Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pathlib.Path.resolve() mishandles symlink loops #109187

Closed
Labels
@barneygale

Description

@barneygale

Bug report

Bug description:

Two closely-related issues inpathlib.Path.resolve():

First,resolve(strict=True) raisesRuntimeError rather thanOSError when a symlink loop is encountered. This is done only for backwards compatibility, since#25264 made pathlib callos.path.realpath(). It should raiseOSError(ELOOP)

Second,resolve(strict=False) suppresses every kind of OS errorexcept symlink loop errors. Again this is only for backwards compatibility. It should suppress exceptions about symlink loops.

Relevant code:

cpython/Lib/pathlib.py

Lines 1233 to 1252 ine21c89f

defcheck_eloop(e):
winerror=getattr(e,'winerror',0)
ife.errno==ELOOPorwinerror==_WINERROR_CANT_RESOLVE_FILENAME:
raiseRuntimeError("Symlink loop from %r"%e.filename)
try:
s=os.path.realpath(self,strict=strict)
exceptOSErrorase:
check_eloop(e)
raise
p=self.with_segments(s)
# In non-strict mode, realpath() doesn't raise on symlink loops.
# Ensure we get an exception by calling stat()
ifnotstrict:
try:
p.stat()
exceptOSErrorase:
check_eloop(e)
returnp

CPython versions tested on:

3.11, 3.12, CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp