New submission from Eric Snow:

(a generalization of issue #21335)

One way or another, we should be able to record the appropriate path in the 
resulting data when a module is frozen.  Keeping track of the source location 
is useful when debugging, especially with tracebacks.  Also see a related 
conversation on python-dev. [1]

If the original filename for a frozen module is preserved, several 
possibilities open up:

* the `get_source` method of `importlib._bootstrap.FrozenImporter` could return 
the original source
* the traceback module could work around the co_filename issue pointed out in 
#21335
* the filename could be incorporated into the value set for co_filename and 
__file__
* frozen modules could be optionally reloaded from source

Given that the filename would (likely) be available only through loading the 
module, it *might* not make sense to store it on the module's spec.  However, 
it might also make sense to store the filename in a way that it can be exposed 
during the "find" stage of import.  In that case it would arguably *belong* on 
the module's spec.

Note that there's a chance that the original filename for a frozen module is no 
longer available.  That shouldn't be much of a problem, though.


[1] https://mail.python.org/pipermail/python-dev/2014-April/134097.html

----------
components: Library (Lib)
messages: 251851
nosy: brett.cannon, eric.snow, ncoghlan
priority: low
severity: normal
stage: needs patch
status: open
title: Support pointing frozen modules to the corresponding source files, if 
available.
type: enhancement
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25268>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to