Skip to content

dill.source.getsource fails inside of ipython #346

@mmckerns

Description

@mmckerns

tested in python 3.6.9. dill.source.getsource fails to recognize a function defined in the current session. (using most current bleeding edge build of dill).

Works in python:

Python 3.6.9 (default, Sep  7 2019, 21:14:28) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dill
>>> 
>>> def squared(x):
...   return x*x
... 
>>> dill.source.getsource(squared)
'def squared(x):\n  return x*x\n'
>>> 

Fails in ipython:

Python 3.6.9 (default, Sep  7 2019, 21:14:28) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import dill                                                          

In [2]: def squared(x): 
   ...:     return x*x 
   ...:                                                                      

In [3]: dill.source.getsource(squared)[:20]                                                                  
Out[3]: '_HiStOrY_V2_\nimport\\'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions