In Python, I came across very strange behavior that is incompatible.
...
except IOError as msg:
sys.exit("###ERROR IOError: %s" % (msg))
Normally this would get me a message like:
#
In the same cases, the above code gives me tupleinstead of the correct error message.
#
This is very strange, because in all cases the exception comes from the same python method, codecs.open(...)
What makes me wonder about this is that if I delete the processing, the exception will reach the top levels with the correct text (full error message), always!
except IOError as msg:
print(msg)
raise msg
In the above example, the complete message will always be printed, for example IOError: [Errno 13] Permission denied: u'filename'.
Why this is happening and how I can prevent it, I do not want to provide users with incomplete error messages.
, .
, sys.exit(), print(msg) , sys.exit not.