diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-02-09 11:30:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-09 11:30:19 (GMT) |
commit | 23cdbfa744f0ec0e9e7575d378df4cb758691cd3 (patch) | |
tree | 3801132c5618951ad64c32f9609bb2524a55eff3 /Lib/test/test_fnmatch.py | |
parent | feaefc7f60cd3be7bf4ecc2b73e77d2bfe048403 (diff) | |
download | cpython-23cdbfa744f0ec0e9e7575d378df4cb758691cd3.zip cpython-23cdbfa744f0ec0e9e7575d378df4cb758691cd3.tar.gz cpython-23cdbfa744f0ec0e9e7575d378df4cb758691cd3.tar.bz2 |
bpo-32775: Fix regular expression warnings in fnmatch. (#5583)
fnmatch.translate() no longer produces patterns which contain set
operations.
Sets starting with '[' or containing '--', '&&', '~~' or '||' will
be interpreted differently in regular expressions in future versions.
Currently they emit warnings. fnmatch.translate() now avoids producing
patterns containing such sets by accident.
Diffstat (limited to 'Lib/test/test_fnmatch.py')
-rw-r--r-- | Lib/test/test_fnmatch.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py index 78245c3..55f9f0d 100644 --- a/Lib/test/test_fnmatch.py +++ b/Lib/test/test_fnmatch.py @@ -2,6 +2,7 @@ import unittest import os +import warnings from fnmatch import fnmatch, fnmatchcase, translate, filter @@ -83,6 +84,17 @@ class FnmatchTestCase(unittest.TestCase): check('usr/bin', 'usr\\bin', normsep) check('usr\\bin', 'usr\\bin') + def test_warnings(self): + with warnings.catch_warnings(): + warnings.simplefilter('error', Warning) + check = self.check_match + check('[', '[[]') + check('&', '[a&&b]') + check('|', '[a||b]') + check('~', '[a~~b]') + check(',', '[a-z+--A-Z]') + check('.', '[a-z--/A-Z]') + class TranslateTestCase(unittest.TestCase): |