On Tue, Apr 20, 2021 at 6:50 PM Chris Angelico <ros...@gmail.com> wrote:

> On Wed, Apr 21, 2021 at 7:46 AM Rob Cliffe via Python-ideas
> <python-ideas@python.org> wrote:
> > On 20/04/2021 19:23, Pol Welter wrote:
> > > Would it be reasonable to include the line number for the function
> `foo()` that it resolved the call to? I.e. 'File "<stdin>", line 1, in foo'.
> > And presumably the module name as well.  If foo had been imported from a
> > different module instead of defined in the current one, the line number
> > alone would be less helpful.
>
> Maybe the easiest/best way would be to have a reference to the
> function itself available on the exception object?
>

I personally think that the easiest/best way would be for Python to use
something like "<stdin-N>" as a "file" name in its repl and in exec, and
use linecache to store each file. This way, the file content (and line
number, etc.) could be retrieved and included in the traceback. This is
often done in other REPLs (such as IPython and IDLE's pyshell).

André Roberge

ChrisA
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/XU72HFNXA2GAGBDHEU2SQMGEGSGWA7S4/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/EAHJCXCPMBH7NKZCA7MRDR7LRBTVJMFV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to