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

fnmatch.translate() can produce a pattern which emits a nested set warning #76956

Closed
timgraham mannequin opened this issue Feb 5, 2018 · 4 comments
Closed

fnmatch.translate() can produce a pattern which emits a nested set warning #76956

timgraham mannequin opened this issue Feb 5, 2018 · 4 comments
Assignees
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@timgraham
Copy link
Mannequin

timgraham mannequin commented Feb 5, 2018

BPO 32775
Nosy @serhiy-storchaka, @timgraham
PRs
  • bpo-32775: Fix regular expression warnings in fnmatch. #5583
  • [3.7] bpo-32775: Fix regular expression warnings in fnmatch. (GH-5583) #5596
  • 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 2018-02-09.11:57:42.153>
    created_at = <Date 2018-02-05.20:07:22.506>
    labels = ['3.7', 'type-bug', 'library']
    title = 'fnmatch.translate() can produce a pattern which emits a nested set warning'
    updated_at = <Date 2018-02-09.11:57:42.152>
    user = 'https://github.com/timgraham'

    bugs.python.org fields:

    activity = <Date 2018-02-09.11:57:42.152>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2018-02-09.11:57:42.153>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2018-02-05.20:07:22.506>
    creator = 'Tim.Graham'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32775
    keywords = ['patch']
    message_count = 4.0
    messages = ['311687', '311689', '311878', '311881']
    nosy_count = 2.0
    nosy_names = ['serhiy.storchaka', 'Tim.Graham']
    pr_nums = ['5583', '5596']
    priority = 'high'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue32775'
    versions = ['Python 3.7']

    @timgraham
    Copy link
    Mannequin Author

    timgraham mannequin commented Feb 5, 2018

    As discussed in bpo-30349#msg311684, fnmatch.translate() can produce a pattern which emits a nested set warning:

    >>> import fnmatch, re
    >>> re.compile(fnmatch.translate('[[]foo]'))
    __main__:1: FutureWarning: Possible nested set at position 10
    re.compile('(?s:\\(.s:[[]foo\\\\\\]\\)\\\\Z)\\Z')

    @timgraham timgraham mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 5, 2018
    @serhiy-storchaka
    Copy link
    Member

    It is easy to fix sets starting with '['. It is more hard to fix sets with doubled '-', '&', '|' or '~'.

    >>> fnmatch.fnmatch('#', '[#--]')
    /home/serhiy/py/cpython/Lib/fnmatch.py:46: FutureWarning: Possible set difference at position 6
      return re.compile(res).match
    True

    @serhiy-storchaka serhiy-storchaka self-assigned this Feb 5, 2018
    @serhiy-storchaka
    Copy link
    Member

    New changeset 23cdbfa by Serhiy Storchaka in branch 'master':
    bpo-32775: Fix regular expression warnings in fnmatch. (bpo-5583)
    23cdbfa

    @serhiy-storchaka
    Copy link
    Member

    New changeset 0e36173 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.7':
    bpo-32775: Fix regular expression warnings in fnmatch. (GH-5583) (GH-5596)
    0e36173

    @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 stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant