Skip to content

Commit

Permalink
Simply accept pathlib objects and convert them early for compatibilty…
Browse files Browse the repository at this point in the history
… with upstream.
  • Loading branch information
jaraco committed Jul 19, 2024
1 parent f2a85c1 commit 424bd98
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion distutils/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(
)

self.name = name
self.sources = list(map(pathlib.Path, sources))
self.sources = list(map(os.fspath, sources))
self.include_dirs = include_dirs or []
self.define_macros = define_macros or []
self.undef_macros = undef_macros or []
Expand Down
2 changes: 1 addition & 1 deletion distutils/filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def exclude_pattern(self, pattern, anchor=1, prefix=None, is_regex=0):
pattern_re = translate_pattern(pattern, anchor, prefix, is_regex)
self.debug_print("exclude_pattern: applying regex r'%s'" % pattern_re.pattern)
for i in range(len(self.files) - 1, -1, -1):
if pattern_re.search(str(self.files[i])):
if pattern_re.search(self.files[i]):
self.debug_print(" removing " + self.files[i])
del self.files[i]
files_found = True
Expand Down
2 changes: 1 addition & 1 deletion distutils/tests/test_build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def test_get_source_files(self):
dist = Distribution({'name': 'xx', 'ext_modules': modules})
cmd = self.build_ext(dist)
cmd.ensure_finalized()
assert cmd.get_source_files() == [pathlib.Path('xxx')]
assert cmd.get_source_files() == ['xxx']

def test_unicode_module_names(self):
modules = [
Expand Down
4 changes: 2 additions & 2 deletions distutils/tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def test_extension_init(self):
with pytest.raises(AssertionError):
Extension('name', ['file', 1])
ext = Extension('name', ['file1', 'file2'])
assert ext.sources == [Path('file1'), Path('file2')]
assert ext.sources == ['file1', 'file2']
ext = Extension('name', [Path('file1'), Path('file2')])
assert ext.sources == [Path('file1'), Path('file2')]
assert ext.sources == ['file1', 'file2']

# others arguments have defaults
for attr in (
Expand Down

0 comments on commit 424bd98

Please sign in to comment.