Skip to content

Commit

Permalink
Fix error reporting with Unicode filenames
Browse files Browse the repository at this point in the history
Close #136
  • Loading branch information
hgrecco committed Aug 24, 2015
1 parent 3f69464 commit 4f428b2
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions pyvisa/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,19 +439,22 @@ class LibraryError(OSError, Error):
@classmethod
def from_exception(cls, exc, filename):

msg = str(exc)
try:
msg = str(exc)

if ': image not found' in msg:
msg = ' File not found or not readable.'
if ': image not found' in msg:
msg = ' File not found or not readable.'

elif ': no suitable image found' in msg:
if 'no matching architecture' in msg:
elif ': no suitable image found' in msg:
if 'no matching architecture' in msg:
return LibraryError.from_wrong_arch(filename)
else:
msg = 'Could not determine filetype.'

elif 'wrong ELF class' in msg:
return LibraryError.from_wrong_arch(filename)
else:
msg = 'Could not determine filetype.'

elif 'wrong ELF class' in msg:
return LibraryError.from_wrong_arch(filename)
except UnicodeDecodeError:
return cls('Error while accessing %s:' % filename)

return cls('Error while accessing %s: %s' % (filename, msg))

Expand Down

0 comments on commit 4f428b2

Please sign in to comment.