diff --git a/IPython/extensions/autoreload.py b/IPython/extensions/autoreload.py index 3715d26..198f84f 100644 --- a/IPython/extensions/autoreload.py +++ b/IPython/extensions/autoreload.py @@ -384,11 +384,23 @@ class StrongRef: return self.obj +mod_attrs = [ + "__name__", + "__doc__", + "__package__", + "__loader__", + "__spec__", + "__file__", + "__cached__", + "__builtins__" +] + + def append_obj(module, d, name, obj, autoload=False): not_in_mod = not hasattr(obj, "__module__") or obj.__module__ != module.__name__ if autoload: - # check needed for module global built-ins (int, str, dict,..) - if name.startswith("__") and not_in_mod: + # check needed for module global built-ins + if not_in_mod and name in mod_attrs: return False else: if not_in_mod: