From 36ce8b329524088cfa53b9a4bffcce3a8d233539 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 4 Jan 2025 05:38:01 -0500 Subject: [PATCH] Refactor for simplicity. --- distutils/ccompiler.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/distutils/ccompiler.py b/distutils/ccompiler.py index 7b5baaf9ae..714f13d8d3 100644 --- a/distutils/ccompiler.py +++ b/distutils/ccompiler.py @@ -983,14 +983,13 @@ def _make_out_path_exts(cls, output_dir, strip_dir, src_name, extensions): >>> CCompiler._make_out_path_exts('.', True, '/foo/bar.c', exts).replace('\\', '/') './bar.o' """ - base, ext = os.path.splitext(src_name) - base = pathlib.PurePath(base) + src = pathlib.PurePath(src_name) # Ensure base is relative to honor output_dir (python/cpython#37775). - base = cls._make_relative(base) + base = cls._make_relative(src) try: - new_ext = extensions[ext] + new_ext = extensions[src.suffix] except LookupError: - raise UnknownFileError(f"unknown file type '{ext}' (from '{src_name}')") + raise UnknownFileError(f"unknown file type '{src.suffix}' (from '{src}')") if strip_dir: base = pathlib.PurePath(base.name) return os.path.join(output_dir, base.with_suffix(new_ext))