New submission from daniel hahler <[email protected]>:
With "." in sys.path the "__file__" attribute will be a relative path, and
therefore cannot be used after "chdir".
This likely affects relative paths in general, but have not tested it.
```
import os
import sys
sys.path.insert(0, '.')
# Importing it before chdir already causes failure.
import imported
os.chdir('/')
print(imported.__file__) # ./imported.py
assert imported.__file__ == os.path.abspath(imported.__file__)
```
It works for "" in sys.path (https://bugs.python.org/issue18416).
----------
components: Interpreter Core
messages: 323800
nosy: blueyed
priority: normal
severity: normal
status: open
title: Module's __file__ should be absolute always ("." in sys.path)
versions: Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue34444>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com