Message323192
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 |
|
Date |
User |
Action |
Args |
2018-08-06 10:19:08 | erik.bray | set | recipients:
+ erik.bray, brett.cannon, paul.moore, ncoghlan, scoder, petr.viktorin, eric.snow, sth, jdemeyer |
2018-08-06 10:19:07 | erik.bray | set | messageid: <1533550747.88.0.56676864532.issue32797@psf.upfronthosting.co.za> |
2018-08-06 10:19:07 | erik.bray | link | issue32797 messages |
2018-08-06 10:19:07 | erik.bray | create | |
|