1/* Generated by Cython 0.21.2 */
2
3#define PY_SSIZE_T_CLEAN
4#ifndef CYTHON_USE_PYLONG_INTERNALS
5#ifdef PYLONG_BITS_IN_DIGIT
6#define CYTHON_USE_PYLONG_INTERNALS 0
7#else
8#include "pyconfig.h"
9#ifdef PYLONG_BITS_IN_DIGIT
10#define CYTHON_USE_PYLONG_INTERNALS 1
11#else
12#define CYTHON_USE_PYLONG_INTERNALS 0
13#endif
14#endif
15#endif
16#include "Python.h"
17#ifndef Py_PYTHON_H
18    #error Python headers needed to compile C extensions, please install development version of Python.
19#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
20    #error Cython requires Python 2.6+ or Python 3.2+.
21#else
22#define CYTHON_ABI "0_21_2"
23#include <stddef.h>
24#ifndef offsetof
25#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
26#endif
27#if !defined(WIN32) && !defined(MS_WINDOWS)
28  #ifndef __stdcall
29    #define __stdcall
30  #endif
31  #ifndef __cdecl
32    #define __cdecl
33  #endif
34  #ifndef __fastcall
35    #define __fastcall
36  #endif
37#endif
38#ifndef DL_IMPORT
39  #define DL_IMPORT(t) t
40#endif
41#ifndef DL_EXPORT
42  #define DL_EXPORT(t) t
43#endif
44#ifndef PY_LONG_LONG
45  #define PY_LONG_LONG LONG_LONG
46#endif
47#ifndef Py_HUGE_VAL
48  #define Py_HUGE_VAL HUGE_VAL
49#endif
50#ifdef PYPY_VERSION
51#define CYTHON_COMPILING_IN_PYPY 1
52#define CYTHON_COMPILING_IN_CPYTHON 0
53#else
54#define CYTHON_COMPILING_IN_PYPY 0
55#define CYTHON_COMPILING_IN_CPYTHON 1
56#endif
57#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600
58#define Py_OptimizeFlag 0
59#endif
60#define __PYX_BUILD_PY_SSIZE_T "n"
61#define CYTHON_FORMAT_SSIZE_T "z"
62#if PY_MAJOR_VERSION < 3
63  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
64  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
65          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
66  #define __Pyx_DefaultClassType PyClass_Type
67#else
68  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
69  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
70          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
71  #define __Pyx_DefaultClassType PyType_Type
72#endif
73#if PY_MAJOR_VERSION >= 3
74  #define Py_TPFLAGS_CHECKTYPES 0
75  #define Py_TPFLAGS_HAVE_INDEX 0
76  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
77#endif
78#if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE)
79  #define Py_TPFLAGS_HAVE_FINALIZE 0
80#endif
81#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
82  #define CYTHON_PEP393_ENABLED 1
83  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
84                                              0 : _PyUnicode_Ready((PyObject *)(op)))
85  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
86  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
87  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
88  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
89  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
90#else
91  #define CYTHON_PEP393_ENABLED 0
92  #define __Pyx_PyUnicode_READY(op)       (0)
93  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
94  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
95  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
96  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
97  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
98#endif
99#if CYTHON_COMPILING_IN_PYPY
100  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
101  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
102  #define __Pyx_PyFrozenSet_Size(s)         PyObject_Size(s)
103#else
104  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
105  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
106      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
107  #define __Pyx_PyFrozenSet_Size(s)         PySet_Size(s)
108#endif
109#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
110#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
111#if PY_MAJOR_VERSION >= 3
112  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
113#else
114  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
115#endif
116#if PY_MAJOR_VERSION >= 3
117  #define PyBaseString_Type            PyUnicode_Type
118  #define PyStringObject               PyUnicodeObject
119  #define PyString_Type                PyUnicode_Type
120  #define PyString_Check               PyUnicode_Check
121  #define PyString_CheckExact          PyUnicode_CheckExact
122#endif
123#if PY_MAJOR_VERSION >= 3
124  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
125  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
126#else
127  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
128  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
129#endif
130#ifndef PySet_CheckExact
131  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
132#endif
133#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
134#if PY_MAJOR_VERSION >= 3
135  #define PyIntObject                  PyLongObject
136  #define PyInt_Type                   PyLong_Type
137  #define PyInt_Check(op)              PyLong_Check(op)
138  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
139  #define PyInt_FromString             PyLong_FromString
140  #define PyInt_FromUnicode            PyLong_FromUnicode
141  #define PyInt_FromLong               PyLong_FromLong
142  #define PyInt_FromSize_t             PyLong_FromSize_t
143  #define PyInt_FromSsize_t            PyLong_FromSsize_t
144  #define PyInt_AsLong                 PyLong_AsLong
145  #define PyInt_AS_LONG                PyLong_AS_LONG
146  #define PyInt_AsSsize_t              PyLong_AsSsize_t
147  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
148  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
149  #define PyNumber_Int                 PyNumber_Long
150#endif
151#if PY_MAJOR_VERSION >= 3
152  #define PyBoolObject                 PyLongObject
153#endif
154#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
155  #ifndef PyUnicode_InternFromString
156    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
157  #endif
158#endif
159#if PY_VERSION_HEX < 0x030200A4
160  typedef long Py_hash_t;
161  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
162  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
163#else
164  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
165  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
166#endif
167#if PY_MAJOR_VERSION >= 3
168  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
169#else
170  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
171#endif
172#ifndef CYTHON_INLINE
173  #if defined(__GNUC__)
174    #define CYTHON_INLINE __inline__
175  #elif defined(_MSC_VER)
176    #define CYTHON_INLINE __inline
177  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
178    #define CYTHON_INLINE inline
179  #else
180    #define CYTHON_INLINE
181  #endif
182#endif
183#ifndef CYTHON_RESTRICT
184  #if defined(__GNUC__)
185    #define CYTHON_RESTRICT __restrict__
186  #elif defined(_MSC_VER) && _MSC_VER >= 1400
187    #define CYTHON_RESTRICT __restrict
188  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
189    #define CYTHON_RESTRICT restrict
190  #else
191    #define CYTHON_RESTRICT
192  #endif
193#endif
194#ifdef NAN
195#define __PYX_NAN() ((float) NAN)
196#else
197static CYTHON_INLINE float __PYX_NAN() {
198  /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
199   a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
200   a quiet NaN. */
201  float value;
202  memset(&value, 0xFF, sizeof(value));
203  return value;
204}
205#endif
206#ifdef __cplusplus
207template<typename T>
208void __Pyx_call_destructor(T* x) {
209    x->~T();
210}
211#endif
212
213
214#if PY_MAJOR_VERSION >= 3
215  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
216  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
217#else
218  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
219  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
220#endif
221
222#ifndef __PYX_EXTERN_C
223  #ifdef __cplusplus
224    #define __PYX_EXTERN_C extern "C"
225  #else
226    #define __PYX_EXTERN_C extern
227  #endif
228#endif
229
230#if defined(WIN32) || defined(MS_WINDOWS)
231#define _USE_MATH_DEFINES
232#endif
233#include <math.h>
234#define __PYX_HAVE__zmq__backend__cython__context
235#define __PYX_HAVE_API__zmq__backend__cython__context
236#include "string.h"
237#include "stdlib.h"
238#include "zmq_compat.h"
239#include "zmq.h"
240#include "zmq_utils.h"
241#include "getpid_compat.h"
242#include "errno.h"
243#include "stdio.h"
244#include "pythread.h"
245#ifdef _OPENMP
246#include <omp.h>
247#endif /* _OPENMP */
248
249#ifdef PYREX_WITHOUT_ASSERTIONS
250#define CYTHON_WITHOUT_ASSERTIONS
251#endif
252
253#ifndef CYTHON_UNUSED
254# if defined(__GNUC__)
255#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
256#     define CYTHON_UNUSED __attribute__ ((__unused__))
257#   else
258#     define CYTHON_UNUSED
259#   endif
260# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
261#   define CYTHON_UNUSED __attribute__ ((__unused__))
262# else
263#   define CYTHON_UNUSED
264# endif
265#endif
266typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
267                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
268
269#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
270#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
271#define __PYX_DEFAULT_STRING_ENCODING ""
272#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
273#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
274#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (    \
275    (sizeof(type) < sizeof(Py_ssize_t))  ||             \
276    (sizeof(type) > sizeof(Py_ssize_t) &&               \
277          likely(v < (type)PY_SSIZE_T_MAX ||            \
278                 v == (type)PY_SSIZE_T_MAX)  &&         \
279          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||       \
280                                v == (type)PY_SSIZE_T_MIN)))  ||  \
281    (sizeof(type) == sizeof(Py_ssize_t) &&              \
282          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||        \
283                               v == (type)PY_SSIZE_T_MAX)))  )
284static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
285static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
286#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
287#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
288#define __Pyx_PyBytes_FromString        PyBytes_FromString
289#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
290static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
291#if PY_MAJOR_VERSION < 3
292    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
293    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
294#else
295    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
296    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
297#endif
298#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
299#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
300#define __Pyx_PyObject_FromUString(s)  __Pyx_PyObject_FromString((const char*)s)
301#define __Pyx_PyBytes_FromUString(s)   __Pyx_PyBytes_FromString((const char*)s)
302#define __Pyx_PyByteArray_FromUString(s)   __Pyx_PyByteArray_FromString((const char*)s)
303#define __Pyx_PyStr_FromUString(s)     __Pyx_PyStr_FromString((const char*)s)
304#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((const char*)s)
305#if PY_MAJOR_VERSION < 3
306static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
307{
308    const Py_UNICODE *u_end = u;
309    while (*u_end++) ;
310    return (size_t)(u_end - u - 1);
311}
312#else
313#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
314#endif
315#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
316#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
317#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
318#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
319#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
320static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
321static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
322static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
323static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
324#if CYTHON_COMPILING_IN_CPYTHON
325#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
326#else
327#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
328#endif
329#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
330#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
331static int __Pyx_sys_getdefaultencoding_not_ascii;
332static int __Pyx_init_sys_getdefaultencoding_params(void) {
333    PyObject* sys;
334    PyObject* default_encoding = NULL;
335    PyObject* ascii_chars_u = NULL;
336    PyObject* ascii_chars_b = NULL;
337    const char* default_encoding_c;
338    sys = PyImport_ImportModule("sys");
339    if (!sys) goto bad;
340    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
341    Py_DECREF(sys);
342    if (!default_encoding) goto bad;
343    default_encoding_c = PyBytes_AsString(default_encoding);
344    if (!default_encoding_c) goto bad;
345    if (strcmp(default_encoding_c, "ascii") == 0) {
346        __Pyx_sys_getdefaultencoding_not_ascii = 0;
347    } else {
348        char ascii_chars[128];
349        int c;
350        for (c = 0; c < 128; c++) {
351            ascii_chars[c] = c;
352        }
353        __Pyx_sys_getdefaultencoding_not_ascii = 1;
354        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
355        if (!ascii_chars_u) goto bad;
356        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
357        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
358            PyErr_Format(
359                PyExc_ValueError,
360                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
361                default_encoding_c);
362            goto bad;
363        }
364        Py_DECREF(ascii_chars_u);
365        Py_DECREF(ascii_chars_b);
366    }
367    Py_DECREF(default_encoding);
368    return 0;
369bad:
370    Py_XDECREF(default_encoding);
371    Py_XDECREF(ascii_chars_u);
372    Py_XDECREF(ascii_chars_b);
373    return -1;
374}
375#endif
376#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
377#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
378#else
379#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
380#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
381static char* __PYX_DEFAULT_STRING_ENCODING;
382static int __Pyx_init_sys_getdefaultencoding_params(void) {
383    PyObject* sys;
384    PyObject* default_encoding = NULL;
385    char* default_encoding_c;
386    sys = PyImport_ImportModule("sys");
387    if (!sys) goto bad;
388    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
389    Py_DECREF(sys);
390    if (!default_encoding) goto bad;
391    default_encoding_c = PyBytes_AsString(default_encoding);
392    if (!default_encoding_c) goto bad;
393    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
394    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
395    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
396    Py_DECREF(default_encoding);
397    return 0;
398bad:
399    Py_XDECREF(default_encoding);
400    return -1;
401}
402#endif
403#endif
404
405
406/* Test for GCC > 2.95 */
407#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
408  #define likely(x)   __builtin_expect(!!(x), 1)
409  #define unlikely(x) __builtin_expect(!!(x), 0)
410#else /* !__GNUC__ or GCC < 2.95 */
411  #define likely(x)   (x)
412  #define unlikely(x) (x)
413#endif /* __GNUC__ */
414
415static PyObject *__pyx_m;
416static PyObject *__pyx_d;
417static PyObject *__pyx_b;
418static PyObject *__pyx_empty_tuple;
419static PyObject *__pyx_empty_bytes;
420static int __pyx_lineno;
421static int __pyx_clineno = 0;
422static const char * __pyx_cfilenm= __FILE__;
423static const char *__pyx_filename;
424
425
426static const char *__pyx_f[] = {
427  "zmq/backend/cython/context.pyx",
428  "zmq/backend/cython/context.pxd",
429  "zmq/backend/cython/checkrc.pxd",
430  "type.pxd",
431  "bool.pxd",
432  "complex.pxd",
433};
434
435/*--- Type declarations ---*/
436struct __pyx_obj_3zmq_7backend_6cython_7context_Context;
437
438/* "zmq/backend/cython/context.pxd":26
439 * #-----------------------------------------------------------------------------
440 *
441 * cdef class Context:             # <<<<<<<<<<<<<<
442 *
443 *     cdef object __weakref__     # enable weakref
444 */
445struct __pyx_obj_3zmq_7backend_6cython_7context_Context {
446  PyObject_HEAD
447  struct __pyx_vtabstruct_3zmq_7backend_6cython_7context_Context *__pyx_vtab;
448  PyObject *__weakref__;
449  void *handle;
450  int _shadow;
451  void **_sockets;
452  size_t _n_sockets;
453  size_t _max_sockets;
454  int _pid;
455  int closed;
456};
457
458
459
460/* "zmq/backend/cython/context.pyx":20
461 * _instance = None
462 *
463 * cdef class Context:             # <<<<<<<<<<<<<<
464 *     """Context(io_threads=1)
465 *
466 */
467
468struct __pyx_vtabstruct_3zmq_7backend_6cython_7context_Context {
469  int (*_term)(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *);
470  void (*_add_socket)(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *, void *);
471  void (*_remove_socket)(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *, void *);
472};
473static struct __pyx_vtabstruct_3zmq_7backend_6cython_7context_Context *__pyx_vtabptr_3zmq_7backend_6cython_7context_Context;
474static CYTHON_INLINE int __pyx_f_3zmq_7backend_6cython_7context_7Context__term(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *);
475static CYTHON_INLINE void __pyx_f_3zmq_7backend_6cython_7context_7Context__add_socket(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *, void *);
476static CYTHON_INLINE void __pyx_f_3zmq_7backend_6cython_7context_7Context__remove_socket(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *, void *);
477#ifndef CYTHON_REFNANNY
478  #define CYTHON_REFNANNY 0
479#endif
480#if CYTHON_REFNANNY
481  typedef struct {
482    void (*INCREF)(void*, PyObject*, int);
483    void (*DECREF)(void*, PyObject*, int);
484    void (*GOTREF)(void*, PyObject*, int);
485    void (*GIVEREF)(void*, PyObject*, int);
486    void* (*SetupContext)(const char*, int, const char*);
487    void (*FinishContext)(void**);
488  } __Pyx_RefNannyAPIStruct;
489  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
490  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
491  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
492#ifdef WITH_THREAD
493  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
494          if (acquire_gil) { \
495              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
496              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
497              PyGILState_Release(__pyx_gilstate_save); \
498          } else { \
499              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
500          }
501#else
502  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
503          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
504#endif
505  #define __Pyx_RefNannyFinishContext() \
506          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
507  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
508  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
509  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
510  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
511  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
512  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
513  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
514  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
515#else
516  #define __Pyx_RefNannyDeclarations
517  #define __Pyx_RefNannySetupContext(name, acquire_gil)
518  #define __Pyx_RefNannyFinishContext()
519  #define __Pyx_INCREF(r) Py_INCREF(r)
520  #define __Pyx_DECREF(r) Py_DECREF(r)
521  #define __Pyx_GOTREF(r)
522  #define __Pyx_GIVEREF(r)
523  #define __Pyx_XINCREF(r) Py_XINCREF(r)
524  #define __Pyx_XDECREF(r) Py_XDECREF(r)
525  #define __Pyx_XGOTREF(r)
526  #define __Pyx_XGIVEREF(r)
527#endif
528#define __Pyx_XDECREF_SET(r, v) do {                            \
529        PyObject *tmp = (PyObject *) r;                         \
530        r = v; __Pyx_XDECREF(tmp);                              \
531    } while (0)
532#define __Pyx_DECREF_SET(r, v) do {                             \
533        PyObject *tmp = (PyObject *) r;                         \
534        r = v; __Pyx_DECREF(tmp);                               \
535    } while (0)
536#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
537#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
538
539#if CYTHON_COMPILING_IN_CPYTHON
540static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
541    PyTypeObject* tp = Py_TYPE(obj);
542    if (likely(tp->tp_getattro))
543        return tp->tp_getattro(obj, attr_name);
544#if PY_MAJOR_VERSION < 3
545    if (likely(tp->tp_getattr))
546        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
547#endif
548    return PyObject_GetAttr(obj, attr_name);
549}
550#else
551#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
552#endif
553
554static PyObject *__Pyx_GetBuiltinName(PyObject *name);
555
556static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
557
558static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
559    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
560    const char* function_name);
561
562static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
563    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
564
565static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
566
567#if CYTHON_COMPILING_IN_CPYTHON
568static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
569#else
570#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
571#endif
572
573#if CYTHON_COMPILING_IN_CPYTHON
574static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
575#endif
576
577static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
578
579#if CYTHON_COMPILING_IN_CPYTHON
580static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
581#else
582#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
583#endif
584
585static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb);
586static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb);
587
588static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
589
590static void __Pyx_WriteUnraisable(const char *name, int clineno,
591                                  int lineno, const char *filename,
592                                  int full_traceback);
593
594static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
595
596static int __Pyx_SetVtable(PyObject *dict, void *vtable);
597
598static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name);
599
600typedef struct {
601    int code_line;
602    PyCodeObject* code_object;
603} __Pyx_CodeObjectCacheEntry;
604struct __Pyx_CodeObjectCache {
605    int count;
606    int max_count;
607    __Pyx_CodeObjectCacheEntry* entries;
608};
609static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
610static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
611static PyCodeObject *__pyx_find_code_object(int code_line);
612static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
613
614static void __Pyx_AddTraceback(const char *funcname, int c_line,
615                               int py_line, const char *filename);
616
617static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
618
619static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
620
621static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);
622
623#ifndef __PYX_FORCE_INIT_THREADS
624  #define __PYX_FORCE_INIT_THREADS 0
625#endif
626
627static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
628
629static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
630
631static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
632
633static int __Pyx_check_binary_version(void);
634
635#if !defined(__Pyx_PyIdentifier_FromString)
636#if PY_MAJOR_VERSION < 3
637  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
638#else
639  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
640#endif
641#endif
642
643static PyObject *__Pyx_ImportModule(const char *name);
644
645static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
646
647static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
648
649static CYTHON_INLINE void __pyx_f_3zmq_7backend_6cython_7context_7Context__add_socket(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, void *__pyx_v_handle); /* proto*/
650static CYTHON_INLINE void __pyx_f_3zmq_7backend_6cython_7context_7Context__remove_socket(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, void *__pyx_v_handle); /* proto*/
651static CYTHON_INLINE int __pyx_f_3zmq_7backend_6cython_7context_7Context__term(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self); /* proto*/
652
653/* Module declarations from 'libc.string' */
654
655/* Module declarations from 'libc.stdlib' */
656
657/* Module declarations from 'zmq.backend.cython.libzmq' */
658
659/* Module declarations from 'libc.errno' */
660
661/* Module declarations from 'cpython.version' */
662
663/* Module declarations from 'cpython.ref' */
664
665/* Module declarations from 'cpython.exc' */
666
667/* Module declarations from 'cpython.module' */
668
669/* Module declarations from 'cpython.mem' */
670
671/* Module declarations from 'cpython.tuple' */
672
673/* Module declarations from 'cpython.list' */
674
675/* Module declarations from 'libc.stdio' */
676
677/* Module declarations from 'cpython.object' */
678
679/* Module declarations from 'cpython.sequence' */
680
681/* Module declarations from 'cpython.mapping' */
682
683/* Module declarations from 'cpython.iterator' */
684
685/* Module declarations from '__builtin__' */
686
687/* Module declarations from 'cpython.type' */
688static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
689
690/* Module declarations from 'cpython.number' */
691
692/* Module declarations from 'cpython.int' */
693
694/* Module declarations from '__builtin__' */
695
696/* Module declarations from 'cpython.bool' */
697static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
698
699/* Module declarations from 'cpython.long' */
700
701/* Module declarations from 'cpython.float' */
702
703/* Module declarations from '__builtin__' */
704
705/* Module declarations from 'cpython.complex' */
706static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
707
708/* Module declarations from 'cpython.string' */
709
710/* Module declarations from 'cpython.unicode' */
711
712/* Module declarations from 'cpython.dict' */
713
714/* Module declarations from 'cpython.instance' */
715
716/* Module declarations from 'cpython.function' */
717
718/* Module declarations from 'cpython.method' */
719
720/* Module declarations from 'cpython.weakref' */
721
722/* Module declarations from 'cpython.getargs' */
723
724/* Module declarations from 'cpython.pythread' */
725
726/* Module declarations from 'cpython.pystate' */
727
728/* Module declarations from 'cpython.cobject' */
729
730/* Module declarations from 'cpython.oldbuffer' */
731
732/* Module declarations from 'cpython.set' */
733
734/* Module declarations from 'cpython.buffer' */
735
736/* Module declarations from 'cpython.bytes' */
737
738/* Module declarations from 'cpython.pycapsule' */
739
740/* Module declarations from 'cpython' */
741
742/* Module declarations from 'zmq.backend.cython.checkrc' */
743static CYTHON_INLINE int __pyx_f_3zmq_7backend_6cython_7checkrc__check_rc(int); /*proto*/
744
745/* Module declarations from 'zmq.backend.cython.context' */
746static PyTypeObject *__pyx_ptype_3zmq_7backend_6cython_7context_Context = 0;
747#define __Pyx_MODULE_NAME "zmq.backend.cython.context"
748int __pyx_module_is_main_zmq__backend__cython__context = 0;
749
750/* Implementation of 'zmq.backend.cython.context' */
751static PyObject *__pyx_builtin_property;
752static PyObject *__pyx_builtin_MemoryError;
753static PyObject *__pyx_builtin_range;
754static PyObject *__pyx_builtin_RuntimeError;
755static PyObject *__pyx_builtin_TypeError;
756static int __pyx_pf_3zmq_7backend_6cython_7context_7Context___init__(CYTHON_UNUSED struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_io_threads, CYTHON_UNUSED PyObject *__pyx_v_shadow); /* proto */
757static int __pyx_pf_3zmq_7backend_6cython_7context_7Context_2__cinit__(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, int __pyx_v_io_threads, size_t __pyx_v_shadow, CYTHON_UNUSED PyObject *__pyx_v_kwargs); /* proto */
758static void __pyx_pf_3zmq_7backend_6cython_7context_7Context_4__dealloc__(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self); /* proto */
759static PyObject *__pyx_pf_3zmq_7backend_6cython_7context_7Context_6underlying(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self); /* proto */
760static PyObject *__pyx_pf_3zmq_7backend_6cython_7context_7Context_8term(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self); /* proto */
761static PyObject *__pyx_pf_3zmq_7backend_6cython_7context_7Context_10set(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, int __pyx_v_option, PyObject *__pyx_v_optval); /* proto */
762static PyObject *__pyx_pf_3zmq_7backend_6cython_7context_7Context_12get(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, int __pyx_v_option); /* proto */
763static PyObject *__pyx_pf_3zmq_7backend_6cython_7context_7Context_14destroy(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, PyObject *__pyx_v_linger); /* proto */
764static PyObject *__pyx_pf_3zmq_7backend_6cython_7context_7Context_6closed___get__(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self); /* proto */
765static int __pyx_pf_3zmq_7backend_6cython_7context_7Context_6closed_2__set__(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
766static PyObject *__pyx_tp_new_3zmq_7backend_6cython_7context_Context(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
767static char __pyx_k_all[] = "__all__";
768static char __pyx_k_main[] = "__main__";
769static char __pyx_k_term[] = "term";
770static char __pyx_k_test[] = "__test__";
771static char __pyx_k_Again[] = "Again";
772static char __pyx_k_range[] = "range";
773static char __pyx_k_handle[] = "_handle";
774static char __pyx_k_import[] = "__import__";
775static char __pyx_k_linger[] = "linger";
776static char __pyx_k_option[] = "option";
777static char __pyx_k_optval[] = "optval";
778static char __pyx_k_shadow[] = "shadow";
779static char __pyx_k_Context[] = "Context";
780static char __pyx_k_ZMQError[] = "ZMQError";
781static char __pyx_k_instance[] = "_instance";
782static char __pyx_k_property[] = "property";
783static char __pyx_k_TypeError[] = "TypeError";
784static char __pyx_k_zmq_error[] = "zmq.error";
785static char __pyx_k_io_threads[] = "io_threads";
786static char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
787static char __pyx_k_underlying[] = "underlying";
788static char __pyx_k_MemoryError[] = "MemoryError";
789static char __pyx_k_RuntimeError[] = "RuntimeError";
790static char __pyx_k_0MQ_Context_class[] = "0MQ Context class.";
791static char __pyx_k_ContextTerminated[] = "ContextTerminated";
792static char __pyx_k_expected_int_got_r[] = "expected int, got: %r";
793static char __pyx_k_Context_has_been_destroyed[] = "Context has been destroyed";
794static char __pyx_k_Could_not_allocate__sockets_arra[] = "Could not allocate _sockets array";
795static char __pyx_k_Could_not_reallocate__sockets_ar[] = "Could not reallocate _sockets array";
796static PyObject *__pyx_n_s_Again;
797static PyObject *__pyx_n_s_Context;
798static PyObject *__pyx_n_s_ContextTerminated;
799static PyObject *__pyx_kp_s_Context_has_been_destroyed;
800static PyObject *__pyx_kp_s_Could_not_allocate__sockets_arra;
801static PyObject *__pyx_kp_s_Could_not_reallocate__sockets_ar;
802static PyObject *__pyx_n_s_MemoryError;
803static PyObject *__pyx_n_s_RuntimeError;
804static PyObject *__pyx_n_s_TypeError;
805static PyObject *__pyx_n_s_ZMQError;
806static PyObject *__pyx_n_s_all;
807static PyObject *__pyx_kp_s_expected_int_got_r;
808static PyObject *__pyx_n_s_handle;
809static PyObject *__pyx_n_s_import;
810static PyObject *__pyx_n_s_instance;
811static PyObject *__pyx_n_s_io_threads;
812static PyObject *__pyx_n_s_linger;
813static PyObject *__pyx_n_s_main;
814static PyObject *__pyx_n_s_option;
815static PyObject *__pyx_n_s_optval;
816static PyObject *__pyx_n_s_property;
817static PyObject *__pyx_n_s_pyx_vtable;
818static PyObject *__pyx_n_s_range;
819static PyObject *__pyx_n_s_shadow;
820static PyObject *__pyx_n_s_term;
821static PyObject *__pyx_n_s_test;
822static PyObject *__pyx_n_s_underlying;
823static PyObject *__pyx_n_s_zmq_error;
824static PyObject *__pyx_int_0;
825static PyObject *__pyx_int_1;
826static PyObject *__pyx_tuple_;
827static PyObject *__pyx_tuple__2;
828static PyObject *__pyx_tuple__3;
829static PyObject *__pyx_tuple__4;
830
831/* "zmq/backend/cython/context.pyx":32
832 *
833 *     # no-op for the signature
834 *     def __init__(self, io_threads=1, shadow=0):             # <<<<<<<<<<<<<<
835 *         pass
836 *
837 */
838
839/* Python wrapper */
840static int __pyx_pw_3zmq_7backend_6cython_7context_7Context_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
841static int __pyx_pw_3zmq_7backend_6cython_7context_7Context_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
842  CYTHON_UNUSED PyObject *__pyx_v_io_threads = 0;
843  CYTHON_UNUSED PyObject *__pyx_v_shadow = 0;
844  int __pyx_lineno = 0;
845  const char *__pyx_filename = NULL;
846  int __pyx_clineno = 0;
847  int __pyx_r;
848  __Pyx_RefNannyDeclarations
849  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
850  {
851    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_io_threads,&__pyx_n_s_shadow,0};
852    PyObject* values[2] = {0,0};
853    values[0] = ((PyObject *)__pyx_int_1);
854    values[1] = ((PyObject *)__pyx_int_0);
855    if (unlikely(__pyx_kwds)) {
856      Py_ssize_t kw_args;
857      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
858      switch (pos_args) {
859        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
860        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
861        case  0: break;
862        default: goto __pyx_L5_argtuple_error;
863      }
864      kw_args = PyDict_Size(__pyx_kwds);
865      switch (pos_args) {
866        case  0:
867        if (kw_args > 0) {
868          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_io_threads);
869          if (value) { values[0] = value; kw_args--; }
870        }
871        case  1:
872        if (kw_args > 0) {
873          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shadow);
874          if (value) { values[1] = value; kw_args--; }
875        }
876      }
877      if (unlikely(kw_args > 0)) {
878        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
879      }
880    } else {
881      switch (PyTuple_GET_SIZE(__pyx_args)) {
882        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
883        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
884        case  0: break;
885        default: goto __pyx_L5_argtuple_error;
886      }
887    }
888    __pyx_v_io_threads = values[0];
889    __pyx_v_shadow = values[1];
890  }
891  goto __pyx_L4_argument_unpacking_done;
892  __pyx_L5_argtuple_error:;
893  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
894  __pyx_L3_error:;
895  __Pyx_AddTraceback("zmq.backend.cython.context.Context.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
896  __Pyx_RefNannyFinishContext();
897  return -1;
898  __pyx_L4_argument_unpacking_done:;
899  __pyx_r = __pyx_pf_3zmq_7backend_6cython_7context_7Context___init__(((struct __pyx_obj_3zmq_7backend_6cython_7context_Context *)__pyx_v_self), __pyx_v_io_threads, __pyx_v_shadow);
900
901  /* function exit code */
902  __Pyx_RefNannyFinishContext();
903  return __pyx_r;
904}
905
906static int __pyx_pf_3zmq_7backend_6cython_7context_7Context___init__(CYTHON_UNUSED struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_io_threads, CYTHON_UNUSED PyObject *__pyx_v_shadow) {
907  int __pyx_r;
908  __Pyx_RefNannyDeclarations
909  __Pyx_RefNannySetupContext("__init__", 0);
910
911  /* function exit code */
912  __pyx_r = 0;
913  __Pyx_RefNannyFinishContext();
914  return __pyx_r;
915}
916
917/* "zmq/backend/cython/context.pyx":35
918 *         pass
919 *
920 *     def __cinit__(self, int io_threads=1, size_t shadow=0, **kwargs):             # <<<<<<<<<<<<<<
921 *         self.handle = NULL
922 *         self._sockets = NULL
923 */
924
925/* Python wrapper */
926static int __pyx_pw_3zmq_7backend_6cython_7context_7Context_3__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
927static int __pyx_pw_3zmq_7backend_6cython_7context_7Context_3__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
928  int __pyx_v_io_threads;
929  size_t __pyx_v_shadow;
930  CYTHON_UNUSED PyObject *__pyx_v_kwargs = 0;
931  int __pyx_lineno = 0;
932  const char *__pyx_filename = NULL;
933  int __pyx_clineno = 0;
934  int __pyx_r;
935  __Pyx_RefNannyDeclarations
936  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
937  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
938  __Pyx_GOTREF(__pyx_v_kwargs);
939  {
940    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_io_threads,&__pyx_n_s_shadow,0};
941    PyObject* values[2] = {0,0};
942    if (unlikely(__pyx_kwds)) {
943      Py_ssize_t kw_args;
944      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
945      switch (pos_args) {
946        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
947        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
948        case  0: break;
949        default: goto __pyx_L5_argtuple_error;
950      }
951      kw_args = PyDict_Size(__pyx_kwds);
952      switch (pos_args) {
953        case  0:
954        if (kw_args > 0) {
955          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_io_threads);
956          if (value) { values[0] = value; kw_args--; }
957        }
958        case  1:
959        if (kw_args > 0) {
960          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_shadow);
961          if (value) { values[1] = value; kw_args--; }
962        }
963      }
964      if (unlikely(kw_args > 0)) {
965        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
966      }
967    } else {
968      switch (PyTuple_GET_SIZE(__pyx_args)) {
969        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
970        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
971        case  0: break;
972        default: goto __pyx_L5_argtuple_error;
973      }
974    }
975    if (values[0]) {
976      __pyx_v_io_threads = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_io_threads == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
977    } else {
978      __pyx_v_io_threads = ((int)1);
979    }
980    if (values[1]) {
981      __pyx_v_shadow = __Pyx_PyInt_As_size_t(values[1]); if (unlikely((__pyx_v_shadow == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
982    } else {
983      __pyx_v_shadow = ((size_t)0);
984    }
985  }
986  goto __pyx_L4_argument_unpacking_done;
987  __pyx_L5_argtuple_error:;
988  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
989  __pyx_L3_error:;
990  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
991  __Pyx_AddTraceback("zmq.backend.cython.context.Context.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
992  __Pyx_RefNannyFinishContext();
993  return -1;
994  __pyx_L4_argument_unpacking_done:;
995  __pyx_r = __pyx_pf_3zmq_7backend_6cython_7context_7Context_2__cinit__(((struct __pyx_obj_3zmq_7backend_6cython_7context_Context *)__pyx_v_self), __pyx_v_io_threads, __pyx_v_shadow, __pyx_v_kwargs);
996
997  /* function exit code */
998  __Pyx_XDECREF(__pyx_v_kwargs);
999  __Pyx_RefNannyFinishContext();
1000  return __pyx_r;
1001}
1002
1003static int __pyx_pf_3zmq_7backend_6cython_7context_7Context_2__cinit__(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, int __pyx_v_io_threads, size_t __pyx_v_shadow, CYTHON_UNUSED PyObject *__pyx_v_kwargs) {
1004  int __pyx_v_rc;
1005  int __pyx_r;
1006  __Pyx_RefNannyDeclarations
1007  int __pyx_t_1;
1008  PyObject *__pyx_t_2 = NULL;
1009  PyObject *__pyx_t_3 = NULL;
1010  PyObject *__pyx_t_4 = NULL;
1011  int __pyx_t_5;
1012  int __pyx_t_6;
1013  int __pyx_lineno = 0;
1014  const char *__pyx_filename = NULL;
1015  int __pyx_clineno = 0;
1016  __Pyx_RefNannySetupContext("__cinit__", 0);
1017
1018  /* "zmq/backend/cython/context.pyx":36
1019 *
1020 *     def __cinit__(self, int io_threads=1, size_t shadow=0, **kwargs):
1021 *         self.handle = NULL             # <<<<<<<<<<<<<<
1022 *         self._sockets = NULL
1023 *         if shadow:
1024 */
1025  __pyx_v_self->handle = NULL;
1026
1027  /* "zmq/backend/cython/context.pyx":37
1028 *     def __cinit__(self, int io_threads=1, size_t shadow=0, **kwargs):
1029 *         self.handle = NULL
1030 *         self._sockets = NULL             # <<<<<<<<<<<<<<
1031 *         if shadow:
1032 *             self.handle = <void *>shadow
1033 */
1034  __pyx_v_self->_sockets = NULL;
1035
1036  /* "zmq/backend/cython/context.pyx":38
1037 *         self.handle = NULL
1038 *         self._sockets = NULL
1039 *         if shadow:             # <<<<<<<<<<<<<<
1040 *             self.handle = <void *>shadow
1041 *             self._shadow = True
1042 */
1043  __pyx_t_1 = (__pyx_v_shadow != 0);
1044  if (__pyx_t_1) {
1045
1046    /* "zmq/backend/cython/context.pyx":39
1047 *         self._sockets = NULL
1048 *         if shadow:
1049 *             self.handle = <void *>shadow             # <<<<<<<<<<<<<<
1050 *             self._shadow = True
1051 *         else:
1052 */
1053    __pyx_v_self->handle = ((void *)__pyx_v_shadow);
1054
1055    /* "zmq/backend/cython/context.pyx":40
1056 *         if shadow:
1057 *             self.handle = <void *>shadow
1058 *             self._shadow = True             # <<<<<<<<<<<<<<
1059 *         else:
1060 *             self._shadow = False
1061 */
1062    __pyx_v_self->_shadow = 1;
1063    goto __pyx_L3;
1064  }
1065  /*else*/ {
1066
1067    /* "zmq/backend/cython/context.pyx":42
1068 *             self._shadow = True
1069 *         else:
1070 *             self._shadow = False             # <<<<<<<<<<<<<<
1071 *             if ZMQ_VERSION_MAJOR >= 3:
1072 *                 self.handle = zmq_ctx_new()
1073 */
1074    __pyx_v_self->_shadow = 0;
1075
1076    /* "zmq/backend/cython/context.pyx":43
1077 *         else:
1078 *             self._shadow = False
1079 *             if ZMQ_VERSION_MAJOR >= 3:             # <<<<<<<<<<<<<<
1080 *                 self.handle = zmq_ctx_new()
1081 *             else:
1082 */
1083    __pyx_t_1 = ((ZMQ_VERSION_MAJOR >= 3) != 0);
1084    if (__pyx_t_1) {
1085
1086      /* "zmq/backend/cython/context.pyx":44
1087 *             self._shadow = False
1088 *             if ZMQ_VERSION_MAJOR >= 3:
1089 *                 self.handle = zmq_ctx_new()             # <<<<<<<<<<<<<<
1090 *             else:
1091 *                 self.handle = zmq_init(io_threads)
1092 */
1093      __pyx_v_self->handle = zmq_ctx_new();
1094      goto __pyx_L4;
1095    }
1096    /*else*/ {
1097
1098      /* "zmq/backend/cython/context.pyx":46
1099 *                 self.handle = zmq_ctx_new()
1100 *             else:
1101 *                 self.handle = zmq_init(io_threads)             # <<<<<<<<<<<<<<
1102 *
1103 *         if self.handle == NULL:
1104 */
1105      __pyx_v_self->handle = zmq_init(__pyx_v_io_threads);
1106    }
1107    __pyx_L4:;
1108  }
1109  __pyx_L3:;
1110
1111  /* "zmq/backend/cython/context.pyx":48
1112 *                 self.handle = zmq_init(io_threads)
1113 *
1114 *         if self.handle == NULL:             # <<<<<<<<<<<<<<
1115 *             raise ZMQError()
1116 *
1117 */
1118  __pyx_t_1 = ((__pyx_v_self->handle == NULL) != 0);
1119  if (__pyx_t_1) {
1120
1121    /* "zmq/backend/cython/context.pyx":49
1122 *
1123 *         if self.handle == NULL:
1124 *             raise ZMQError()             # <<<<<<<<<<<<<<
1125 *
1126 *         cdef int rc = 0
1127 */
1128    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ZMQError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1129    __Pyx_GOTREF(__pyx_t_3);
1130    __pyx_t_4 = NULL;
1131    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) {
1132      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
1133      if (likely(__pyx_t_4)) {
1134        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1135        __Pyx_INCREF(__pyx_t_4);
1136        __Pyx_INCREF(function);
1137        __Pyx_DECREF_SET(__pyx_t_3, function);
1138      }
1139    }
1140    if (__pyx_t_4) {
1141      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1142      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1143    } else {
1144      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1145    }
1146    __Pyx_GOTREF(__pyx_t_2);
1147    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1148    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
1149    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1150    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1151  }
1152
1153  /* "zmq/backend/cython/context.pyx":51
1154 *             raise ZMQError()
1155 *
1156 *         cdef int rc = 0             # <<<<<<<<<<<<<<
1157 *         if ZMQ_VERSION_MAJOR >= 3 and not self._shadow:
1158 *             rc = zmq_ctx_set(self.handle, ZMQ_IO_THREADS, io_threads)
1159 */
1160  __pyx_v_rc = 0;
1161
1162  /* "zmq/backend/cython/context.pyx":52
1163 *
1164 *         cdef int rc = 0
1165 *         if ZMQ_VERSION_MAJOR >= 3 and not self._shadow:             # <<<<<<<<<<<<<<
1166 *             rc = zmq_ctx_set(self.handle, ZMQ_IO_THREADS, io_threads)
1167 *             _check_rc(rc)
1168 */
1169  __pyx_t_5 = ((ZMQ_VERSION_MAJOR >= 3) != 0);
1170  if (__pyx_t_5) {
1171  } else {
1172    __pyx_t_1 = __pyx_t_5;
1173    goto __pyx_L7_bool_binop_done;
1174  }
1175  __pyx_t_5 = ((!(__pyx_v_self->_shadow != 0)) != 0);
1176  __pyx_t_1 = __pyx_t_5;
1177  __pyx_L7_bool_binop_done:;
1178  if (__pyx_t_1) {
1179
1180    /* "zmq/backend/cython/context.pyx":53
1181 *         cdef int rc = 0
1182 *         if ZMQ_VERSION_MAJOR >= 3 and not self._shadow:
1183 *             rc = zmq_ctx_set(self.handle, ZMQ_IO_THREADS, io_threads)             # <<<<<<<<<<<<<<
1184 *             _check_rc(rc)
1185 *
1186 */
1187    __pyx_v_rc = zmq_ctx_set(__pyx_v_self->handle, ZMQ_IO_THREADS, __pyx_v_io_threads);
1188
1189    /* "zmq/backend/cython/context.pyx":54
1190 *         if ZMQ_VERSION_MAJOR >= 3 and not self._shadow:
1191 *             rc = zmq_ctx_set(self.handle, ZMQ_IO_THREADS, io_threads)
1192 *             _check_rc(rc)             # <<<<<<<<<<<<<<
1193 *
1194 *         self.closed = False
1195 */
1196    __pyx_t_6 = __pyx_f_3zmq_7backend_6cython_7checkrc__check_rc(__pyx_v_rc); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1197    goto __pyx_L6;
1198  }
1199  __pyx_L6:;
1200
1201  /* "zmq/backend/cython/context.pyx":56
1202 *             _check_rc(rc)
1203 *
1204 *         self.closed = False             # <<<<<<<<<<<<<<
1205 *         self._n_sockets = 0
1206 *         self._max_sockets = 32
1207 */
1208  __pyx_v_self->closed = 0;
1209
1210  /* "zmq/backend/cython/context.pyx":57
1211 *
1212 *         self.closed = False
1213 *         self._n_sockets = 0             # <<<<<<<<<<<<<<
1214 *         self._max_sockets = 32
1215 *
1216 */
1217  __pyx_v_self->_n_sockets = 0;
1218
1219  /* "zmq/backend/cython/context.pyx":58
1220 *         self.closed = False
1221 *         self._n_sockets = 0
1222 *         self._max_sockets = 32             # <<<<<<<<<<<<<<
1223 *
1224 *         self._sockets = <void **>malloc(self._max_sockets*sizeof(void *))
1225 */
1226  __pyx_v_self->_max_sockets = 32;
1227
1228  /* "zmq/backend/cython/context.pyx":60
1229 *         self._max_sockets = 32
1230 *
1231 *         self._sockets = <void **>malloc(self._max_sockets*sizeof(void *))             # <<<<<<<<<<<<<<
1232 *         if self._sockets == NULL:
1233 *             raise MemoryError("Could not allocate _sockets array")
1234 */
1235  __pyx_v_self->_sockets = ((void **)malloc((__pyx_v_self->_max_sockets * (sizeof(void *)))));
1236
1237  /* "zmq/backend/cython/context.pyx":61
1238 *
1239 *         self._sockets = <void **>malloc(self._max_sockets*sizeof(void *))
1240 *         if self._sockets == NULL:             # <<<<<<<<<<<<<<
1241 *             raise MemoryError("Could not allocate _sockets array")
1242 *
1243 */
1244  __pyx_t_1 = ((__pyx_v_self->_sockets == NULL) != 0);
1245  if (__pyx_t_1) {
1246
1247    /* "zmq/backend/cython/context.pyx":62
1248 *         self._sockets = <void **>malloc(self._max_sockets*sizeof(void *))
1249 *         if self._sockets == NULL:
1250 *             raise MemoryError("Could not allocate _sockets array")             # <<<<<<<<<<<<<<
1251 *
1252 *         self._pid = getpid()
1253 */
1254    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1255    __Pyx_GOTREF(__pyx_t_2);
1256    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
1257    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1258    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1259  }
1260
1261  /* "zmq/backend/cython/context.pyx":64
1262 *             raise MemoryError("Could not allocate _sockets array")
1263 *
1264 *         self._pid = getpid()             # <<<<<<<<<<<<<<
1265 *
1266 *     def __dealloc__(self):
1267 */
1268  __pyx_v_self->_pid = getpid();
1269
1270  /* "zmq/backend/cython/context.pyx":35
1271 *         pass
1272 *
1273 *     def __cinit__(self, int io_threads=1, size_t shadow=0, **kwargs):             # <<<<<<<<<<<<<<
1274 *         self.handle = NULL
1275 *         self._sockets = NULL
1276 */
1277
1278  /* function exit code */
1279  __pyx_r = 0;
1280  goto __pyx_L0;
1281  __pyx_L1_error:;
1282  __Pyx_XDECREF(__pyx_t_2);
1283  __Pyx_XDECREF(__pyx_t_3);
1284  __Pyx_XDECREF(__pyx_t_4);
1285  __Pyx_AddTraceback("zmq.backend.cython.context.Context.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1286  __pyx_r = -1;
1287  __pyx_L0:;
1288  __Pyx_RefNannyFinishContext();
1289  return __pyx_r;
1290}
1291
1292/* "zmq/backend/cython/context.pyx":66
1293 *         self._pid = getpid()
1294 *
1295 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
1296 *         """don't touch members in dealloc, just cleanup allocations"""
1297 *         cdef int rc
1298 */
1299
1300/* Python wrapper */
1301static void __pyx_pw_3zmq_7backend_6cython_7context_7Context_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
1302static void __pyx_pw_3zmq_7backend_6cython_7context_7Context_5__dealloc__(PyObject *__pyx_v_self) {
1303  __Pyx_RefNannyDeclarations
1304  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
1305  __pyx_pf_3zmq_7backend_6cython_7context_7Context_4__dealloc__(((struct __pyx_obj_3zmq_7backend_6cython_7context_Context *)__pyx_v_self));
1306
1307  /* function exit code */
1308  __Pyx_RefNannyFinishContext();
1309}
1310
1311static void __pyx_pf_3zmq_7backend_6cython_7context_7Context_4__dealloc__(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self) {
1312  __Pyx_RefNannyDeclarations
1313  int __pyx_t_1;
1314  __Pyx_RefNannySetupContext("__dealloc__", 0);
1315
1316  /* "zmq/backend/cython/context.pyx":69
1317 *         """don't touch members in dealloc, just cleanup allocations"""
1318 *         cdef int rc
1319 *         if self._sockets != NULL:             # <<<<<<<<<<<<<<
1320 *             free(self._sockets)
1321 *             self._sockets = NULL
1322 */
1323  __pyx_t_1 = ((__pyx_v_self->_sockets != NULL) != 0);
1324  if (__pyx_t_1) {
1325
1326    /* "zmq/backend/cython/context.pyx":70
1327 *         cdef int rc
1328 *         if self._sockets != NULL:
1329 *             free(self._sockets)             # <<<<<<<<<<<<<<
1330 *             self._sockets = NULL
1331 *             self._n_sockets = 0
1332 */
1333    free(__pyx_v_self->_sockets);
1334
1335    /* "zmq/backend/cython/context.pyx":71
1336 *         if self._sockets != NULL:
1337 *             free(self._sockets)
1338 *             self._sockets = NULL             # <<<<<<<<<<<<<<
1339 *             self._n_sockets = 0
1340 *
1341 */
1342    __pyx_v_self->_sockets = NULL;
1343
1344    /* "zmq/backend/cython/context.pyx":72
1345 *             free(self._sockets)
1346 *             self._sockets = NULL
1347 *             self._n_sockets = 0             # <<<<<<<<<<<<<<
1348 *
1349 *         # we can't call object methods in dealloc as it
1350 */
1351    __pyx_v_self->_n_sockets = 0;
1352    goto __pyx_L3;
1353  }
1354  __pyx_L3:;
1355
1356  /* "zmq/backend/cython/context.pyx":76
1357 *         # we can't call object methods in dealloc as it
1358 *         # might already be partially deleted
1359 *         if not self._shadow:             # <<<<<<<<<<<<<<
1360 *             self._term()
1361 *
1362 */
1363  __pyx_t_1 = ((!(__pyx_v_self->_shadow != 0)) != 0);
1364  if (__pyx_t_1) {
1365
1366    /* "zmq/backend/cython/context.pyx":77
1367 *         # might already be partially deleted
1368 *         if not self._shadow:
1369 *             self._term()             # <<<<<<<<<<<<<<
1370 *
1371 *     cdef inline void _add_socket(self, void* handle):
1372 */
1373    __pyx_f_3zmq_7backend_6cython_7context_7Context__term(__pyx_v_self);
1374    goto __pyx_L4;
1375  }
1376  __pyx_L4:;
1377
1378  /* "zmq/backend/cython/context.pyx":66
1379 *         self._pid = getpid()
1380 *
1381 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
1382 *         """don't touch members in dealloc, just cleanup allocations"""
1383 *         cdef int rc
1384 */
1385
1386  /* function exit code */
1387  __Pyx_RefNannyFinishContext();
1388}
1389
1390/* "zmq/backend/cython/context.pyx":79
1391 *             self._term()
1392 *
1393 *     cdef inline void _add_socket(self, void* handle):             # <<<<<<<<<<<<<<
1394 *         """Add a socket handle to be closed when Context terminates.
1395 *
1396 */
1397
1398static CYTHON_INLINE void __pyx_f_3zmq_7backend_6cython_7context_7Context__add_socket(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, void *__pyx_v_handle) {
1399  __Pyx_RefNannyDeclarations
1400  int __pyx_t_1;
1401  PyObject *__pyx_t_2 = NULL;
1402  int __pyx_lineno = 0;
1403  const char *__pyx_filename = NULL;
1404  int __pyx_clineno = 0;
1405  __Pyx_RefNannySetupContext("_add_socket", 0);
1406
1407  /* "zmq/backend/cython/context.pyx":84
1408 *         This is to be called in the Socket constructor.
1409 *         """
1410 *         if self._n_sockets >= self._max_sockets:             # <<<<<<<<<<<<<<
1411 *             self._max_sockets *= 2
1412 *             self._sockets = <void **>realloc(self._sockets, self._max_sockets*sizeof(void *))
1413 */
1414  __pyx_t_1 = ((__pyx_v_self->_n_sockets >= __pyx_v_self->_max_sockets) != 0);
1415  if (__pyx_t_1) {
1416
1417    /* "zmq/backend/cython/context.pyx":85
1418 *         """
1419 *         if self._n_sockets >= self._max_sockets:
1420 *             self._max_sockets *= 2             # <<<<<<<<<<<<<<
1421 *             self._sockets = <void **>realloc(self._sockets, self._max_sockets*sizeof(void *))
1422 *             if self._sockets == NULL:
1423 */
1424    __pyx_v_self->_max_sockets = (__pyx_v_self->_max_sockets * 2);
1425
1426    /* "zmq/backend/cython/context.pyx":86
1427 *         if self._n_sockets >= self._max_sockets:
1428 *             self._max_sockets *= 2
1429 *             self._sockets = <void **>realloc(self._sockets, self._max_sockets*sizeof(void *))             # <<<<<<<<<<<<<<
1430 *             if self._sockets == NULL:
1431 *                 raise MemoryError("Could not reallocate _sockets array")
1432 */
1433    __pyx_v_self->_sockets = ((void **)realloc(__pyx_v_self->_sockets, (__pyx_v_self->_max_sockets * (sizeof(void *)))));
1434
1435    /* "zmq/backend/cython/context.pyx":87
1436 *             self._max_sockets *= 2
1437 *             self._sockets = <void **>realloc(self._sockets, self._max_sockets*sizeof(void *))
1438 *             if self._sockets == NULL:             # <<<<<<<<<<<<<<
1439 *                 raise MemoryError("Could not reallocate _sockets array")
1440 *
1441 */
1442    __pyx_t_1 = ((__pyx_v_self->_sockets == NULL) != 0);
1443    if (__pyx_t_1) {
1444
1445      /* "zmq/backend/cython/context.pyx":88
1446 *             self._sockets = <void **>realloc(self._sockets, self._max_sockets*sizeof(void *))
1447 *             if self._sockets == NULL:
1448 *                 raise MemoryError("Could not reallocate _sockets array")             # <<<<<<<<<<<<<<
1449 *
1450 *         self._sockets[self._n_sockets] = handle
1451 */
1452      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1453      __Pyx_GOTREF(__pyx_t_2);
1454      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
1455      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1456      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1457    }
1458    goto __pyx_L3;
1459  }
1460  __pyx_L3:;
1461
1462  /* "zmq/backend/cython/context.pyx":90
1463 *                 raise MemoryError("Could not reallocate _sockets array")
1464 *
1465 *         self._sockets[self._n_sockets] = handle             # <<<<<<<<<<<<<<
1466 *         self._n_sockets += 1
1467 *
1468 */
1469  (__pyx_v_self->_sockets[__pyx_v_self->_n_sockets]) = __pyx_v_handle;
1470
1471  /* "zmq/backend/cython/context.pyx":91
1472 *
1473 *         self._sockets[self._n_sockets] = handle
1474 *         self._n_sockets += 1             # <<<<<<<<<<<<<<
1475 *
1476 *     cdef inline void _remove_socket(self, void* handle):
1477 */
1478  __pyx_v_self->_n_sockets = (__pyx_v_self->_n_sockets + 1);
1479
1480  /* "zmq/backend/cython/context.pyx":79
1481 *             self._term()
1482 *
1483 *     cdef inline void _add_socket(self, void* handle):             # <<<<<<<<<<<<<<
1484 *         """Add a socket handle to be closed when Context terminates.
1485 *
1486 */
1487
1488  /* function exit code */
1489  goto __pyx_L0;
1490  __pyx_L1_error:;
1491  __Pyx_XDECREF(__pyx_t_2);
1492  __Pyx_WriteUnraisable("zmq.backend.cython.context.Context._add_socket", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
1493  __pyx_L0:;
1494  __Pyx_RefNannyFinishContext();
1495}
1496
1497/* "zmq/backend/cython/context.pyx":93
1498 *         self._n_sockets += 1
1499 *
1500 *     cdef inline void _remove_socket(self, void* handle):             # <<<<<<<<<<<<<<
1501 *         """Remove a socket from the collected handles.
1502 *
1503 */
1504
1505static CYTHON_INLINE void __pyx_f_3zmq_7backend_6cython_7context_7Context__remove_socket(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, void *__pyx_v_handle) {
1506  int __pyx_v_found;
1507  size_t __pyx_v_idx;
1508  __Pyx_RefNannyDeclarations
1509  size_t __pyx_t_1;
1510  size_t __pyx_t_2;
1511  int __pyx_t_3;
1512  __Pyx_RefNannySetupContext("_remove_socket", 0);
1513
1514  /* "zmq/backend/cython/context.pyx":99
1515 *         close a socket a second time.
1516 *         """
1517 *         cdef bint found = False             # <<<<<<<<<<<<<<
1518 *
1519 *         for idx in range(self._n_sockets):
1520 */
1521  __pyx_v_found = 0;
1522
1523  /* "zmq/backend/cython/context.pyx":101
1524 *         cdef bint found = False
1525 *
1526 *         for idx in range(self._n_sockets):             # <<<<<<<<<<<<<<
1527 *             if self._sockets[idx] == handle:
1528 *                 found=True
1529 */
1530  __pyx_t_1 = __pyx_v_self->_n_sockets;
1531  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
1532    __pyx_v_idx = __pyx_t_2;
1533
1534    /* "zmq/backend/cython/context.pyx":102
1535 *
1536 *         for idx in range(self._n_sockets):
1537 *             if self._sockets[idx] == handle:             # <<<<<<<<<<<<<<
1538 *                 found=True
1539 *                 break
1540 */
1541    __pyx_t_3 = (((__pyx_v_self->_sockets[__pyx_v_idx]) == __pyx_v_handle) != 0);
1542    if (__pyx_t_3) {
1543
1544      /* "zmq/backend/cython/context.pyx":103
1545 *         for idx in range(self._n_sockets):
1546 *             if self._sockets[idx] == handle:
1547 *                 found=True             # <<<<<<<<<<<<<<
1548 *                 break
1549 *
1550 */
1551      __pyx_v_found = 1;
1552
1553      /* "zmq/backend/cython/context.pyx":104
1554 *             if self._sockets[idx] == handle:
1555 *                 found=True
1556 *                 break             # <<<<<<<<<<<<<<
1557 *
1558 *         if found:
1559 */
1560      goto __pyx_L4_break;
1561    }
1562  }
1563  __pyx_L4_break:;
1564
1565  /* "zmq/backend/cython/context.pyx":106
1566 *                 break
1567 *
1568 *         if found:             # <<<<<<<<<<<<<<
1569 *             self._n_sockets -= 1
1570 *             if self._n_sockets:
1571 */
1572  __pyx_t_3 = (__pyx_v_found != 0);
1573  if (__pyx_t_3) {
1574
1575    /* "zmq/backend/cython/context.pyx":107
1576 *
1577 *         if found:
1578 *             self._n_sockets -= 1             # <<<<<<<<<<<<<<
1579 *             if self._n_sockets:
1580 *                 # move last handle to closed socket's index
1581 */
1582    __pyx_v_self->_n_sockets = (__pyx_v_self->_n_sockets - 1);
1583
1584    /* "zmq/backend/cython/context.pyx":108
1585 *         if found:
1586 *             self._n_sockets -= 1
1587 *             if self._n_sockets:             # <<<<<<<<<<<<<<
1588 *                 # move last handle to closed socket's index
1589 *                 self._sockets[idx] = self._sockets[self._n_sockets]
1590 */
1591    __pyx_t_3 = (__pyx_v_self->_n_sockets != 0);
1592    if (__pyx_t_3) {
1593
1594      /* "zmq/backend/cython/context.pyx":110
1595 *             if self._n_sockets:
1596 *                 # move last handle to closed socket's index
1597 *                 self._sockets[idx] = self._sockets[self._n_sockets]             # <<<<<<<<<<<<<<
1598 *
1599 *
1600 */
1601      (__pyx_v_self->_sockets[__pyx_v_idx]) = (__pyx_v_self->_sockets[__pyx_v_self->_n_sockets]);
1602      goto __pyx_L7;
1603    }
1604    __pyx_L7:;
1605    goto __pyx_L6;
1606  }
1607  __pyx_L6:;
1608
1609  /* "zmq/backend/cython/context.pyx":93
1610 *         self._n_sockets += 1
1611 *
1612 *     cdef inline void _remove_socket(self, void* handle):             # <<<<<<<<<<<<<<
1613 *         """Remove a socket from the collected handles.
1614 *
1615 */
1616
1617  /* function exit code */
1618  __Pyx_RefNannyFinishContext();
1619}
1620
1621/* "zmq/backend/cython/context.pyx":114
1622 *
1623 *     @property
1624 *     def underlying(self):             # <<<<<<<<<<<<<<
1625 *         """The address of the underlying libzmq context"""
1626 *         return <size_t> self.handle
1627 */
1628
1629/* Python wrapper */
1630static PyObject *__pyx_pw_3zmq_7backend_6cython_7context_7Context_7underlying(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1631static char __pyx_doc_3zmq_7backend_6cython_7context_7Context_6underlying[] = "The address of the underlying libzmq context";
1632static PyObject *__pyx_pw_3zmq_7backend_6cython_7context_7Context_7underlying(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1633  PyObject *__pyx_r = 0;
1634  __Pyx_RefNannyDeclarations
1635  __Pyx_RefNannySetupContext("underlying (wrapper)", 0);
1636  __pyx_r = __pyx_pf_3zmq_7backend_6cython_7context_7Context_6underlying(((struct __pyx_obj_3zmq_7backend_6cython_7context_Context *)__pyx_v_self));
1637
1638  /* function exit code */
1639  __Pyx_RefNannyFinishContext();
1640  return __pyx_r;
1641}
1642
1643static PyObject *__pyx_pf_3zmq_7backend_6cython_7context_7Context_6underlying(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self) {
1644  PyObject *__pyx_r = NULL;
1645  __Pyx_RefNannyDeclarations
1646  PyObject *__pyx_t_1 = NULL;
1647  int __pyx_lineno = 0;
1648  const char *__pyx_filename = NULL;
1649  int __pyx_clineno = 0;
1650  __Pyx_RefNannySetupContext("underlying", 0);
1651
1652  /* "zmq/backend/cython/context.pyx":116
1653 *     def underlying(self):
1654 *         """The address of the underlying libzmq context"""
1655 *         return <size_t> self.handle             # <<<<<<<<<<<<<<
1656 *
1657 *     # backward-compat, though nobody is using it
1658 */
1659  __Pyx_XDECREF(__pyx_r);
1660  __pyx_t_1 = __Pyx_PyInt_FromSize_t(((size_t)__pyx_v_self->handle)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1661  __Pyx_GOTREF(__pyx_t_1);
1662  __pyx_r = __pyx_t_1;
1663  __pyx_t_1 = 0;
1664  goto __pyx_L0;
1665
1666  /* "zmq/backend/cython/context.pyx":114
1667 *
1668 *     @property
1669 *     def underlying(self):             # <<<<<<<<<<<<<<
1670 *         """The address of the underlying libzmq context"""
1671 *         return <size_t> self.handle
1672 */
1673
1674  /* function exit code */
1675  __pyx_L1_error:;
1676  __Pyx_XDECREF(__pyx_t_1);
1677  __Pyx_AddTraceback("zmq.backend.cython.context.Context.underlying", __pyx_clineno, __pyx_lineno, __pyx_filename);
1678  __pyx_r = NULL;
1679  __pyx_L0:;
1680  __Pyx_XGIVEREF(__pyx_r);
1681  __Pyx_RefNannyFinishContext();
1682  return __pyx_r;
1683}
1684
1685/* "zmq/backend/cython/context.pyx":121
1686 *     _handle = underlying
1687 *
1688 *     cdef inline int _term(self):             # <<<<<<<<<<<<<<
1689 *         cdef int rc=0
1690 *         if self.handle != NULL and not self.closed and getpid() == self._pid:
1691 */
1692
1693static CYTHON_INLINE int __pyx_f_3zmq_7backend_6cython_7context_7Context__term(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self) {
1694  int __pyx_v_rc;
1695  int __pyx_r;
1696  __Pyx_RefNannyDeclarations
1697  int __pyx_t_1;
1698  int __pyx_t_2;
1699  __Pyx_RefNannySetupContext("_term", 0);
1700
1701  /* "zmq/backend/cython/context.pyx":122
1702 *
1703 *     cdef inline int _term(self):
1704 *         cdef int rc=0             # <<<<<<<<<<<<<<
1705 *         if self.handle != NULL and not self.closed and getpid() == self._pid:
1706 *             with nogil:
1707 */
1708  __pyx_v_rc = 0;
1709
1710  /* "zmq/backend/cython/context.pyx":123
1711 *     cdef inline int _term(self):
1712 *         cdef int rc=0
1713 *         if self.handle != NULL and not self.closed and getpid() == self._pid:             # <<<<<<<<<<<<<<
1714 *             with nogil:
1715 *                 rc = zmq_ctx_destroy(self.handle)
1716 */
1717  __pyx_t_2 = ((__pyx_v_self->handle != NULL) != 0);
1718  if (__pyx_t_2) {
1719  } else {
1720    __pyx_t_1 = __pyx_t_2;
1721    goto __pyx_L4_bool_binop_done;
1722  }
1723  __pyx_t_2 = ((!(__pyx_v_self->closed != 0)) != 0);
1724  if (__pyx_t_2) {
1725  } else {
1726    __pyx_t_1 = __pyx_t_2;
1727    goto __pyx_L4_bool_binop_done;
1728  }
1729  __pyx_t_2 = ((getpid() == __pyx_v_self->_pid) != 0);
1730  __pyx_t_1 = __pyx_t_2;
1731  __pyx_L4_bool_binop_done:;
1732  if (__pyx_t_1) {
1733
1734    /* "zmq/backend/cython/context.pyx":124
1735 *         cdef int rc=0
1736 *         if self.handle != NULL and not self.closed and getpid() == self._pid:
1737 *             with nogil:             # <<<<<<<<<<<<<<
1738 *                 rc = zmq_ctx_destroy(self.handle)
1739 *         self.handle = NULL
1740 */
1741    {
1742        #ifdef WITH_THREAD
1743        PyThreadState *_save;
1744        Py_UNBLOCK_THREADS
1745        #endif
1746        /*try:*/ {
1747
1748          /* "zmq/backend/cython/context.pyx":125
1749 *         if self.handle != NULL and not self.closed and getpid() == self._pid:
1750 *             with nogil:
1751 *                 rc = zmq_ctx_destroy(self.handle)             # <<<<<<<<<<<<<<
1752 *         self.handle = NULL
1753 *         return rc
1754 */
1755          __pyx_v_rc = zmq_ctx_destroy(__pyx_v_self->handle);
1756        }
1757
1758        /* "zmq/backend/cython/context.pyx":124
1759 *         cdef int rc=0
1760 *         if self.handle != NULL and not self.closed and getpid() == self._pid:
1761 *             with nogil:             # <<<<<<<<<<<<<<
1762 *                 rc = zmq_ctx_destroy(self.handle)
1763 *         self.handle = NULL
1764 */
1765        /*finally:*/ {
1766          /*normal exit:*/{
1767            #ifdef WITH_THREAD
1768            Py_BLOCK_THREADS
1769            #endif
1770            goto __pyx_L9;
1771          }
1772          __pyx_L9:;
1773        }
1774    }
1775    goto __pyx_L3;
1776  }
1777  __pyx_L3:;
1778
1779  /* "zmq/backend/cython/context.pyx":126
1780 *             with nogil:
1781 *                 rc = zmq_ctx_destroy(self.handle)
1782 *         self.handle = NULL             # <<<<<<<<<<<<<<
1783 *         return rc
1784 *
1785 */
1786  __pyx_v_self->handle = NULL;
1787
1788  /* "zmq/backend/cython/context.pyx":127
1789 *                 rc = zmq_ctx_destroy(self.handle)
1790 *         self.handle = NULL
1791 *         return rc             # <<<<<<<<<<<<<<
1792 *
1793 *     def term(self):
1794 */
1795  __pyx_r = __pyx_v_rc;
1796  goto __pyx_L0;
1797
1798  /* "zmq/backend/cython/context.pyx":121
1799 *     _handle = underlying
1800 *
1801 *     cdef inline int _term(self):             # <<<<<<<<<<<<<<
1802 *         cdef int rc=0
1803 *         if self.handle != NULL and not self.closed and getpid() == self._pid:
1804 */
1805
1806  /* function exit code */
1807  __pyx_L0:;
1808  __Pyx_RefNannyFinishContext();
1809  return __pyx_r;
1810}
1811
1812/* "zmq/backend/cython/context.pyx":129
1813 *         return rc
1814 *
1815 *     def term(self):             # <<<<<<<<<<<<<<
1816 *         """ctx.term()
1817 *
1818 */
1819
1820/* Python wrapper */
1821static PyObject *__pyx_pw_3zmq_7backend_6cython_7context_7Context_9term(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1822static char __pyx_doc_3zmq_7backend_6cython_7context_7Context_8term[] = "ctx.term()\n\n        Close or terminate the context.\n        \n        This can be called to close the context by hand. If this is not called,\n        the context will automatically be closed when it is garbage collected.\n        ";
1823static PyObject *__pyx_pw_3zmq_7backend_6cython_7context_7Context_9term(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1824  PyObject *__pyx_r = 0;
1825  __Pyx_RefNannyDeclarations
1826  __Pyx_RefNannySetupContext("term (wrapper)", 0);
1827  __pyx_r = __pyx_pf_3zmq_7backend_6cython_7context_7Context_8term(((struct __pyx_obj_3zmq_7backend_6cython_7context_Context *)__pyx_v_self));
1828
1829  /* function exit code */
1830  __Pyx_RefNannyFinishContext();
1831  return __pyx_r;
1832}
1833
1834static PyObject *__pyx_pf_3zmq_7backend_6cython_7context_7Context_8term(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self) {
1835  CYTHON_UNUSED int __pyx_v_rc;
1836  PyObject *__pyx_r = NULL;
1837  __Pyx_RefNannyDeclarations
1838  __Pyx_RefNannySetupContext("term", 0);
1839
1840  /* "zmq/backend/cython/context.pyx":138
1841 *         """
1842 *         cdef int rc
1843 *         rc = self._term()             # <<<<<<<<<<<<<<
1844 *         self.closed = True
1845 *
1846 */
1847  __pyx_v_rc = __pyx_f_3zmq_7backend_6cython_7context_7Context__term(__pyx_v_self);
1848
1849  /* "zmq/backend/cython/context.pyx":139
1850 *         cdef int rc
1851 *         rc = self._term()
1852 *         self.closed = True             # <<<<<<<<<<<<<<
1853 *
1854 *     def set(self, int option, optval):
1855 */
1856  __pyx_v_self->closed = 1;
1857
1858  /* "zmq/backend/cython/context.pyx":129
1859 *         return rc
1860 *
1861 *     def term(self):             # <<<<<<<<<<<<<<
1862 *         """ctx.term()
1863 *
1864 */
1865
1866  /* function exit code */
1867  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1868  __Pyx_XGIVEREF(__pyx_r);
1869  __Pyx_RefNannyFinishContext();
1870  return __pyx_r;
1871}
1872
1873/* "zmq/backend/cython/context.pyx":141
1874 *         self.closed = True
1875 *
1876 *     def set(self, int option, optval):             # <<<<<<<<<<<<<<
1877 *         """ctx.set(option, optval)
1878 *
1879 */
1880
1881/* Python wrapper */
1882static PyObject *__pyx_pw_3zmq_7backend_6cython_7context_7Context_11set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1883static char __pyx_doc_3zmq_7backend_6cython_7context_7Context_10set[] = "ctx.set(option, optval)\n\n        Set a context option.\n\n        See the 0MQ API documentation for zmq_ctx_set\n        for details on specific options.\n        \n        .. versionadded:: libzmq-3.2\n        .. versionadded:: 13.0\n\n        Parameters\n        ----------\n        option : int\n            The option to set.  Available values will depend on your\n            version of libzmq.  Examples include::\n            \n                zmq.IO_THREADS, zmq.MAX_SOCKETS\n        \n        optval : int\n            The value of the option to set.\n        ";
1884static PyObject *__pyx_pw_3zmq_7backend_6cython_7context_7Context_11set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1885  int __pyx_v_option;
1886  PyObject *__pyx_v_optval = 0;
1887  int __pyx_lineno = 0;
1888  const char *__pyx_filename = NULL;
1889  int __pyx_clineno = 0;
1890  PyObject *__pyx_r = 0;
1891  __Pyx_RefNannyDeclarations
1892  __Pyx_RefNannySetupContext("set (wrapper)", 0);
1893  {
1894    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_option,&__pyx_n_s_optval,0};
1895    PyObject* values[2] = {0,0};
1896    if (unlikely(__pyx_kwds)) {
1897      Py_ssize_t kw_args;
1898      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1899      switch (pos_args) {
1900        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1901        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1902        case  0: break;
1903        default: goto __pyx_L5_argtuple_error;
1904      }
1905      kw_args = PyDict_Size(__pyx_kwds);
1906      switch (pos_args) {
1907        case  0:
1908        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_option)) != 0)) kw_args--;
1909        else goto __pyx_L5_argtuple_error;
1910        case  1:
1911        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_optval)) != 0)) kw_args--;
1912        else {
1913          __Pyx_RaiseArgtupleInvalid("set", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1914        }
1915      }
1916      if (unlikely(kw_args > 0)) {
1917        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1918      }
1919    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
1920      goto __pyx_L5_argtuple_error;
1921    } else {
1922      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1923      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1924    }
1925    __pyx_v_option = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_option == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1926    __pyx_v_optval = values[1];
1927  }
1928  goto __pyx_L4_argument_unpacking_done;
1929  __pyx_L5_argtuple_error:;
1930  __Pyx_RaiseArgtupleInvalid("set", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1931  __pyx_L3_error:;
1932  __Pyx_AddTraceback("zmq.backend.cython.context.Context.set", __pyx_clineno, __pyx_lineno, __pyx_filename);
1933  __Pyx_RefNannyFinishContext();
1934  return NULL;
1935  __pyx_L4_argument_unpacking_done:;
1936  __pyx_r = __pyx_pf_3zmq_7backend_6cython_7context_7Context_10set(((struct __pyx_obj_3zmq_7backend_6cython_7context_Context *)__pyx_v_self), __pyx_v_option, __pyx_v_optval);
1937
1938  /* function exit code */
1939  __Pyx_RefNannyFinishContext();
1940  return __pyx_r;
1941}
1942
1943static PyObject *__pyx_pf_3zmq_7backend_6cython_7context_7Context_10set(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, int __pyx_v_option, PyObject *__pyx_v_optval) {
1944  int __pyx_v_optval_int_c;
1945  int __pyx_v_rc;
1946  PyObject *__pyx_r = NULL;
1947  __Pyx_RefNannyDeclarations
1948  int __pyx_t_1;
1949  PyObject *__pyx_t_2 = NULL;
1950  int __pyx_t_3;
1951  PyObject *__pyx_t_4 = NULL;
1952  int __pyx_t_5;
1953  int __pyx_lineno = 0;
1954  const char *__pyx_filename = NULL;
1955  int __pyx_clineno = 0;
1956  __Pyx_RefNannySetupContext("set", 0);
1957
1958  /* "zmq/backend/cython/context.pyx":167
1959 *         cdef char* optval_c
1960 *
1961 *         if self.closed:             # <<<<<<<<<<<<<<
1962 *             raise RuntimeError("Context has been destroyed")
1963 *
1964 */
1965  __pyx_t_1 = (__pyx_v_self->closed != 0);
1966  if (__pyx_t_1) {
1967
1968    /* "zmq/backend/cython/context.pyx":168
1969 *
1970 *         if self.closed:
1971 *             raise RuntimeError("Context has been destroyed")             # <<<<<<<<<<<<<<
1972 *
1973 *         if not isinstance(optval, int):
1974 */
1975    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1976    __Pyx_GOTREF(__pyx_t_2);
1977    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
1978    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1979    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1980  }
1981
1982  /* "zmq/backend/cython/context.pyx":170
1983 *             raise RuntimeError("Context has been destroyed")
1984 *
1985 *         if not isinstance(optval, int):             # <<<<<<<<<<<<<<
1986 *             raise TypeError('expected int, got: %r' % optval)
1987 *         optval_int_c = optval
1988 */
1989  __pyx_t_1 = PyInt_Check(__pyx_v_optval);
1990  __pyx_t_3 = ((!(__pyx_t_1 != 0)) != 0);
1991  if (__pyx_t_3) {
1992
1993    /* "zmq/backend/cython/context.pyx":171
1994 *
1995 *         if not isinstance(optval, int):
1996 *             raise TypeError('expected int, got: %r' % optval)             # <<<<<<<<<<<<<<
1997 *         optval_int_c = optval
1998 *         rc = zmq_ctx_set(self.handle, option, optval_int_c)
1999 */
2000    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_expected_int_got_r, __pyx_v_optval); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2001    __Pyx_GOTREF(__pyx_t_2);
2002    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2003    __Pyx_GOTREF(__pyx_t_4);
2004    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
2005    __Pyx_GIVEREF(__pyx_t_2);
2006    __pyx_t_2 = 0;
2007    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2008    __Pyx_GOTREF(__pyx_t_2);
2009    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2010    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
2011    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2012    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2013  }
2014
2015  /* "zmq/backend/cython/context.pyx":172
2016 *         if not isinstance(optval, int):
2017 *             raise TypeError('expected int, got: %r' % optval)
2018 *         optval_int_c = optval             # <<<<<<<<<<<<<<
2019 *         rc = zmq_ctx_set(self.handle, option, optval_int_c)
2020 *         _check_rc(rc)
2021 */
2022  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_optval); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2023  __pyx_v_optval_int_c = __pyx_t_5;
2024
2025  /* "zmq/backend/cython/context.pyx":173
2026 *             raise TypeError('expected int, got: %r' % optval)
2027 *         optval_int_c = optval
2028 *         rc = zmq_ctx_set(self.handle, option, optval_int_c)             # <<<<<<<<<<<<<<
2029 *         _check_rc(rc)
2030 *
2031 */
2032  __pyx_v_rc = zmq_ctx_set(__pyx_v_self->handle, __pyx_v_option, __pyx_v_optval_int_c);
2033
2034  /* "zmq/backend/cython/context.pyx":174
2035 *         optval_int_c = optval
2036 *         rc = zmq_ctx_set(self.handle, option, optval_int_c)
2037 *         _check_rc(rc)             # <<<<<<<<<<<<<<
2038 *
2039 *     def get(self, int option):
2040 */
2041  __pyx_t_5 = __pyx_f_3zmq_7backend_6cython_7checkrc__check_rc(__pyx_v_rc); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2042
2043  /* "zmq/backend/cython/context.pyx":141
2044 *         self.closed = True
2045 *
2046 *     def set(self, int option, optval):             # <<<<<<<<<<<<<<
2047 *         """ctx.set(option, optval)
2048 *
2049 */
2050
2051  /* function exit code */
2052  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2053  goto __pyx_L0;
2054  __pyx_L1_error:;
2055  __Pyx_XDECREF(__pyx_t_2);
2056  __Pyx_XDECREF(__pyx_t_4);
2057  __Pyx_AddTraceback("zmq.backend.cython.context.Context.set", __pyx_clineno, __pyx_lineno, __pyx_filename);
2058  __pyx_r = NULL;
2059  __pyx_L0:;
2060  __Pyx_XGIVEREF(__pyx_r);
2061  __Pyx_RefNannyFinishContext();
2062  return __pyx_r;
2063}
2064
2065/* "zmq/backend/cython/context.pyx":176
2066 *         _check_rc(rc)
2067 *
2068 *     def get(self, int option):             # <<<<<<<<<<<<<<
2069 *         """ctx.get(option)
2070 *
2071 */
2072
2073/* Python wrapper */
2074static PyObject *__pyx_pw_3zmq_7backend_6cython_7context_7Context_13get(PyObject *__pyx_v_self, PyObject *__pyx_arg_option); /*proto*/
2075static char __pyx_doc_3zmq_7backend_6cython_7context_7Context_12get[] = "ctx.get(option)\n\n        Get the value of a context option.\n\n        See the 0MQ API documentation for zmq_ctx_get\n        for details on specific options.\n        \n        .. versionadded:: libzmq-3.2\n        .. versionadded:: 13.0\n\n        Parameters\n        ----------\n        option : int\n            The option to get.  Available values will depend on your\n            version of libzmq.  Examples include::\n            \n                zmq.IO_THREADS, zmq.MAX_SOCKETS\n            \n        Returns\n        -------\n        optval : int\n            The value of the option as an integer.\n        ";
2076static PyObject *__pyx_pw_3zmq_7backend_6cython_7context_7Context_13get(PyObject *__pyx_v_self, PyObject *__pyx_arg_option) {
2077  int __pyx_v_option;
2078  int __pyx_lineno = 0;
2079  const char *__pyx_filename = NULL;
2080  int __pyx_clineno = 0;
2081  PyObject *__pyx_r = 0;
2082  __Pyx_RefNannyDeclarations
2083  __Pyx_RefNannySetupContext("get (wrapper)", 0);
2084  assert(__pyx_arg_option); {
2085    __pyx_v_option = __Pyx_PyInt_As_int(__pyx_arg_option); if (unlikely((__pyx_v_option == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2086  }
2087  goto __pyx_L4_argument_unpacking_done;
2088  __pyx_L3_error:;
2089  __Pyx_AddTraceback("zmq.backend.cython.context.Context.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
2090  __Pyx_RefNannyFinishContext();
2091  return NULL;
2092  __pyx_L4_argument_unpacking_done:;
2093  __pyx_r = __pyx_pf_3zmq_7backend_6cython_7context_7Context_12get(((struct __pyx_obj_3zmq_7backend_6cython_7context_Context *)__pyx_v_self), ((int)__pyx_v_option));
2094
2095  /* function exit code */
2096  __Pyx_RefNannyFinishContext();
2097  return __pyx_r;
2098}
2099
2100static PyObject *__pyx_pf_3zmq_7backend_6cython_7context_7Context_12get(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, int __pyx_v_option) {
2101  int __pyx_v_rc;
2102  PyObject *__pyx_r = NULL;
2103  __Pyx_RefNannyDeclarations
2104  int __pyx_t_1;
2105  PyObject *__pyx_t_2 = NULL;
2106  int __pyx_t_3;
2107  int __pyx_lineno = 0;
2108  const char *__pyx_filename = NULL;
2109  int __pyx_clineno = 0;
2110  __Pyx_RefNannySetupContext("get", 0);
2111
2112  /* "zmq/backend/cython/context.pyx":204
2113 *         cdef int rc
2114 *
2115 *         if self.closed:             # <<<<<<<<<<<<<<
2116 *             raise RuntimeError("Context has been destroyed")
2117 *
2118 */
2119  __pyx_t_1 = (__pyx_v_self->closed != 0);
2120  if (__pyx_t_1) {
2121
2122    /* "zmq/backend/cython/context.pyx":205
2123 *
2124 *         if self.closed:
2125 *             raise RuntimeError("Context has been destroyed")             # <<<<<<<<<<<<<<
2126 *
2127 *         rc = zmq_ctx_get(self.handle, option)
2128 */
2129    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2130    __Pyx_GOTREF(__pyx_t_2);
2131    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
2132    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2133    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2134  }
2135
2136  /* "zmq/backend/cython/context.pyx":207
2137 *             raise RuntimeError("Context has been destroyed")
2138 *
2139 *         rc = zmq_ctx_get(self.handle, option)             # <<<<<<<<<<<<<<
2140 *         _check_rc(rc)
2141 *
2142 */
2143  __pyx_v_rc = zmq_ctx_get(__pyx_v_self->handle, __pyx_v_option);
2144
2145  /* "zmq/backend/cython/context.pyx":208
2146 *
2147 *         rc = zmq_ctx_get(self.handle, option)
2148 *         _check_rc(rc)             # <<<<<<<<<<<<<<
2149 *
2150 *         return rc
2151 */
2152  __pyx_t_3 = __pyx_f_3zmq_7backend_6cython_7checkrc__check_rc(__pyx_v_rc); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2153
2154  /* "zmq/backend/cython/context.pyx":210
2155 *         _check_rc(rc)
2156 *
2157 *         return rc             # <<<<<<<<<<<<<<
2158 *
2159 *     def destroy(self, linger=None):
2160 */
2161  __Pyx_XDECREF(__pyx_r);
2162  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2163  __Pyx_GOTREF(__pyx_t_2);
2164  __pyx_r = __pyx_t_2;
2165  __pyx_t_2 = 0;
2166  goto __pyx_L0;
2167
2168  /* "zmq/backend/cython/context.pyx":176
2169 *         _check_rc(rc)
2170 *
2171 *     def get(self, int option):             # <<<<<<<<<<<<<<
2172 *         """ctx.get(option)
2173 *
2174 */
2175
2176  /* function exit code */
2177  __pyx_L1_error:;
2178  __Pyx_XDECREF(__pyx_t_2);
2179  __Pyx_AddTraceback("zmq.backend.cython.context.Context.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
2180  __pyx_r = NULL;
2181  __pyx_L0:;
2182  __Pyx_XGIVEREF(__pyx_r);
2183  __Pyx_RefNannyFinishContext();
2184  return __pyx_r;
2185}
2186
2187/* "zmq/backend/cython/context.pyx":212
2188 *         return rc
2189 *
2190 *     def destroy(self, linger=None):             # <<<<<<<<<<<<<<
2191 *         """ctx.destroy(linger=None)
2192 *
2193 */
2194
2195/* Python wrapper */
2196static PyObject *__pyx_pw_3zmq_7backend_6cython_7context_7Context_15destroy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2197static char __pyx_doc_3zmq_7backend_6cython_7context_7Context_14destroy[] = "ctx.destroy(linger=None)\n        \n        Close all sockets associated with this context, and then terminate\n        the context. If linger is specified,\n        the LINGER sockopt of the sockets will be set prior to closing.\n        \n        .. warning::\n        \n            destroy involves calling ``zmq_close()``, which is **NOT** threadsafe.\n            If there are active sockets in other threads, this must not be called.\n        ";
2198static PyObject *__pyx_pw_3zmq_7backend_6cython_7context_7Context_15destroy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2199  PyObject *__pyx_v_linger = 0;
2200  int __pyx_lineno = 0;
2201  const char *__pyx_filename = NULL;
2202  int __pyx_clineno = 0;
2203  PyObject *__pyx_r = 0;
2204  __Pyx_RefNannyDeclarations
2205  __Pyx_RefNannySetupContext("destroy (wrapper)", 0);
2206  {
2207    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_linger,0};
2208    PyObject* values[1] = {0};
2209    values[0] = ((PyObject *)Py_None);
2210    if (unlikely(__pyx_kwds)) {
2211      Py_ssize_t kw_args;
2212      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2213      switch (pos_args) {
2214        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2215        case  0: break;
2216        default: goto __pyx_L5_argtuple_error;
2217      }
2218      kw_args = PyDict_Size(__pyx_kwds);
2219      switch (pos_args) {
2220        case  0:
2221        if (kw_args > 0) {
2222          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_linger);
2223          if (value) { values[0] = value; kw_args--; }
2224        }
2225      }
2226      if (unlikely(kw_args > 0)) {
2227        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "destroy") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2228      }
2229    } else {
2230      switch (PyTuple_GET_SIZE(__pyx_args)) {
2231        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2232        case  0: break;
2233        default: goto __pyx_L5_argtuple_error;
2234      }
2235    }
2236    __pyx_v_linger = values[0];
2237  }
2238  goto __pyx_L4_argument_unpacking_done;
2239  __pyx_L5_argtuple_error:;
2240  __Pyx_RaiseArgtupleInvalid("destroy", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2241  __pyx_L3_error:;
2242  __Pyx_AddTraceback("zmq.backend.cython.context.Context.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
2243  __Pyx_RefNannyFinishContext();
2244  return NULL;
2245  __pyx_L4_argument_unpacking_done:;
2246  __pyx_r = __pyx_pf_3zmq_7backend_6cython_7context_7Context_14destroy(((struct __pyx_obj_3zmq_7backend_6cython_7context_Context *)__pyx_v_self), __pyx_v_linger);
2247
2248  /* function exit code */
2249  __Pyx_RefNannyFinishContext();
2250  return __pyx_r;
2251}
2252
2253static PyObject *__pyx_pf_3zmq_7backend_6cython_7context_7Context_14destroy(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, PyObject *__pyx_v_linger) {
2254  int __pyx_v_linger_c;
2255  int __pyx_v_setlinger;
2256  int __pyx_v_rc;
2257  PyObject *__pyx_r = NULL;
2258  __Pyx_RefNannyDeclarations
2259  int __pyx_t_1;
2260  int __pyx_t_2;
2261  int __pyx_t_3;
2262  PyObject *__pyx_t_4 = NULL;
2263  PyObject *__pyx_t_5 = NULL;
2264  PyObject *__pyx_t_6 = NULL;
2265  int __pyx_lineno = 0;
2266  const char *__pyx_filename = NULL;
2267  int __pyx_clineno = 0;
2268  __Pyx_RefNannySetupContext("destroy", 0);
2269
2270  /* "zmq/backend/cython/context.pyx":226
2271 *
2272 *         cdef int linger_c
2273 *         cdef bint setlinger=False             # <<<<<<<<<<<<<<
2274 *
2275 *         if linger is not None:
2276 */
2277  __pyx_v_setlinger = 0;
2278
2279  /* "zmq/backend/cython/context.pyx":228
2280 *         cdef bint setlinger=False
2281 *
2282 *         if linger is not None:             # <<<<<<<<<<<<<<
2283 *             linger_c = linger
2284 *             setlinger=True
2285 */
2286  __pyx_t_1 = (__pyx_v_linger != Py_None);
2287  __pyx_t_2 = (__pyx_t_1 != 0);
2288  if (__pyx_t_2) {
2289
2290    /* "zmq/backend/cython/context.pyx":229
2291 *
2292 *         if linger is not None:
2293 *             linger_c = linger             # <<<<<<<<<<<<<<
2294 *             setlinger=True
2295 *
2296 */
2297    __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_v_linger); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2298    __pyx_v_linger_c = __pyx_t_3;
2299
2300    /* "zmq/backend/cython/context.pyx":230
2301 *         if linger is not None:
2302 *             linger_c = linger
2303 *             setlinger=True             # <<<<<<<<<<<<<<
2304 *
2305 *         if self.handle != NULL and not self.closed and self._n_sockets:
2306 */
2307    __pyx_v_setlinger = 1;
2308    goto __pyx_L3;
2309  }
2310  __pyx_L3:;
2311
2312  /* "zmq/backend/cython/context.pyx":232
2313 *             setlinger=True
2314 *
2315 *         if self.handle != NULL and not self.closed and self._n_sockets:             # <<<<<<<<<<<<<<
2316 *             while self._n_sockets:
2317 *                 if setlinger:
2318 */
2319  __pyx_t_1 = ((__pyx_v_self->handle != NULL) != 0);
2320  if (__pyx_t_1) {
2321  } else {
2322    __pyx_t_2 = __pyx_t_1;
2323    goto __pyx_L5_bool_binop_done;
2324  }
2325  __pyx_t_1 = ((!(__pyx_v_self->closed != 0)) != 0);
2326  if (__pyx_t_1) {
2327  } else {
2328    __pyx_t_2 = __pyx_t_1;
2329    goto __pyx_L5_bool_binop_done;
2330  }
2331  __pyx_t_1 = (__pyx_v_self->_n_sockets != 0);
2332  __pyx_t_2 = __pyx_t_1;
2333  __pyx_L5_bool_binop_done:;
2334  if (__pyx_t_2) {
2335
2336    /* "zmq/backend/cython/context.pyx":233
2337 *
2338 *         if self.handle != NULL and not self.closed and self._n_sockets:
2339 *             while self._n_sockets:             # <<<<<<<<<<<<<<
2340 *                 if setlinger:
2341 *                     zmq_setsockopt(self._sockets[0], ZMQ_LINGER, &linger_c, sizeof(int))
2342 */
2343    while (1) {
2344      __pyx_t_2 = (__pyx_v_self->_n_sockets != 0);
2345      if (!__pyx_t_2) break;
2346
2347      /* "zmq/backend/cython/context.pyx":234
2348 *         if self.handle != NULL and not self.closed and self._n_sockets:
2349 *             while self._n_sockets:
2350 *                 if setlinger:             # <<<<<<<<<<<<<<
2351 *                     zmq_setsockopt(self._sockets[0], ZMQ_LINGER, &linger_c, sizeof(int))
2352 *                 rc = zmq_close(self._sockets[0])
2353 */
2354      __pyx_t_2 = (__pyx_v_setlinger != 0);
2355      if (__pyx_t_2) {
2356
2357        /* "zmq/backend/cython/context.pyx":235
2358 *             while self._n_sockets:
2359 *                 if setlinger:
2360 *                     zmq_setsockopt(self._sockets[0], ZMQ_LINGER, &linger_c, sizeof(int))             # <<<<<<<<<<<<<<
2361 *                 rc = zmq_close(self._sockets[0])
2362 *                 if rc < 0 and zmq_errno() != ZMQ_ENOTSOCK:
2363 */
2364        zmq_setsockopt((__pyx_v_self->_sockets[0]), ZMQ_LINGER, (&__pyx_v_linger_c), (sizeof(int)));
2365        goto __pyx_L10;
2366      }
2367      __pyx_L10:;
2368
2369      /* "zmq/backend/cython/context.pyx":236
2370 *                 if setlinger:
2371 *                     zmq_setsockopt(self._sockets[0], ZMQ_LINGER, &linger_c, sizeof(int))
2372 *                 rc = zmq_close(self._sockets[0])             # <<<<<<<<<<<<<<
2373 *                 if rc < 0 and zmq_errno() != ZMQ_ENOTSOCK:
2374 *                     raise ZMQError()
2375 */
2376      __pyx_v_rc = zmq_close((__pyx_v_self->_sockets[0]));
2377
2378      /* "zmq/backend/cython/context.pyx":237
2379 *                     zmq_setsockopt(self._sockets[0], ZMQ_LINGER, &linger_c, sizeof(int))
2380 *                 rc = zmq_close(self._sockets[0])
2381 *                 if rc < 0 and zmq_errno() != ZMQ_ENOTSOCK:             # <<<<<<<<<<<<<<
2382 *                     raise ZMQError()
2383 *                 self._n_sockets -= 1
2384 */
2385      __pyx_t_1 = ((__pyx_v_rc < 0) != 0);
2386      if (__pyx_t_1) {
2387      } else {
2388        __pyx_t_2 = __pyx_t_1;
2389        goto __pyx_L12_bool_binop_done;
2390      }
2391      __pyx_t_1 = ((zmq_errno() != ENOTSOCK) != 0);
2392      __pyx_t_2 = __pyx_t_1;
2393      __pyx_L12_bool_binop_done:;
2394      if (__pyx_t_2) {
2395
2396        /* "zmq/backend/cython/context.pyx":238
2397 *                 rc = zmq_close(self._sockets[0])
2398 *                 if rc < 0 and zmq_errno() != ZMQ_ENOTSOCK:
2399 *                     raise ZMQError()             # <<<<<<<<<<<<<<
2400 *                 self._n_sockets -= 1
2401 *                 self._sockets[0] = self._sockets[self._n_sockets]
2402 */
2403        __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_ZMQError); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2404        __Pyx_GOTREF(__pyx_t_5);
2405        __pyx_t_6 = NULL;
2406        if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
2407          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
2408          if (likely(__pyx_t_6)) {
2409            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
2410            __Pyx_INCREF(__pyx_t_6);
2411            __Pyx_INCREF(function);
2412            __Pyx_DECREF_SET(__pyx_t_5, function);
2413          }
2414        }
2415        if (__pyx_t_6) {
2416          __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2417          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2418        } else {
2419          __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2420        }
2421        __Pyx_GOTREF(__pyx_t_4);
2422        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2423        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
2424        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2425        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2426      }
2427
2428      /* "zmq/backend/cython/context.pyx":239
2429 *                 if rc < 0 and zmq_errno() != ZMQ_ENOTSOCK:
2430 *                     raise ZMQError()
2431 *                 self._n_sockets -= 1             # <<<<<<<<<<<<<<
2432 *                 self._sockets[0] = self._sockets[self._n_sockets]
2433 *         self.term()
2434 */
2435      __pyx_v_self->_n_sockets = (__pyx_v_self->_n_sockets - 1);
2436
2437      /* "zmq/backend/cython/context.pyx":240
2438 *                     raise ZMQError()
2439 *                 self._n_sockets -= 1
2440 *                 self._sockets[0] = self._sockets[self._n_sockets]             # <<<<<<<<<<<<<<
2441 *         self.term()
2442 *
2443 */
2444      (__pyx_v_self->_sockets[0]) = (__pyx_v_self->_sockets[__pyx_v_self->_n_sockets]);
2445    }
2446    goto __pyx_L4;
2447  }
2448  __pyx_L4:;
2449
2450  /* "zmq/backend/cython/context.pyx":241
2451 *                 self._n_sockets -= 1
2452 *                 self._sockets[0] = self._sockets[self._n_sockets]
2453 *         self.term()             # <<<<<<<<<<<<<<
2454 *
2455 * __all__ = ['Context']
2456 */
2457  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_term); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2458  __Pyx_GOTREF(__pyx_t_5);
2459  __pyx_t_6 = NULL;
2460  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
2461    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
2462    if (likely(__pyx_t_6)) {
2463      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
2464      __Pyx_INCREF(__pyx_t_6);
2465      __Pyx_INCREF(function);
2466      __Pyx_DECREF_SET(__pyx_t_5, function);
2467    }
2468  }
2469  if (__pyx_t_6) {
2470    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2471    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2472  } else {
2473    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2474  }
2475  __Pyx_GOTREF(__pyx_t_4);
2476  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2477  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2478
2479  /* "zmq/backend/cython/context.pyx":212
2480 *         return rc
2481 *
2482 *     def destroy(self, linger=None):             # <<<<<<<<<<<<<<
2483 *         """ctx.destroy(linger=None)
2484 *
2485 */
2486
2487  /* function exit code */
2488  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2489  goto __pyx_L0;
2490  __pyx_L1_error:;
2491  __Pyx_XDECREF(__pyx_t_4);
2492  __Pyx_XDECREF(__pyx_t_5);
2493  __Pyx_XDECREF(__pyx_t_6);
2494  __Pyx_AddTraceback("zmq.backend.cython.context.Context.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
2495  __pyx_r = NULL;
2496  __pyx_L0:;
2497  __Pyx_XGIVEREF(__pyx_r);
2498  __Pyx_RefNannyFinishContext();
2499  return __pyx_r;
2500}
2501
2502/* "zmq/backend/cython/context.pxd":36
2503 *     cdef int _pid               # the pid of the process which created me (for fork safety)
2504 *
2505 *     cdef public bint closed   # bool property for a closed context.             # <<<<<<<<<<<<<<
2506 *     cdef inline int _term(self)
2507 *     # helpers for events on _sockets in Socket.__cinit__()/close()
2508 */
2509
2510/* Python wrapper */
2511static PyObject *__pyx_pw_3zmq_7backend_6cython_7context_7Context_6closed_1__get__(PyObject *__pyx_v_self); /*proto*/
2512static PyObject *__pyx_pw_3zmq_7backend_6cython_7context_7Context_6closed_1__get__(PyObject *__pyx_v_self) {
2513  PyObject *__pyx_r = 0;
2514  __Pyx_RefNannyDeclarations
2515  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
2516  __pyx_r = __pyx_pf_3zmq_7backend_6cython_7context_7Context_6closed___get__(((struct __pyx_obj_3zmq_7backend_6cython_7context_Context *)__pyx_v_self));
2517
2518  /* function exit code */
2519  __Pyx_RefNannyFinishContext();
2520  return __pyx_r;
2521}
2522
2523static PyObject *__pyx_pf_3zmq_7backend_6cython_7context_7Context_6closed___get__(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self) {
2524  PyObject *__pyx_r = NULL;
2525  __Pyx_RefNannyDeclarations
2526  PyObject *__pyx_t_1 = NULL;
2527  int __pyx_lineno = 0;
2528  const char *__pyx_filename = NULL;
2529  int __pyx_clineno = 0;
2530  __Pyx_RefNannySetupContext("__get__", 0);
2531  __Pyx_XDECREF(__pyx_r);
2532  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->closed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2533  __Pyx_GOTREF(__pyx_t_1);
2534  __pyx_r = __pyx_t_1;
2535  __pyx_t_1 = 0;
2536  goto __pyx_L0;
2537
2538  /* function exit code */
2539  __pyx_L1_error:;
2540  __Pyx_XDECREF(__pyx_t_1);
2541  __Pyx_AddTraceback("zmq.backend.cython.context.Context.closed.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2542  __pyx_r = NULL;
2543  __pyx_L0:;
2544  __Pyx_XGIVEREF(__pyx_r);
2545  __Pyx_RefNannyFinishContext();
2546  return __pyx_r;
2547}
2548
2549/* Python wrapper */
2550static int __pyx_pw_3zmq_7backend_6cython_7context_7Context_6closed_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
2551static int __pyx_pw_3zmq_7backend_6cython_7context_7Context_6closed_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
2552  int __pyx_r;
2553  __Pyx_RefNannyDeclarations
2554  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
2555  __pyx_r = __pyx_pf_3zmq_7backend_6cython_7context_7Context_6closed_2__set__(((struct __pyx_obj_3zmq_7backend_6cython_7context_Context *)__pyx_v_self), ((PyObject *)__pyx_v_value));
2556
2557  /* function exit code */
2558  __Pyx_RefNannyFinishContext();
2559  return __pyx_r;
2560}
2561
2562static int __pyx_pf_3zmq_7backend_6cython_7context_7Context_6closed_2__set__(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *__pyx_v_self, PyObject *__pyx_v_value) {
2563  int __pyx_r;
2564  __Pyx_RefNannyDeclarations
2565  int __pyx_t_1;
2566  int __pyx_lineno = 0;
2567  const char *__pyx_filename = NULL;
2568  int __pyx_clineno = 0;
2569  __Pyx_RefNannySetupContext("__set__", 0);
2570  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2571  __pyx_v_self->closed = __pyx_t_1;
2572
2573  /* function exit code */
2574  __pyx_r = 0;
2575  goto __pyx_L0;
2576  __pyx_L1_error:;
2577  __Pyx_AddTraceback("zmq.backend.cython.context.Context.closed.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2578  __pyx_r = -1;
2579  __pyx_L0:;
2580  __Pyx_RefNannyFinishContext();
2581  return __pyx_r;
2582}
2583
2584/* "zmq/backend/cython/checkrc.pxd":5
2585 * from libzmq cimport zmq_errno, ZMQ_ETERM
2586 *
2587 * cdef inline int _check_rc(int rc) except -1:             # <<<<<<<<<<<<<<
2588 *     """internal utility for checking zmq return condition
2589 *
2590 */
2591
2592static CYTHON_INLINE int __pyx_f_3zmq_7backend_6cython_7checkrc__check_rc(int __pyx_v_rc) {
2593  int __pyx_v_errno;
2594  PyObject *__pyx_v_Again = NULL;
2595  PyObject *__pyx_v_ContextTerminated = NULL;
2596  PyObject *__pyx_v_ZMQError = NULL;
2597  int __pyx_r;
2598  __Pyx_RefNannyDeclarations
2599  int __pyx_t_1;
2600  int __pyx_t_2;
2601  PyObject *__pyx_t_3 = NULL;
2602  PyObject *__pyx_t_4 = NULL;
2603  PyObject *__pyx_t_5 = NULL;
2604  PyObject *__pyx_t_6 = NULL;
2605  PyObject *__pyx_t_7 = NULL;
2606  int __pyx_lineno = 0;
2607  const char *__pyx_filename = NULL;
2608  int __pyx_clineno = 0;
2609  __Pyx_RefNannySetupContext("_check_rc", 0);
2610
2611  /* "zmq/backend/cython/checkrc.pxd":10
2612 *     and raising the appropriate Exception class
2613 *     """
2614 *     cdef int errno = zmq_errno()             # <<<<<<<<<<<<<<
2615 *     PyErr_CheckSignals()
2616 *     if rc < 0:
2617 */
2618  __pyx_v_errno = zmq_errno();
2619
2620  /* "zmq/backend/cython/checkrc.pxd":11
2621 *     """
2622 *     cdef int errno = zmq_errno()
2623 *     PyErr_CheckSignals()             # <<<<<<<<<<<<<<
2624 *     if rc < 0:
2625 *         if errno == EAGAIN:
2626 */
2627  __pyx_t_1 = PyErr_CheckSignals(); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2628
2629  /* "zmq/backend/cython/checkrc.pxd":12
2630 *     cdef int errno = zmq_errno()
2631 *     PyErr_CheckSignals()
2632 *     if rc < 0:             # <<<<<<<<<<<<<<
2633 *         if errno == EAGAIN:
2634 *             from zmq.error import Again
2635 */
2636  __pyx_t_2 = ((__pyx_v_rc < 0) != 0);
2637  if (__pyx_t_2) {
2638
2639    /* "zmq/backend/cython/checkrc.pxd":16
2640 *             from zmq.error import Again
2641 *             raise Again(errno)
2642 *         elif errno == ZMQ_ETERM:             # <<<<<<<<<<<<<<
2643 *             from zmq.error import ContextTerminated
2644 *             raise ContextTerminated(errno)
2645 */
2646    switch (__pyx_v_errno) {
2647
2648      /* "zmq/backend/cython/checkrc.pxd":13
2649 *     PyErr_CheckSignals()
2650 *     if rc < 0:
2651 *         if errno == EAGAIN:             # <<<<<<<<<<<<<<
2652 *             from zmq.error import Again
2653 *             raise Again(errno)
2654 */
2655      case EAGAIN:
2656
2657      /* "zmq/backend/cython/checkrc.pxd":14
2658 *     if rc < 0:
2659 *         if errno == EAGAIN:
2660 *             from zmq.error import Again             # <<<<<<<<<<<<<<
2661 *             raise Again(errno)
2662 *         elif errno == ZMQ_ETERM:
2663 */
2664      __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2665      __Pyx_GOTREF(__pyx_t_3);
2666      __Pyx_INCREF(__pyx_n_s_Again);
2667      PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_Again);
2668      __Pyx_GIVEREF(__pyx_n_s_Again);
2669      __pyx_t_4 = __Pyx_Import(__pyx_n_s_zmq_error, __pyx_t_3, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2670      __Pyx_GOTREF(__pyx_t_4);
2671      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2672      __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_Again); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2673      __Pyx_GOTREF(__pyx_t_3);
2674      __Pyx_INCREF(__pyx_t_3);
2675      __pyx_v_Again = __pyx_t_3;
2676      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2677      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2678
2679      /* "zmq/backend/cython/checkrc.pxd":15
2680 *         if errno == EAGAIN:
2681 *             from zmq.error import Again
2682 *             raise Again(errno)             # <<<<<<<<<<<<<<
2683 *         elif errno == ZMQ_ETERM:
2684 *             from zmq.error import ContextTerminated
2685 */
2686      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_errno); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2687      __Pyx_GOTREF(__pyx_t_3);
2688      __Pyx_INCREF(__pyx_v_Again);
2689      __pyx_t_5 = __pyx_v_Again; __pyx_t_6 = NULL;
2690      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
2691        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
2692        if (likely(__pyx_t_6)) {
2693          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
2694          __Pyx_INCREF(__pyx_t_6);
2695          __Pyx_INCREF(function);
2696          __Pyx_DECREF_SET(__pyx_t_5, function);
2697        }
2698      }
2699      if (!__pyx_t_6) {
2700        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2701        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2702        __Pyx_GOTREF(__pyx_t_4);
2703      } else {
2704        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2705        __Pyx_GOTREF(__pyx_t_7);
2706        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
2707        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_3);
2708        __Pyx_GIVEREF(__pyx_t_3);
2709        __pyx_t_3 = 0;
2710        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2711        __Pyx_GOTREF(__pyx_t_4);
2712        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2713      }
2714      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2715      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
2716      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2717      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2718      break;
2719
2720      /* "zmq/backend/cython/checkrc.pxd":16
2721 *             from zmq.error import Again
2722 *             raise Again(errno)
2723 *         elif errno == ZMQ_ETERM:             # <<<<<<<<<<<<<<
2724 *             from zmq.error import ContextTerminated
2725 *             raise ContextTerminated(errno)
2726 */
2727      case ETERM:
2728
2729      /* "zmq/backend/cython/checkrc.pxd":17
2730 *             raise Again(errno)
2731 *         elif errno == ZMQ_ETERM:
2732 *             from zmq.error import ContextTerminated             # <<<<<<<<<<<<<<
2733 *             raise ContextTerminated(errno)
2734 *         else:
2735 */
2736      __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2737      __Pyx_GOTREF(__pyx_t_4);
2738      __Pyx_INCREF(__pyx_n_s_ContextTerminated);
2739      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_ContextTerminated);
2740      __Pyx_GIVEREF(__pyx_n_s_ContextTerminated);
2741      __pyx_t_5 = __Pyx_Import(__pyx_n_s_zmq_error, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2742      __Pyx_GOTREF(__pyx_t_5);
2743      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2744      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_ContextTerminated); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2745      __Pyx_GOTREF(__pyx_t_4);
2746      __Pyx_INCREF(__pyx_t_4);
2747      __pyx_v_ContextTerminated = __pyx_t_4;
2748      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2749      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2750
2751      /* "zmq/backend/cython/checkrc.pxd":18
2752 *         elif errno == ZMQ_ETERM:
2753 *             from zmq.error import ContextTerminated
2754 *             raise ContextTerminated(errno)             # <<<<<<<<<<<<<<
2755 *         else:
2756 *             from zmq.error import ZMQError
2757 */
2758      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_errno); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2759      __Pyx_GOTREF(__pyx_t_4);
2760      __Pyx_INCREF(__pyx_v_ContextTerminated);
2761      __pyx_t_7 = __pyx_v_ContextTerminated; __pyx_t_3 = NULL;
2762      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
2763        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
2764        if (likely(__pyx_t_3)) {
2765          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
2766          __Pyx_INCREF(__pyx_t_3);
2767          __Pyx_INCREF(function);
2768          __Pyx_DECREF_SET(__pyx_t_7, function);
2769        }
2770      }
2771      if (!__pyx_t_3) {
2772        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2773        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2774        __Pyx_GOTREF(__pyx_t_5);
2775      } else {
2776        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2777        __Pyx_GOTREF(__pyx_t_6);
2778        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
2779        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
2780        __Pyx_GIVEREF(__pyx_t_4);
2781        __pyx_t_4 = 0;
2782        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2783        __Pyx_GOTREF(__pyx_t_5);
2784        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2785      }
2786      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2787      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
2788      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2789      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2790      break;
2791      default:
2792
2793      /* "zmq/backend/cython/checkrc.pxd":20
2794 *             raise ContextTerminated(errno)
2795 *         else:
2796 *             from zmq.error import ZMQError             # <<<<<<<<<<<<<<
2797 *             raise ZMQError(errno)
2798 *         # return -1
2799 */
2800      __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2801      __Pyx_GOTREF(__pyx_t_5);
2802      __Pyx_INCREF(__pyx_n_s_ZMQError);
2803      PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_ZMQError);
2804      __Pyx_GIVEREF(__pyx_n_s_ZMQError);
2805      __pyx_t_7 = __Pyx_Import(__pyx_n_s_zmq_error, __pyx_t_5, -1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2806      __Pyx_GOTREF(__pyx_t_7);
2807      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2808      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_ZMQError); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2809      __Pyx_GOTREF(__pyx_t_5);
2810      __Pyx_INCREF(__pyx_t_5);
2811      __pyx_v_ZMQError = __pyx_t_5;
2812      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2813      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2814
2815      /* "zmq/backend/cython/checkrc.pxd":21
2816 *         else:
2817 *             from zmq.error import ZMQError
2818 *             raise ZMQError(errno)             # <<<<<<<<<<<<<<
2819 *         # return -1
2820 *     return 0
2821 */
2822      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_errno); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2823      __Pyx_GOTREF(__pyx_t_5);
2824      __Pyx_INCREF(__pyx_v_ZMQError);
2825      __pyx_t_6 = __pyx_v_ZMQError; __pyx_t_4 = NULL;
2826      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
2827        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
2828        if (likely(__pyx_t_4)) {
2829          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
2830          __Pyx_INCREF(__pyx_t_4);
2831          __Pyx_INCREF(function);
2832          __Pyx_DECREF_SET(__pyx_t_6, function);
2833        }
2834      }
2835      if (!__pyx_t_4) {
2836        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2837        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2838        __Pyx_GOTREF(__pyx_t_7);
2839      } else {
2840        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2841        __Pyx_GOTREF(__pyx_t_3);
2842        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
2843        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_5);
2844        __Pyx_GIVEREF(__pyx_t_5);
2845        __pyx_t_5 = 0;
2846        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2847        __Pyx_GOTREF(__pyx_t_7);
2848        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2849      }
2850      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2851      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
2852      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2853      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2854      break;
2855    }
2856  }
2857
2858  /* "zmq/backend/cython/checkrc.pxd":23
2859 *             raise ZMQError(errno)
2860 *         # return -1
2861 *     return 0             # <<<<<<<<<<<<<<
2862 */
2863  __pyx_r = 0;
2864  goto __pyx_L0;
2865
2866  /* "zmq/backend/cython/checkrc.pxd":5
2867 * from libzmq cimport zmq_errno, ZMQ_ETERM
2868 *
2869 * cdef inline int _check_rc(int rc) except -1:             # <<<<<<<<<<<<<<
2870 *     """internal utility for checking zmq return condition
2871 *
2872 */
2873
2874  /* function exit code */
2875  __pyx_L1_error:;
2876  __Pyx_XDECREF(__pyx_t_3);
2877  __Pyx_XDECREF(__pyx_t_4);
2878  __Pyx_XDECREF(__pyx_t_5);
2879  __Pyx_XDECREF(__pyx_t_6);
2880  __Pyx_XDECREF(__pyx_t_7);
2881  __Pyx_AddTraceback("zmq.backend.cython.checkrc._check_rc", __pyx_clineno, __pyx_lineno, __pyx_filename);
2882  __pyx_r = -1;
2883  __pyx_L0:;
2884  __Pyx_XDECREF(__pyx_v_Again);
2885  __Pyx_XDECREF(__pyx_v_ContextTerminated);
2886  __Pyx_XDECREF(__pyx_v_ZMQError);
2887  __Pyx_RefNannyFinishContext();
2888  return __pyx_r;
2889}
2890static struct __pyx_vtabstruct_3zmq_7backend_6cython_7context_Context __pyx_vtable_3zmq_7backend_6cython_7context_Context;
2891
2892static PyObject *__pyx_tp_new_3zmq_7backend_6cython_7context_Context(PyTypeObject *t, PyObject *a, PyObject *k) {
2893  struct __pyx_obj_3zmq_7backend_6cython_7context_Context *p;
2894  PyObject *o;
2895  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
2896    o = (*t->tp_alloc)(t, 0);
2897  } else {
2898    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
2899  }
2900  if (unlikely(!o)) return 0;
2901  p = ((struct __pyx_obj_3zmq_7backend_6cython_7context_Context *)o);
2902  p->__pyx_vtab = __pyx_vtabptr_3zmq_7backend_6cython_7context_Context;
2903  if (unlikely(__pyx_pw_3zmq_7backend_6cython_7context_7Context_3__cinit__(o, a, k) < 0)) {
2904    Py_DECREF(o); o = 0;
2905  }
2906  return o;
2907}
2908
2909static void __pyx_tp_dealloc_3zmq_7backend_6cython_7context_Context(PyObject *o) {
2910  struct __pyx_obj_3zmq_7backend_6cython_7context_Context *p = (struct __pyx_obj_3zmq_7backend_6cython_7context_Context *)o;
2911  #if PY_VERSION_HEX >= 0x030400a1
2912  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
2913    if (PyObject_CallFinalizerFromDealloc(o)) return;
2914  }
2915  #endif
2916  {
2917    PyObject *etype, *eval, *etb;
2918    PyErr_Fetch(&etype, &eval, &etb);
2919    ++Py_REFCNT(o);
2920    __pyx_pw_3zmq_7backend_6cython_7context_7Context_5__dealloc__(o);
2921    --Py_REFCNT(o);
2922    PyErr_Restore(etype, eval, etb);
2923  }
2924  if (p->__weakref__) PyObject_ClearWeakRefs(o);
2925  (*Py_TYPE(o)->tp_free)(o);
2926}
2927
2928static PyObject *__pyx_getprop_3zmq_7backend_6cython_7context_7Context_closed(PyObject *o, CYTHON_UNUSED void *x) {
2929  return __pyx_pw_3zmq_7backend_6cython_7context_7Context_6closed_1__get__(o);
2930}
2931
2932static int __pyx_setprop_3zmq_7backend_6cython_7context_7Context_closed(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
2933  if (v) {
2934    return __pyx_pw_3zmq_7backend_6cython_7context_7Context_6closed_3__set__(o, v);
2935  }
2936  else {
2937    PyErr_SetString(PyExc_NotImplementedError, "__del__");
2938    return -1;
2939  }
2940}
2941
2942static PyMethodDef __pyx_methods_3zmq_7backend_6cython_7context_Context[] = {
2943  {"underlying", (PyCFunction)__pyx_pw_3zmq_7backend_6cython_7context_7Context_7underlying, METH_NOARGS, __pyx_doc_3zmq_7backend_6cython_7context_7Context_6underlying},
2944  {"term", (PyCFunction)__pyx_pw_3zmq_7backend_6cython_7context_7Context_9term, METH_NOARGS, __pyx_doc_3zmq_7backend_6cython_7context_7Context_8term},
2945  {"set", (PyCFunction)__pyx_pw_3zmq_7backend_6cython_7context_7Context_11set, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3zmq_7backend_6cython_7context_7Context_10set},
2946  {"get", (PyCFunction)__pyx_pw_3zmq_7backend_6cython_7context_7Context_13get, METH_O, __pyx_doc_3zmq_7backend_6cython_7context_7Context_12get},
2947  {"destroy", (PyCFunction)__pyx_pw_3zmq_7backend_6cython_7context_7Context_15destroy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3zmq_7backend_6cython_7context_7Context_14destroy},
2948  {0, 0, 0, 0}
2949};
2950
2951static struct PyGetSetDef __pyx_getsets_3zmq_7backend_6cython_7context_Context[] = {
2952  {(char *)"closed", __pyx_getprop_3zmq_7backend_6cython_7context_7Context_closed, __pyx_setprop_3zmq_7backend_6cython_7context_7Context_closed, 0, 0},
2953  {0, 0, 0, 0, 0}
2954};
2955
2956static PyTypeObject __pyx_type_3zmq_7backend_6cython_7context_Context = {
2957  PyVarObject_HEAD_INIT(0, 0)
2958  "zmq.backend.cython.context.Context", /*tp_name*/
2959  sizeof(struct __pyx_obj_3zmq_7backend_6cython_7context_Context), /*tp_basicsize*/
2960  0, /*tp_itemsize*/
2961  __pyx_tp_dealloc_3zmq_7backend_6cython_7context_Context, /*tp_dealloc*/
2962  0, /*tp_print*/
2963  0, /*tp_getattr*/
2964  0, /*tp_setattr*/
2965  #if PY_MAJOR_VERSION < 3
2966  0, /*tp_compare*/
2967  #else
2968  0, /*reserved*/
2969  #endif
2970  0, /*tp_repr*/
2971  0, /*tp_as_number*/
2972  0, /*tp_as_sequence*/
2973  0, /*tp_as_mapping*/
2974  0, /*tp_hash*/
2975  0, /*tp_call*/
2976  0, /*tp_str*/
2977  0, /*tp_getattro*/
2978  0, /*tp_setattro*/
2979  0, /*tp_as_buffer*/
2980  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
2981  "Context(io_threads=1)\n\n    Manage the lifecycle of a 0MQ context.\n\n    Parameters\n    ----------\n    io_threads : int\n        The number of IO threads.\n    ", /*tp_doc*/
2982  0, /*tp_traverse*/
2983  0, /*tp_clear*/
2984  0, /*tp_richcompare*/
2985  0, /*tp_weaklistoffset*/
2986  0, /*tp_iter*/
2987  0, /*tp_iternext*/
2988  __pyx_methods_3zmq_7backend_6cython_7context_Context, /*tp_methods*/
2989  0, /*tp_members*/
2990  __pyx_getsets_3zmq_7backend_6cython_7context_Context, /*tp_getset*/
2991  0, /*tp_base*/
2992  0, /*tp_dict*/
2993  0, /*tp_descr_get*/
2994  0, /*tp_descr_set*/
2995  0, /*tp_dictoffset*/
2996  __pyx_pw_3zmq_7backend_6cython_7context_7Context_1__init__, /*tp_init*/
2997  0, /*tp_alloc*/
2998  __pyx_tp_new_3zmq_7backend_6cython_7context_Context, /*tp_new*/
2999  0, /*tp_free*/
3000  0, /*tp_is_gc*/
3001  0, /*tp_bases*/
3002  0, /*tp_mro*/
3003  0, /*tp_cache*/
3004  0, /*tp_subclasses*/
3005  0, /*tp_weaklist*/
3006  0, /*tp_del*/
3007  0, /*tp_version_tag*/
3008  #if PY_VERSION_HEX >= 0x030400a1
3009  0, /*tp_finalize*/
3010  #endif
3011};
3012
3013static PyMethodDef __pyx_methods[] = {
3014  {0, 0, 0, 0}
3015};
3016
3017#if PY_MAJOR_VERSION >= 3
3018static struct PyModuleDef __pyx_moduledef = {
3019  #if PY_VERSION_HEX < 0x03020000
3020    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
3021  #else
3022    PyModuleDef_HEAD_INIT,
3023  #endif
3024    "context",
3025    __pyx_k_0MQ_Context_class, /* m_doc */
3026    -1, /* m_size */
3027    __pyx_methods /* m_methods */,
3028    NULL, /* m_reload */
3029    NULL, /* m_traverse */
3030    NULL, /* m_clear */
3031    NULL /* m_free */
3032};
3033#endif
3034
3035static __Pyx_StringTabEntry __pyx_string_tab[] = {
3036  {&__pyx_n_s_Again, __pyx_k_Again, sizeof(__pyx_k_Again), 0, 0, 1, 1},
3037  {&__pyx_n_s_Context, __pyx_k_Context, sizeof(__pyx_k_Context), 0, 0, 1, 1},
3038  {&__pyx_n_s_ContextTerminated, __pyx_k_ContextTerminated, sizeof(__pyx_k_ContextTerminated), 0, 0, 1, 1},
3039  {&__pyx_kp_s_Context_has_been_destroyed, __pyx_k_Context_has_been_destroyed, sizeof(__pyx_k_Context_has_been_destroyed), 0, 0, 1, 0},
3040  {&__pyx_kp_s_Could_not_allocate__sockets_arra, __pyx_k_Could_not_allocate__sockets_arra, sizeof(__pyx_k_Could_not_allocate__sockets_arra), 0, 0, 1, 0},
3041  {&__pyx_kp_s_Could_not_reallocate__sockets_ar, __pyx_k_Could_not_reallocate__sockets_ar, sizeof(__pyx_k_Could_not_reallocate__sockets_ar), 0, 0, 1, 0},
3042  {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
3043  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
3044  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
3045  {&__pyx_n_s_ZMQError, __pyx_k_ZMQError, sizeof(__pyx_k_ZMQError), 0, 0, 1, 1},
3046  {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
3047  {&__pyx_kp_s_expected_int_got_r, __pyx_k_expected_int_got_r, sizeof(__pyx_k_expected_int_got_r), 0, 0, 1, 0},
3048  {&__pyx_n_s_handle, __pyx_k_handle, sizeof(__pyx_k_handle), 0, 0, 1, 1},
3049  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
3050  {&__pyx_n_s_instance, __pyx_k_instance, sizeof(__pyx_k_instance), 0, 0, 1, 1},
3051  {&__pyx_n_s_io_threads, __pyx_k_io_threads, sizeof(__pyx_k_io_threads), 0, 0, 1, 1},
3052  {&__pyx_n_s_linger, __pyx_k_linger, sizeof(__pyx_k_linger), 0, 0, 1, 1},
3053  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
3054  {&__pyx_n_s_option, __pyx_k_option, sizeof(__pyx_k_option), 0, 0, 1, 1},
3055  {&__pyx_n_s_optval, __pyx_k_optval, sizeof(__pyx_k_optval), 0, 0, 1, 1},
3056  {&__pyx_n_s_property, __pyx_k_property, sizeof(__pyx_k_property), 0, 0, 1, 1},
3057  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
3058  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
3059  {&__pyx_n_s_shadow, __pyx_k_shadow, sizeof(__pyx_k_shadow), 0, 0, 1, 1},
3060  {&__pyx_n_s_term, __pyx_k_term, sizeof(__pyx_k_term), 0, 0, 1, 1},
3061  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
3062  {&__pyx_n_s_underlying, __pyx_k_underlying, sizeof(__pyx_k_underlying), 0, 0, 1, 1},
3063  {&__pyx_n_s_zmq_error, __pyx_k_zmq_error, sizeof(__pyx_k_zmq_error), 0, 0, 1, 1},
3064  {0, 0, 0, 0, 0, 0, 0}
3065};
3066static int __Pyx_InitCachedBuiltins(void) {
3067  __pyx_builtin_property = __Pyx_GetBuiltinName(__pyx_n_s_property); if (!__pyx_builtin_property) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3068  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3069  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3070  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3071  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3072  return 0;
3073  __pyx_L1_error:;
3074  return -1;
3075}
3076
3077static int __Pyx_InitCachedConstants(void) {
3078  __Pyx_RefNannyDeclarations
3079  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
3080
3081  /* "zmq/backend/cython/context.pyx":62
3082 *         self._sockets = <void **>malloc(self._max_sockets*sizeof(void *))
3083 *         if self._sockets == NULL:
3084 *             raise MemoryError("Could not allocate _sockets array")             # <<<<<<<<<<<<<<
3085 *
3086 *         self._pid = getpid()
3087 */
3088  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Could_not_allocate__sockets_arra); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3089  __Pyx_GOTREF(__pyx_tuple_);
3090  __Pyx_GIVEREF(__pyx_tuple_);
3091
3092  /* "zmq/backend/cython/context.pyx":88
3093 *             self._sockets = <void **>realloc(self._sockets, self._max_sockets*sizeof(void *))
3094 *             if self._sockets == NULL:
3095 *                 raise MemoryError("Could not reallocate _sockets array")             # <<<<<<<<<<<<<<
3096 *
3097 *         self._sockets[self._n_sockets] = handle
3098 */
3099  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Could_not_reallocate__sockets_ar); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3100  __Pyx_GOTREF(__pyx_tuple__2);
3101  __Pyx_GIVEREF(__pyx_tuple__2);
3102
3103  /* "zmq/backend/cython/context.pyx":168
3104 *
3105 *         if self.closed:
3106 *             raise RuntimeError("Context has been destroyed")             # <<<<<<<<<<<<<<
3107 *
3108 *         if not isinstance(optval, int):
3109 */
3110  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Context_has_been_destroyed); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3111  __Pyx_GOTREF(__pyx_tuple__3);
3112  __Pyx_GIVEREF(__pyx_tuple__3);
3113
3114  /* "zmq/backend/cython/context.pyx":205
3115 *
3116 *         if self.closed:
3117 *             raise RuntimeError("Context has been destroyed")             # <<<<<<<<<<<<<<
3118 *
3119 *         rc = zmq_ctx_get(self.handle, option)
3120 */
3121  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_Context_has_been_destroyed); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3122  __Pyx_GOTREF(__pyx_tuple__4);
3123  __Pyx_GIVEREF(__pyx_tuple__4);
3124  __Pyx_RefNannyFinishContext();
3125  return 0;
3126  __pyx_L1_error:;
3127  __Pyx_RefNannyFinishContext();
3128  return -1;
3129}
3130
3131static int __Pyx_InitGlobals(void) {
3132  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
3133  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3134  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3135  return 0;
3136  __pyx_L1_error:;
3137  return -1;
3138}
3139
3140#if PY_MAJOR_VERSION < 3
3141PyMODINIT_FUNC initcontext(void); /*proto*/
3142PyMODINIT_FUNC initcontext(void)
3143#else
3144PyMODINIT_FUNC PyInit_context(void); /*proto*/
3145PyMODINIT_FUNC PyInit_context(void)
3146#endif
3147{
3148  PyObject *__pyx_t_1 = NULL;
3149  PyObject *__pyx_t_2 = NULL;
3150  int __pyx_lineno = 0;
3151  const char *__pyx_filename = NULL;
3152  int __pyx_clineno = 0;
3153  __Pyx_RefNannyDeclarations
3154  #if CYTHON_REFNANNY
3155  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
3156  if (!__Pyx_RefNanny) {
3157      PyErr_Clear();
3158      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
3159      if (!__Pyx_RefNanny)
3160          Py_FatalError("failed to import 'refnanny' module");
3161  }
3162  #endif
3163  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_context(void)", 0);
3164  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3165  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3166  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3167  #ifdef __Pyx_CyFunction_USED
3168  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3169  #endif
3170  #ifdef __Pyx_FusedFunction_USED
3171  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3172  #endif
3173  #ifdef __Pyx_Generator_USED
3174  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3175  #endif
3176  /*--- Library function declarations ---*/
3177  /*--- Threads initialization code ---*/
3178  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
3179  #ifdef WITH_THREAD /* Python build with threading support? */
3180  PyEval_InitThreads();
3181  #endif
3182  #endif
3183  /*--- Module creation code ---*/
3184  #if PY_MAJOR_VERSION < 3
3185  __pyx_m = Py_InitModule4("context", __pyx_methods, __pyx_k_0MQ_Context_class, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
3186  #else
3187  __pyx_m = PyModule_Create(&__pyx_moduledef);
3188  #endif
3189  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3190  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3191  Py_INCREF(__pyx_d);
3192  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3193  #if CYTHON_COMPILING_IN_PYPY
3194  Py_INCREF(__pyx_b);
3195  #endif
3196  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
3197  /*--- Initialize various global constants etc. ---*/
3198  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3199  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
3200  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3201  #endif
3202  if (__pyx_module_is_main_zmq__backend__cython__context) {
3203    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
3204  }
3205  #if PY_MAJOR_VERSION >= 3
3206  {
3207    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3208    if (!PyDict_GetItemString(modules, "zmq.backend.cython.context")) {
3209      if (unlikely(PyDict_SetItemString(modules, "zmq.backend.cython.context", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3210    }
3211  }
3212  #endif
3213  /*--- Builtin init code ---*/
3214  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3215  /*--- Constants init code ---*/
3216  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3217  /*--- Global init code ---*/
3218  /*--- Variable export code ---*/
3219  /*--- Function export code ---*/
3220  /*--- Type init code ---*/
3221  __pyx_vtabptr_3zmq_7backend_6cython_7context_Context = &__pyx_vtable_3zmq_7backend_6cython_7context_Context;
3222  __pyx_vtable_3zmq_7backend_6cython_7context_Context._term = (int (*)(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *))__pyx_f_3zmq_7backend_6cython_7context_7Context__term;
3223  __pyx_vtable_3zmq_7backend_6cython_7context_Context._add_socket = (void (*)(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *, void *))__pyx_f_3zmq_7backend_6cython_7context_7Context__add_socket;
3224  __pyx_vtable_3zmq_7backend_6cython_7context_Context._remove_socket = (void (*)(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *, void *))__pyx_f_3zmq_7backend_6cython_7context_7Context__remove_socket;
3225  if (PyType_Ready(&__pyx_type_3zmq_7backend_6cython_7context_Context) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3226  __pyx_type_3zmq_7backend_6cython_7context_Context.tp_print = 0;
3227  if (__Pyx_SetVtable(__pyx_type_3zmq_7backend_6cython_7context_Context.tp_dict, __pyx_vtabptr_3zmq_7backend_6cython_7context_Context) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3228  if (PyObject_SetAttrString(__pyx_m, "Context", (PyObject *)&__pyx_type_3zmq_7backend_6cython_7context_Context) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3229  if (__pyx_type_3zmq_7backend_6cython_7context_Context.tp_weaklistoffset == 0) __pyx_type_3zmq_7backend_6cython_7context_Context.tp_weaklistoffset = offsetof(struct __pyx_obj_3zmq_7backend_6cython_7context_Context, __weakref__);
3230  __pyx_ptype_3zmq_7backend_6cython_7context_Context = &__pyx_type_3zmq_7backend_6cython_7context_Context;
3231  /*--- Type import code ---*/
3232  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type",
3233  #if CYTHON_COMPILING_IN_PYPY
3234  sizeof(PyTypeObject),
3235  #else
3236  sizeof(PyHeapTypeObject),
3237  #endif
3238  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3239  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3240  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3241  /*--- Variable import code ---*/
3242  /*--- Function import code ---*/
3243  /*--- Execution code ---*/
3244
3245  /* "zmq/backend/cython/context.pyx":14
3246 *     int getpid()
3247 *
3248 * from zmq.error import ZMQError             # <<<<<<<<<<<<<<
3249 * from zmq.backend.cython.checkrc cimport _check_rc
3250 *
3251 */
3252  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3253  __Pyx_GOTREF(__pyx_t_1);
3254  __Pyx_INCREF(__pyx_n_s_ZMQError);
3255  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_ZMQError);
3256  __Pyx_GIVEREF(__pyx_n_s_ZMQError);
3257  __pyx_t_2 = __Pyx_Import(__pyx_n_s_zmq_error, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3258  __Pyx_GOTREF(__pyx_t_2);
3259  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3260  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3261  __Pyx_GOTREF(__pyx_t_1);
3262  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ZMQError, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3263  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3264  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3265
3266  /* "zmq/backend/cython/context.pyx":18
3267 *
3268 *
3269 * _instance = None             # <<<<<<<<<<<<<<
3270 *
3271 * cdef class Context:
3272 */
3273  if (PyDict_SetItem(__pyx_d, __pyx_n_s_instance, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3274
3275  /* "zmq/backend/cython/context.pyx":114
3276 *
3277 *     @property
3278 *     def underlying(self):             # <<<<<<<<<<<<<<
3279 *         """The address of the underlying libzmq context"""
3280 *         return <size_t> self.handle
3281 */
3282  __pyx_t_2 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_3zmq_7backend_6cython_7context_Context, __pyx_n_s_underlying); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3283  __Pyx_GOTREF(__pyx_t_2);
3284
3285  /* "zmq/backend/cython/context.pyx":113
3286 *
3287 *
3288 *     @property             # <<<<<<<<<<<<<<
3289 *     def underlying(self):
3290 *         """The address of the underlying libzmq context"""
3291 */
3292  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3293  __Pyx_GOTREF(__pyx_t_1);
3294  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
3295  __Pyx_GIVEREF(__pyx_t_2);
3296  __pyx_t_2 = 0;
3297  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_property, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3298  __Pyx_GOTREF(__pyx_t_2);
3299  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3300  if (PyDict_SetItem((PyObject *)__pyx_ptype_3zmq_7backend_6cython_7context_Context->tp_dict, __pyx_n_s_underlying, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3301  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3302  PyType_Modified(__pyx_ptype_3zmq_7backend_6cython_7context_Context);
3303
3304  /* "zmq/backend/cython/context.pyx":119
3305 *
3306 *     # backward-compat, though nobody is using it
3307 *     _handle = underlying             # <<<<<<<<<<<<<<
3308 *
3309 *     cdef inline int _term(self):
3310 */
3311  __pyx_t_2 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_3zmq_7backend_6cython_7context_Context, __pyx_n_s_underlying); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3312  __Pyx_GOTREF(__pyx_t_2);
3313  if (PyDict_SetItem((PyObject *)__pyx_ptype_3zmq_7backend_6cython_7context_Context->tp_dict, __pyx_n_s_handle, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3314  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3315  PyType_Modified(__pyx_ptype_3zmq_7backend_6cython_7context_Context);
3316
3317  /* "zmq/backend/cython/context.pyx":243
3318 *         self.term()
3319 *
3320 * __all__ = ['Context']             # <<<<<<<<<<<<<<
3321 */
3322  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3323  __Pyx_GOTREF(__pyx_t_2);
3324  __Pyx_INCREF(__pyx_n_s_Context);
3325  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Context);
3326  __Pyx_GIVEREF(__pyx_n_s_Context);
3327  if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3328  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3329
3330  /* "zmq/backend/cython/context.pyx":1
3331 * """0MQ Context class."""             # <<<<<<<<<<<<<<
3332 * # coding: utf-8
3333 *
3334 */
3335  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3336  __Pyx_GOTREF(__pyx_t_2);
3337  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3338  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3339
3340  /* "zmq/backend/cython/checkrc.pxd":5
3341 * from libzmq cimport zmq_errno, ZMQ_ETERM
3342 *
3343 * cdef inline int _check_rc(int rc) except -1:             # <<<<<<<<<<<<<<
3344 *     """internal utility for checking zmq return condition
3345 *
3346 */
3347
3348  /*--- Wrapped vars code ---*/
3349
3350  goto __pyx_L0;
3351  __pyx_L1_error:;
3352  __Pyx_XDECREF(__pyx_t_1);
3353  __Pyx_XDECREF(__pyx_t_2);
3354  if (__pyx_m) {
3355    if (__pyx_d) {
3356      __Pyx_AddTraceback("init zmq.backend.cython.context", __pyx_clineno, __pyx_lineno, __pyx_filename);
3357    }
3358    Py_DECREF(__pyx_m); __pyx_m = 0;
3359  } else if (!PyErr_Occurred()) {
3360    PyErr_SetString(PyExc_ImportError, "init zmq.backend.cython.context");
3361  }
3362  __pyx_L0:;
3363  __Pyx_RefNannyFinishContext();
3364  #if PY_MAJOR_VERSION < 3
3365  return;
3366  #else
3367  return __pyx_m;
3368  #endif
3369}
3370
3371/* Runtime support code */
3372#if CYTHON_REFNANNY
3373static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
3374    PyObject *m = NULL, *p = NULL;
3375    void *r = NULL;
3376    m = PyImport_ImportModule((char *)modname);
3377    if (!m) goto end;
3378    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
3379    if (!p) goto end;
3380    r = PyLong_AsVoidPtr(p);
3381end:
3382    Py_XDECREF(p);
3383    Py_XDECREF(m);
3384    return (__Pyx_RefNannyAPIStruct *)r;
3385}
3386#endif
3387
3388static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
3389    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
3390    if (unlikely(!result)) {
3391        PyErr_Format(PyExc_NameError,
3392#if PY_MAJOR_VERSION >= 3
3393            "name '%U' is not defined", name);
3394#else
3395            "name '%.200s' is not defined", PyString_AS_STRING(name));
3396#endif
3397    }
3398    return result;
3399}
3400
3401static void __Pyx_RaiseDoubleKeywordsError(
3402    const char* func_name,
3403    PyObject* kw_name)
3404{
3405    PyErr_Format(PyExc_TypeError,
3406        #if PY_MAJOR_VERSION >= 3
3407        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
3408        #else
3409        "%s() got multiple values for keyword argument '%s'", func_name,
3410        PyString_AsString(kw_name));
3411        #endif
3412}
3413
3414static int __Pyx_ParseOptionalKeywords(
3415    PyObject *kwds,
3416    PyObject **argnames[],
3417    PyObject *kwds2,
3418    PyObject *values[],
3419    Py_ssize_t num_pos_args,
3420    const char* function_name)
3421{
3422    PyObject *key = 0, *value = 0;
3423    Py_ssize_t pos = 0;
3424    PyObject*** name;
3425    PyObject*** first_kw_arg = argnames + num_pos_args;
3426    while (PyDict_Next(kwds, &pos, &key, &value)) {
3427        name = first_kw_arg;
3428        while (*name && (**name != key)) name++;
3429        if (*name) {
3430            values[name-argnames] = value;
3431            continue;
3432        }
3433        name = first_kw_arg;
3434        #if PY_MAJOR_VERSION < 3
3435        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
3436            while (*name) {
3437                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
3438                        && _PyString_Eq(**name, key)) {
3439                    values[name-argnames] = value;
3440                    break;
3441                }
3442                name++;
3443            }
3444            if (*name) continue;
3445            else {
3446                PyObject*** argname = argnames;
3447                while (argname != first_kw_arg) {
3448                    if ((**argname == key) || (
3449                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
3450                             && _PyString_Eq(**argname, key))) {
3451                        goto arg_passed_twice;
3452                    }
3453                    argname++;
3454                }
3455            }
3456        } else
3457        #endif
3458        if (likely(PyUnicode_Check(key))) {
3459            while (*name) {
3460                int cmp = (**name == key) ? 0 :
3461                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
3462                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
3463                #endif
3464                    PyUnicode_Compare(**name, key);
3465                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
3466                if (cmp == 0) {
3467                    values[name-argnames] = value;
3468                    break;
3469                }
3470                name++;
3471            }
3472            if (*name) continue;
3473            else {
3474                PyObject*** argname = argnames;
3475                while (argname != first_kw_arg) {
3476                    int cmp = (**argname == key) ? 0 :
3477                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
3478                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
3479                    #endif
3480                        PyUnicode_Compare(**argname, key);
3481                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
3482                    if (cmp == 0) goto arg_passed_twice;
3483                    argname++;
3484                }
3485            }
3486        } else
3487            goto invalid_keyword_type;
3488        if (kwds2) {
3489            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
3490        } else {
3491            goto invalid_keyword;
3492        }
3493    }
3494    return 0;
3495arg_passed_twice:
3496    __Pyx_RaiseDoubleKeywordsError(function_name, key);
3497    goto bad;
3498invalid_keyword_type:
3499    PyErr_Format(PyExc_TypeError,
3500        "%.200s() keywords must be strings", function_name);
3501    goto bad;
3502invalid_keyword:
3503    PyErr_Format(PyExc_TypeError,
3504    #if PY_MAJOR_VERSION < 3
3505        "%.200s() got an unexpected keyword argument '%.200s'",
3506        function_name, PyString_AsString(key));
3507    #else
3508        "%s() got an unexpected keyword argument '%U'",
3509        function_name, key);
3510    #endif
3511bad:
3512    return -1;
3513}
3514
3515static void __Pyx_RaiseArgtupleInvalid(
3516    const char* func_name,
3517    int exact,
3518    Py_ssize_t num_min,
3519    Py_ssize_t num_max,
3520    Py_ssize_t num_found)
3521{
3522    Py_ssize_t num_expected;
3523    const char *more_or_less;
3524    if (num_found < num_min) {
3525        num_expected = num_min;
3526        more_or_less = "at least";
3527    } else {
3528        num_expected = num_max;
3529        more_or_less = "at most";
3530    }
3531    if (exact) {
3532        more_or_less = "exactly";
3533    }
3534    PyErr_Format(PyExc_TypeError,
3535                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
3536                 func_name, more_or_less, num_expected,
3537                 (num_expected == 1) ? "" : "s", num_found);
3538}
3539
3540static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
3541    PyObject *result;
3542#if CYTHON_COMPILING_IN_CPYTHON
3543    result = PyDict_GetItem(__pyx_d, name);
3544    if (likely(result)) {
3545        Py_INCREF(result);
3546    } else {
3547#else
3548    result = PyObject_GetItem(__pyx_d, name);
3549    if (!result) {
3550        PyErr_Clear();
3551#endif
3552        result = __Pyx_GetBuiltinName(name);
3553    }
3554    return result;
3555}
3556
3557#if CYTHON_COMPILING_IN_CPYTHON
3558static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
3559    PyObject *result;
3560    ternaryfunc call = func->ob_type->tp_call;
3561    if (unlikely(!call))
3562        return PyObject_Call(func, arg, kw);
3563    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
3564        return NULL;
3565    result = (*call)(func, arg, kw);
3566    Py_LeaveRecursiveCall();
3567    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
3568        PyErr_SetString(
3569            PyExc_SystemError,
3570            "NULL result without error in PyObject_Call");
3571    }
3572    return result;
3573}
3574#endif
3575
3576#if CYTHON_COMPILING_IN_CPYTHON
3577static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
3578    PyObject *self, *result;
3579    PyCFunction cfunc;
3580    cfunc = PyCFunction_GET_FUNCTION(func);
3581    self = PyCFunction_GET_SELF(func);
3582    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
3583        return NULL;
3584    result = cfunc(self, arg);
3585    Py_LeaveRecursiveCall();
3586    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
3587        PyErr_SetString(
3588            PyExc_SystemError,
3589            "NULL result without error in PyObject_Call");
3590    }
3591    return result;
3592}
3593#endif
3594
3595#if CYTHON_COMPILING_IN_CPYTHON
3596static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3597    PyObject *result;
3598    PyObject *args = PyTuple_New(1);
3599    if (unlikely(!args)) return NULL;
3600    Py_INCREF(arg);
3601    PyTuple_SET_ITEM(args, 0, arg);
3602    result = __Pyx_PyObject_Call(func, args, NULL);
3603    Py_DECREF(args);
3604    return result;
3605}
3606static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3607#ifdef __Pyx_CyFunction_USED
3608    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
3609#else
3610    if (likely(PyCFunction_Check(func))) {
3611#endif
3612        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
3613            return __Pyx_PyObject_CallMethO(func, arg);
3614        }
3615    }
3616    return __Pyx__PyObject_CallOneArg(func, arg);
3617}
3618#else
3619static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
3620    PyObject* args = PyTuple_Pack(1, arg);
3621    return (likely(args)) ? __Pyx_PyObject_Call(func, args, NULL) : NULL;
3622}
3623#endif
3624
3625#if CYTHON_COMPILING_IN_CPYTHON
3626static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
3627#ifdef __Pyx_CyFunction_USED
3628    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
3629#else
3630    if (likely(PyCFunction_Check(func))) {
3631#endif
3632        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
3633            return __Pyx_PyObject_CallMethO(func, NULL);
3634        }
3635    }
3636    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
3637}
3638#endif
3639
3640static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
3641#if CYTHON_COMPILING_IN_CPYTHON
3642    PyObject *tmp_type, *tmp_value, *tmp_tb;
3643    PyThreadState *tstate = PyThreadState_GET();
3644    tmp_type = tstate->curexc_type;
3645    tmp_value = tstate->curexc_value;
3646    tmp_tb = tstate->curexc_traceback;
3647    tstate->curexc_type = type;
3648    tstate->curexc_value = value;
3649    tstate->curexc_traceback = tb;
3650    Py_XDECREF(tmp_type);
3651    Py_XDECREF(tmp_value);
3652    Py_XDECREF(tmp_tb);
3653#else
3654    PyErr_Restore(type, value, tb);
3655#endif
3656}
3657static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
3658#if CYTHON_COMPILING_IN_CPYTHON
3659    PyThreadState *tstate = PyThreadState_GET();
3660    *type = tstate->curexc_type;
3661    *value = tstate->curexc_value;
3662    *tb = tstate->curexc_traceback;
3663    tstate->curexc_type = 0;
3664    tstate->curexc_value = 0;
3665    tstate->curexc_traceback = 0;
3666#else
3667    PyErr_Fetch(type, value, tb);
3668#endif
3669}
3670
3671#if PY_MAJOR_VERSION < 3
3672static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
3673                        CYTHON_UNUSED PyObject *cause) {
3674    Py_XINCREF(type);
3675    if (!value || value == Py_None)
3676        value = NULL;
3677    else
3678        Py_INCREF(value);
3679    if (!tb || tb == Py_None)
3680        tb = NULL;
3681    else {
3682        Py_INCREF(tb);
3683        if (!PyTraceBack_Check(tb)) {
3684            PyErr_SetString(PyExc_TypeError,
3685                "raise: arg 3 must be a traceback or None");
3686            goto raise_error;
3687        }
3688    }
3689    if (PyType_Check(type)) {
3690#if CYTHON_COMPILING_IN_PYPY
3691        if (!value) {
3692            Py_INCREF(Py_None);
3693            value = Py_None;
3694        }
3695#endif
3696        PyErr_NormalizeException(&type, &value, &tb);
3697    } else {
3698        if (value) {
3699            PyErr_SetString(PyExc_TypeError,
3700                "instance exception may not have a separate value");
3701            goto raise_error;
3702        }
3703        value = type;
3704        type = (PyObject*) Py_TYPE(type);
3705        Py_INCREF(type);
3706        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
3707            PyErr_SetString(PyExc_TypeError,
3708                "raise: exception class must be a subclass of BaseException");
3709            goto raise_error;
3710        }
3711    }
3712    __Pyx_ErrRestore(type, value, tb);
3713    return;
3714raise_error:
3715    Py_XDECREF(value);
3716    Py_XDECREF(type);
3717    Py_XDECREF(tb);
3718    return;
3719}
3720#else
3721static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
3722    PyObject* owned_instance = NULL;
3723    if (tb == Py_None) {
3724        tb = 0;
3725    } else if (tb && !PyTraceBack_Check(tb)) {
3726        PyErr_SetString(PyExc_TypeError,
3727            "raise: arg 3 must be a traceback or None");
3728        goto bad;
3729    }
3730    if (value == Py_None)
3731        value = 0;
3732    if (PyExceptionInstance_Check(type)) {
3733        if (value) {
3734            PyErr_SetString(PyExc_TypeError,
3735                "instance exception may not have a separate value");
3736            goto bad;
3737        }
3738        value = type;
3739        type = (PyObject*) Py_TYPE(value);
3740    } else if (PyExceptionClass_Check(type)) {
3741        PyObject *instance_class = NULL;
3742        if (value && PyExceptionInstance_Check(value)) {
3743            instance_class = (PyObject*) Py_TYPE(value);
3744            if (instance_class != type) {
3745                if (PyObject_IsSubclass(instance_class, type)) {
3746                    type = instance_class;
3747                } else {
3748                    instance_class = NULL;
3749                }
3750            }
3751        }
3752        if (!instance_class) {
3753            PyObject *args;
3754            if (!value)
3755                args = PyTuple_New(0);
3756            else if (PyTuple_Check(value)) {
3757                Py_INCREF(value);
3758                args = value;
3759            } else
3760                args = PyTuple_Pack(1, value);
3761            if (!args)
3762                goto bad;
3763            owned_instance = PyObject_Call(type, args, NULL);
3764            Py_DECREF(args);
3765            if (!owned_instance)
3766                goto bad;
3767            value = owned_instance;
3768            if (!PyExceptionInstance_Check(value)) {
3769                PyErr_Format(PyExc_TypeError,
3770                             "calling %R should have returned an instance of "
3771                             "BaseException, not %R",
3772                             type, Py_TYPE(value));
3773                goto bad;
3774            }
3775        }
3776    } else {
3777        PyErr_SetString(PyExc_TypeError,
3778            "raise: exception class must be a subclass of BaseException");
3779        goto bad;
3780    }
3781#if PY_VERSION_HEX >= 0x03030000
3782    if (cause) {
3783#else
3784    if (cause && cause != Py_None) {
3785#endif
3786        PyObject *fixed_cause;
3787        if (cause == Py_None) {
3788            fixed_cause = NULL;
3789        } else if (PyExceptionClass_Check(cause)) {
3790            fixed_cause = PyObject_CallObject(cause, NULL);
3791            if (fixed_cause == NULL)
3792                goto bad;
3793        } else if (PyExceptionInstance_Check(cause)) {
3794            fixed_cause = cause;
3795            Py_INCREF(fixed_cause);
3796        } else {
3797            PyErr_SetString(PyExc_TypeError,
3798                            "exception causes must derive from "
3799                            "BaseException");
3800            goto bad;
3801        }
3802        PyException_SetCause(value, fixed_cause);
3803    }
3804    PyErr_SetObject(type, value);
3805    if (tb) {
3806#if CYTHON_COMPILING_IN_PYPY
3807        PyObject *tmp_type, *tmp_value, *tmp_tb;
3808        PyErr_Fetch(tmp_type, tmp_value, tmp_tb);
3809        Py_INCREF(tb);
3810        PyErr_Restore(tmp_type, tmp_value, tb);
3811        Py_XDECREF(tmp_tb);
3812#else
3813        PyThreadState *tstate = PyThreadState_GET();
3814        PyObject* tmp_tb = tstate->curexc_traceback;
3815        if (tb != tmp_tb) {
3816            Py_INCREF(tb);
3817            tstate->curexc_traceback = tb;
3818            Py_XDECREF(tmp_tb);
3819        }
3820#endif
3821    }
3822bad:
3823    Py_XDECREF(owned_instance);
3824    return;
3825}
3826#endif
3827
3828static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
3829                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
3830                                  int full_traceback) {
3831    PyObject *old_exc, *old_val, *old_tb;
3832    PyObject *ctx;
3833    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
3834    if (full_traceback) {
3835        Py_XINCREF(old_exc);
3836        Py_XINCREF(old_val);
3837        Py_XINCREF(old_tb);
3838        __Pyx_ErrRestore(old_exc, old_val, old_tb);
3839        PyErr_PrintEx(1);
3840    }
3841    #if PY_MAJOR_VERSION < 3
3842    ctx = PyString_FromString(name);
3843    #else
3844    ctx = PyUnicode_FromString(name);
3845    #endif
3846    __Pyx_ErrRestore(old_exc, old_val, old_tb);
3847    if (!ctx) {
3848        PyErr_WriteUnraisable(Py_None);
3849    } else {
3850        PyErr_WriteUnraisable(ctx);
3851        Py_DECREF(ctx);
3852    }
3853}
3854
3855static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
3856    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
3857    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
3858        PyErr_Format(PyExc_ImportError,
3859        #if PY_MAJOR_VERSION < 3
3860            "cannot import name %.230s", PyString_AS_STRING(name));
3861        #else
3862            "cannot import name %S", name);
3863        #endif
3864    }
3865    return value;
3866}
3867
3868static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
3869#if PY_VERSION_HEX >= 0x02070000
3870    PyObject *ob = PyCapsule_New(vtable, 0, 0);
3871#else
3872    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
3873#endif
3874    if (!ob)
3875        goto bad;
3876    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
3877        goto bad;
3878    Py_DECREF(ob);
3879    return 0;
3880bad:
3881    Py_XDECREF(ob);
3882    return -1;
3883}
3884
3885static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
3886    PyObject *result;
3887    result = __Pyx_PyObject_GetAttrStr(nmspace, name);
3888    if (!result)
3889        result = __Pyx_GetModuleGlobalName(name);
3890    return result;
3891}
3892
3893static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
3894    int start = 0, mid = 0, end = count - 1;
3895    if (end >= 0 && code_line > entries[end].code_line) {
3896        return count;
3897    }
3898    while (start < end) {
3899        mid = (start + end) / 2;
3900        if (code_line < entries[mid].code_line) {
3901            end = mid;
3902        } else if (code_line > entries[mid].code_line) {
3903             start = mid + 1;
3904        } else {
3905            return mid;
3906        }
3907    }
3908    if (code_line <= entries[mid].code_line) {
3909        return mid;
3910    } else {
3911        return mid + 1;
3912    }
3913}
3914static PyCodeObject *__pyx_find_code_object(int code_line) {
3915    PyCodeObject* code_object;
3916    int pos;
3917    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
3918        return NULL;
3919    }
3920    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3921    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
3922        return NULL;
3923    }
3924    code_object = __pyx_code_cache.entries[pos].code_object;
3925    Py_INCREF(code_object);
3926    return code_object;
3927}
3928static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
3929    int pos, i;
3930    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
3931    if (unlikely(!code_line)) {
3932        return;
3933    }
3934    if (unlikely(!entries)) {
3935        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
3936        if (likely(entries)) {
3937            __pyx_code_cache.entries = entries;
3938            __pyx_code_cache.max_count = 64;
3939            __pyx_code_cache.count = 1;
3940            entries[0].code_line = code_line;
3941            entries[0].code_object = code_object;
3942            Py_INCREF(code_object);
3943        }
3944        return;
3945    }
3946    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3947    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
3948        PyCodeObject* tmp = entries[pos].code_object;
3949        entries[pos].code_object = code_object;
3950        Py_DECREF(tmp);
3951        return;
3952    }
3953    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
3954        int new_max = __pyx_code_cache.max_count + 64;
3955        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
3956            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
3957        if (unlikely(!entries)) {
3958            return;
3959        }
3960        __pyx_code_cache.entries = entries;
3961        __pyx_code_cache.max_count = new_max;
3962    }
3963    for (i=__pyx_code_cache.count; i>pos; i--) {
3964        entries[i] = entries[i-1];
3965    }
3966    entries[pos].code_line = code_line;
3967    entries[pos].code_object = code_object;
3968    __pyx_code_cache.count++;
3969    Py_INCREF(code_object);
3970}
3971
3972#include "compile.h"
3973#include "frameobject.h"
3974#include "traceback.h"
3975static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
3976            const char *funcname, int c_line,
3977            int py_line, const char *filename) {
3978    PyCodeObject *py_code = 0;
3979    PyObject *py_srcfile = 0;
3980    PyObject *py_funcname = 0;
3981    #if PY_MAJOR_VERSION < 3
3982    py_srcfile = PyString_FromString(filename);
3983    #else
3984    py_srcfile = PyUnicode_FromString(filename);
3985    #endif
3986    if (!py_srcfile) goto bad;
3987    if (c_line) {
3988        #if PY_MAJOR_VERSION < 3
3989        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3990        #else
3991        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3992        #endif
3993    }
3994    else {
3995        #if PY_MAJOR_VERSION < 3
3996        py_funcname = PyString_FromString(funcname);
3997        #else
3998        py_funcname = PyUnicode_FromString(funcname);
3999        #endif
4000    }
4001    if (!py_funcname) goto bad;
4002    py_code = __Pyx_PyCode_New(
4003        0,
4004        0,
4005        0,
4006        0,
4007        0,
4008        __pyx_empty_bytes, /*PyObject *code,*/
4009        __pyx_empty_tuple, /*PyObject *consts,*/
4010        __pyx_empty_tuple, /*PyObject *names,*/
4011        __pyx_empty_tuple, /*PyObject *varnames,*/
4012        __pyx_empty_tuple, /*PyObject *freevars,*/
4013        __pyx_empty_tuple, /*PyObject *cellvars,*/
4014        py_srcfile,   /*PyObject *filename,*/
4015        py_funcname,  /*PyObject *name,*/
4016        py_line,
4017        __pyx_empty_bytes  /*PyObject *lnotab*/
4018    );
4019    Py_DECREF(py_srcfile);
4020    Py_DECREF(py_funcname);
4021    return py_code;
4022bad:
4023    Py_XDECREF(py_srcfile);
4024    Py_XDECREF(py_funcname);
4025    return NULL;
4026}
4027static void __Pyx_AddTraceback(const char *funcname, int c_line,
4028                               int py_line, const char *filename) {
4029    PyCodeObject *py_code = 0;
4030    PyFrameObject *py_frame = 0;
4031    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
4032    if (!py_code) {
4033        py_code = __Pyx_CreateCodeObjectForTraceback(
4034            funcname, c_line, py_line, filename);
4035        if (!py_code) goto bad;
4036        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
4037    }
4038    py_frame = PyFrame_New(
4039        PyThreadState_GET(), /*PyThreadState *tstate,*/
4040        py_code,             /*PyCodeObject *code,*/
4041        __pyx_d,      /*PyObject *globals,*/
4042        0                    /*PyObject *locals*/
4043    );
4044    if (!py_frame) goto bad;
4045    py_frame->f_lineno = py_line;
4046    PyTraceBack_Here(py_frame);
4047bad:
4048    Py_XDECREF(py_code);
4049    Py_XDECREF(py_frame);
4050}
4051
4052static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
4053    PyObject *empty_list = 0;
4054    PyObject *module = 0;
4055    PyObject *global_dict = 0;
4056    PyObject *empty_dict = 0;
4057    PyObject *list;
4058    #if PY_VERSION_HEX < 0x03030000
4059    PyObject *py_import;
4060    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
4061    if (!py_import)
4062        goto bad;
4063    #endif
4064    if (from_list)
4065        list = from_list;
4066    else {
4067        empty_list = PyList_New(0);
4068        if (!empty_list)
4069            goto bad;
4070        list = empty_list;
4071    }
4072    global_dict = PyModule_GetDict(__pyx_m);
4073    if (!global_dict)
4074        goto bad;
4075    empty_dict = PyDict_New();
4076    if (!empty_dict)
4077        goto bad;
4078    {
4079        #if PY_MAJOR_VERSION >= 3
4080        if (level == -1) {
4081            if (strchr(__Pyx_MODULE_NAME, '.')) {
4082                #if PY_VERSION_HEX < 0x03030000
4083                PyObject *py_level = PyInt_FromLong(1);
4084                if (!py_level)
4085                    goto bad;
4086                module = PyObject_CallFunctionObjArgs(py_import,
4087                    name, global_dict, empty_dict, list, py_level, NULL);
4088                Py_DECREF(py_level);
4089                #else
4090                module = PyImport_ImportModuleLevelObject(
4091                    name, global_dict, empty_dict, list, 1);
4092                #endif
4093                if (!module) {
4094                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
4095                        goto bad;
4096                    PyErr_Clear();
4097                }
4098            }
4099            level = 0;
4100        }
4101        #endif
4102        if (!module) {
4103            #if PY_VERSION_HEX < 0x03030000
4104            PyObject *py_level = PyInt_FromLong(level);
4105            if (!py_level)
4106                goto bad;
4107            module = PyObject_CallFunctionObjArgs(py_import,
4108                name, global_dict, empty_dict, list, py_level, NULL);
4109            Py_DECREF(py_level);
4110            #else
4111            module = PyImport_ImportModuleLevelObject(
4112                name, global_dict, empty_dict, list, level);
4113            #endif
4114        }
4115    }
4116bad:
4117    #if PY_VERSION_HEX < 0x03030000
4118    Py_XDECREF(py_import);
4119    #endif
4120    Py_XDECREF(empty_list);
4121    Py_XDECREF(empty_dict);
4122    return module;
4123}
4124
4125#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)       \
4126    {                                                                     \
4127        func_type value = func_value;                                     \
4128        if (sizeof(target_type) < sizeof(func_type)) {                    \
4129            if (unlikely(value != (func_type) (target_type) value)) {     \
4130                func_type zero = 0;                                       \
4131                if (is_unsigned && unlikely(value < zero))                \
4132                    goto raise_neg_overflow;                              \
4133                else                                                      \
4134                    goto raise_overflow;                                  \
4135            }                                                             \
4136        }                                                                 \
4137        return (target_type) value;                                       \
4138    }
4139
4140#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
4141 #if CYTHON_USE_PYLONG_INTERNALS
4142  #include "longintrepr.h"
4143 #endif
4144#endif
4145
4146static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
4147    const int neg_one = (int) -1, const_zero = 0;
4148    const int is_unsigned = neg_one > const_zero;
4149#if PY_MAJOR_VERSION < 3
4150    if (likely(PyInt_Check(x))) {
4151        if (sizeof(int) < sizeof(long)) {
4152            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
4153        } else {
4154            long val = PyInt_AS_LONG(x);
4155            if (is_unsigned && unlikely(val < 0)) {
4156                goto raise_neg_overflow;
4157            }
4158            return (int) val;
4159        }
4160    } else
4161#endif
4162    if (likely(PyLong_Check(x))) {
4163        if (is_unsigned) {
4164#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
4165 #if CYTHON_USE_PYLONG_INTERNALS
4166            switch (Py_SIZE(x)) {
4167                case  0: return 0;
4168                case  1: __PYX_VERIFY_RETURN_INT(int, digit, ((PyLongObject*)x)->ob_digit[0]);
4169            }
4170 #endif
4171#endif
4172            if (unlikely(Py_SIZE(x) < 0)) {
4173                goto raise_neg_overflow;
4174            }
4175            if (sizeof(int) <= sizeof(unsigned long)) {
4176                __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong(x))
4177            } else if (sizeof(int) <= sizeof(unsigned long long)) {
4178                __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong(x))
4179            }
4180        } else {
4181#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
4182 #if CYTHON_USE_PYLONG_INTERNALS
4183            switch (Py_SIZE(x)) {
4184                case  0: return 0;
4185                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +(((PyLongObject*)x)->ob_digit[0]));
4186                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
4187            }
4188 #endif
4189#endif
4190            if (sizeof(int) <= sizeof(long)) {
4191                __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong(x))
4192            } else if (sizeof(int) <= sizeof(long long)) {
4193                __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong(x))
4194            }
4195        }
4196        {
4197#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4198            PyErr_SetString(PyExc_RuntimeError,
4199                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4200#else
4201            int val;
4202            PyObject *v = __Pyx_PyNumber_Int(x);
4203 #if PY_MAJOR_VERSION < 3
4204            if (likely(v) && !PyLong_Check(v)) {
4205                PyObject *tmp = v;
4206                v = PyNumber_Long(tmp);
4207                Py_DECREF(tmp);
4208            }
4209 #endif
4210            if (likely(v)) {
4211                int one = 1; int is_little = (int)*(unsigned char *)&one;
4212                unsigned char *bytes = (unsigned char *)&val;
4213                int ret = _PyLong_AsByteArray((PyLongObject *)v,
4214                                              bytes, sizeof(val),
4215                                              is_little, !is_unsigned);
4216                Py_DECREF(v);
4217                if (likely(!ret))
4218                    return val;
4219            }
4220#endif
4221            return (int) -1;
4222        }
4223    } else {
4224        int val;
4225        PyObject *tmp = __Pyx_PyNumber_Int(x);
4226        if (!tmp) return (int) -1;
4227        val = __Pyx_PyInt_As_int(tmp);
4228        Py_DECREF(tmp);
4229        return val;
4230    }
4231raise_overflow:
4232    PyErr_SetString(PyExc_OverflowError,
4233        "value too large to convert to int");
4234    return (int) -1;
4235raise_neg_overflow:
4236    PyErr_SetString(PyExc_OverflowError,
4237        "can't convert negative value to int");
4238    return (int) -1;
4239}
4240
4241static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
4242    const size_t neg_one = (size_t) -1, const_zero = 0;
4243    const int is_unsigned = neg_one > const_zero;
4244#if PY_MAJOR_VERSION < 3
4245    if (likely(PyInt_Check(x))) {
4246        if (sizeof(size_t) < sizeof(long)) {
4247            __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
4248        } else {
4249            long val = PyInt_AS_LONG(x);
4250            if (is_unsigned && unlikely(val < 0)) {
4251                goto raise_neg_overflow;
4252            }
4253            return (size_t) val;
4254        }
4255    } else
4256#endif
4257    if (likely(PyLong_Check(x))) {
4258        if (is_unsigned) {
4259#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
4260 #if CYTHON_USE_PYLONG_INTERNALS
4261            switch (Py_SIZE(x)) {
4262                case  0: return 0;
4263                case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, ((PyLongObject*)x)->ob_digit[0]);
4264            }
4265 #endif
4266#endif
4267            if (unlikely(Py_SIZE(x) < 0)) {
4268                goto raise_neg_overflow;
4269            }
4270            if (sizeof(size_t) <= sizeof(unsigned long)) {
4271                __PYX_VERIFY_RETURN_INT(size_t, unsigned long, PyLong_AsUnsignedLong(x))
4272            } else if (sizeof(size_t) <= sizeof(unsigned long long)) {
4273                __PYX_VERIFY_RETURN_INT(size_t, unsigned long long, PyLong_AsUnsignedLongLong(x))
4274            }
4275        } else {
4276#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
4277 #if CYTHON_USE_PYLONG_INTERNALS
4278            switch (Py_SIZE(x)) {
4279                case  0: return 0;
4280                case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +(((PyLongObject*)x)->ob_digit[0]));
4281                case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
4282            }
4283 #endif
4284#endif
4285            if (sizeof(size_t) <= sizeof(long)) {
4286                __PYX_VERIFY_RETURN_INT(size_t, long, PyLong_AsLong(x))
4287            } else if (sizeof(size_t) <= sizeof(long long)) {
4288                __PYX_VERIFY_RETURN_INT(size_t, long long, PyLong_AsLongLong(x))
4289            }
4290        }
4291        {
4292#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4293            PyErr_SetString(PyExc_RuntimeError,
4294                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4295#else
4296            size_t val;
4297            PyObject *v = __Pyx_PyNumber_Int(x);
4298 #if PY_MAJOR_VERSION < 3
4299            if (likely(v) && !PyLong_Check(v)) {
4300                PyObject *tmp = v;
4301                v = PyNumber_Long(tmp);
4302                Py_DECREF(tmp);
4303            }
4304 #endif
4305            if (likely(v)) {
4306                int one = 1; int is_little = (int)*(unsigned char *)&one;
4307                unsigned char *bytes = (unsigned char *)&val;
4308                int ret = _PyLong_AsByteArray((PyLongObject *)v,
4309                                              bytes, sizeof(val),
4310                                              is_little, !is_unsigned);
4311                Py_DECREF(v);
4312                if (likely(!ret))
4313                    return val;
4314            }
4315#endif
4316            return (size_t) -1;
4317        }
4318    } else {
4319        size_t val;
4320        PyObject *tmp = __Pyx_PyNumber_Int(x);
4321        if (!tmp) return (size_t) -1;
4322        val = __Pyx_PyInt_As_size_t(tmp);
4323        Py_DECREF(tmp);
4324        return val;
4325    }
4326raise_overflow:
4327    PyErr_SetString(PyExc_OverflowError,
4328        "value too large to convert to size_t");
4329    return (size_t) -1;
4330raise_neg_overflow:
4331    PyErr_SetString(PyExc_OverflowError,
4332        "can't convert negative value to size_t");
4333    return (size_t) -1;
4334}
4335
4336static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
4337    const int neg_one = (int) -1, const_zero = 0;
4338    const int is_unsigned = neg_one > const_zero;
4339    if (is_unsigned) {
4340        if (sizeof(int) < sizeof(long)) {
4341            return PyInt_FromLong((long) value);
4342        } else if (sizeof(int) <= sizeof(unsigned long)) {
4343            return PyLong_FromUnsignedLong((unsigned long) value);
4344        } else if (sizeof(int) <= sizeof(unsigned long long)) {
4345            return PyLong_FromUnsignedLongLong((unsigned long long) value);
4346        }
4347    } else {
4348        if (sizeof(int) <= sizeof(long)) {
4349            return PyInt_FromLong((long) value);
4350        } else if (sizeof(int) <= sizeof(long long)) {
4351            return PyLong_FromLongLong((long long) value);
4352        }
4353    }
4354    {
4355        int one = 1; int little = (int)*(unsigned char *)&one;
4356        unsigned char *bytes = (unsigned char *)&value;
4357        return _PyLong_FromByteArray(bytes, sizeof(int),
4358                                     little, !is_unsigned);
4359    }
4360}
4361
4362static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
4363    const long neg_one = (long) -1, const_zero = 0;
4364    const int is_unsigned = neg_one > const_zero;
4365    if (is_unsigned) {
4366        if (sizeof(long) < sizeof(long)) {
4367            return PyInt_FromLong((long) value);
4368        } else if (sizeof(long) <= sizeof(unsigned long)) {
4369            return PyLong_FromUnsignedLong((unsigned long) value);
4370        } else if (sizeof(long) <= sizeof(unsigned long long)) {
4371            return PyLong_FromUnsignedLongLong((unsigned long long) value);
4372        }
4373    } else {
4374        if (sizeof(long) <= sizeof(long)) {
4375            return PyInt_FromLong((long) value);
4376        } else if (sizeof(long) <= sizeof(long long)) {
4377            return PyLong_FromLongLong((long long) value);
4378        }
4379    }
4380    {
4381        int one = 1; int little = (int)*(unsigned char *)&one;
4382        unsigned char *bytes = (unsigned char *)&value;
4383        return _PyLong_FromByteArray(bytes, sizeof(long),
4384                                     little, !is_unsigned);
4385    }
4386}
4387
4388static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
4389    const long neg_one = (long) -1, const_zero = 0;
4390    const int is_unsigned = neg_one > const_zero;
4391#if PY_MAJOR_VERSION < 3
4392    if (likely(PyInt_Check(x))) {
4393        if (sizeof(long) < sizeof(long)) {
4394            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
4395        } else {
4396            long val = PyInt_AS_LONG(x);
4397            if (is_unsigned && unlikely(val < 0)) {
4398                goto raise_neg_overflow;
4399            }
4400            return (long) val;
4401        }
4402    } else
4403#endif
4404    if (likely(PyLong_Check(x))) {
4405        if (is_unsigned) {
4406#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
4407 #if CYTHON_USE_PYLONG_INTERNALS
4408            switch (Py_SIZE(x)) {
4409                case  0: return 0;
4410                case  1: __PYX_VERIFY_RETURN_INT(long, digit, ((PyLongObject*)x)->ob_digit[0]);
4411            }
4412 #endif
4413#endif
4414            if (unlikely(Py_SIZE(x) < 0)) {
4415                goto raise_neg_overflow;
4416            }
4417            if (sizeof(long) <= sizeof(unsigned long)) {
4418                __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong(x))
4419            } else if (sizeof(long) <= sizeof(unsigned long long)) {
4420                __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong(x))
4421            }
4422        } else {
4423#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
4424 #if CYTHON_USE_PYLONG_INTERNALS
4425            switch (Py_SIZE(x)) {
4426                case  0: return 0;
4427                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +(((PyLongObject*)x)->ob_digit[0]));
4428                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
4429            }
4430 #endif
4431#endif
4432            if (sizeof(long) <= sizeof(long)) {
4433                __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong(x))
4434            } else if (sizeof(long) <= sizeof(long long)) {
4435                __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong(x))
4436            }
4437        }
4438        {
4439#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
4440            PyErr_SetString(PyExc_RuntimeError,
4441                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
4442#else
4443            long val;
4444            PyObject *v = __Pyx_PyNumber_Int(x);
4445 #if PY_MAJOR_VERSION < 3
4446            if (likely(v) && !PyLong_Check(v)) {
4447                PyObject *tmp = v;
4448                v = PyNumber_Long(tmp);
4449                Py_DECREF(tmp);
4450            }
4451 #endif
4452            if (likely(v)) {
4453                int one = 1; int is_little = (int)*(unsigned char *)&one;
4454                unsigned char *bytes = (unsigned char *)&val;
4455                int ret = _PyLong_AsByteArray((PyLongObject *)v,
4456                                              bytes, sizeof(val),
4457                                              is_little, !is_unsigned);
4458                Py_DECREF(v);
4459                if (likely(!ret))
4460                    return val;
4461            }
4462#endif
4463            return (long) -1;
4464        }
4465    } else {
4466        long val;
4467        PyObject *tmp = __Pyx_PyNumber_Int(x);
4468        if (!tmp) return (long) -1;
4469        val = __Pyx_PyInt_As_long(tmp);
4470        Py_DECREF(tmp);
4471        return val;
4472    }
4473raise_overflow:
4474    PyErr_SetString(PyExc_OverflowError,
4475        "value too large to convert to long");
4476    return (long) -1;
4477raise_neg_overflow:
4478    PyErr_SetString(PyExc_OverflowError,
4479        "can't convert negative value to long");
4480    return (long) -1;
4481}
4482
4483static int __Pyx_check_binary_version(void) {
4484    char ctversion[4], rtversion[4];
4485    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
4486    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
4487    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
4488        char message[200];
4489        PyOS_snprintf(message, sizeof(message),
4490                      "compiletime version %s of module '%.100s' "
4491                      "does not match runtime version %s",
4492                      ctversion, __Pyx_MODULE_NAME, rtversion);
4493        return PyErr_WarnEx(NULL, message, 1);
4494    }
4495    return 0;
4496}
4497
4498#ifndef __PYX_HAVE_RT_ImportModule
4499#define __PYX_HAVE_RT_ImportModule
4500static PyObject *__Pyx_ImportModule(const char *name) {
4501    PyObject *py_name = 0;
4502    PyObject *py_module = 0;
4503    py_name = __Pyx_PyIdentifier_FromString(name);
4504    if (!py_name)
4505        goto bad;
4506    py_module = PyImport_Import(py_name);
4507    Py_DECREF(py_name);
4508    return py_module;
4509bad:
4510    Py_XDECREF(py_name);
4511    return 0;
4512}
4513#endif
4514
4515#ifndef __PYX_HAVE_RT_ImportType
4516#define __PYX_HAVE_RT_ImportType
4517static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
4518    size_t size, int strict)
4519{
4520    PyObject *py_module = 0;
4521    PyObject *result = 0;
4522    PyObject *py_name = 0;
4523    char warning[200];
4524    Py_ssize_t basicsize;
4525#ifdef Py_LIMITED_API
4526    PyObject *py_basicsize;
4527#endif
4528    py_module = __Pyx_ImportModule(module_name);
4529    if (!py_module)
4530        goto bad;
4531    py_name = __Pyx_PyIdentifier_FromString(class_name);
4532    if (!py_name)
4533        goto bad;
4534    result = PyObject_GetAttr(py_module, py_name);
4535    Py_DECREF(py_name);
4536    py_name = 0;
4537    Py_DECREF(py_module);
4538    py_module = 0;
4539    if (!result)
4540        goto bad;
4541    if (!PyType_Check(result)) {
4542        PyErr_Format(PyExc_TypeError,
4543            "%.200s.%.200s is not a type object",
4544            module_name, class_name);
4545        goto bad;
4546    }
4547#ifndef Py_LIMITED_API
4548    basicsize = ((PyTypeObject *)result)->tp_basicsize;
4549#else
4550    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
4551    if (!py_basicsize)
4552        goto bad;
4553    basicsize = PyLong_AsSsize_t(py_basicsize);
4554    Py_DECREF(py_basicsize);
4555    py_basicsize = 0;
4556    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
4557        goto bad;
4558#endif
4559    if (!strict && (size_t)basicsize > size) {
4560        PyOS_snprintf(warning, sizeof(warning),
4561            "%s.%s size changed, may indicate binary incompatibility",
4562            module_name, class_name);
4563        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
4564    }
4565    else if ((size_t)basicsize != size) {
4566        PyErr_Format(PyExc_ValueError,
4567            "%.200s.%.200s has the wrong size, try recompiling",
4568            module_name, class_name);
4569        goto bad;
4570    }
4571    return (PyTypeObject *)result;
4572bad:
4573    Py_XDECREF(py_module);
4574    Py_XDECREF(result);
4575    return NULL;
4576}
4577#endif
4578
4579static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
4580    while (t->p) {
4581        #if PY_MAJOR_VERSION < 3
4582        if (t->is_unicode) {
4583            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
4584        } else if (t->intern) {
4585            *t->p = PyString_InternFromString(t->s);
4586        } else {
4587            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
4588        }
4589        #else
4590        if (t->is_unicode | t->is_str) {
4591            if (t->intern) {
4592                *t->p = PyUnicode_InternFromString(t->s);
4593            } else if (t->encoding) {
4594                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
4595            } else {
4596                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
4597            }
4598        } else {
4599            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
4600        }
4601        #endif
4602        if (!*t->p)
4603            return -1;
4604        ++t;
4605    }
4606    return 0;
4607}
4608
4609static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
4610    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
4611}
4612static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
4613    Py_ssize_t ignore;
4614    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
4615}
4616static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
4617#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
4618    if (
4619#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
4620            __Pyx_sys_getdefaultencoding_not_ascii &&
4621#endif
4622            PyUnicode_Check(o)) {
4623#if PY_VERSION_HEX < 0x03030000
4624        char* defenc_c;
4625        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
4626        if (!defenc) return NULL;
4627        defenc_c = PyBytes_AS_STRING(defenc);
4628#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
4629        {
4630            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
4631            char* c;
4632            for (c = defenc_c; c < end; c++) {
4633                if ((unsigned char) (*c) >= 128) {
4634                    PyUnicode_AsASCIIString(o);
4635                    return NULL;
4636                }
4637            }
4638        }
4639#endif
4640        *length = PyBytes_GET_SIZE(defenc);
4641        return defenc_c;
4642#else
4643        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
4644#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
4645        if (PyUnicode_IS_ASCII(o)) {
4646            *length = PyUnicode_GET_LENGTH(o);
4647            return PyUnicode_AsUTF8(o);
4648        } else {
4649            PyUnicode_AsASCIIString(o);
4650            return NULL;
4651        }
4652#else
4653        return PyUnicode_AsUTF8AndSize(o, length);
4654#endif
4655#endif
4656    } else
4657#endif
4658#if !CYTHON_COMPILING_IN_PYPY
4659    if (PyByteArray_Check(o)) {
4660        *length = PyByteArray_GET_SIZE(o);
4661        return PyByteArray_AS_STRING(o);
4662    } else
4663#endif
4664    {
4665        char* result;
4666        int r = PyBytes_AsStringAndSize(o, &result, length);
4667        if (unlikely(r < 0)) {
4668            return NULL;
4669        } else {
4670            return result;
4671        }
4672    }
4673}
4674static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
4675   int is_true = x == Py_True;
4676   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
4677   else return PyObject_IsTrue(x);
4678}
4679static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
4680  PyNumberMethods *m;
4681  const char *name = NULL;
4682  PyObject *res = NULL;
4683#if PY_MAJOR_VERSION < 3
4684  if (PyInt_Check(x) || PyLong_Check(x))
4685#else
4686  if (PyLong_Check(x))
4687#endif
4688    return Py_INCREF(x), x;
4689  m = Py_TYPE(x)->tp_as_number;
4690#if PY_MAJOR_VERSION < 3
4691  if (m && m->nb_int) {
4692    name = "int";
4693    res = PyNumber_Int(x);
4694  }
4695  else if (m && m->nb_long) {
4696    name = "long";
4697    res = PyNumber_Long(x);
4698  }
4699#else
4700  if (m && m->nb_int) {
4701    name = "int";
4702    res = PyNumber_Long(x);
4703  }
4704#endif
4705  if (res) {
4706#if PY_MAJOR_VERSION < 3
4707    if (!PyInt_Check(res) && !PyLong_Check(res)) {
4708#else
4709    if (!PyLong_Check(res)) {
4710#endif
4711      PyErr_Format(PyExc_TypeError,
4712                   "__%.4s__ returned non-%.4s (type %.200s)",
4713                   name, name, Py_TYPE(res)->tp_name);
4714      Py_DECREF(res);
4715      return NULL;
4716    }
4717  }
4718  else if (!PyErr_Occurred()) {
4719    PyErr_SetString(PyExc_TypeError,
4720                    "an integer is required");
4721  }
4722  return res;
4723}
4724static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
4725  Py_ssize_t ival;
4726  PyObject *x;
4727#if PY_MAJOR_VERSION < 3
4728  if (likely(PyInt_CheckExact(b)))
4729      return PyInt_AS_LONG(b);
4730#endif
4731  if (likely(PyLong_CheckExact(b))) {
4732    #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
4733     #if CYTHON_USE_PYLONG_INTERNALS
4734       switch (Py_SIZE(b)) {
4735       case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
4736       case  0: return 0;
4737       case  1: return ((PyLongObject*)b)->ob_digit[0];
4738       }
4739     #endif
4740    #endif
4741    return PyLong_AsSsize_t(b);
4742  }
4743  x = PyNumber_Index(b);
4744  if (!x) return -1;
4745  ival = PyInt_AsSsize_t(x);
4746  Py_DECREF(x);
4747  return ival;
4748}
4749static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
4750    return PyInt_FromSize_t(ival);
4751}
4752
4753
4754#endif /* Py_PYTHON_H */
4755