Skip to content

Commit

Permalink
Catch UnicodeDecodeError when embedding file via =@ or :=@.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbrzt committed Jan 25, 2014
1 parent 748a0a4 commit 1aa7701
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion httpie/input.py
Expand Up @@ -608,7 +608,13 @@ def parse_items(items, data=None, headers=None, files=None, params=None):
with open(os.path.expanduser(value), 'rb') as f:
value = f.read().decode('utf8')
except IOError as e:
raise ParseError('%s": %s' % (item.orig, e))
raise ParseError('"%s": %s' % (item.orig, e))
except UnicodeDecodeError:
raise ParseError(
'"%s": cannot embed the content of "%s",'
' not a UTF8 or ASCII-encoded text file'
% (item.orig, item.value)
)

if item.sep in SEP_GROUP_RAW_JSON_ITEMS:
try:
Expand Down

0 comments on commit 1aa7701

Please sign in to comment.