Skip to content

Replace raw strings with bytes literal as iterator sentinels in checksum calculation#2446

Merged
boegel merged 1 commit intoeasybuilders:developfrom
vanzod:chksum_sentinel
Mar 16, 2018
Merged

Replace raw strings with bytes literal as iterator sentinels in checksum calculation#2446
boegel merged 1 commit intoeasybuilders:developfrom
vanzod:chksum_sentinel

Conversation

@vanzod
Copy link
Copy Markdown
Member

@vanzod vanzod commented Mar 16, 2018

When porting the same construct in Python 3, the use of r'' as iterator sentinel result in an infinite loop.
This can be solved by replacing it with a bytes literal.

Useful for future Python 3 compatibility since raw strings do not seem to work as interator sentinel
@boegel
Copy link
Copy Markdown
Member

boegel commented Mar 16, 2018

tests fail, but for a reason unrelated to this PR, follow up in #2447 ...

@boegel boegel added this to the 3.6.0 milestone Mar 16, 2018
Copy link
Copy Markdown
Member

@boegel boegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@easybuilders easybuilders deleted a comment from boegelbot Mar 16, 2018
@boegel
Copy link
Copy Markdown
Member

boegel commented Mar 16, 2018

Based on https://docs.python.org/2/whatsnew/2.6.html#pep-3112-byte-literals and this:

$ python
Python 2.7.5 (default, Aug  4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> r'' == b''
True
  • the passing tests, this is good to go. One tiny step towards supporting Python 3... Thanks @vanzod!

@boegel boegel merged commit 49f847a into easybuilders:develop Mar 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants