summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/zipfile/_path/__init__.py2
-rw-r--r--Misc/NEWS.d/next/Library/2024-11-08-11-06-14.gh-issue-126565.dFFO22.rst1
2 files changed, 2 insertions, 1 deletions
diff --git a/Lib/zipfile/_path/__init__.py b/Lib/zipfile/_path/__init__.py
index c0e53e2..5ae16ec 100644
--- a/Lib/zipfile/_path/__init__.py
+++ b/Lib/zipfile/_path/__init__.py
@@ -339,7 +339,7 @@ class Path:
if self.is_dir():
raise IsADirectoryError(self)
zip_mode = mode[0]
- if not self.exists() and zip_mode == 'r':
+ if zip_mode == 'r' and not self.exists():
raise FileNotFoundError(self)
stream = self.root.open(self.at, zip_mode, pwd=pwd)
if 'b' in mode:
diff --git a/Misc/NEWS.d/next/Library/2024-11-08-11-06-14.gh-issue-126565.dFFO22.rst b/Misc/NEWS.d/next/Library/2024-11-08-11-06-14.gh-issue-126565.dFFO22.rst
new file mode 100644
index 0000000..2285857
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-11-08-11-06-14.gh-issue-126565.dFFO22.rst
@@ -0,0 +1 @@
+Improve performances of :meth:`zipfile.Path.open` for non-reading modes.