[Python-checkins] (no subject)

Furkan Önder webhook-mailer at python.org
Fri Jun 5 15:56:40 EDT 2020




To: python-checkins at python.org
Subject:
 bpo-19468: delete unnecessary instance check in importlib.reload() (GH-19424)
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

https://github.com/python/cpython/commit/fef1fae9df3b03510f9defb25bd0388135b4=
c591
commit: fef1fae9df3b03510f9defb25bd0388135b4c591
branch: master
author: Furkan =C3=96nder <furkantahaonder at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-06-05T12:56:32-07:00
summary:

bpo-19468: delete unnecessary instance check in importlib.reload() (GH-19424)



Automerge-Triggered-By: @brettcannon

files:
A Misc/NEWS.d/next/Core and Builtins/2020-05-30-23-18-35.bpo-19468.S-TA7p.rst
M Lib/importlib/__init__.py

diff --git a/Lib/importlib/__init__.py b/Lib/importlib/__init__.py
index 0c73c505f98db..bea37d766262f 100644
--- a/Lib/importlib/__init__.py
+++ b/Lib/importlib/__init__.py
@@ -54,7 +54,6 @@
 # Fully bootstrapped at this point, import whatever you like, circular
 # dependencies and startup overhead minimisation permitting :)
=20
-import types
 import warnings
=20
=20
@@ -136,12 +135,13 @@ def reload(module):
     The module must have been successfully imported before.
=20
     """
-    if not module or not isinstance(module, types.ModuleType):
-        raise TypeError("reload() argument must be a module")
     try:
         name =3D module.__spec__.name
     except AttributeError:
-        name =3D module.__name__
+        try:
+            name =3D module.__name__
+        except AttributeError:
+            raise TypeError("reload() argument must be a module")
=20
     if sys.modules.get(name) is not module:
         msg =3D "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-1946=
8.S-TA7p.rst
new file mode 100644
index 0000000000000..e35750e37f4da
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-05-30-23-18-35.bpo-19468.S-TA7p=
.rst=09
@@ -0,0 +1,2 @@
+Delete unnecessary instance check in importlib.reload().
+Patch by Furkan =C3=96nder.



More information about the Python-checkins mailing list