cpython
cpython copied to clipboard
bpo-43950: implement on-the-fly source tracking for interactive mode
Purely for design purposes, do not review/merge.
https://bugs.python.org/issue43950
One problem with this patch is that, we need to limit fetching from __source__ only for the main frame, otherwise if the offsets match out it will show something like this;
$ ./python
Python 3.11.0a0 (heads/[bpo-43950](https://bugs.python.org/issue43950)-source-tracking-dirty:1173c11e09, Jul 17 2021, 14:52:40) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def frame_3():
... return 1/0
...
>>> def frame_2():
... return frame_3()
...
>>> def frame_1():
... return frame_2()
...
>>> if True:
... 1+ frame_1()
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
1+ frame_1()
^^^^^^^^^
File "<stdin>", line 2, in frame_1
1+ frame_1()
^^^^^^^^^
File "<stdin>", line 2, in frame_2
1+ frame_1()
^^^^^^^^^
File "<stdin>", line 2, in frame_3
1+ frame_1()
^^^
ZeroDivisionError: division by zero
This PR is stale because it has been open for 30 days with no activity.
Hey @isidentical , can this be closed now?
Thanks for the reminder @CAM-Gerlach, this was mainly an experiment before it ever got to be a real PR so yep we can close it.