While converting a bunch of werkzeug code to Python 3.1, I ran into an issue with one of the bytes objects that was previously a string.
The line of code in question was originally this:
if value and value == value[-1] == b'"': ...
If value is something, and the first and last characters are a quote character, then…
However, as it turns out, the bytes object is actually a list of integers in the range of 0-255.
So when you use an indexing operation on a byte, you actually get an integer back. For example:>>> x = b'Hello World' >>> x 72 >>> x = 'Hello World' >>> x 'H'
Big difference, eh?