-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix/improve comparison of byte strings #5267
Conversation
Codecov Report
@@ Coverage Diff @@
## features #5267 +/- ##
============================================
+ Coverage 92.07% 93.24% +1.16%
============================================
Files 115 115
Lines 26159 26356 +197
Branches 2578 2623 +45
============================================
+ Hits 24086 24575 +489
+ Misses 1746 1465 -281
+ Partials 327 316 -11
Continue to review full report at Codecov.
|
Azure failure is unrelated. |
if PY3: | ||
assert diff == [ | ||
"b'spam' == b'eggs'", | ||
"At index 0 diff: 115 != 101", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm I thought that we wouldn't see this line, but only see the - b'spam'
+ b'eggs'
bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No - it just skips the "contains more items" now.
I think it is fine / useful, although it could mention that those a bytes / ordinals.
If so, how should it sound like then?
Or should we skip any handling (i.e. as a sequence) for bytes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm I'd like to still see the reprdiff since I think that's useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using the slice operator instead?
>>> b'foo'[0]
102
>>> b'foo'[0:1]
b'f'
We will then be able to see "At index 0 diff: b's' != b'e'"
, which is readable and has no downsides as far as I can see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a special case for bytes on py3 then, or for sequences in general?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, as a special case for bytes on py3. For sequences it is not clear to me it would be better than what we have now, at least for me.
|
By "later" you mean after dropping Python 2 in 4.6/4.7? |
Gentle ping :) |
Busy pong.. ;) |
Superseded by #5495 |
Improve comparison of byte strings (supersedes #5267)
Fixes #5260.