Skip to content

Commit

Permalink
Add tests and fix failure identified in the tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jan 4, 2025
1 parent 57152cf commit ede1af2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion distutils/ccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,13 @@ def _make_out_path(self, output_dir, strip_dir, src_name):

@classmethod
def _make_out_path_exts(cls, output_dir, strip_dir, src_name, extensions):
r"""
>>> exts = {'.c': '.o'}
>>> CCompiler._make_out_path_exts('.', False, '/foo/bar.c', exts).replace('\\', '/')
'./foo/bar.o'
>>> CCompiler._make_out_path_exts('.', True, '/foo/bar.c', exts).replace('\\', '/')
'./bar.o'
"""
base, ext = os.path.splitext(src_name)
base = pathlib.PurePath(base)
# Ensure base is relative to honor output_dir (python/cpython#37775).
Expand All @@ -985,7 +992,7 @@ def _make_out_path_exts(cls, output_dir, strip_dir, src_name, extensions):
except LookupError:
raise UnknownFileError(f"unknown file type '{ext}' (from '{src_name}')")
if strip_dir:
base = base.name
base = pathlib.PurePath(base.name)
return os.path.join(output_dir, base.with_suffix(new_ext))

@staticmethod
Expand Down

0 comments on commit ede1af2

Please sign in to comment.