From ede1af29d210311f5f033f7226da58a19f197183 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 4 Jan 2025 05:23:51 -0500 Subject: [PATCH] Add tests and fix failure identified in the tests. --- distutils/ccompiler.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/distutils/ccompiler.py b/distutils/ccompiler.py index 9b637f8c..7b5baaf9 100644 --- a/distutils/ccompiler.py +++ b/distutils/ccompiler.py @@ -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). @@ -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