[issue16974] when "python -c command" does a traceback, it open the file "<string>"
AWhetter
report at bugs.python.org
Fri Oct 4 13:05:50 EDT 2019
AWhetter <ashley at awhetter.co.uk> added the comment:
If we were to add a new attribute to indicate whether a file is real or not, there would need to be a way for users to indicate whether a file is real or not to functions such as `compile()` (there's lots more!) that take a filename. Without enforcing this being set and introducing backward incompatible changes, it would need a default value. To be backwards compatible we could default to True and the existing behaviour persists.
It's also worth mentioning that there's a few places (there might be more!) where Python already assumes that a file in angle brackets is not a real file:
* https://github.com/python/cpython/blob/abd7cd856ba326bd7574135c7d034e98492ab695/Lib/bdb.py#L45
* https://github.com/python/cpython/blob/abd7cd856ba326bd7574135c7d034e98492ab695/Lib/pdb.py#L694
* https://github.com/python/cpython/blob/abd7cd856ba326bd7574135c7d034e98492ab695/Lib/pickle.py#L324
Nothing major though and easily changeable so it's definitely possible but it would be a lot of work to make sure that everything is setting the new attribute properly.
Is there a preference on what the name of this attribute should be? Maybe `__is_real_file__`. It's clear but long.
----------
nosy: +AWhetter
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue16974>
_______________________________________
More information about the Python-bugs-list
mailing list