Author vstinner
Recipients ncoghlan, r.david.murray, vstinner, yselivanov
Date 2019-06-28.00:18:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561681103.33.0.105079209119.issue20443@roundup.psfhosted.org>
In-reply-to
Content
Example of case where a module path is still relative:
---
import sys
import os
modname = 'relpath'
filename = modname + '.py'
sys.path.insert(0, os.curdir)
with open(filename, "w") as fp:
    print("import sys", file=fp)
    print("mod = sys.modules[__name__]", file=fp)
    print("print(f'{__file__=}')", file=fp)
    print("print(f'{mod.__file__=}')", file=fp)
    print("print(f'{mod.__cached__=}')", file=fp)
__import__(modname)
os.unlink(filename)
---

Output:
---
__file__='./relpath.py'
mod.__file__='./relpath.py'
mod.__cached__='./__pycache__/relpath.cpython-39.pyc'
---

__file__ and mod.__file__ are relative paths: not absolute paths.
History
Date User Action Args
2019-06-28 00:18:23vstinnersetrecipients: + vstinner, ncoghlan, r.david.murray, yselivanov
2019-06-28 00:18:23vstinnersetmessageid: <1561681103.33.0.105079209119.issue20443@roundup.psfhosted.org>
2019-06-28 00:18:23vstinnerlinkissue20443 messages
2019-06-28 00:18:23vstinnercreate