Skip to content

Commit b0647c2

Browse files
committed
Show the whole extension module file name in hint
Signed-off-by: Filipe Laíns <lains@riseup.net>
1 parent 212c02d commit b0647c2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Lib/test/test_traceback.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5235,17 +5235,17 @@ def test_incompatible_extension_modules_hint(self):
52355235
untagged_suffix = importlib.machinery.EXTENSION_SUFFIXES[-1]
52365236
with os_helper.temp_dir() as tmp:
52375237
# create a module with a incompatible ABI tag
5238-
incompatible_module = os.path.join(tmp, f'foo.some-abi{untagged_suffix}')
5239-
open(incompatible_module, "wb").close()
5238+
incompatible_module = f'foo.some-abi{untagged_suffix}'
5239+
open(os.path.join(tmp, incompatible_module), "wb").close()
52405240
# try importing it
52415241
code = f'''
52425242
import sys
52435243
sys.path.insert(0, {tmp!r})
52445244
import foo
52455245
'''
52465246
_, _, stderr = assert_python_failure('-c', code, __cwd=tmp)
5247-
hint = b'Although a module with this name was found for a different Python version (some-abi).'
5248-
self.assertIn(hint, stderr)
5247+
hint = f'Although a module with this name was found for a different Python version ({incompatible_module}).'
5248+
self.assertIn(hint, stderr.decode())
52495249

52505250

52515251
class TestColorizedTraceback(unittest.TestCase):

Lib/traceback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1915,4 +1915,4 @@ def _find_incompatible_extension_module(module_name):
19151915

19161916
for entry in traversable.iterdir():
19171917
if entry.name.startswith(child + '.') and entry.name.endswith(untagged_suffix):
1918-
return entry.name.removeprefix(child + '.').removesuffix(untagged_suffix)
1918+
return entry.name

0 commit comments

Comments
 (0)