classification
Title: fnmatch.translate() can produce a pattern which emits a nested set warning
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Tim.Graham, serhiy.storchaka
Priority: high Keywords: patch

Created on 2018-02-05 20:07 by Tim.Graham, last changed 2018-02-09 11:57 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 5583 merged serhiy.storchaka, 2018-02-07 17:17
PR 5596 merged miss-islington, 2018-02-09 11:31
Messages (4)
msg311687 - (view) Author: Tim Graham (Tim.Graham) * Date: 2018-02-05 20:07
As discussed in issue30349#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')
msg311689 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-05 20:17
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
msg311878 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-09 11:30
New changeset 23cdbfa744f0ec0e9e7575d378df4cb758691cd3 by Serhiy Storchaka in branch 'master':
bpo-32775: Fix regular expression warnings in fnmatch. (#5583)
https://github.com/python/cpython/commit/23cdbfa744f0ec0e9e7575d378df4cb758691cd3
msg311881 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-09 11:56
New changeset 0e361730b0954f7560640dd932f00f507e328c45 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.7':
bpo-32775: Fix regular expression warnings in fnmatch. (GH-5583) (GH-5596)
https://github.com/python/cpython/commit/0e361730b0954f7560640dd932f00f507e328c45
History
Date User Action Args
2018-02-09 11:57:42serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-02-09 11:56:55serhiy.storchakasetmessages: + msg311881
2018-02-09 11:31:30miss-islingtonsetpull_requests: + pull_request5412
2018-02-09 11:30:22serhiy.storchakasetmessages: + msg311878
2018-02-07 17:17:38serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request5400
2018-02-05 20:17:37serhiy.storchakasetpriority: normal -> high
assignee: serhiy.storchaka
messages: + msg311689
2018-02-05 20:07:22Tim.Grahamcreate