Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re.compile fails when compiling bytes under -bb mode #74790

Closed
rowillia mannequin opened this issue Jun 9, 2017 · 4 comments
Closed

re.compile fails when compiling bytes under -bb mode #74790

rowillia mannequin opened this issue Jun 9, 2017 · 4 comments
Assignees
Labels
3.7 (EOL) end of life topic-regex type-bug An unexpected behavior, bug, or error

Comments

@rowillia
Copy link
Mannequin

rowillia mannequin commented Jun 9, 2017

BPO 30605
Nosy @ezio-melotti, @serhiy-storchaka, @rowillia
PRs
  • bpo-30605: Fix compiling binary regexs with BytesWarnings enabled. #2016
  • [3.6] bpo-30605: Fix compiling binary regexs with BytesWarnings enabled. (GH-2016) #2214
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2017-06-15.14:18:21.126>
    created_at = <Date 2017-06-09.00:48:51.019>
    labels = ['expert-regex', 'type-bug', '3.7']
    title = 're.compile fails when compiling bytes under `-bb` mode'
    updated_at = <Date 2017-06-15.14:18:21.125>
    user = 'https://github.com/rowillia'

    bugs.python.org fields:

    activity = <Date 2017-06-15.14:18:21.125>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2017-06-15.14:18:21.126>
    closer = 'serhiy.storchaka'
    components = ['Regular Expressions']
    creation = <Date 2017-06-09.00:48:51.019>
    creator = 'Roy Williams'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30605
    keywords = []
    message_count = 4.0
    messages = ['295473', '295474', '295612', '296090']
    nosy_count = 4.0
    nosy_names = ['ezio.melotti', 'mrabarnett', 'serhiy.storchaka', 'Roy Williams']
    pr_nums = ['2016', '2214']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue30605'
    versions = ['Python 3.6', 'Python 3.7']

    @rowillia
    Copy link
    Mannequin Author

    rowillia mannequin commented Jun 9, 2017

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

    @rowillia rowillia mannequin added 3.7 (EOL) end of life topic-regex labels Jun 9, 2017
    @rowillia
    Copy link
    Mannequin Author

    rowillia mannequin commented Jun 9, 2017

    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
    

    @serhiy-storchaka serhiy-storchaka self-assigned this Jun 9, 2017
    @serhiy-storchaka serhiy-storchaka added the type-bug An unexpected behavior, bug, or error label Jun 9, 2017
    @serhiy-storchaka
    Copy link
    Member

    New changeset 171b9a3 by Serhiy Storchaka (Roy Williams) in branch 'master':
    bpo-30605: Fix compiling binary regexs with BytesWarnings enabled. (bpo-2016)
    171b9a3

    @serhiy-storchaka
    Copy link
    Member

    New changeset 523a243 by Serhiy Storchaka in branch '3.6':
    [3.6] bpo-30605: Fix compiling binary regexs with BytesWarnings enabled. (GH-2016) (bpo-2214)
    523a243

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life topic-regex type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant