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.

classification
Title: os.path.realpath fails with WinError 161
Type: behavior Stage: patch review
Components: Library (Lib), Windows Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Spacetown, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: patch

Created on 2021-08-03 05:24 by Spacetown, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 27574 open Spacetown, 2021-08-03 05:41
Messages (5)
msg398814 - (view) Author: Michael Förderer (Spacetown) * Date: 2021-08-03 05:24
Using os.path.realpath(...) in the MVFS of Clearcase SCM (virtual file system) in Windows 10 a exception occures:

X:\my_view\tools\python\3_8>python.exe
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.realpath('.')
Traceback (most recent call last):
  File "X:\my_view\tools\python\3_8\lib\ntpath.py", line 647, in realpath
    path = _getfinalpathname(path)
OSError: [WinError 87] Falscher Parameter: 'X:\\my_view\\tools\\python\\3_8\\.'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "X:\my_view\tools\python\3_8\lib\ntpath.py", line 651, in realpath
    path = _getfinalpathname_nonstrict(path)
  File "X:\my_view\tools\python\3_8\lib\ntpath.py", line 601, in _getfinalpathname_nonstrict
    path = _getfinalpathname(path)
FileNotFoundError: [WinError 161] Der angegebene Pfadname ist ungültig: 'X:\\'
>>> 

The error 161 (ERROR_BAD_PATHNAME) should also be ignored in _getfinalpathname_nonstrict.
msg398835 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2021-08-03 15:46
It should also ignore ERROR_BAD_NETPATH (53).
msg398931 - (view) Author: Michael Förderer (Spacetown) * Date: 2021-08-04 18:31
Updated with ERROR_BAD_NETPATH (53).
What about following errors:
- ERROR_LOCK_VIOLATION (33)
- ERROR_DEV_NOT_EXIST (52)
- ERROR_BAD_NET_RESP (58)
- ERROR_UNEXP_NET_ERR (59)
- ERROR_NETNAME_DELETED (64)
- ERROR_NETWORK_ACCESS_DENIED (65)
- ERROR_BAD_DEV_TYPE (66)
msg398956 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2021-08-04 21:46
ERROR_NETWORK_ACCESS_DENIED (65) should probably be added to the ignore list. I don't know whether it occurs in practice, but we have it mapped to EACCES in PC/errmap.h. The common access error is ERROR_ACCESS_DENIED (5), even on a UNC share with restricted access.

Add ERROR_DEV_NOT_EXIST (55) only if you have a case that fails with this error code. It's from the NT status code STATUS_DEVICE_DOES_NOT_EXIST. This might occur when trying to automount a device that's pending removal (see the implementation in ReactOS IopMountVolume [1]), but I can't create this condition. I think a device object would need to be practically stuck in the pending removal state for this to be a practical problem.

ERROR_LOCK_VIOLATION (33) isn't relevant. It's an I/O access error for a locked range of a file. realpath() doesn't read or write file data.

For the others, I'd wait for an issue to be reported. 

---

[1] https://github.com/reactos/reactos/blob/master/ntoskrnl/io/iomgr/volume.c#L457
msg398972 - (view) Author: Michael Förderer (Spacetown) * Date: 2021-08-05 07:29
Done.
History
Date User Action Args
2022-04-11 14:59:48adminsetgithub: 88980
2021-08-05 07:29:35Spacetownsetmessages: + msg398972
2021-08-04 21:46:25eryksunsetmessages: + msg398956
2021-08-04 18:31:41Spacetownsetmessages: + msg398931
2021-08-03 15:46:27eryksunsetnosy: + eryksun
messages: + msg398835
2021-08-03 14:51:01eryksunsetnosy: + paul.moore, tim.golden, zach.ware, steve.dower

type: behavior
components: + Windows
versions: + Python 3.9, Python 3.10, Python 3.11, - Python 3.8
2021-08-03 05:41:08Spacetownsetkeywords: + patch
stage: patch review
pull_requests: + pull_request26081
2021-08-03 05:24:11Spacetowncreate