Skip to content

Deep reload throws a NonImplementedError #10235

Open

Description

@Perlence

I tried to deep reload module types, but got the following error. This kind of error does not occur in Python 3.4.2, but occurs in Python 3.5.2 and Python 3.6.0.

Long and winding traceback...
Python 3.5.2 (default, Oct 31 2016, 21:20:07) 
Type "copyright", "credits" or "license" for more information.

IPython 5.2.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import types
In [2]: from IPython.lib.deepreload import reload
In [3]: reload(types)
Reloading functools
Reloading _functools
Reloading abc
Reloading _weakrefset
Reloading _weakref
Reloading collections
Reloading _collections_abc
Reloading operator
Reloading _operator
Reloading keyword
Reloading heapq
Reloading _heapq
Reloading importlib
Reloading _imp
Reloading _frozen_importlib
Reloading _frozen_importlib_external
Reloading types
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-3-2c2c5ada3170> in <module>()
----> 1 reload(types)

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in reload(module, exclude)
    340     try:
    341         with replace_import_hook(deep_import_hook):
--> 342             return deep_reload_hook(module)
    343     finally:
    344         found_now = {}

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/contextlib.py in __exit__(self, type, value, traceback)
     75                 value = type()
     76             try:
---> 77                 self.gen.throw(type, value, traceback)
     78                 raise RuntimeError("generator didn't stop after throw()")
     79             except StopIteration as exc:

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in replace_import_hook(new_import)
     50     builtin_mod.__import__ = new_import
     51     try:
---> 52         yield
     53     finally:
     54         builtin_mod.__import__ = saved_import

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in reload(module, exclude)
    340     try:
    341         with replace_import_hook(deep_import_hook):
--> 342             return deep_reload_hook(module)
    343     finally:
    344         found_now = {}

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in deep_reload_hook(m)
    309 
    310     try:
--> 311         newm = imp.load_module(name, fp, filename, stuff)
    312     except:
    313          # load_module probably removed name from modules because of

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_module(name, file, filename, details)
    232         raise ValueError(msg)
    233     elif type_ == PY_SOURCE:
--> 234         return load_source(name, filename, file)
    235     elif type_ == PY_COMPILED:
    236         return load_compiled(name, filename, file)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_source(name, pathname, file)
    168     spec = util.spec_from_file_location(name, pathname, loader=loader)
    169     if name in sys.modules:
--> 170         module = _exec(spec, sys.modules[name])
    171     else:
    172         module = _load(spec)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap.py in _exec(spec, module)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap_external.py in exec_module(self, module)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/types.py in <module>()
    164 
    165 
--> 166 import functools as _functools
    167 import collections.abc as _collections_abc
    168 

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
    250     parent, buf = get_parent(globals, level)
    251 
--> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
    253 
    254     tail = head

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
    154     buf += subname
    155 
--> 156     result = import_submodule(mod, subname, buf)
    157     if result is None and mod != altmod:
    158         result = import_submodule(altmod, subname, subname)

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
    199 
    200         try:
--> 201             m = imp.load_module(fullname, fp, filename, stuff)
    202         except:
    203             # load_module probably removed name from modules because of

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_module(name, file, filename, details)
    232         raise ValueError(msg)
    233     elif type_ == PY_SOURCE:
--> 234         return load_source(name, filename, file)
    235     elif type_ == PY_COMPILED:
    236         return load_compiled(name, filename, file)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_source(name, pathname, file)
    168     spec = util.spec_from_file_location(name, pathname, loader=loader)
    169     if name in sys.modules:
--> 170         module = _exec(spec, sys.modules[name])
    171     else:
    172         module = _load(spec)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap.py in _exec(spec, module)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap_external.py in exec_module(self, module)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/functools.py in <module>()
     19     pass
     20 from abc import get_cache_token
---> 21 from collections import namedtuple
     22 from types import MappingProxyType
     23 from weakref import WeakKeyDictionary

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
    250     parent, buf = get_parent(globals, level)
    251 
--> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
    253 
    254     tail = head

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
    154     buf += subname
    155 
--> 156     result = import_submodule(mod, subname, buf)
    157     if result is None and mod != altmod:
    158         result = import_submodule(altmod, subname, subname)

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
    199 
    200         try:
--> 201             m = imp.load_module(fullname, fp, filename, stuff)
    202         except:
    203             # load_module probably removed name from modules because of

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_module(name, file, filename, details)
    242             return load_dynamic(name, filename, file)
    243     elif type_ == PKG_DIRECTORY:
--> 244         return load_package(name, filename)
    245     elif type_ == C_BUILTIN:
    246         return init_builtin(name)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_package(name, path)
    212                                         submodule_search_locations=[])
    213     if name in sys.modules:
--> 214         return _exec(spec, sys.modules[name])
    215     else:
    216         return _load(spec)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap.py in _exec(spec, module)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap_external.py in exec_module(self, module)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/collections/__init__.py in <module>()
     27 from keyword import iskeyword as _iskeyword
     28 import sys as _sys
---> 29 import heapq as _heapq
     30 from _weakref import proxy as _proxy
     31 from itertools import repeat as _repeat, chain as _chain, starmap as _starmap

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
    250     parent, buf = get_parent(globals, level)
    251 
--> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
    253 
    254     tail = head

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
    154     buf += subname
    155 
--> 156     result = import_submodule(mod, subname, buf)
    157     if result is None and mod != altmod:
    158         result = import_submodule(altmod, subname, subname)

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
    199 
    200         try:
--> 201             m = imp.load_module(fullname, fp, filename, stuff)
    202         except:
    203             # load_module probably removed name from modules because of

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_module(name, file, filename, details)
    232         raise ValueError(msg)
    233     elif type_ == PY_SOURCE:
--> 234         return load_source(name, filename, file)
    235     elif type_ == PY_COMPILED:
    236         return load_compiled(name, filename, file)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_source(name, pathname, file)
    168     spec = util.spec_from_file_location(name, pathname, loader=loader)
    169     if name in sys.modules:
--> 170         module = _exec(spec, sys.modules[name])
    171     else:
    172         module = _load(spec)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap.py in _exec(spec, module)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap_external.py in exec_module(self, module)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/heapq.py in <module>()
    585 # If available, use C implementation
    586 try:
--> 587     from _heapq import *
    588 except ImportError:
    589     pass

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
    250     parent, buf = get_parent(globals, level)
    251 
--> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
    253 
    254     tail = head

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
    154     buf += subname
    155 
--> 156     result = import_submodule(mod, subname, buf)
    157     if result is None and mod != altmod:
    158         result = import_submodule(altmod, subname, subname)

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
    199 
    200         try:
--> 201             m = imp.load_module(fullname, fp, filename, stuff)
    202         except:
    203             # load_module probably removed name from modules because of

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_module(name, file, filename, details)
    240                 return load_dynamic(name, filename, opened_file)
    241         else:
--> 242             return load_dynamic(name, filename, file)
    243     elif type_ == PKG_DIRECTORY:
    244         return load_package(name, filename)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_dynamic(name, path, file)
    333         Load an extension module.
    334         """
--> 335         import importlib.machinery
    336         loader = importlib.machinery.ExtensionFileLoader(name, path)
    337 

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
    250     parent, buf = get_parent(globals, level)
    251 
--> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
    253 
    254     tail = head

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
    154     buf += subname
    155 
--> 156     result = import_submodule(mod, subname, buf)
    157     if result is None and mod != altmod:
    158         result = import_submodule(altmod, subname, subname)

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
    199 
    200         try:
--> 201             m = imp.load_module(fullname, fp, filename, stuff)
    202         except:
    203             # load_module probably removed name from modules because of

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_module(name, file, filename, details)
    242             return load_dynamic(name, filename, file)
    243     elif type_ == PKG_DIRECTORY:
--> 244         return load_package(name, filename)
    245     elif type_ == C_BUILTIN:
    246         return init_builtin(name)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_package(name, path)
    212                                         submodule_search_locations=[])
    213     if name in sys.modules:
--> 214         return _exec(spec, sys.modules[name])
    215     else:
    216         return _load(spec)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap.py in _exec(spec, module)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap_external.py in exec_module(self, module)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/__init__.py in <module>()
     55 # dependencies and startup overhead minimisation permitting :)
     56 
---> 57 import types
     58 import warnings
     59 

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
    250     parent, buf = get_parent(globals, level)
    251 
--> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
    253 
    254     tail = head

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
    154     buf += subname
    155 
--> 156     result = import_submodule(mod, subname, buf)
    157     if result is None and mod != altmod:
    158         result = import_submodule(altmod, subname, subname)

/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
    199 
    200         try:
--> 201             m = imp.load_module(fullname, fp, filename, stuff)
    202         except:
    203             # load_module probably removed name from modules because of

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_module(name, file, filename, details)
    232         raise ValueError(msg)
    233     elif type_ == PY_SOURCE:
--> 234         return load_source(name, filename, file)
    235     elif type_ == PY_COMPILED:
    236         return load_compiled(name, filename, file)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/imp.py in load_source(name, pathname, file)
    168     spec = util.spec_from_file_location(name, pathname, loader=loader)
    169     if name in sys.modules:
--> 170         module = _exec(spec, sys.modules[name])
    171     else:
    172         module = _load(spec)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap.py in _exec(spec, module)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap.py in _init_module_attrs(spec, module, override)

/home/sviatoslav/.pythonz/pythons/CPython-3.5.2/lib/python3.5/importlib/_bootstrap.py in cached(self)

NotImplementedError: 

System information:

$ python -c "import IPython; print(IPython.sys_info())"
{'commit_hash': 'be4827b',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': '/home/sviatoslav/workspace/py35/lib/python3.5/site-packages/IPython',
 'ipython_version': '5.2.1',
 'os_name': 'posix',
 'platform': 'Linux-3.16.0-4-amd64-x86_64-with-debian-8.7',
 'sys_executable': '/home/sviatoslav/workspace/py35/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.5.2 (default, Oct 31 2016, 21:20:07) \n[GCC 4.9.2]'}

Activity

  1. Carreau commented on Feb 7, 2017

    @Carreau
    Member

    Hum, types and deeprelaod are pretty dark magic. We likely need to blacklist some modules.

    Do you want to attempt a PR ?

  2. Perlence commented on Feb 7, 2017

    @Perlence
    Author

    Do you want to attempt a PR ?

    Sorry, I have no idea what's going on there.

  3. added this to the 6.0 milestone on Feb 7, 2017
  4. Carreau commented on Feb 7, 2017

    @Carreau
    Member

    Sorry, I have no idea what's going on there.

    No worries. We'll have a look ! Thanks.

  5. added a commit that references this issue on Feb 21, 2017
    aaaedbd
  6. tillahoffmann commented on Sep 13, 2017

    @tillahoffmann
    Contributor

    @Carreau, I am still seeing this issue in 6.1.0 even though types should have been excluded explicitly as in your #10318. Any thoughts? My python version is 3.6.2.

  7. astromme commented on Oct 9, 2017

    @astromme

    I'm also seeing this still in 6.2.1

  8. Carreau commented on Oct 9, 2017

    @Carreau
    Member

    Hum, happy to reopen, but I can't reproduce on a fresh install, so I'll have issues to debug :

    $ ipython
    Python 3.6.3 | packaged by conda-forge | (default, Oct  5 2017, 19:18:17)
    Type 'copyright', 'credits' or 'license' for more information
    IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
    
    In [1]: import types
    
    In [2]: from IPython.lib.deepreload import reload
    
    In [3]: reload(types)
    Out[3]: <module 'types' from '/Users/bussonniermatthias/anaconda/lib/python3.6/types.py'>
    

    Do you both have the exact same traceback ?

  9. reopened this on Oct 9, 2017
  10. tillahoffmann commented on Oct 9, 2017

    @tillahoffmann
    Contributor

    The example you provide actually works fine for me. However, I can't reload other packages (e.g. json):

    Python 3.6.2 (default, Jul 24 2017, 19:47:39) 
    Type 'copyright', 'credits' or 'license' for more information
    IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
    
    In [1]: import json
    
    In [2]: from IPython.lib.deepreload import reload
    
    In [3]: reload(json)
    Reloading json.decoder
    Reloading re
    Reloading enum
    Reloading types
    Reloading functools
    Reloading _functools
    Reloading abc
    Reloading _weakrefset
    Reloading _weakref
    Reloading collections
    Reloading _collections_abc
    Reloading operator
    Reloading _operator
    Reloading keyword
    Reloading heapq
    Reloading _heapq
    Reloading importlib
    Reloading _imp
    Reloading _frozen_importlib
    Reloading _frozen_importlib_external
    Reloading warnings
    ---------------------------------------------------------------------------
    NotImplementedError                       Traceback (most recent call last)
    <ipython-input-3-9009d350791b> in <module>()
    ----> 1 reload(json)
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in reload(module, exclude)
        343     try:
        344         with replace_import_hook(deep_import_hook):
    --> 345             return deep_reload_hook(module)
        346     finally:
        347         found_now = {}
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in deep_reload_hook(m)
        315 
        316     try:
    --> 317         newm = imp.load_module(name, fp, filename, stuff)
        318     except:
        319          # load_module probably removed name from modules because of
    
    /usr/local/lib/python3.6/imp.py in load_module(name, file, filename, details)
        242             return load_dynamic(name, filename, file)
        243     elif type_ == PKG_DIRECTORY:
    --> 244         return load_package(name, filename)
        245     elif type_ == C_BUILTIN:
        246         return init_builtin(name)
    
    /usr/local/lib/python3.6/imp.py in load_package(name, path)
        212                                         submodule_search_locations=[])
        213     if name in sys.modules:
    --> 214         return _exec(spec, sys.modules[name])
        215     else:
        216         return _load(spec)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _exec(spec, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap_external.py in exec_module(self, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
    
    /usr/local/lib/python3.6/json/__init__.py in <module>()
        104 __author__ = 'Bob Ippolito <[email protected]>'
        105 
    --> 106 from .decoder import JSONDecoder, JSONDecodeError
        107 from .encoder import JSONEncoder
        108 import codecs
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
        250     parent, buf = get_parent(globals, level)
        251 
    --> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
        253 
        254     tail = head
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
        153     buf += subname
        154 
    --> 155     result = import_submodule(mod, subname, buf)
        156     if result is None and mod != altmod:
        157         result = import_submodule(altmod, subname, subname)
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
        199 
        200         try:
    --> 201             m = imp.load_module(fullname, fp, filename, stuff)
        202         except:
        203             # load_module probably removed name from modules because of
    
    /usr/local/lib/python3.6/imp.py in load_module(name, file, filename, details)
        232         raise ValueError(msg)
        233     elif type_ == PY_SOURCE:
    --> 234         return load_source(name, filename, file)
        235     elif type_ == PY_COMPILED:
        236         return load_compiled(name, filename, file)
    
    /usr/local/lib/python3.6/imp.py in load_source(name, pathname, file)
        168     spec = util.spec_from_file_location(name, pathname, loader=loader)
        169     if name in sys.modules:
    --> 170         module = _exec(spec, sys.modules[name])
        171     else:
        172         module = _load(spec)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _exec(spec, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap_external.py in exec_module(self, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
    
    /usr/local/lib/python3.6/json/decoder.py in <module>()
          1 """Implementation of JSONDecoder
          2 """
    ----> 3 import re
          4 
          5 from json import scanner
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
        250     parent, buf = get_parent(globals, level)
        251 
    --> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
        253 
        254     tail = head
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
        153     buf += subname
        154 
    --> 155     result = import_submodule(mod, subname, buf)
        156     if result is None and mod != altmod:
        157         result = import_submodule(altmod, subname, subname)
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
        199 
        200         try:
    --> 201             m = imp.load_module(fullname, fp, filename, stuff)
        202         except:
        203             # load_module probably removed name from modules because of
    
    /usr/local/lib/python3.6/imp.py in load_module(name, file, filename, details)
        232         raise ValueError(msg)
        233     elif type_ == PY_SOURCE:
    --> 234         return load_source(name, filename, file)
        235     elif type_ == PY_COMPILED:
        236         return load_compiled(name, filename, file)
    
    /usr/local/lib/python3.6/imp.py in load_source(name, pathname, file)
        168     spec = util.spec_from_file_location(name, pathname, loader=loader)
        169     if name in sys.modules:
    --> 170         module = _exec(spec, sys.modules[name])
        171     else:
        172         module = _load(spec)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _exec(spec, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap_external.py in exec_module(self, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
    
    /usr/local/lib/python3.6/re.py in <module>()
        120 """
        121 
    --> 122 import enum
        123 import sre_compile
        124 import sre_parse
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
        250     parent, buf = get_parent(globals, level)
        251 
    --> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
        253 
        254     tail = head
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
        153     buf += subname
        154 
    --> 155     result = import_submodule(mod, subname, buf)
        156     if result is None and mod != altmod:
        157         result = import_submodule(altmod, subname, subname)
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
        199 
        200         try:
    --> 201             m = imp.load_module(fullname, fp, filename, stuff)
        202         except:
        203             # load_module probably removed name from modules because of
    
    /usr/local/lib/python3.6/imp.py in load_module(name, file, filename, details)
        232         raise ValueError(msg)
        233     elif type_ == PY_SOURCE:
    --> 234         return load_source(name, filename, file)
        235     elif type_ == PY_COMPILED:
        236         return load_compiled(name, filename, file)
    
    /usr/local/lib/python3.6/imp.py in load_source(name, pathname, file)
        168     spec = util.spec_from_file_location(name, pathname, loader=loader)
        169     if name in sys.modules:
    --> 170         module = _exec(spec, sys.modules[name])
        171     else:
        172         module = _load(spec)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _exec(spec, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap_external.py in exec_module(self, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
    
    /usr/local/lib/python3.6/enum.py in <module>()
          1 import sys
    ----> 2 from types import MappingProxyType, DynamicClassAttribute
          3 from functools import reduce
          4 from operator import or_ as _or_
          5 
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
        250     parent, buf = get_parent(globals, level)
        251 
    --> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
        253 
        254     tail = head
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
        153     buf += subname
        154 
    --> 155     result = import_submodule(mod, subname, buf)
        156     if result is None and mod != altmod:
        157         result = import_submodule(altmod, subname, subname)
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
        199 
        200         try:
    --> 201             m = imp.load_module(fullname, fp, filename, stuff)
        202         except:
        203             # load_module probably removed name from modules because of
    
    /usr/local/lib/python3.6/imp.py in load_module(name, file, filename, details)
        232         raise ValueError(msg)
        233     elif type_ == PY_SOURCE:
    --> 234         return load_source(name, filename, file)
        235     elif type_ == PY_COMPILED:
        236         return load_compiled(name, filename, file)
    
    /usr/local/lib/python3.6/imp.py in load_source(name, pathname, file)
        168     spec = util.spec_from_file_location(name, pathname, loader=loader)
        169     if name in sys.modules:
    --> 170         module = _exec(spec, sys.modules[name])
        171     else:
        172         module = _load(spec)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _exec(spec, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap_external.py in exec_module(self, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
    
    /usr/local/lib/python3.6/types.py in <module>()
        169 
        170 
    --> 171 import functools as _functools
        172 import collections.abc as _collections_abc
        173 
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
        250     parent, buf = get_parent(globals, level)
        251 
    --> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
        253 
        254     tail = head
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
        153     buf += subname
        154 
    --> 155     result = import_submodule(mod, subname, buf)
        156     if result is None and mod != altmod:
        157         result = import_submodule(altmod, subname, subname)
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
        199 
        200         try:
    --> 201             m = imp.load_module(fullname, fp, filename, stuff)
        202         except:
        203             # load_module probably removed name from modules because of
    
    /usr/local/lib/python3.6/imp.py in load_module(name, file, filename, details)
        232         raise ValueError(msg)
        233     elif type_ == PY_SOURCE:
    --> 234         return load_source(name, filename, file)
        235     elif type_ == PY_COMPILED:
        236         return load_compiled(name, filename, file)
    
    /usr/local/lib/python3.6/imp.py in load_source(name, pathname, file)
        168     spec = util.spec_from_file_location(name, pathname, loader=loader)
        169     if name in sys.modules:
    --> 170         module = _exec(spec, sys.modules[name])
        171     else:
        172         module = _load(spec)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _exec(spec, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap_external.py in exec_module(self, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
    
    /usr/local/lib/python3.6/functools.py in <module>()
         19     pass
         20 from abc import get_cache_token
    ---> 21 from collections import namedtuple
         22 from types import MappingProxyType
         23 from weakref import WeakKeyDictionary
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
        250     parent, buf = get_parent(globals, level)
        251 
    --> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
        253 
        254     tail = head
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
        153     buf += subname
        154 
    --> 155     result = import_submodule(mod, subname, buf)
        156     if result is None and mod != altmod:
        157         result = import_submodule(altmod, subname, subname)
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
        199 
        200         try:
    --> 201             m = imp.load_module(fullname, fp, filename, stuff)
        202         except:
        203             # load_module probably removed name from modules because of
    
    /usr/local/lib/python3.6/imp.py in load_module(name, file, filename, details)
        242             return load_dynamic(name, filename, file)
        243     elif type_ == PKG_DIRECTORY:
    --> 244         return load_package(name, filename)
        245     elif type_ == C_BUILTIN:
        246         return init_builtin(name)
    
    /usr/local/lib/python3.6/imp.py in load_package(name, path)
        212                                         submodule_search_locations=[])
        213     if name in sys.modules:
    --> 214         return _exec(spec, sys.modules[name])
        215     else:
        216         return _load(spec)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _exec(spec, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap_external.py in exec_module(self, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
    
    /usr/local/lib/python3.6/collections/__init__.py in <module>()
         27 from keyword import iskeyword as _iskeyword
         28 import sys as _sys
    ---> 29 import heapq as _heapq
         30 from _weakref import proxy as _proxy
         31 from itertools import repeat as _repeat, chain as _chain, starmap as _starmap
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
        250     parent, buf = get_parent(globals, level)
        251 
    --> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
        253 
        254     tail = head
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
        153     buf += subname
        154 
    --> 155     result = import_submodule(mod, subname, buf)
        156     if result is None and mod != altmod:
        157         result = import_submodule(altmod, subname, subname)
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
        199 
        200         try:
    --> 201             m = imp.load_module(fullname, fp, filename, stuff)
        202         except:
        203             # load_module probably removed name from modules because of
    
    /usr/local/lib/python3.6/imp.py in load_module(name, file, filename, details)
        232         raise ValueError(msg)
        233     elif type_ == PY_SOURCE:
    --> 234         return load_source(name, filename, file)
        235     elif type_ == PY_COMPILED:
        236         return load_compiled(name, filename, file)
    
    /usr/local/lib/python3.6/imp.py in load_source(name, pathname, file)
        168     spec = util.spec_from_file_location(name, pathname, loader=loader)
        169     if name in sys.modules:
    --> 170         module = _exec(spec, sys.modules[name])
        171     else:
        172         module = _load(spec)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _exec(spec, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap_external.py in exec_module(self, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
    
    /usr/local/lib/python3.6/heapq.py in <module>()
        585 # If available, use C implementation
        586 try:
    --> 587     from _heapq import *
        588 except ImportError:
        589     pass
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
        250     parent, buf = get_parent(globals, level)
        251 
    --> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
        253 
        254     tail = head
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
        153     buf += subname
        154 
    --> 155     result = import_submodule(mod, subname, buf)
        156     if result is None and mod != altmod:
        157         result = import_submodule(altmod, subname, subname)
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
        199 
        200         try:
    --> 201             m = imp.load_module(fullname, fp, filename, stuff)
        202         except:
        203             # load_module probably removed name from modules because of
    
    /usr/local/lib/python3.6/imp.py in load_module(name, file, filename, details)
        240                 return load_dynamic(name, filename, opened_file)
        241         else:
    --> 242             return load_dynamic(name, filename, file)
        243     elif type_ == PKG_DIRECTORY:
        244         return load_package(name, filename)
    
    /usr/local/lib/python3.6/imp.py in load_dynamic(name, path, file)
        333         Load an extension module.
        334         """
    --> 335         import importlib.machinery
        336         loader = importlib.machinery.ExtensionFileLoader(name, path)
        337 
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
        250     parent, buf = get_parent(globals, level)
        251 
    --> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
        253 
        254     tail = head
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
        153     buf += subname
        154 
    --> 155     result = import_submodule(mod, subname, buf)
        156     if result is None and mod != altmod:
        157         result = import_submodule(altmod, subname, subname)
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
        199 
        200         try:
    --> 201             m = imp.load_module(fullname, fp, filename, stuff)
        202         except:
        203             # load_module probably removed name from modules because of
    
    /usr/local/lib/python3.6/imp.py in load_module(name, file, filename, details)
        242             return load_dynamic(name, filename, file)
        243     elif type_ == PKG_DIRECTORY:
    --> 244         return load_package(name, filename)
        245     elif type_ == C_BUILTIN:
        246         return init_builtin(name)
    
    /usr/local/lib/python3.6/imp.py in load_package(name, path)
        212                                         submodule_search_locations=[])
        213     if name in sys.modules:
    --> 214         return _exec(spec, sys.modules[name])
        215     else:
        216         return _load(spec)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _exec(spec, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap_external.py in exec_module(self, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)
    
    /usr/local/lib/python3.6/importlib/__init__.py in <module>()
         56 
         57 import types
    ---> 58 import warnings
         59 
         60 
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in deep_import_hook(name, globals, locals, fromlist, level)
        250     parent, buf = get_parent(globals, level)
        251 
    --> 252     head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
        253 
        254     tail = head
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in load_next(mod, altmod, name, buf)
        153     buf += subname
        154 
    --> 155     result = import_submodule(mod, subname, buf)
        156     if result is None and mod != altmod:
        157         result = import_submodule(altmod, subname, subname)
    
    /usr/local/lib/python3.6/site-packages/IPython/lib/deepreload.py in import_submodule(mod, subname, fullname)
        199 
        200         try:
    --> 201             m = imp.load_module(fullname, fp, filename, stuff)
        202         except:
        203             # load_module probably removed name from modules because of
    
    /usr/local/lib/python3.6/imp.py in load_module(name, file, filename, details)
        232         raise ValueError(msg)
        233     elif type_ == PY_SOURCE:
    --> 234         return load_source(name, filename, file)
        235     elif type_ == PY_COMPILED:
        236         return load_compiled(name, filename, file)
    
    /usr/local/lib/python3.6/imp.py in load_source(name, pathname, file)
        168     spec = util.spec_from_file_location(name, pathname, loader=loader)
        169     if name in sys.modules:
    --> 170         module = _exec(spec, sys.modules[name])
        171     else:
        172         module = _load(spec)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _exec(spec, module)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in _init_module_attrs(spec, module, override)
    
    /usr/local/lib/python3.6/importlib/_bootstrap.py in cached(self)
    
    NotImplementedError: 
    
  11. Carreau commented on Oct 9, 2017

    @Carreau
    Member

    I think we'll have to be smarter and auto exclude modules we can't deep reload and warn users they were not deep reloaded.

  12. acandreani commented on Dec 24, 2017

    @acandreani

    temporary solution: add deep level control to recursion. Use this code in startup folder, on linux is: ~/.ipython/profile_default/startup/

    from autoreload import reload as r
    
    def reload(module,level=0):
        """Recursively reload modules."""
        r(module)
        if level>0:
            for attribute_name in dir(module):
                attribute = getattr(module, attribute_name)
                if type(attribute) is ModuleType:
                    reload(attribute,level-1)
    
    
  13. AlJohri commented on Jun 8, 2018

    @AlJohri

    I just ran into this issue as well while trying to use deepreload.reload

  14. vict0rsch commented on Jun 11, 2018

    @vict0rsch

    Same here (NotImplementedError on reloading types)

    Python 3.6.4
    IPython 6.4.0
    macOS 10.13.2  
    
  15. ioistired commented on Aug 26, 2018

    @ioistired

    I cannot reproduce this with types, but I can reproduce this by reloading deepreload itself.
    Ubuntu 18.04.1 LTS
    CPython 3.6.5
    IPython 6.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions