Skip to content

Commit 0acc59e

Browse files
rollback some change and add test
1 parent 8df33f8 commit 0acc59e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Lib/test/test_traceback.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5189,6 +5189,15 @@ def test_no_site_package_flavour(self):
51895189
b"or to enable your virtual environment?"), stderr
51905190
)
51915191

5192+
code = """import abs"""
5193+
_, _, stderr = assert_python_failure('-S', '-c', code)
5194+
self.assertIn(b"Did you mean: 'abc'?", stderr)
5195+
self.assertIn(
5196+
(b"Site initialization is disabled, did you forget to "
5197+
b"add the site-packages directory to sys.path "
5198+
b"or to enable your virtual environment?"), stderr
5199+
)
5200+
51925201
def test_missing_stdlib_module(self):
51935202
code = """
51945203
import sys

Lib/traceback.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import tokenize
1414
import io
1515
import importlib.util
16-
from importlib.machinery import ModuleSpec
1716
import pathlib
1817
import _colorize
1918

@@ -1763,10 +1762,7 @@ def _compute_suggestion_error(exc_value, tb, wrong_name):
17631762
d = []
17641763
for finder in sys.meta_path:
17651764
if discover := getattr(finder, 'discover', None):
1766-
try:
1767-
d += [spec.name for spec in discover(parent) if isinstance(spec, ModuleSpec)]
1768-
except Exception:
1769-
continue
1765+
d += [spec.name for spec in discover(parent)]
17701766
except Exception:
17711767
return None
17721768
elif isinstance(exc_value, ImportError):

0 commit comments

Comments
 (0)