Message392234
For example if I mount directory
C:\example\dir
to
Z:\
the
os.path.realpath('Z:\\')
returns the real directory.
Use following commands in Windows to reproduce the issue:
md C:\example\dir
subst Z: C:\example\dir
python.exe -c "import os; print(os.path.realpath('Z:\\'))"
Python 3.8 outputs:
C:\example\dir
Python 3.7 outputs:
Z:\
This is unexpected behavior change and it breaks our scripts in many places, because we use mounts in Windows ("subst" command) and Linux ("mount" command).
We had to add our own implementation for realpath to our scripts, but it also affects other tools, such as Python debugger (breakpoints stopped working) and IDEs (such as PyCharm).
It can be argued whether the behavior to resolve mounts is good.
But this change breaks the ability to work with Python scripts in mounts.
I hope it can be fixed in Python 3.8.10.
I propose to fix it in Python 3.8.10 by adding to function
os.path.realpath(path)
a new parameter (named for example "resolve_mounts"), like that:
os.path.realpath(path, *, resolve_mounts=False)
And if resolve_mounts==False, then the function should not resolve mounts in Windows ("subst" command) and Linux ("mount" command).
Let me know if you wish to get a Pull Request with the proposed fix. I can try to implement it. |
|
Date |
User |
Action |
Args |
2021-04-28 16:26:16 | sfmc | set | recipients:
+ sfmc |
2021-04-28 16:26:16 | sfmc | set | messageid: <1619627176.09.0.686852454721.issue43968@roundup.psfhosted.org> |
2021-04-28 16:26:16 | sfmc | link | issue43968 messages |
2021-04-28 16:26:16 | sfmc | create | |
|