Message371903
It is common to use glob() as
glob.glob(os.path.join(basedir, pattern))
But it does not work correctly if the base directory contains special globbing characters ('*', '?', '['). It is an uncommon case, so in most cases the code works. But when move sources to the directory containing special characters, built it and run tests, some tests will fail:
test test_tokenize failed -- Traceback (most recent call last):
File "/home/serhiy/py/[cpython]/Lib/test/test_tokenize.py", line 1615, in test_random_files
testfiles.remove(os.path.join(tempdir, "test_unicode_identifiers.py"))
ValueError: list.remove(x): x not in list
test test_multiprocessing_fork failed -- Traceback (most recent call last):
File "/home/serhiy/py/[cpython]/Lib/test/_test_multiprocessing.py", line 4272, in test_import
modules = self.get_module_names()
File "/home/serhiy/py/[cpython]/Lib/test/_test_multiprocessing.py", line 4267, in get_module_names
modules.remove('multiprocessing.__init__')
ValueError: list.remove(x): x not in list
test test_bz2 failed -- Traceback (most recent call last):
File "/home/serhiy/py/[cpython]/Lib/test/test_bz2.py", line 740, in testDecompressorChunksMaxsize
self.assertFalse(bzd.needs_input)
AssertionError: True is not false
test test_multiprocessing_forkserver failed -- Traceback (most recent call last):
File "/home/serhiy/py/[cpython]/Lib/test/_test_multiprocessing.py", line 4272, in test_import
modules = self.get_module_names()
File "/home/serhiy/py/[cpython]/Lib/test/_test_multiprocessing.py", line 4267, in get_module_names
modules.remove('multiprocessing.__init__')
ValueError: list.remove(x): x not in list
test test_multiprocessing_spawn failed -- Traceback (most recent call last):
File "/home/serhiy/py/[cpython]/Lib/test/_test_multiprocessing.py", line 4272, in test_import
modules = self.get_module_names()
File "/home/serhiy/py/[cpython]/Lib/test/_test_multiprocessing.py", line 4267, in get_module_names
modules.remove('multiprocessing.__init__')
ValueError: list.remove(x): x not in list
The proposed PR adds glob.escape() to the above code:
glob.glob(os.path.join(glob.escape(basedir), pattern)) |
|
Date |
User |
Action |
Args |
2020-06-19 21:16:43 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka |
2020-06-19 21:16:43 | serhiy.storchaka | set | messageid: <1592601403.75.0.126611663451.issue41043@roundup.psfhosted.org> |
2020-06-19 21:16:43 | serhiy.storchaka | link | issue41043 messages |
2020-06-19 21:16:43 | serhiy.storchaka | create | |
|