New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Byte warning mode and b'' != '' #48238
Comments
In byte warning mode (-b or -bb command line argument) b'' == '' raises ./python -bb
>>> b'' == ''
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
BytesWarning: Comparison between bytes and string
>>> b'' != ''
True I can't recall why I implemented the byte warning mode this way. But |
+1 I was just confused by this fact yesterday. :) |
+1 as well. Lib/pty.py had a line like that ("while buf != ''") and I |
Here is a patch for this issue. |
Thanks for the patch but you've missed a spot in bytearrayobject.c: Objects/bytearrayobject.c: if (Py_BytesWarningFlag && op == Py_EQ) { |
It would also be nice to have tests. (in test_bytes) |
@christian.heimes: Oops, i totally forget the bytearray() type. Here |
I don't know how to activate BytesWarning as error (as "python3 -bb" |
warnings.simplefilter("always", BytesWarning) should do the trick. |
Setting as a deferred blocker since this is a 3.0 thing and not a 2.6 thing. |
New patch including the test. The test doesn't fail anymore if -bb is |
r66950 |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: