Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion distutils/compilers/C/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Compiler:
# dictionary (see below -- used by the 'new_compiler()' factory
# function) -- authors of new compiler interface classes are
# responsible for updating 'compiler_class'!
compiler_type: ClassVar[str] = None # type: ignore[assignment]
compiler_type: ClassVar[str] = None
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be added back in #368 , but tests currently fails with this due to unused type-ignore


# XXX things not handled by this compiler abstraction model:
# * client can't provide additional options for a compiler,
Expand Down
23 changes: 12 additions & 11 deletions distutils/tests/test_filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import os
import re
import sys
from distutils import debug, filelist
from distutils.errors import DistutilsTemplateError
from distutils.filelist import FileList, glob_to_re, translate_pattern
Expand Down Expand Up @@ -45,22 +46,22 @@ def assertWarnings(self, caplog):
caplog.clear()

def test_glob_to_re(self):
sep = os.sep
if os.sep == '\\':
sep = re.escape(os.sep)
sep = re.escape(os.sep) if os.sep == '\\' else os.sep
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively:

Suggested change
sep = re.escape(os.sep) if os.sep == '\\' else os.sep
sep = r"\\" if os.sep == "\\" else os.sep

or even:

Suggested change
sep = re.escape(os.sep) if os.sep == '\\' else os.sep
sep = re.escape(os.sep)

# https://docs.python.org/3/whatsnew/3.14.html#re
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end_of_str_metachar = r"\z" if sys.version_info >= (3, 14) else r"\Z"

for glob, regex in (
# simple cases
('foo*', r'(?s:foo[^%(sep)s]*)\Z'),
('foo?', r'(?s:foo[^%(sep)s])\Z'),
('foo??', r'(?s:foo[^%(sep)s][^%(sep)s])\Z'),
('foo*', r'(?s:foo[^%(sep)s]*)%(eos)s'),
('foo?', r'(?s:foo[^%(sep)s])%(eos)s'),
('foo??', r'(?s:foo[^%(sep)s][^%(sep)s])%(eos)s'),
# special cases
(r'foo\\*', r'(?s:foo\\\\[^%(sep)s]*)\Z'),
(r'foo\\\*', r'(?s:foo\\\\\\[^%(sep)s]*)\Z'),
('foo????', r'(?s:foo[^%(sep)s][^%(sep)s][^%(sep)s][^%(sep)s])\Z'),
(r'foo\\??', r'(?s:foo\\\\[^%(sep)s][^%(sep)s])\Z'),
(r'foo\\*', r'(?s:foo\\\\[^%(sep)s]*)%(eos)s'),
(r'foo\\\*', r'(?s:foo\\\\\\[^%(sep)s]*)%(eos)s'),
('foo????', r'(?s:foo[^%(sep)s][^%(sep)s][^%(sep)s][^%(sep)s])%(eos)s'),
(r'foo\\??', r'(?s:foo\\\\[^%(sep)s][^%(sep)s])%(eos)s'),
):
regex = regex % {'sep': sep}
regex = regex % {'sep': sep, 'eos': end_of_str_metachar}
assert glob_to_re(glob) == regex

def test_process_template_line(self):
Expand Down
Loading