Skip to content

os.path.realpath fails with WinError 161 #88980

Closed

Description

@Spacetown
mannequin
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']

    Activity

    1. added
      type-bugAn unexpected behavior, bug, or error
      and removed on Aug 3, 2021
    2. eryksun commented on Aug 3, 2021

      @eryksun
      Contributor

      It should also ignore ERROR_BAD_NETPATH (53).

    3. Spacetown commented on Aug 4, 2021

      Spacetownmannequin
      MannequinAuthor

      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)
    4. eryksun commented on Aug 4, 2021

      @eryksun
      Contributor

      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

    5. Spacetown commented on Aug 5, 2021

      Spacetownmannequin
      MannequinAuthor

      Done.

    6. transferred this issue fromon Apr 10, 2022
    7. added
      3.13only security fixes
      3.14bugs and security fixes
      3.15bugs and security fixes
      and removed
      3.11only security fixes
      on May 19, 2025
    8. added
      3.11only security fixes
      3.12only security fixes
      and removed
      3.13only security fixes
      3.14bugs and security fixes
      3.15bugs and security fixes
      on May 19, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.10 (EOL)end of life3.11only security fixes3.12only security fixesOS-windowsstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions