Skip to content

Commit ae94481

Browse files
committed
Report a module that exists but cannot be imported
dir_of_mod_or_error() ran dir() on the exception import_module() returns, so a failed import looked like a module whose every item is missing: sqlite3 alone filled 198 of those lines, and CPython's own _ios_support was compared as a module holding ImportError's attributes. Returning the exception reaches the "exists but not importable" line that was already written for it, and drops 529 lines from "stdlib items". Assisted-by: Claude Code:claude-opus-5
1 parent f8365e1 commit ae94481

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎scripts/whats_left.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ def is_child(module, item):
301301

302302
def dir_of_mod_or_error(module_name, keep_other=True):
303303
module = import_module(module_name)
304+
if isinstance(module, Exception):
305+
return module
304306
item_names = sorted(set(dir(module)))
305307
result = {}
306308
for item_name in item_names:
@@ -458,8 +460,8 @@ def method_incompatibility_reason(typ, method_name):
458460
if rustpymod is None:
459461
result["not_implemented"][modname] = None
460462
elif isinstance(rustpymod, Exception):
461-
result["failed_to_import"][modname] = rustpymod.__class__.__name__ + str(
462-
rustpymod
463+
result["failed_to_import"][modname] = (
464+
f"{rustpymod.__class__.__name__}: {rustpymod}"
463465
)
464466
else:
465467
module = import_module(modname)

0 commit comments

Comments
 (0)