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
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:
Changes by Serhiy Storchaka storch...@gmail.com:
--
resolution: - fixed
stage: commit review - resolved
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23681
___
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
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
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 integer.
Paul Moore added the comment:
LGTM, just one minor comment in review.
--
nosy: +paul.moore
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23681
___
Changes by Martin Panter vadmium...@gmail.com:
--
nosy: +vadmium
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23681
___
___
Python-bugs-list
Changes by Brett Cannon br...@python.org:
--
priority: deferred blocker - release blocker
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23681
___
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
Changes by Brett Cannon br...@python.org:
--
priority: normal - deferred blocker
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23681
___
___
Changes by Brett Cannon br...@python.org:
--
versions: +Python 3.5 -Python 2.7
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23681
___
___
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 rep...@bugs.python.org
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 rep...@bugs.python.org
http://bugs.python.org/issue23681
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:
Changes by Claudiu Popa pcmantic...@gmail.com:
--
nosy: +Claudiu.Popa
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23681
___
___
Python-bugs-list
16 matches
Mail list logo