Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get dill.source.getsource to work in PyCharm #359

Closed
amine-aboufirass opened this issue Mar 22, 2020 · 6 comments
Closed

Can't get dill.source.getsource to work in PyCharm #359

amine-aboufirass opened this issue Mar 22, 2020 · 6 comments

Comments

@amine-aboufirass
Copy link

I am working with the following:

  • python version 3.6.7
  • dill version :
# Name                    Version                   Build  Channel
dill                      0.3.1.1          py36h9f0ad1d_1    conda-forge

In a regular python interpreter in PyCharm I am running the following commands:

>>> def f(x): return x+1
>>> import dill
>>> dill.source.getsource(f)

The last line throws the following error:

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\aboufira\AppData\Local\Continuum\miniconda3\envs\fipy-dev\lib\site-packages\dill\source.py", line 354, in getsource
lines, lnum = getsourcelines(object, enclosing=enclosing)
File "C:\Users\aboufira\AppData\Local\Continuum\miniconda3\envs\fipy-dev\lib\site-packages\dill\source.py", line 325, in getsourcelines
code, n = getblocks(object, lstrip=lstrip, enclosing=enclosing, locate=True)
File "C:\Users\aboufira\AppData\Local\Continuum\miniconda3\envs\fipy-dev\lib\site-packages\dill\source.py", line 251, in getblocks
lines, lnum = findsource(object)
File "C:\Users\aboufira\AppData\Local\Continuum\miniconda3\envs\fipy-dev\lib\site-packages\dill\source.py", line 154, in findsource
raise IOError('could not extract source code')
OSError: could not extract source code

When running from a script however, this seems to work fine.

@mmckerns
Copy link
Member

I think this is a compatibility issue with pycharm, not dill itself. I tested your version of dill and python on Windows, and it works fine. It's known that dill.source and IPython have some compatibility issues, so I'm assuming that interaction with pycharm is the issue. Can you try an interpreter without using pycharm (e.g. in the command shell)?

@amine-aboufirass
Copy link
Author

I tried and it works outside of pycharm. I will log an issue with Pycharm. Thanks.

@mmckerns mmckerns changed the title Can't get dill.source.getsource to work in interpreter Can't get dill.source.getsource to work in PyCharm Mar 23, 2020
@mmckerns
Copy link
Member

Can you link the issue with this one? On cross-comparability issues, any mods may need to be made here or there, or both.

@amine-aboufirass
Copy link
Author

@mmckerns here it is

https://youtrack.jetbrains.com/issue/PY-41239

I still didn't get a response on it though...

@mmckerns
Copy link
Member

mmckerns commented Apr 2, 2020

Cross-module compatibility issues can take a while. Hopefully you get some movement on it here or there.

@mmckerns
Copy link
Member

@amine-aboufirass: as PyCharm uses IPython, and we just applied a PR (#531) for getsource in IPython, I think I can assume it fixes this issue as well. Please reopen if you find that it did not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants