Files
deb-python-eventlet/eventlet/common.py
amajorek e3ac6b4c99 Added clear_sysy_exc_info to eventlet.common.
Portable clearing of last exception information - No-op in 3.x and ys.exc_clear in 2.x
2010-02-28 15:18:30 -05:00

29 lines
853 B
Python

import sys
def get_errno(exc):
""" Get the error code out of socket.error objects.
socket.error in <2.5 does not have errno attribute
socket.error in 3.x does not allow indexing access
e.args[0] works for all.
There are cases when args[0] is not errno.
i.e. http://bugs.python.org/issue6471
Maybe there are cases when errno is set, but it is not the first argument?
"""
try:
if exc.errno is not None: return exc.errno
except AttributeError:
pass
try:
return exc.args[0]
except IndexError:
return None
if sys.version_info[0]<3:
clear_sys_exc_info = sys.exc_clear
else:
def clear_sys_exc_info():
"""No-op In py3k.
Exception information is not visible outside of except statements.
sys.exc_clear became obsolete and removed."""
pass