Skip to content

Commit 212c02d

Browse files
committed
Fix Windows
Signed-off-by: Filipe Laíns <lains@riseup.net>
1 parent 44c765f commit 212c02d

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Lib/test/test_traceback.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5209,8 +5209,17 @@ def test_find_incompatible_extension_modules(self):
52095209
if shlib_suffix := sysconfig.get_config_var('SHLIB_SUFFIX'):
52105210
self.assertEqual(last_extension_suffix, shlib_suffix)
52115211
else:
5212-
dot, *extensions = last_extension_suffix.split('.')
5213-
self.assertEqual(dot, '') # sanity check
5212+
before_dot, *extensions = last_extension_suffix.split('.')
5213+
expected_prefixes = ['']
5214+
if os.name == 'nt':
5215+
# Windows puts the debug tag in the module file stem (eg. foo_d.pyd)
5216+
expected_prefixes.append('_d')
5217+
self.assertIn(before_dot, expected_prefixes, msg=(
5218+
f'Unexpected prefix {before_dot!r} in extension module '
5219+
f'suffix {last_extension_suffix!r}. '
5220+
'traceback._find_incompatible_extension_module needs to be '
5221+
'updated to take this into account!'
5222+
))
52145223
# if SHLIB_SUFFIX is not define, we assume the native
52155224
# shared library suffix only contains one extension
52165225
# (eg. '.so', bad eg. '.cpython-315-x86_64-linux-gnu.so')

Lib/traceback.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,10 @@ def _find_incompatible_extension_module(module_name):
19001900
# tests.test_traceback.MiscTest.test_find_incompatible_extension_modules
19011901
# tests that assumption.
19021902
untagged_suffix = importlib.machinery.EXTENSION_SUFFIXES[-1]
1903+
# On Windows the debug tag is part of the module file stem, instead of the
1904+
# extension (eg. foo_d.pyd), so let's remove it and just look for .pyd.
1905+
if os.name == 'nt':
1906+
untagged_suffix = untagged_suffix.removeprefix('_d')
19031907

19041908
parent, _, child = module_name.rpartition('.')
19051909
if parent:

0 commit comments

Comments
 (0)