aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py3/IPython/core/compilerop.py
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.ru>2022-05-18 00:43:36 +0300
committerrobot-contrib <robot-contrib@yandex-team.ru>2022-05-18 00:43:36 +0300
commit9e5f436a8b2a27bcc7802e443ea3ef3e41a82a75 (patch)
tree78b522cab9f76336e62064d4d8ff7c897659b20e /contrib/python/ipython/py3/IPython/core/compilerop.py
parent8113a823ffca6451bb5ff8f0334560885a939a24 (diff)
downloadydb-9e5f436a8b2a27bcc7802e443ea3ef3e41a82a75.tar.gz
Update contrib/python/ipython/py3 to 8.3.0
ref:e84342d4d30476f9148137f37fd0c6405fd36f55
Diffstat (limited to 'contrib/python/ipython/py3/IPython/core/compilerop.py')
-rw-r--r--contrib/python/ipython/py3/IPython/core/compilerop.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/contrib/python/ipython/py3/IPython/core/compilerop.py b/contrib/python/ipython/py3/IPython/core/compilerop.py
index 50672a1954..b43e570b3a 100644
--- a/contrib/python/ipython/py3/IPython/core/compilerop.py
+++ b/contrib/python/ipython/py3/IPython/core/compilerop.py
@@ -92,6 +92,10 @@ class CachingCompiler(codeop.Compile):
# (otherwise we'd lose our tracebacks).
linecache.checkcache = check_linecache_ipython
+ # Caching a dictionary { filename: execution_count } for nicely
+ # rendered tracebacks. The filename corresponds to the filename
+ # argument used for the builtins.compile function.
+ self._filename_map = {}
def ast_parse(self, source, filename='<unknown>', symbol='exec'):
"""Parse code to an AST with the current compiler flags active.
@@ -118,12 +122,12 @@ class CachingCompiler(codeop.Compile):
Parameters
----------
raw_code : str
- The raw cell code.
+ The raw cell code.
transformed_code : str
- The executable Python source code to cache and compile.
+ The executable Python source code to cache and compile.
number : int
- A number which forms part of the code's name. Used for the execution
- counter.
+ A number which forms part of the code's name. Used for the execution
+ counter.
Returns
-------
@@ -137,12 +141,12 @@ class CachingCompiler(codeop.Compile):
Parameters
----------
transformed_code : str
- The executable Python source code to cache and compile.
+ The executable Python source code to cache and compile.
number : int
- A number which forms part of the code's name. Used for the execution
- counter.
+ A number which forms part of the code's name. Used for the execution
+ counter.
raw_code : str
- The raw code before transformation, if None, set to `transformed_code`.
+ The raw code before transformation, if None, set to `transformed_code`.
Returns
-------
@@ -153,6 +157,10 @@ class CachingCompiler(codeop.Compile):
raw_code = transformed_code
name = self.get_code_name(raw_code, transformed_code, number)
+
+ # Save the execution count
+ self._filename_map[name] = number
+
entry = (
len(transformed_code),
time.time(),