mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-125519: Improve traceback if importlib.reload()
is called with a non-module object (#125520)
This commit is contained in:
parent
9256be7ff0
commit
c5c21fee7a
3 changed files with 18 additions and 1 deletions
|
@ -103,7 +103,7 @@ def reload(module):
|
|||
try:
|
||||
name = module.__name__
|
||||
except AttributeError:
|
||||
raise TypeError("reload() argument must be a module")
|
||||
raise TypeError("reload() argument must be a module") from None
|
||||
|
||||
if sys.modules.get(name) is not module:
|
||||
raise ImportError(f"module {name} not in sys.modules", name=name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue