You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
inspect.getsource does not return full source for some functions #7517
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:
def a(
a=0,
):
0
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'
Activity
fanninpm commentedon Mar 27, 2026
This is being worked on in #7519.
youknowone commentedon Mar 30, 2026
Fixed by #7519, thank you for the report!