Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os.path.realpath fails with WinError 161 #88980

Open
Spacetown mannequin opened this issue Aug 3, 2021 · 5 comments
Open

os.path.realpath fails with WinError 161 #88980

Spacetown mannequin opened this issue Aug 3, 2021 · 5 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Spacetown
Copy link
Mannequin

Spacetown mannequin commented Aug 3, 2021

BPO 44817
Nosy @pfmoore, @tjguk, @zware, @eryksun, @zooba, @Spacetown
PRs
  • bpo-44817: Ignore WinError 161 (ERROR_BAD_PATHNAME) #27574
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2021-08-03.05:24:11.950>
    labels = ['type-bug', '3.9', '3.10', '3.11', 'library', 'OS-windows']
    title = 'os.path.realpath fails with WinError 161'
    updated_at = <Date 2021-08-05.07:29:35.809>
    user = 'https://github.com/Spacetown'

    bugs.python.org fields:

    activity = <Date 2021-08-05.07:29:35.809>
    actor = 'Spacetown'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)', 'Windows']
    creation = <Date 2021-08-03.05:24:11.950>
    creator = 'Spacetown'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44817
    keywords = ['patch']
    message_count = 5.0
    messages = ['398814', '398835', '398931', '398956', '398972']
    nosy_count = 6.0
    nosy_names = ['paul.moore', 'tim.golden', 'zach.ware', 'eryksun', 'steve.dower', 'Spacetown']
    pr_nums = ['27574']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue44817'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @Spacetown
    Copy link
    Mannequin Author

    Spacetown mannequin commented Aug 3, 2021

    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.

    @Spacetown Spacetown mannequin added 3.8 (EOL) end of life stdlib Python modules in the Lib dir labels Aug 3, 2021
    @eryksun eryksun added OS-windows 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes type-bug An unexpected behavior, bug, or error and removed 3.8 (EOL) end of life labels Aug 3, 2021
    @eryksun
    Copy link
    Contributor

    eryksun commented Aug 3, 2021

    It should also ignore ERROR_BAD_NETPATH (53).

    @Spacetown
    Copy link
    Mannequin Author

    Spacetown mannequin commented Aug 4, 2021

    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)

    @eryksun
    Copy link
    Contributor

    eryksun commented Aug 4, 2021

    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

    @Spacetown
    Copy link
    Mannequin Author

    Spacetown mannequin commented Aug 5, 2021

    Done.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes 3.11 only security fixes OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant