Summary
inspect.getsource does not return full source for some(?) functions
Verified on commit 3dae07c built in release mode with rustc 1.93.0.
Expected
"""
import inspect
def a(
a=0,
):
0
a = inspect.getsource(a)
print(a)
# getsource should return the full source including "def a(",
# but RustPython returns only "a=0,\n): 0\n" (the last lines)
assert "def" in a, f"Expected full source, got: {a!r}"
This should (and does on cpython) print the following:
a=0,
Traceback (most recent call last):
File "/Users/drmaciver/Projects/hypothesis/rustpython-bugs/bug1_getsource_truncated.py", line 26, in <module>
assert "def" in a, f"Expected full source, got: {a!r}"
^
AssertionError: Expected full source, got: ' a=0,\n'
Python Documentation
(https://docs.python.org/3/library/inspect.html#inspect.getsource)
Summary
inspect.getsourcedoes not return full source for some(?) functionsVerified on commit 3dae07c built in release mode with rustc 1.93.0.
Expected
""" import inspect def a( a=0, ): 0 a = inspect.getsource(a) print(a) # getsource should return the full source including "def a(", # but RustPython returns only "a=0,\n): 0\n" (the last lines) assert "def" in a, f"Expected full source, got: {a!r}"This should (and does on cpython) print the following:
Python Documentation
(https://docs.python.org/3/library/inspect.html#inspect.getsource)