GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Python 3.9.23 regression for `Path.resolve()` on Windows with `WinError 53` · Issue #136755 · python/cpython

Python 3.9.23 regression for Path.resolve() on Windows with WinError 53 #136755

New issue
Copy link
New issue
Copy link
Closed
Closed
Python 3.9.23 regression for Path.resolve() on Windows with WinError 53#136755
Copy link
Labels
3.9 (EOL)end of lifeend of lifeOS-windowsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-securityA security issueA security issue

Description

@krassowski
krassowski
opened on Jul 18, 2025
Issue body actions

Bug report

Bug description:

from pathlib import Path

Path("//VBOXSVR/shared-folder").expanduser().resolve()

Raises FileNotFoundError: [WinError 53] The network path was not found: '\\\\VBOXSVR\\shared-folder\\'.

This appears to be a consequence of this backport:

  • [3.9] bpo-43757: Make pathlib use os.path.realpath() to resolve symlinks in a path (GH-25264) #135035 which rewrote the Path.resolve() to use os.path.realpath under the hood
  • which was a prerequisite for [3.9] gh-135034: Normalize link targets in tarfile, add os.path.realpath(strict='allow_missing') (GH-135037) #135084 security fix

By default the FileNotFoundError should be caught as a descendant of OSError, but since #135035 it is then also re-raised as it is not on the list of ignored Windows errors.

This passes on Python 3.10+ because 53: ERROR_BAD_NETPATH is included on the list since #27574:

cpython/Lib/ntpath.py

Lines 659 to 668 in 28937d3

# 53: ERROR_BAD_NETPATH
# 65: ERROR_NETWORK_ACCESS_DENIED
# 67: ERROR_BAD_NET_NAME (implies remote server unavailable)
# 87: ERROR_INVALID_PARAMETER
# 123: ERROR_INVALID_NAME
# 161: ERROR_BAD_PATHNAME
# 1005: ERROR_UNRECOGNIZED_VOLUME
# 1920: ERROR_CANT_ACCESS_FILE
# 1921: ERROR_CANT_RESOLVE_FILENAME (implies unfollowable symlink)
allowed_winerror = 1, 2, 3, 5, 21, 32, 50, 53, 65, 67, 87, 123, 161, 1005, 1920, 1921

but it it was not backported to 3.9:

cpython/Lib/ntpath.py

Lines 588 to 596 in 6c97200

# 21: ERROR_NOT_READY (implies drive with no media)
# 32: ERROR_SHARING_VIOLATION (probably an NTFS paging file)
# 50: ERROR_NOT_SUPPORTED
# 67: ERROR_BAD_NET_NAME (implies remote server unavailable)
# 87: ERROR_INVALID_PARAMETER
# 123: ERROR_INVALID_NAME
# 1920: ERROR_CANT_ACCESS_FILE
# 1921: ERROR_CANT_RESOLVE_FILENAME (implies unfollowable symlink)
allowed_winerror = 1, 2, 3, 5, 21, 32, 50, 67, 87, 123, 1920, 1921

And since this code path is now used for Path.resolve() since #135035 was merged and backported I think that #27574 should be backported to other Python version to preserve old behaviour.

    def normalized_uri(root_dir):
        """Attempt to make an LSP rootUri from a ContentsManager root_dir
    
        Special care must be taken around windows paths: the canonical form of
        windows drives and UNC paths is lower case
        """
>       root_uri = Path(root_dir).expanduser().resolve().as_uri()

C:\Users\runneradmin\miniconda3\envs\test\lib\site-packages\jupyter_lsp\paths.py:16: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = WindowsPath('//VBOXSVR/shared-folder/'), strict = False

    def resolve(self, strict=False):
        """
        Make the path absolute, resolving all symlinks on the way and also
        normalizing it (for example turning slashes into backslashes under
        Windows).
        """
    
        def check_eloop(e):
            winerror = getattr(e, 'winerror', 0)
            if e.errno == ELOOP or winerror == _WINERROR_CANT_RESOLVE_FILENAME:
                raise RuntimeError("Symlink loop from %r" % e.filename)
    
        try:
>           s = self._accessor.realpath(self, strict=strict)

C:\Users\runneradmin\miniconda3\envs\test\lib\pathlib.py:1140: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

path = '\\\\VBOXSVR\\shared-folder\\'

    def realpath(path, *, strict=False):
        path = normpath(path)
        if isinstance(path, bytes):
            prefix = b'\\\\?\\'
            unc_prefix = b'\\\\?\\UNC\\'
            new_unc_prefix = b'\\\\'
            cwd = os.getcwdb()
            # bpo-38081: Special case for realpath(b'nul')
            if normcase(path) == normcase(os.fsencode(devnull)):
                return b'\\\\.\\NUL'
        else:
            prefix = '\\\\?\\'
            unc_prefix = '\\\\?\\UNC\\'
            new_unc_prefix = '\\\\'
            cwd = os.getcwd()
            # bpo-38081: Special case for realpath('nul')
            if normcase(path) == normcase(devnull):
                return '\\\\.\\NUL'
        had_prefix = path.startswith(prefix)
    
        if strict is ALLOW_MISSING:
            ignored_error = FileNotFoundError
            strict = True
        elif strict:
            ignored_error = ()
        else:
            ignored_error = OSError
    
        if not had_prefix and not isabs(path):
            path = join(cwd, path)
        try:
            path = _getfinalpathname(path)
            initial_winerror = 0
        except ignored_error as ex:
            initial_winerror = ex.winerror
>           path = _getfinalpathname_nonstrict(path,
                                               ignored_error=ignored_error)

C:\Users\runneradmin\miniconda3\envs\test\lib\ntpath.py:663: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

path = '\\\\VBOXSVR\\shared-folder\\', ignored_error = <class 'OSError'>

    def _getfinalpathname_nonstrict(path, ignored_error=OSError):
        # These error codes indicate that we should stop resolving the path
        # and return the value we currently have.
        # 1: ERROR_INVALID_FUNCTION
        # 2: ERROR_FILE_NOT_FOUND
        # 3: ERROR_DIRECTORY_NOT_FOUND
        # 5: ERROR_ACCESS_DENIED
        # 21: ERROR_NOT_READY (implies drive with no media)
        # 32: ERROR_SHARING_VIOLATION (probably an NTFS paging file)
        # 50: ERROR_NOT_SUPPORTED
        # 67: ERROR_BAD_NET_NAME (implies remote server unavailable)
        # 87: ERROR_INVALID_PARAMETER
        # 123: ERROR_INVALID_NAME
        # 1920: ERROR_CANT_ACCESS_FILE
        # 1921: ERROR_CANT_RESOLVE_FILENAME (implies unfollowable symlink)
        allowed_winerror = 1, 2, 3, 5, 21, 32, 50, 67, 87, 123, 1920, 1921
    
        # Non-strict algorithm is to find as much of the target directory
        # as we can and join the rest.
        tail = ''
        while path:
            try:
>               path = _getfinalpathname(path)
E               FileNotFoundError: [WinError 53] The network path was not found: '\\\\VBOXSVR\\shared-folder\\'

CPython versions tested on:

3.9

Operating systems tested on:

Windows

Linked PRs

  • [3.9] gh-136755: Ignore additional errors in ntpath.realpath (GH-27574) #140008

Activity

  1. krassowski
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jul 18, 2025
  2. StanFromIreland commented on Jul 18, 2025

    @StanFromIreland
    StanFromIreland
    on Jul 18, 2025
    Member
    More actions

    Note that 3.9 is security only.

    CC @ambv @barneygale

  3. picnixz
    assigned
    picnixz
    and unassigned
    picnixz
    on Jul 18, 2025
  4. picnixz
    added
    3.9 (EOL)end of lifeend of life
    on Jul 18, 2025
  5. picnixz commented on Jul 18, 2025

    @picnixz
    picnixz
    on Jul 18, 2025
    Member
    More actions

    It's security-only but the backport was recent (June) so we should consider that the backport caused some relevant issues

    Reacted by Stan Ulbrych and Barney Gale
  6. picnixz
    added
    type-securityA security issueA security issue
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    topic-pathlib
    on Jul 18, 2025
  7. aisk
    added
    OS-windows
    on Jul 19, 2025
  8. StanFromIreland commented on Oct 2, 2025

    @StanFromIreland
    StanFromIreland
    on Oct 2, 2025
    Member
    More actions

    cc @ambv since 3.9's last release is quite soon.

  9. StanFromIreland commented on Oct 12, 2025

    @StanFromIreland
    StanFromIreland
    on Oct 12, 2025
    Member
    More actions

    I opened #140008 to backport 124ecd6 to 3.9 for @ambv if he wishes to fix this. Otherwise, feel free to close.

  10. ambv commented on Oct 20, 2025

    @ambv
    ambv
    on Oct 20, 2025
    Contributor
    More actions

    Yeah, sorry I missed this for 3.9.24. We'll release one last 3.9.25 that will include this fix, if nothing else.

    Reacted by Stan Ulbrych
  11. ambv
    added a commit that references this issue on Oct 20, 2025

    [3.9] gh-136755: Ignore additional errors in ntpath.realpath (GH-27574)…

    111bbc1
  12. StanFromIreland
    closed this as completedon Oct 22, 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.9 (EOL)end of lifeend of lifeOS-windowsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-securityA security issueA security issue

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.