[issue1692664] warnings.py gets filename wrong for eval/exec

2018-04-27 Thread Thomas Kluyver

Thomas Kluyver  added the comment:

Thanks Guido, the new issue is #33375.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1692664] warnings.py gets filename wrong for eval/exec

2018-04-27 Thread Guido van Rossum

Guido van Rossum  added the comment:

I recommend opening a new issue (you can link to this one for past discussion).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1692664] warnings.py gets filename wrong for eval/exec

2018-04-27 Thread Thomas Kluyver

Thomas Kluyver  added the comment:

Time for some bug archaeology!

The reason given for not using frame.f_code.co_filename for warnings was that 
it can be wrong when the path of .pyc files changes. However, it looks like 
that was fixed in #1180193 (thanks for the pointer zseil), so I'd like this 
idea to be reconsidered.

Python uses frame.f_code.co_filename for tracebacks and in pdb, so it's 
counterintuitive that the warnings module works differently. They are all 
trying to do the same thing: find and show the bit of code that you're 
interested in.

This causes problems in IPython with warnings attributed to interactive code: 
warnings sees it all as part of the __main__ module, so we can't distinguish 
which input it's pointing to (it's usually obvious, but still...). We have 
integrated with linecache to make tracebacks work, and I think that if warnings 
used code.co_filename, it would also work as expected.

--
nosy: +takluyver

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com