]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-19468: delete unnecessary instance check in importlib.reload() (GH-19424)
authorFurkan Önder <furkantahaonder@gmail.com>
Fri, 5 Jun 2020 19:56:32 +0000 (22:56 +0300)
committerGitHub <noreply@github.com>
Fri, 5 Jun 2020 19:56:32 +0000 (12:56 -0700)
Automerge-Triggered-By: @brettcannon
Lib/importlib/__init__.py
Misc/NEWS.d/next/Core and Builtins/2020-05-30-23-18-35.bpo-19468.S-TA7p.rst [new file with mode: 0644]

index 0c73c505f98dba01d4b0a645a385629533f6216c..bea37d766262f88aa656420f429b277308090b5b 100644 (file)
@@ -54,7 +54,6 @@ _unpack_uint32 = _bootstrap_external._unpack_uint32
 # Fully bootstrapped at this point, import whatever you like, circular
 # dependencies and startup overhead minimisation permitting :)
 
-import types
 import warnings
 
 
@@ -136,12 +135,13 @@ def reload(module):
     The module must have been successfully imported before.
 
     """
-    if not module or not isinstance(module, types.ModuleType):
-        raise TypeError("reload() argument must be a module")
     try:
         name = module.__spec__.name
     except AttributeError:
-        name = module.__name__
+        try:
+            name = module.__name__
+        except AttributeError:
+            raise TypeError("reload() argument must be a module")
 
     if sys.modules.get(name) is not module:
         msg = "module {} not in sys.modules"
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-05-30-23-18-35.bpo-19468.S-TA7p.rst b/Misc/NEWS.d/next/Core and Builtins/2020-05-30-23-18-35.bpo-19468.S-TA7p.rst
new file mode 100644 (file)
index 0000000..e35750e
--- /dev/null
@@ -0,0 +1,2 @@
+Delete unnecessary instance check in importlib.reload().
+Patch by Furkan Önder.