This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: re.compile fails when compiling bytes under `-bb` mode
Type: behavior Stage: resolved
Components: Regular Expressions Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Roy Williams, ezio.melotti, mrabarnett, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-06-09 00:48 by Roy Williams, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 2016 merged Roy Williams, 2017-06-09 01:02
PR 2214 merged serhiy.storchaka, 2017-06-15 13:21
Messages (4)
msg295473 - (view) Author: Roy Williams (Roy Williams) * Date: 2017-06-09 00:48
import re
re.compile(br'^(.*?)$(?m)')
msg295474 - (view) Author: Roy Williams (Roy Williams) * Date: 2017-06-09 00:50
Repro:

```
import re
re.compile(br'^(.*?)$(?m)')
```

Results in
```
Traceback (most recent call last):
  File "test_compile.py", line 2, in <module>
    re.compile(br'^(.*?)$(?m)')
  File "/usr/lib/python3.6/re.py", line 233, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python3.6/re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.6/sre_compile.py", line 562, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.6/sre_parse.py", line 856, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, False)
  File "/usr/lib/python3.6/sre_parse.py", line 415, in _parse_sub
    itemsappend(_parse(source, state, verbose))
  File "/usr/lib/python3.6/sre_parse.py", line 741, in _parse
    ' (truncated)' if len(source.string) > 20 else '',
BytesWarning: str() on a bytes instance
```
msg295612 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-10 05:01
New changeset 171b9a354e816eebc6d4c3a8553303942e9c5025 by Serhiy Storchaka (Roy Williams) in branch 'master':
bpo-30605: Fix compiling binary regexs with BytesWarnings enabled. (#2016)
https://github.com/python/cpython/commit/171b9a354e816eebc6d4c3a8553303942e9c5025
msg296090 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-15 13:55
New changeset 523a243840feb4d5f444a1b128e540876afac3d2 by Serhiy Storchaka in branch '3.6':
[3.6] bpo-30605: Fix compiling binary regexs with BytesWarnings enabled. (GH-2016) (#2214)
https://github.com/python/cpython/commit/523a243840feb4d5f444a1b128e540876afac3d2
History
Date User Action Args
2022-04-11 14:58:47adminsetgithub: 74790
2017-06-15 14:18:21serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: backport needed -> resolved
2017-06-15 13:55:24serhiy.storchakasetmessages: + msg296090
2017-06-15 13:21:43serhiy.storchakasetpull_requests: + pull_request2258
2017-06-10 05:03:19serhiy.storchakasetstage: patch review -> backport needed
2017-06-10 05:01:18serhiy.storchakasetmessages: + msg295612
2017-06-09 06:10:49serhiy.storchakasetassignee: serhiy.storchaka

type: behavior
nosy: + serhiy.storchaka
stage: patch review
2017-06-09 01:02:37Roy Williamssetpull_requests: + pull_request2081
2017-06-09 00:50:30Roy Williamssetmessages: + msg295474
2017-06-09 00:48:51Roy Williamscreate