File: __init__.py

package info (click to toggle)
python-eventlet 0.9.16-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,884 kB
  • sloc: python: 16,306; makefile: 97
file content (36 lines) | stat: -rw-r--r-- 1,179 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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:
    from sys import exc_clear as clear_sys_exc_info
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

if sys.version_info[0]==2 and sys.version_info[1]<5:
    class BaseException:                      # pylint: disable-msg=W0622
        # not subclassing from object() intentionally, because in
        # that case "raise Timeout" fails with TypeError.
        pass
else:
    from __builtin__ import BaseException