alexmojaki / executing

Get information about what a Python frame is currently doing, particularly the AST node being executed
MIT License
330 stars 32 forks source link

Failed to detect nodes in ipython/jupyter since v1.1.0 #58

Closed pwwang closed 2 years ago

pwwang commented 2 years ago
Python 3.9.5 (default, Jun  4 2021, 12:28:51) 
Type 'copyright', 'credits' or 'license' for more information
IPython 8.1.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import sys 
   ...: from executing import Source, __version__ 
   ...:  
   ...:  
   ...: def get_node(): 
   ...:     frame = sys._getframe(1) 
   ...:     return Source.executing(frame).node 
   ...:  
   ...:  
   ...: node = get_node() 
   ...: print(node) 
   ...:
None

In [2]: __version__
Out[2]: '1.1.0'

Used to work with v1.0.0

Python 3.9.5 (default, Jun  4 2021, 12:28:51) 
Type 'copyright', 'credits' or 'license' for more information
IPython 8.1.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import sys 
   ...: from executing import Source, __version__ 
   ...:  
   ...:  
   ...: def get_node(): 
   ...:     frame = sys._getframe(1) 
   ...:     return Source.executing(frame).node 
   ...:  
   ...:  
   ...: node = get_node() 
   ...: print(node) 
   ...:
<ast.Call object at 0x7fb7de6748b0>

In [2]: __version__
Out[2]: '1.0.0'
pwwang commented 2 years ago

Related: https://github.com/pwwang/datar/issues/149

alexmojaki commented 2 years ago

Released fix in 1.1.1