Skip to content

Commit ede1af2

Browse files
committed
Add tests and fix failure identified in the tests.
1 parent 57152cf commit ede1af2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

distutils/ccompiler.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,13 @@ def _make_out_path(self, output_dir, strip_dir, src_name):
976976

977977
@classmethod
978978
def _make_out_path_exts(cls, output_dir, strip_dir, src_name, extensions):
979+
r"""
980+
>>> exts = {'.c': '.o'}
981+
>>> CCompiler._make_out_path_exts('.', False, '/foo/bar.c', exts).replace('\\', '/')
982+
'./foo/bar.o'
983+
>>> CCompiler._make_out_path_exts('.', True, '/foo/bar.c', exts).replace('\\', '/')
984+
'./bar.o'
985+
"""
979986
base, ext = os.path.splitext(src_name)
980987
base = pathlib.PurePath(base)
981988
# Ensure base is relative to honor output_dir (python/cpython#37775).
@@ -985,7 +992,7 @@ def _make_out_path_exts(cls, output_dir, strip_dir, src_name, extensions):
985992
except LookupError:
986993
raise UnknownFileError(f"unknown file type '{ext}' (from '{src_name}')")
987994
if strip_dir:
988-
base = base.name
995+
base = pathlib.PurePath(base.name)
989996
return os.path.join(output_dir, base.with_suffix(new_ext))
990997

991998
@staticmethod

0 commit comments

Comments
 (0)