Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fef1fae

Browse files
authored
bpo-19468: delete unnecessary instance check in importlib.reload() (GH-19424)
Automerge-Triggered-By: @brettcannon
1 parent 087d612 commit fef1fae

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

Lib/importlib/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
# Fully bootstrapped at this point, import whatever you like, circular
5555
# dependencies and startup overhead minimisation permitting :)
5656

57-
import types
5857
import warnings
5958

6059

@@ -136,12 +135,13 @@ def reload(module):
136135
The module must have been successfully imported before.
137136
138137
"""
139-
if not module or not isinstance(module, types.ModuleType):
140-
raise TypeError("reload() argument must be a module")
141138
try:
142139
name = module.__spec__.name
143140
except AttributeError:
144-
name = module.__name__
141+
try:
142+
name = module.__name__
143+
except AttributeError:
144+
raise TypeError("reload() argument must be a module")
145145

146146
if sys.modules.get(name) is not module:
147147
msg = "module {} not in sys.modules"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Delete unnecessary instance check in importlib.reload().
2+
Patch by Furkan Önder.

0 commit comments

Comments
 (0)