Skip to content

Commit

Permalink
Raise more appropriate exceptions when 'open' is invoked on missing i…
Browse files Browse the repository at this point in the history
…tems or directories. Fixes #46.
  • Loading branch information
jaraco committed Mar 3, 2020
1 parent bf4a22f commit ffee568
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions zipp.py
Expand Up @@ -220,7 +220,11 @@ def open(self, mode='r', *args, pwd=None, **kwargs):
of ``pathlib.Path.open()`` by passing arguments through
to io.TextIOWrapper().
"""
if self.is_dir():
raise IsADirectoryError(self)
zip_mode = mode[0]
if not self.exists() and zip_mode == 'r':
raise FileNotFoundError(self)
stream = self.root.open(self.at, zip_mode, pwd=pwd)
if 'b' in mode:
if args or kwargs:
Expand Down

0 comments on commit ffee568

Please sign in to comment.