diff --git a/newsfragments/1a1928d.feature.rst b/newsfragments/1a1928d.feature.rst new file mode 100644 index 0000000..2285857 --- /dev/null +++ b/newsfragments/1a1928d.feature.rst @@ -0,0 +1 @@ +Improve performances of :meth:`zipfile.Path.open` for non-reading modes. diff --git a/zipp/__init__.py b/zipp/__init__.py index cb4f42c..031d9d4 100644 --- a/zipp/__init__.py +++ b/zipp/__init__.py @@ -343,7 +343,7 @@ def open(self, mode='r', *args, pwd=None, **kwargs): 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: