Skip to content

Commit 6b5fd8c

Browse files
committed
Remove _make_strs and update msvc to accept WindowsPath.
1 parent 618a98b commit 6b5fd8c

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

distutils/compilers/C/msvc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,9 @@ def compile( # noqa: C901
406406
src = os.path.abspath(src)
407407

408408
if ext in self._c_extensions:
409-
input_opt = "/Tc" + src
409+
input_opt = f"/Tc{src}"
410410
elif ext in self._cpp_extensions:
411-
input_opt = "/Tp" + src
411+
input_opt = f"/Tp{src}"
412412
add_cpp_opts = True
413413
elif ext in self._rc_extensions:
414414
# compile .RC to .RES file

distutils/compilers/C/tests/test_base.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import platform
32
import sysconfig
43
import textwrap
@@ -10,15 +9,6 @@
109
pytestmark = pytest.mark.usefixtures('suppress_path_mangle')
1110

1211

13-
def _make_strs(paths):
14-
"""
15-
Convert paths to strings for platform compatibility.
16-
"""
17-
if platform.system() != "Windows":
18-
return paths
19-
return list(map(os.fspath, paths))
20-
21-
2212
@pytest.fixture
2313
def c_file(tmp_path):
2414
c_file = tmp_path / 'foo.c'
@@ -49,11 +39,11 @@ def test_set_include_dirs(c_file):
4939
compiler = base.new_compiler()
5040
python = sysconfig.get_paths()['include']
5141
compiler.set_include_dirs([python])
52-
compiler.compile(_make_strs([c_file]))
42+
compiler.compile([c_file])
5343

5444
# do it again, setting include dirs after any initialization
5545
compiler.set_include_dirs([python])
56-
compiler.compile(_make_strs([c_file]))
46+
compiler.compile([c_file])
5747

5848

5949
def test_has_function_prototype():
@@ -87,7 +77,7 @@ def test_include_dirs_after_multiple_compile_calls(c_file):
8777
compiler = base.new_compiler()
8878
python = sysconfig.get_paths()['include']
8979
compiler.set_include_dirs([python])
90-
compiler.compile(_make_strs([c_file]))
80+
compiler.compile([c_file])
9181
assert compiler.include_dirs == [python]
92-
compiler.compile(_make_strs([c_file]))
82+
compiler.compile([c_file])
9383
assert compiler.include_dirs == [python]

0 commit comments

Comments
 (0)