MCPcopy Create free account
hub / github.com/ipython/ipython / __init__

Method __init__

IPython/core/compilerop.py:73–93  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

71 """
72
73 def __init__(self):
74 codeop.Compile.__init__(self)
75
76 # This is ugly, but it must be done this way to allow multiple
77 # simultaneous ipython instances to coexist. Since Python itself
78 # directly accesses the data structures in the linecache module, and
79 # the cache therein is global, we must work with that data structure.
80 # We must hold a reference to the original checkcache routine and call
81 # that in our own check_cache() below, but the special IPython cache
82 # must also be shared by all IPython instances. If we were to hold
83 # separate caches (one in each CachingCompiler instance), any call made
84 # by Python itself to linecache.checkcache() would obliterate the
85 # cached data from the other IPython instances.
86 if not hasattr(linecache, '_ipython_cache'):
87 linecache._ipython_cache = {}
88 if not hasattr(linecache, '_checkcache_ori'):
89 linecache._checkcache_ori = linecache.checkcache
90 # Now, we must monkeypatch the linecache directly so that parts of the
91 # stdlib that call it outside our control go through our codepath
92 # (otherwise we'd lose our tracebacks).
93 linecache.checkcache = check_linecache_ipython
94
95
96 def ast_parse(self, source, filename='<unknown>', symbol='exec'):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected