homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients ncoghlan, r.david.murray, vstinner, yselivanov
Date 2019年06月14日.11:13:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1560510813.27.0.459581465553.issue20443@roundup.psfhosted.org>
In-reply-to
Content
The site module tries to compute the absolute path of __file__ and __cached__ attributes of all modules in sys.modules:
def abs_paths():
 """Set all module __file__ and __cached__ attributes to an absolute path"""
 for m in set(sys.modules.values()):
 if (getattr(getattr(m, '__loader__', None), '__module__', None) not in
 ('_frozen_importlib', '_frozen_importlib_external')):
 continue # don't mess with a PEP 302-supplied __file__
 try:
 m.__file__ = os.path.abspath(m.__file__)
 except (AttributeError, OSError, TypeError):
 pass
 try:
 m.__cached__ = os.path.abspath(m.__cached__)
 except (AttributeError, OSError, TypeError):
 pass
The __path__ attribute isn't updated.
Another approach would be to hack importlib to compute the absolute path before loading a module, rather than trying to fix it *afterwards*.
One pratical problem: posixpath and ntpath are not available when importlib is setup, these modules are implemented in pure Python and so must be imported.
Maybe importlib could use a naive implementation of os.path.abspath(). Maybe the C function _Py_abspath() that I implemented in PR 14053 should be exposed somehow to importlib as a private function using a builtin module like _imp, so it can be used directly.
History
Date User Action Args
2019年06月14日 11:13:33vstinnersetrecipients: + vstinner, ncoghlan, r.david.murray, yselivanov
2019年06月14日 11:13:33vstinnersetmessageid: <1560510813.27.0.459581465553.issue20443@roundup.psfhosted.org>
2019年06月14日 11:13:33vstinnerlinkissue20443 messages
2019年06月14日 11:13:32vstinnercreate

AltStyle によって変換されたページ (->オリジナル) /