Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 51eb040

Browse files
committed
Merge branch 'main' into shaperilio/autoreload-verbosity
2 parents 3eb6aaf + f3a9322 commit 51eb040

45 files changed

Lines changed: 1654 additions & 448 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Install dependencies
2929
run: |
3030
python -m pip install --upgrade pip
31-
pip install darker black==21.12b0
31+
pip install darker==1.5.1 black==22.10.0
3232
- name: Lint with darker
3333
run: |
3434
darker -r 60625f241f298b5039cb2debc365db38aa7bb522 --check --diff . || (

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ __pycache__
2424
.cache
2525
.coverage
2626
*.swp
27-
.vscode
2827
.pytest_cache
2928
.python-version
3029
venv*/

IPython/core/compilerop.py

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,6 @@ class CachingCompiler(codeop.Compile):
7373
def __init__(self):
7474
codeop.Compile.__init__(self)
7575

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-
9576
# Caching a dictionary { filename: execution_count } for nicely
9677
# rendered tracebacks. The filename corresponds to the filename
9778
# argument used for the builtins.compile function.
@@ -161,14 +142,24 @@ def cache(self, transformed_code, number=0, raw_code=None):
161142
# Save the execution count
162143
self._filename_map[name] = number
163144

145+
# Since Python 2.5, setting mtime to `None` means the lines will
146+
# never be removed by `linecache.checkcache`. This means all the
147+
# monkeypatching has *never* been necessary, since this code was
148+
# only added in 2010, at which point IPython had already stopped
149+
# supporting Python 2.4.
150+
#
151+
# Note that `linecache.clearcache` and `linecache.updatecache` may
152+
# still remove our code from the cache, but those show explicit
153+
# intent, and we should not try to interfere. Normally the former
154+
# is never called except when out of memory, and the latter is only
155+
# called for lines *not* in the cache.
164156
entry = (
165157
len(transformed_code),
166-
time.time(),
158+
None,
167159
[line + "\n" for line in transformed_code.splitlines()],
168160
name,
169161
)
170162
linecache.cache[name] = entry
171-
linecache._ipython_cache[name] = entry
172163
return name
173164

174165
@contextmanager
@@ -187,10 +178,22 @@ def extra_flags(self, flags):
187178

188179

189180
def check_linecache_ipython(*args):
190-
"""Call linecache.checkcache() safely protecting our cached values.
181+
"""Deprecated since IPython 8.6. Call linecache.checkcache() directly.
182+
183+
It was already not necessary to call this function directly. If no
184+
CachingCompiler had been created, this function would fail badly. If
185+
an instance had been created, this function would've been monkeypatched
186+
into place.
187+
188+
As of IPython 8.6, the monkeypatching has gone away entirely. But there
189+
were still internal callers of this function, so maybe external callers
190+
also existed?
191191
"""
192-
# First call the original checkcache as intended
193-
linecache._checkcache_ori(*args)
194-
# Then, update back the cache with our data, so that tracebacks related
195-
# to our compiled codes can be produced.
196-
linecache.cache.update(linecache._ipython_cache)
192+
import warnings
193+
194+
warnings.warn(
195+
"Deprecated Since IPython 8.6, Just call linecache.checkcache() directly.",
196+
DeprecationWarning,
197+
stacklevel=2,
198+
)
199+
linecache.checkcache()

0 commit comments

Comments
 (0)