You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking at the source code for io.py, it's clear the error stems from here:
try:
reader=READERS.get_a_plugin(file_type, library)
exceptNoSupportingPluginFound:
iffile_name:
ifnotos.path.exists(file_name):
raiseIOError("%s does not exist"%file_name)
else:
raise
The except block is entered, but the first if is true while the second if is false (because the path does exist, it is just a directory rather than a file), so no new exception is raised. The code continues on until reader is referenced again, which fails because it was never defined.
Expected behavior:
That os.path.exists check should probably be os.path.isfile instead, and the error message should be "%s is not a file" rather than "%s does not exist". That if should also then have an else that raises an exception, so you are never stuck in a position where reader is undefined and you are left with an UnboundLocalError. Something like this:
try:
reader=READERS.get_a_plugin(file_type, library)
exceptNoSupportingPluginFound:
ifnotos.path.isfile(file_name):
raiseIOError("%s is not a file"%file_name)
else:
raise
The text was updated successfully, but these errors were encountered:
After installing
pyexcel-xlsxr
, running the following file gives an unhelpful error message:Looking at the source code for
io.py
, it's clear the error stems from here:The
except
block is entered, but the firstif
is true while the secondif
is false (because the path does exist, it is just a directory rather than a file), so no new exception is raised. The code continues on untilreader
is referenced again, which fails because it was never defined.Expected behavior:
That
os.path.exists
check should probably beos.path.isfile
instead, and the error message should be"%s is not a file"
rather than"%s does not exist"
. Thatif
should also then have anelse
that raises an exception, so you are never stuck in a position wherereader
is undefined and you are left with anUnboundLocalError
. Something like this:The text was updated successfully, but these errors were encountered: