~ubuntu-branches/ubuntu/wily/pyzmq/wily

« back to all changes in this revision

Viewing changes to zmq/core/error.pyx

  • Committer: Package Import Robot
  • Author(s): Julian Taylor, Julian Taylor, Jakub Wilk
  • Date: 2013-05-09 15:07:29 UTC
  • mfrom: (2.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20130509150729-1xf0eb5wrokflfm7
Tags: 2.2.0.1-2
[ Julian Taylor ]
* upload to unstable
* python-gevent-dbg is fixed, enable python2 dbg autopkgtests
* cython0.19-compat.patch: fix build with cython 0.19

[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
from zmq.utils.strtypes import bytes
35
35
 
36
 
def strerror(int errnum):
37
 
    """strerror(errnum)
 
36
def strerror(int errno):
 
37
    """strerror(errno)
38
38
 
39
39
    Return the error string given the error number.
40
40
    """
41
41
    cdef const_char_ptr str_e
42
42
    # char * will be a bytes object:
43
 
    with nogil:
44
 
        str_e = zmq_strerror(errnum)
 
43
    str_e = zmq_strerror(errno)
45
44
    if str is bytes:
46
45
        # Python 2: str is bytes, so we already have the right type
47
46
        return str_e
60
59
 
61
60
    Parameters
62
61
    ----------
63
 
    error : int
 
62
    errno : int
64
63
        The ZMQ errno or None.  If None, then ``zmq_errno()`` is called and
65
64
        used.
 
65
    msg : string
 
66
        Description of the error or None.
66
67
    """
 
68
    errno = None
67
69
 
68
 
    def __init__(self, error=None):
 
70
    def __init__(self, errno=None, msg=None):
69
71
        """Wrap an errno style error.
70
72
 
71
73
        Parameters
72
74
        ----------
73
 
        error : int
 
75
        errno : int
74
76
            The ZMQ errno or None.  If None, then ``zmq_errno()`` is called and
75
77
            used.
 
78
        msg : string
 
79
            Description of the error or None.
76
80
        """
77
 
        cdef int errno
78
 
        if error is None:
79
 
            with nogil:
80
 
                errno = zmq_errno()
 
81
        if errno is None:
 
82
            errno = zmq_errno()
81
83
            error = errno
82
 
        if type(error) == int:
83
 
            self.strerror = strerror(error)
84
 
            self.errno = error
 
84
        if type(errno) == int:
 
85
            self.errno = errno
 
86
            if msg is None:
 
87
                self.strerror = strerror(errno)
 
88
            else:
 
89
                self.strerror = msg
85
90
        else:
86
 
            self.strerror = str(error)
87
 
            self.errno = None
 
91
            if msg is None:
 
92
                self.strerror = str(errno)
 
93
            else:
 
94
                self.strerror = msg
88
95
        # flush signals, because there could be a SIGINT
89
96
        # waiting to pounce, resulting in uncaught exceptions.
90
97
        # Doing this here means getting SIGINT during a blocking