Erik Bray <erik.m.b...@gmail.com> added the comment:

Brett:
> As Nick said, we have no generalized concept of source maps and I think
coming up with that is what will be required to solve this as i personally
don't view Loader.get_source() is not meant to be a generalized concept of
some form of source code but Python source code.

I see what you're saying here, but given that Loader can return Python modules 
that are ostensibly not actually generated from Python source code, then it's 
not *obvious* that Loader.get_source() must return Python source.  At the very 
least the documentation [1] should clarify this.  But it's also a bit 
arbitrarily limiting, especially given the demonstrable possibility of 
providing tracebacks and code inspection for *non-Python* code (as in the case 
of Cython) that compiles to Python modules.


Nick:
> 1. Enhance PathFinder to allow specification of which path importer cache and 
> path_hooks entries to use

This would be good.  Perhaps veering off-topic, but in an earlier attempt to 
fix this issue I actually tried to implement a sys.path_hooks hook for 
importing Cython modules such that I could provide an appropriate Loader for 
them with a get_source that actually works.  This turned out to be very 
difficult in large part due to the difficulty of customizing the relationship 
between the default PathFinder on sys.meta_path and the sys.path_hooks entries. 
 I made a post about this to python-ideas [2] but it never gained much 
traction, probably in large part due to the specialized nature of the problem 
and the complexity of my solution :)


[1] 
https://docs.python.org/3/library/importlib.html#importlib.abc.InspectLoader.get_source
[2] https://mail.python.org/pipermail/python-ideas/2018-February/048905.html

----------

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

Reply via email to