From 6a3d5ad61504965ec3a94a93f804b1f97ccd3b71 Mon Sep 17 00:00:00 2001 From: Ian Stapleton Cordasco Date: Wed, 25 Apr 2018 18:01:44 -0500 Subject: [PATCH] Skip invalid escape sequence check on 2.6 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 --- pycodestyle.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pycodestyle.py b/pycodestyle.py index f545cc0e..e9f70f9d 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -1487,6 +1487,13 @@ def python_3000_invalid_escape_sequence(logical_line, tokens): Okay: regex = r'\.png$' W605: regex = '\.png$' """ + if (2, 6) < sys.version_info <= (2, 7): + # NOTE(sigmavirus24): There's a bug on 2.6 + # (https://bugs.python.org/issue15054) that prevents the tokenizer + # from handling bytestrings appropriately. That means this check + # produces false-positives. Instead, let's simply skip this. + return + # https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals valid = [ '\n',