Skip invalid escape sequence check on 2.6#763
Skip invalid escape sequence check on 2.6#763sigmavirus24 wants to merge 1 commit intoPyCQA:masterfrom
Conversation
|
cc @jwilk |
| Okay: regex = r'\.png$' | ||
| W605: regex = '\.png$' | ||
| """ | ||
| if (2, 5) < sys.version_info <= (2, 6): |
There was a problem hiding this comment.
This condition is off-by-one: it's true in Python 2.5 (which doesn't have b'' strings, so not affected by this bug), but false in Python 2.6. How about:
if sys.version_info[:2] == (2, 6):?
There was a problem hiding this comment.
Thanks, I've updated the range to be correct.
Python 2.6 has a bug (https://bugs.python.org/issue15054) that prevents us from tokenizing strings properly that are b'' strings. This means we cannot reliably detect future deprecated escape sequences on 2.6 Closes PyCQAgh-755
|
Guessing that a unit test needs updating? |
|
FWIW I can reproduce this when using Python2 and trying to escape square brackets:
|
You should absolutely see this on 2.7. It's not that it's a problem on 2.7 but if your code lives past 2020, you should be well-warned that it will break on the latest versions of 3.7 and there are things you can do today to avoid that. |
|
Thanks, though I still feel like I'm missing something 'cos the docs / internet search seems to suggest escaping square brackets is ok. https://docs.python.org/3/library/re.html
Anyhoo, gonna use |
|
|
|
Thanks again, found the pbk&c, :-S the following are different. |
|
@jones77 I'm not certain if you're looking for an explanation or if you're merely commenting on the ability to use |
|
Given the comments in #720, Python 2.6 support will be dropped. So perhaps this PR is no longer required? |
Python 2.6 has a bug (https://bugs.python.org/issue15054) that prevents
us from tokenizing strings properly that are b'' strings. This means we
cannot reliably detect future deprecated escape sequences on 2.6
Closes gh-755