Skip to content

Commit

Permalink
Tolerate literal globs (GH-5942 backport to 3.0.x) (GH-5961)
Browse files Browse the repository at this point in the history
Closes #5942
  • Loading branch information
eewanco committed Feb 27, 2024
1 parent ead1ac6 commit f2954a0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Cython/Utils.py
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions 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"),
)

0 comments on commit f2954a0

Please sign in to comment.