On Python 2, you are still confusing types (bytes vs strings) - conceptually even if technically the code works. So even if it works by accident, your logic must be wrong somewhere.