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 sfmc
Recipients sfmc
Date 2021-04-28.16:26:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1619627176.09.0.686852454721.issue43968@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-04-28 16:26:16sfmcsetrecipients: + sfmc
2021-04-28 16:26:16sfmcsetmessageid: <1619627176.09.0.686852454721.issue43968@roundup.psfhosted.org>
2021-04-28 16:26:16sfmclinkissue43968 messages
2021-04-28 16:26:16sfmccreate