-
-
Notifications
You must be signed in to change notification settings - Fork 34k
Open
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixespendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibStandard 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 error
Description
Bug report
Bug description:
Hello, when faced with a file in a folder the user cannot read, there is a behavior change between python 3.13 and 3.14. In the script below, you can see that is_file() returns different results:
import sys
import tempfile
from pathlib import Path
print(f"Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
child = root / "child"
child.mkdir()
path_under_child = child / "nonexistent"
try:
child.chmod(0o000)
try:
result = path_under_child.is_file()
print(f" (child/nonexistent).is_file() = {result} (no exception)")
except OSError as e:
print(f" (child/nonexistent).is_file() raised: {type(e).__name__}: {e}")
finally:
child.chmod(0o755)
except OSError as e:
print(f" chmod failed: {e}")
print("Done")Here are the results:
Python 3.13.11
(child/nonexistent).is_file() raised: PermissionError: [Errno 13] Permission denied: '/tmp/tmpc2x6rhs9/child/nonexistent'
Done
and for 3.14:
Python 3.14.2
(child/nonexistent).is_file() = False (no exception)
Done
Is this an expected change? If so, it's not mentioned in the What's New section: https://docs.python.org/3/whatsnew/3.14.html#pathlib
or is it an unexpected breaking change? It's not the end of the world, but it means adding more logic to work for both codepaths
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixespendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibStandard 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 error