Tim Graham <[email protected]> added the comment:
It might be worth adding part of the problematic regex to the warning message.
For Django's tests, I see an error like "FutureWarning: Possible nested set at
position 17 return re.compile(res).match". It took some effort to track down
the source.
A partial traceback is:
File "/home/tim/code/django/django/core/management/commands/loaddata.py",
line 247, in find_fixtures
for candidate in glob.iglob(glob.escape(path) + '*'):
File "/home/tim/code/cpython/Lib/glob.py", line 72, in _iglob
for name in glob_in_dir(dirname, basename, dironly):
File "/home/tim/code/cpython/Lib/glob.py", line 83, in _glob1
return fnmatch.filter(names, pattern)
File "/home/tim/code/cpython/Lib/fnmatch.py", line 52, in filter
match = _compile_pattern(pat)
File "/home/tim/code/cpython/Lib/fnmatch.py", line 46, in _compile_pattern
return re.compile(res).match
File "/home/tim/code/cpython/Lib/re.py", line 240, in compile
return _compile(pattern, flags)
File "/home/tim/code/cpython/Lib/re.py", line 292, in _compile
p = sre_compile.compile(pattern, flags)
File "/home/tim/code/cpython/Lib/sre_compile.py", line 764, in compile
p = sre_parse.parse(p, flags)
File "/home/tim/code/cpython/Lib/sre_parse.py", line 930, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "/home/tim/code/cpython/Lib/sre_parse.py", line 426, in _parse_sub
not nested and not items))
File "/home/tim/code/cpython/Lib/sre_parse.py", line 816, in _parse
p = _parse_sub(source, state, sub_verbose, nested + 1)
File "/home/tim/code/cpython/Lib/sre_parse.py", line 426, in _parse_sub
not nested and not items))
File "/home/tim/code/cpython/Lib/sre_parse.py", line 524, in _parse
FutureWarning, stacklevel=nested + 6
FutureWarning: Possible nested set at position 17
As an aside, I'm not sure how to fix the warning in Django. It comes from the
test added in
https://github.com/django/django/commit/98df288ddaba9787e4a370f12aba51c2b9133142
where a path like 'tests/fixtures/fixtures/fixture_with[special]chars' is run
through glob.escape() which creates
'tests/fixtures/fixtures/fixture_with[[]special]chars'.
----------
nosy: +Tim.Graham
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue30349>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com