When working in the terminal with the following code, an error occurs:
from pscript import py2js
def foo(a, b=2):
print(a - b)
print(py2js(foo))
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pscript/functions.py", line 77, in py2js_
lines, linenr = inspect.getsourcelines(ob)
File "/usr/lib/python3.6/inspect.py", line 955, in getsourcelines
lines, lnum = findsource(object)
File "/usr/lib/python3.6/inspect.py", line 786, in findsource
raise OSError('could not get source code')
OSError: could not get source code
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/pscript/functions.py", line 145, in py2js
return py2js_(ob)
File "/usr/local/lib/python3.6/dist-packages/pscript/functions.py", line 80, in py2js_
(ob, err))
ValueError: Could not get source code for object <function foo at 0x7fc97016aea0>: could not get source code
When studying, it becomes clear that inspect.getsource(foo) gives an error when working in the terminal. But if you use the module dill then everything is ok.
from dill.source import getsource
print(getsource(foo))
When working in the terminal with the following code, an error occurs:
When studying, it becomes clear that
inspect.getsource(foo)gives an error when working in the terminal. But if you use the module dill then everything is ok.