Skip to content

Instantly share code, notes, and snippets.

@markshannon
Last active September 4, 2015 21:26
Show Gist options
  • Save markshannon/7121deb93c8a23705426 to your computer and use it in GitHub Desktop.
Save markshannon/7121deb93c8a23705426 to your computer and use it in GitHub Desktop.
diff -r aa2517e9f9ce Lib/importlib/__init__.py
--- a/Lib/importlib/__init__.py Thu Jul 30 00:04:11 2015 +0300
+++ b/Lib/importlib/__init__.py Fri Sep 04 22:14:03 2015 +0100
@@ -135,12 +135,13 @@
The module must have been successfully imported before.
"""
- if not module or not isinstance(module, types.ModuleType):
- raise TypeError("reload() argument must be module")
try:
name = module.__spec__.name
except AttributeError:
- name = module.__name__
+ try:
+ name = module.__name__
+ except:
+ raise TypeError("reload() argument must be a module or module-like object")
if sys.modules.get(name) is not module:
msg = "module {} not in sys.modules"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment