diff --git a/Cython/Utils.py b/Cython/Utils.py index b3bfd8602f8..529f70ba3f0 100644 --- a/Cython/Utils.py +++ b/Cython/Utils.py @@ -316,7 +316,10 @@ def find_versioned_file(directory, filename, suffix, assert not suffix or suffix[:1] == '.' path_prefix = os.path.join(directory, filename) - matching_files = glob.glob(path_prefix + ".cython-*" + suffix) + matching_files = glob.glob( + (glob.escape(path_prefix) if sys.version_info >= (3, 4) else + ''.join([ '['+c+']' if c in '[*?' else c for c in path_prefix])) + + ".cython-*" + suffix) path = path_prefix + suffix if not os.path.exists(path): path = None diff --git a/tests/run/sys_path_globbed.srctree b/tests/run/sys_path_globbed.srctree new file mode 100644 index 00000000000..6386cab8b76 --- /dev/null +++ b/tests/run/sys_path_globbed.srctree @@ -0,0 +1,21 @@ +# tag: gh5942 + +PYTHON setup.py build_ext --inplace +PYTHON -c "from tglob import mytest; mytest()" + +######## tglob.pyx ######## +def mytest(): + assert True + +######## setup.py ######## +import sys + +from Cython.Build.Dependencies import cythonize +from distutils.core import setup, Extension + +sys.path.append("[Hello-World]*?") + +setup( + ext_modules=cythonize(["tglob.pyx"], language_level="3"), +) +