New submission from Chris Seto: Expected behavior: ~ ❯❯❯ pyenv shell 3.5.2 ~ ❯❯❯ python --version Python 3.5.2 ~ ❯❯❯ python Python 3.5.2 (default, Oct 24 2016, 00:12:20) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> re.compile('[^\B]') re.compile('[^\\B]') >>> re.compile(r'[^\B]') re.compile('[^\\B]')
Actual: ~ ❯❯❯ pyenv shell 3.6.0 ~ ❯❯❯ python --version Python 3.6.0 ~ ❯❯❯ python Python 3.6.0 (default, Apr 26 2017, 17:24:07) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> re.compile('[^\B]') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/re.py", line 233, in compile return _compile(pattern, flags) File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/re.py", line 301, in _compile p = sre_compile.compile(pattern, flags) File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/sre_compile.py", line 562, in compile p = sre_parse.parse(p, flags) File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/sre_parse.py", line 856, in parse p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, False) File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/sre_parse.py", line 415, in _parse_sub itemsappend(_parse(source, state, verbose)) File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/sre_parse.py", line 526, in _parse code1 = _class_escape(source, this) File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/sre_parse.py", line 336, in _class_escape raise source.error('bad escape %s' % escape, len(escape)) sre_constants.error: bad escape \B at position 2 >>> re.compile(r'[^\B]') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/re.py", line 233, in compile return _compile(pattern, flags) File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/re.py", line 301, in _compile p = sre_compile.compile(pattern, flags) File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/sre_compile.py", line 562, in compile p = sre_parse.parse(p, flags) File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/sre_parse.py", line 856, in parse p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, False) File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/sre_parse.py", line 415, in _parse_sub itemsappend(_parse(source, state, verbose)) File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/sre_parse.py", line 526, in _parse code1 = _class_escape(source, this) File "/Users/chrisseto/.pyenv/versions/3.6.0/lib/python3.6/sre_parse.py", line 336, in _class_escape raise source.error('bad escape %s' % escape, len(escape)) sre_constants.error: bad escape \B at position 2 ---------- components: Regular Expressions messages: 292445 nosy: Chris Seto2, ezio.melotti, mrabarnett priority: normal severity: normal status: open title: Regex becomes invalid in python 3.6 type: behavior versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30187> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com