[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-20 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- resolution: -> fixed stage: commit review -> resolved status: open -> closed ___ Python tracker ___

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-20 Thread Roundup Robot
Roundup Robot added the comment: New changeset 104c55bc2276 by Serhiy Storchaka in branch '3.4': Issue #23681: Fixed Python 2 to 3 poring bugs. https://hg.python.org/cpython/rev/104c55bc2276 New changeset 817f1f47824c by Serhiy Storchaka in branch 'default': Issue #23681: Fixed Python 2 to 3 por

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-20 Thread Brett Cannon
Brett Cannon added the comment: I did one final pass on the patch and only had wording comments, so tweak those and it LGTM. Assigned to Serhiy since it's obviously his patch. =) Only other thing is to either open up a separate bug or at least apply the fixes to the stdlib in Python 3.4 as wel

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-20 Thread STINNER Victor
STINNER Victor added the comment: > This will help when someone writes something like `b'abcd'[2] == b'c'` What if someone writes line[-1] == 0 and line is a Unicode string? Should we emit a warning? I patched locally PyUnicode_RichCompare() to emit a warning. Hum, there are *many* warnings i

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: @Brett: Yes, the patch handles `42 == b'*'` as well. @Victor: The problem in such code: x = b'Array' x[0] == b'A' Added explicit tests for bytes on the right side of the comparison and replaced b'.'[0] to ord(b'.'). -- Added file: http://bugs.pyth

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-20 Thread STINNER Victor
STINNER Victor added the comment: I didn't understand the issue. $ python2 >>> b'A'[0] == 65 False $ python3 Python 3.4.1 (default, Nov 3 2014, 14:38:10) >>> b'A'[0] == 65 True Oh ok, now I get it: Python 2 and Python 3 behaves differently when comparing a string of a single byte and an int

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-19 Thread Martin Panter
Changes by Martin Panter : -- nosy: +vadmium ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-19 Thread Paul Moore
Paul Moore added the comment: LGTM, just one minor comment in review. -- nosy: +paul.moore ___ Python tracker ___ ___ Python-bugs-list

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-16 Thread Berker Peksag
Berker Peksag added the comment: > [...] fixes existing bugs in the stdlib and tests. These changes should probably be backported to 3.4. -- nosy: +berker.peksag ___ Python tracker

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-16 Thread Claudiu Popa
Changes by Claudiu Popa : -- nosy: +Claudiu.Popa ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here is a patch that adds required feature and fixes existing bugs in the stdlib and tests. No one of failed tests was false positive. -- keywords: +patch stage: test needed -> patch review Added file: http://bugs.python.org/file38511/bytes_to_int_co

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: 6 tests failed: test_buffer test_poplib test_quopri test_smtpd test_sunau test_tokenize And all of them look as bugs. -- nosy: +serhiy.storchaka ___ Python tracker _

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-16 Thread Brett Cannon
Changes by Brett Cannon : -- versions: +Python 3.5 -Python 2.7 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-16 Thread Brett Cannon
Changes by Brett Cannon : -- priority: normal -> deferred blocker ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-16 Thread Brett Cannon
New submission from Brett Cannon: To help writing Python 2/3 code the -b flag should switch on a warning when comparing an int to a bytes object in Python 2. This will help when someone writes something like `b'abcd'[2] == b'c'` and it always returns False thanks to the indexing returning 99 i

[issue23681] Have -b warn when directly comparing ints and bytes

2015-03-16 Thread Brett Cannon
Changes by Brett Cannon : -- priority: deferred blocker -> release blocker ___ Python tracker ___ ___ Python-bugs-list mailing list Un