You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2025-08-10 22:42:05 +02:00
Review OSError exceptions handling (#1080)
- Replace obsolete `IOError` (Python 2) with `OSError`, cf https://docs.python.org/3/library/exceptions.html#OSError. - Improve `OSError` catches at different places, simplifying the code.
This commit is contained in:
committed by
GitHub
parent
a61f9e1114
commit
8374a9ed83
@@ -106,7 +106,7 @@ def process_file_upload_arg(arg: KeyValueArg) -> Tuple[str, IO, str]:
|
||||
mime_type = parts[1] if len(parts) > 1 else None
|
||||
try:
|
||||
f = open(os.path.expanduser(filename), 'rb')
|
||||
except IOError as e:
|
||||
except OSError as e:
|
||||
raise ParseError(f'{arg.orig!r}: {e}')
|
||||
return (
|
||||
os.path.basename(filename),
|
||||
@@ -139,7 +139,7 @@ def load_text_file(item: KeyValueArg) -> str:
|
||||
try:
|
||||
with open(os.path.expanduser(path), 'rb') as f:
|
||||
return f.read().decode()
|
||||
except IOError as e:
|
||||
except OSError as e:
|
||||
raise ParseError(f'{item.orig!r}: {e}')
|
||||
except UnicodeDecodeError:
|
||||
raise ParseError(
|
||||
|
Reference in New Issue
Block a user