PageRenderTime 60ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 2ms

/zmq/core/socket.c

https://bitbucket.org/markotibold/pyzmq-static
C | 10425 lines | 7026 code | 728 blank | 2671 comment | 1314 complexity | 979cc623d9830e0766d3d536ba0449be MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0
  1. /* Generated by Cython 0.14.1 on Fri May 13 15:49:46 2011 */
  2. #define PY_SSIZE_T_CLEAN
  3. #include "Python.h"
  4. #ifndef Py_PYTHON_H
  5. #error Python headers needed to compile C extensions, please install development version of Python.
  6. #else
  7. #include <stddef.h> /* For offsetof */
  8. #ifndef offsetof
  9. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  10. #endif
  11. #if !defined(WIN32) && !defined(MS_WINDOWS)
  12. #ifndef __stdcall
  13. #define __stdcall
  14. #endif
  15. #ifndef __cdecl
  16. #define __cdecl
  17. #endif
  18. #ifndef __fastcall
  19. #define __fastcall
  20. #endif
  21. #endif
  22. #ifndef DL_IMPORT
  23. #define DL_IMPORT(t) t
  24. #endif
  25. #ifndef DL_EXPORT
  26. #define DL_EXPORT(t) t
  27. #endif
  28. #ifndef PY_LONG_LONG
  29. #define PY_LONG_LONG LONG_LONG
  30. #endif
  31. #if PY_VERSION_HEX < 0x02040000
  32. #define METH_COEXIST 0
  33. #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  34. #define PyDict_Contains(d,o) PySequence_Contains(d,o)
  35. #endif
  36. #if PY_VERSION_HEX < 0x02050000
  37. typedef int Py_ssize_t;
  38. #define PY_SSIZE_T_MAX INT_MAX
  39. #define PY_SSIZE_T_MIN INT_MIN
  40. #define PY_FORMAT_SIZE_T ""
  41. #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  42. #define PyInt_AsSsize_t(o) PyInt_AsLong(o)
  43. #define PyNumber_Index(o) PyNumber_Int(o)
  44. #define PyIndex_Check(o) PyNumber_Check(o)
  45. #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  46. #endif
  47. #if PY_VERSION_HEX < 0x02060000
  48. #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  49. #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
  50. #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
  51. #define PyVarObject_HEAD_INIT(type, size) \
  52. PyObject_HEAD_INIT(type) size,
  53. #define PyType_Modified(t)
  54. typedef struct {
  55. void *buf;
  56. PyObject *obj;
  57. Py_ssize_t len;
  58. Py_ssize_t itemsize;
  59. int readonly;
  60. int ndim;
  61. char *format;
  62. Py_ssize_t *shape;
  63. Py_ssize_t *strides;
  64. Py_ssize_t *suboffsets;
  65. void *internal;
  66. } Py_buffer;
  67. #define PyBUF_SIMPLE 0
  68. #define PyBUF_WRITABLE 0x0001
  69. #define PyBUF_FORMAT 0x0004
  70. #define PyBUF_ND 0x0008
  71. #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  72. #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  73. #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  74. #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  75. #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  76. #endif
  77. #if PY_MAJOR_VERSION < 3
  78. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  79. #else
  80. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  81. #endif
  82. #if PY_MAJOR_VERSION >= 3
  83. #define Py_TPFLAGS_CHECKTYPES 0
  84. #define Py_TPFLAGS_HAVE_INDEX 0
  85. #endif
  86. #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  87. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  88. #endif
  89. #if PY_MAJOR_VERSION >= 3
  90. #define PyBaseString_Type PyUnicode_Type
  91. #define PyStringObject PyUnicodeObject
  92. #define PyString_Type PyUnicode_Type
  93. #define PyString_Check PyUnicode_Check
  94. #define PyString_CheckExact PyUnicode_CheckExact
  95. #endif
  96. #if PY_VERSION_HEX < 0x02060000
  97. #define PyBytesObject PyStringObject
  98. #define PyBytes_Type PyString_Type
  99. #define PyBytes_Check PyString_Check
  100. #define PyBytes_CheckExact PyString_CheckExact
  101. #define PyBytes_FromString PyString_FromString
  102. #define PyBytes_FromStringAndSize PyString_FromStringAndSize
  103. #define PyBytes_FromFormat PyString_FromFormat
  104. #define PyBytes_DecodeEscape PyString_DecodeEscape
  105. #define PyBytes_AsString PyString_AsString
  106. #define PyBytes_AsStringAndSize PyString_AsStringAndSize
  107. #define PyBytes_Size PyString_Size
  108. #define PyBytes_AS_STRING PyString_AS_STRING
  109. #define PyBytes_GET_SIZE PyString_GET_SIZE
  110. #define PyBytes_Repr PyString_Repr
  111. #define PyBytes_Concat PyString_Concat
  112. #define PyBytes_ConcatAndDel PyString_ConcatAndDel
  113. #endif
  114. #if PY_VERSION_HEX < 0x02060000
  115. #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type)
  116. #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type)
  117. #endif
  118. #ifndef PySet_CheckExact
  119. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  120. #endif
  121. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  122. #if PY_MAJOR_VERSION >= 3
  123. #define PyIntObject PyLongObject
  124. #define PyInt_Type PyLong_Type
  125. #define PyInt_Check(op) PyLong_Check(op)
  126. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  127. #define PyInt_FromString PyLong_FromString
  128. #define PyInt_FromUnicode PyLong_FromUnicode
  129. #define PyInt_FromLong PyLong_FromLong
  130. #define PyInt_FromSize_t PyLong_FromSize_t
  131. #define PyInt_FromSsize_t PyLong_FromSsize_t
  132. #define PyInt_AsLong PyLong_AsLong
  133. #define PyInt_AS_LONG PyLong_AS_LONG
  134. #define PyInt_AsSsize_t PyLong_AsSsize_t
  135. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  136. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  137. #endif
  138. #if PY_MAJOR_VERSION >= 3
  139. #define PyBoolObject PyLongObject
  140. #endif
  141. #if PY_MAJOR_VERSION >= 3
  142. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  143. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  144. #else
  145. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  146. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  147. #endif
  148. #if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  149. #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  150. #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  151. #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
  152. #else
  153. #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
  154. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
  155. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
  156. (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  157. #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
  158. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
  159. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
  160. (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  161. #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
  162. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
  163. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
  164. (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
  165. #endif
  166. #if PY_MAJOR_VERSION >= 3
  167. #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
  168. #endif
  169. #if PY_VERSION_HEX < 0x02050000
  170. #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n)))
  171. #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  172. #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n)))
  173. #else
  174. #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n))
  175. #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  176. #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n))
  177. #endif
  178. #if PY_VERSION_HEX < 0x02050000
  179. #define __Pyx_NAMESTR(n) ((char *)(n))
  180. #define __Pyx_DOCSTR(n) ((char *)(n))
  181. #else
  182. #define __Pyx_NAMESTR(n) (n)
  183. #define __Pyx_DOCSTR(n) (n)
  184. #endif
  185. #ifdef __cplusplus
  186. #define __PYX_EXTERN_C extern "C"
  187. #else
  188. #define __PYX_EXTERN_C extern
  189. #endif
  190. #if defined(WIN32) || defined(MS_WINDOWS)
  191. #define _USE_MATH_DEFINES
  192. #endif
  193. #include <math.h>
  194. #define __PYX_HAVE_API__zmq__core__socket
  195. #include "allocate.h"
  196. #include "errno.h"
  197. #include "string.h"
  198. #include "zmq_compat.h"
  199. #include "zmq.h"
  200. #include "zmq_utils.h"
  201. #include "pyversion_compat.h"
  202. #include "stdlib.h"
  203. #include "stdio.h"
  204. #include "pythread.h"
  205. #ifdef PYREX_WITHOUT_ASSERTIONS
  206. #define CYTHON_WITHOUT_ASSERTIONS
  207. #endif
  208. /* inline attribute */
  209. #ifndef CYTHON_INLINE
  210. #if defined(__GNUC__)
  211. #define CYTHON_INLINE __inline__
  212. #elif defined(_MSC_VER)
  213. #define CYTHON_INLINE __inline
  214. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  215. #define CYTHON_INLINE inline
  216. #else
  217. #define CYTHON_INLINE
  218. #endif
  219. #endif
  220. /* unused attribute */
  221. #ifndef CYTHON_UNUSED
  222. # if defined(__GNUC__)
  223. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  224. # define CYTHON_UNUSED __attribute__ ((__unused__))
  225. # else
  226. # define CYTHON_UNUSED
  227. # endif
  228. # elif defined(__ICC) || defined(__INTEL_COMPILER)
  229. # define CYTHON_UNUSED __attribute__ ((__unused__))
  230. # else
  231. # define CYTHON_UNUSED
  232. # endif
  233. #endif
  234. typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
  235. /* Type Conversion Predeclarations */
  236. #define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
  237. #define __Pyx_PyBytes_AsUString(s) ((unsigned char*) PyBytes_AsString(s))
  238. #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
  239. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  240. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
  241. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  242. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  243. static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
  244. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  245. #ifdef __GNUC__
  246. /* Test for GCC > 2.95 */
  247. #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
  248. #define likely(x) __builtin_expect(!!(x), 1)
  249. #define unlikely(x) __builtin_expect(!!(x), 0)
  250. #else /* __GNUC__ > 2 ... */
  251. #define likely(x) (x)
  252. #define unlikely(x) (x)
  253. #endif /* __GNUC__ > 2 ... */
  254. #else /* __GNUC__ */
  255. #define likely(x) (x)
  256. #define unlikely(x) (x)
  257. #endif /* __GNUC__ */
  258. static PyObject *__pyx_m;
  259. static PyObject *__pyx_b;
  260. static PyObject *__pyx_empty_tuple;
  261. static PyObject *__pyx_empty_bytes;
  262. static int __pyx_lineno;
  263. static int __pyx_clineno = 0;
  264. static const char * __pyx_cfilenm= __FILE__;
  265. static const char *__pyx_filename;
  266. static const char *__pyx_f[] = {
  267. "socket.pyx",
  268. "socket.pxd",
  269. "buffers.pxd",
  270. "message.pxd",
  271. "bool.pxd",
  272. "complex.pxd",
  273. };
  274. /* Type declarations */
  275. /* "zmq/core/socket.pxd":44
  276. *
  277. * # cpdef methods for direct-cython access:
  278. * cpdef object send(self, object data, int flags=*, copy=*, track=*) # <<<<<<<<<<<<<<
  279. * cpdef object recv(self, int flags=*, copy=*, track=*)
  280. *
  281. */
  282. struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send {
  283. int __pyx_n;
  284. int flags;
  285. PyObject *copy;
  286. PyObject *track;
  287. };
  288. /* "zmq/core/socket.pxd":45
  289. * # cpdef methods for direct-cython access:
  290. * cpdef object send(self, object data, int flags=*, copy=*, track=*)
  291. * cpdef object recv(self, int flags=*, copy=*, track=*) # <<<<<<<<<<<<<<
  292. *
  293. */
  294. struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv {
  295. int __pyx_n;
  296. int flags;
  297. PyObject *copy;
  298. PyObject *track;
  299. };
  300. /* "zmq/core/socket.pyx":79
  301. * raise ZMQError(ENOTSUP)
  302. *
  303. * cdef inline Message _recv_message(void *handle, int flags=0, track=False): # <<<<<<<<<<<<<<
  304. * """Receive a message in a non-copying manner and return a Message."""
  305. * cdef int rc
  306. */
  307. struct __pyx_opt_args_3zmq_4core_6socket__recv_message {
  308. int __pyx_n;
  309. int flags;
  310. PyObject *track;
  311. };
  312. /* "zmq/core/socket.pyx":92
  313. * return msg
  314. *
  315. * cdef inline object _recv_copy(void *handle, int flags=0): # <<<<<<<<<<<<<<
  316. * """Recieve a message and return a copy"""
  317. * cdef zmq_msg_t zmq_msg
  318. */
  319. struct __pyx_opt_args_3zmq_4core_6socket__recv_copy {
  320. int __pyx_n;
  321. int flags;
  322. };
  323. /* "zmq/core/socket.pyx":105
  324. * return msg_bytes
  325. *
  326. * cdef inline object _send_message(void *handle, Message msg, int flags=0): # <<<<<<<<<<<<<<
  327. * """Send a Message on this socket in a non-copy manner."""
  328. * cdef int rc
  329. */
  330. struct __pyx_opt_args_3zmq_4core_6socket__send_message {
  331. int __pyx_n;
  332. int flags;
  333. };
  334. /* "zmq/core/socket.pyx":124
  335. *
  336. *
  337. * cdef inline object _send_copy(void *handle, object msg, int flags=0): # <<<<<<<<<<<<<<
  338. * """Send a message on this socket by copying its content."""
  339. * cdef int rc, rc2
  340. */
  341. struct __pyx_opt_args_3zmq_4core_6socket__send_copy {
  342. int __pyx_n;
  343. int flags;
  344. };
  345. /* "zmq/core/socket.pxd":33
  346. *
  347. *
  348. * cdef class Socket: # <<<<<<<<<<<<<<
  349. * """A 0MQ socket."""
  350. *
  351. */
  352. struct __pyx_obj_3zmq_4core_6socket_Socket {
  353. PyObject_HEAD
  354. struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *__pyx_vtab;
  355. void *handle;
  356. int socket_type;
  357. PyObject *context;
  358. PyObject *closed;
  359. };
  360. /* "message.pxd":32
  361. * #-----------------------------------------------------------------------------
  362. *
  363. * cdef class MessageTracker(object): # <<<<<<<<<<<<<<
  364. * """A class for tracking if 0MQ is done using one or more messages."""
  365. *
  366. */
  367. struct __pyx_obj_3zmq_4core_7message_MessageTracker {
  368. PyObject_HEAD
  369. PyObject *events;
  370. PyObject *peers;
  371. };
  372. /* "message.pxd":39
  373. *
  374. *
  375. * cdef class Message: # <<<<<<<<<<<<<<
  376. * """A Message class for non-copy send/recvs."""
  377. *
  378. */
  379. struct __pyx_obj_3zmq_4core_7message_Message {
  380. PyObject_HEAD
  381. struct __pyx_vtabstruct_3zmq_4core_7message_Message *__pyx_vtab;
  382. zmq_msg_t zmq_msg;
  383. PyObject *_data;
  384. PyObject *_buffer;
  385. PyObject *_bytes;
  386. int _failed_init;
  387. PyObject *tracker_event;
  388. PyObject *tracker;
  389. };
  390. /* "zmq/core/socket.pyx":151
  391. *
  392. *
  393. * cdef class Socket: # <<<<<<<<<<<<<<
  394. * """Socket(context, socket_type)
  395. *
  396. */
  397. struct __pyx_vtabstruct_3zmq_4core_6socket_Socket {
  398. PyObject *(*send)(struct __pyx_obj_3zmq_4core_6socket_Socket *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send *__pyx_optional_args);
  399. PyObject *(*recv)(struct __pyx_obj_3zmq_4core_6socket_Socket *, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv *__pyx_optional_args);
  400. };
  401. static struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *__pyx_vtabptr_3zmq_4core_6socket_Socket;
  402. /* "message.pxd":39
  403. *
  404. *
  405. * cdef class Message: # <<<<<<<<<<<<<<
  406. * """A Message class for non-copy send/recvs."""
  407. *
  408. */
  409. struct __pyx_vtabstruct_3zmq_4core_7message_Message {
  410. struct __pyx_obj_3zmq_4core_7message_Message *(*fast_copy)(struct __pyx_obj_3zmq_4core_7message_Message *);
  411. PyObject *(*_getbuffer)(struct __pyx_obj_3zmq_4core_7message_Message *);
  412. };
  413. static struct __pyx_vtabstruct_3zmq_4core_7message_Message *__pyx_vtabptr_3zmq_4core_7message_Message;
  414. #ifndef CYTHON_REFNANNY
  415. #define CYTHON_REFNANNY 0
  416. #endif
  417. #if CYTHON_REFNANNY
  418. typedef struct {
  419. void (*INCREF)(void*, PyObject*, int);
  420. void (*DECREF)(void*, PyObject*, int);
  421. void (*GOTREF)(void*, PyObject*, int);
  422. void (*GIVEREF)(void*, PyObject*, int);
  423. void* (*SetupContext)(const char*, int, const char*);
  424. void (*FinishContext)(void**);
  425. } __Pyx_RefNannyAPIStruct;
  426. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  427. static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
  428. PyObject *m = NULL, *p = NULL;
  429. void *r = NULL;
  430. m = PyImport_ImportModule((char *)modname);
  431. if (!m) goto end;
  432. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  433. if (!p) goto end;
  434. r = PyLong_AsVoidPtr(p);
  435. end:
  436. Py_XDECREF(p);
  437. Py_XDECREF(m);
  438. return (__Pyx_RefNannyAPIStruct *)r;
  439. }
  440. #define __Pyx_RefNannySetupContext(name) void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  441. #define __Pyx_RefNannyFinishContext() __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  442. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  443. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  444. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  445. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  446. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
  447. #else
  448. #define __Pyx_RefNannySetupContext(name)
  449. #define __Pyx_RefNannyFinishContext()
  450. #define __Pyx_INCREF(r) Py_INCREF(r)
  451. #define __Pyx_DECREF(r) Py_DECREF(r)
  452. #define __Pyx_GOTREF(r)
  453. #define __Pyx_GIVEREF(r)
  454. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  455. #endif /* CYTHON_REFNANNY */
  456. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
  457. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)
  458. static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
  459. static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
  460. static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  461. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
  462. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  463. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
  464. static void __Pyx_RaiseDoubleKeywordsError(
  465. const char* func_name, PyObject* kw_name); /*proto*/
  466. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name); /*proto*/
  467. static CYTHON_INLINE long __Pyx_NegateNonNeg(long b) { return unlikely(b < 0) ? b : !b; }
  468. static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
  469. return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
  470. }
  471. static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
  472. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
  473. PyObject *r;
  474. if (!j) return NULL;
  475. r = PyObject_GetItem(o, j);
  476. Py_DECREF(j);
  477. return r;
  478. }
  479. #define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
  480. __Pyx_GetItemInt_List_Fast(o, i) : \
  481. __Pyx_GetItemInt_Generic(o, to_py_func(i)))
  482. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
  483. if (likely(o != Py_None)) {
  484. if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
  485. PyObject *r = PyList_GET_ITEM(o, i);
  486. Py_INCREF(r);
  487. return r;
  488. }
  489. else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
  490. PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
  491. Py_INCREF(r);
  492. return r;
  493. }
  494. }
  495. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  496. }
  497. #define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
  498. __Pyx_GetItemInt_Tuple_Fast(o, i) : \
  499. __Pyx_GetItemInt_Generic(o, to_py_func(i)))
  500. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
  501. if (likely(o != Py_None)) {
  502. if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
  503. PyObject *r = PyTuple_GET_ITEM(o, i);
  504. Py_INCREF(r);
  505. return r;
  506. }
  507. else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
  508. PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
  509. Py_INCREF(r);
  510. return r;
  511. }
  512. }
  513. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  514. }
  515. #define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
  516. __Pyx_GetItemInt_Fast(o, i) : \
  517. __Pyx_GetItemInt_Generic(o, to_py_func(i)))
  518. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
  519. PyObject *r;
  520. if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
  521. r = PyList_GET_ITEM(o, i);
  522. Py_INCREF(r);
  523. }
  524. else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
  525. r = PyTuple_GET_ITEM(o, i);
  526. Py_INCREF(r);
  527. }
  528. else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
  529. r = PySequence_GetItem(o, i);
  530. }
  531. else {
  532. r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  533. }
  534. return r;
  535. }
  536. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  537. static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  538. static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
  539. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
  540. #ifndef __PYX_FORCE_INIT_THREADS
  541. #if PY_VERSION_HEX < 0x02040200
  542. #define __PYX_FORCE_INIT_THREADS 1
  543. #else
  544. #define __PYX_FORCE_INIT_THREADS 0
  545. #endif
  546. #endif
  547. static CYTHON_INLINE pyzmq_int64_t __Pyx_PyInt_from_py_pyzmq_int64_t(PyObject *);
  548. static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_pyzmq_int64_t(pyzmq_int64_t);
  549. static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
  550. static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
  551. static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
  552. static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
  553. static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
  554. static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
  555. static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
  556. static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
  557. static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
  558. static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
  559. static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
  560. static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
  561. static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
  562. static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
  563. static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
  564. static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
  565. static CYTHON_INLINE int __Pyx_StrEq(const char *, const char *); /*proto*/
  566. static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
  567. static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict); /*proto*/
  568. static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
  569. static void* __Pyx_GetVtable(PyObject *dict); /*proto*/
  570. static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/
  571. static void __Pyx_AddTraceback(const char *funcname); /*proto*/
  572. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
  573. /* Module declarations from zmq.core.czmq */
  574. /* Module declarations from zmq.core.message */
  575. static PyTypeObject *__pyx_ptype_3zmq_4core_7message_MessageTracker = 0;
  576. static PyTypeObject *__pyx_ptype_3zmq_4core_7message_Message = 0;
  577. static PyObject *(*__pyx_f_3zmq_4core_7message_copy_zmq_msg_bytes)(zmq_msg_t *); /*proto*/
  578. /* Module declarations from libc.stdlib */
  579. /* Module declarations from cpython.version */
  580. /* Module declarations from cpython.ref */
  581. /* Module declarations from cpython.exc */
  582. /* Module declarations from cpython.module */
  583. /* Module declarations from cpython.mem */
  584. /* Module declarations from cpython.tuple */
  585. /* Module declarations from cpython.list */
  586. /* Module declarations from libc.stdio */
  587. /* Module declarations from cpython.object */
  588. /* Module declarations from cpython.sequence */
  589. /* Module declarations from cpython.mapping */
  590. /* Module declarations from cpython.iterator */
  591. /* Module declarations from cpython.type */
  592. /* Module declarations from cpython.number */
  593. /* Module declarations from cpython.int */
  594. /* Module declarations from __builtin__ */
  595. /* Module declarations from cpython.bool */
  596. static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
  597. /* Module declarations from cpython.long */
  598. /* Module declarations from cpython.float */
  599. /* Module declarations from __builtin__ */
  600. /* Module declarations from cpython.complex */
  601. static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
  602. /* Module declarations from cpython.string */
  603. /* Module declarations from cpython.unicode */
  604. /* Module declarations from cpython.dict */
  605. /* Module declarations from cpython.instance */
  606. /* Module declarations from cpython.function */
  607. /* Module declarations from cpython.method */
  608. /* Module declarations from cpython.weakref */
  609. /* Module declarations from cpython.getargs */
  610. /* Module declarations from cpython.pythread */
  611. /* Module declarations from cpython.cobject */
  612. /* Module declarations from cpython.oldbuffer */
  613. /* Module declarations from cpython.set */
  614. /* Module declarations from cpython.buffer */
  615. /* Module declarations from cpython.bytes */
  616. /* Module declarations from cpython.pycapsule */
  617. /* Module declarations from cpython */
  618. /* Module declarations from buffers */
  619. static CYTHON_INLINE int __pyx_f_7buffers_newstyle_available(void); /*proto*/
  620. static CYTHON_INLINE int __pyx_f_7buffers_memoryview_available(void); /*proto*/
  621. static CYTHON_INLINE int __pyx_f_7buffers_oldstyle_available(void); /*proto*/
  622. static CYTHON_INLINE int __pyx_f_7buffers_check_buffer(PyObject *); /*proto*/
  623. static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer(PyObject *, int, int, void **, Py_ssize_t *, Py_ssize_t *); /*proto*/
  624. static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer_r(PyObject *, void **, Py_ssize_t *); /*proto*/
  625. static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer_w(PyObject *, void **, Py_ssize_t *); /*proto*/
  626. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_3(void *, Py_ssize_t, int); /*proto*/
  627. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_2(void *, Py_ssize_t, int); /*proto*/
  628. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer(void *, Py_ssize_t, int); /*proto*/
  629. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_r(void *, Py_ssize_t); /*proto*/
  630. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_w(void *, Py_ssize_t); /*proto*/
  631. static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject(PyObject *, int); /*proto*/
  632. static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject_r(PyObject *); /*proto*/
  633. static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject_w(PyObject *); /*proto*/
  634. /* Module declarations from zmq.core.socket */
  635. static PyTypeObject *__pyx_ptype_3zmq_4core_6socket_Socket = 0;
  636. static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__check_closed(struct __pyx_obj_3zmq_4core_6socket_Socket *); /*proto*/
  637. static CYTHON_INLINE struct __pyx_obj_3zmq_4core_7message_Message *__pyx_f_3zmq_4core_6socket__recv_message(void *, struct __pyx_opt_args_3zmq_4core_6socket__recv_message *__pyx_optional_args); /*proto*/
  638. static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__recv_copy(void *, struct __pyx_opt_args_3zmq_4core_6socket__recv_copy *__pyx_optional_args); /*proto*/
  639. static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__send_message(void *, struct __pyx_obj_3zmq_4core_7message_Message *, struct __pyx_opt_args_3zmq_4core_6socket__send_message *__pyx_optional_args); /*proto*/
  640. static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__send_copy(void *, PyObject *, struct __pyx_opt_args_3zmq_4core_6socket__send_copy *__pyx_optional_args); /*proto*/
  641. #define __Pyx_MODULE_NAME "zmq.core.socket"
  642. static int __pyx_module_is_main_zmq__core__socket = 0;
  643. /* Implementation of zmq.core.socket */
  644. static PyObject *__pyx_builtin_TypeError;
  645. static PyObject *__pyx_builtin_xrange;
  646. static PyObject *__pyx_builtin_ValueError;
  647. static PyObject *__pyx_builtin_ImportError;
  648. static PyObject *__pyx_builtin_AttributeError;
  649. static PyObject *__pyx_builtin_NotImplementedError;
  650. static char __pyx_k_2[] = "unicode not allowed, use setsockopt_unicode";
  651. static char __pyx_k_4[] = "expected str, got: %r";
  652. static char __pyx_k_5[] = "expected int, got: %r";
  653. static char __pyx_k_6[] = "utf-8";
  654. static char __pyx_k_7[] = "unicode strings only";
  655. static char __pyx_k_9[] = "option %i will not return a string to be decoded";
  656. static char __pyx_k_11[] = "%s:%s";
  657. static char __pyx_k_12[] = "Could not bind socket to random port.";
  658. static char __pyx_k_17[] = "unicode not allowed, use send_unicode";
  659. static char __pyx_k_19[] = "Not a tracked message";
  660. static char __pyx_k_28[] = "unicode/str objects only";
  661. static char __pyx_k_30[] = "jsonlib{1,2}, json or simplejson library is required.";
  662. static char __pyx_k_33[] = "%r does not provide a buffer interface.";
  663. static char __pyx_k_34[] = "";
  664. static char __pyx_k_35[] = "New style buffers not available.";
  665. static char __pyx_k_37[] = "Old style buffers not available.";
  666. static char __pyx_k_39[] = "0MQ Socket class.";
  667. static char __pyx_k_40[] = "zmq.utils";
  668. static char __pyx_k_41[] = "zmq.core";
  669. static char __pyx_k_42[] = "zmq.core.constants";
  670. static char __pyx_k_43[] = "*";
  671. static char __pyx_k_44[] = "zmq.core.error";
  672. static char __pyx_k_45[] = "zmq.utils.strtypes";
  673. static char __pyx_k__B[] = "B";
  674. static char __pyx_k__u[] = "u";
  675. static char __pyx_k__buf[] = "buf";
  676. static char __pyx_k__len[] = "len";
  677. static char __pyx_k__obj[] = "obj";
  678. static char __pyx_k__sys[] = "sys";
  679. static char __pyx_k__addr[] = "addr";
  680. static char __pyx_k__bind[] = "bind";
  681. static char __pyx_k__char[] = "char";
  682. static char __pyx_k__copy[] = "copy";
  683. static char __pyx_k__data[] = "data";
  684. static char __pyx_k__recv[] = "recv";
  685. static char __pyx_k__send[] = "send";
  686. static char __pyx_k__time[] = "time";
  687. static char __pyx_k__bytes[] = "bytes";
  688. static char __pyx_k__close[] = "close";
  689. static char __pyx_k__dtype[] = "dtype";
  690. static char __pyx_k__dumps[] = "dumps";
  691. static char __pyx_k__flags[] = "flags";
  692. static char __pyx_k__loads[] = "loads";
  693. static char __pyx_k__range[] = "range";
  694. static char __pyx_k__shape[] = "shape";
  695. static char __pyx_k__track[] = "track";
  696. static char __pyx_k__EINVAL[] = "EINVAL";
  697. static char __pyx_k__Socket[] = "Socket";
  698. static char __pyx_k__append[] = "append";
  699. static char __pyx_k__buffer[] = "buffer";
  700. static char __pyx_k__closed[] = "closed";
  701. static char __pyx_k__codecs[] = "codecs";
  702. static char __pyx_k__decode[] = "decode";
  703. static char __pyx_k__encode[] = "encode";
  704. static char __pyx_k__format[] = "format";
  705. static char __pyx_k__handle[] = "handle";
  706. static char __pyx_k__option[] = "option";
  707. static char __pyx_k__optval[] = "optval";
  708. static char __pyx_k__pickle[] = "pickle";
  709. static char __pyx_k__random[] = "random";
  710. static char __pyx_k__struct[] = "struct";
  711. static char __pyx_k__xrange[] = "xrange";
  712. static char __pyx_k__ENOTSUP[] = "ENOTSUP";
  713. static char __pyx_k__RCVMORE[] = "RCVMORE";
  714. static char __pyx_k__SNDMORE[] = "SNDMORE";
  715. static char __pyx_k____all__[] = "__all__";
  716. static char __pyx_k___handle[] = "_handle";
  717. static char __pyx_k__cPickle[] = "cPickle";
  718. static char __pyx_k__context[] = "context";
  719. static char __pyx_k__jsonapi[] = "jsonapi";
  720. static char __pyx_k__jsonmod[] = "jsonmod";
  721. static char __pyx_k__rcvmore[] = "rcvmore";
  722. static char __pyx_k__tracker[] = "tracker";
  723. static char __pyx_k__unicode[] = "unicode";
  724. static char __pyx_k__zmq_msg[] = "zmq_msg";
  725. static char __pyx_k__IDENTITY[] = "IDENTITY";
  726. static char __pyx_k__ZMQError[] = "ZMQError";
  727. static char __pyx_k____main__[] = "__main__";
  728. static char __pyx_k____test__[] = "__test__";
  729. static char __pyx_k__copy_mod[] = "copy_mod";
  730. static char __pyx_k__encoding[] = "encoding";
  731. static char __pyx_k__itemsize[] = "itemsize";
  732. static char __pyx_k__max_port[] = "max_port";
  733. static char __pyx_k__min_port[] = "min_port";
  734. static char __pyx_k__protocol[] = "protocol";
  735. static char __pyx_k__typecode[] = "typecode";
  736. static char __pyx_k__TypeError[] = "TypeError";
  737. static char __pyx_k__constants[] = "constants";
  738. static char __pyx_k__fast_copy[] = "fast_copy";
  739. static char __pyx_k__max_tries[] = "max_tries";
  740. static char __pyx_k__msg_parts[] = "msg_parts";
  741. static char __pyx_k__randrange[] = "randrange";
  742. static char __pyx_k__ValueError[] = "ValueError";
  743. static char __pyx_k__basestring[] = "basestring";
  744. static char __pyx_k__getsockopt[] = "getsockopt";
  745. static char __pyx_k__setsockopt[] = "setsockopt";
  746. static char __pyx_k__ImportError[] = "ImportError";
  747. static char __pyx_k__socket_type[] = "socket_type";
  748. static char __pyx_k__ZMQBindError[] = "ZMQBindError";
  749. static char __pyx_k__int_sockopts[] = "int_sockopts";
  750. static char __pyx_k__AttributeError[] = "AttributeError";
  751. static char __pyx_k__bytes_sockopts[] = "bytes_sockopts";
  752. static char __pyx_k__int64_sockopts[] = "int64_sockopts";
  753. static char __pyx_k__NotImplementedError[] = "NotImplementedError";
  754. static PyObject *__pyx_kp_s_11;
  755. static PyObject *__pyx_kp_s_12;
  756. static PyObject *__pyx_kp_s_17;
  757. static PyObject *__pyx_kp_s_19;
  758. static PyObject *__pyx_kp_s_2;
  759. static PyObject *__pyx_kp_s_28;
  760. static PyObject *__pyx_kp_s_30;
  761. static PyObject *__pyx_kp_s_33;
  762. static PyObject *__pyx_kp_s_34;
  763. static PyObject *__pyx_kp_s_35;
  764. static PyObject *__pyx_kp_s_37;
  765. static PyObject *__pyx_kp_s_4;
  766. static PyObject *__pyx_n_s_40;
  767. static PyObject *__pyx_n_s_41;
  768. static PyObject *__pyx_n_s_42;
  769. static PyObject *__pyx_n_s_43;
  770. static PyObject *__pyx_n_s_44;
  771. static PyObject *__pyx_n_s_45;
  772. static PyObject *__pyx_kp_s_5;
  773. static PyObject *__pyx_kp_s_6;
  774. static PyObject *__pyx_kp_s_7;
  775. static PyObject *__pyx_kp_s_9;
  776. static PyObject *__pyx_n_s__AttributeError;
  777. static PyObject *__pyx_n_s__B;
  778. static PyObject *__pyx_n_s__EINVAL;
  779. static PyObject *__pyx_n_s__ENOTSUP;
  780. static PyObject *__pyx_n_s__IDENTITY;
  781. static PyObject *__pyx_n_s__ImportError;
  782. static PyObject *__pyx_n_s__NotImplementedError;
  783. static PyObject *__pyx_n_s__RCVMORE;
  784. static PyObject *__pyx_n_s__SNDMORE;
  785. static PyObject *__pyx_n_s__Socket;
  786. static PyObject *__pyx_n_s__TypeError;
  787. static PyObject *__pyx_n_s__ValueError;
  788. static PyObject *__pyx_n_s__ZMQBindError;
  789. static PyObject *__pyx_n_s__ZMQError;
  790. static PyObject *__pyx_n_s____all__;
  791. static PyObject *__pyx_n_s____main__;
  792. static PyObject *__pyx_n_s____test__;
  793. static PyObject *__pyx_n_s___handle;
  794. static PyObject *__pyx_n_s__addr;
  795. static PyObject *__pyx_n_s__append;
  796. static PyObject *__pyx_n_s__basestring;
  797. static PyObject *__pyx_n_s__bind;
  798. static PyObject *__pyx_n_s__buf;
  799. static PyObject *__pyx_n_s__buffer;
  800. static PyObject *__pyx_n_s__bytes;
  801. static PyObject *__pyx_n_s__bytes_sockopts;
  802. static PyObject *__pyx_n_s__cPickle;
  803. static PyObject *__pyx_n_s__char;
  804. static PyObject *__pyx_n_s__close;
  805. static PyObject *__pyx_n_s__closed;
  806. static PyObject *__pyx_n_s__codecs;
  807. static PyObject *__pyx_n_s__constants;
  808. static PyObject *__pyx_n_s__context;
  809. static PyObject *__pyx_n_s__copy;
  810. static PyObject *__pyx_n_s__copy_mod;
  811. static PyObject *__pyx_n_s__data;
  812. static PyObject *__pyx_n_s__decode;
  813. static PyObject *__pyx_n_s__dtype;
  814. static PyObject *__pyx_n_s__dumps;
  815. static PyObject *__pyx_n_s__encode;
  816. static PyObject *__pyx_n_s__encoding;
  817. static PyObject *__pyx_n_s__fast_copy;
  818. static PyObject *__pyx_n_s__flags;
  819. static PyObject *__pyx_n_s__format;
  820. static PyObject *__pyx_n_s__getsockopt;
  821. static PyObject *__pyx_n_s__handle;
  822. static PyObject *__pyx_n_s__int64_sockopts;
  823. static PyObject *__pyx_n_s__int_sockopts;
  824. static PyObject *__pyx_n_s__itemsize;
  825. static PyObject *__pyx_n_s__jsonapi;
  826. static PyObject *__pyx_n_s__jsonmod;
  827. static PyObject *__pyx_n_s__len;
  828. static PyObject *__pyx_n_s__loads;
  829. static PyObject *__pyx_n_s__max_port;
  830. static PyObject *__pyx_n_s__max_tries;
  831. static PyObject *__pyx_n_s__min_port;
  832. static PyObject *__pyx_n_s__msg_parts;
  833. static PyObject *__pyx_n_s__obj;
  834. static PyObject *__pyx_n_s__option;
  835. static PyObject *__pyx_n_s__optval;
  836. static PyObject *__pyx_n_s__pickle;
  837. static PyObject *__pyx_n_s__protocol;
  838. static PyObject *__pyx_n_s__random;
  839. static PyObject *__pyx_n_s__randrange;
  840. static PyObject *__pyx_n_s__range;
  841. static PyObject *__pyx_n_s__rcvmore;
  842. static PyObject *__pyx_n_s__recv;
  843. static PyObject *__pyx_n_s__send;
  844. static PyObject *__pyx_n_s__setsockopt;
  845. static PyObject *__pyx_n_s__shape;
  846. static PyObject *__pyx_n_s__socket_type;
  847. static PyObject *__pyx_n_s__struct;
  848. static PyObject *__pyx_n_s__sys;
  849. static PyObject *__pyx_n_s__time;
  850. static PyObject *__pyx_n_s__track;
  851. static PyObject *__pyx_n_s__tracker;
  852. static PyObject *__pyx_n_s__typecode;
  853. static PyObject *__pyx_n_s__u;
  854. static PyObject *__pyx_n_s__unicode;
  855. static PyObject *__pyx_n_s__xrange;
  856. static PyObject *__pyx_n_s__zmq_msg;
  857. static PyObject *__pyx_int_0;
  858. static PyObject *__pyx_int_neg_1;
  859. static PyObject *__pyx_int_100;
  860. static PyObject *__pyx_int_49152;
  861. static PyObject *__pyx_int_65536;
  862. static PyObject *__pyx_k_1;
  863. static PyObject *__pyx_k_15;
  864. static PyObject *__pyx_k_16;
  865. static PyObject *__pyx_k_21;
  866. static PyObject *__pyx_k_22;
  867. static PyObject *__pyx_k_23;
  868. static PyObject *__pyx_k_24;
  869. static PyObject *__pyx_k_25;
  870. static PyObject *__pyx_k_26;
  871. static PyObject *__pyx_k_27;
  872. static PyObject *__pyx_k_tuple_3;
  873. static PyObject *__pyx_k_tuple_8;
  874. static PyObject *__pyx_k_tuple_10;
  875. static PyObject *__pyx_k_tuple_13;
  876. static PyObject *__pyx_k_tuple_14;
  877. static PyObject *__pyx_k_tuple_18;
  878. static PyObject *__pyx_k_tuple_20;
  879. static PyObject *__pyx_k_tuple_29;
  880. static PyObject *__pyx_k_tuple_31;
  881. static PyObject *__pyx_k_tuple_32;
  882. static PyObject *__pyx_k_tuple_36;
  883. static PyObject *__pyx_k_tuple_38;
  884. /* "zmq/core/socket.pyx":75
  885. * # true methods frequently cannot be inlined, acc. Cython docs
  886. *
  887. * cdef inline _check_closed(Socket s): # <<<<<<<<<<<<<<
  888. * if s.closed:
  889. * raise ZMQError(ENOTSUP)
  890. */
  891. static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__check_closed(struct __pyx_obj_3zmq_4core_6socket_Socket *__pyx_v_s) {
  892. PyObject *__pyx_r = NULL;
  893. int __pyx_t_1;
  894. PyObject *__pyx_t_2 = NULL;
  895. PyObject *__pyx_t_3 = NULL;
  896. PyObject *__pyx_t_4 = NULL;
  897. __Pyx_RefNannySetupContext("_check_closed");
  898. /* "zmq/core/socket.pyx":76
  899. *
  900. * cdef inline _check_closed(Socket s):
  901. * if s.closed: # <<<<<<<<<<<<<<
  902. * raise ZMQError(ENOTSUP)
  903. *
  904. */
  905. __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_s->closed); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  906. if (__pyx_t_1) {
  907. /* "zmq/core/socket.pyx":77
  908. * cdef inline _check_closed(Socket s):
  909. * if s.closed:
  910. * raise ZMQError(ENOTSUP) # <<<<<<<<<<<<<<
  911. *
  912. * cdef inline Message _recv_message(void *handle, int flags=0, track=False):
  913. */
  914. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  915. __Pyx_GOTREF(__pyx_t_2);
  916. __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ENOTSUP); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  917. __Pyx_GOTREF(__pyx_t_3);
  918. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  919. __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  920. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  921. __Pyx_GIVEREF(__pyx_t_3);
  922. __pyx_t_3 = 0;
  923. __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  924. __Pyx_GOTREF(__pyx_t_3);
  925. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  926. __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  927. __Pyx_Raise(__pyx_t_3, 0, 0);
  928. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  929. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  930. goto __pyx_L3;
  931. }
  932. __pyx_L3:;
  933. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  934. goto __pyx_L0;
  935. __pyx_L1_error:;
  936. __Pyx_XDECREF(__pyx_t_2);
  937. __Pyx_XDECREF(__pyx_t_3);
  938. __Pyx_XDECREF(__pyx_t_4);
  939. __Pyx_AddTraceback("zmq.core.socket._check_closed");
  940. __pyx_r = 0;
  941. __pyx_L0:;
  942. __Pyx_XGIVEREF(__pyx_r);
  943. __Pyx_RefNannyFinishContext();
  944. return __pyx_r;
  945. }
  946. /* "zmq/core/socket.pyx":79
  947. * raise ZMQError(ENOTSUP)
  948. *
  949. * cdef inline Message _recv_message(void *handle, int flags=0, track=False): # <<<<<<<<<<<<<<
  950. * """Receive a message in a non-copying manner and return a Message."""
  951. * cdef int rc
  952. */
  953. static CYTHON_INLINE struct __pyx_obj_3zmq_4core_7message_Message *__pyx_f_3zmq_4core_6socket__recv_message(void *__pyx_v_handle, struct __pyx_opt_args_3zmq_4core_6socket__recv_message *__pyx_optional_args) {
  954. int __pyx_v_flags = ((int)0);
  955. PyObject *__pyx_v_track = __pyx_k_1;
  956. int __pyx_v_rc;
  957. struct __pyx_obj_3zmq_4core_7message_Message *__pyx_v_msg;
  958. struct __pyx_obj_3zmq_4core_7message_Message *__pyx_r = NULL;
  959. PyObject *__pyx_t_1 = NULL;
  960. PyObject *__pyx_t_2 = NULL;
  961. int __pyx_t_3;
  962. __Pyx_RefNannySetupContext("_recv_message");
  963. if (__pyx_optional_args) {
  964. if (__pyx_optional_args->__pyx_n > 0) {
  965. __pyx_v_flags = __pyx_optional_args->flags;
  966. if (__pyx_optional_args->__pyx_n > 1) {
  967. __pyx_v_track = __pyx_optional_args->track;
  968. }
  969. }
  970. }
  971. __pyx_v_msg = ((struct __pyx_obj_3zmq_4core_7message_Message *)Py_None); __Pyx_INCREF(Py_None);
  972. /* "zmq/core/socket.pyx":83
  973. * cdef int rc
  974. * cdef Message msg
  975. * msg = Message(track=track) # <<<<<<<<<<<<<<
  976. *
  977. * with nogil:
  978. */
  979. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  980. __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  981. if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__track), __pyx_v_track) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  982. __pyx_t_2 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_3zmq_4core_7message_Message)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  983. __Pyx_GOTREF(__pyx_t_2);
  984. __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  985. __Pyx_DECREF(((PyObject *)__pyx_v_msg));
  986. __pyx_v_msg = ((struct __pyx_obj_3zmq_4core_7message_Message *)__pyx_t_2);
  987. __pyx_t_2 = 0;
  988. /* "zmq/core/socket.pyx":85
  989. * msg = Message(track=track)
  990. *
  991. * with nogil: # <<<<<<<<<<<<<<
  992. * rc = zmq_recvmsg(handle, &msg.zmq_msg, flags)
  993. *
  994. */
  995. {
  996. #ifdef WITH_THREAD
  997. PyThreadState *_save;
  998. #endif
  999. Py_UNBLOCK_THREADS
  1000. /*try:*/ {
  1001. /* "zmq/core/socket.pyx":86
  1002. *
  1003. * with nogil:
  1004. * rc = zmq_recvmsg(handle, &msg.zmq_msg, flags) # <<<<<<<<<<<<<<
  1005. *
  1006. * if rc < 0:
  1007. */
  1008. __pyx_v_rc = zmq_recvmsg(__pyx_v_handle, (&__pyx_v_msg->zmq_msg), __pyx_v_flags);
  1009. }
  1010. /* "zmq/core/socket.pyx":85
  1011. * msg = Message(track=track)
  1012. *
  1013. * with nogil: # <<<<<<<<<<<<<<
  1014. * rc = zmq_recvmsg(handle, &msg.zmq_msg, flags)
  1015. *
  1016. */
  1017. /*finally:*/ {
  1018. Py_BLOCK_THREADS
  1019. }
  1020. }
  1021. /* "zmq/core/socket.pyx":88
  1022. * rc = zmq_recvmsg(handle, &msg.zmq_msg, flags)
  1023. *
  1024. * if rc < 0: # <<<<<<<<<<<<<<
  1025. * raise ZMQError()
  1026. * return msg
  1027. */
  1028. __pyx_t_3 = (__pyx_v_rc < 0);
  1029. if (__pyx_t_3) {
  1030. /* "zmq/core/socket.pyx":89
  1031. *
  1032. * if rc < 0:
  1033. * raise ZMQError() # <<<<<<<<<<<<<<
  1034. * return msg
  1035. *
  1036. */
  1037. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1038. __Pyx_GOTREF(__pyx_t_2);
  1039. __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1040. __Pyx_GOTREF(__pyx_t_1);
  1041. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1042. __Pyx_Raise(__pyx_t_1, 0, 0);
  1043. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1044. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1045. goto __pyx_L6;
  1046. }
  1047. __pyx_L6:;
  1048. /* "zmq/core/socket.pyx":90
  1049. * if rc < 0:
  1050. * raise ZMQError()
  1051. * return msg # <<<<<<<<<<<<<<
  1052. *
  1053. * cdef inline object _recv_copy(void *handle, int flags=0):
  1054. */
  1055. __Pyx_XDECREF(((PyObject *)__pyx_r));
  1056. __Pyx_INCREF(((PyObject *)__pyx_v_msg));
  1057. __pyx_r = __pyx_v_msg;
  1058. goto __pyx_L0;
  1059. __pyx_r = ((struct __pyx_obj_3zmq_4core_7message_Message *)Py_None); __Pyx_INCREF(Py_None);
  1060. goto __pyx_L0;
  1061. __pyx_L1_error:;
  1062. __Pyx_XDECREF(__pyx_t_1);
  1063. __Pyx_XDECREF(__pyx_t_2);
  1064. __Pyx_AddTraceback("zmq.core.socket._recv_message");
  1065. __pyx_r = 0;
  1066. __pyx_L0:;
  1067. __Pyx_DECREF((PyObject *)__pyx_v_msg);
  1068. __Pyx_XGIVEREF((PyObject *)__pyx_r);
  1069. __Pyx_RefNannyFinishContext();
  1070. return __pyx_r;
  1071. }
  1072. /* "zmq/core/socket.pyx":92
  1073. * return msg
  1074. *
  1075. * cdef inline object _recv_copy(void *handle, int flags=0): # <<<<<<<<<<<<<<
  1076. * """Recieve a message and return a copy"""
  1077. * cdef zmq_msg_t zmq_msg
  1078. */
  1079. static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__recv_copy(void *__pyx_v_handle, struct __pyx_opt_args_3zmq_4core_6socket__recv_copy *__pyx_optional_args) {
  1080. int __pyx_v_flags = ((int)0);
  1081. zmq_msg_t __pyx_v_zmq_msg;
  1082. int __pyx_v_rc;
  1083. PyObject *__pyx_v_msg_bytes;
  1084. PyObject *__pyx_r = NULL;
  1085. int __pyx_t_1;
  1086. PyObject *__pyx_t_2 = NULL;
  1087. PyObject *__pyx_t_3 = NULL;
  1088. __Pyx_RefNannySetupContext("_recv_copy");
  1089. if (__pyx_optional_args) {
  1090. if (__pyx_optional_args->__pyx_n > 0) {
  1091. __pyx_v_flags = __pyx_optional_args->flags;
  1092. }
  1093. }
  1094. __pyx_v_msg_bytes = Py_None; __Pyx_INCREF(Py_None);
  1095. /* "zmq/core/socket.pyx":95
  1096. * """Recieve a message and return a copy"""
  1097. * cdef zmq_msg_t zmq_msg
  1098. * with nogil: # <<<<<<<<<<<<<<
  1099. * zmq_msg_init (&zmq_msg)
  1100. * rc = zmq_recvmsg(handle, &zmq_msg, flags)
  1101. */
  1102. {
  1103. #ifdef WITH_THREAD
  1104. PyThreadState *_save;
  1105. #endif
  1106. Py_UNBLOCK_THREADS
  1107. /*try:*/ {
  1108. /* "zmq/core/socket.pyx":96
  1109. * cdef zmq_msg_t zmq_msg
  1110. * with nogil:
  1111. * zmq_msg_init (&zmq_msg) # <<<<<<<<<<<<<<
  1112. * rc = zmq_recvmsg(handle, &zmq_msg, flags)
  1113. * if rc < 0:
  1114. */
  1115. zmq_msg_init((&__pyx_v_zmq_msg));
  1116. /* "zmq/core/socket.pyx":97
  1117. * with nogil:
  1118. * zmq_msg_init (&zmq_msg)
  1119. * rc = zmq_recvmsg(handle, &zmq_msg, flags) # <<<<<<<<<<<<<<
  1120. * if rc < 0:
  1121. * raise ZMQError()
  1122. */
  1123. __pyx_v_rc = zmq_recvmsg(__pyx_v_handle, (&__pyx_v_zmq_msg), __pyx_v_flags);
  1124. }
  1125. /* "zmq/core/socket.pyx":95
  1126. * """Recieve a message and return a copy"""
  1127. * cdef zmq_msg_t zmq_msg
  1128. * with nogil: # <<<<<<<<<<<<<<
  1129. * zmq_msg_init (&zmq_msg)
  1130. * rc = zmq_recvmsg(handle, &zmq_msg, flags)
  1131. */
  1132. /*finally:*/ {
  1133. Py_BLOCK_THREADS
  1134. }
  1135. }
  1136. /* "zmq/core/socket.pyx":98
  1137. * zmq_msg_init (&zmq_msg)
  1138. * rc = zmq_recvmsg(handle, &zmq_msg, flags)
  1139. * if rc < 0: # <<<<<<<<<<<<<<
  1140. * raise ZMQError()
  1141. * msg_bytes = copy_zmq_msg_bytes(&zmq_msg)
  1142. */
  1143. __pyx_t_1 = (__pyx_v_rc < 0);
  1144. if (__pyx_t_1) {
  1145. /* "zmq/core/socket.pyx":99
  1146. * rc = zmq_recvmsg(handle, &zmq_msg, flags)
  1147. * if rc < 0:
  1148. * raise ZMQError() # <<<<<<<<<<<<<<
  1149. * msg_bytes = copy_zmq_msg_bytes(&zmq_msg)
  1150. * with nogil:
  1151. */
  1152. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1153. __Pyx_GOTREF(__pyx_t_2);
  1154. __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1155. __Pyx_GOTREF(__pyx_t_3);
  1156. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1157. __Pyx_Raise(__pyx_t_3, 0, 0);
  1158. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  1159. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1160. goto __pyx_L6;
  1161. }
  1162. __pyx_L6:;
  1163. /* "zmq/core/socket.pyx":100
  1164. * if rc < 0:
  1165. * raise ZMQError()
  1166. * msg_bytes = copy_zmq_msg_bytes(&zmq_msg) # <<<<<<<<<<<<<<
  1167. * with nogil:
  1168. * zmq_msg_close(&zmq_msg)
  1169. */
  1170. __pyx_t_3 = __pyx_f_3zmq_4core_7message_copy_zmq_msg_bytes((&__pyx_v_zmq_msg)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1171. __Pyx_GOTREF(__pyx_t_3);
  1172. __Pyx_DECREF(__pyx_v_msg_bytes);
  1173. __pyx_v_msg_bytes = __pyx_t_3;
  1174. __pyx_t_3 = 0;
  1175. /* "zmq/core/socket.pyx":101
  1176. * raise ZMQError()
  1177. * msg_bytes = copy_zmq_msg_bytes(&zmq_msg)
  1178. * with nogil: # <<<<<<<<<<<<<<
  1179. * zmq_msg_close(&zmq_msg)
  1180. * return msg_bytes
  1181. */
  1182. {
  1183. #ifdef WITH_THREAD
  1184. PyThreadState *_save;
  1185. #endif
  1186. Py_UNBLOCK_THREADS
  1187. /*try:*/ {
  1188. /* "zmq/core/socket.pyx":102
  1189. * msg_bytes = copy_zmq_msg_bytes(&zmq_msg)
  1190. * with nogil:
  1191. * zmq_msg_close(&zmq_msg) # <<<<<<<<<<<<<<
  1192. * return msg_bytes
  1193. *
  1194. */
  1195. zmq_msg_close((&__pyx_v_zmq_msg));
  1196. }
  1197. /* "zmq/core/socket.pyx":101
  1198. * raise ZMQError()
  1199. * msg_bytes = copy_zmq_msg_bytes(&zmq_msg)
  1200. * with nogil: # <<<<<<<<<<<<<<
  1201. * zmq_msg_close(&zmq_msg)
  1202. * return msg_bytes
  1203. */
  1204. /*finally:*/ {
  1205. Py_BLOCK_THREADS
  1206. }
  1207. }
  1208. /* "zmq/core/socket.pyx":103
  1209. * with nogil:
  1210. * zmq_msg_close(&zmq_msg)
  1211. * return msg_bytes # <<<<<<<<<<<<<<
  1212. *
  1213. * cdef inline object _send_message(void *handle, Message msg, int flags=0):
  1214. */
  1215. __Pyx_XDECREF(__pyx_r);
  1216. __Pyx_INCREF(__pyx_v_msg_bytes);
  1217. __pyx_r = __pyx_v_msg_bytes;
  1218. goto __pyx_L0;
  1219. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  1220. goto __pyx_L0;
  1221. __pyx_L1_error:;
  1222. __Pyx_XDECREF(__pyx_t_2);
  1223. __Pyx_XDECREF(__pyx_t_3);
  1224. __Pyx_AddTraceback("zmq.core.socket._recv_copy");
  1225. __pyx_r = 0;
  1226. __pyx_L0:;
  1227. __Pyx_DECREF(__pyx_v_msg_bytes);
  1228. __Pyx_XGIVEREF(__pyx_r);
  1229. __Pyx_RefNannyFinishContext();
  1230. return __pyx_r;
  1231. }
  1232. /* "zmq/core/socket.pyx":105
  1233. * return msg_bytes
  1234. *
  1235. * cdef inline object _send_message(void *handle, Message msg, int flags=0): # <<<<<<<<<<<<<<
  1236. * """Send a Message on this socket in a non-copy manner."""
  1237. * cdef int rc
  1238. */
  1239. static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__send_message(void *__pyx_v_handle, struct __pyx_obj_3zmq_4core_7message_Message *__pyx_v_msg, struct __pyx_opt_args_3zmq_4core_6socket__send_message *__pyx_optional_args) {
  1240. int __pyx_v_flags = ((int)0);
  1241. int __pyx_v_rc;
  1242. struct __pyx_obj_3zmq_4core_7message_Message *__pyx_v_msg_copy;
  1243. PyObject *__pyx_r = NULL;
  1244. PyObject *__pyx_t_1 = NULL;
  1245. int __pyx_t_2;
  1246. PyObject *__pyx_t_3 = NULL;
  1247. __Pyx_RefNannySetupContext("_send_message");
  1248. if (__pyx_optional_args) {
  1249. if (__pyx_optional_args->__pyx_n > 0) {
  1250. __pyx_v_flags = __pyx_optional_args->flags;
  1251. }
  1252. }
  1253. __pyx_v_msg_copy = ((struct __pyx_obj_3zmq_4core_7message_Message *)Py_None); __Pyx_INCREF(Py_None);
  1254. /* "zmq/core/socket.pyx":112
  1255. * # Always copy so the original message isn't garbage collected.
  1256. * # This doesn't do a real copy, just a reference.
  1257. * msg_copy = msg.fast_copy() # <<<<<<<<<<<<<<
  1258. *
  1259. * with nogil:
  1260. */
  1261. __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_3zmq_4core_7message_Message *)__pyx_v_msg->__pyx_vtab)->fast_copy(__pyx_v_msg)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1262. __Pyx_GOTREF(__pyx_t_1);
  1263. __Pyx_DECREF(((PyObject *)__pyx_v_msg_copy));
  1264. __pyx_v_msg_copy = ((struct __pyx_obj_3zmq_4core_7message_Message *)__pyx_t_1);
  1265. __pyx_t_1 = 0;
  1266. /* "zmq/core/socket.pyx":114
  1267. * msg_copy = msg.fast_copy()
  1268. *
  1269. * with nogil: # <<<<<<<<<<<<<<
  1270. * rc = zmq_sendmsg(handle, &msg_copy.zmq_msg, flags)
  1271. *
  1272. */
  1273. {
  1274. #ifdef WITH_THREAD
  1275. PyThreadState *_save;
  1276. #endif
  1277. Py_UNBLOCK_THREADS
  1278. /*try:*/ {
  1279. /* "zmq/core/socket.pyx":115
  1280. *
  1281. * with nogil:
  1282. * rc = zmq_sendmsg(handle, &msg_copy.zmq_msg, flags) # <<<<<<<<<<<<<<
  1283. *
  1284. * if rc < 0:
  1285. */
  1286. __pyx_v_rc = zmq_sendmsg(__pyx_v_handle, (&__pyx_v_msg_copy->zmq_msg), __pyx_v_flags);
  1287. }
  1288. /* "zmq/core/socket.pyx":114
  1289. * msg_copy = msg.fast_copy()
  1290. *
  1291. * with nogil: # <<<<<<<<<<<<<<
  1292. * rc = zmq_sendmsg(handle, &msg_copy.zmq_msg, flags)
  1293. *
  1294. */
  1295. /*finally:*/ {
  1296. Py_BLOCK_THREADS
  1297. }
  1298. }
  1299. /* "zmq/core/socket.pyx":117
  1300. * rc = zmq_sendmsg(handle, &msg_copy.zmq_msg, flags)
  1301. *
  1302. * if rc < 0: # <<<<<<<<<<<<<<
  1303. * # don't pop from the Queue here, because the free_fn will
  1304. * # still call Queue.get() even if the send fails
  1305. */
  1306. __pyx_t_2 = (__pyx_v_rc < 0);
  1307. if (__pyx_t_2) {
  1308. /* "zmq/core/socket.pyx":120
  1309. * # don't pop from the Queue here, because the free_fn will
  1310. * # still call Queue.get() even if the send fails
  1311. * raise ZMQError() # <<<<<<<<<<<<<<
  1312. * return msg.tracker
  1313. *
  1314. */
  1315. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1316. __Pyx_GOTREF(__pyx_t_1);
  1317. __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1318. __Pyx_GOTREF(__pyx_t_3);
  1319. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1320. __Pyx_Raise(__pyx_t_3, 0, 0);
  1321. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  1322. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1323. goto __pyx_L6;
  1324. }
  1325. __pyx_L6:;
  1326. /* "zmq/core/socket.pyx":121
  1327. * # still call Queue.get() even if the send fails
  1328. * raise ZMQError()
  1329. * return msg.tracker # <<<<<<<<<<<<<<
  1330. *
  1331. *
  1332. */
  1333. __Pyx_XDECREF(__pyx_r);
  1334. __Pyx_INCREF(__pyx_v_msg->tracker);
  1335. __pyx_r = __pyx_v_msg->tracker;
  1336. goto __pyx_L0;
  1337. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  1338. goto __pyx_L0;
  1339. __pyx_L1_error:;
  1340. __Pyx_XDECREF(__pyx_t_1);
  1341. __Pyx_XDECREF(__pyx_t_3);
  1342. __Pyx_AddTraceback("zmq.core.socket._send_message");
  1343. __pyx_r = 0;
  1344. __pyx_L0:;
  1345. __Pyx_DECREF((PyObject *)__pyx_v_msg_copy);
  1346. __Pyx_XGIVEREF(__pyx_r);
  1347. __Pyx_RefNannyFinishContext();
  1348. return __pyx_r;
  1349. }
  1350. /* "zmq/core/socket.pyx":124
  1351. *
  1352. *
  1353. * cdef inline object _send_copy(void *handle, object msg, int flags=0): # <<<<<<<<<<<<<<
  1354. * """Send a message on this socket by copying its content."""
  1355. * cdef int rc, rc2
  1356. */
  1357. static CYTHON_INLINE PyObject *__pyx_f_3zmq_4core_6socket__send_copy(void *__pyx_v_handle, PyObject *__pyx_v_msg, struct __pyx_opt_args_3zmq_4core_6socket__send_copy *__pyx_optional_args) {
  1358. int __pyx_v_flags = ((int)0);
  1359. int __pyx_v_rc;
  1360. int __pyx_v_rc2;
  1361. zmq_msg_t __pyx_v_data;
  1362. char *__pyx_v_msg_c;
  1363. Py_ssize_t __pyx_v_msg_c_len;
  1364. PyObject *__pyx_r = NULL;
  1365. PyObject *__pyx_t_1 = NULL;
  1366. PyObject *__pyx_t_2 = NULL;
  1367. int __pyx_t_3;
  1368. int __pyx_t_4;
  1369. int __pyx_t_5;
  1370. __Pyx_RefNannySetupContext("_send_copy");
  1371. if (__pyx_optional_args) {
  1372. if (__pyx_optional_args->__pyx_n > 0) {
  1373. __pyx_v_flags = __pyx_optional_args->flags;
  1374. }
  1375. }
  1376. /* "zmq/core/socket.pyx":129
  1377. * cdef zmq_msg_t data
  1378. * cdef char *msg_c
  1379. * cdef Py_ssize_t msg_c_len=0 # <<<<<<<<<<<<<<
  1380. *
  1381. * # copy to c array:
  1382. */
  1383. __pyx_v_msg_c_len = 0;
  1384. /* "zmq/core/socket.pyx":132
  1385. *
  1386. * # copy to c array:
  1387. * asbuffer_r(msg, <void **>&msg_c, &msg_c_len) # <<<<<<<<<<<<<<
  1388. *
  1389. * # Copy the msg before sending. This avoids any complications with
  1390. */
  1391. __pyx_t_1 = __pyx_v_msg;
  1392. __Pyx_INCREF(__pyx_t_1);
  1393. __pyx_t_2 = __pyx_f_7buffers_asbuffer_r(__pyx_t_1, ((void **)(&__pyx_v_msg_c)), (&__pyx_v_msg_c_len)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1394. __Pyx_GOTREF(__pyx_t_2);
  1395. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1396. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1397. /* "zmq/core/socket.pyx":137
  1398. * # the GIL, etc.
  1399. * # If zmq_msg_init_* fails we must not call zmq_msg_close (Bus Error)
  1400. * with nogil: # <<<<<<<<<<<<<<
  1401. * rc = zmq_msg_init_size(&data, msg_c_len)
  1402. * memcpy(zmq_msg_data(&data), msg_c, zmq_msg_size(&data))
  1403. */
  1404. {
  1405. #ifdef WITH_THREAD
  1406. PyThreadState *_save;
  1407. #endif
  1408. Py_UNBLOCK_THREADS
  1409. /*try:*/ {
  1410. /* "zmq/core/socket.pyx":138
  1411. * # If zmq_msg_init_* fails we must not call zmq_msg_close (Bus Error)
  1412. * with nogil:
  1413. * rc = zmq_msg_init_size(&data, msg_c_len) # <<<<<<<<<<<<<<
  1414. * memcpy(zmq_msg_data(&data), msg_c, zmq_msg_size(&data))
  1415. *
  1416. */
  1417. __pyx_v_rc = zmq_msg_init_size((&__pyx_v_data), __pyx_v_msg_c_len);
  1418. /* "zmq/core/socket.pyx":139
  1419. * with nogil:
  1420. * rc = zmq_msg_init_size(&data, msg_c_len)
  1421. * memcpy(zmq_msg_data(&data), msg_c, zmq_msg_size(&data)) # <<<<<<<<<<<<<<
  1422. *
  1423. * if rc != 0:
  1424. */
  1425. memcpy(zmq_msg_data((&__pyx_v_data)), __pyx_v_msg_c, zmq_msg_size((&__pyx_v_data)));
  1426. }
  1427. /* "zmq/core/socket.pyx":137
  1428. * # the GIL, etc.
  1429. * # If zmq_msg_init_* fails we must not call zmq_msg_close (Bus Error)
  1430. * with nogil: # <<<<<<<<<<<<<<
  1431. * rc = zmq_msg_init_size(&data, msg_c_len)
  1432. * memcpy(zmq_msg_data(&data), msg_c, zmq_msg_size(&data))
  1433. */
  1434. /*finally:*/ {
  1435. Py_BLOCK_THREADS
  1436. }
  1437. }
  1438. /* "zmq/core/socket.pyx":141
  1439. * memcpy(zmq_msg_data(&data), msg_c, zmq_msg_size(&data))
  1440. *
  1441. * if rc != 0: # <<<<<<<<<<<<<<
  1442. * raise ZMQError()
  1443. *
  1444. */
  1445. __pyx_t_3 = (__pyx_v_rc != 0);
  1446. if (__pyx_t_3) {
  1447. /* "zmq/core/socket.pyx":142
  1448. *
  1449. * if rc != 0:
  1450. * raise ZMQError() # <<<<<<<<<<<<<<
  1451. *
  1452. * with nogil:
  1453. */
  1454. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1455. __Pyx_GOTREF(__pyx_t_2);
  1456. __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1457. __Pyx_GOTREF(__pyx_t_1);
  1458. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1459. __Pyx_Raise(__pyx_t_1, 0, 0);
  1460. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1461. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1462. goto __pyx_L6;
  1463. }
  1464. __pyx_L6:;
  1465. /* "zmq/core/socket.pyx":144
  1466. * raise ZMQError()
  1467. *
  1468. * with nogil: # <<<<<<<<<<<<<<
  1469. * rc = zmq_sendmsg(handle, &data, flags)
  1470. * rc2 = zmq_msg_close(&data)
  1471. */
  1472. {
  1473. #ifdef WITH_THREAD
  1474. PyThreadState *_save;
  1475. #endif
  1476. Py_UNBLOCK_THREADS
  1477. /*try:*/ {
  1478. /* "zmq/core/socket.pyx":145
  1479. *
  1480. * with nogil:
  1481. * rc = zmq_sendmsg(handle, &data, flags) # <<<<<<<<<<<<<<
  1482. * rc2 = zmq_msg_close(&data)
  1483. * if rc < 0 or rc2 != 0:
  1484. */
  1485. __pyx_v_rc = zmq_sendmsg(__pyx_v_handle, (&__pyx_v_data), __pyx_v_flags);
  1486. /* "zmq/core/socket.pyx":146
  1487. * with nogil:
  1488. * rc = zmq_sendmsg(handle, &data, flags)
  1489. * rc2 = zmq_msg_close(&data) # <<<<<<<<<<<<<<
  1490. * if rc < 0 or rc2 != 0:
  1491. * raise ZMQError()
  1492. */
  1493. __pyx_v_rc2 = zmq_msg_close((&__pyx_v_data));
  1494. }
  1495. /* "zmq/core/socket.pyx":144
  1496. * raise ZMQError()
  1497. *
  1498. * with nogil: # <<<<<<<<<<<<<<
  1499. * rc = zmq_sendmsg(handle, &data, flags)
  1500. * rc2 = zmq_msg_close(&data)
  1501. */
  1502. /*finally:*/ {
  1503. Py_BLOCK_THREADS
  1504. }
  1505. }
  1506. /* "zmq/core/socket.pyx":147
  1507. * rc = zmq_sendmsg(handle, &data, flags)
  1508. * rc2 = zmq_msg_close(&data)
  1509. * if rc < 0 or rc2 != 0: # <<<<<<<<<<<<<<
  1510. * raise ZMQError()
  1511. *
  1512. */
  1513. __pyx_t_3 = (__pyx_v_rc < 0);
  1514. if (!__pyx_t_3) {
  1515. __pyx_t_4 = (__pyx_v_rc2 != 0);
  1516. __pyx_t_5 = __pyx_t_4;
  1517. } else {
  1518. __pyx_t_5 = __pyx_t_3;
  1519. }
  1520. if (__pyx_t_5) {
  1521. /* "zmq/core/socket.pyx":148
  1522. * rc2 = zmq_msg_close(&data)
  1523. * if rc < 0 or rc2 != 0:
  1524. * raise ZMQError() # <<<<<<<<<<<<<<
  1525. *
  1526. *
  1527. */
  1528. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1529. __Pyx_GOTREF(__pyx_t_1);
  1530. __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1531. __Pyx_GOTREF(__pyx_t_2);
  1532. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1533. __Pyx_Raise(__pyx_t_2, 0, 0);
  1534. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1535. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1536. goto __pyx_L10;
  1537. }
  1538. __pyx_L10:;
  1539. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  1540. goto __pyx_L0;
  1541. __pyx_L1_error:;
  1542. __Pyx_XDECREF(__pyx_t_1);
  1543. __Pyx_XDECREF(__pyx_t_2);
  1544. __Pyx_AddTraceback("zmq.core.socket._send_copy");
  1545. __pyx_r = 0;
  1546. __pyx_L0:;
  1547. __Pyx_XGIVEREF(__pyx_r);
  1548. __Pyx_RefNannyFinishContext();
  1549. return __pyx_r;
  1550. }
  1551. /* "zmq/core/socket.pyx":171
  1552. * """
  1553. *
  1554. * def __cinit__(self, object context, int socket_type): # <<<<<<<<<<<<<<
  1555. * cdef Py_ssize_t c_handle
  1556. * c_handle = context._handle
  1557. */
  1558. static int __pyx_pf_3zmq_4core_6socket_6Socket___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1559. static int __pyx_pf_3zmq_4core_6socket_6Socket___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1560. PyObject *__pyx_v_context = 0;
  1561. int __pyx_v_socket_type;
  1562. Py_ssize_t __pyx_v_c_handle;
  1563. int __pyx_r;
  1564. PyObject *__pyx_t_1 = NULL;
  1565. Py_ssize_t __pyx_t_2;
  1566. int __pyx_t_3;
  1567. PyObject *__pyx_t_4 = NULL;
  1568. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__context,&__pyx_n_s__socket_type,0};
  1569. __Pyx_RefNannySetupContext("__cinit__");
  1570. if (unlikely(__pyx_kwds)) {
  1571. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  1572. PyObject* values[2] = {0,0};
  1573. switch (PyTuple_GET_SIZE(__pyx_args)) {
  1574. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1575. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1576. case 0: break;
  1577. default: goto __pyx_L5_argtuple_error;
  1578. }
  1579. switch (PyTuple_GET_SIZE(__pyx_args)) {
  1580. case 0:
  1581. values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__context);
  1582. if (likely(values[0])) kw_args--;
  1583. else goto __pyx_L5_argtuple_error;
  1584. case 1:
  1585. values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__socket_type);
  1586. if (likely(values[1])) kw_args--;
  1587. else {
  1588. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1589. }
  1590. }
  1591. if (unlikely(kw_args > 0)) {
  1592. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1593. }
  1594. __pyx_v_context = values[0];
  1595. __pyx_v_socket_type = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_socket_type == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1596. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  1597. goto __pyx_L5_argtuple_error;
  1598. } else {
  1599. __pyx_v_context = PyTuple_GET_ITEM(__pyx_args, 0);
  1600. __pyx_v_socket_type = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_socket_type == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1601. }
  1602. goto __pyx_L4_argument_unpacking_done;
  1603. __pyx_L5_argtuple_error:;
  1604. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1605. __pyx_L3_error:;
  1606. __Pyx_AddTraceback("zmq.core.socket.Socket.__cinit__");
  1607. __Pyx_RefNannyFinishContext();
  1608. return -1;
  1609. __pyx_L4_argument_unpacking_done:;
  1610. /* "zmq/core/socket.pyx":173
  1611. * def __cinit__(self, object context, int socket_type):
  1612. * cdef Py_ssize_t c_handle
  1613. * c_handle = context._handle # <<<<<<<<<<<<<<
  1614. *
  1615. * self.handle = NULL
  1616. */
  1617. __pyx_t_1 = PyObject_GetAttr(__pyx_v_context, __pyx_n_s___handle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1618. __Pyx_GOTREF(__pyx_t_1);
  1619. __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1620. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1621. __pyx_v_c_handle = __pyx_t_2;
  1622. /* "zmq/core/socket.pyx":175
  1623. * c_handle = context._handle
  1624. *
  1625. * self.handle = NULL # <<<<<<<<<<<<<<
  1626. * self.context = context
  1627. * self.socket_type = socket_type
  1628. */
  1629. ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle = NULL;
  1630. /* "zmq/core/socket.pyx":176
  1631. *
  1632. * self.handle = NULL
  1633. * self.context = context # <<<<<<<<<<<<<<
  1634. * self.socket_type = socket_type
  1635. * with nogil:
  1636. */
  1637. __Pyx_INCREF(__pyx_v_context);
  1638. __Pyx_GIVEREF(__pyx_v_context);
  1639. __Pyx_GOTREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context);
  1640. __Pyx_DECREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context);
  1641. ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context = __pyx_v_context;
  1642. /* "zmq/core/socket.pyx":177
  1643. * self.handle = NULL
  1644. * self.context = context
  1645. * self.socket_type = socket_type # <<<<<<<<<<<<<<
  1646. * with nogil:
  1647. * self.handle = zmq_socket(<void *>c_handle, socket_type)
  1648. */
  1649. ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->socket_type = __pyx_v_socket_type;
  1650. /* "zmq/core/socket.pyx":178
  1651. * self.context = context
  1652. * self.socket_type = socket_type
  1653. * with nogil: # <<<<<<<<<<<<<<
  1654. * self.handle = zmq_socket(<void *>c_handle, socket_type)
  1655. * if self.handle == NULL:
  1656. */
  1657. {
  1658. #ifdef WITH_THREAD
  1659. PyThreadState *_save;
  1660. #endif
  1661. Py_UNBLOCK_THREADS
  1662. /*try:*/ {
  1663. /* "zmq/core/socket.pyx":179
  1664. * self.socket_type = socket_type
  1665. * with nogil:
  1666. * self.handle = zmq_socket(<void *>c_handle, socket_type) # <<<<<<<<<<<<<<
  1667. * if self.handle == NULL:
  1668. * raise ZMQError()
  1669. */
  1670. ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle = zmq_socket(((void *)__pyx_v_c_handle), __pyx_v_socket_type);
  1671. }
  1672. /* "zmq/core/socket.pyx":178
  1673. * self.context = context
  1674. * self.socket_type = socket_type
  1675. * with nogil: # <<<<<<<<<<<<<<
  1676. * self.handle = zmq_socket(<void *>c_handle, socket_type)
  1677. * if self.handle == NULL:
  1678. */
  1679. /*finally:*/ {
  1680. Py_BLOCK_THREADS
  1681. }
  1682. }
  1683. /* "zmq/core/socket.pyx":180
  1684. * with nogil:
  1685. * self.handle = zmq_socket(<void *>c_handle, socket_type)
  1686. * if self.handle == NULL: # <<<<<<<<<<<<<<
  1687. * raise ZMQError()
  1688. * self.closed = False
  1689. */
  1690. __pyx_t_3 = (((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle == NULL);
  1691. if (__pyx_t_3) {
  1692. /* "zmq/core/socket.pyx":181
  1693. * self.handle = zmq_socket(<void *>c_handle, socket_type)
  1694. * if self.handle == NULL:
  1695. * raise ZMQError() # <<<<<<<<<<<<<<
  1696. * self.closed = False
  1697. *
  1698. */
  1699. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1700. __Pyx_GOTREF(__pyx_t_1);
  1701. __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1702. __Pyx_GOTREF(__pyx_t_4);
  1703. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1704. __Pyx_Raise(__pyx_t_4, 0, 0);
  1705. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1706. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1707. goto __pyx_L9;
  1708. }
  1709. __pyx_L9:;
  1710. /* "zmq/core/socket.pyx":182
  1711. * if self.handle == NULL:
  1712. * raise ZMQError()
  1713. * self.closed = False # <<<<<<<<<<<<<<
  1714. *
  1715. * def __dealloc__(self):
  1716. */
  1717. __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1718. __Pyx_GOTREF(__pyx_t_4);
  1719. __Pyx_GIVEREF(__pyx_t_4);
  1720. __Pyx_GOTREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed);
  1721. __Pyx_DECREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed);
  1722. ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed = __pyx_t_4;
  1723. __pyx_t_4 = 0;
  1724. __pyx_r = 0;
  1725. goto __pyx_L0;
  1726. __pyx_L1_error:;
  1727. __Pyx_XDECREF(__pyx_t_1);
  1728. __Pyx_XDECREF(__pyx_t_4);
  1729. __Pyx_AddTraceback("zmq.core.socket.Socket.__cinit__");
  1730. __pyx_r = -1;
  1731. __pyx_L0:;
  1732. __Pyx_RefNannyFinishContext();
  1733. return __pyx_r;
  1734. }
  1735. /* "zmq/core/socket.pyx":184
  1736. * self.closed = False
  1737. *
  1738. * def __dealloc__(self): # <<<<<<<<<<<<<<
  1739. * self.close()
  1740. *
  1741. */
  1742. static void __pyx_pf_3zmq_4core_6socket_6Socket_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
  1743. static void __pyx_pf_3zmq_4core_6socket_6Socket_1__dealloc__(PyObject *__pyx_v_self) {
  1744. PyObject *__pyx_t_1 = NULL;
  1745. PyObject *__pyx_t_2 = NULL;
  1746. __Pyx_RefNannySetupContext("__dealloc__");
  1747. /* "zmq/core/socket.pyx":185
  1748. *
  1749. * def __dealloc__(self):
  1750. * self.close() # <<<<<<<<<<<<<<
  1751. *
  1752. * def close(self):
  1753. */
  1754. __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1755. __Pyx_GOTREF(__pyx_t_1);
  1756. __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1757. __Pyx_GOTREF(__pyx_t_2);
  1758. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1759. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1760. goto __pyx_L0;
  1761. __pyx_L1_error:;
  1762. __Pyx_XDECREF(__pyx_t_1);
  1763. __Pyx_XDECREF(__pyx_t_2);
  1764. __Pyx_AddTraceback("zmq.core.socket.Socket.__dealloc__");
  1765. __pyx_L0:;
  1766. __Pyx_RefNannyFinishContext();
  1767. }
  1768. /* "zmq/core/socket.pyx":187
  1769. * self.close()
  1770. *
  1771. * def close(self): # <<<<<<<<<<<<<<
  1772. * """s.close()
  1773. *
  1774. */
  1775. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_2close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  1776. static char __pyx_doc_3zmq_4core_6socket_6Socket_2close[] = "s.close()\n\n Close the socket.\n\n This can be called to close the socket by hand. If this is not\n called, the socket will automatically be closed when it is\n garbage collected.\n ";
  1777. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_2close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  1778. int __pyx_v_rc;
  1779. PyObject *__pyx_r = NULL;
  1780. int __pyx_t_1;
  1781. int __pyx_t_2;
  1782. int __pyx_t_3;
  1783. PyObject *__pyx_t_4 = NULL;
  1784. PyObject *__pyx_t_5 = NULL;
  1785. __Pyx_RefNannySetupContext("close");
  1786. /* "zmq/core/socket.pyx":197
  1787. * """
  1788. * cdef int rc
  1789. * if self.handle != NULL and not self.closed: # <<<<<<<<<<<<<<
  1790. * with nogil:
  1791. * rc = zmq_close(self.handle)
  1792. */
  1793. __pyx_t_1 = (((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle != NULL);
  1794. if (__pyx_t_1) {
  1795. __pyx_t_2 = __Pyx_PyObject_IsTrue(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1796. __pyx_t_3 = (!__pyx_t_2);
  1797. __pyx_t_2 = __pyx_t_3;
  1798. } else {
  1799. __pyx_t_2 = __pyx_t_1;
  1800. }
  1801. if (__pyx_t_2) {
  1802. /* "zmq/core/socket.pyx":198
  1803. * cdef int rc
  1804. * if self.handle != NULL and not self.closed:
  1805. * with nogil: # <<<<<<<<<<<<<<
  1806. * rc = zmq_close(self.handle)
  1807. * if rc != 0:
  1808. */
  1809. {
  1810. #ifdef WITH_THREAD
  1811. PyThreadState *_save;
  1812. #endif
  1813. Py_UNBLOCK_THREADS
  1814. /*try:*/ {
  1815. /* "zmq/core/socket.pyx":199
  1816. * if self.handle != NULL and not self.closed:
  1817. * with nogil:
  1818. * rc = zmq_close(self.handle) # <<<<<<<<<<<<<<
  1819. * if rc != 0:
  1820. * raise ZMQError()
  1821. */
  1822. __pyx_v_rc = zmq_close(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle);
  1823. }
  1824. /* "zmq/core/socket.pyx":198
  1825. * cdef int rc
  1826. * if self.handle != NULL and not self.closed:
  1827. * with nogil: # <<<<<<<<<<<<<<
  1828. * rc = zmq_close(self.handle)
  1829. * if rc != 0:
  1830. */
  1831. /*finally:*/ {
  1832. Py_BLOCK_THREADS
  1833. }
  1834. }
  1835. /* "zmq/core/socket.pyx":200
  1836. * with nogil:
  1837. * rc = zmq_close(self.handle)
  1838. * if rc != 0: # <<<<<<<<<<<<<<
  1839. * raise ZMQError()
  1840. * self.handle = NULL
  1841. */
  1842. __pyx_t_2 = (__pyx_v_rc != 0);
  1843. if (__pyx_t_2) {
  1844. /* "zmq/core/socket.pyx":201
  1845. * rc = zmq_close(self.handle)
  1846. * if rc != 0:
  1847. * raise ZMQError() # <<<<<<<<<<<<<<
  1848. * self.handle = NULL
  1849. * self.closed = True
  1850. */
  1851. __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1852. __Pyx_GOTREF(__pyx_t_4);
  1853. __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1854. __Pyx_GOTREF(__pyx_t_5);
  1855. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1856. __Pyx_Raise(__pyx_t_5, 0, 0);
  1857. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1858. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1859. goto __pyx_L9;
  1860. }
  1861. __pyx_L9:;
  1862. /* "zmq/core/socket.pyx":202
  1863. * if rc != 0:
  1864. * raise ZMQError()
  1865. * self.handle = NULL # <<<<<<<<<<<<<<
  1866. * self.closed = True
  1867. *
  1868. */
  1869. ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle = NULL;
  1870. /* "zmq/core/socket.pyx":203
  1871. * raise ZMQError()
  1872. * self.handle = NULL
  1873. * self.closed = True # <<<<<<<<<<<<<<
  1874. *
  1875. * def setsockopt(self, int option, optval):
  1876. */
  1877. __pyx_t_5 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1878. __Pyx_GOTREF(__pyx_t_5);
  1879. __Pyx_GIVEREF(__pyx_t_5);
  1880. __Pyx_GOTREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed);
  1881. __Pyx_DECREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed);
  1882. ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed = __pyx_t_5;
  1883. __pyx_t_5 = 0;
  1884. goto __pyx_L5;
  1885. }
  1886. __pyx_L5:;
  1887. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  1888. goto __pyx_L0;
  1889. __pyx_L1_error:;
  1890. __Pyx_XDECREF(__pyx_t_4);
  1891. __Pyx_XDECREF(__pyx_t_5);
  1892. __Pyx_AddTraceback("zmq.core.socket.Socket.close");
  1893. __pyx_r = NULL;
  1894. __pyx_L0:;
  1895. __Pyx_XGIVEREF(__pyx_r);
  1896. __Pyx_RefNannyFinishContext();
  1897. return __pyx_r;
  1898. }
  1899. /* "zmq/core/socket.pyx":205
  1900. * self.closed = True
  1901. *
  1902. * def setsockopt(self, int option, optval): # <<<<<<<<<<<<<<
  1903. * """s.setsockopt(option, optval)
  1904. *
  1905. */
  1906. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_3setsockopt(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1907. static char __pyx_doc_3zmq_4core_6socket_6Socket_3setsockopt[] = "s.setsockopt(option, optval)\n\n Set socket options.\n\n See the 0MQ documentation for details on specific options.\n\n Parameters\n ----------\n option : str\n The name of the option to set. Can be any of: SUBSCRIBE, \n UNSUBSCRIBE, IDENTITY, HWM, SWAP, AFFINITY, RATE, \n RECOVERY_IVL, MCAST_LOOP, SNDBUF, RCVBUF.\n optval : int or str\n The value of the option to set.\n ";
  1908. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_3setsockopt(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1909. int __pyx_v_option;
  1910. PyObject *__pyx_v_optval = 0;
  1911. pyzmq_int64_t __pyx_v_optval_int64_c;
  1912. int __pyx_v_optval_int_c;
  1913. int __pyx_v_rc;
  1914. char *__pyx_v_optval_c;
  1915. Py_ssize_t __pyx_v_sz;
  1916. PyObject *__pyx_r = NULL;
  1917. PyObject *__pyx_t_1 = NULL;
  1918. PyObject *__pyx_t_2 = NULL;
  1919. int __pyx_t_3;
  1920. PyObject *__pyx_t_4 = NULL;
  1921. int __pyx_t_5;
  1922. char *__pyx_t_6;
  1923. Py_ssize_t __pyx_t_7;
  1924. pyzmq_int64_t __pyx_t_8;
  1925. int __pyx_t_9;
  1926. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__option,&__pyx_n_s__optval,0};
  1927. __Pyx_RefNannySetupContext("setsockopt");
  1928. if (unlikely(__pyx_kwds)) {
  1929. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  1930. PyObject* values[2] = {0,0};
  1931. switch (PyTuple_GET_SIZE(__pyx_args)) {
  1932. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1933. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1934. case 0: break;
  1935. default: goto __pyx_L5_argtuple_error;
  1936. }
  1937. switch (PyTuple_GET_SIZE(__pyx_args)) {
  1938. case 0:
  1939. values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__option);
  1940. if (likely(values[0])) kw_args--;
  1941. else goto __pyx_L5_argtuple_error;
  1942. case 1:
  1943. values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__optval);
  1944. if (likely(values[1])) kw_args--;
  1945. else {
  1946. __Pyx_RaiseArgtupleInvalid("setsockopt", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1947. }
  1948. }
  1949. if (unlikely(kw_args > 0)) {
  1950. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setsockopt") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1951. }
  1952. __pyx_v_option = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_option == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1953. __pyx_v_optval = values[1];
  1954. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  1955. goto __pyx_L5_argtuple_error;
  1956. } else {
  1957. __pyx_v_option = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_option == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1958. __pyx_v_optval = PyTuple_GET_ITEM(__pyx_args, 1);
  1959. }
  1960. goto __pyx_L4_argument_unpacking_done;
  1961. __pyx_L5_argtuple_error:;
  1962. __Pyx_RaiseArgtupleInvalid("setsockopt", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1963. __pyx_L3_error:;
  1964. __Pyx_AddTraceback("zmq.core.socket.Socket.setsockopt");
  1965. __Pyx_RefNannyFinishContext();
  1966. return NULL;
  1967. __pyx_L4_argument_unpacking_done:;
  1968. /* "zmq/core/socket.pyx":227
  1969. * cdef Py_ssize_t sz
  1970. *
  1971. * _check_closed(self) # <<<<<<<<<<<<<<
  1972. * if isinstance(optval, unicode):
  1973. * raise TypeError("unicode not allowed, use setsockopt_unicode")
  1974. */
  1975. __pyx_t_1 = __pyx_v_self;
  1976. __Pyx_INCREF(__pyx_t_1);
  1977. __pyx_t_2 = __pyx_f_3zmq_4core_6socket__check_closed(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1978. __Pyx_GOTREF(__pyx_t_2);
  1979. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1980. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1981. /* "zmq/core/socket.pyx":228
  1982. *
  1983. * _check_closed(self)
  1984. * if isinstance(optval, unicode): # <<<<<<<<<<<<<<
  1985. * raise TypeError("unicode not allowed, use setsockopt_unicode")
  1986. *
  1987. */
  1988. __pyx_t_2 = __pyx_v_optval;
  1989. __Pyx_INCREF(__pyx_t_2);
  1990. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__unicode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1991. __Pyx_GOTREF(__pyx_t_1);
  1992. __pyx_t_3 = PyObject_IsInstance(__pyx_t_2, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1993. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1994. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1995. if (__pyx_t_3) {
  1996. /* "zmq/core/socket.pyx":229
  1997. * _check_closed(self)
  1998. * if isinstance(optval, unicode):
  1999. * raise TypeError("unicode not allowed, use setsockopt_unicode") # <<<<<<<<<<<<<<
  2000. *
  2001. * if option in constants.bytes_sockopts:
  2002. */
  2003. __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2004. __Pyx_GOTREF(__pyx_t_1);
  2005. __Pyx_Raise(__pyx_t_1, 0, 0);
  2006. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2007. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2008. goto __pyx_L6;
  2009. }
  2010. __pyx_L6:;
  2011. /* "zmq/core/socket.pyx":231
  2012. * raise TypeError("unicode not allowed, use setsockopt_unicode")
  2013. *
  2014. * if option in constants.bytes_sockopts: # <<<<<<<<<<<<<<
  2015. * if not isinstance(optval, bytes):
  2016. * raise TypeError('expected str, got: %r' % optval)
  2017. */
  2018. __pyx_t_1 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2019. __Pyx_GOTREF(__pyx_t_1);
  2020. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__constants); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2021. __Pyx_GOTREF(__pyx_t_2);
  2022. __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__bytes_sockopts); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2023. __Pyx_GOTREF(__pyx_t_4);
  2024. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2025. __pyx_t_3 = ((PySequence_Contains(__pyx_t_4, __pyx_t_1))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2026. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2027. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2028. if (__pyx_t_3) {
  2029. /* "zmq/core/socket.pyx":232
  2030. *
  2031. * if option in constants.bytes_sockopts:
  2032. * if not isinstance(optval, bytes): # <<<<<<<<<<<<<<
  2033. * raise TypeError('expected str, got: %r' % optval)
  2034. * optval_c = PyBytes_AsString(optval)
  2035. */
  2036. __pyx_t_4 = __pyx_v_optval;
  2037. __Pyx_INCREF(__pyx_t_4);
  2038. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__bytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2039. __Pyx_GOTREF(__pyx_t_1);
  2040. __pyx_t_3 = PyObject_IsInstance(__pyx_t_4, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2041. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2042. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2043. __pyx_t_5 = (!__pyx_t_3);
  2044. if (__pyx_t_5) {
  2045. /* "zmq/core/socket.pyx":233
  2046. * if option in constants.bytes_sockopts:
  2047. * if not isinstance(optval, bytes):
  2048. * raise TypeError('expected str, got: %r' % optval) # <<<<<<<<<<<<<<
  2049. * optval_c = PyBytes_AsString(optval)
  2050. * sz = PyBytes_Size(optval)
  2051. */
  2052. __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), __pyx_v_optval); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2053. __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  2054. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2055. __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  2056. PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1));
  2057. __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  2058. __pyx_t_1 = 0;
  2059. __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2060. __Pyx_GOTREF(__pyx_t_1);
  2061. __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  2062. __Pyx_Raise(__pyx_t_1, 0, 0);
  2063. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2064. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2065. goto __pyx_L8;
  2066. }
  2067. __pyx_L8:;
  2068. /* "zmq/core/socket.pyx":234
  2069. * if not isinstance(optval, bytes):
  2070. * raise TypeError('expected str, got: %r' % optval)
  2071. * optval_c = PyBytes_AsString(optval) # <<<<<<<<<<<<<<
  2072. * sz = PyBytes_Size(optval)
  2073. * with nogil:
  2074. */
  2075. __pyx_t_1 = __pyx_v_optval;
  2076. __Pyx_INCREF(__pyx_t_1);
  2077. __pyx_t_6 = PyBytes_AsString(__pyx_t_1); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2078. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2079. __pyx_v_optval_c = __pyx_t_6;
  2080. /* "zmq/core/socket.pyx":235
  2081. * raise TypeError('expected str, got: %r' % optval)
  2082. * optval_c = PyBytes_AsString(optval)
  2083. * sz = PyBytes_Size(optval) # <<<<<<<<<<<<<<
  2084. * with nogil:
  2085. * rc = zmq_setsockopt(
  2086. */
  2087. __pyx_t_1 = __pyx_v_optval;
  2088. __Pyx_INCREF(__pyx_t_1);
  2089. __pyx_t_7 = PyBytes_Size(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2090. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2091. __pyx_v_sz = __pyx_t_7;
  2092. /* "zmq/core/socket.pyx":236
  2093. * optval_c = PyBytes_AsString(optval)
  2094. * sz = PyBytes_Size(optval)
  2095. * with nogil: # <<<<<<<<<<<<<<
  2096. * rc = zmq_setsockopt(
  2097. * self.handle, option,
  2098. */
  2099. {
  2100. #ifdef WITH_THREAD
  2101. PyThreadState *_save;
  2102. #endif
  2103. Py_UNBLOCK_THREADS
  2104. /*try:*/ {
  2105. /* "zmq/core/socket.pyx":240
  2106. * self.handle, option,
  2107. * optval_c, sz
  2108. * ) # <<<<<<<<<<<<<<
  2109. * elif option in constants.int64_sockopts:
  2110. * if not isinstance(optval, int):
  2111. */
  2112. __pyx_v_rc = zmq_setsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_option, __pyx_v_optval_c, __pyx_v_sz);
  2113. }
  2114. /* "zmq/core/socket.pyx":236
  2115. * optval_c = PyBytes_AsString(optval)
  2116. * sz = PyBytes_Size(optval)
  2117. * with nogil: # <<<<<<<<<<<<<<
  2118. * rc = zmq_setsockopt(
  2119. * self.handle, option,
  2120. */
  2121. /*finally:*/ {
  2122. Py_BLOCK_THREADS
  2123. }
  2124. }
  2125. goto __pyx_L7;
  2126. }
  2127. /* "zmq/core/socket.pyx":241
  2128. * optval_c, sz
  2129. * )
  2130. * elif option in constants.int64_sockopts: # <<<<<<<<<<<<<<
  2131. * if not isinstance(optval, int):
  2132. * raise TypeError('expected int, got: %r' % optval)
  2133. */
  2134. __pyx_t_1 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2135. __Pyx_GOTREF(__pyx_t_1);
  2136. __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__constants); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2137. __Pyx_GOTREF(__pyx_t_4);
  2138. __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__int64_sockopts); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2139. __Pyx_GOTREF(__pyx_t_2);
  2140. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2141. __pyx_t_5 = ((PySequence_Contains(__pyx_t_2, __pyx_t_1))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2142. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2143. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2144. if (__pyx_t_5) {
  2145. /* "zmq/core/socket.pyx":242
  2146. * )
  2147. * elif option in constants.int64_sockopts:
  2148. * if not isinstance(optval, int): # <<<<<<<<<<<<<<
  2149. * raise TypeError('expected int, got: %r' % optval)
  2150. * optval_int64_c = optval
  2151. */
  2152. __pyx_t_2 = __pyx_v_optval;
  2153. __Pyx_INCREF(__pyx_t_2);
  2154. __pyx_t_1 = ((PyObject *)((PyObject*)(&PyInt_Type)));
  2155. __Pyx_INCREF(__pyx_t_1);
  2156. __pyx_t_5 = __Pyx_TypeCheck(__pyx_t_2, __pyx_t_1);
  2157. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2158. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2159. __pyx_t_3 = (!__pyx_t_5);
  2160. if (__pyx_t_3) {
  2161. /* "zmq/core/socket.pyx":243
  2162. * elif option in constants.int64_sockopts:
  2163. * if not isinstance(optval, int):
  2164. * raise TypeError('expected int, got: %r' % optval) # <<<<<<<<<<<<<<
  2165. * optval_int64_c = optval
  2166. * with nogil:
  2167. */
  2168. __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_v_optval); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2169. __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  2170. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2171. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  2172. PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
  2173. __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  2174. __pyx_t_1 = 0;
  2175. __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2176. __Pyx_GOTREF(__pyx_t_1);
  2177. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  2178. __Pyx_Raise(__pyx_t_1, 0, 0);
  2179. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2180. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2181. goto __pyx_L12;
  2182. }
  2183. __pyx_L12:;
  2184. /* "zmq/core/socket.pyx":244
  2185. * if not isinstance(optval, int):
  2186. * raise TypeError('expected int, got: %r' % optval)
  2187. * optval_int64_c = optval # <<<<<<<<<<<<<<
  2188. * with nogil:
  2189. * rc = zmq_setsockopt(
  2190. */
  2191. __pyx_t_8 = __Pyx_PyInt_from_py_pyzmq_int64_t(__pyx_v_optval); if (unlikely((__pyx_t_8 == (pyzmq_int64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2192. __pyx_v_optval_int64_c = __pyx_t_8;
  2193. /* "zmq/core/socket.pyx":245
  2194. * raise TypeError('expected int, got: %r' % optval)
  2195. * optval_int64_c = optval
  2196. * with nogil: # <<<<<<<<<<<<<<
  2197. * rc = zmq_setsockopt(
  2198. * self.handle, option,
  2199. */
  2200. {
  2201. #ifdef WITH_THREAD
  2202. PyThreadState *_save;
  2203. #endif
  2204. Py_UNBLOCK_THREADS
  2205. /*try:*/ {
  2206. /* "zmq/core/socket.pyx":248
  2207. * rc = zmq_setsockopt(
  2208. * self.handle, option,
  2209. * &optval_int64_c, sizeof(int64_t) # <<<<<<<<<<<<<<
  2210. * )
  2211. * elif option in constants.int_sockopts:
  2212. */
  2213. __pyx_v_rc = zmq_setsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_option, (&__pyx_v_optval_int64_c), (sizeof(pyzmq_int64_t)));
  2214. }
  2215. /* "zmq/core/socket.pyx":245
  2216. * raise TypeError('expected int, got: %r' % optval)
  2217. * optval_int64_c = optval
  2218. * with nogil: # <<<<<<<<<<<<<<
  2219. * rc = zmq_setsockopt(
  2220. * self.handle, option,
  2221. */
  2222. /*finally:*/ {
  2223. Py_BLOCK_THREADS
  2224. }
  2225. }
  2226. goto __pyx_L7;
  2227. }
  2228. /* "zmq/core/socket.pyx":250
  2229. * &optval_int64_c, sizeof(int64_t)
  2230. * )
  2231. * elif option in constants.int_sockopts: # <<<<<<<<<<<<<<
  2232. * if not isinstance(optval, int):
  2233. * raise TypeError('expected int, got: %r' % optval)
  2234. */
  2235. __pyx_t_1 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2236. __Pyx_GOTREF(__pyx_t_1);
  2237. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__constants); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2238. __Pyx_GOTREF(__pyx_t_2);
  2239. __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int_sockopts); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2240. __Pyx_GOTREF(__pyx_t_4);
  2241. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2242. __pyx_t_3 = ((PySequence_Contains(__pyx_t_4, __pyx_t_1))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2243. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2244. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2245. if (__pyx_t_3) {
  2246. /* "zmq/core/socket.pyx":251
  2247. * )
  2248. * elif option in constants.int_sockopts:
  2249. * if not isinstance(optval, int): # <<<<<<<<<<<<<<
  2250. * raise TypeError('expected int, got: %r' % optval)
  2251. * optval_int_c = optval
  2252. */
  2253. __pyx_t_4 = __pyx_v_optval;
  2254. __Pyx_INCREF(__pyx_t_4);
  2255. __pyx_t_1 = ((PyObject *)((PyObject*)(&PyInt_Type)));
  2256. __Pyx_INCREF(__pyx_t_1);
  2257. __pyx_t_3 = __Pyx_TypeCheck(__pyx_t_4, __pyx_t_1);
  2258. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2259. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2260. __pyx_t_5 = (!__pyx_t_3);
  2261. if (__pyx_t_5) {
  2262. /* "zmq/core/socket.pyx":252
  2263. * elif option in constants.int_sockopts:
  2264. * if not isinstance(optval, int):
  2265. * raise TypeError('expected int, got: %r' % optval) # <<<<<<<<<<<<<<
  2266. * optval_int_c = optval
  2267. * with nogil:
  2268. */
  2269. __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_v_optval); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2270. __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  2271. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2272. __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  2273. PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1));
  2274. __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  2275. __pyx_t_1 = 0;
  2276. __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2277. __Pyx_GOTREF(__pyx_t_1);
  2278. __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  2279. __Pyx_Raise(__pyx_t_1, 0, 0);
  2280. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2281. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2282. goto __pyx_L16;
  2283. }
  2284. __pyx_L16:;
  2285. /* "zmq/core/socket.pyx":253
  2286. * if not isinstance(optval, int):
  2287. * raise TypeError('expected int, got: %r' % optval)
  2288. * optval_int_c = optval # <<<<<<<<<<<<<<
  2289. * with nogil:
  2290. * rc = zmq_setsockopt(
  2291. */
  2292. __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_v_optval); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2293. __pyx_v_optval_int_c = __pyx_t_9;
  2294. /* "zmq/core/socket.pyx":254
  2295. * raise TypeError('expected int, got: %r' % optval)
  2296. * optval_int_c = optval
  2297. * with nogil: # <<<<<<<<<<<<<<
  2298. * rc = zmq_setsockopt(
  2299. * self.handle, option,
  2300. */
  2301. {
  2302. #ifdef WITH_THREAD
  2303. PyThreadState *_save;
  2304. #endif
  2305. Py_UNBLOCK_THREADS
  2306. /*try:*/ {
  2307. /* "zmq/core/socket.pyx":257
  2308. * rc = zmq_setsockopt(
  2309. * self.handle, option,
  2310. * &optval_int_c, sizeof(int) # <<<<<<<<<<<<<<
  2311. * )
  2312. * else:
  2313. */
  2314. __pyx_v_rc = zmq_setsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_option, (&__pyx_v_optval_int_c), (sizeof(int)));
  2315. }
  2316. /* "zmq/core/socket.pyx":254
  2317. * raise TypeError('expected int, got: %r' % optval)
  2318. * optval_int_c = optval
  2319. * with nogil: # <<<<<<<<<<<<<<
  2320. * rc = zmq_setsockopt(
  2321. * self.handle, option,
  2322. */
  2323. /*finally:*/ {
  2324. Py_BLOCK_THREADS
  2325. }
  2326. }
  2327. goto __pyx_L7;
  2328. }
  2329. /*else*/ {
  2330. /* "zmq/core/socket.pyx":260
  2331. * )
  2332. * else:
  2333. * raise ZMQError(EINVAL) # <<<<<<<<<<<<<<
  2334. *
  2335. * if rc != 0:
  2336. */
  2337. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2338. __Pyx_GOTREF(__pyx_t_1);
  2339. __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__EINVAL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2340. __Pyx_GOTREF(__pyx_t_4);
  2341. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2342. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  2343. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  2344. __Pyx_GIVEREF(__pyx_t_4);
  2345. __pyx_t_4 = 0;
  2346. __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2347. __Pyx_GOTREF(__pyx_t_4);
  2348. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2349. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  2350. __Pyx_Raise(__pyx_t_4, 0, 0);
  2351. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2352. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2353. }
  2354. __pyx_L7:;
  2355. /* "zmq/core/socket.pyx":262
  2356. * raise ZMQError(EINVAL)
  2357. *
  2358. * if rc != 0: # <<<<<<<<<<<<<<
  2359. * raise ZMQError()
  2360. *
  2361. */
  2362. __pyx_t_5 = (__pyx_v_rc != 0);
  2363. if (__pyx_t_5) {
  2364. /* "zmq/core/socket.pyx":263
  2365. *
  2366. * if rc != 0:
  2367. * raise ZMQError() # <<<<<<<<<<<<<<
  2368. *
  2369. * def getsockopt(self, int option):
  2370. */
  2371. __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2372. __Pyx_GOTREF(__pyx_t_4);
  2373. __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2374. __Pyx_GOTREF(__pyx_t_2);
  2375. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2376. __Pyx_Raise(__pyx_t_2, 0, 0);
  2377. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2378. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2379. goto __pyx_L20;
  2380. }
  2381. __pyx_L20:;
  2382. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2383. goto __pyx_L0;
  2384. __pyx_L1_error:;
  2385. __Pyx_XDECREF(__pyx_t_1);
  2386. __Pyx_XDECREF(__pyx_t_2);
  2387. __Pyx_XDECREF(__pyx_t_4);
  2388. __Pyx_AddTraceback("zmq.core.socket.Socket.setsockopt");
  2389. __pyx_r = NULL;
  2390. __pyx_L0:;
  2391. __Pyx_XGIVEREF(__pyx_r);
  2392. __Pyx_RefNannyFinishContext();
  2393. return __pyx_r;
  2394. }
  2395. /* "zmq/core/socket.pyx":265
  2396. * raise ZMQError()
  2397. *
  2398. * def getsockopt(self, int option): # <<<<<<<<<<<<<<
  2399. * """s.getsockopt(option)
  2400. *
  2401. */
  2402. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_4getsockopt(PyObject *__pyx_v_self, PyObject *__pyx_arg_option); /*proto*/
  2403. static char __pyx_doc_3zmq_4core_6socket_6Socket_4getsockopt[] = "s.getsockopt(option)\n\n Get the value of a socket option.\n\n See the 0MQ documentation for details on specific options.\n\n Parameters\n ----------\n option : str\n The name of the option to set. Can be any of: \n IDENTITY, HWM, SWAP, AFFINITY, RATE, \n RECOVERY_IVL, MCAST_LOOP, SNDBUF, RCVBUF, RCVMORE.\n\n Returns\n -------\n optval : int, str\n The value of the option as a string or int.\n ";
  2404. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_4getsockopt(PyObject *__pyx_v_self, PyObject *__pyx_arg_option) {
  2405. int __pyx_v_option;
  2406. pyzmq_int64_t __pyx_v_optval_int64_c;
  2407. int __pyx_v_optval_int_c;
  2408. char __pyx_v_identity_str_c[255];
  2409. size_t __pyx_v_sz;
  2410. int __pyx_v_rc;
  2411. PyObject *__pyx_v_result;
  2412. PyObject *__pyx_r = NULL;
  2413. PyObject *__pyx_t_1 = NULL;
  2414. PyObject *__pyx_t_2 = NULL;
  2415. PyObject *__pyx_t_3 = NULL;
  2416. int __pyx_t_4;
  2417. __Pyx_RefNannySetupContext("getsockopt");
  2418. assert(__pyx_arg_option); {
  2419. __pyx_v_option = __Pyx_PyInt_AsInt(__pyx_arg_option); if (unlikely((__pyx_v_option == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2420. }
  2421. goto __pyx_L4_argument_unpacking_done;
  2422. __pyx_L3_error:;
  2423. __Pyx_AddTraceback("zmq.core.socket.Socket.getsockopt");
  2424. __Pyx_RefNannyFinishContext();
  2425. return NULL;
  2426. __pyx_L4_argument_unpacking_done:;
  2427. __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);
  2428. /* "zmq/core/socket.pyx":290
  2429. * cdef int rc
  2430. *
  2431. * _check_closed(self) # <<<<<<<<<<<<<<
  2432. *
  2433. * if option in constants.bytes_sockopts:
  2434. */
  2435. __pyx_t_1 = __pyx_v_self;
  2436. __Pyx_INCREF(__pyx_t_1);
  2437. __pyx_t_2 = __pyx_f_3zmq_4core_6socket__check_closed(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2438. __Pyx_GOTREF(__pyx_t_2);
  2439. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2440. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2441. /* "zmq/core/socket.pyx":292
  2442. * _check_closed(self)
  2443. *
  2444. * if option in constants.bytes_sockopts: # <<<<<<<<<<<<<<
  2445. * sz = 255
  2446. * with nogil:
  2447. */
  2448. __pyx_t_2 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2449. __Pyx_GOTREF(__pyx_t_2);
  2450. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__constants); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2451. __Pyx_GOTREF(__pyx_t_1);
  2452. __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__bytes_sockopts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2453. __Pyx_GOTREF(__pyx_t_3);
  2454. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2455. __pyx_t_4 = ((PySequence_Contains(__pyx_t_3, __pyx_t_2))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2456. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2457. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2458. if (__pyx_t_4) {
  2459. /* "zmq/core/socket.pyx":293
  2460. *
  2461. * if option in constants.bytes_sockopts:
  2462. * sz = 255 # <<<<<<<<<<<<<<
  2463. * with nogil:
  2464. * rc = zmq_getsockopt(self.handle, option, <void *>identity_str_c, &sz)
  2465. */
  2466. __pyx_v_sz = 255;
  2467. /* "zmq/core/socket.pyx":294
  2468. * if option in constants.bytes_sockopts:
  2469. * sz = 255
  2470. * with nogil: # <<<<<<<<<<<<<<
  2471. * rc = zmq_getsockopt(self.handle, option, <void *>identity_str_c, &sz)
  2472. * if rc != 0:
  2473. */
  2474. {
  2475. #ifdef WITH_THREAD
  2476. PyThreadState *_save;
  2477. #endif
  2478. Py_UNBLOCK_THREADS
  2479. /*try:*/ {
  2480. /* "zmq/core/socket.pyx":295
  2481. * sz = 255
  2482. * with nogil:
  2483. * rc = zmq_getsockopt(self.handle, option, <void *>identity_str_c, &sz) # <<<<<<<<<<<<<<
  2484. * if rc != 0:
  2485. * raise ZMQError()
  2486. */
  2487. __pyx_v_rc = zmq_getsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_option, ((void *)__pyx_v_identity_str_c), (&__pyx_v_sz));
  2488. }
  2489. /* "zmq/core/socket.pyx":294
  2490. * if option in constants.bytes_sockopts:
  2491. * sz = 255
  2492. * with nogil: # <<<<<<<<<<<<<<
  2493. * rc = zmq_getsockopt(self.handle, option, <void *>identity_str_c, &sz)
  2494. * if rc != 0:
  2495. */
  2496. /*finally:*/ {
  2497. Py_BLOCK_THREADS
  2498. }
  2499. }
  2500. /* "zmq/core/socket.pyx":296
  2501. * with nogil:
  2502. * rc = zmq_getsockopt(self.handle, option, <void *>identity_str_c, &sz)
  2503. * if rc != 0: # <<<<<<<<<<<<<<
  2504. * raise ZMQError()
  2505. * result = PyBytes_FromStringAndSize(<char *>identity_str_c, sz)
  2506. */
  2507. __pyx_t_4 = (__pyx_v_rc != 0);
  2508. if (__pyx_t_4) {
  2509. /* "zmq/core/socket.pyx":297
  2510. * rc = zmq_getsockopt(self.handle, option, <void *>identity_str_c, &sz)
  2511. * if rc != 0:
  2512. * raise ZMQError() # <<<<<<<<<<<<<<
  2513. * result = PyBytes_FromStringAndSize(<char *>identity_str_c, sz)
  2514. * elif option in constants.int64_sockopts:
  2515. */
  2516. __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2517. __Pyx_GOTREF(__pyx_t_3);
  2518. __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2519. __Pyx_GOTREF(__pyx_t_2);
  2520. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2521. __Pyx_Raise(__pyx_t_2, 0, 0);
  2522. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2523. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2524. goto __pyx_L9;
  2525. }
  2526. __pyx_L9:;
  2527. /* "zmq/core/socket.pyx":298
  2528. * if rc != 0:
  2529. * raise ZMQError()
  2530. * result = PyBytes_FromStringAndSize(<char *>identity_str_c, sz) # <<<<<<<<<<<<<<
  2531. * elif option in constants.int64_sockopts:
  2532. * sz = sizeof(int64_t)
  2533. */
  2534. __pyx_t_2 = ((PyObject *)PyBytes_FromStringAndSize(((char *)__pyx_v_identity_str_c), __pyx_v_sz)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2535. __Pyx_GOTREF(__pyx_t_2);
  2536. __Pyx_DECREF(__pyx_v_result);
  2537. __pyx_v_result = __pyx_t_2;
  2538. __pyx_t_2 = 0;
  2539. goto __pyx_L5;
  2540. }
  2541. /* "zmq/core/socket.pyx":299
  2542. * raise ZMQError()
  2543. * result = PyBytes_FromStringAndSize(<char *>identity_str_c, sz)
  2544. * elif option in constants.int64_sockopts: # <<<<<<<<<<<<<<
  2545. * sz = sizeof(int64_t)
  2546. * with nogil:
  2547. */
  2548. __pyx_t_2 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2549. __Pyx_GOTREF(__pyx_t_2);
  2550. __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__constants); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2551. __Pyx_GOTREF(__pyx_t_3);
  2552. __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__int64_sockopts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2553. __Pyx_GOTREF(__pyx_t_1);
  2554. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2555. __pyx_t_4 = ((PySequence_Contains(__pyx_t_1, __pyx_t_2))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2556. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2557. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2558. if (__pyx_t_4) {
  2559. /* "zmq/core/socket.pyx":300
  2560. * result = PyBytes_FromStringAndSize(<char *>identity_str_c, sz)
  2561. * elif option in constants.int64_sockopts:
  2562. * sz = sizeof(int64_t) # <<<<<<<<<<<<<<
  2563. * with nogil:
  2564. * rc = zmq_getsockopt(self.handle, option, <void *>&optval_int64_c, &sz)
  2565. */
  2566. __pyx_v_sz = (sizeof(pyzmq_int64_t));
  2567. /* "zmq/core/socket.pyx":301
  2568. * elif option in constants.int64_sockopts:
  2569. * sz = sizeof(int64_t)
  2570. * with nogil: # <<<<<<<<<<<<<<
  2571. * rc = zmq_getsockopt(self.handle, option, <void *>&optval_int64_c, &sz)
  2572. * if rc != 0:
  2573. */
  2574. {
  2575. #ifdef WITH_THREAD
  2576. PyThreadState *_save;
  2577. #endif
  2578. Py_UNBLOCK_THREADS
  2579. /*try:*/ {
  2580. /* "zmq/core/socket.pyx":302
  2581. * sz = sizeof(int64_t)
  2582. * with nogil:
  2583. * rc = zmq_getsockopt(self.handle, option, <void *>&optval_int64_c, &sz) # <<<<<<<<<<<<<<
  2584. * if rc != 0:
  2585. * raise ZMQError()
  2586. */
  2587. __pyx_v_rc = zmq_getsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_option, ((void *)(&__pyx_v_optval_int64_c)), (&__pyx_v_sz));
  2588. }
  2589. /* "zmq/core/socket.pyx":301
  2590. * elif option in constants.int64_sockopts:
  2591. * sz = sizeof(int64_t)
  2592. * with nogil: # <<<<<<<<<<<<<<
  2593. * rc = zmq_getsockopt(self.handle, option, <void *>&optval_int64_c, &sz)
  2594. * if rc != 0:
  2595. */
  2596. /*finally:*/ {
  2597. Py_BLOCK_THREADS
  2598. }
  2599. }
  2600. /* "zmq/core/socket.pyx":303
  2601. * with nogil:
  2602. * rc = zmq_getsockopt(self.handle, option, <void *>&optval_int64_c, &sz)
  2603. * if rc != 0: # <<<<<<<<<<<<<<
  2604. * raise ZMQError()
  2605. * result = optval_int64_c
  2606. */
  2607. __pyx_t_4 = (__pyx_v_rc != 0);
  2608. if (__pyx_t_4) {
  2609. /* "zmq/core/socket.pyx":304
  2610. * rc = zmq_getsockopt(self.handle, option, <void *>&optval_int64_c, &sz)
  2611. * if rc != 0:
  2612. * raise ZMQError() # <<<<<<<<<<<<<<
  2613. * result = optval_int64_c
  2614. * elif option in constants.int_sockopts:
  2615. */
  2616. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2617. __Pyx_GOTREF(__pyx_t_1);
  2618. __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2619. __Pyx_GOTREF(__pyx_t_2);
  2620. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2621. __Pyx_Raise(__pyx_t_2, 0, 0);
  2622. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2623. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2624. goto __pyx_L13;
  2625. }
  2626. __pyx_L13:;
  2627. /* "zmq/core/socket.pyx":305
  2628. * if rc != 0:
  2629. * raise ZMQError()
  2630. * result = optval_int64_c # <<<<<<<<<<<<<<
  2631. * elif option in constants.int_sockopts:
  2632. * sz = sizeof(int)
  2633. */
  2634. __pyx_t_2 = __Pyx_PyInt_to_py_pyzmq_int64_t(__pyx_v_optval_int64_c); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2635. __Pyx_GOTREF(__pyx_t_2);
  2636. __Pyx_DECREF(__pyx_v_result);
  2637. __pyx_v_result = __pyx_t_2;
  2638. __pyx_t_2 = 0;
  2639. goto __pyx_L5;
  2640. }
  2641. /* "zmq/core/socket.pyx":306
  2642. * raise ZMQError()
  2643. * result = optval_int64_c
  2644. * elif option in constants.int_sockopts: # <<<<<<<<<<<<<<
  2645. * sz = sizeof(int)
  2646. * with nogil:
  2647. */
  2648. __pyx_t_2 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2649. __Pyx_GOTREF(__pyx_t_2);
  2650. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__constants); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2651. __Pyx_GOTREF(__pyx_t_1);
  2652. __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__int_sockopts); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2653. __Pyx_GOTREF(__pyx_t_3);
  2654. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2655. __pyx_t_4 = ((PySequence_Contains(__pyx_t_3, __pyx_t_2))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2656. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2657. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2658. if (__pyx_t_4) {
  2659. /* "zmq/core/socket.pyx":307
  2660. * result = optval_int64_c
  2661. * elif option in constants.int_sockopts:
  2662. * sz = sizeof(int) # <<<<<<<<<<<<<<
  2663. * with nogil:
  2664. * rc = zmq_getsockopt(self.handle, option, <void *>&optval_int_c, &sz)
  2665. */
  2666. __pyx_v_sz = (sizeof(int));
  2667. /* "zmq/core/socket.pyx":308
  2668. * elif option in constants.int_sockopts:
  2669. * sz = sizeof(int)
  2670. * with nogil: # <<<<<<<<<<<<<<
  2671. * rc = zmq_getsockopt(self.handle, option, <void *>&optval_int_c, &sz)
  2672. * if rc != 0:
  2673. */
  2674. {
  2675. #ifdef WITH_THREAD
  2676. PyThreadState *_save;
  2677. #endif
  2678. Py_UNBLOCK_THREADS
  2679. /*try:*/ {
  2680. /* "zmq/core/socket.pyx":309
  2681. * sz = sizeof(int)
  2682. * with nogil:
  2683. * rc = zmq_getsockopt(self.handle, option, <void *>&optval_int_c, &sz) # <<<<<<<<<<<<<<
  2684. * if rc != 0:
  2685. * raise ZMQError()
  2686. */
  2687. __pyx_v_rc = zmq_getsockopt(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle, __pyx_v_option, ((void *)(&__pyx_v_optval_int_c)), (&__pyx_v_sz));
  2688. }
  2689. /* "zmq/core/socket.pyx":308
  2690. * elif option in constants.int_sockopts:
  2691. * sz = sizeof(int)
  2692. * with nogil: # <<<<<<<<<<<<<<
  2693. * rc = zmq_getsockopt(self.handle, option, <void *>&optval_int_c, &sz)
  2694. * if rc != 0:
  2695. */
  2696. /*finally:*/ {
  2697. Py_BLOCK_THREADS
  2698. }
  2699. }
  2700. /* "zmq/core/socket.pyx":310
  2701. * with nogil:
  2702. * rc = zmq_getsockopt(self.handle, option, <void *>&optval_int_c, &sz)
  2703. * if rc != 0: # <<<<<<<<<<<<<<
  2704. * raise ZMQError()
  2705. * result = optval_int_c
  2706. */
  2707. __pyx_t_4 = (__pyx_v_rc != 0);
  2708. if (__pyx_t_4) {
  2709. /* "zmq/core/socket.pyx":311
  2710. * rc = zmq_getsockopt(self.handle, option, <void *>&optval_int_c, &sz)
  2711. * if rc != 0:
  2712. * raise ZMQError() # <<<<<<<<<<<<<<
  2713. * result = optval_int_c
  2714. * else:
  2715. */
  2716. __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2717. __Pyx_GOTREF(__pyx_t_3);
  2718. __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2719. __Pyx_GOTREF(__pyx_t_2);
  2720. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2721. __Pyx_Raise(__pyx_t_2, 0, 0);
  2722. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2723. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2724. goto __pyx_L17;
  2725. }
  2726. __pyx_L17:;
  2727. /* "zmq/core/socket.pyx":312
  2728. * if rc != 0:
  2729. * raise ZMQError()
  2730. * result = optval_int_c # <<<<<<<<<<<<<<
  2731. * else:
  2732. * raise ZMQError(EINVAL)
  2733. */
  2734. __pyx_t_2 = PyInt_FromLong(__pyx_v_optval_int_c); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2735. __Pyx_GOTREF(__pyx_t_2);
  2736. __Pyx_DECREF(__pyx_v_result);
  2737. __pyx_v_result = __pyx_t_2;
  2738. __pyx_t_2 = 0;
  2739. goto __pyx_L5;
  2740. }
  2741. /*else*/ {
  2742. /* "zmq/core/socket.pyx":314
  2743. * result = optval_int_c
  2744. * else:
  2745. * raise ZMQError(EINVAL) # <<<<<<<<<<<<<<
  2746. *
  2747. * return result
  2748. */
  2749. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2750. __Pyx_GOTREF(__pyx_t_2);
  2751. __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__EINVAL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2752. __Pyx_GOTREF(__pyx_t_3);
  2753. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2754. __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  2755. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  2756. __Pyx_GIVEREF(__pyx_t_3);
  2757. __pyx_t_3 = 0;
  2758. __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2759. __Pyx_GOTREF(__pyx_t_3);
  2760. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2761. __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  2762. __Pyx_Raise(__pyx_t_3, 0, 0);
  2763. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2764. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2765. }
  2766. __pyx_L5:;
  2767. /* "zmq/core/socket.pyx":316
  2768. * raise ZMQError(EINVAL)
  2769. *
  2770. * return result # <<<<<<<<<<<<<<
  2771. *
  2772. * def setsockopt_unicode(self, int option, optval, encoding='utf-8'):
  2773. */
  2774. __Pyx_XDECREF(__pyx_r);
  2775. __Pyx_INCREF(__pyx_v_result);
  2776. __pyx_r = __pyx_v_result;
  2777. goto __pyx_L0;
  2778. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2779. goto __pyx_L0;
  2780. __pyx_L1_error:;
  2781. __Pyx_XDECREF(__pyx_t_1);
  2782. __Pyx_XDECREF(__pyx_t_2);
  2783. __Pyx_XDECREF(__pyx_t_3);
  2784. __Pyx_AddTraceback("zmq.core.socket.Socket.getsockopt");
  2785. __pyx_r = NULL;
  2786. __pyx_L0:;
  2787. __Pyx_DECREF(__pyx_v_result);
  2788. __Pyx_XGIVEREF(__pyx_r);
  2789. __Pyx_RefNannyFinishContext();
  2790. return __pyx_r;
  2791. }
  2792. /* "zmq/core/socket.pyx":318
  2793. * return result
  2794. *
  2795. * def setsockopt_unicode(self, int option, optval, encoding='utf-8'): # <<<<<<<<<<<<<<
  2796. * """s.setsockopt_unicode(option, optval, encoding='utf-8')
  2797. *
  2798. */
  2799. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_5setsockopt_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2800. static char __pyx_doc_3zmq_4core_6socket_6Socket_5setsockopt_unicode[] = "s.setsockopt_unicode(option, optval, encoding='utf-8')\n\n Set socket options with a unicode object it is simply a wrapper\n for setsockopt to protect from encoding ambiguity.\n\n See the 0MQ documentation for details on specific options.\n\n Parameters\n ----------\n option : int\n The name of the option to set. Can be any of: SUBSCRIBE, \n UNSUBSCRIBE, IDENTITY\n optval : unicode\n The value of the option to set.\n encoding : str\n The encoding to be used, default is utf8\n ";
  2801. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_5setsockopt_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2802. int __pyx_v_option;
  2803. PyObject *__pyx_v_optval = 0;
  2804. PyObject *__pyx_v_encoding = 0;
  2805. PyObject *__pyx_r = NULL;
  2806. PyObject *__pyx_t_1 = NULL;
  2807. PyObject *__pyx_t_2 = NULL;
  2808. int __pyx_t_3;
  2809. int __pyx_t_4;
  2810. PyObject *__pyx_t_5 = NULL;
  2811. PyObject *__pyx_t_6 = NULL;
  2812. PyObject *__pyx_t_7 = NULL;
  2813. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__option,&__pyx_n_s__optval,&__pyx_n_s__encoding,0};
  2814. __Pyx_RefNannySetupContext("setsockopt_unicode");
  2815. if (unlikely(__pyx_kwds)) {
  2816. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  2817. PyObject* values[3] = {0,0,0};
  2818. values[2] = ((PyObject *)__pyx_kp_s_6);
  2819. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2820. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  2821. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2822. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2823. case 0: break;
  2824. default: goto __pyx_L5_argtuple_error;
  2825. }
  2826. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2827. case 0:
  2828. values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__option);
  2829. if (likely(values[0])) kw_args--;
  2830. else goto __pyx_L5_argtuple_error;
  2831. case 1:
  2832. values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__optval);
  2833. if (likely(values[1])) kw_args--;
  2834. else {
  2835. __Pyx_RaiseArgtupleInvalid("setsockopt_unicode", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2836. }
  2837. case 2:
  2838. if (kw_args > 0) {
  2839. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding);
  2840. if (value) { values[2] = value; kw_args--; }
  2841. }
  2842. }
  2843. if (unlikely(kw_args > 0)) {
  2844. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setsockopt_unicode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2845. }
  2846. __pyx_v_option = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_option == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2847. __pyx_v_optval = values[1];
  2848. __pyx_v_encoding = values[2];
  2849. } else {
  2850. __pyx_v_encoding = ((PyObject *)__pyx_kp_s_6);
  2851. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2852. case 3:
  2853. __pyx_v_encoding = PyTuple_GET_ITEM(__pyx_args, 2);
  2854. case 2:
  2855. __pyx_v_optval = PyTuple_GET_ITEM(__pyx_args, 1);
  2856. __pyx_v_option = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_option == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2857. break;
  2858. default: goto __pyx_L5_argtuple_error;
  2859. }
  2860. }
  2861. goto __pyx_L4_argument_unpacking_done;
  2862. __pyx_L5_argtuple_error:;
  2863. __Pyx_RaiseArgtupleInvalid("setsockopt_unicode", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2864. __pyx_L3_error:;
  2865. __Pyx_AddTraceback("zmq.core.socket.Socket.setsockopt_unicode");
  2866. __Pyx_RefNannyFinishContext();
  2867. return NULL;
  2868. __pyx_L4_argument_unpacking_done:;
  2869. /* "zmq/core/socket.pyx":336
  2870. * The encoding to be used, default is utf8
  2871. * """
  2872. * if not isinstance(optval, unicode): # <<<<<<<<<<<<<<
  2873. * raise TypeError("unicode strings only")
  2874. * return self.setsockopt(option, optval.encode(encoding))
  2875. */
  2876. __pyx_t_1 = __pyx_v_optval;
  2877. __Pyx_INCREF(__pyx_t_1);
  2878. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__unicode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2879. __Pyx_GOTREF(__pyx_t_2);
  2880. __pyx_t_3 = PyObject_IsInstance(__pyx_t_1, __pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2881. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2882. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2883. __pyx_t_4 = (!__pyx_t_3);
  2884. if (__pyx_t_4) {
  2885. /* "zmq/core/socket.pyx":337
  2886. * """
  2887. * if not isinstance(optval, unicode):
  2888. * raise TypeError("unicode strings only") # <<<<<<<<<<<<<<
  2889. * return self.setsockopt(option, optval.encode(encoding))
  2890. *
  2891. */
  2892. __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2893. __Pyx_GOTREF(__pyx_t_2);
  2894. __Pyx_Raise(__pyx_t_2, 0, 0);
  2895. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2896. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2897. goto __pyx_L6;
  2898. }
  2899. __pyx_L6:;
  2900. /* "zmq/core/socket.pyx":338
  2901. * if not isinstance(optval, unicode):
  2902. * raise TypeError("unicode strings only")
  2903. * return self.setsockopt(option, optval.encode(encoding)) # <<<<<<<<<<<<<<
  2904. *
  2905. * def getsockopt_unicode(self, int option, encoding='utf-8'):
  2906. */
  2907. __Pyx_XDECREF(__pyx_r);
  2908. __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__setsockopt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2909. __Pyx_GOTREF(__pyx_t_2);
  2910. __pyx_t_1 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2911. __Pyx_GOTREF(__pyx_t_1);
  2912. __pyx_t_5 = PyObject_GetAttr(__pyx_v_optval, __pyx_n_s__encode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2913. __Pyx_GOTREF(__pyx_t_5);
  2914. __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2915. __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  2916. __Pyx_INCREF(__pyx_v_encoding);
  2917. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_encoding);
  2918. __Pyx_GIVEREF(__pyx_v_encoding);
  2919. __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2920. __Pyx_GOTREF(__pyx_t_7);
  2921. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2922. __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  2923. __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2924. __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  2925. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
  2926. __Pyx_GIVEREF(__pyx_t_1);
  2927. PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7);
  2928. __Pyx_GIVEREF(__pyx_t_7);
  2929. __pyx_t_1 = 0;
  2930. __pyx_t_7 = 0;
  2931. __pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2932. __Pyx_GOTREF(__pyx_t_7);
  2933. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2934. __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  2935. __pyx_r = __pyx_t_7;
  2936. __pyx_t_7 = 0;
  2937. goto __pyx_L0;
  2938. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  2939. goto __pyx_L0;
  2940. __pyx_L1_error:;
  2941. __Pyx_XDECREF(__pyx_t_1);
  2942. __Pyx_XDECREF(__pyx_t_2);
  2943. __Pyx_XDECREF(__pyx_t_5);
  2944. __Pyx_XDECREF(__pyx_t_6);
  2945. __Pyx_XDECREF(__pyx_t_7);
  2946. __Pyx_AddTraceback("zmq.core.socket.Socket.setsockopt_unicode");
  2947. __pyx_r = NULL;
  2948. __pyx_L0:;
  2949. __Pyx_XGIVEREF(__pyx_r);
  2950. __Pyx_RefNannyFinishContext();
  2951. return __pyx_r;
  2952. }
  2953. /* "zmq/core/socket.pyx":340
  2954. * return self.setsockopt(option, optval.encode(encoding))
  2955. *
  2956. * def getsockopt_unicode(self, int option, encoding='utf-8'): # <<<<<<<<<<<<<<
  2957. * """s.getsockopt_unicode(option, encoding='utf-8')
  2958. *
  2959. */
  2960. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_6getsockopt_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2961. static char __pyx_doc_3zmq_4core_6socket_6Socket_6getsockopt_unicode[] = "s.getsockopt_unicode(option, encoding='utf-8')\n\n Get the value of a socket option.\n\n See the 0MQ documentation for details on specific options.\n\n Parameters\n ----------\n option : unicode string\n The name of the option to set. Can be any of: \n IDENTITY, HWM, SWAP, AFFINITY, RATE, \n RECOVERY_IVL, MCAST_LOOP, SNDBUF, RCVBUF, RCVMORE.\n\n Returns\n -------\n optval : unicode\n The value of the option as a unicode string.\n ";
  2962. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_6getsockopt_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2963. int __pyx_v_option;
  2964. PyObject *__pyx_v_encoding = 0;
  2965. PyObject *__pyx_r = NULL;
  2966. int __pyx_t_1;
  2967. PyObject *__pyx_t_2 = NULL;
  2968. PyObject *__pyx_t_3 = NULL;
  2969. PyObject *__pyx_t_4 = NULL;
  2970. int __pyx_t_5;
  2971. int __pyx_t_6;
  2972. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__option,&__pyx_n_s__encoding,0};
  2973. __Pyx_RefNannySetupContext("getsockopt_unicode");
  2974. if (unlikely(__pyx_kwds)) {
  2975. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  2976. PyObject* values[2] = {0,0};
  2977. values[1] = ((PyObject *)__pyx_kp_s_6);
  2978. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2979. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2980. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2981. case 0: break;
  2982. default: goto __pyx_L5_argtuple_error;
  2983. }
  2984. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2985. case 0:
  2986. values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__option);
  2987. if (likely(values[0])) kw_args--;
  2988. else goto __pyx_L5_argtuple_error;
  2989. case 1:
  2990. if (kw_args > 0) {
  2991. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding);
  2992. if (value) { values[1] = value; kw_args--; }
  2993. }
  2994. }
  2995. if (unlikely(kw_args > 0)) {
  2996. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "getsockopt_unicode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2997. }
  2998. __pyx_v_option = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_option == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2999. __pyx_v_encoding = values[1];
  3000. } else {
  3001. __pyx_v_encoding = ((PyObject *)__pyx_kp_s_6);
  3002. switch (PyTuple_GET_SIZE(__pyx_args)) {
  3003. case 2: __pyx_v_encoding = PyTuple_GET_ITEM(__pyx_args, 1);
  3004. case 1: __pyx_v_option = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_option == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3005. break;
  3006. default: goto __pyx_L5_argtuple_error;
  3007. }
  3008. }
  3009. goto __pyx_L4_argument_unpacking_done;
  3010. __pyx_L5_argtuple_error:;
  3011. __Pyx_RaiseArgtupleInvalid("getsockopt_unicode", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3012. __pyx_L3_error:;
  3013. __Pyx_AddTraceback("zmq.core.socket.Socket.getsockopt_unicode");
  3014. __Pyx_RefNannyFinishContext();
  3015. return NULL;
  3016. __pyx_L4_argument_unpacking_done:;
  3017. /* "zmq/core/socket.pyx":359
  3018. * The value of the option as a unicode string.
  3019. * """
  3020. * if option not in [IDENTITY]: # <<<<<<<<<<<<<<
  3021. * raise TypeError("option %i will not return a string to be decoded"%option)
  3022. * return self.getsockopt(option).decode(encoding)
  3023. */
  3024. __pyx_t_1 = __pyx_v_option;
  3025. __pyx_t_2 = PyInt_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3026. __Pyx_GOTREF(__pyx_t_2);
  3027. __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__IDENTITY); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3028. __Pyx_GOTREF(__pyx_t_3);
  3029. __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_NE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3030. __Pyx_GOTREF(__pyx_t_4);
  3031. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3032. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3033. __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3034. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3035. __pyx_t_6 = __pyx_t_5;
  3036. if (__pyx_t_6) {
  3037. /* "zmq/core/socket.pyx":360
  3038. * """
  3039. * if option not in [IDENTITY]:
  3040. * raise TypeError("option %i will not return a string to be decoded"%option) # <<<<<<<<<<<<<<
  3041. * return self.getsockopt(option).decode(encoding)
  3042. *
  3043. */
  3044. __pyx_t_4 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3045. __Pyx_GOTREF(__pyx_t_4);
  3046. __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3047. __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  3048. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3049. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3050. __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  3051. PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
  3052. __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  3053. __pyx_t_3 = 0;
  3054. __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3055. __Pyx_GOTREF(__pyx_t_3);
  3056. __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  3057. __Pyx_Raise(__pyx_t_3, 0, 0);
  3058. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3059. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3060. goto __pyx_L6;
  3061. }
  3062. __pyx_L6:;
  3063. /* "zmq/core/socket.pyx":361
  3064. * if option not in [IDENTITY]:
  3065. * raise TypeError("option %i will not return a string to be decoded"%option)
  3066. * return self.getsockopt(option).decode(encoding) # <<<<<<<<<<<<<<
  3067. *
  3068. * def bind(self, addr):
  3069. */
  3070. __Pyx_XDECREF(__pyx_r);
  3071. __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__getsockopt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3072. __Pyx_GOTREF(__pyx_t_3);
  3073. __pyx_t_4 = PyInt_FromLong(__pyx_v_option); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3074. __Pyx_GOTREF(__pyx_t_4);
  3075. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3076. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  3077. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  3078. __Pyx_GIVEREF(__pyx_t_4);
  3079. __pyx_t_4 = 0;
  3080. __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3081. __Pyx_GOTREF(__pyx_t_4);
  3082. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3083. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  3084. __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__decode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3085. __Pyx_GOTREF(__pyx_t_2);
  3086. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3087. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3088. __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  3089. __Pyx_INCREF(__pyx_v_encoding);
  3090. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_encoding);
  3091. __Pyx_GIVEREF(__pyx_v_encoding);
  3092. __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3093. __Pyx_GOTREF(__pyx_t_3);
  3094. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3095. __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  3096. __pyx_r = __pyx_t_3;
  3097. __pyx_t_3 = 0;
  3098. goto __pyx_L0;
  3099. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  3100. goto __pyx_L0;
  3101. __pyx_L1_error:;
  3102. __Pyx_XDECREF(__pyx_t_2);
  3103. __Pyx_XDECREF(__pyx_t_3);
  3104. __Pyx_XDECREF(__pyx_t_4);
  3105. __Pyx_AddTraceback("zmq.core.socket.Socket.getsockopt_unicode");
  3106. __pyx_r = NULL;
  3107. __pyx_L0:;
  3108. __Pyx_XGIVEREF(__pyx_r);
  3109. __Pyx_RefNannyFinishContext();
  3110. return __pyx_r;
  3111. }
  3112. /* "zmq/core/socket.pyx":363
  3113. * return self.getsockopt(option).decode(encoding)
  3114. *
  3115. * def bind(self, addr): # <<<<<<<<<<<<<<
  3116. * """s.bind(addr)
  3117. *
  3118. */
  3119. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_7bind(PyObject *__pyx_v_self, PyObject *__pyx_v_addr); /*proto*/
  3120. static char __pyx_doc_3zmq_4core_6socket_6Socket_7bind[] = "s.bind(addr)\n\n Bind the socket to an address.\n\n This causes the socket to listen on a network port. Sockets on the\n other side of this connection will use ``Socket.connect(addr)`` to\n connect to this socket.\n\n Parameters\n ----------\n addr : str\n The address string. This has the form 'protocol://interface:port',\n for example 'tcp://127.0.0.1:5555'. Protocols supported are\n tcp, upd, pgm, inproc and ipc. If the address is unicode, it is\n encoded to utf-8 first.\n ";
  3121. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_7bind(PyObject *__pyx_v_self, PyObject *__pyx_v_addr) {
  3122. int __pyx_v_rc;
  3123. PyObject *__pyx_r = NULL;
  3124. PyObject *__pyx_t_1 = NULL;
  3125. PyObject *__pyx_t_2 = NULL;
  3126. int __pyx_t_3;
  3127. int __pyx_t_4;
  3128. void *__pyx_t_5;
  3129. char *__pyx_t_6;
  3130. __Pyx_RefNannySetupContext("bind");
  3131. __Pyx_INCREF(__pyx_v_addr);
  3132. /* "zmq/core/socket.pyx":382
  3133. * cdef int rc
  3134. *
  3135. * _check_closed(self) # <<<<<<<<<<<<<<
  3136. * if isinstance(addr, unicode):
  3137. * addr = addr.encode('utf-8')
  3138. */
  3139. __pyx_t_1 = __pyx_v_self;
  3140. __Pyx_INCREF(__pyx_t_1);
  3141. __pyx_t_2 = __pyx_f_3zmq_4core_6socket__check_closed(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3142. __Pyx_GOTREF(__pyx_t_2);
  3143. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3144. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3145. /* "zmq/core/socket.pyx":383
  3146. *
  3147. * _check_closed(self)
  3148. * if isinstance(addr, unicode): # <<<<<<<<<<<<<<
  3149. * addr = addr.encode('utf-8')
  3150. * if not isinstance(addr, bytes):
  3151. */
  3152. __pyx_t_2 = __pyx_v_addr;
  3153. __Pyx_INCREF(__pyx_t_2);
  3154. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__unicode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3155. __Pyx_GOTREF(__pyx_t_1);
  3156. __pyx_t_3 = PyObject_IsInstance(__pyx_t_2, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3157. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3158. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3159. if (__pyx_t_3) {
  3160. /* "zmq/core/socket.pyx":384
  3161. * _check_closed(self)
  3162. * if isinstance(addr, unicode):
  3163. * addr = addr.encode('utf-8') # <<<<<<<<<<<<<<
  3164. * if not isinstance(addr, bytes):
  3165. * raise TypeError('expected str, got: %r' % addr)
  3166. */
  3167. __pyx_t_1 = PyObject_GetAttr(__pyx_v_addr, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3168. __Pyx_GOTREF(__pyx_t_1);
  3169. __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3170. __Pyx_GOTREF(__pyx_t_2);
  3171. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3172. __Pyx_DECREF(__pyx_v_addr);
  3173. __pyx_v_addr = __pyx_t_2;
  3174. __pyx_t_2 = 0;
  3175. goto __pyx_L5;
  3176. }
  3177. __pyx_L5:;
  3178. /* "zmq/core/socket.pyx":385
  3179. * if isinstance(addr, unicode):
  3180. * addr = addr.encode('utf-8')
  3181. * if not isinstance(addr, bytes): # <<<<<<<<<<<<<<
  3182. * raise TypeError('expected str, got: %r' % addr)
  3183. * with nogil:
  3184. */
  3185. __pyx_t_2 = __pyx_v_addr;
  3186. __Pyx_INCREF(__pyx_t_2);
  3187. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__bytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3188. __Pyx_GOTREF(__pyx_t_1);
  3189. __pyx_t_3 = PyObject_IsInstance(__pyx_t_2, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3190. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3191. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3192. __pyx_t_4 = (!__pyx_t_3);
  3193. if (__pyx_t_4) {
  3194. /* "zmq/core/socket.pyx":386
  3195. * addr = addr.encode('utf-8')
  3196. * if not isinstance(addr, bytes):
  3197. * raise TypeError('expected str, got: %r' % addr) # <<<<<<<<<<<<<<
  3198. * with nogil:
  3199. * rc = zmq_bind(self.handle, addr)
  3200. */
  3201. __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), __pyx_v_addr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3202. __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  3203. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3204. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  3205. PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
  3206. __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  3207. __pyx_t_1 = 0;
  3208. __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3209. __Pyx_GOTREF(__pyx_t_1);
  3210. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  3211. __Pyx_Raise(__pyx_t_1, 0, 0);
  3212. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3213. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3214. goto __pyx_L6;
  3215. }
  3216. __pyx_L6:;
  3217. /* "zmq/core/socket.pyx":387
  3218. * if not isinstance(addr, bytes):
  3219. * raise TypeError('expected str, got: %r' % addr)
  3220. * with nogil: # <<<<<<<<<<<<<<
  3221. * rc = zmq_bind(self.handle, addr)
  3222. * if rc != 0:
  3223. */
  3224. {
  3225. #ifdef WITH_THREAD
  3226. PyThreadState *_save;
  3227. #endif
  3228. Py_UNBLOCK_THREADS
  3229. /*try:*/ {
  3230. /* "zmq/core/socket.pyx":388
  3231. * raise TypeError('expected str, got: %r' % addr)
  3232. * with nogil:
  3233. * rc = zmq_bind(self.handle, addr) # <<<<<<<<<<<<<<
  3234. * if rc != 0:
  3235. * raise ZMQError()
  3236. */
  3237. __pyx_t_5 = ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle;
  3238. __pyx_t_6 = PyBytes_AsString(__pyx_v_addr); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L8;}
  3239. __pyx_v_rc = zmq_bind(__pyx_t_5, __pyx_t_6);
  3240. }
  3241. /* "zmq/core/socket.pyx":387
  3242. * if not isinstance(addr, bytes):
  3243. * raise TypeError('expected str, got: %r' % addr)
  3244. * with nogil: # <<<<<<<<<<<<<<
  3245. * rc = zmq_bind(self.handle, addr)
  3246. * if rc != 0:
  3247. */
  3248. /*finally:*/ {
  3249. int __pyx_why;
  3250. __pyx_why = 0; goto __pyx_L9;
  3251. __pyx_L8: __pyx_why = 4; goto __pyx_L9;
  3252. __pyx_L9:;
  3253. Py_BLOCK_THREADS
  3254. switch (__pyx_why) {
  3255. case 4: goto __pyx_L1_error;
  3256. }
  3257. }
  3258. }
  3259. /* "zmq/core/socket.pyx":389
  3260. * with nogil:
  3261. * rc = zmq_bind(self.handle, addr)
  3262. * if rc != 0: # <<<<<<<<<<<<<<
  3263. * raise ZMQError()
  3264. *
  3265. */
  3266. __pyx_t_4 = (__pyx_v_rc != 0);
  3267. if (__pyx_t_4) {
  3268. /* "zmq/core/socket.pyx":390
  3269. * rc = zmq_bind(self.handle, addr)
  3270. * if rc != 0:
  3271. * raise ZMQError() # <<<<<<<<<<<<<<
  3272. *
  3273. * def bind_to_random_port(self, addr, min_port=49152, max_port=65536, max_tries=100):
  3274. */
  3275. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3276. __Pyx_GOTREF(__pyx_t_1);
  3277. __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3278. __Pyx_GOTREF(__pyx_t_2);
  3279. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3280. __Pyx_Raise(__pyx_t_2, 0, 0);
  3281. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3282. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3283. goto __pyx_L11;
  3284. }
  3285. __pyx_L11:;
  3286. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  3287. goto __pyx_L0;
  3288. __pyx_L1_error:;
  3289. __Pyx_XDECREF(__pyx_t_1);
  3290. __Pyx_XDECREF(__pyx_t_2);
  3291. __Pyx_AddTraceback("zmq.core.socket.Socket.bind");
  3292. __pyx_r = NULL;
  3293. __pyx_L0:;
  3294. __Pyx_DECREF(__pyx_v_addr);
  3295. __Pyx_XGIVEREF(__pyx_r);
  3296. __Pyx_RefNannyFinishContext();
  3297. return __pyx_r;
  3298. }
  3299. /* "zmq/core/socket.pyx":392
  3300. * raise ZMQError()
  3301. *
  3302. * def bind_to_random_port(self, addr, min_port=49152, max_port=65536, max_tries=100): # <<<<<<<<<<<<<<
  3303. * """s.bind_to_random_port(addr, min_port=49152, max_port=65536, max_tries=100)
  3304. *
  3305. */
  3306. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_8bind_to_random_port(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  3307. static char __pyx_doc_3zmq_4core_6socket_6Socket_8bind_to_random_port[] = "s.bind_to_random_port(addr, min_port=49152, max_port=65536, max_tries=100)\n\n Bind this socket to a random port in a range.\n\n Parameters\n ----------\n addr : str\n The address string without the port to pass to ``Socket.bind()``.\n min_port : int, optional\n The minimum port in the range of ports to try (inclusive).\n max_port : int, optional\n The maximum port in the range of ports to try (exclusive).\n max_tries : int, optional\n The maximum number of bind attempts to make.\n\n Returns\n -------\n port : int\n The port the socket was bound to.\n \n Raises\n ------\n ZMQBindError\n if `max_tries` reached before successful bind\n ";
  3308. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_8bind_to_random_port(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  3309. PyObject *__pyx_v_addr = 0;
  3310. PyObject *__pyx_v_min_port = 0;
  3311. PyObject *__pyx_v_max_port = 0;
  3312. PyObject *__pyx_v_max_tries = 0;
  3313. PyObject *__pyx_v_i;
  3314. PyObject *__pyx_v_port;
  3315. PyObject *__pyx_r = NULL;
  3316. Py_ssize_t __pyx_t_1;
  3317. PyObject *__pyx_t_2 = NULL;
  3318. PyObject *__pyx_t_3 = NULL;
  3319. PyObject *__pyx_t_4 = NULL;
  3320. PyObject *__pyx_t_5 = NULL;
  3321. int __pyx_t_6;
  3322. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__addr,&__pyx_n_s__min_port,&__pyx_n_s__max_port,&__pyx_n_s__max_tries,0};
  3323. __Pyx_RefNannySetupContext("bind_to_random_port");
  3324. if (unlikely(__pyx_kwds)) {
  3325. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  3326. PyObject* values[4] = {0,0,0,0};
  3327. values[1] = ((PyObject *)__pyx_int_49152);
  3328. values[2] = ((PyObject *)__pyx_int_65536);
  3329. values[3] = ((PyObject *)__pyx_int_100);
  3330. switch (PyTuple_GET_SIZE(__pyx_args)) {
  3331. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  3332. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  3333. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  3334. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  3335. case 0: break;
  3336. default: goto __pyx_L5_argtuple_error;
  3337. }
  3338. switch (PyTuple_GET_SIZE(__pyx_args)) {
  3339. case 0:
  3340. values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__addr);
  3341. if (likely(values[0])) kw_args--;
  3342. else goto __pyx_L5_argtuple_error;
  3343. case 1:
  3344. if (kw_args > 0) {
  3345. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_port);
  3346. if (value) { values[1] = value; kw_args--; }
  3347. }
  3348. case 2:
  3349. if (kw_args > 0) {
  3350. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_port);
  3351. if (value) { values[2] = value; kw_args--; }
  3352. }
  3353. case 3:
  3354. if (kw_args > 0) {
  3355. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_tries);
  3356. if (value) { values[3] = value; kw_args--; }
  3357. }
  3358. }
  3359. if (unlikely(kw_args > 0)) {
  3360. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "bind_to_random_port") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3361. }
  3362. __pyx_v_addr = values[0];
  3363. __pyx_v_min_port = values[1];
  3364. __pyx_v_max_port = values[2];
  3365. __pyx_v_max_tries = values[3];
  3366. } else {
  3367. __pyx_v_min_port = ((PyObject *)__pyx_int_49152);
  3368. __pyx_v_max_port = ((PyObject *)__pyx_int_65536);
  3369. __pyx_v_max_tries = ((PyObject *)__pyx_int_100);
  3370. switch (PyTuple_GET_SIZE(__pyx_args)) {
  3371. case 4: __pyx_v_max_tries = PyTuple_GET_ITEM(__pyx_args, 3);
  3372. case 3: __pyx_v_max_port = PyTuple_GET_ITEM(__pyx_args, 2);
  3373. case 2: __pyx_v_min_port = PyTuple_GET_ITEM(__pyx_args, 1);
  3374. case 1: __pyx_v_addr = PyTuple_GET_ITEM(__pyx_args, 0);
  3375. break;
  3376. default: goto __pyx_L5_argtuple_error;
  3377. }
  3378. }
  3379. goto __pyx_L4_argument_unpacking_done;
  3380. __pyx_L5_argtuple_error:;
  3381. __Pyx_RaiseArgtupleInvalid("bind_to_random_port", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  3382. __pyx_L3_error:;
  3383. __Pyx_AddTraceback("zmq.core.socket.Socket.bind_to_random_port");
  3384. __Pyx_RefNannyFinishContext();
  3385. return NULL;
  3386. __pyx_L4_argument_unpacking_done:;
  3387. __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
  3388. __pyx_v_port = Py_None; __Pyx_INCREF(Py_None);
  3389. /* "zmq/core/socket.pyx":418
  3390. * if `max_tries` reached before successful bind
  3391. * """
  3392. * for i in xrange(max_tries): # <<<<<<<<<<<<<<
  3393. * try:
  3394. * port = random.randrange(min_port, max_port)
  3395. */
  3396. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3397. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  3398. __Pyx_INCREF(__pyx_v_max_tries);
  3399. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_max_tries);
  3400. __Pyx_GIVEREF(__pyx_v_max_tries);
  3401. __pyx_t_3 = PyObject_Call(__pyx_builtin_xrange, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3402. __Pyx_GOTREF(__pyx_t_3);
  3403. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  3404. if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
  3405. __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2);
  3406. } else {
  3407. __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3408. __Pyx_GOTREF(__pyx_t_2);
  3409. }
  3410. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3411. for (;;) {
  3412. if (likely(PyList_CheckExact(__pyx_t_2))) {
  3413. if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break;
  3414. __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
  3415. } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
  3416. if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
  3417. __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
  3418. } else {
  3419. __pyx_t_3 = PyIter_Next(__pyx_t_2);
  3420. if (!__pyx_t_3) {
  3421. if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3422. break;
  3423. }
  3424. __Pyx_GOTREF(__pyx_t_3);
  3425. }
  3426. __Pyx_DECREF(__pyx_v_i);
  3427. __pyx_v_i = __pyx_t_3;
  3428. __pyx_t_3 = 0;
  3429. /* "zmq/core/socket.pyx":419
  3430. * """
  3431. * for i in xrange(max_tries):
  3432. * try: # <<<<<<<<<<<<<<
  3433. * port = random.randrange(min_port, max_port)
  3434. * self.bind('%s:%s' % (addr, port))
  3435. */
  3436. {
  3437. PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
  3438. __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
  3439. __Pyx_XGOTREF(__pyx_save_exc_type);
  3440. __Pyx_XGOTREF(__pyx_save_exc_value);
  3441. __Pyx_XGOTREF(__pyx_save_exc_tb);
  3442. /*try:*/ {
  3443. /* "zmq/core/socket.pyx":420
  3444. * for i in xrange(max_tries):
  3445. * try:
  3446. * port = random.randrange(min_port, max_port) # <<<<<<<<<<<<<<
  3447. * self.bind('%s:%s' % (addr, port))
  3448. * except ZMQError:
  3449. */
  3450. __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__random); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
  3451. __Pyx_GOTREF(__pyx_t_3);
  3452. __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__randrange); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
  3453. __Pyx_GOTREF(__pyx_t_4);
  3454. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3455. __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
  3456. __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  3457. __Pyx_INCREF(__pyx_v_min_port);
  3458. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_min_port);
  3459. __Pyx_GIVEREF(__pyx_v_min_port);
  3460. __Pyx_INCREF(__pyx_v_max_port);
  3461. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_max_port);
  3462. __Pyx_GIVEREF(__pyx_v_max_port);
  3463. __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
  3464. __Pyx_GOTREF(__pyx_t_5);
  3465. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3466. __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  3467. __Pyx_DECREF(__pyx_v_port);
  3468. __pyx_v_port = __pyx_t_5;
  3469. __pyx_t_5 = 0;
  3470. /* "zmq/core/socket.pyx":421
  3471. * try:
  3472. * port = random.randrange(min_port, max_port)
  3473. * self.bind('%s:%s' % (addr, port)) # <<<<<<<<<<<<<<
  3474. * except ZMQError:
  3475. * pass
  3476. */
  3477. __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__bind); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
  3478. __Pyx_GOTREF(__pyx_t_5);
  3479. __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
  3480. __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  3481. __Pyx_INCREF(__pyx_v_addr);
  3482. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_addr);
  3483. __Pyx_GIVEREF(__pyx_v_addr);
  3484. __Pyx_INCREF(__pyx_v_port);
  3485. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_port);
  3486. __Pyx_GIVEREF(__pyx_v_port);
  3487. __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
  3488. __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  3489. __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  3490. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
  3491. __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  3492. PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
  3493. __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  3494. __pyx_t_4 = 0;
  3495. __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L8_error;}
  3496. __Pyx_GOTREF(__pyx_t_4);
  3497. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3498. __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  3499. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3500. }
  3501. /*else:*/ {
  3502. /* "zmq/core/socket.pyx":425
  3503. * pass
  3504. * else:
  3505. * return port # <<<<<<<<<<<<<<
  3506. * raise ZMQBindError("Could not bind socket to random port.")
  3507. *
  3508. */
  3509. __Pyx_XDECREF(__pyx_r);
  3510. __Pyx_INCREF(__pyx_v_port);
  3511. __pyx_r = __pyx_v_port;
  3512. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3513. goto __pyx_L11_except_return;
  3514. }
  3515. __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
  3516. __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
  3517. __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
  3518. goto __pyx_L15_try_end;
  3519. __pyx_L8_error:;
  3520. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3521. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3522. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  3523. /* "zmq/core/socket.pyx":422
  3524. * port = random.randrange(min_port, max_port)
  3525. * self.bind('%s:%s' % (addr, port))
  3526. * except ZMQError: # <<<<<<<<<<<<<<
  3527. * pass
  3528. * else:
  3529. */
  3530. __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L10_except_error;}
  3531. __Pyx_GOTREF(__pyx_t_4);
  3532. __pyx_t_6 = PyErr_ExceptionMatches(__pyx_t_4);
  3533. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3534. if (__pyx_t_6) {
  3535. PyErr_Restore(0,0,0);
  3536. goto __pyx_L9_exception_handled;
  3537. }
  3538. __pyx_L10_except_error:;
  3539. __Pyx_XGIVEREF(__pyx_save_exc_type);
  3540. __Pyx_XGIVEREF(__pyx_save_exc_value);
  3541. __Pyx_XGIVEREF(__pyx_save_exc_tb);
  3542. __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
  3543. goto __pyx_L1_error;
  3544. __pyx_L11_except_return:;
  3545. __Pyx_XGIVEREF(__pyx_save_exc_type);
  3546. __Pyx_XGIVEREF(__pyx_save_exc_value);
  3547. __Pyx_XGIVEREF(__pyx_save_exc_tb);
  3548. __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
  3549. goto __pyx_L0;
  3550. __pyx_L9_exception_handled:;
  3551. __Pyx_XGIVEREF(__pyx_save_exc_type);
  3552. __Pyx_XGIVEREF(__pyx_save_exc_value);
  3553. __Pyx_XGIVEREF(__pyx_save_exc_tb);
  3554. __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
  3555. __pyx_L15_try_end:;
  3556. }
  3557. }
  3558. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3559. /* "zmq/core/socket.pyx":426
  3560. * else:
  3561. * return port
  3562. * raise ZMQBindError("Could not bind socket to random port.") # <<<<<<<<<<<<<<
  3563. *
  3564. * def connect(self, addr):
  3565. */
  3566. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQBindError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3567. __Pyx_GOTREF(__pyx_t_2);
  3568. __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_13), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3569. __Pyx_GOTREF(__pyx_t_4);
  3570. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3571. __Pyx_Raise(__pyx_t_4, 0, 0);
  3572. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3573. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3574. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  3575. goto __pyx_L0;
  3576. __pyx_L1_error:;
  3577. __Pyx_XDECREF(__pyx_t_2);
  3578. __Pyx_XDECREF(__pyx_t_3);
  3579. __Pyx_XDECREF(__pyx_t_4);
  3580. __Pyx_XDECREF(__pyx_t_5);
  3581. __Pyx_AddTraceback("zmq.core.socket.Socket.bind_to_random_port");
  3582. __pyx_r = NULL;
  3583. __pyx_L0:;
  3584. __Pyx_DECREF(__pyx_v_i);
  3585. __Pyx_DECREF(__pyx_v_port);
  3586. __Pyx_XGIVEREF(__pyx_r);
  3587. __Pyx_RefNannyFinishContext();
  3588. return __pyx_r;
  3589. }
  3590. /* "zmq/core/socket.pyx":428
  3591. * raise ZMQBindError("Could not bind socket to random port.")
  3592. *
  3593. * def connect(self, addr): # <<<<<<<<<<<<<<
  3594. * """s.connect(addr)
  3595. *
  3596. */
  3597. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_9connect(PyObject *__pyx_v_self, PyObject *__pyx_v_addr); /*proto*/
  3598. static char __pyx_doc_3zmq_4core_6socket_6Socket_9connect[] = "s.connect(addr)\n\n Connect to a remote 0MQ socket.\n\n Parameters\n ----------\n addr : str\n The address string. This has the form 'protocol://interface:port',\n for example 'tcp://127.0.0.1:5555'. Protocols supported are\n tcp, upd, pgm, inproc and ipc. If the address is unicode, it is\n encoded to utf-8 first.\n ";
  3599. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_9connect(PyObject *__pyx_v_self, PyObject *__pyx_v_addr) {
  3600. int __pyx_v_rc;
  3601. PyObject *__pyx_r = NULL;
  3602. PyObject *__pyx_t_1 = NULL;
  3603. PyObject *__pyx_t_2 = NULL;
  3604. int __pyx_t_3;
  3605. int __pyx_t_4;
  3606. void *__pyx_t_5;
  3607. char *__pyx_t_6;
  3608. __Pyx_RefNannySetupContext("connect");
  3609. __Pyx_INCREF(__pyx_v_addr);
  3610. /* "zmq/core/socket.pyx":443
  3611. * cdef int rc
  3612. *
  3613. * _check_closed(self) # <<<<<<<<<<<<<<
  3614. * if isinstance(addr, unicode):
  3615. * addr = addr.encode('utf-8')
  3616. */
  3617. __pyx_t_1 = __pyx_v_self;
  3618. __Pyx_INCREF(__pyx_t_1);
  3619. __pyx_t_2 = __pyx_f_3zmq_4core_6socket__check_closed(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3620. __Pyx_GOTREF(__pyx_t_2);
  3621. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3622. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3623. /* "zmq/core/socket.pyx":444
  3624. *
  3625. * _check_closed(self)
  3626. * if isinstance(addr, unicode): # <<<<<<<<<<<<<<
  3627. * addr = addr.encode('utf-8')
  3628. * if not isinstance(addr, bytes):
  3629. */
  3630. __pyx_t_2 = __pyx_v_addr;
  3631. __Pyx_INCREF(__pyx_t_2);
  3632. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__unicode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3633. __Pyx_GOTREF(__pyx_t_1);
  3634. __pyx_t_3 = PyObject_IsInstance(__pyx_t_2, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3635. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3636. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3637. if (__pyx_t_3) {
  3638. /* "zmq/core/socket.pyx":445
  3639. * _check_closed(self)
  3640. * if isinstance(addr, unicode):
  3641. * addr = addr.encode('utf-8') # <<<<<<<<<<<<<<
  3642. * if not isinstance(addr, bytes):
  3643. * raise TypeError('expected str, got: %r' % addr)
  3644. */
  3645. __pyx_t_1 = PyObject_GetAttr(__pyx_v_addr, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3646. __Pyx_GOTREF(__pyx_t_1);
  3647. __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3648. __Pyx_GOTREF(__pyx_t_2);
  3649. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3650. __Pyx_DECREF(__pyx_v_addr);
  3651. __pyx_v_addr = __pyx_t_2;
  3652. __pyx_t_2 = 0;
  3653. goto __pyx_L5;
  3654. }
  3655. __pyx_L5:;
  3656. /* "zmq/core/socket.pyx":446
  3657. * if isinstance(addr, unicode):
  3658. * addr = addr.encode('utf-8')
  3659. * if not isinstance(addr, bytes): # <<<<<<<<<<<<<<
  3660. * raise TypeError('expected str, got: %r' % addr)
  3661. * with nogil:
  3662. */
  3663. __pyx_t_2 = __pyx_v_addr;
  3664. __Pyx_INCREF(__pyx_t_2);
  3665. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__bytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3666. __Pyx_GOTREF(__pyx_t_1);
  3667. __pyx_t_3 = PyObject_IsInstance(__pyx_t_2, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3668. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3669. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3670. __pyx_t_4 = (!__pyx_t_3);
  3671. if (__pyx_t_4) {
  3672. /* "zmq/core/socket.pyx":447
  3673. * addr = addr.encode('utf-8')
  3674. * if not isinstance(addr, bytes):
  3675. * raise TypeError('expected str, got: %r' % addr) # <<<<<<<<<<<<<<
  3676. * with nogil:
  3677. * rc = zmq_connect(self.handle, addr)
  3678. */
  3679. __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), __pyx_v_addr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3680. __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  3681. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3682. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  3683. PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
  3684. __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  3685. __pyx_t_1 = 0;
  3686. __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3687. __Pyx_GOTREF(__pyx_t_1);
  3688. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  3689. __Pyx_Raise(__pyx_t_1, 0, 0);
  3690. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3691. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3692. goto __pyx_L6;
  3693. }
  3694. __pyx_L6:;
  3695. /* "zmq/core/socket.pyx":448
  3696. * if not isinstance(addr, bytes):
  3697. * raise TypeError('expected str, got: %r' % addr)
  3698. * with nogil: # <<<<<<<<<<<<<<
  3699. * rc = zmq_connect(self.handle, addr)
  3700. * if rc != 0:
  3701. */
  3702. {
  3703. #ifdef WITH_THREAD
  3704. PyThreadState *_save;
  3705. #endif
  3706. Py_UNBLOCK_THREADS
  3707. /*try:*/ {
  3708. /* "zmq/core/socket.pyx":449
  3709. * raise TypeError('expected str, got: %r' % addr)
  3710. * with nogil:
  3711. * rc = zmq_connect(self.handle, addr) # <<<<<<<<<<<<<<
  3712. * if rc != 0:
  3713. * raise ZMQError()
  3714. */
  3715. __pyx_t_5 = ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->handle;
  3716. __pyx_t_6 = PyBytes_AsString(__pyx_v_addr); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L8;}
  3717. __pyx_v_rc = zmq_connect(__pyx_t_5, __pyx_t_6);
  3718. }
  3719. /* "zmq/core/socket.pyx":448
  3720. * if not isinstance(addr, bytes):
  3721. * raise TypeError('expected str, got: %r' % addr)
  3722. * with nogil: # <<<<<<<<<<<<<<
  3723. * rc = zmq_connect(self.handle, addr)
  3724. * if rc != 0:
  3725. */
  3726. /*finally:*/ {
  3727. int __pyx_why;
  3728. __pyx_why = 0; goto __pyx_L9;
  3729. __pyx_L8: __pyx_why = 4; goto __pyx_L9;
  3730. __pyx_L9:;
  3731. Py_BLOCK_THREADS
  3732. switch (__pyx_why) {
  3733. case 4: goto __pyx_L1_error;
  3734. }
  3735. }
  3736. }
  3737. /* "zmq/core/socket.pyx":450
  3738. * with nogil:
  3739. * rc = zmq_connect(self.handle, addr)
  3740. * if rc != 0: # <<<<<<<<<<<<<<
  3741. * raise ZMQError()
  3742. *
  3743. */
  3744. __pyx_t_4 = (__pyx_v_rc != 0);
  3745. if (__pyx_t_4) {
  3746. /* "zmq/core/socket.pyx":451
  3747. * rc = zmq_connect(self.handle, addr)
  3748. * if rc != 0:
  3749. * raise ZMQError() # <<<<<<<<<<<<<<
  3750. *
  3751. * #-------------------------------------------------------------------------
  3752. */
  3753. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3754. __Pyx_GOTREF(__pyx_t_1);
  3755. __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3756. __Pyx_GOTREF(__pyx_t_2);
  3757. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3758. __Pyx_Raise(__pyx_t_2, 0, 0);
  3759. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3760. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3761. goto __pyx_L11;
  3762. }
  3763. __pyx_L11:;
  3764. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  3765. goto __pyx_L0;
  3766. __pyx_L1_error:;
  3767. __Pyx_XDECREF(__pyx_t_1);
  3768. __Pyx_XDECREF(__pyx_t_2);
  3769. __Pyx_AddTraceback("zmq.core.socket.Socket.connect");
  3770. __pyx_r = NULL;
  3771. __pyx_L0:;
  3772. __Pyx_DECREF(__pyx_v_addr);
  3773. __Pyx_XGIVEREF(__pyx_r);
  3774. __Pyx_RefNannyFinishContext();
  3775. return __pyx_r;
  3776. }
  3777. /* "zmq/core/socket.pyx":457
  3778. * #-------------------------------------------------------------------------
  3779. *
  3780. * cpdef object send(self, object data, int flags=0, copy=True, track=False): # <<<<<<<<<<<<<<
  3781. * """s.send(data, flags=0, copy=True, track=False)
  3782. *
  3783. */
  3784. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_10send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  3785. static PyObject *__pyx_f_3zmq_4core_6socket_6Socket_send(struct __pyx_obj_3zmq_4core_6socket_Socket *__pyx_v_self, PyObject *__pyx_v_data, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send *__pyx_optional_args) {
  3786. int __pyx_v_flags = ((int)0);
  3787. PyObject *__pyx_v_copy = __pyx_k_15;
  3788. PyObject *__pyx_v_track = __pyx_k_16;
  3789. PyObject *__pyx_v_msg;
  3790. PyObject *__pyx_r = NULL;
  3791. PyObject *__pyx_t_1 = NULL;
  3792. PyObject *__pyx_t_2 = NULL;
  3793. PyObject *__pyx_t_3 = NULL;
  3794. int __pyx_t_4;
  3795. void *__pyx_t_5;
  3796. struct __pyx_opt_args_3zmq_4core_6socket__send_copy __pyx_t_6;
  3797. int __pyx_t_7;
  3798. int __pyx_t_8;
  3799. struct __pyx_opt_args_3zmq_4core_6socket__send_message __pyx_t_9;
  3800. __Pyx_RefNannySetupContext("send");
  3801. if (__pyx_optional_args) {
  3802. if (__pyx_optional_args->__pyx_n > 0) {
  3803. __pyx_v_flags = __pyx_optional_args->flags;
  3804. if (__pyx_optional_args->__pyx_n > 1) {
  3805. __pyx_v_copy = __pyx_optional_args->copy;
  3806. if (__pyx_optional_args->__pyx_n > 2) {
  3807. __pyx_v_track = __pyx_optional_args->track;
  3808. }
  3809. }
  3810. }
  3811. }
  3812. __Pyx_INCREF(__pyx_v_data);
  3813. __pyx_v_msg = Py_None; __Pyx_INCREF(Py_None);
  3814. /* Check if called by wrapper */
  3815. if (unlikely(__pyx_skip_dispatch)) ;
  3816. /* Check if overriden in Python */
  3817. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  3818. __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__send); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3819. __Pyx_GOTREF(__pyx_t_1);
  3820. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_3zmq_4core_6socket_6Socket_10send)) {
  3821. __Pyx_XDECREF(__pyx_r);
  3822. __pyx_t_2 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3823. __Pyx_GOTREF(__pyx_t_2);
  3824. __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3825. __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  3826. __Pyx_INCREF(__pyx_v_data);
  3827. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_data);
  3828. __Pyx_GIVEREF(__pyx_v_data);
  3829. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  3830. __Pyx_GIVEREF(__pyx_t_2);
  3831. __Pyx_INCREF(__pyx_v_copy);
  3832. PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_copy);
  3833. __Pyx_GIVEREF(__pyx_v_copy);
  3834. __Pyx_INCREF(__pyx_v_track);
  3835. PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_track);
  3836. __Pyx_GIVEREF(__pyx_v_track);
  3837. __pyx_t_2 = 0;
  3838. __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3839. __Pyx_GOTREF(__pyx_t_2);
  3840. __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  3841. __pyx_r = __pyx_t_2;
  3842. __pyx_t_2 = 0;
  3843. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3844. goto __pyx_L0;
  3845. }
  3846. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3847. }
  3848. /* "zmq/core/socket.pyx":494
  3849. *
  3850. * """
  3851. * _check_closed(self) # <<<<<<<<<<<<<<
  3852. *
  3853. * if isinstance(data, unicode):
  3854. */
  3855. __pyx_t_1 = ((PyObject *)__pyx_v_self);
  3856. __Pyx_INCREF(__pyx_t_1);
  3857. __pyx_t_2 = __pyx_f_3zmq_4core_6socket__check_closed(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3858. __Pyx_GOTREF(__pyx_t_2);
  3859. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3860. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3861. /* "zmq/core/socket.pyx":496
  3862. * _check_closed(self)
  3863. *
  3864. * if isinstance(data, unicode): # <<<<<<<<<<<<<<
  3865. * raise TypeError("unicode not allowed, use send_unicode")
  3866. *
  3867. */
  3868. __pyx_t_2 = __pyx_v_data;
  3869. __Pyx_INCREF(__pyx_t_2);
  3870. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__unicode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3871. __Pyx_GOTREF(__pyx_t_1);
  3872. __pyx_t_4 = PyObject_IsInstance(__pyx_t_2, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3873. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3874. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3875. if (__pyx_t_4) {
  3876. /* "zmq/core/socket.pyx":497
  3877. *
  3878. * if isinstance(data, unicode):
  3879. * raise TypeError("unicode not allowed, use send_unicode") # <<<<<<<<<<<<<<
  3880. *
  3881. * if copy:
  3882. */
  3883. __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_18), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3884. __Pyx_GOTREF(__pyx_t_1);
  3885. __Pyx_Raise(__pyx_t_1, 0, 0);
  3886. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3887. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3888. goto __pyx_L3;
  3889. }
  3890. __pyx_L3:;
  3891. /* "zmq/core/socket.pyx":499
  3892. * raise TypeError("unicode not allowed, use send_unicode")
  3893. *
  3894. * if copy: # <<<<<<<<<<<<<<
  3895. * # msg.bytes never returns the input data object
  3896. * # it is always a copy, but always the same copy
  3897. */
  3898. __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_copy); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3899. if (__pyx_t_4) {
  3900. /* "zmq/core/socket.pyx":502
  3901. * # msg.bytes never returns the input data object
  3902. * # it is always a copy, but always the same copy
  3903. * if isinstance(data, Message): # <<<<<<<<<<<<<<
  3904. * data = data.buffer
  3905. * return _send_copy(self.handle, data, flags)
  3906. */
  3907. __pyx_t_1 = __pyx_v_data;
  3908. __Pyx_INCREF(__pyx_t_1);
  3909. __pyx_t_2 = ((PyObject *)((PyObject*)__pyx_ptype_3zmq_4core_7message_Message));
  3910. __Pyx_INCREF(__pyx_t_2);
  3911. __pyx_t_4 = __Pyx_TypeCheck(__pyx_t_1, __pyx_t_2);
  3912. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3913. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3914. if (__pyx_t_4) {
  3915. /* "zmq/core/socket.pyx":503
  3916. * # it is always a copy, but always the same copy
  3917. * if isinstance(data, Message):
  3918. * data = data.buffer # <<<<<<<<<<<<<<
  3919. * return _send_copy(self.handle, data, flags)
  3920. * else:
  3921. */
  3922. __pyx_t_2 = PyObject_GetAttr(__pyx_v_data, __pyx_n_s__buffer); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3923. __Pyx_GOTREF(__pyx_t_2);
  3924. __Pyx_DECREF(__pyx_v_data);
  3925. __pyx_v_data = __pyx_t_2;
  3926. __pyx_t_2 = 0;
  3927. goto __pyx_L5;
  3928. }
  3929. __pyx_L5:;
  3930. /* "zmq/core/socket.pyx":504
  3931. * if isinstance(data, Message):
  3932. * data = data.buffer
  3933. * return _send_copy(self.handle, data, flags) # <<<<<<<<<<<<<<
  3934. * else:
  3935. * if isinstance(data, Message):
  3936. */
  3937. __Pyx_XDECREF(__pyx_r);
  3938. __pyx_t_5 = __pyx_v_self->handle;
  3939. __pyx_t_2 = __pyx_v_data;
  3940. __Pyx_INCREF(__pyx_t_2);
  3941. __pyx_t_6.__pyx_n = 1;
  3942. __pyx_t_6.flags = __pyx_v_flags;
  3943. __pyx_t_1 = __pyx_f_3zmq_4core_6socket__send_copy(__pyx_t_5, __pyx_t_2, &__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3944. __Pyx_GOTREF(__pyx_t_1);
  3945. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3946. __pyx_r = __pyx_t_1;
  3947. __pyx_t_1 = 0;
  3948. goto __pyx_L0;
  3949. goto __pyx_L4;
  3950. }
  3951. /*else*/ {
  3952. /* "zmq/core/socket.pyx":506
  3953. * return _send_copy(self.handle, data, flags)
  3954. * else:
  3955. * if isinstance(data, Message): # <<<<<<<<<<<<<<
  3956. * if track and not data.tracker:
  3957. * raise ValueError('Not a tracked message')
  3958. */
  3959. __pyx_t_1 = __pyx_v_data;
  3960. __Pyx_INCREF(__pyx_t_1);
  3961. __pyx_t_2 = ((PyObject *)((PyObject*)__pyx_ptype_3zmq_4core_7message_Message));
  3962. __Pyx_INCREF(__pyx_t_2);
  3963. __pyx_t_4 = __Pyx_TypeCheck(__pyx_t_1, __pyx_t_2);
  3964. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3965. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3966. if (__pyx_t_4) {
  3967. /* "zmq/core/socket.pyx":507
  3968. * else:
  3969. * if isinstance(data, Message):
  3970. * if track and not data.tracker: # <<<<<<<<<<<<<<
  3971. * raise ValueError('Not a tracked message')
  3972. * msg = data
  3973. */
  3974. __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_track); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3975. if (__pyx_t_4) {
  3976. __pyx_t_2 = PyObject_GetAttr(__pyx_v_data, __pyx_n_s__tracker); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3977. __Pyx_GOTREF(__pyx_t_2);
  3978. __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3979. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3980. __pyx_t_8 = (!__pyx_t_7);
  3981. __pyx_t_7 = __pyx_t_8;
  3982. } else {
  3983. __pyx_t_7 = __pyx_t_4;
  3984. }
  3985. if (__pyx_t_7) {
  3986. /* "zmq/core/socket.pyx":508
  3987. * if isinstance(data, Message):
  3988. * if track and not data.tracker:
  3989. * raise ValueError('Not a tracked message') # <<<<<<<<<<<<<<
  3990. * msg = data
  3991. * else:
  3992. */
  3993. __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3994. __Pyx_GOTREF(__pyx_t_2);
  3995. __Pyx_Raise(__pyx_t_2, 0, 0);
  3996. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3997. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3998. goto __pyx_L7;
  3999. }
  4000. __pyx_L7:;
  4001. /* "zmq/core/socket.pyx":509
  4002. * if track and not data.tracker:
  4003. * raise ValueError('Not a tracked message')
  4004. * msg = data # <<<<<<<<<<<<<<
  4005. * else:
  4006. * msg = Message(data, track=track)
  4007. */
  4008. __Pyx_INCREF(__pyx_v_data);
  4009. __Pyx_DECREF(__pyx_v_msg);
  4010. __pyx_v_msg = __pyx_v_data;
  4011. goto __pyx_L6;
  4012. }
  4013. /*else*/ {
  4014. /* "zmq/core/socket.pyx":511
  4015. * msg = data
  4016. * else:
  4017. * msg = Message(data, track=track) # <<<<<<<<<<<<<<
  4018. * return _send_message(self.handle, msg, flags)
  4019. *
  4020. */
  4021. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4022. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  4023. __Pyx_INCREF(__pyx_v_data);
  4024. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_data);
  4025. __Pyx_GIVEREF(__pyx_v_data);
  4026. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4027. __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  4028. if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__track), __pyx_v_track) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4029. __pyx_t_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_3zmq_4core_7message_Message)), ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4030. __Pyx_GOTREF(__pyx_t_3);
  4031. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  4032. __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  4033. __Pyx_DECREF(__pyx_v_msg);
  4034. __pyx_v_msg = __pyx_t_3;
  4035. __pyx_t_3 = 0;
  4036. }
  4037. __pyx_L6:;
  4038. /* "zmq/core/socket.pyx":512
  4039. * else:
  4040. * msg = Message(data, track=track)
  4041. * return _send_message(self.handle, msg, flags) # <<<<<<<<<<<<<<
  4042. *
  4043. * cpdef object recv(self, int flags=0, copy=True, track=False):
  4044. */
  4045. __Pyx_XDECREF(__pyx_r);
  4046. __pyx_t_5 = __pyx_v_self->handle;
  4047. if (!(likely(((__pyx_v_msg) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_msg, __pyx_ptype_3zmq_4core_7message_Message))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4048. __pyx_t_3 = __pyx_v_msg;
  4049. __Pyx_INCREF(__pyx_t_3);
  4050. __pyx_t_9.__pyx_n = 1;
  4051. __pyx_t_9.flags = __pyx_v_flags;
  4052. __pyx_t_1 = __pyx_f_3zmq_4core_6socket__send_message(__pyx_t_5, ((struct __pyx_obj_3zmq_4core_7message_Message *)__pyx_t_3), &__pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4053. __Pyx_GOTREF(__pyx_t_1);
  4054. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4055. __pyx_r = __pyx_t_1;
  4056. __pyx_t_1 = 0;
  4057. goto __pyx_L0;
  4058. }
  4059. __pyx_L4:;
  4060. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4061. goto __pyx_L0;
  4062. __pyx_L1_error:;
  4063. __Pyx_XDECREF(__pyx_t_1);
  4064. __Pyx_XDECREF(__pyx_t_2);
  4065. __Pyx_XDECREF(__pyx_t_3);
  4066. __Pyx_AddTraceback("zmq.core.socket.Socket.send");
  4067. __pyx_r = 0;
  4068. __pyx_L0:;
  4069. __Pyx_DECREF(__pyx_v_msg);
  4070. __Pyx_DECREF(__pyx_v_data);
  4071. __Pyx_XGIVEREF(__pyx_r);
  4072. __Pyx_RefNannyFinishContext();
  4073. return __pyx_r;
  4074. }
  4075. /* "zmq/core/socket.pyx":457
  4076. * #-------------------------------------------------------------------------
  4077. *
  4078. * cpdef object send(self, object data, int flags=0, copy=True, track=False): # <<<<<<<<<<<<<<
  4079. * """s.send(data, flags=0, copy=True, track=False)
  4080. *
  4081. */
  4082. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_10send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4083. static char __pyx_doc_3zmq_4core_6socket_6Socket_10send[] = "s.send(data, flags=0, copy=True, track=False)\n\n Send a message on this socket.\n\n This queues the message to be sent by the IO thread at a later time.\n\n Parameters\n ----------\n data : object, str, Message\n The content of the message.\n flags : int\n Any supported flag: NOBLOCK, SNDMORE.\n copy : bool\n Should the message be sent in a copying or non-copying manner.\n track : bool\n Should the message be tracked for notification that ZMQ has\n finished with it? (ignored if copy=True)\n\n Returns\n -------\n None : if `copy` or not track\n None if message was sent, raises an exception otherwise.\n MessageTracker : if track and not copy\n a MessageTracker object, whose `pending` property will\n be True until the send is completed.\n \n Raises\n ------\n TypeError\n If a unicode object is passed\n ValueError\n If `track=True`, but an untracked Message is passed.\n ZMQError\n If the send does not succeed for any reason.\n \n ";
  4084. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_10send(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  4085. PyObject *__pyx_v_data = 0;
  4086. int __pyx_v_flags;
  4087. PyObject *__pyx_v_copy = 0;
  4088. PyObject *__pyx_v_track = 0;
  4089. PyObject *__pyx_r = NULL;
  4090. PyObject *__pyx_t_1 = NULL;
  4091. int __pyx_t_2;
  4092. PyObject *__pyx_t_3 = NULL;
  4093. PyObject *__pyx_t_4 = NULL;
  4094. PyObject *__pyx_t_5 = NULL;
  4095. struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send __pyx_t_6;
  4096. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__data,&__pyx_n_s__flags,&__pyx_n_s__copy,&__pyx_n_s__track,0};
  4097. __Pyx_RefNannySetupContext("send");
  4098. if (unlikely(__pyx_kwds)) {
  4099. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  4100. PyObject* values[4] = {0,0,0,0};
  4101. values[2] = __pyx_k_15;
  4102. values[3] = __pyx_k_16;
  4103. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4104. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  4105. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  4106. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4107. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4108. case 0: break;
  4109. default: goto __pyx_L5_argtuple_error;
  4110. }
  4111. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4112. case 0:
  4113. values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data);
  4114. if (likely(values[0])) kw_args--;
  4115. else goto __pyx_L5_argtuple_error;
  4116. case 1:
  4117. if (kw_args > 0) {
  4118. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
  4119. if (value) { values[1] = value; kw_args--; }
  4120. }
  4121. case 2:
  4122. if (kw_args > 0) {
  4123. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__copy);
  4124. if (value) { values[2] = value; kw_args--; }
  4125. }
  4126. case 3:
  4127. if (kw_args > 0) {
  4128. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track);
  4129. if (value) { values[3] = value; kw_args--; }
  4130. }
  4131. }
  4132. if (unlikely(kw_args > 0)) {
  4133. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4134. }
  4135. __pyx_v_data = values[0];
  4136. if (values[1]) {
  4137. __pyx_v_flags = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4138. } else {
  4139. __pyx_v_flags = ((int)0);
  4140. }
  4141. __pyx_v_copy = values[2];
  4142. __pyx_v_track = values[3];
  4143. } else {
  4144. __pyx_v_flags = ((int)0);
  4145. __pyx_v_copy = __pyx_k_15;
  4146. __pyx_v_track = __pyx_k_16;
  4147. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4148. case 4: __pyx_v_track = PyTuple_GET_ITEM(__pyx_args, 3);
  4149. case 3: __pyx_v_copy = PyTuple_GET_ITEM(__pyx_args, 2);
  4150. case 2: __pyx_v_flags = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4151. case 1: __pyx_v_data = PyTuple_GET_ITEM(__pyx_args, 0);
  4152. break;
  4153. default: goto __pyx_L5_argtuple_error;
  4154. }
  4155. }
  4156. goto __pyx_L4_argument_unpacking_done;
  4157. __pyx_L5_argtuple_error:;
  4158. __Pyx_RaiseArgtupleInvalid("send", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4159. __pyx_L3_error:;
  4160. __Pyx_AddTraceback("zmq.core.socket.Socket.send");
  4161. __Pyx_RefNannyFinishContext();
  4162. return NULL;
  4163. __pyx_L4_argument_unpacking_done:;
  4164. __Pyx_XDECREF(__pyx_r);
  4165. __pyx_t_1 = __pyx_v_data;
  4166. __Pyx_INCREF(__pyx_t_1);
  4167. __pyx_t_2 = __pyx_v_flags;
  4168. __pyx_t_3 = __pyx_v_copy;
  4169. __Pyx_INCREF(__pyx_t_3);
  4170. __pyx_t_4 = __pyx_v_track;
  4171. __Pyx_INCREF(__pyx_t_4);
  4172. __pyx_t_6.__pyx_n = 3;
  4173. __pyx_t_6.flags = __pyx_t_2;
  4174. __pyx_t_6.copy = __pyx_t_3;
  4175. __pyx_t_6.track = __pyx_t_4;
  4176. __pyx_t_5 = ((struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->__pyx_vtab)->send(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), __pyx_t_1, 1, &__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4177. __Pyx_GOTREF(__pyx_t_5);
  4178. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4179. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4180. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4181. __pyx_r = __pyx_t_5;
  4182. __pyx_t_5 = 0;
  4183. goto __pyx_L0;
  4184. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4185. goto __pyx_L0;
  4186. __pyx_L1_error:;
  4187. __Pyx_XDECREF(__pyx_t_1);
  4188. __Pyx_XDECREF(__pyx_t_3);
  4189. __Pyx_XDECREF(__pyx_t_4);
  4190. __Pyx_XDECREF(__pyx_t_5);
  4191. __Pyx_AddTraceback("zmq.core.socket.Socket.send");
  4192. __pyx_r = NULL;
  4193. __pyx_L0:;
  4194. __Pyx_XGIVEREF(__pyx_r);
  4195. __Pyx_RefNannyFinishContext();
  4196. return __pyx_r;
  4197. }
  4198. /* "zmq/core/socket.pyx":514
  4199. * return _send_message(self.handle, msg, flags)
  4200. *
  4201. * cpdef object recv(self, int flags=0, copy=True, track=False): # <<<<<<<<<<<<<<
  4202. * """s.recv(flags=0, copy=True, track=False)
  4203. *
  4204. */
  4205. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_11recv(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4206. static PyObject *__pyx_f_3zmq_4core_6socket_6Socket_recv(struct __pyx_obj_3zmq_4core_6socket_Socket *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv *__pyx_optional_args) {
  4207. int __pyx_v_flags = ((int)0);
  4208. PyObject *__pyx_v_copy = __pyx_k_21;
  4209. PyObject *__pyx_v_track = __pyx_k_22;
  4210. PyObject *__pyx_r = NULL;
  4211. PyObject *__pyx_t_1 = NULL;
  4212. PyObject *__pyx_t_2 = NULL;
  4213. PyObject *__pyx_t_3 = NULL;
  4214. int __pyx_t_4;
  4215. struct __pyx_opt_args_3zmq_4core_6socket__recv_copy __pyx_t_5;
  4216. void *__pyx_t_6;
  4217. int __pyx_t_7;
  4218. struct __pyx_opt_args_3zmq_4core_6socket__recv_message __pyx_t_8;
  4219. __Pyx_RefNannySetupContext("recv");
  4220. if (__pyx_optional_args) {
  4221. if (__pyx_optional_args->__pyx_n > 0) {
  4222. __pyx_v_flags = __pyx_optional_args->flags;
  4223. if (__pyx_optional_args->__pyx_n > 1) {
  4224. __pyx_v_copy = __pyx_optional_args->copy;
  4225. if (__pyx_optional_args->__pyx_n > 2) {
  4226. __pyx_v_track = __pyx_optional_args->track;
  4227. }
  4228. }
  4229. }
  4230. }
  4231. /* Check if called by wrapper */
  4232. if (unlikely(__pyx_skip_dispatch)) ;
  4233. /* Check if overriden in Python */
  4234. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  4235. __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__recv); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4236. __Pyx_GOTREF(__pyx_t_1);
  4237. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_3zmq_4core_6socket_6Socket_11recv)) {
  4238. __Pyx_XDECREF(__pyx_r);
  4239. __pyx_t_2 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4240. __Pyx_GOTREF(__pyx_t_2);
  4241. __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4242. __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  4243. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  4244. __Pyx_GIVEREF(__pyx_t_2);
  4245. __Pyx_INCREF(__pyx_v_copy);
  4246. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_copy);
  4247. __Pyx_GIVEREF(__pyx_v_copy);
  4248. __Pyx_INCREF(__pyx_v_track);
  4249. PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_track);
  4250. __Pyx_GIVEREF(__pyx_v_track);
  4251. __pyx_t_2 = 0;
  4252. __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4253. __Pyx_GOTREF(__pyx_t_2);
  4254. __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  4255. __pyx_r = __pyx_t_2;
  4256. __pyx_t_2 = 0;
  4257. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4258. goto __pyx_L0;
  4259. }
  4260. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4261. }
  4262. /* "zmq/core/socket.pyx":545
  4263. * for any of the reasons zmq_recvmsg might fail.
  4264. * """
  4265. * _check_closed(self) # <<<<<<<<<<<<<<
  4266. *
  4267. * if copy:
  4268. */
  4269. __pyx_t_1 = ((PyObject *)__pyx_v_self);
  4270. __Pyx_INCREF(__pyx_t_1);
  4271. __pyx_t_2 = __pyx_f_3zmq_4core_6socket__check_closed(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4272. __Pyx_GOTREF(__pyx_t_2);
  4273. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4274. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4275. /* "zmq/core/socket.pyx":547
  4276. * _check_closed(self)
  4277. *
  4278. * if copy: # <<<<<<<<<<<<<<
  4279. * return _recv_copy(self.handle, flags)
  4280. * else:
  4281. */
  4282. __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_copy); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4283. if (__pyx_t_4) {
  4284. /* "zmq/core/socket.pyx":548
  4285. *
  4286. * if copy:
  4287. * return _recv_copy(self.handle, flags) # <<<<<<<<<<<<<<
  4288. * else:
  4289. * return _recv_message(self.handle, flags, track)
  4290. */
  4291. __Pyx_XDECREF(__pyx_r);
  4292. __pyx_t_5.__pyx_n = 1;
  4293. __pyx_t_5.flags = __pyx_v_flags;
  4294. __pyx_t_2 = __pyx_f_3zmq_4core_6socket__recv_copy(__pyx_v_self->handle, &__pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4295. __Pyx_GOTREF(__pyx_t_2);
  4296. __pyx_r = __pyx_t_2;
  4297. __pyx_t_2 = 0;
  4298. goto __pyx_L0;
  4299. goto __pyx_L3;
  4300. }
  4301. /*else*/ {
  4302. /* "zmq/core/socket.pyx":550
  4303. * return _recv_copy(self.handle, flags)
  4304. * else:
  4305. * return _recv_message(self.handle, flags, track) # <<<<<<<<<<<<<<
  4306. *
  4307. * def send_multipart(self, msg_parts, int flags=0, copy=True, track=False):
  4308. */
  4309. __Pyx_XDECREF(__pyx_r);
  4310. __pyx_t_6 = __pyx_v_self->handle;
  4311. __pyx_t_7 = __pyx_v_flags;
  4312. __pyx_t_2 = __pyx_v_track;
  4313. __Pyx_INCREF(__pyx_t_2);
  4314. __pyx_t_8.__pyx_n = 2;
  4315. __pyx_t_8.flags = __pyx_t_7;
  4316. __pyx_t_8.track = __pyx_t_2;
  4317. __pyx_t_1 = ((PyObject *)__pyx_f_3zmq_4core_6socket__recv_message(__pyx_t_6, &__pyx_t_8)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4318. __Pyx_GOTREF(__pyx_t_1);
  4319. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4320. __pyx_r = __pyx_t_1;
  4321. __pyx_t_1 = 0;
  4322. goto __pyx_L0;
  4323. }
  4324. __pyx_L3:;
  4325. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4326. goto __pyx_L0;
  4327. __pyx_L1_error:;
  4328. __Pyx_XDECREF(__pyx_t_1);
  4329. __Pyx_XDECREF(__pyx_t_2);
  4330. __Pyx_XDECREF(__pyx_t_3);
  4331. __Pyx_AddTraceback("zmq.core.socket.Socket.recv");
  4332. __pyx_r = 0;
  4333. __pyx_L0:;
  4334. __Pyx_XGIVEREF(__pyx_r);
  4335. __Pyx_RefNannyFinishContext();
  4336. return __pyx_r;
  4337. }
  4338. /* "zmq/core/socket.pyx":514
  4339. * return _send_message(self.handle, msg, flags)
  4340. *
  4341. * cpdef object recv(self, int flags=0, copy=True, track=False): # <<<<<<<<<<<<<<
  4342. * """s.recv(flags=0, copy=True, track=False)
  4343. *
  4344. */
  4345. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_11recv(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4346. static char __pyx_doc_3zmq_4core_6socket_6Socket_11recv[] = "s.recv(flags=0, copy=True, track=False)\n\n Receive a message.\n\n Parameters\n ----------\n flags : int\n Any supported flag: NOBLOCK. If NOBLOCK is set, this method\n will raise a ZMQError with EAGAIN if a message is not ready.\n If NOBLOCK is not set, then this method will block until a\n message arrives.\n copy : bool\n Should the message be received in a copying or non-copying manner?\n If False a Message object is returned, if True a string copy of\n message is returned.\n track : bool\n Should the message be tracked for notification that ZMQ has\n finished with it? (ignored if copy=True)\n\n Returns\n -------\n msg : str, Message\n The returned message. If `copy` is False, then it will be a Message,\n otherwise a str.\n \n Raises\n ------\n ZMQError\n for any of the reasons zmq_recvmsg might fail.\n ";
  4347. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_11recv(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  4348. int __pyx_v_flags;
  4349. PyObject *__pyx_v_copy = 0;
  4350. PyObject *__pyx_v_track = 0;
  4351. PyObject *__pyx_r = NULL;
  4352. int __pyx_t_1;
  4353. PyObject *__pyx_t_2 = NULL;
  4354. PyObject *__pyx_t_3 = NULL;
  4355. PyObject *__pyx_t_4 = NULL;
  4356. struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv __pyx_t_5;
  4357. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__flags,&__pyx_n_s__copy,&__pyx_n_s__track,0};
  4358. __Pyx_RefNannySetupContext("recv");
  4359. if (unlikely(__pyx_kwds)) {
  4360. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  4361. PyObject* values[3] = {0,0,0};
  4362. values[1] = __pyx_k_21;
  4363. values[2] = __pyx_k_22;
  4364. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4365. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  4366. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4367. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4368. case 0: break;
  4369. default: goto __pyx_L5_argtuple_error;
  4370. }
  4371. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4372. case 0:
  4373. if (kw_args > 0) {
  4374. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
  4375. if (value) { values[0] = value; kw_args--; }
  4376. }
  4377. case 1:
  4378. if (kw_args > 0) {
  4379. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__copy);
  4380. if (value) { values[1] = value; kw_args--; }
  4381. }
  4382. case 2:
  4383. if (kw_args > 0) {
  4384. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track);
  4385. if (value) { values[2] = value; kw_args--; }
  4386. }
  4387. }
  4388. if (unlikely(kw_args > 0)) {
  4389. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "recv") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4390. }
  4391. if (values[0]) {
  4392. __pyx_v_flags = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4393. } else {
  4394. __pyx_v_flags = ((int)0);
  4395. }
  4396. __pyx_v_copy = values[1];
  4397. __pyx_v_track = values[2];
  4398. } else {
  4399. __pyx_v_flags = ((int)0);
  4400. __pyx_v_copy = __pyx_k_21;
  4401. __pyx_v_track = __pyx_k_22;
  4402. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4403. case 3: __pyx_v_track = PyTuple_GET_ITEM(__pyx_args, 2);
  4404. case 2: __pyx_v_copy = PyTuple_GET_ITEM(__pyx_args, 1);
  4405. case 1: __pyx_v_flags = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4406. case 0: break;
  4407. default: goto __pyx_L5_argtuple_error;
  4408. }
  4409. }
  4410. goto __pyx_L4_argument_unpacking_done;
  4411. __pyx_L5_argtuple_error:;
  4412. __Pyx_RaiseArgtupleInvalid("recv", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4413. __pyx_L3_error:;
  4414. __Pyx_AddTraceback("zmq.core.socket.Socket.recv");
  4415. __Pyx_RefNannyFinishContext();
  4416. return NULL;
  4417. __pyx_L4_argument_unpacking_done:;
  4418. __Pyx_XDECREF(__pyx_r);
  4419. __pyx_t_1 = __pyx_v_flags;
  4420. __pyx_t_2 = __pyx_v_copy;
  4421. __Pyx_INCREF(__pyx_t_2);
  4422. __pyx_t_3 = __pyx_v_track;
  4423. __Pyx_INCREF(__pyx_t_3);
  4424. __pyx_t_5.__pyx_n = 3;
  4425. __pyx_t_5.flags = __pyx_t_1;
  4426. __pyx_t_5.copy = __pyx_t_2;
  4427. __pyx_t_5.track = __pyx_t_3;
  4428. __pyx_t_4 = ((struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->__pyx_vtab)->recv(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), 1, &__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4429. __Pyx_GOTREF(__pyx_t_4);
  4430. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4431. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4432. __pyx_r = __pyx_t_4;
  4433. __pyx_t_4 = 0;
  4434. goto __pyx_L0;
  4435. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4436. goto __pyx_L0;
  4437. __pyx_L1_error:;
  4438. __Pyx_XDECREF(__pyx_t_2);
  4439. __Pyx_XDECREF(__pyx_t_3);
  4440. __Pyx_XDECREF(__pyx_t_4);
  4441. __Pyx_AddTraceback("zmq.core.socket.Socket.recv");
  4442. __pyx_r = NULL;
  4443. __pyx_L0:;
  4444. __Pyx_XGIVEREF(__pyx_r);
  4445. __Pyx_RefNannyFinishContext();
  4446. return __pyx_r;
  4447. }
  4448. /* "zmq/core/socket.pyx":552
  4449. * return _recv_message(self.handle, flags, track)
  4450. *
  4451. * def send_multipart(self, msg_parts, int flags=0, copy=True, track=False): # <<<<<<<<<<<<<<
  4452. * """s.send_multipart(msg_parts, flags=0, copy=True, track=False)
  4453. *
  4454. */
  4455. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_12send_multipart(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4456. static char __pyx_doc_3zmq_4core_6socket_6Socket_12send_multipart[] = "s.send_multipart(msg_parts, flags=0, copy=True, track=False)\n\n Send a sequence of messages as a multipart message.\n\n Parameters\n ----------\n msg_parts : iterable\n A sequence of messages to send as a multipart message. Each element\n can be any sendable object (Message, bytes, buffer-providers)\n flags : int, optional\n Only the NOBLOCK flagis supported, SNDMORE is handled\n automatically.\n copy : bool, optional\n Should the message(s) be sent in a copying or non-copying manner.\n track : bool, optional\n Should the message(s) be tracked for notification that ZMQ has\n finished with it (ignored if copy=True).\n \n Returns\n -------\n None : if copy or not track\n MessageTracker : if track and not copy\n a MessageTracker object, whose `pending` property will\n be True until the last send is completed.\n ";
  4457. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_12send_multipart(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  4458. PyObject *__pyx_v_msg_parts = 0;
  4459. int __pyx_v_flags;
  4460. PyObject *__pyx_v_copy = 0;
  4461. PyObject *__pyx_v_track = 0;
  4462. PyObject *__pyx_v_msg;
  4463. PyObject *__pyx_r = NULL;
  4464. Py_ssize_t __pyx_t_1;
  4465. PyObject *__pyx_t_2 = NULL;
  4466. PyObject *__pyx_t_3 = NULL;
  4467. PyObject *__pyx_t_4 = NULL;
  4468. PyObject *__pyx_t_5 = NULL;
  4469. PyObject *__pyx_t_6 = NULL;
  4470. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__msg_parts,&__pyx_n_s__flags,&__pyx_n_s__copy,&__pyx_n_s__track,0};
  4471. __Pyx_RefNannySetupContext("send_multipart");
  4472. if (unlikely(__pyx_kwds)) {
  4473. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  4474. PyObject* values[4] = {0,0,0,0};
  4475. values[2] = __pyx_k_23;
  4476. values[3] = __pyx_k_24;
  4477. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4478. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  4479. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  4480. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4481. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4482. case 0: break;
  4483. default: goto __pyx_L5_argtuple_error;
  4484. }
  4485. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4486. case 0:
  4487. values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__msg_parts);
  4488. if (likely(values[0])) kw_args--;
  4489. else goto __pyx_L5_argtuple_error;
  4490. case 1:
  4491. if (kw_args > 0) {
  4492. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
  4493. if (value) { values[1] = value; kw_args--; }
  4494. }
  4495. case 2:
  4496. if (kw_args > 0) {
  4497. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__copy);
  4498. if (value) { values[2] = value; kw_args--; }
  4499. }
  4500. case 3:
  4501. if (kw_args > 0) {
  4502. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track);
  4503. if (value) { values[3] = value; kw_args--; }
  4504. }
  4505. }
  4506. if (unlikely(kw_args > 0)) {
  4507. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send_multipart") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4508. }
  4509. __pyx_v_msg_parts = values[0];
  4510. if (values[1]) {
  4511. __pyx_v_flags = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4512. } else {
  4513. __pyx_v_flags = ((int)0);
  4514. }
  4515. __pyx_v_copy = values[2];
  4516. __pyx_v_track = values[3];
  4517. } else {
  4518. __pyx_v_flags = ((int)0);
  4519. __pyx_v_copy = __pyx_k_23;
  4520. __pyx_v_track = __pyx_k_24;
  4521. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4522. case 4: __pyx_v_track = PyTuple_GET_ITEM(__pyx_args, 3);
  4523. case 3: __pyx_v_copy = PyTuple_GET_ITEM(__pyx_args, 2);
  4524. case 2: __pyx_v_flags = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4525. case 1: __pyx_v_msg_parts = PyTuple_GET_ITEM(__pyx_args, 0);
  4526. break;
  4527. default: goto __pyx_L5_argtuple_error;
  4528. }
  4529. }
  4530. goto __pyx_L4_argument_unpacking_done;
  4531. __pyx_L5_argtuple_error:;
  4532. __Pyx_RaiseArgtupleInvalid("send_multipart", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4533. __pyx_L3_error:;
  4534. __Pyx_AddTraceback("zmq.core.socket.Socket.send_multipart");
  4535. __Pyx_RefNannyFinishContext();
  4536. return NULL;
  4537. __pyx_L4_argument_unpacking_done:;
  4538. __pyx_v_msg = Py_None; __Pyx_INCREF(Py_None);
  4539. /* "zmq/core/socket.pyx":578
  4540. * be True until the last send is completed.
  4541. * """
  4542. * for msg in msg_parts[:-1]: # <<<<<<<<<<<<<<
  4543. * self.send(msg, SNDMORE|flags, copy=copy, track=track)
  4544. * # Send the last part without the extra SNDMORE flag.
  4545. */
  4546. __pyx_t_2 = __Pyx_PySequence_GetSlice(__pyx_v_msg_parts, 0, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4547. __Pyx_GOTREF(__pyx_t_2);
  4548. if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
  4549. __pyx_t_1 = 0; __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3);
  4550. } else {
  4551. __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4552. __Pyx_GOTREF(__pyx_t_3);
  4553. }
  4554. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4555. for (;;) {
  4556. if (likely(PyList_CheckExact(__pyx_t_3))) {
  4557. if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
  4558. __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++;
  4559. } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
  4560. if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
  4561. __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++;
  4562. } else {
  4563. __pyx_t_2 = PyIter_Next(__pyx_t_3);
  4564. if (!__pyx_t_2) {
  4565. if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4566. break;
  4567. }
  4568. __Pyx_GOTREF(__pyx_t_2);
  4569. }
  4570. __Pyx_DECREF(__pyx_v_msg);
  4571. __pyx_v_msg = __pyx_t_2;
  4572. __pyx_t_2 = 0;
  4573. /* "zmq/core/socket.pyx":579
  4574. * """
  4575. * for msg in msg_parts[:-1]:
  4576. * self.send(msg, SNDMORE|flags, copy=copy, track=track) # <<<<<<<<<<<<<<
  4577. * # Send the last part without the extra SNDMORE flag.
  4578. * return self.send(msg_parts[-1], flags, copy=copy, track=track)
  4579. */
  4580. __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__send); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4581. __Pyx_GOTREF(__pyx_t_2);
  4582. __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__SNDMORE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4583. __Pyx_GOTREF(__pyx_t_4);
  4584. __pyx_t_5 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4585. __Pyx_GOTREF(__pyx_t_5);
  4586. __pyx_t_6 = PyNumber_Or(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4587. __Pyx_GOTREF(__pyx_t_6);
  4588. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4589. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4590. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4591. __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  4592. __Pyx_INCREF(__pyx_v_msg);
  4593. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_msg);
  4594. __Pyx_GIVEREF(__pyx_v_msg);
  4595. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
  4596. __Pyx_GIVEREF(__pyx_t_6);
  4597. __pyx_t_6 = 0;
  4598. __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4599. __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  4600. if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__copy), __pyx_v_copy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4601. if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__track), __pyx_v_track) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4602. __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4603. __Pyx_GOTREF(__pyx_t_4);
  4604. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4605. __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  4606. __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  4607. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4608. }
  4609. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4610. /* "zmq/core/socket.pyx":581
  4611. * self.send(msg, SNDMORE|flags, copy=copy, track=track)
  4612. * # Send the last part without the extra SNDMORE flag.
  4613. * return self.send(msg_parts[-1], flags, copy=copy, track=track) # <<<<<<<<<<<<<<
  4614. *
  4615. * def recv_multipart(self, int flags=0, copy=True, track=False):
  4616. */
  4617. __Pyx_XDECREF(__pyx_r);
  4618. __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__send); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4619. __Pyx_GOTREF(__pyx_t_3);
  4620. __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_msg_parts, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4621. __Pyx_GOTREF(__pyx_t_4);
  4622. __pyx_t_6 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4623. __Pyx_GOTREF(__pyx_t_6);
  4624. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4625. __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  4626. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  4627. __Pyx_GIVEREF(__pyx_t_4);
  4628. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
  4629. __Pyx_GIVEREF(__pyx_t_6);
  4630. __pyx_t_4 = 0;
  4631. __pyx_t_6 = 0;
  4632. __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4633. __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  4634. if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__copy), __pyx_v_copy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4635. if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__track), __pyx_v_track) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4636. __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_3, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4637. __Pyx_GOTREF(__pyx_t_4);
  4638. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4639. __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  4640. __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  4641. __pyx_r = __pyx_t_4;
  4642. __pyx_t_4 = 0;
  4643. goto __pyx_L0;
  4644. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4645. goto __pyx_L0;
  4646. __pyx_L1_error:;
  4647. __Pyx_XDECREF(__pyx_t_2);
  4648. __Pyx_XDECREF(__pyx_t_3);
  4649. __Pyx_XDECREF(__pyx_t_4);
  4650. __Pyx_XDECREF(__pyx_t_5);
  4651. __Pyx_XDECREF(__pyx_t_6);
  4652. __Pyx_AddTraceback("zmq.core.socket.Socket.send_multipart");
  4653. __pyx_r = NULL;
  4654. __pyx_L0:;
  4655. __Pyx_DECREF(__pyx_v_msg);
  4656. __Pyx_XGIVEREF(__pyx_r);
  4657. __Pyx_RefNannyFinishContext();
  4658. return __pyx_r;
  4659. }
  4660. /* "zmq/core/socket.pyx":583
  4661. * return self.send(msg_parts[-1], flags, copy=copy, track=track)
  4662. *
  4663. * def recv_multipart(self, int flags=0, copy=True, track=False): # <<<<<<<<<<<<<<
  4664. * """s.recv_multipart(flags=0, copy=True, track=False)
  4665. *
  4666. */
  4667. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_13recv_multipart(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4668. static char __pyx_doc_3zmq_4core_6socket_6Socket_13recv_multipart[] = "s.recv_multipart(flags=0, copy=True, track=False)\n\n Receive a multipart message as a list of messages.\n\n Parameters\n ----------\n flags : int, optional\n Any supported flag: NOBLOCK. If NOBLOCK is set, this method\n will raise a ZMQError with EAGAIN if a message is not ready.\n If NOBLOCK is not set, then this method will block until a\n message arrives.\n copy : bool, optional\n Should the message(s) be received in a copying or non-copying manner?\n If False a Message object is returned for part, if True a string copy of\n message is returned for each message part.\n track : bool, optional\n Should the message(s) be tracked for notification that ZMQ has\n finished with it? (ignored if copy=True)\n \n Returns\n -------\n msg_parts : list\n A list of messages in the multipart message; either Messages or strs,\n depending on `copy`.\n ";
  4669. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_13recv_multipart(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  4670. int __pyx_v_flags;
  4671. PyObject *__pyx_v_copy = 0;
  4672. PyObject *__pyx_v_track = 0;
  4673. PyObject *__pyx_v_parts;
  4674. PyObject *__pyx_v_part;
  4675. PyObject *__pyx_r = NULL;
  4676. PyObject *__pyx_t_1 = NULL;
  4677. PyObject *__pyx_t_2 = NULL;
  4678. PyObject *__pyx_t_3 = NULL;
  4679. PyObject *__pyx_t_4 = NULL;
  4680. int __pyx_t_5;
  4681. int __pyx_t_6;
  4682. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__flags,&__pyx_n_s__copy,&__pyx_n_s__track,0};
  4683. __Pyx_RefNannySetupContext("recv_multipart");
  4684. if (unlikely(__pyx_kwds)) {
  4685. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  4686. PyObject* values[3] = {0,0,0};
  4687. values[1] = __pyx_k_25;
  4688. values[2] = __pyx_k_26;
  4689. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4690. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  4691. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4692. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4693. case 0: break;
  4694. default: goto __pyx_L5_argtuple_error;
  4695. }
  4696. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4697. case 0:
  4698. if (kw_args > 0) {
  4699. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
  4700. if (value) { values[0] = value; kw_args--; }
  4701. }
  4702. case 1:
  4703. if (kw_args > 0) {
  4704. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__copy);
  4705. if (value) { values[1] = value; kw_args--; }
  4706. }
  4707. case 2:
  4708. if (kw_args > 0) {
  4709. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__track);
  4710. if (value) { values[2] = value; kw_args--; }
  4711. }
  4712. }
  4713. if (unlikely(kw_args > 0)) {
  4714. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "recv_multipart") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4715. }
  4716. if (values[0]) {
  4717. __pyx_v_flags = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4718. } else {
  4719. __pyx_v_flags = ((int)0);
  4720. }
  4721. __pyx_v_copy = values[1];
  4722. __pyx_v_track = values[2];
  4723. } else {
  4724. __pyx_v_flags = ((int)0);
  4725. __pyx_v_copy = __pyx_k_25;
  4726. __pyx_v_track = __pyx_k_26;
  4727. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4728. case 3: __pyx_v_track = PyTuple_GET_ITEM(__pyx_args, 2);
  4729. case 2: __pyx_v_copy = PyTuple_GET_ITEM(__pyx_args, 1);
  4730. case 1: __pyx_v_flags = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4731. case 0: break;
  4732. default: goto __pyx_L5_argtuple_error;
  4733. }
  4734. }
  4735. goto __pyx_L4_argument_unpacking_done;
  4736. __pyx_L5_argtuple_error:;
  4737. __Pyx_RaiseArgtupleInvalid("recv_multipart", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4738. __pyx_L3_error:;
  4739. __Pyx_AddTraceback("zmq.core.socket.Socket.recv_multipart");
  4740. __Pyx_RefNannyFinishContext();
  4741. return NULL;
  4742. __pyx_L4_argument_unpacking_done:;
  4743. __pyx_v_parts = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  4744. __pyx_v_part = Py_None; __Pyx_INCREF(Py_None);
  4745. /* "zmq/core/socket.pyx":609
  4746. * depending on `copy`.
  4747. * """
  4748. * parts = [] # <<<<<<<<<<<<<<
  4749. * while True:
  4750. * part = self.recv(flags, copy=copy, track=track)
  4751. */
  4752. __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4753. __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  4754. __Pyx_DECREF(((PyObject *)__pyx_v_parts));
  4755. __pyx_v_parts = __pyx_t_1;
  4756. __pyx_t_1 = 0;
  4757. /* "zmq/core/socket.pyx":610
  4758. * """
  4759. * parts = []
  4760. * while True: # <<<<<<<<<<<<<<
  4761. * part = self.recv(flags, copy=copy, track=track)
  4762. * parts.append(part)
  4763. */
  4764. while (1) {
  4765. if (!1) break;
  4766. /* "zmq/core/socket.pyx":611
  4767. * parts = []
  4768. * while True:
  4769. * part = self.recv(flags, copy=copy, track=track) # <<<<<<<<<<<<<<
  4770. * parts.append(part)
  4771. * if self.rcvmore():
  4772. */
  4773. __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__recv); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4774. __Pyx_GOTREF(__pyx_t_1);
  4775. __pyx_t_2 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4776. __Pyx_GOTREF(__pyx_t_2);
  4777. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4778. __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  4779. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  4780. __Pyx_GIVEREF(__pyx_t_2);
  4781. __pyx_t_2 = 0;
  4782. __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4783. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  4784. if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__copy), __pyx_v_copy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4785. if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__track), __pyx_v_track) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4786. __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4787. __Pyx_GOTREF(__pyx_t_4);
  4788. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4789. __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  4790. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  4791. __Pyx_DECREF(__pyx_v_part);
  4792. __pyx_v_part = __pyx_t_4;
  4793. __pyx_t_4 = 0;
  4794. /* "zmq/core/socket.pyx":612
  4795. * while True:
  4796. * part = self.recv(flags, copy=copy, track=track)
  4797. * parts.append(part) # <<<<<<<<<<<<<<
  4798. * if self.rcvmore():
  4799. * continue
  4800. */
  4801. if (unlikely(__pyx_v_parts == Py_None)) {
  4802. PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4803. }
  4804. __pyx_t_5 = PyList_Append(__pyx_v_parts, __pyx_v_part); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4805. /* "zmq/core/socket.pyx":613
  4806. * part = self.recv(flags, copy=copy, track=track)
  4807. * parts.append(part)
  4808. * if self.rcvmore(): # <<<<<<<<<<<<<<
  4809. * continue
  4810. * else:
  4811. */
  4812. __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rcvmore); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4813. __Pyx_GOTREF(__pyx_t_4);
  4814. __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4815. __Pyx_GOTREF(__pyx_t_2);
  4816. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4817. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4818. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4819. if (__pyx_t_6) {
  4820. /* "zmq/core/socket.pyx":614
  4821. * parts.append(part)
  4822. * if self.rcvmore():
  4823. * continue # <<<<<<<<<<<<<<
  4824. * else:
  4825. * break
  4826. */
  4827. goto __pyx_L6_continue;
  4828. goto __pyx_L8;
  4829. }
  4830. /*else*/ {
  4831. /* "zmq/core/socket.pyx":616
  4832. * continue
  4833. * else:
  4834. * break # <<<<<<<<<<<<<<
  4835. * return parts
  4836. *
  4837. */
  4838. goto __pyx_L7_break;
  4839. }
  4840. __pyx_L8:;
  4841. __pyx_L6_continue:;
  4842. }
  4843. __pyx_L7_break:;
  4844. /* "zmq/core/socket.pyx":617
  4845. * else:
  4846. * break
  4847. * return parts # <<<<<<<<<<<<<<
  4848. *
  4849. * def rcvmore(self):
  4850. */
  4851. __Pyx_XDECREF(__pyx_r);
  4852. __Pyx_INCREF(((PyObject *)__pyx_v_parts));
  4853. __pyx_r = ((PyObject *)__pyx_v_parts);
  4854. goto __pyx_L0;
  4855. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4856. goto __pyx_L0;
  4857. __pyx_L1_error:;
  4858. __Pyx_XDECREF(__pyx_t_1);
  4859. __Pyx_XDECREF(__pyx_t_2);
  4860. __Pyx_XDECREF(__pyx_t_3);
  4861. __Pyx_XDECREF(__pyx_t_4);
  4862. __Pyx_AddTraceback("zmq.core.socket.Socket.recv_multipart");
  4863. __pyx_r = NULL;
  4864. __pyx_L0:;
  4865. __Pyx_DECREF(__pyx_v_parts);
  4866. __Pyx_DECREF(__pyx_v_part);
  4867. __Pyx_XGIVEREF(__pyx_r);
  4868. __Pyx_RefNannyFinishContext();
  4869. return __pyx_r;
  4870. }
  4871. /* "zmq/core/socket.pyx":619
  4872. * return parts
  4873. *
  4874. * def rcvmore(self): # <<<<<<<<<<<<<<
  4875. * """s.rcvmore()
  4876. *
  4877. */
  4878. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_14rcvmore(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  4879. static char __pyx_doc_3zmq_4core_6socket_6Socket_14rcvmore[] = "s.rcvmore()\n\n Are there more parts to a multipart message?\n \n Returns\n -------\n more : bool\n whether we are in the middle of a multipart message.\n ";
  4880. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_14rcvmore(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  4881. PyObject *__pyx_v_more;
  4882. PyObject *__pyx_r = NULL;
  4883. PyObject *__pyx_t_1 = NULL;
  4884. PyObject *__pyx_t_2 = NULL;
  4885. PyObject *__pyx_t_3 = NULL;
  4886. int __pyx_t_4;
  4887. __Pyx_RefNannySetupContext("rcvmore");
  4888. __pyx_v_more = Py_None; __Pyx_INCREF(Py_None);
  4889. /* "zmq/core/socket.pyx":629
  4890. * whether we are in the middle of a multipart message.
  4891. * """
  4892. * more = self.getsockopt(RCVMORE) # <<<<<<<<<<<<<<
  4893. * return bool(more)
  4894. *
  4895. */
  4896. __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__getsockopt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4897. __Pyx_GOTREF(__pyx_t_1);
  4898. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__RCVMORE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4899. __Pyx_GOTREF(__pyx_t_2);
  4900. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4901. __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  4902. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  4903. __Pyx_GIVEREF(__pyx_t_2);
  4904. __pyx_t_2 = 0;
  4905. __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4906. __Pyx_GOTREF(__pyx_t_2);
  4907. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4908. __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  4909. __Pyx_DECREF(__pyx_v_more);
  4910. __pyx_v_more = __pyx_t_2;
  4911. __pyx_t_2 = 0;
  4912. /* "zmq/core/socket.pyx":630
  4913. * """
  4914. * more = self.getsockopt(RCVMORE)
  4915. * return bool(more) # <<<<<<<<<<<<<<
  4916. *
  4917. * def send_unicode(self, u, int flags=0, copy=False, encoding='utf-8'):
  4918. */
  4919. __Pyx_XDECREF(__pyx_r);
  4920. __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_more); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4921. __pyx_t_2 = __Pyx_PyBool_FromLong((!(!__pyx_t_4))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 630; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  4922. __Pyx_GOTREF(__pyx_t_2);
  4923. __pyx_r = __pyx_t_2;
  4924. __pyx_t_2 = 0;
  4925. goto __pyx_L0;
  4926. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4927. goto __pyx_L0;
  4928. __pyx_L1_error:;
  4929. __Pyx_XDECREF(__pyx_t_1);
  4930. __Pyx_XDECREF(__pyx_t_2);
  4931. __Pyx_XDECREF(__pyx_t_3);
  4932. __Pyx_AddTraceback("zmq.core.socket.Socket.rcvmore");
  4933. __pyx_r = NULL;
  4934. __pyx_L0:;
  4935. __Pyx_DECREF(__pyx_v_more);
  4936. __Pyx_XGIVEREF(__pyx_r);
  4937. __Pyx_RefNannyFinishContext();
  4938. return __pyx_r;
  4939. }
  4940. /* "zmq/core/socket.pyx":632
  4941. * return bool(more)
  4942. *
  4943. * def send_unicode(self, u, int flags=0, copy=False, encoding='utf-8'): # <<<<<<<<<<<<<<
  4944. * """s.send_unicode(u, flags=0, copy=False, encoding='utf-8')
  4945. *
  4946. */
  4947. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_15send_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4948. static char __pyx_doc_3zmq_4core_6socket_6Socket_15send_unicode[] = "s.send_unicode(u, flags=0, copy=False, encoding='utf-8')\n\n Send a Python unicode object as a message with an encoding.\n\n Parameters\n ----------\n u : Python unicode object\n The unicode string to send.\n flags : int, optional\n Any valid send flag.\n encoding : str [default: 'utf-8']\n The encoding to be used\n ";
  4949. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_15send_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  4950. PyObject *__pyx_v_u = 0;
  4951. int __pyx_v_flags;
  4952. PyObject *__pyx_v_copy = 0;
  4953. PyObject *__pyx_v_encoding = 0;
  4954. PyObject *__pyx_r = NULL;
  4955. PyObject *__pyx_t_1 = NULL;
  4956. PyObject *__pyx_t_2 = NULL;
  4957. int __pyx_t_3;
  4958. int __pyx_t_4;
  4959. PyObject *__pyx_t_5 = NULL;
  4960. PyObject *__pyx_t_6 = NULL;
  4961. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__u,&__pyx_n_s__flags,&__pyx_n_s__copy,&__pyx_n_s__encoding,0};
  4962. __Pyx_RefNannySetupContext("send_unicode");
  4963. if (unlikely(__pyx_kwds)) {
  4964. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  4965. PyObject* values[4] = {0,0,0,0};
  4966. values[2] = __pyx_k_27;
  4967. values[3] = ((PyObject *)__pyx_kp_s_6);
  4968. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4969. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  4970. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  4971. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4972. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4973. case 0: break;
  4974. default: goto __pyx_L5_argtuple_error;
  4975. }
  4976. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4977. case 0:
  4978. values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__u);
  4979. if (likely(values[0])) kw_args--;
  4980. else goto __pyx_L5_argtuple_error;
  4981. case 1:
  4982. if (kw_args > 0) {
  4983. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
  4984. if (value) { values[1] = value; kw_args--; }
  4985. }
  4986. case 2:
  4987. if (kw_args > 0) {
  4988. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__copy);
  4989. if (value) { values[2] = value; kw_args--; }
  4990. }
  4991. case 3:
  4992. if (kw_args > 0) {
  4993. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding);
  4994. if (value) { values[3] = value; kw_args--; }
  4995. }
  4996. }
  4997. if (unlikely(kw_args > 0)) {
  4998. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send_unicode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  4999. }
  5000. __pyx_v_u = values[0];
  5001. if (values[1]) {
  5002. __pyx_v_flags = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5003. } else {
  5004. __pyx_v_flags = ((int)0);
  5005. }
  5006. __pyx_v_copy = values[2];
  5007. __pyx_v_encoding = values[3];
  5008. } else {
  5009. __pyx_v_flags = ((int)0);
  5010. __pyx_v_copy = __pyx_k_27;
  5011. __pyx_v_encoding = ((PyObject *)__pyx_kp_s_6);
  5012. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5013. case 4: __pyx_v_encoding = PyTuple_GET_ITEM(__pyx_args, 3);
  5014. case 3: __pyx_v_copy = PyTuple_GET_ITEM(__pyx_args, 2);
  5015. case 2: __pyx_v_flags = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5016. case 1: __pyx_v_u = PyTuple_GET_ITEM(__pyx_args, 0);
  5017. break;
  5018. default: goto __pyx_L5_argtuple_error;
  5019. }
  5020. }
  5021. goto __pyx_L4_argument_unpacking_done;
  5022. __pyx_L5_argtuple_error:;
  5023. __Pyx_RaiseArgtupleInvalid("send_unicode", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5024. __pyx_L3_error:;
  5025. __Pyx_AddTraceback("zmq.core.socket.Socket.send_unicode");
  5026. __Pyx_RefNannyFinishContext();
  5027. return NULL;
  5028. __pyx_L4_argument_unpacking_done:;
  5029. /* "zmq/core/socket.pyx":646
  5030. * The encoding to be used
  5031. * """
  5032. * if not isinstance(u, basestring): # <<<<<<<<<<<<<<
  5033. * raise TypeError("unicode/str objects only")
  5034. * return self.send(u.encode(encoding), flags=flags, copy=copy)
  5035. */
  5036. __pyx_t_1 = __pyx_v_u;
  5037. __Pyx_INCREF(__pyx_t_1);
  5038. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__basestring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5039. __Pyx_GOTREF(__pyx_t_2);
  5040. __pyx_t_3 = PyObject_IsInstance(__pyx_t_1, __pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5041. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5042. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5043. __pyx_t_4 = (!__pyx_t_3);
  5044. if (__pyx_t_4) {
  5045. /* "zmq/core/socket.pyx":647
  5046. * """
  5047. * if not isinstance(u, basestring):
  5048. * raise TypeError("unicode/str objects only") # <<<<<<<<<<<<<<
  5049. * return self.send(u.encode(encoding), flags=flags, copy=copy)
  5050. *
  5051. */
  5052. __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_29), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5053. __Pyx_GOTREF(__pyx_t_2);
  5054. __Pyx_Raise(__pyx_t_2, 0, 0);
  5055. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5056. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5057. goto __pyx_L6;
  5058. }
  5059. __pyx_L6:;
  5060. /* "zmq/core/socket.pyx":648
  5061. * if not isinstance(u, basestring):
  5062. * raise TypeError("unicode/str objects only")
  5063. * return self.send(u.encode(encoding), flags=flags, copy=copy) # <<<<<<<<<<<<<<
  5064. *
  5065. * def recv_unicode(self, int flags=0, encoding='utf-8'):
  5066. */
  5067. __Pyx_XDECREF(__pyx_r);
  5068. __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__send); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5069. __Pyx_GOTREF(__pyx_t_2);
  5070. __pyx_t_1 = PyObject_GetAttr(__pyx_v_u, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5071. __Pyx_GOTREF(__pyx_t_1);
  5072. __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5073. __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  5074. __Pyx_INCREF(__pyx_v_encoding);
  5075. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_encoding);
  5076. __Pyx_GIVEREF(__pyx_v_encoding);
  5077. __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5078. __Pyx_GOTREF(__pyx_t_6);
  5079. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5080. __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  5081. __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5082. __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  5083. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
  5084. __Pyx_GIVEREF(__pyx_t_6);
  5085. __pyx_t_6 = 0;
  5086. __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5087. __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  5088. __pyx_t_1 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5089. __Pyx_GOTREF(__pyx_t_1);
  5090. if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__flags), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5091. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5092. if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__copy), __pyx_v_copy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5093. __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5094. __Pyx_GOTREF(__pyx_t_1);
  5095. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5096. __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  5097. __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  5098. __pyx_r = __pyx_t_1;
  5099. __pyx_t_1 = 0;
  5100. goto __pyx_L0;
  5101. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5102. goto __pyx_L0;
  5103. __pyx_L1_error:;
  5104. __Pyx_XDECREF(__pyx_t_1);
  5105. __Pyx_XDECREF(__pyx_t_2);
  5106. __Pyx_XDECREF(__pyx_t_5);
  5107. __Pyx_XDECREF(__pyx_t_6);
  5108. __Pyx_AddTraceback("zmq.core.socket.Socket.send_unicode");
  5109. __pyx_r = NULL;
  5110. __pyx_L0:;
  5111. __Pyx_XGIVEREF(__pyx_r);
  5112. __Pyx_RefNannyFinishContext();
  5113. return __pyx_r;
  5114. }
  5115. /* "zmq/core/socket.pyx":650
  5116. * return self.send(u.encode(encoding), flags=flags, copy=copy)
  5117. *
  5118. * def recv_unicode(self, int flags=0, encoding='utf-8'): # <<<<<<<<<<<<<<
  5119. * """s.recv_unicode(flags=0, encoding='utf-8')
  5120. *
  5121. */
  5122. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_16recv_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5123. static char __pyx_doc_3zmq_4core_6socket_6Socket_16recv_unicode[] = "s.recv_unicode(flags=0, encoding='utf-8')\n\n Receive a unicode string, as sent by send_unicode.\n \n Parameters\n ----------\n flags : int\n Any valid recv flag.\n encoding : str [default: 'utf-8']\n The encoding to be used\n\n Returns\n -------\n s : unicode string\n The Python unicode string that arrives as message bytes.\n ";
  5124. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_16recv_unicode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5125. int __pyx_v_flags;
  5126. PyObject *__pyx_v_encoding = 0;
  5127. PyObject *__pyx_v_msg;
  5128. PyObject *__pyx_r = NULL;
  5129. PyObject *__pyx_t_1 = NULL;
  5130. PyObject *__pyx_t_2 = NULL;
  5131. PyObject *__pyx_t_3 = NULL;
  5132. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__flags,&__pyx_n_s__encoding,0};
  5133. __Pyx_RefNannySetupContext("recv_unicode");
  5134. if (unlikely(__pyx_kwds)) {
  5135. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  5136. PyObject* values[2] = {0,0};
  5137. values[1] = ((PyObject *)__pyx_kp_s_6);
  5138. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5139. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  5140. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5141. case 0: break;
  5142. default: goto __pyx_L5_argtuple_error;
  5143. }
  5144. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5145. case 0:
  5146. if (kw_args > 0) {
  5147. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
  5148. if (value) { values[0] = value; kw_args--; }
  5149. }
  5150. case 1:
  5151. if (kw_args > 0) {
  5152. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding);
  5153. if (value) { values[1] = value; kw_args--; }
  5154. }
  5155. }
  5156. if (unlikely(kw_args > 0)) {
  5157. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "recv_unicode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5158. }
  5159. if (values[0]) {
  5160. __pyx_v_flags = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5161. } else {
  5162. __pyx_v_flags = ((int)0);
  5163. }
  5164. __pyx_v_encoding = values[1];
  5165. } else {
  5166. __pyx_v_flags = ((int)0);
  5167. __pyx_v_encoding = ((PyObject *)__pyx_kp_s_6);
  5168. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5169. case 2: __pyx_v_encoding = PyTuple_GET_ITEM(__pyx_args, 1);
  5170. case 1: __pyx_v_flags = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5171. case 0: break;
  5172. default: goto __pyx_L5_argtuple_error;
  5173. }
  5174. }
  5175. goto __pyx_L4_argument_unpacking_done;
  5176. __pyx_L5_argtuple_error:;
  5177. __Pyx_RaiseArgtupleInvalid("recv_unicode", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5178. __pyx_L3_error:;
  5179. __Pyx_AddTraceback("zmq.core.socket.Socket.recv_unicode");
  5180. __Pyx_RefNannyFinishContext();
  5181. return NULL;
  5182. __pyx_L4_argument_unpacking_done:;
  5183. __pyx_v_msg = Py_None; __Pyx_INCREF(Py_None);
  5184. /* "zmq/core/socket.pyx":667
  5185. * The Python unicode string that arrives as message bytes.
  5186. * """
  5187. * msg = self.recv(flags=flags, copy=False) # <<<<<<<<<<<<<<
  5188. * return codecs.decode(msg.bytes, encoding)
  5189. *
  5190. */
  5191. __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__recv); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5192. __Pyx_GOTREF(__pyx_t_1);
  5193. __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5194. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  5195. __pyx_t_3 = PyInt_FromLong(__pyx_v_flags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5196. __Pyx_GOTREF(__pyx_t_3);
  5197. if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__flags), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5198. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5199. __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5200. __Pyx_GOTREF(__pyx_t_3);
  5201. if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__copy), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5202. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5203. __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5204. __Pyx_GOTREF(__pyx_t_3);
  5205. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5206. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  5207. __Pyx_DECREF(__pyx_v_msg);
  5208. __pyx_v_msg = __pyx_t_3;
  5209. __pyx_t_3 = 0;
  5210. /* "zmq/core/socket.pyx":668
  5211. * """
  5212. * msg = self.recv(flags=flags, copy=False)
  5213. * return codecs.decode(msg.bytes, encoding) # <<<<<<<<<<<<<<
  5214. *
  5215. * def send_pyobj(self, obj, flags=0, protocol=-1):
  5216. */
  5217. __Pyx_XDECREF(__pyx_r);
  5218. __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__codecs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5219. __Pyx_GOTREF(__pyx_t_3);
  5220. __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__decode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5221. __Pyx_GOTREF(__pyx_t_2);
  5222. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5223. __pyx_t_3 = PyObject_GetAttr(__pyx_v_msg, __pyx_n_s__bytes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5224. __Pyx_GOTREF(__pyx_t_3);
  5225. __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5226. __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  5227. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  5228. __Pyx_GIVEREF(__pyx_t_3);
  5229. __Pyx_INCREF(__pyx_v_encoding);
  5230. PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_encoding);
  5231. __Pyx_GIVEREF(__pyx_v_encoding);
  5232. __pyx_t_3 = 0;
  5233. __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5234. __Pyx_GOTREF(__pyx_t_3);
  5235. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5236. __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  5237. __pyx_r = __pyx_t_3;
  5238. __pyx_t_3 = 0;
  5239. goto __pyx_L0;
  5240. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5241. goto __pyx_L0;
  5242. __pyx_L1_error:;
  5243. __Pyx_XDECREF(__pyx_t_1);
  5244. __Pyx_XDECREF(__pyx_t_2);
  5245. __Pyx_XDECREF(__pyx_t_3);
  5246. __Pyx_AddTraceback("zmq.core.socket.Socket.recv_unicode");
  5247. __pyx_r = NULL;
  5248. __pyx_L0:;
  5249. __Pyx_DECREF(__pyx_v_msg);
  5250. __Pyx_XGIVEREF(__pyx_r);
  5251. __Pyx_RefNannyFinishContext();
  5252. return __pyx_r;
  5253. }
  5254. /* "zmq/core/socket.pyx":670
  5255. * return codecs.decode(msg.bytes, encoding)
  5256. *
  5257. * def send_pyobj(self, obj, flags=0, protocol=-1): # <<<<<<<<<<<<<<
  5258. * """s.send_pyobj(obj, flags=0, protocol=-1)
  5259. *
  5260. */
  5261. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_17send_pyobj(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5262. static char __pyx_doc_3zmq_4core_6socket_6Socket_17send_pyobj[] = "s.send_pyobj(obj, flags=0, protocol=-1)\n\n Send a Python object as a message using pickle to serialize.\n\n Parameters\n ----------\n obj : Python object\n The Python object to send.\n flags : int\n Any valid send flag.\n protocol : int\n The pickle protocol number to use. Default of -1 will select\n the highest supported number. Use 0 for multiple platform\n support.\n ";
  5263. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_17send_pyobj(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5264. PyObject *__pyx_v_obj = 0;
  5265. PyObject *__pyx_v_flags = 0;
  5266. PyObject *__pyx_v_protocol = 0;
  5267. PyObject *__pyx_v_msg;
  5268. PyObject *__pyx_r = NULL;
  5269. PyObject *__pyx_t_1 = NULL;
  5270. PyObject *__pyx_t_2 = NULL;
  5271. PyObject *__pyx_t_3 = NULL;
  5272. int __pyx_t_4;
  5273. struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send __pyx_t_5;
  5274. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__obj,&__pyx_n_s__flags,&__pyx_n_s__protocol,0};
  5275. __Pyx_RefNannySetupContext("send_pyobj");
  5276. if (unlikely(__pyx_kwds)) {
  5277. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  5278. PyObject* values[3] = {0,0,0};
  5279. values[1] = ((PyObject *)__pyx_int_0);
  5280. values[2] = ((PyObject *)__pyx_int_neg_1);
  5281. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5282. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  5283. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  5284. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5285. case 0: break;
  5286. default: goto __pyx_L5_argtuple_error;
  5287. }
  5288. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5289. case 0:
  5290. values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obj);
  5291. if (likely(values[0])) kw_args--;
  5292. else goto __pyx_L5_argtuple_error;
  5293. case 1:
  5294. if (kw_args > 0) {
  5295. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
  5296. if (value) { values[1] = value; kw_args--; }
  5297. }
  5298. case 2:
  5299. if (kw_args > 0) {
  5300. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__protocol);
  5301. if (value) { values[2] = value; kw_args--; }
  5302. }
  5303. }
  5304. if (unlikely(kw_args > 0)) {
  5305. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send_pyobj") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5306. }
  5307. __pyx_v_obj = values[0];
  5308. __pyx_v_flags = values[1];
  5309. __pyx_v_protocol = values[2];
  5310. } else {
  5311. __pyx_v_flags = ((PyObject *)__pyx_int_0);
  5312. __pyx_v_protocol = ((PyObject *)__pyx_int_neg_1);
  5313. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5314. case 3: __pyx_v_protocol = PyTuple_GET_ITEM(__pyx_args, 2);
  5315. case 2: __pyx_v_flags = PyTuple_GET_ITEM(__pyx_args, 1);
  5316. case 1: __pyx_v_obj = PyTuple_GET_ITEM(__pyx_args, 0);
  5317. break;
  5318. default: goto __pyx_L5_argtuple_error;
  5319. }
  5320. }
  5321. goto __pyx_L4_argument_unpacking_done;
  5322. __pyx_L5_argtuple_error:;
  5323. __Pyx_RaiseArgtupleInvalid("send_pyobj", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5324. __pyx_L3_error:;
  5325. __Pyx_AddTraceback("zmq.core.socket.Socket.send_pyobj");
  5326. __Pyx_RefNannyFinishContext();
  5327. return NULL;
  5328. __pyx_L4_argument_unpacking_done:;
  5329. __pyx_v_msg = Py_None; __Pyx_INCREF(Py_None);
  5330. /* "zmq/core/socket.pyx":686
  5331. * support.
  5332. * """
  5333. * msg = pickle.dumps(obj, protocol) # <<<<<<<<<<<<<<
  5334. * return self.send(msg, flags)
  5335. *
  5336. */
  5337. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__pickle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5338. __Pyx_GOTREF(__pyx_t_1);
  5339. __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__dumps); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5340. __Pyx_GOTREF(__pyx_t_2);
  5341. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5342. __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5343. __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  5344. __Pyx_INCREF(__pyx_v_obj);
  5345. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_obj);
  5346. __Pyx_GIVEREF(__pyx_v_obj);
  5347. __Pyx_INCREF(__pyx_v_protocol);
  5348. PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_protocol);
  5349. __Pyx_GIVEREF(__pyx_v_protocol);
  5350. __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5351. __Pyx_GOTREF(__pyx_t_3);
  5352. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5353. __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  5354. __Pyx_DECREF(__pyx_v_msg);
  5355. __pyx_v_msg = __pyx_t_3;
  5356. __pyx_t_3 = 0;
  5357. /* "zmq/core/socket.pyx":687
  5358. * """
  5359. * msg = pickle.dumps(obj, protocol)
  5360. * return self.send(msg, flags) # <<<<<<<<<<<<<<
  5361. *
  5362. * def recv_pyobj(self, flags=0):
  5363. */
  5364. __Pyx_XDECREF(__pyx_r);
  5365. __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_flags); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5366. __pyx_t_5.__pyx_n = 1;
  5367. __pyx_t_5.flags = __pyx_t_4;
  5368. __pyx_t_3 = ((struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->__pyx_vtab)->send(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), __pyx_v_msg, 0, &__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5369. __Pyx_GOTREF(__pyx_t_3);
  5370. __pyx_r = __pyx_t_3;
  5371. __pyx_t_3 = 0;
  5372. goto __pyx_L0;
  5373. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5374. goto __pyx_L0;
  5375. __pyx_L1_error:;
  5376. __Pyx_XDECREF(__pyx_t_1);
  5377. __Pyx_XDECREF(__pyx_t_2);
  5378. __Pyx_XDECREF(__pyx_t_3);
  5379. __Pyx_AddTraceback("zmq.core.socket.Socket.send_pyobj");
  5380. __pyx_r = NULL;
  5381. __pyx_L0:;
  5382. __Pyx_DECREF(__pyx_v_msg);
  5383. __Pyx_XGIVEREF(__pyx_r);
  5384. __Pyx_RefNannyFinishContext();
  5385. return __pyx_r;
  5386. }
  5387. /* "zmq/core/socket.pyx":689
  5388. * return self.send(msg, flags)
  5389. *
  5390. * def recv_pyobj(self, flags=0): # <<<<<<<<<<<<<<
  5391. * """s.recv_pyobj(flags=0)
  5392. *
  5393. */
  5394. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_18recv_pyobj(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5395. static char __pyx_doc_3zmq_4core_6socket_6Socket_18recv_pyobj[] = "s.recv_pyobj(flags=0)\n\n Receive a Python object as a message using pickle to serialize.\n\n Parameters\n ----------\n flags : int\n Any valid recv flag.\n\n Returns\n -------\n obj : Python object\n The Python object that arrives as a message.\n ";
  5396. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_18recv_pyobj(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5397. PyObject *__pyx_v_flags = 0;
  5398. PyObject *__pyx_v_s;
  5399. PyObject *__pyx_r = NULL;
  5400. int __pyx_t_1;
  5401. PyObject *__pyx_t_2 = NULL;
  5402. struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv __pyx_t_3;
  5403. PyObject *__pyx_t_4 = NULL;
  5404. PyObject *__pyx_t_5 = NULL;
  5405. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__flags,0};
  5406. __Pyx_RefNannySetupContext("recv_pyobj");
  5407. if (unlikely(__pyx_kwds)) {
  5408. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  5409. PyObject* values[1] = {0};
  5410. values[0] = ((PyObject *)__pyx_int_0);
  5411. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5412. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5413. case 0: break;
  5414. default: goto __pyx_L5_argtuple_error;
  5415. }
  5416. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5417. case 0:
  5418. if (kw_args > 0) {
  5419. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
  5420. if (value) { values[0] = value; kw_args--; }
  5421. }
  5422. }
  5423. if (unlikely(kw_args > 0)) {
  5424. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "recv_pyobj") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5425. }
  5426. __pyx_v_flags = values[0];
  5427. } else {
  5428. __pyx_v_flags = ((PyObject *)__pyx_int_0);
  5429. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5430. case 1: __pyx_v_flags = PyTuple_GET_ITEM(__pyx_args, 0);
  5431. case 0: break;
  5432. default: goto __pyx_L5_argtuple_error;
  5433. }
  5434. }
  5435. goto __pyx_L4_argument_unpacking_done;
  5436. __pyx_L5_argtuple_error:;
  5437. __Pyx_RaiseArgtupleInvalid("recv_pyobj", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5438. __pyx_L3_error:;
  5439. __Pyx_AddTraceback("zmq.core.socket.Socket.recv_pyobj");
  5440. __Pyx_RefNannyFinishContext();
  5441. return NULL;
  5442. __pyx_L4_argument_unpacking_done:;
  5443. __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);
  5444. /* "zmq/core/socket.pyx":704
  5445. * The Python object that arrives as a message.
  5446. * """
  5447. * s = self.recv(flags) # <<<<<<<<<<<<<<
  5448. * return pickle.loads(s)
  5449. *
  5450. */
  5451. __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_flags); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5452. __pyx_t_3.__pyx_n = 1;
  5453. __pyx_t_3.flags = __pyx_t_1;
  5454. __pyx_t_2 = ((struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->__pyx_vtab)->recv(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), 0, &__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5455. __Pyx_GOTREF(__pyx_t_2);
  5456. __Pyx_DECREF(__pyx_v_s);
  5457. __pyx_v_s = __pyx_t_2;
  5458. __pyx_t_2 = 0;
  5459. /* "zmq/core/socket.pyx":705
  5460. * """
  5461. * s = self.recv(flags)
  5462. * return pickle.loads(s) # <<<<<<<<<<<<<<
  5463. *
  5464. * def send_json(self, obj, flags=0):
  5465. */
  5466. __Pyx_XDECREF(__pyx_r);
  5467. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__pickle); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5468. __Pyx_GOTREF(__pyx_t_2);
  5469. __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__loads); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5470. __Pyx_GOTREF(__pyx_t_4);
  5471. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5472. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5473. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  5474. __Pyx_INCREF(__pyx_v_s);
  5475. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_s);
  5476. __Pyx_GIVEREF(__pyx_v_s);
  5477. __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5478. __Pyx_GOTREF(__pyx_t_5);
  5479. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5480. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  5481. __pyx_r = __pyx_t_5;
  5482. __pyx_t_5 = 0;
  5483. goto __pyx_L0;
  5484. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5485. goto __pyx_L0;
  5486. __pyx_L1_error:;
  5487. __Pyx_XDECREF(__pyx_t_2);
  5488. __Pyx_XDECREF(__pyx_t_4);
  5489. __Pyx_XDECREF(__pyx_t_5);
  5490. __Pyx_AddTraceback("zmq.core.socket.Socket.recv_pyobj");
  5491. __pyx_r = NULL;
  5492. __pyx_L0:;
  5493. __Pyx_DECREF(__pyx_v_s);
  5494. __Pyx_XGIVEREF(__pyx_r);
  5495. __Pyx_RefNannyFinishContext();
  5496. return __pyx_r;
  5497. }
  5498. /* "zmq/core/socket.pyx":707
  5499. * return pickle.loads(s)
  5500. *
  5501. * def send_json(self, obj, flags=0): # <<<<<<<<<<<<<<
  5502. * """s.send_json(obj, flags=0)
  5503. *
  5504. */
  5505. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_19send_json(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5506. static char __pyx_doc_3zmq_4core_6socket_6Socket_19send_json[] = "s.send_json(obj, flags=0)\n\n Send a Python object as a message using json to serialize.\n\n Parameters\n ----------\n obj : Python object\n The Python object to send.\n flags : int\n Any valid send flag.\n ";
  5507. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_19send_json(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5508. PyObject *__pyx_v_obj = 0;
  5509. PyObject *__pyx_v_flags = 0;
  5510. PyObject *__pyx_v_msg;
  5511. PyObject *__pyx_r = NULL;
  5512. PyObject *__pyx_t_1 = NULL;
  5513. PyObject *__pyx_t_2 = NULL;
  5514. int __pyx_t_3;
  5515. PyObject *__pyx_t_4 = NULL;
  5516. int __pyx_t_5;
  5517. struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send __pyx_t_6;
  5518. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__obj,&__pyx_n_s__flags,0};
  5519. __Pyx_RefNannySetupContext("send_json");
  5520. if (unlikely(__pyx_kwds)) {
  5521. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  5522. PyObject* values[2] = {0,0};
  5523. values[1] = ((PyObject *)__pyx_int_0);
  5524. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5525. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  5526. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5527. case 0: break;
  5528. default: goto __pyx_L5_argtuple_error;
  5529. }
  5530. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5531. case 0:
  5532. values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__obj);
  5533. if (likely(values[0])) kw_args--;
  5534. else goto __pyx_L5_argtuple_error;
  5535. case 1:
  5536. if (kw_args > 0) {
  5537. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
  5538. if (value) { values[1] = value; kw_args--; }
  5539. }
  5540. }
  5541. if (unlikely(kw_args > 0)) {
  5542. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "send_json") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5543. }
  5544. __pyx_v_obj = values[0];
  5545. __pyx_v_flags = values[1];
  5546. } else {
  5547. __pyx_v_flags = ((PyObject *)__pyx_int_0);
  5548. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5549. case 2: __pyx_v_flags = PyTuple_GET_ITEM(__pyx_args, 1);
  5550. case 1: __pyx_v_obj = PyTuple_GET_ITEM(__pyx_args, 0);
  5551. break;
  5552. default: goto __pyx_L5_argtuple_error;
  5553. }
  5554. }
  5555. goto __pyx_L4_argument_unpacking_done;
  5556. __pyx_L5_argtuple_error:;
  5557. __Pyx_RaiseArgtupleInvalid("send_json", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5558. __pyx_L3_error:;
  5559. __Pyx_AddTraceback("zmq.core.socket.Socket.send_json");
  5560. __Pyx_RefNannyFinishContext();
  5561. return NULL;
  5562. __pyx_L4_argument_unpacking_done:;
  5563. __pyx_v_msg = Py_None; __Pyx_INCREF(Py_None);
  5564. /* "zmq/core/socket.pyx":719
  5565. * Any valid send flag.
  5566. * """
  5567. * if jsonapi.jsonmod is None: # <<<<<<<<<<<<<<
  5568. * raise ImportError('jsonlib{1,2}, json or simplejson library is required.')
  5569. * else:
  5570. */
  5571. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__jsonapi); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5572. __Pyx_GOTREF(__pyx_t_1);
  5573. __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__jsonmod); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5574. __Pyx_GOTREF(__pyx_t_2);
  5575. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5576. __pyx_t_3 = (__pyx_t_2 == Py_None);
  5577. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5578. if (__pyx_t_3) {
  5579. /* "zmq/core/socket.pyx":720
  5580. * """
  5581. * if jsonapi.jsonmod is None:
  5582. * raise ImportError('jsonlib{1,2}, json or simplejson library is required.') # <<<<<<<<<<<<<<
  5583. * else:
  5584. * msg = jsonapi.dumps(obj)
  5585. */
  5586. __pyx_t_2 = PyObject_Call(__pyx_builtin_ImportError, ((PyObject *)__pyx_k_tuple_31), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5587. __Pyx_GOTREF(__pyx_t_2);
  5588. __Pyx_Raise(__pyx_t_2, 0, 0);
  5589. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5590. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5591. goto __pyx_L6;
  5592. }
  5593. /*else*/ {
  5594. /* "zmq/core/socket.pyx":722
  5595. * raise ImportError('jsonlib{1,2}, json or simplejson library is required.')
  5596. * else:
  5597. * msg = jsonapi.dumps(obj) # <<<<<<<<<<<<<<
  5598. * return self.send(msg, flags)
  5599. *
  5600. */
  5601. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__jsonapi); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5602. __Pyx_GOTREF(__pyx_t_2);
  5603. __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__dumps); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5604. __Pyx_GOTREF(__pyx_t_1);
  5605. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5606. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5607. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  5608. __Pyx_INCREF(__pyx_v_obj);
  5609. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_obj);
  5610. __Pyx_GIVEREF(__pyx_v_obj);
  5611. __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5612. __Pyx_GOTREF(__pyx_t_4);
  5613. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5614. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  5615. __Pyx_DECREF(__pyx_v_msg);
  5616. __pyx_v_msg = __pyx_t_4;
  5617. __pyx_t_4 = 0;
  5618. /* "zmq/core/socket.pyx":723
  5619. * else:
  5620. * msg = jsonapi.dumps(obj)
  5621. * return self.send(msg, flags) # <<<<<<<<<<<<<<
  5622. *
  5623. * def recv_json(self, flags=0):
  5624. */
  5625. __Pyx_XDECREF(__pyx_r);
  5626. __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_v_flags); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5627. __pyx_t_6.__pyx_n = 1;
  5628. __pyx_t_6.flags = __pyx_t_5;
  5629. __pyx_t_4 = ((struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->__pyx_vtab)->send(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), __pyx_v_msg, 0, &__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5630. __Pyx_GOTREF(__pyx_t_4);
  5631. __pyx_r = __pyx_t_4;
  5632. __pyx_t_4 = 0;
  5633. goto __pyx_L0;
  5634. }
  5635. __pyx_L6:;
  5636. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5637. goto __pyx_L0;
  5638. __pyx_L1_error:;
  5639. __Pyx_XDECREF(__pyx_t_1);
  5640. __Pyx_XDECREF(__pyx_t_2);
  5641. __Pyx_XDECREF(__pyx_t_4);
  5642. __Pyx_AddTraceback("zmq.core.socket.Socket.send_json");
  5643. __pyx_r = NULL;
  5644. __pyx_L0:;
  5645. __Pyx_DECREF(__pyx_v_msg);
  5646. __Pyx_XGIVEREF(__pyx_r);
  5647. __Pyx_RefNannyFinishContext();
  5648. return __pyx_r;
  5649. }
  5650. /* "zmq/core/socket.pyx":725
  5651. * return self.send(msg, flags)
  5652. *
  5653. * def recv_json(self, flags=0): # <<<<<<<<<<<<<<
  5654. * """s.recv_json(flags=0)
  5655. *
  5656. */
  5657. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_20recv_json(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5658. static char __pyx_doc_3zmq_4core_6socket_6Socket_20recv_json[] = "s.recv_json(flags=0)\n\n Receive a Python object as a message using json to serialize.\n\n Parameters\n ----------\n flags : int\n Any valid recv flag.\n\n Returns\n -------\n obj : Python object\n The Python object that arrives as a message.\n ";
  5659. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_20recv_json(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5660. PyObject *__pyx_v_flags = 0;
  5661. PyObject *__pyx_v_msg;
  5662. PyObject *__pyx_r = NULL;
  5663. PyObject *__pyx_t_1 = NULL;
  5664. PyObject *__pyx_t_2 = NULL;
  5665. int __pyx_t_3;
  5666. int __pyx_t_4;
  5667. struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv __pyx_t_5;
  5668. PyObject *__pyx_t_6 = NULL;
  5669. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__flags,0};
  5670. __Pyx_RefNannySetupContext("recv_json");
  5671. if (unlikely(__pyx_kwds)) {
  5672. Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
  5673. PyObject* values[1] = {0};
  5674. values[0] = ((PyObject *)__pyx_int_0);
  5675. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5676. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5677. case 0: break;
  5678. default: goto __pyx_L5_argtuple_error;
  5679. }
  5680. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5681. case 0:
  5682. if (kw_args > 0) {
  5683. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__flags);
  5684. if (value) { values[0] = value; kw_args--; }
  5685. }
  5686. }
  5687. if (unlikely(kw_args > 0)) {
  5688. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "recv_json") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5689. }
  5690. __pyx_v_flags = values[0];
  5691. } else {
  5692. __pyx_v_flags = ((PyObject *)__pyx_int_0);
  5693. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5694. case 1: __pyx_v_flags = PyTuple_GET_ITEM(__pyx_args, 0);
  5695. case 0: break;
  5696. default: goto __pyx_L5_argtuple_error;
  5697. }
  5698. }
  5699. goto __pyx_L4_argument_unpacking_done;
  5700. __pyx_L5_argtuple_error:;
  5701. __Pyx_RaiseArgtupleInvalid("recv_json", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  5702. __pyx_L3_error:;
  5703. __Pyx_AddTraceback("zmq.core.socket.Socket.recv_json");
  5704. __Pyx_RefNannyFinishContext();
  5705. return NULL;
  5706. __pyx_L4_argument_unpacking_done:;
  5707. __pyx_v_msg = Py_None; __Pyx_INCREF(Py_None);
  5708. /* "zmq/core/socket.pyx":740
  5709. * The Python object that arrives as a message.
  5710. * """
  5711. * if jsonapi.jsonmod is None: # <<<<<<<<<<<<<<
  5712. * raise ImportError('jsonlib{1,2}, json or simplejson library is required.')
  5713. * else:
  5714. */
  5715. __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__jsonapi); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5716. __Pyx_GOTREF(__pyx_t_1);
  5717. __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__jsonmod); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5718. __Pyx_GOTREF(__pyx_t_2);
  5719. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5720. __pyx_t_3 = (__pyx_t_2 == Py_None);
  5721. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5722. if (__pyx_t_3) {
  5723. /* "zmq/core/socket.pyx":741
  5724. * """
  5725. * if jsonapi.jsonmod is None:
  5726. * raise ImportError('jsonlib{1,2}, json or simplejson library is required.') # <<<<<<<<<<<<<<
  5727. * else:
  5728. * msg = self.recv(flags)
  5729. */
  5730. __pyx_t_2 = PyObject_Call(__pyx_builtin_ImportError, ((PyObject *)__pyx_k_tuple_32), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5731. __Pyx_GOTREF(__pyx_t_2);
  5732. __Pyx_Raise(__pyx_t_2, 0, 0);
  5733. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5734. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5735. goto __pyx_L6;
  5736. }
  5737. /*else*/ {
  5738. /* "zmq/core/socket.pyx":743
  5739. * raise ImportError('jsonlib{1,2}, json or simplejson library is required.')
  5740. * else:
  5741. * msg = self.recv(flags) # <<<<<<<<<<<<<<
  5742. * return jsonapi.loads(msg)
  5743. *
  5744. */
  5745. __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_flags); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5746. __pyx_t_5.__pyx_n = 1;
  5747. __pyx_t_5.flags = __pyx_t_4;
  5748. __pyx_t_2 = ((struct __pyx_vtabstruct_3zmq_4core_6socket_Socket *)((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->__pyx_vtab)->recv(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self), 0, &__pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5749. __Pyx_GOTREF(__pyx_t_2);
  5750. __Pyx_DECREF(__pyx_v_msg);
  5751. __pyx_v_msg = __pyx_t_2;
  5752. __pyx_t_2 = 0;
  5753. /* "zmq/core/socket.pyx":744
  5754. * else:
  5755. * msg = self.recv(flags)
  5756. * return jsonapi.loads(msg) # <<<<<<<<<<<<<<
  5757. *
  5758. *
  5759. */
  5760. __Pyx_XDECREF(__pyx_r);
  5761. __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__jsonapi); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5762. __Pyx_GOTREF(__pyx_t_2);
  5763. __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__loads); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5764. __Pyx_GOTREF(__pyx_t_1);
  5765. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5766. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5767. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  5768. __Pyx_INCREF(__pyx_v_msg);
  5769. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_msg);
  5770. __Pyx_GIVEREF(__pyx_v_msg);
  5771. __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5772. __Pyx_GOTREF(__pyx_t_6);
  5773. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5774. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  5775. __pyx_r = __pyx_t_6;
  5776. __pyx_t_6 = 0;
  5777. goto __pyx_L0;
  5778. }
  5779. __pyx_L6:;
  5780. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5781. goto __pyx_L0;
  5782. __pyx_L1_error:;
  5783. __Pyx_XDECREF(__pyx_t_1);
  5784. __Pyx_XDECREF(__pyx_t_2);
  5785. __Pyx_XDECREF(__pyx_t_6);
  5786. __Pyx_AddTraceback("zmq.core.socket.Socket.recv_json");
  5787. __pyx_r = NULL;
  5788. __pyx_L0:;
  5789. __Pyx_DECREF(__pyx_v_msg);
  5790. __Pyx_XGIVEREF(__pyx_r);
  5791. __Pyx_RefNannyFinishContext();
  5792. return __pyx_r;
  5793. }
  5794. /* "zmq/core/socket.pxd":37
  5795. *
  5796. * cdef void *handle # The C handle for the underlying zmq object.
  5797. * cdef public int socket_type # The 0MQ socket type - REQ,REP, etc. # <<<<<<<<<<<<<<
  5798. * # Hold on to a reference to the context to make sure it is not garbage
  5799. * # collected until the socket it done with it.
  5800. */
  5801. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_11socket_type___get__(PyObject *__pyx_v_self); /*proto*/
  5802. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_11socket_type___get__(PyObject *__pyx_v_self) {
  5803. PyObject *__pyx_r = NULL;
  5804. PyObject *__pyx_t_1 = NULL;
  5805. __Pyx_RefNannySetupContext("__get__");
  5806. __Pyx_XDECREF(__pyx_r);
  5807. __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->socket_type); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5808. __Pyx_GOTREF(__pyx_t_1);
  5809. __pyx_r = __pyx_t_1;
  5810. __pyx_t_1 = 0;
  5811. goto __pyx_L0;
  5812. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5813. goto __pyx_L0;
  5814. __pyx_L1_error:;
  5815. __Pyx_XDECREF(__pyx_t_1);
  5816. __Pyx_AddTraceback("zmq.core.socket.Socket.socket_type.__get__");
  5817. __pyx_r = NULL;
  5818. __pyx_L0:;
  5819. __Pyx_XGIVEREF(__pyx_r);
  5820. __Pyx_RefNannyFinishContext();
  5821. return __pyx_r;
  5822. }
  5823. static int __pyx_pf_3zmq_4core_6socket_6Socket_11socket_type_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
  5824. static int __pyx_pf_3zmq_4core_6socket_6Socket_11socket_type_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  5825. int __pyx_r;
  5826. int __pyx_t_1;
  5827. __Pyx_RefNannySetupContext("__set__");
  5828. __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  5829. ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->socket_type = __pyx_t_1;
  5830. __pyx_r = 0;
  5831. goto __pyx_L0;
  5832. __pyx_L1_error:;
  5833. __Pyx_AddTraceback("zmq.core.socket.Socket.socket_type.__set__");
  5834. __pyx_r = -1;
  5835. __pyx_L0:;
  5836. __Pyx_RefNannyFinishContext();
  5837. return __pyx_r;
  5838. }
  5839. /* "zmq/core/socket.pxd":40
  5840. * # Hold on to a reference to the context to make sure it is not garbage
  5841. * # collected until the socket it done with it.
  5842. * cdef public object context # The zmq Context object that owns this. # <<<<<<<<<<<<<<
  5843. * cdef public object closed # bool property for a closed socket.
  5844. *
  5845. */
  5846. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_7context___get__(PyObject *__pyx_v_self); /*proto*/
  5847. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_7context___get__(PyObject *__pyx_v_self) {
  5848. PyObject *__pyx_r = NULL;
  5849. __Pyx_RefNannySetupContext("__get__");
  5850. __Pyx_XDECREF(__pyx_r);
  5851. __Pyx_INCREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context);
  5852. __pyx_r = ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context;
  5853. goto __pyx_L0;
  5854. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5855. __pyx_L0:;
  5856. __Pyx_XGIVEREF(__pyx_r);
  5857. __Pyx_RefNannyFinishContext();
  5858. return __pyx_r;
  5859. }
  5860. static int __pyx_pf_3zmq_4core_6socket_6Socket_7context_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
  5861. static int __pyx_pf_3zmq_4core_6socket_6Socket_7context_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  5862. int __pyx_r;
  5863. __Pyx_RefNannySetupContext("__set__");
  5864. __Pyx_INCREF(__pyx_v_value);
  5865. __Pyx_GIVEREF(__pyx_v_value);
  5866. __Pyx_GOTREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context);
  5867. __Pyx_DECREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context);
  5868. ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context = __pyx_v_value;
  5869. __pyx_r = 0;
  5870. __Pyx_RefNannyFinishContext();
  5871. return __pyx_r;
  5872. }
  5873. static int __pyx_pf_3zmq_4core_6socket_6Socket_7context_2__del__(PyObject *__pyx_v_self); /*proto*/
  5874. static int __pyx_pf_3zmq_4core_6socket_6Socket_7context_2__del__(PyObject *__pyx_v_self) {
  5875. int __pyx_r;
  5876. __Pyx_RefNannySetupContext("__del__");
  5877. __Pyx_INCREF(Py_None);
  5878. __Pyx_GIVEREF(Py_None);
  5879. __Pyx_GOTREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context);
  5880. __Pyx_DECREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context);
  5881. ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->context = Py_None;
  5882. __pyx_r = 0;
  5883. __Pyx_RefNannyFinishContext();
  5884. return __pyx_r;
  5885. }
  5886. /* "zmq/core/socket.pxd":41
  5887. * # collected until the socket it done with it.
  5888. * cdef public object context # The zmq Context object that owns this.
  5889. * cdef public object closed # bool property for a closed socket. # <<<<<<<<<<<<<<
  5890. *
  5891. * # cpdef methods for direct-cython access:
  5892. */
  5893. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_6closed___get__(PyObject *__pyx_v_self); /*proto*/
  5894. static PyObject *__pyx_pf_3zmq_4core_6socket_6Socket_6closed___get__(PyObject *__pyx_v_self) {
  5895. PyObject *__pyx_r = NULL;
  5896. __Pyx_RefNannySetupContext("__get__");
  5897. __Pyx_XDECREF(__pyx_r);
  5898. __Pyx_INCREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed);
  5899. __pyx_r = ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed;
  5900. goto __pyx_L0;
  5901. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5902. __pyx_L0:;
  5903. __Pyx_XGIVEREF(__pyx_r);
  5904. __Pyx_RefNannyFinishContext();
  5905. return __pyx_r;
  5906. }
  5907. static int __pyx_pf_3zmq_4core_6socket_6Socket_6closed_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
  5908. static int __pyx_pf_3zmq_4core_6socket_6Socket_6closed_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  5909. int __pyx_r;
  5910. __Pyx_RefNannySetupContext("__set__");
  5911. __Pyx_INCREF(__pyx_v_value);
  5912. __Pyx_GIVEREF(__pyx_v_value);
  5913. __Pyx_GOTREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed);
  5914. __Pyx_DECREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed);
  5915. ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed = __pyx_v_value;
  5916. __pyx_r = 0;
  5917. __Pyx_RefNannyFinishContext();
  5918. return __pyx_r;
  5919. }
  5920. static int __pyx_pf_3zmq_4core_6socket_6Socket_6closed_2__del__(PyObject *__pyx_v_self); /*proto*/
  5921. static int __pyx_pf_3zmq_4core_6socket_6Socket_6closed_2__del__(PyObject *__pyx_v_self) {
  5922. int __pyx_r;
  5923. __Pyx_RefNannySetupContext("__del__");
  5924. __Pyx_INCREF(Py_None);
  5925. __Pyx_GIVEREF(Py_None);
  5926. __Pyx_GOTREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed);
  5927. __Pyx_DECREF(((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed);
  5928. ((struct __pyx_obj_3zmq_4core_6socket_Socket *)__pyx_v_self)->closed = Py_None;
  5929. __pyx_r = 0;
  5930. __Pyx_RefNannyFinishContext();
  5931. return __pyx_r;
  5932. }
  5933. /* "buffers.pxd":74
  5934. *
  5935. *
  5936. * cdef inline int newstyle_available(): # <<<<<<<<<<<<<<
  5937. * return PY_MAJOR_VERSION >= 3 or (PY_MAJOR_VERSION >=2 and PY_MINOR_VERSION >= 6)
  5938. *
  5939. */
  5940. static CYTHON_INLINE int __pyx_f_7buffers_newstyle_available(void) {
  5941. int __pyx_r;
  5942. int __pyx_t_1;
  5943. int __pyx_t_2;
  5944. int __pyx_t_3;
  5945. int __pyx_t_4;
  5946. __Pyx_RefNannySetupContext("newstyle_available");
  5947. /* "buffers.pxd":75
  5948. *
  5949. * cdef inline int newstyle_available():
  5950. * return PY_MAJOR_VERSION >= 3 or (PY_MAJOR_VERSION >=2 and PY_MINOR_VERSION >= 6) # <<<<<<<<<<<<<<
  5951. *
  5952. * cdef inline int memoryview_available():
  5953. */
  5954. __pyx_t_1 = (PY_MAJOR_VERSION >= 3);
  5955. if (!__pyx_t_1) {
  5956. __pyx_t_2 = (PY_MAJOR_VERSION >= 2);
  5957. if (__pyx_t_2) {
  5958. __pyx_t_3 = (PY_MINOR_VERSION >= 6);
  5959. __pyx_t_4 = __pyx_t_3;
  5960. } else {
  5961. __pyx_t_4 = __pyx_t_2;
  5962. }
  5963. __pyx_t_2 = __pyx_t_4;
  5964. } else {
  5965. __pyx_t_2 = __pyx_t_1;
  5966. }
  5967. __pyx_r = __pyx_t_2;
  5968. goto __pyx_L0;
  5969. __pyx_r = 0;
  5970. __pyx_L0:;
  5971. __Pyx_RefNannyFinishContext();
  5972. return __pyx_r;
  5973. }
  5974. /* "buffers.pxd":77
  5975. * return PY_MAJOR_VERSION >= 3 or (PY_MAJOR_VERSION >=2 and PY_MINOR_VERSION >= 6)
  5976. *
  5977. * cdef inline int memoryview_available(): # <<<<<<<<<<<<<<
  5978. * return PY_MAJOR_VERSION >= 3 or (PY_MAJOR_VERSION >=2 and PY_MINOR_VERSION >= 7)
  5979. *
  5980. */
  5981. static CYTHON_INLINE int __pyx_f_7buffers_memoryview_available(void) {
  5982. int __pyx_r;
  5983. int __pyx_t_1;
  5984. int __pyx_t_2;
  5985. int __pyx_t_3;
  5986. int __pyx_t_4;
  5987. __Pyx_RefNannySetupContext("memoryview_available");
  5988. /* "buffers.pxd":78
  5989. *
  5990. * cdef inline int memoryview_available():
  5991. * return PY_MAJOR_VERSION >= 3 or (PY_MAJOR_VERSION >=2 and PY_MINOR_VERSION >= 7) # <<<<<<<<<<<<<<
  5992. *
  5993. * cdef inline int oldstyle_available():
  5994. */
  5995. __pyx_t_1 = (PY_MAJOR_VERSION >= 3);
  5996. if (!__pyx_t_1) {
  5997. __pyx_t_2 = (PY_MAJOR_VERSION >= 2);
  5998. if (__pyx_t_2) {
  5999. __pyx_t_3 = (PY_MINOR_VERSION >= 7);
  6000. __pyx_t_4 = __pyx_t_3;
  6001. } else {
  6002. __pyx_t_4 = __pyx_t_2;
  6003. }
  6004. __pyx_t_2 = __pyx_t_4;
  6005. } else {
  6006. __pyx_t_2 = __pyx_t_1;
  6007. }
  6008. __pyx_r = __pyx_t_2;
  6009. goto __pyx_L0;
  6010. __pyx_r = 0;
  6011. __pyx_L0:;
  6012. __Pyx_RefNannyFinishContext();
  6013. return __pyx_r;
  6014. }
  6015. /* "buffers.pxd":80
  6016. * return PY_MAJOR_VERSION >= 3 or (PY_MAJOR_VERSION >=2 and PY_MINOR_VERSION >= 7)
  6017. *
  6018. * cdef inline int oldstyle_available(): # <<<<<<<<<<<<<<
  6019. * return PY_MAJOR_VERSION < 3
  6020. *
  6021. */
  6022. static CYTHON_INLINE int __pyx_f_7buffers_oldstyle_available(void) {
  6023. int __pyx_r;
  6024. __Pyx_RefNannySetupContext("oldstyle_available");
  6025. /* "buffers.pxd":81
  6026. *
  6027. * cdef inline int oldstyle_available():
  6028. * return PY_MAJOR_VERSION < 3 # <<<<<<<<<<<<<<
  6029. *
  6030. * cdef inline int check_buffer(object ob):
  6031. */
  6032. __pyx_r = (PY_MAJOR_VERSION < 3);
  6033. goto __pyx_L0;
  6034. __pyx_r = 0;
  6035. __pyx_L0:;
  6036. __Pyx_RefNannyFinishContext();
  6037. return __pyx_r;
  6038. }
  6039. /* "buffers.pxd":83
  6040. * return PY_MAJOR_VERSION < 3
  6041. *
  6042. * cdef inline int check_buffer(object ob): # <<<<<<<<<<<<<<
  6043. * """Version independent check for whether an object is a buffer.
  6044. *
  6045. */
  6046. static CYTHON_INLINE int __pyx_f_7buffers_check_buffer(PyObject *__pyx_v_ob) {
  6047. int __pyx_r;
  6048. int __pyx_t_1;
  6049. PyObject *__pyx_t_2 = NULL;
  6050. long __pyx_t_3;
  6051. __Pyx_RefNannySetupContext("check_buffer");
  6052. /* "buffers.pxd":95
  6053. * int : 0 if no buffer interface, 3 if newstyle buffer interface, 2 if oldstyle.
  6054. * """
  6055. * if newstyle_available(): # <<<<<<<<<<<<<<
  6056. * if PyObject_CheckBuffer(ob):
  6057. * return 3
  6058. */
  6059. __pyx_t_1 = __pyx_f_7buffers_newstyle_available();
  6060. if (__pyx_t_1) {
  6061. /* "buffers.pxd":96
  6062. * """
  6063. * if newstyle_available():
  6064. * if PyObject_CheckBuffer(ob): # <<<<<<<<<<<<<<
  6065. * return 3
  6066. * if oldstyle_available():
  6067. */
  6068. __pyx_t_2 = __pyx_v_ob;
  6069. __Pyx_INCREF(__pyx_t_2);
  6070. __pyx_t_1 = PyObject_CheckBuffer(__pyx_t_2);
  6071. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6072. if (__pyx_t_1) {
  6073. /* "buffers.pxd":97
  6074. * if newstyle_available():
  6075. * if PyObject_CheckBuffer(ob):
  6076. * return 3 # <<<<<<<<<<<<<<
  6077. * if oldstyle_available():
  6078. * return PyObject_CheckReadBuffer(ob) and 2
  6079. */
  6080. __pyx_r = 3;
  6081. goto __pyx_L0;
  6082. goto __pyx_L4;
  6083. }
  6084. __pyx_L4:;
  6085. goto __pyx_L3;
  6086. }
  6087. __pyx_L3:;
  6088. /* "buffers.pxd":98
  6089. * if PyObject_CheckBuffer(ob):
  6090. * return 3
  6091. * if oldstyle_available(): # <<<<<<<<<<<<<<
  6092. * return PyObject_CheckReadBuffer(ob) and 2
  6093. * return 0
  6094. */
  6095. __pyx_t_1 = __pyx_f_7buffers_oldstyle_available();
  6096. if (__pyx_t_1) {
  6097. /* "buffers.pxd":99
  6098. * return 3
  6099. * if oldstyle_available():
  6100. * return PyObject_CheckReadBuffer(ob) and 2 # <<<<<<<<<<<<<<
  6101. * return 0
  6102. *
  6103. */
  6104. __pyx_t_2 = __pyx_v_ob;
  6105. __Pyx_INCREF(__pyx_t_2);
  6106. __pyx_t_1 = PyObject_CheckReadBuffer(__pyx_t_2);
  6107. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6108. if (__pyx_t_1) {
  6109. __pyx_t_3 = 2;
  6110. } else {
  6111. __pyx_t_3 = __pyx_t_1;
  6112. }
  6113. __pyx_r = __pyx_t_3;
  6114. goto __pyx_L0;
  6115. goto __pyx_L5;
  6116. }
  6117. __pyx_L5:;
  6118. /* "buffers.pxd":100
  6119. * if oldstyle_available():
  6120. * return PyObject_CheckReadBuffer(ob) and 2
  6121. * return 0 # <<<<<<<<<<<<<<
  6122. *
  6123. *
  6124. */
  6125. __pyx_r = 0;
  6126. goto __pyx_L0;
  6127. __pyx_r = 0;
  6128. __pyx_L0:;
  6129. __Pyx_RefNannyFinishContext();
  6130. return __pyx_r;
  6131. }
  6132. /* "buffers.pxd":103
  6133. *
  6134. *
  6135. * cdef inline object asbuffer(object ob, int writable, int format, # <<<<<<<<<<<<<<
  6136. * void **base, Py_ssize_t *size,
  6137. * Py_ssize_t *itemsize):
  6138. */
  6139. static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer(PyObject *__pyx_v_ob, int __pyx_v_writable, int __pyx_v_format, void **__pyx_v_base, Py_ssize_t *__pyx_v_size, Py_ssize_t *__pyx_v_itemsize) {
  6140. void *__pyx_v_bptr;
  6141. Py_ssize_t __pyx_v_blen;
  6142. Py_ssize_t __pyx_v_bitemlen;
  6143. PyObject *__pyx_v_bfmt = 0;
  6144. Py_buffer __pyx_v_view;
  6145. int __pyx_v_flags;
  6146. int __pyx_v_mode;
  6147. PyObject *__pyx_v_dtype;
  6148. PyObject *__pyx_r = NULL;
  6149. PyObject *__pyx_t_1 = NULL;
  6150. int __pyx_t_2;
  6151. PyObject *__pyx_t_3 = NULL;
  6152. int __pyx_t_4;
  6153. Py_ssize_t __pyx_t_5;
  6154. PyObject *__pyx_t_6 = NULL;
  6155. PyObject *__pyx_t_7 = NULL;
  6156. PyObject *__pyx_t_8 = NULL;
  6157. PyObject *__pyx_t_9 = NULL;
  6158. PyObject *__pyx_t_10 = NULL;
  6159. PyObject *__pyx_t_11 = NULL;
  6160. __Pyx_RefNannySetupContext("asbuffer");
  6161. __pyx_v_dtype = Py_None; __Pyx_INCREF(Py_None);
  6162. /* "buffers.pxd":130
  6163. * """
  6164. *
  6165. * cdef void *bptr = NULL # <<<<<<<<<<<<<<
  6166. * cdef Py_ssize_t blen = 0, bitemlen = 0
  6167. * cdef str bfmt = None
  6168. */
  6169. __pyx_v_bptr = NULL;
  6170. /* "buffers.pxd":131
  6171. *
  6172. * cdef void *bptr = NULL
  6173. * cdef Py_ssize_t blen = 0, bitemlen = 0 # <<<<<<<<<<<<<<
  6174. * cdef str bfmt = None
  6175. * cdef Py_buffer view
  6176. */
  6177. __pyx_v_blen = 0;
  6178. __pyx_v_bitemlen = 0;
  6179. /* "buffers.pxd":132
  6180. * cdef void *bptr = NULL
  6181. * cdef Py_ssize_t blen = 0, bitemlen = 0
  6182. * cdef str bfmt = None # <<<<<<<<<<<<<<
  6183. * cdef Py_buffer view
  6184. * cdef int flags = PyBUF_SIMPLE
  6185. */
  6186. __Pyx_INCREF(Py_None);
  6187. __pyx_v_bfmt = ((PyObject*)Py_None);
  6188. /* "buffers.pxd":134
  6189. * cdef str bfmt = None
  6190. * cdef Py_buffer view
  6191. * cdef int flags = PyBUF_SIMPLE # <<<<<<<<<<<<<<
  6192. * cdef int mode = 0
  6193. *
  6194. */
  6195. __pyx_v_flags = PyBUF_SIMPLE;
  6196. /* "buffers.pxd":135
  6197. * cdef Py_buffer view
  6198. * cdef int flags = PyBUF_SIMPLE
  6199. * cdef int mode = 0 # <<<<<<<<<<<<<<
  6200. *
  6201. * mode = check_buffer(ob)
  6202. */
  6203. __pyx_v_mode = 0;
  6204. /* "buffers.pxd":137
  6205. * cdef int mode = 0
  6206. *
  6207. * mode = check_buffer(ob) # <<<<<<<<<<<<<<
  6208. * if mode == 0:
  6209. * raise TypeError("%r does not provide a buffer interface."%ob)
  6210. */
  6211. __pyx_t_1 = __pyx_v_ob;
  6212. __Pyx_INCREF(__pyx_t_1);
  6213. __pyx_v_mode = __pyx_f_7buffers_check_buffer(__pyx_t_1);
  6214. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6215. /* "buffers.pxd":138
  6216. *
  6217. * mode = check_buffer(ob)
  6218. * if mode == 0: # <<<<<<<<<<<<<<
  6219. * raise TypeError("%r does not provide a buffer interface."%ob)
  6220. *
  6221. */
  6222. __pyx_t_2 = (__pyx_v_mode == 0);
  6223. if (__pyx_t_2) {
  6224. /* "buffers.pxd":139
  6225. * mode = check_buffer(ob)
  6226. * if mode == 0:
  6227. * raise TypeError("%r does not provide a buffer interface."%ob) # <<<<<<<<<<<<<<
  6228. *
  6229. * if mode == 3:
  6230. */
  6231. __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_33), __pyx_v_ob); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6232. __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  6233. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6234. __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  6235. PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
  6236. __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  6237. __pyx_t_1 = 0;
  6238. __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6239. __Pyx_GOTREF(__pyx_t_1);
  6240. __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  6241. __Pyx_Raise(__pyx_t_1, 0, 0);
  6242. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6243. {__pyx_filename = __pyx_f[2]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6244. goto __pyx_L3;
  6245. }
  6246. __pyx_L3:;
  6247. /* "buffers.pxd":141
  6248. * raise TypeError("%r does not provide a buffer interface."%ob)
  6249. *
  6250. * if mode == 3: # <<<<<<<<<<<<<<
  6251. * flags = PyBUF_ANY_CONTIGUOUS
  6252. * if writable:
  6253. */
  6254. __pyx_t_2 = (__pyx_v_mode == 3);
  6255. if (__pyx_t_2) {
  6256. /* "buffers.pxd":142
  6257. *
  6258. * if mode == 3:
  6259. * flags = PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<<
  6260. * if writable:
  6261. * flags |= PyBUF_WRITABLE
  6262. */
  6263. __pyx_v_flags = PyBUF_ANY_CONTIGUOUS;
  6264. /* "buffers.pxd":143
  6265. * if mode == 3:
  6266. * flags = PyBUF_ANY_CONTIGUOUS
  6267. * if writable: # <<<<<<<<<<<<<<
  6268. * flags |= PyBUF_WRITABLE
  6269. * if format:
  6270. */
  6271. if (__pyx_v_writable) {
  6272. /* "buffers.pxd":144
  6273. * flags = PyBUF_ANY_CONTIGUOUS
  6274. * if writable:
  6275. * flags |= PyBUF_WRITABLE # <<<<<<<<<<<<<<
  6276. * if format:
  6277. * flags |= PyBUF_FORMAT
  6278. */
  6279. __pyx_v_flags = (__pyx_v_flags | PyBUF_WRITABLE);
  6280. goto __pyx_L5;
  6281. }
  6282. __pyx_L5:;
  6283. /* "buffers.pxd":145
  6284. * if writable:
  6285. * flags |= PyBUF_WRITABLE
  6286. * if format: # <<<<<<<<<<<<<<
  6287. * flags |= PyBUF_FORMAT
  6288. * PyObject_GetBuffer(ob, &view, flags)
  6289. */
  6290. if (__pyx_v_format) {
  6291. /* "buffers.pxd":146
  6292. * flags |= PyBUF_WRITABLE
  6293. * if format:
  6294. * flags |= PyBUF_FORMAT # <<<<<<<<<<<<<<
  6295. * PyObject_GetBuffer(ob, &view, flags)
  6296. * bptr = view.buf
  6297. */
  6298. __pyx_v_flags = (__pyx_v_flags | PyBUF_FORMAT);
  6299. goto __pyx_L6;
  6300. }
  6301. __pyx_L6:;
  6302. /* "buffers.pxd":147
  6303. * if format:
  6304. * flags |= PyBUF_FORMAT
  6305. * PyObject_GetBuffer(ob, &view, flags) # <<<<<<<<<<<<<<
  6306. * bptr = view.buf
  6307. * blen = view.len
  6308. */
  6309. __pyx_t_1 = __pyx_v_ob;
  6310. __Pyx_INCREF(__pyx_t_1);
  6311. __pyx_t_4 = PyObject_GetBuffer(__pyx_t_1, (&__pyx_v_view), __pyx_v_flags); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6312. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6313. /* "buffers.pxd":148
  6314. * flags |= PyBUF_FORMAT
  6315. * PyObject_GetBuffer(ob, &view, flags)
  6316. * bptr = view.buf # <<<<<<<<<<<<<<
  6317. * blen = view.len
  6318. * if format:
  6319. */
  6320. __pyx_v_bptr = __pyx_v_view.buf;
  6321. /* "buffers.pxd":149
  6322. * PyObject_GetBuffer(ob, &view, flags)
  6323. * bptr = view.buf
  6324. * blen = view.len # <<<<<<<<<<<<<<
  6325. * if format:
  6326. * if view.format != NULL:
  6327. */
  6328. __pyx_v_blen = __pyx_v_view.len;
  6329. /* "buffers.pxd":150
  6330. * bptr = view.buf
  6331. * blen = view.len
  6332. * if format: # <<<<<<<<<<<<<<
  6333. * if view.format != NULL:
  6334. * bfmt = view.format
  6335. */
  6336. if (__pyx_v_format) {
  6337. /* "buffers.pxd":151
  6338. * blen = view.len
  6339. * if format:
  6340. * if view.format != NULL: # <<<<<<<<<<<<<<
  6341. * bfmt = view.format
  6342. * bitemlen = view.itemsize
  6343. */
  6344. __pyx_t_2 = (__pyx_v_view.format != NULL);
  6345. if (__pyx_t_2) {
  6346. /* "buffers.pxd":152
  6347. * if format:
  6348. * if view.format != NULL:
  6349. * bfmt = view.format # <<<<<<<<<<<<<<
  6350. * bitemlen = view.itemsize
  6351. * PyBuffer_Release(&view)
  6352. */
  6353. __pyx_t_1 = PyBytes_FromString(__pyx_v_view.format); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6354. __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  6355. if (!(likely(PyString_CheckExact(((PyObject *)__pyx_t_1)))||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(((PyObject *)__pyx_t_1))->tp_name), 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6356. __Pyx_DECREF(((PyObject *)__pyx_v_bfmt));
  6357. __pyx_v_bfmt = ((PyObject*)__pyx_t_1);
  6358. __pyx_t_1 = 0;
  6359. /* "buffers.pxd":153
  6360. * if view.format != NULL:
  6361. * bfmt = view.format
  6362. * bitemlen = view.itemsize # <<<<<<<<<<<<<<
  6363. * PyBuffer_Release(&view)
  6364. * else: # oldstyle
  6365. */
  6366. __pyx_v_bitemlen = __pyx_v_view.itemsize;
  6367. goto __pyx_L8;
  6368. }
  6369. __pyx_L8:;
  6370. goto __pyx_L7;
  6371. }
  6372. __pyx_L7:;
  6373. /* "buffers.pxd":154
  6374. * bfmt = view.format
  6375. * bitemlen = view.itemsize
  6376. * PyBuffer_Release(&view) # <<<<<<<<<<<<<<
  6377. * else: # oldstyle
  6378. * if writable:
  6379. */
  6380. PyBuffer_Release((&__pyx_v_view));
  6381. goto __pyx_L4;
  6382. }
  6383. /*else*/ {
  6384. /* "buffers.pxd":156
  6385. * PyBuffer_Release(&view)
  6386. * else: # oldstyle
  6387. * if writable: # <<<<<<<<<<<<<<
  6388. * PyObject_AsWriteBuffer(ob, &bptr, &blen)
  6389. * else:
  6390. */
  6391. if (__pyx_v_writable) {
  6392. /* "buffers.pxd":157
  6393. * else: # oldstyle
  6394. * if writable:
  6395. * PyObject_AsWriteBuffer(ob, &bptr, &blen) # <<<<<<<<<<<<<<
  6396. * else:
  6397. * PyObject_AsReadBuffer(ob, <const_void **>&bptr, &blen)
  6398. */
  6399. __pyx_t_1 = __pyx_v_ob;
  6400. __Pyx_INCREF(__pyx_t_1);
  6401. __pyx_t_4 = PyObject_AsWriteBuffer(__pyx_t_1, (&__pyx_v_bptr), (&__pyx_v_blen)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6402. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6403. goto __pyx_L9;
  6404. }
  6405. /*else*/ {
  6406. /* "buffers.pxd":159
  6407. * PyObject_AsWriteBuffer(ob, &bptr, &blen)
  6408. * else:
  6409. * PyObject_AsReadBuffer(ob, <const_void **>&bptr, &blen) # <<<<<<<<<<<<<<
  6410. * if format:
  6411. * try: # numpy.ndarray
  6412. */
  6413. __pyx_t_1 = __pyx_v_ob;
  6414. __Pyx_INCREF(__pyx_t_1);
  6415. __pyx_t_4 = PyObject_AsReadBuffer(__pyx_t_1, ((const void **)(&__pyx_v_bptr)), (&__pyx_v_blen)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6416. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6417. }
  6418. __pyx_L9:;
  6419. /* "buffers.pxd":160
  6420. * else:
  6421. * PyObject_AsReadBuffer(ob, <const_void **>&bptr, &blen)
  6422. * if format: # <<<<<<<<<<<<<<
  6423. * try: # numpy.ndarray
  6424. * dtype = ob.dtype
  6425. */
  6426. if (__pyx_v_format) {
  6427. /* "buffers.pxd":161
  6428. * PyObject_AsReadBuffer(ob, <const_void **>&bptr, &blen)
  6429. * if format:
  6430. * try: # numpy.ndarray # <<<<<<<<<<<<<<
  6431. * dtype = ob.dtype
  6432. * bfmt = dtype.char
  6433. */
  6434. {
  6435. PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
  6436. __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
  6437. __Pyx_XGOTREF(__pyx_save_exc_type);
  6438. __Pyx_XGOTREF(__pyx_save_exc_value);
  6439. __Pyx_XGOTREF(__pyx_save_exc_tb);
  6440. /*try:*/ {
  6441. /* "buffers.pxd":162
  6442. * if format:
  6443. * try: # numpy.ndarray
  6444. * dtype = ob.dtype # <<<<<<<<<<<<<<
  6445. * bfmt = dtype.char
  6446. * bitemlen = dtype.itemsize
  6447. */
  6448. __pyx_t_1 = PyObject_GetAttr(__pyx_v_ob, __pyx_n_s__dtype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  6449. __Pyx_GOTREF(__pyx_t_1);
  6450. __Pyx_DECREF(__pyx_v_dtype);
  6451. __pyx_v_dtype = __pyx_t_1;
  6452. __pyx_t_1 = 0;
  6453. /* "buffers.pxd":163
  6454. * try: # numpy.ndarray
  6455. * dtype = ob.dtype
  6456. * bfmt = dtype.char # <<<<<<<<<<<<<<
  6457. * bitemlen = dtype.itemsize
  6458. * except AttributeError:
  6459. */
  6460. __pyx_t_1 = PyObject_GetAttr(__pyx_v_dtype, __pyx_n_s__char); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  6461. __Pyx_GOTREF(__pyx_t_1);
  6462. if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  6463. __Pyx_DECREF(((PyObject *)__pyx_v_bfmt));
  6464. __pyx_v_bfmt = ((PyObject*)__pyx_t_1);
  6465. __pyx_t_1 = 0;
  6466. /* "buffers.pxd":164
  6467. * dtype = ob.dtype
  6468. * bfmt = dtype.char
  6469. * bitemlen = dtype.itemsize # <<<<<<<<<<<<<<
  6470. * except AttributeError:
  6471. * try: # array.array
  6472. */
  6473. __pyx_t_1 = PyObject_GetAttr(__pyx_v_dtype, __pyx_n_s__itemsize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  6474. __Pyx_GOTREF(__pyx_t_1);
  6475. __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
  6476. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6477. __pyx_v_bitemlen = __pyx_t_5;
  6478. }
  6479. __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
  6480. __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
  6481. __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
  6482. goto __pyx_L18_try_end;
  6483. __pyx_L11_error:;
  6484. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  6485. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  6486. /* "buffers.pxd":165
  6487. * bfmt = dtype.char
  6488. * bitemlen = dtype.itemsize
  6489. * except AttributeError: # <<<<<<<<<<<<<<
  6490. * try: # array.array
  6491. * bfmt = ob.typecode
  6492. */
  6493. __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
  6494. if (__pyx_t_4) {
  6495. __Pyx_AddTraceback("buffers.asbuffer");
  6496. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
  6497. __Pyx_GOTREF(__pyx_t_1);
  6498. __Pyx_GOTREF(__pyx_t_3);
  6499. __Pyx_GOTREF(__pyx_t_6);
  6500. /* "buffers.pxd":166
  6501. * bitemlen = dtype.itemsize
  6502. * except AttributeError:
  6503. * try: # array.array # <<<<<<<<<<<<<<
  6504. * bfmt = ob.typecode
  6505. * bitemlen = ob.itemsize
  6506. */
  6507. {
  6508. PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
  6509. __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
  6510. __Pyx_XGOTREF(__pyx_save_exc_type);
  6511. __Pyx_XGOTREF(__pyx_save_exc_value);
  6512. __Pyx_XGOTREF(__pyx_save_exc_tb);
  6513. /*try:*/ {
  6514. /* "buffers.pxd":167
  6515. * except AttributeError:
  6516. * try: # array.array
  6517. * bfmt = ob.typecode # <<<<<<<<<<<<<<
  6518. * bitemlen = ob.itemsize
  6519. * except AttributeError:
  6520. */
  6521. __pyx_t_7 = PyObject_GetAttr(__pyx_v_ob, __pyx_n_s__typecode); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L21_error;}
  6522. __Pyx_GOTREF(__pyx_t_7);
  6523. if (!(likely(PyString_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_7)->tp_name), 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L21_error;}
  6524. __Pyx_DECREF(((PyObject *)__pyx_v_bfmt));
  6525. __pyx_v_bfmt = ((PyObject*)__pyx_t_7);
  6526. __pyx_t_7 = 0;
  6527. /* "buffers.pxd":168
  6528. * try: # array.array
  6529. * bfmt = ob.typecode
  6530. * bitemlen = ob.itemsize # <<<<<<<<<<<<<<
  6531. * except AttributeError:
  6532. * if isinstance(ob, bytes):
  6533. */
  6534. __pyx_t_7 = PyObject_GetAttr(__pyx_v_ob, __pyx_n_s__itemsize); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L21_error;}
  6535. __Pyx_GOTREF(__pyx_t_7);
  6536. __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L21_error;}
  6537. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6538. __pyx_v_bitemlen = __pyx_t_5;
  6539. }
  6540. __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
  6541. __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
  6542. __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
  6543. goto __pyx_L28_try_end;
  6544. __pyx_L21_error:;
  6545. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6546. /* "buffers.pxd":169
  6547. * bfmt = ob.typecode
  6548. * bitemlen = ob.itemsize
  6549. * except AttributeError: # <<<<<<<<<<<<<<
  6550. * if isinstance(ob, bytes):
  6551. * bfmt = "B"
  6552. */
  6553. __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
  6554. if (__pyx_t_4) {
  6555. __Pyx_AddTraceback("buffers.asbuffer");
  6556. if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L23_except_error;}
  6557. __Pyx_GOTREF(__pyx_t_7);
  6558. __Pyx_GOTREF(__pyx_t_8);
  6559. __Pyx_GOTREF(__pyx_t_9);
  6560. /* "buffers.pxd":170
  6561. * bitemlen = ob.itemsize
  6562. * except AttributeError:
  6563. * if isinstance(ob, bytes): # <<<<<<<<<<<<<<
  6564. * bfmt = "B"
  6565. * bitemlen = 1
  6566. */
  6567. __pyx_t_10 = __pyx_v_ob;
  6568. __Pyx_INCREF(__pyx_t_10);
  6569. __pyx_t_11 = ((PyObject *)((PyObject*)(&PyBytes_Type)));
  6570. __Pyx_INCREF(__pyx_t_11);
  6571. __pyx_t_2 = __Pyx_TypeCheck(__pyx_t_10, __pyx_t_11);
  6572. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  6573. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  6574. if (__pyx_t_2) {
  6575. /* "buffers.pxd":171
  6576. * except AttributeError:
  6577. * if isinstance(ob, bytes):
  6578. * bfmt = "B" # <<<<<<<<<<<<<<
  6579. * bitemlen = 1
  6580. * else:
  6581. */
  6582. __Pyx_INCREF(((PyObject *)__pyx_n_s__B));
  6583. __Pyx_DECREF(((PyObject *)__pyx_v_bfmt));
  6584. __pyx_v_bfmt = __pyx_n_s__B;
  6585. /* "buffers.pxd":172
  6586. * if isinstance(ob, bytes):
  6587. * bfmt = "B"
  6588. * bitemlen = 1 # <<<<<<<<<<<<<<
  6589. * else:
  6590. * # nothing found
  6591. */
  6592. __pyx_v_bitemlen = 1;
  6593. goto __pyx_L31;
  6594. }
  6595. /*else*/ {
  6596. /* "buffers.pxd":175
  6597. * else:
  6598. * # nothing found
  6599. * bfmt = None # <<<<<<<<<<<<<<
  6600. * bitemlen = 0
  6601. * if base: base[0] = <void *>bptr
  6602. */
  6603. __Pyx_INCREF(Py_None);
  6604. __Pyx_DECREF(((PyObject *)__pyx_v_bfmt));
  6605. __pyx_v_bfmt = ((PyObject*)Py_None);
  6606. /* "buffers.pxd":176
  6607. * # nothing found
  6608. * bfmt = None
  6609. * bitemlen = 0 # <<<<<<<<<<<<<<
  6610. * if base: base[0] = <void *>bptr
  6611. * if size: size[0] = <Py_ssize_t>blen
  6612. */
  6613. __pyx_v_bitemlen = 0;
  6614. }
  6615. __pyx_L31:;
  6616. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6617. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6618. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6619. goto __pyx_L22_exception_handled;
  6620. }
  6621. __pyx_L23_except_error:;
  6622. __Pyx_XGIVEREF(__pyx_save_exc_type);
  6623. __Pyx_XGIVEREF(__pyx_save_exc_value);
  6624. __Pyx_XGIVEREF(__pyx_save_exc_tb);
  6625. __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
  6626. goto __pyx_L13_except_error;
  6627. __pyx_L22_exception_handled:;
  6628. __Pyx_XGIVEREF(__pyx_save_exc_type);
  6629. __Pyx_XGIVEREF(__pyx_save_exc_value);
  6630. __Pyx_XGIVEREF(__pyx_save_exc_tb);
  6631. __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
  6632. __pyx_L28_try_end:;
  6633. }
  6634. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6635. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6636. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6637. goto __pyx_L12_exception_handled;
  6638. }
  6639. __pyx_L13_except_error:;
  6640. __Pyx_XGIVEREF(__pyx_save_exc_type);
  6641. __Pyx_XGIVEREF(__pyx_save_exc_value);
  6642. __Pyx_XGIVEREF(__pyx_save_exc_tb);
  6643. __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
  6644. goto __pyx_L1_error;
  6645. __pyx_L12_exception_handled:;
  6646. __Pyx_XGIVEREF(__pyx_save_exc_type);
  6647. __Pyx_XGIVEREF(__pyx_save_exc_value);
  6648. __Pyx_XGIVEREF(__pyx_save_exc_tb);
  6649. __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
  6650. __pyx_L18_try_end:;
  6651. }
  6652. goto __pyx_L10;
  6653. }
  6654. __pyx_L10:;
  6655. }
  6656. __pyx_L4:;
  6657. /* "buffers.pxd":177
  6658. * bfmt = None
  6659. * bitemlen = 0
  6660. * if base: base[0] = <void *>bptr # <<<<<<<<<<<<<<
  6661. * if size: size[0] = <Py_ssize_t>blen
  6662. * if itemsize: itemsize[0] = <Py_ssize_t>bitemlen
  6663. */
  6664. __pyx_t_2 = (__pyx_v_base != 0);
  6665. if (__pyx_t_2) {
  6666. (__pyx_v_base[0]) = ((void *)__pyx_v_bptr);
  6667. goto __pyx_L32;
  6668. }
  6669. __pyx_L32:;
  6670. /* "buffers.pxd":178
  6671. * bitemlen = 0
  6672. * if base: base[0] = <void *>bptr
  6673. * if size: size[0] = <Py_ssize_t>blen # <<<<<<<<<<<<<<
  6674. * if itemsize: itemsize[0] = <Py_ssize_t>bitemlen
  6675. * return bfmt
  6676. */
  6677. __pyx_t_2 = (__pyx_v_size != 0);
  6678. if (__pyx_t_2) {
  6679. (__pyx_v_size[0]) = __pyx_v_blen;
  6680. goto __pyx_L33;
  6681. }
  6682. __pyx_L33:;
  6683. /* "buffers.pxd":179
  6684. * if base: base[0] = <void *>bptr
  6685. * if size: size[0] = <Py_ssize_t>blen
  6686. * if itemsize: itemsize[0] = <Py_ssize_t>bitemlen # <<<<<<<<<<<<<<
  6687. * return bfmt
  6688. *
  6689. */
  6690. __pyx_t_2 = (__pyx_v_itemsize != 0);
  6691. if (__pyx_t_2) {
  6692. (__pyx_v_itemsize[0]) = __pyx_v_bitemlen;
  6693. goto __pyx_L34;
  6694. }
  6695. __pyx_L34:;
  6696. /* "buffers.pxd":180
  6697. * if size: size[0] = <Py_ssize_t>blen
  6698. * if itemsize: itemsize[0] = <Py_ssize_t>bitemlen
  6699. * return bfmt # <<<<<<<<<<<<<<
  6700. *
  6701. *
  6702. */
  6703. __Pyx_XDECREF(__pyx_r);
  6704. __Pyx_INCREF(((PyObject *)__pyx_v_bfmt));
  6705. __pyx_r = ((PyObject *)__pyx_v_bfmt);
  6706. goto __pyx_L0;
  6707. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6708. goto __pyx_L0;
  6709. __pyx_L1_error:;
  6710. __Pyx_XDECREF(__pyx_t_1);
  6711. __Pyx_XDECREF(__pyx_t_3);
  6712. __Pyx_XDECREF(__pyx_t_6);
  6713. __Pyx_XDECREF(__pyx_t_7);
  6714. __Pyx_XDECREF(__pyx_t_8);
  6715. __Pyx_XDECREF(__pyx_t_9);
  6716. __Pyx_XDECREF(__pyx_t_10);
  6717. __Pyx_XDECREF(__pyx_t_11);
  6718. __Pyx_AddTraceback("buffers.asbuffer");
  6719. __pyx_r = 0;
  6720. __pyx_L0:;
  6721. __Pyx_XDECREF(__pyx_v_bfmt);
  6722. __Pyx_DECREF(__pyx_v_dtype);
  6723. __Pyx_XGIVEREF(__pyx_r);
  6724. __Pyx_RefNannyFinishContext();
  6725. return __pyx_r;
  6726. }
  6727. /* "buffers.pxd":183
  6728. *
  6729. *
  6730. * cdef inline object asbuffer_r(object ob, void **base, Py_ssize_t *size): # <<<<<<<<<<<<<<
  6731. * """Wrapper for standard calls to asbuffer with a readonly buffer."""
  6732. * asbuffer(ob, 0, 0, base, size, NULL)
  6733. */
  6734. static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer_r(PyObject *__pyx_v_ob, void **__pyx_v_base, Py_ssize_t *__pyx_v_size) {
  6735. PyObject *__pyx_r = NULL;
  6736. PyObject *__pyx_t_1 = NULL;
  6737. PyObject *__pyx_t_2 = NULL;
  6738. __Pyx_RefNannySetupContext("asbuffer_r");
  6739. /* "buffers.pxd":185
  6740. * cdef inline object asbuffer_r(object ob, void **base, Py_ssize_t *size):
  6741. * """Wrapper for standard calls to asbuffer with a readonly buffer."""
  6742. * asbuffer(ob, 0, 0, base, size, NULL) # <<<<<<<<<<<<<<
  6743. * return ob
  6744. *
  6745. */
  6746. __pyx_t_1 = __pyx_v_ob;
  6747. __Pyx_INCREF(__pyx_t_1);
  6748. __pyx_t_2 = __pyx_f_7buffers_asbuffer(__pyx_t_1, 0, 0, __pyx_v_base, __pyx_v_size, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6749. __Pyx_GOTREF(__pyx_t_2);
  6750. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6751. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6752. /* "buffers.pxd":186
  6753. * """Wrapper for standard calls to asbuffer with a readonly buffer."""
  6754. * asbuffer(ob, 0, 0, base, size, NULL)
  6755. * return ob # <<<<<<<<<<<<<<
  6756. *
  6757. *
  6758. */
  6759. __Pyx_XDECREF(__pyx_r);
  6760. __Pyx_INCREF(__pyx_v_ob);
  6761. __pyx_r = __pyx_v_ob;
  6762. goto __pyx_L0;
  6763. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6764. goto __pyx_L0;
  6765. __pyx_L1_error:;
  6766. __Pyx_XDECREF(__pyx_t_1);
  6767. __Pyx_XDECREF(__pyx_t_2);
  6768. __Pyx_AddTraceback("buffers.asbuffer_r");
  6769. __pyx_r = 0;
  6770. __pyx_L0:;
  6771. __Pyx_XGIVEREF(__pyx_r);
  6772. __Pyx_RefNannyFinishContext();
  6773. return __pyx_r;
  6774. }
  6775. /* "buffers.pxd":189
  6776. *
  6777. *
  6778. * cdef inline object asbuffer_w(object ob, void **base, Py_ssize_t *size): # <<<<<<<<<<<<<<
  6779. * """Wrapper for standard calls to asbuffer with a writable buffer."""
  6780. * asbuffer(ob, 1, 0, base, size, NULL)
  6781. */
  6782. static CYTHON_INLINE PyObject *__pyx_f_7buffers_asbuffer_w(PyObject *__pyx_v_ob, void **__pyx_v_base, Py_ssize_t *__pyx_v_size) {
  6783. PyObject *__pyx_r = NULL;
  6784. PyObject *__pyx_t_1 = NULL;
  6785. PyObject *__pyx_t_2 = NULL;
  6786. __Pyx_RefNannySetupContext("asbuffer_w");
  6787. /* "buffers.pxd":191
  6788. * cdef inline object asbuffer_w(object ob, void **base, Py_ssize_t *size):
  6789. * """Wrapper for standard calls to asbuffer with a writable buffer."""
  6790. * asbuffer(ob, 1, 0, base, size, NULL) # <<<<<<<<<<<<<<
  6791. * return ob
  6792. *
  6793. */
  6794. __pyx_t_1 = __pyx_v_ob;
  6795. __Pyx_INCREF(__pyx_t_1);
  6796. __pyx_t_2 = __pyx_f_7buffers_asbuffer(__pyx_t_1, 1, 0, __pyx_v_base, __pyx_v_size, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6797. __Pyx_GOTREF(__pyx_t_2);
  6798. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6799. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6800. /* "buffers.pxd":192
  6801. * """Wrapper for standard calls to asbuffer with a writable buffer."""
  6802. * asbuffer(ob, 1, 0, base, size, NULL)
  6803. * return ob # <<<<<<<<<<<<<<
  6804. *
  6805. * #------------------------------------------------------------------------------
  6806. */
  6807. __Pyx_XDECREF(__pyx_r);
  6808. __Pyx_INCREF(__pyx_v_ob);
  6809. __pyx_r = __pyx_v_ob;
  6810. goto __pyx_L0;
  6811. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6812. goto __pyx_L0;
  6813. __pyx_L1_error:;
  6814. __Pyx_XDECREF(__pyx_t_1);
  6815. __Pyx_XDECREF(__pyx_t_2);
  6816. __Pyx_AddTraceback("buffers.asbuffer_w");
  6817. __pyx_r = 0;
  6818. __pyx_L0:;
  6819. __Pyx_XGIVEREF(__pyx_r);
  6820. __Pyx_RefNannyFinishContext();
  6821. return __pyx_r;
  6822. }
  6823. /* "buffers.pxd":198
  6824. * #------------------------------------------------------------------------------
  6825. *
  6826. * cdef inline object frombuffer_3(void *ptr, Py_ssize_t s, int readonly): # <<<<<<<<<<<<<<
  6827. * """Python 3 version of frombuffer.
  6828. *
  6829. */
  6830. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_3(void *__pyx_v_ptr, Py_ssize_t __pyx_v_s, int __pyx_v_readonly) {
  6831. Py_buffer __pyx_v_pybuf;
  6832. Py_ssize_t *__pyx_v_shape;
  6833. PyObject *__pyx_v_astr = 0;
  6834. PyObject *__pyx_r = NULL;
  6835. Py_ssize_t __pyx_t_1[1];
  6836. int __pyx_t_2;
  6837. PyObject *__pyx_t_3 = NULL;
  6838. __Pyx_RefNannySetupContext("frombuffer_3");
  6839. /* "buffers.pxd":205
  6840. * """
  6841. * cdef Py_buffer pybuf
  6842. * cdef Py_ssize_t *shape = [s] # <<<<<<<<<<<<<<
  6843. * cdef str astr=""
  6844. * if newstyle_available():
  6845. */
  6846. __pyx_t_1[0] = __pyx_v_s;
  6847. __pyx_v_shape = __pyx_t_1;
  6848. /* "buffers.pxd":206
  6849. * cdef Py_buffer pybuf
  6850. * cdef Py_ssize_t *shape = [s]
  6851. * cdef str astr="" # <<<<<<<<<<<<<<
  6852. * if newstyle_available():
  6853. * PyBuffer_FillInfo(&pybuf, astr, ptr, s, readonly, PyBUF_SIMPLE)
  6854. */
  6855. __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
  6856. __pyx_v_astr = __pyx_kp_s_34;
  6857. /* "buffers.pxd":207
  6858. * cdef Py_ssize_t *shape = [s]
  6859. * cdef str astr=""
  6860. * if newstyle_available(): # <<<<<<<<<<<<<<
  6861. * PyBuffer_FillInfo(&pybuf, astr, ptr, s, readonly, PyBUF_SIMPLE)
  6862. * pybuf.format = "B"
  6863. */
  6864. __pyx_t_2 = __pyx_f_7buffers_newstyle_available();
  6865. if (__pyx_t_2) {
  6866. /* "buffers.pxd":208
  6867. * cdef str astr=""
  6868. * if newstyle_available():
  6869. * PyBuffer_FillInfo(&pybuf, astr, ptr, s, readonly, PyBUF_SIMPLE) # <<<<<<<<<<<<<<
  6870. * pybuf.format = "B"
  6871. * pybuf.shape = shape
  6872. */
  6873. __pyx_t_2 = PyBuffer_FillInfo((&__pyx_v_pybuf), ((PyObject *)__pyx_v_astr), __pyx_v_ptr, __pyx_v_s, __pyx_v_readonly, PyBUF_SIMPLE); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6874. /* "buffers.pxd":209
  6875. * if newstyle_available():
  6876. * PyBuffer_FillInfo(&pybuf, astr, ptr, s, readonly, PyBUF_SIMPLE)
  6877. * pybuf.format = "B" # <<<<<<<<<<<<<<
  6878. * pybuf.shape = shape
  6879. * return PyMemoryView_FromBuffer(&pybuf)
  6880. */
  6881. __pyx_v_pybuf.format = __pyx_k__B;
  6882. /* "buffers.pxd":210
  6883. * PyBuffer_FillInfo(&pybuf, astr, ptr, s, readonly, PyBUF_SIMPLE)
  6884. * pybuf.format = "B"
  6885. * pybuf.shape = shape # <<<<<<<<<<<<<<
  6886. * return PyMemoryView_FromBuffer(&pybuf)
  6887. * else:
  6888. */
  6889. __pyx_v_pybuf.shape = __pyx_v_shape;
  6890. /* "buffers.pxd":211
  6891. * pybuf.format = "B"
  6892. * pybuf.shape = shape
  6893. * return PyMemoryView_FromBuffer(&pybuf) # <<<<<<<<<<<<<<
  6894. * else:
  6895. * raise NotImplementedError("New style buffers not available.")
  6896. */
  6897. __Pyx_XDECREF(__pyx_r);
  6898. __pyx_t_3 = PyMemoryView_FromBuffer((&__pyx_v_pybuf)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6899. __Pyx_GOTREF(__pyx_t_3);
  6900. __pyx_r = __pyx_t_3;
  6901. __pyx_t_3 = 0;
  6902. goto __pyx_L0;
  6903. goto __pyx_L3;
  6904. }
  6905. /*else*/ {
  6906. /* "buffers.pxd":213
  6907. * return PyMemoryView_FromBuffer(&pybuf)
  6908. * else:
  6909. * raise NotImplementedError("New style buffers not available.") # <<<<<<<<<<<<<<
  6910. *
  6911. *
  6912. */
  6913. __pyx_t_3 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_36), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6914. __Pyx_GOTREF(__pyx_t_3);
  6915. __Pyx_Raise(__pyx_t_3, 0, 0);
  6916. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6917. {__pyx_filename = __pyx_f[2]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6918. }
  6919. __pyx_L3:;
  6920. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6921. goto __pyx_L0;
  6922. __pyx_L1_error:;
  6923. __Pyx_XDECREF(__pyx_t_3);
  6924. __Pyx_AddTraceback("buffers.frombuffer_3");
  6925. __pyx_r = 0;
  6926. __pyx_L0:;
  6927. __Pyx_XDECREF(__pyx_v_astr);
  6928. __Pyx_XGIVEREF(__pyx_r);
  6929. __Pyx_RefNannyFinishContext();
  6930. return __pyx_r;
  6931. }
  6932. /* "buffers.pxd":216
  6933. *
  6934. *
  6935. * cdef inline object frombuffer_2(void *ptr, Py_ssize_t s, int readonly): # <<<<<<<<<<<<<<
  6936. * """Python 2 version of frombuffer.
  6937. *
  6938. */
  6939. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_2(void *__pyx_v_ptr, Py_ssize_t __pyx_v_s, int __pyx_v_readonly) {
  6940. PyObject *__pyx_r = NULL;
  6941. int __pyx_t_1;
  6942. PyObject *__pyx_t_2 = NULL;
  6943. __Pyx_RefNannySetupContext("frombuffer_2");
  6944. /* "buffers.pxd":222
  6945. * """
  6946. *
  6947. * if oldstyle_available(): # <<<<<<<<<<<<<<
  6948. * if readonly:
  6949. * return PyBuffer_FromMemory(ptr, s)
  6950. */
  6951. __pyx_t_1 = __pyx_f_7buffers_oldstyle_available();
  6952. if (__pyx_t_1) {
  6953. /* "buffers.pxd":223
  6954. *
  6955. * if oldstyle_available():
  6956. * if readonly: # <<<<<<<<<<<<<<
  6957. * return PyBuffer_FromMemory(ptr, s)
  6958. * else:
  6959. */
  6960. if (__pyx_v_readonly) {
  6961. /* "buffers.pxd":224
  6962. * if oldstyle_available():
  6963. * if readonly:
  6964. * return PyBuffer_FromMemory(ptr, s) # <<<<<<<<<<<<<<
  6965. * else:
  6966. * return PyBuffer_FromReadWriteMemory(ptr, s)
  6967. */
  6968. __Pyx_XDECREF(__pyx_r);
  6969. __pyx_t_2 = PyBuffer_FromMemory(__pyx_v_ptr, __pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6970. __Pyx_GOTREF(__pyx_t_2);
  6971. __pyx_r = __pyx_t_2;
  6972. __pyx_t_2 = 0;
  6973. goto __pyx_L0;
  6974. goto __pyx_L4;
  6975. }
  6976. /*else*/ {
  6977. /* "buffers.pxd":226
  6978. * return PyBuffer_FromMemory(ptr, s)
  6979. * else:
  6980. * return PyBuffer_FromReadWriteMemory(ptr, s) # <<<<<<<<<<<<<<
  6981. * else:
  6982. * raise NotImplementedError("Old style buffers not available.")
  6983. */
  6984. __Pyx_XDECREF(__pyx_r);
  6985. __pyx_t_2 = PyBuffer_FromReadWriteMemory(__pyx_v_ptr, __pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  6986. __Pyx_GOTREF(__pyx_t_2);
  6987. __pyx_r = __pyx_t_2;
  6988. __pyx_t_2 = 0;
  6989. goto __pyx_L0;
  6990. }
  6991. __pyx_L4:;
  6992. goto __pyx_L3;
  6993. }
  6994. /*else*/ {
  6995. /* "buffers.pxd":228
  6996. * return PyBuffer_FromReadWriteMemory(ptr, s)
  6997. * else:
  6998. * raise NotImplementedError("Old style buffers not available.") # <<<<<<<<<<<<<<
  6999. *
  7000. *
  7001. */
  7002. __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_38), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7003. __Pyx_GOTREF(__pyx_t_2);
  7004. __Pyx_Raise(__pyx_t_2, 0, 0);
  7005. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7006. {__pyx_filename = __pyx_f[2]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7007. }
  7008. __pyx_L3:;
  7009. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7010. goto __pyx_L0;
  7011. __pyx_L1_error:;
  7012. __Pyx_XDECREF(__pyx_t_2);
  7013. __Pyx_AddTraceback("buffers.frombuffer_2");
  7014. __pyx_r = 0;
  7015. __pyx_L0:;
  7016. __Pyx_XGIVEREF(__pyx_r);
  7017. __Pyx_RefNannyFinishContext();
  7018. return __pyx_r;
  7019. }
  7020. /* "buffers.pxd":231
  7021. *
  7022. *
  7023. * cdef inline object frombuffer(void *ptr, Py_ssize_t s, int readonly): # <<<<<<<<<<<<<<
  7024. * """Create a Python Buffer/View of a C array.
  7025. *
  7026. */
  7027. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer(void *__pyx_v_ptr, Py_ssize_t __pyx_v_s, int __pyx_v_readonly) {
  7028. PyObject *__pyx_r = NULL;
  7029. int __pyx_t_1;
  7030. PyObject *__pyx_t_2 = NULL;
  7031. __Pyx_RefNannySetupContext("frombuffer");
  7032. /* "buffers.pxd":248
  7033. * """
  7034. * # oldstyle first priority for now
  7035. * if oldstyle_available(): # <<<<<<<<<<<<<<
  7036. * return frombuffer_2(ptr, s, readonly)
  7037. * else:
  7038. */
  7039. __pyx_t_1 = __pyx_f_7buffers_oldstyle_available();
  7040. if (__pyx_t_1) {
  7041. /* "buffers.pxd":249
  7042. * # oldstyle first priority for now
  7043. * if oldstyle_available():
  7044. * return frombuffer_2(ptr, s, readonly) # <<<<<<<<<<<<<<
  7045. * else:
  7046. * return frombuffer_3(ptr, s, readonly)
  7047. */
  7048. __Pyx_XDECREF(__pyx_r);
  7049. __pyx_t_2 = __pyx_f_7buffers_frombuffer_2(__pyx_v_ptr, __pyx_v_s, __pyx_v_readonly); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7050. __Pyx_GOTREF(__pyx_t_2);
  7051. __pyx_r = __pyx_t_2;
  7052. __pyx_t_2 = 0;
  7053. goto __pyx_L0;
  7054. goto __pyx_L3;
  7055. }
  7056. /*else*/ {
  7057. /* "buffers.pxd":251
  7058. * return frombuffer_2(ptr, s, readonly)
  7059. * else:
  7060. * return frombuffer_3(ptr, s, readonly) # <<<<<<<<<<<<<<
  7061. *
  7062. *
  7063. */
  7064. __Pyx_XDECREF(__pyx_r);
  7065. __pyx_t_2 = __pyx_f_7buffers_frombuffer_3(__pyx_v_ptr, __pyx_v_s, __pyx_v_readonly); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7066. __Pyx_GOTREF(__pyx_t_2);
  7067. __pyx_r = __pyx_t_2;
  7068. __pyx_t_2 = 0;
  7069. goto __pyx_L0;
  7070. }
  7071. __pyx_L3:;
  7072. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7073. goto __pyx_L0;
  7074. __pyx_L1_error:;
  7075. __Pyx_XDECREF(__pyx_t_2);
  7076. __Pyx_AddTraceback("buffers.frombuffer");
  7077. __pyx_r = 0;
  7078. __pyx_L0:;
  7079. __Pyx_XGIVEREF(__pyx_r);
  7080. __Pyx_RefNannyFinishContext();
  7081. return __pyx_r;
  7082. }
  7083. /* "buffers.pxd":254
  7084. *
  7085. *
  7086. * cdef inline object frombuffer_r(void *ptr, Py_ssize_t s): # <<<<<<<<<<<<<<
  7087. * """Wrapper for readonly view frombuffer."""
  7088. * return frombuffer(ptr, s, 1)
  7089. */
  7090. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_r(void *__pyx_v_ptr, Py_ssize_t __pyx_v_s) {
  7091. PyObject *__pyx_r = NULL;
  7092. PyObject *__pyx_t_1 = NULL;
  7093. __Pyx_RefNannySetupContext("frombuffer_r");
  7094. /* "buffers.pxd":256
  7095. * cdef inline object frombuffer_r(void *ptr, Py_ssize_t s):
  7096. * """Wrapper for readonly view frombuffer."""
  7097. * return frombuffer(ptr, s, 1) # <<<<<<<<<<<<<<
  7098. *
  7099. *
  7100. */
  7101. __Pyx_XDECREF(__pyx_r);
  7102. __pyx_t_1 = __pyx_f_7buffers_frombuffer(__pyx_v_ptr, __pyx_v_s, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7103. __Pyx_GOTREF(__pyx_t_1);
  7104. __pyx_r = __pyx_t_1;
  7105. __pyx_t_1 = 0;
  7106. goto __pyx_L0;
  7107. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7108. goto __pyx_L0;
  7109. __pyx_L1_error:;
  7110. __Pyx_XDECREF(__pyx_t_1);
  7111. __Pyx_AddTraceback("buffers.frombuffer_r");
  7112. __pyx_r = 0;
  7113. __pyx_L0:;
  7114. __Pyx_XGIVEREF(__pyx_r);
  7115. __Pyx_RefNannyFinishContext();
  7116. return __pyx_r;
  7117. }
  7118. /* "buffers.pxd":259
  7119. *
  7120. *
  7121. * cdef inline object frombuffer_w(void *ptr, Py_ssize_t s): # <<<<<<<<<<<<<<
  7122. * """Wrapper for writable view frombuffer."""
  7123. * return frombuffer(ptr, s, 0)
  7124. */
  7125. static CYTHON_INLINE PyObject *__pyx_f_7buffers_frombuffer_w(void *__pyx_v_ptr, Py_ssize_t __pyx_v_s) {
  7126. PyObject *__pyx_r = NULL;
  7127. PyObject *__pyx_t_1 = NULL;
  7128. __Pyx_RefNannySetupContext("frombuffer_w");
  7129. /* "buffers.pxd":261
  7130. * cdef inline object frombuffer_w(void *ptr, Py_ssize_t s):
  7131. * """Wrapper for writable view frombuffer."""
  7132. * return frombuffer(ptr, s, 0) # <<<<<<<<<<<<<<
  7133. *
  7134. * #------------------------------------------------------------------------------
  7135. */
  7136. __Pyx_XDECREF(__pyx_r);
  7137. __pyx_t_1 = __pyx_f_7buffers_frombuffer(__pyx_v_ptr, __pyx_v_s, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7138. __Pyx_GOTREF(__pyx_t_1);
  7139. __pyx_r = __pyx_t_1;
  7140. __pyx_t_1 = 0;
  7141. goto __pyx_L0;
  7142. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7143. goto __pyx_L0;
  7144. __pyx_L1_error:;
  7145. __Pyx_XDECREF(__pyx_t_1);
  7146. __Pyx_AddTraceback("buffers.frombuffer_w");
  7147. __pyx_r = 0;
  7148. __pyx_L0:;
  7149. __Pyx_XGIVEREF(__pyx_r);
  7150. __Pyx_RefNannyFinishContext();
  7151. return __pyx_r;
  7152. }
  7153. /* "buffers.pxd":268
  7154. * #------------------------------------------------------------------------------
  7155. *
  7156. * cdef inline object viewfromobject(object obj, int readonly): # <<<<<<<<<<<<<<
  7157. * """Construct a Python Buffer/View object from another Python object.
  7158. *
  7159. */
  7160. static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject(PyObject *__pyx_v_obj, int __pyx_v_readonly) {
  7161. PyObject *__pyx_r = NULL;
  7162. int __pyx_t_1;
  7163. PyObject *__pyx_t_2 = NULL;
  7164. PyObject *__pyx_t_3 = NULL;
  7165. __Pyx_RefNannySetupContext("viewfromobject");
  7166. /* "buffers.pxd":284
  7167. * Buffer/View of the original object.
  7168. * """
  7169. * if not memoryview_available(): # <<<<<<<<<<<<<<
  7170. * if readonly:
  7171. * return PyBuffer_FromObject(obj, 0, Py_END_OF_BUFFER)
  7172. */
  7173. __pyx_t_1 = (!__pyx_f_7buffers_memoryview_available());
  7174. if (__pyx_t_1) {
  7175. /* "buffers.pxd":285
  7176. * """
  7177. * if not memoryview_available():
  7178. * if readonly: # <<<<<<<<<<<<<<
  7179. * return PyBuffer_FromObject(obj, 0, Py_END_OF_BUFFER)
  7180. * else:
  7181. */
  7182. if (__pyx_v_readonly) {
  7183. /* "buffers.pxd":286
  7184. * if not memoryview_available():
  7185. * if readonly:
  7186. * return PyBuffer_FromObject(obj, 0, Py_END_OF_BUFFER) # <<<<<<<<<<<<<<
  7187. * else:
  7188. * return PyBuffer_FromReadWriteObject(obj, 0, Py_END_OF_BUFFER)
  7189. */
  7190. __Pyx_XDECREF(__pyx_r);
  7191. __pyx_t_2 = __pyx_v_obj;
  7192. __Pyx_INCREF(__pyx_t_2);
  7193. __pyx_t_3 = PyBuffer_FromObject(__pyx_t_2, 0, Py_END_OF_BUFFER); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7194. __Pyx_GOTREF(__pyx_t_3);
  7195. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7196. __pyx_r = __pyx_t_3;
  7197. __pyx_t_3 = 0;
  7198. goto __pyx_L0;
  7199. goto __pyx_L4;
  7200. }
  7201. /*else*/ {
  7202. /* "buffers.pxd":288
  7203. * return PyBuffer_FromObject(obj, 0, Py_END_OF_BUFFER)
  7204. * else:
  7205. * return PyBuffer_FromReadWriteObject(obj, 0, Py_END_OF_BUFFER) # <<<<<<<<<<<<<<
  7206. * else:
  7207. * return PyMemoryView_FromObject(obj)
  7208. */
  7209. __Pyx_XDECREF(__pyx_r);
  7210. __pyx_t_3 = __pyx_v_obj;
  7211. __Pyx_INCREF(__pyx_t_3);
  7212. __pyx_t_2 = PyBuffer_FromReadWriteObject(__pyx_t_3, 0, Py_END_OF_BUFFER); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7213. __Pyx_GOTREF(__pyx_t_2);
  7214. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7215. __pyx_r = __pyx_t_2;
  7216. __pyx_t_2 = 0;
  7217. goto __pyx_L0;
  7218. }
  7219. __pyx_L4:;
  7220. goto __pyx_L3;
  7221. }
  7222. /*else*/ {
  7223. /* "buffers.pxd":290
  7224. * return PyBuffer_FromReadWriteObject(obj, 0, Py_END_OF_BUFFER)
  7225. * else:
  7226. * return PyMemoryView_FromObject(obj) # <<<<<<<<<<<<<<
  7227. *
  7228. *
  7229. */
  7230. __Pyx_XDECREF(__pyx_r);
  7231. __pyx_t_2 = __pyx_v_obj;
  7232. __Pyx_INCREF(__pyx_t_2);
  7233. __pyx_t_3 = PyMemoryView_FromObject(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7234. __Pyx_GOTREF(__pyx_t_3);
  7235. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7236. __pyx_r = __pyx_t_3;
  7237. __pyx_t_3 = 0;
  7238. goto __pyx_L0;
  7239. }
  7240. __pyx_L3:;
  7241. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7242. goto __pyx_L0;
  7243. __pyx_L1_error:;
  7244. __Pyx_XDECREF(__pyx_t_2);
  7245. __Pyx_XDECREF(__pyx_t_3);
  7246. __Pyx_AddTraceback("buffers.viewfromobject");
  7247. __pyx_r = 0;
  7248. __pyx_L0:;
  7249. __Pyx_XGIVEREF(__pyx_r);
  7250. __Pyx_RefNannyFinishContext();
  7251. return __pyx_r;
  7252. }
  7253. /* "buffers.pxd":293
  7254. *
  7255. *
  7256. * cdef inline object viewfromobject_r(object obj): # <<<<<<<<<<<<<<
  7257. * """Wrapper for readonly viewfromobject."""
  7258. * return viewfromobject(obj, 1)
  7259. */
  7260. static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject_r(PyObject *__pyx_v_obj) {
  7261. PyObject *__pyx_r = NULL;
  7262. PyObject *__pyx_t_1 = NULL;
  7263. PyObject *__pyx_t_2 = NULL;
  7264. __Pyx_RefNannySetupContext("viewfromobject_r");
  7265. /* "buffers.pxd":295
  7266. * cdef inline object viewfromobject_r(object obj):
  7267. * """Wrapper for readonly viewfromobject."""
  7268. * return viewfromobject(obj, 1) # <<<<<<<<<<<<<<
  7269. *
  7270. *
  7271. */
  7272. __Pyx_XDECREF(__pyx_r);
  7273. __pyx_t_1 = __pyx_v_obj;
  7274. __Pyx_INCREF(__pyx_t_1);
  7275. __pyx_t_2 = __pyx_f_7buffers_viewfromobject(__pyx_t_1, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7276. __Pyx_GOTREF(__pyx_t_2);
  7277. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7278. __pyx_r = __pyx_t_2;
  7279. __pyx_t_2 = 0;
  7280. goto __pyx_L0;
  7281. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7282. goto __pyx_L0;
  7283. __pyx_L1_error:;
  7284. __Pyx_XDECREF(__pyx_t_1);
  7285. __Pyx_XDECREF(__pyx_t_2);
  7286. __Pyx_AddTraceback("buffers.viewfromobject_r");
  7287. __pyx_r = 0;
  7288. __pyx_L0:;
  7289. __Pyx_XGIVEREF(__pyx_r);
  7290. __Pyx_RefNannyFinishContext();
  7291. return __pyx_r;
  7292. }
  7293. /* "buffers.pxd":298
  7294. *
  7295. *
  7296. * cdef inline object viewfromobject_w(object obj): # <<<<<<<<<<<<<<
  7297. * """Wrapper for writable viewfromobject."""
  7298. * return viewfromobject(obj, 0)
  7299. */
  7300. static CYTHON_INLINE PyObject *__pyx_f_7buffers_viewfromobject_w(PyObject *__pyx_v_obj) {
  7301. PyObject *__pyx_r = NULL;
  7302. PyObject *__pyx_t_1 = NULL;
  7303. PyObject *__pyx_t_2 = NULL;
  7304. __Pyx_RefNannySetupContext("viewfromobject_w");
  7305. /* "buffers.pxd":300
  7306. * cdef inline object viewfromobject_w(object obj):
  7307. * """Wrapper for writable viewfromobject."""
  7308. * return viewfromobject(obj, 0) # <<<<<<<<<<<<<<
  7309. */
  7310. __Pyx_XDECREF(__pyx_r);
  7311. __pyx_t_1 = __pyx_v_obj;
  7312. __Pyx_INCREF(__pyx_t_1);
  7313. __pyx_t_2 = __pyx_f_7buffers_viewfromobject(__pyx_t_1, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7314. __Pyx_GOTREF(__pyx_t_2);
  7315. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7316. __pyx_r = __pyx_t_2;
  7317. __pyx_t_2 = 0;
  7318. goto __pyx_L0;
  7319. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7320. goto __pyx_L0;
  7321. __pyx_L1_error:;
  7322. __Pyx_XDECREF(__pyx_t_1);
  7323. __Pyx_XDECREF(__pyx_t_2);
  7324. __Pyx_AddTraceback("buffers.viewfromobject_w");
  7325. __pyx_r = 0;
  7326. __pyx_L0:;
  7327. __Pyx_XGIVEREF(__pyx_r);
  7328. __Pyx_RefNannyFinishContext();
  7329. return __pyx_r;
  7330. }
  7331. static struct __pyx_vtabstruct_3zmq_4core_6socket_Socket __pyx_vtable_3zmq_4core_6socket_Socket;
  7332. static PyObject *__pyx_tp_new_3zmq_4core_6socket_Socket(PyTypeObject *t, PyObject *a, PyObject *k) {
  7333. struct __pyx_obj_3zmq_4core_6socket_Socket *p;
  7334. PyObject *o = (*t->tp_alloc)(t, 0);
  7335. if (!o) return 0;
  7336. p = ((struct __pyx_obj_3zmq_4core_6socket_Socket *)o);
  7337. p->__pyx_vtab = __pyx_vtabptr_3zmq_4core_6socket_Socket;
  7338. p->context = Py_None; Py_INCREF(Py_None);
  7339. p->closed = Py_None; Py_INCREF(Py_None);
  7340. if (__pyx_pf_3zmq_4core_6socket_6Socket___cinit__(o, a, k) < 0) {
  7341. Py_DECREF(o); o = 0;
  7342. }
  7343. return o;
  7344. }
  7345. static void __pyx_tp_dealloc_3zmq_4core_6socket_Socket(PyObject *o) {
  7346. struct __pyx_obj_3zmq_4core_6socket_Socket *p = (struct __pyx_obj_3zmq_4core_6socket_Socket *)o;
  7347. {
  7348. PyObject *etype, *eval, *etb;
  7349. PyErr_Fetch(&etype, &eval, &etb);
  7350. ++Py_REFCNT(o);
  7351. __pyx_pf_3zmq_4core_6socket_6Socket_1__dealloc__(o);
  7352. if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
  7353. --Py_REFCNT(o);
  7354. PyErr_Restore(etype, eval, etb);
  7355. }
  7356. Py_XDECREF(p->context);
  7357. Py_XDECREF(p->closed);
  7358. (*Py_TYPE(o)->tp_free)(o);
  7359. }
  7360. static int __pyx_tp_traverse_3zmq_4core_6socket_Socket(PyObject *o, visitproc v, void *a) {
  7361. int e;
  7362. struct __pyx_obj_3zmq_4core_6socket_Socket *p = (struct __pyx_obj_3zmq_4core_6socket_Socket *)o;
  7363. if (p->context) {
  7364. e = (*v)(p->context, a); if (e) return e;
  7365. }
  7366. if (p->closed) {
  7367. e = (*v)(p->closed, a); if (e) return e;
  7368. }
  7369. return 0;
  7370. }
  7371. static int __pyx_tp_clear_3zmq_4core_6socket_Socket(PyObject *o) {
  7372. struct __pyx_obj_3zmq_4core_6socket_Socket *p = (struct __pyx_obj_3zmq_4core_6socket_Socket *)o;
  7373. PyObject* tmp;
  7374. tmp = ((PyObject*)p->context);
  7375. p->context = Py_None; Py_INCREF(Py_None);
  7376. Py_XDECREF(tmp);
  7377. tmp = ((PyObject*)p->closed);
  7378. p->closed = Py_None; Py_INCREF(Py_None);
  7379. Py_XDECREF(tmp);
  7380. return 0;
  7381. }
  7382. static PyObject *__pyx_getprop_3zmq_4core_6socket_6Socket_socket_type(PyObject *o, void *x) {
  7383. return __pyx_pf_3zmq_4core_6socket_6Socket_11socket_type___get__(o);
  7384. }
  7385. static int __pyx_setprop_3zmq_4core_6socket_6Socket_socket_type(PyObject *o, PyObject *v, void *x) {
  7386. if (v) {
  7387. return __pyx_pf_3zmq_4core_6socket_6Socket_11socket_type_1__set__(o, v);
  7388. }
  7389. else {
  7390. PyErr_SetString(PyExc_NotImplementedError, "__del__");
  7391. return -1;
  7392. }
  7393. }
  7394. static PyObject *__pyx_getprop_3zmq_4core_6socket_6Socket_context(PyObject *o, void *x) {
  7395. return __pyx_pf_3zmq_4core_6socket_6Socket_7context___get__(o);
  7396. }
  7397. static int __pyx_setprop_3zmq_4core_6socket_6Socket_context(PyObject *o, PyObject *v, void *x) {
  7398. if (v) {
  7399. return __pyx_pf_3zmq_4core_6socket_6Socket_7context_1__set__(o, v);
  7400. }
  7401. else {
  7402. return __pyx_pf_3zmq_4core_6socket_6Socket_7context_2__del__(o);
  7403. }
  7404. }
  7405. static PyObject *__pyx_getprop_3zmq_4core_6socket_6Socket_closed(PyObject *o, void *x) {
  7406. return __pyx_pf_3zmq_4core_6socket_6Socket_6closed___get__(o);
  7407. }
  7408. static int __pyx_setprop_3zmq_4core_6socket_6Socket_closed(PyObject *o, PyObject *v, void *x) {
  7409. if (v) {
  7410. return __pyx_pf_3zmq_4core_6socket_6Socket_6closed_1__set__(o, v);
  7411. }
  7412. else {
  7413. return __pyx_pf_3zmq_4core_6socket_6Socket_6closed_2__del__(o);
  7414. }
  7415. }
  7416. static PyMethodDef __pyx_methods_3zmq_4core_6socket_Socket[] = {
  7417. {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_2close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_2close)},
  7418. {__Pyx_NAMESTR("setsockopt"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_3setsockopt, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_3setsockopt)},
  7419. {__Pyx_NAMESTR("getsockopt"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_4getsockopt, METH_O, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_4getsockopt)},
  7420. {__Pyx_NAMESTR("setsockopt_unicode"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_5setsockopt_unicode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_5setsockopt_unicode)},
  7421. {__Pyx_NAMESTR("getsockopt_unicode"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_6getsockopt_unicode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_6getsockopt_unicode)},
  7422. {__Pyx_NAMESTR("bind"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_7bind, METH_O, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_7bind)},
  7423. {__Pyx_NAMESTR("bind_to_random_port"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_8bind_to_random_port, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_8bind_to_random_port)},
  7424. {__Pyx_NAMESTR("connect"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_9connect, METH_O, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_9connect)},
  7425. {__Pyx_NAMESTR("send"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_10send, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_10send)},
  7426. {__Pyx_NAMESTR("recv"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_11recv, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_11recv)},
  7427. {__Pyx_NAMESTR("send_multipart"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_12send_multipart, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_12send_multipart)},
  7428. {__Pyx_NAMESTR("recv_multipart"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_13recv_multipart, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_13recv_multipart)},
  7429. {__Pyx_NAMESTR("rcvmore"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_14rcvmore, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_14rcvmore)},
  7430. {__Pyx_NAMESTR("send_unicode"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_15send_unicode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_15send_unicode)},
  7431. {__Pyx_NAMESTR("recv_unicode"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_16recv_unicode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_16recv_unicode)},
  7432. {__Pyx_NAMESTR("send_pyobj"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_17send_pyobj, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_17send_pyobj)},
  7433. {__Pyx_NAMESTR("recv_pyobj"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_18recv_pyobj, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_18recv_pyobj)},
  7434. {__Pyx_NAMESTR("send_json"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_19send_json, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_19send_json)},
  7435. {__Pyx_NAMESTR("recv_json"), (PyCFunction)__pyx_pf_3zmq_4core_6socket_6Socket_20recv_json, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3zmq_4core_6socket_6Socket_20recv_json)},
  7436. {0, 0, 0, 0}
  7437. };
  7438. static struct PyGetSetDef __pyx_getsets_3zmq_4core_6socket_Socket[] = {
  7439. {(char *)"socket_type", __pyx_getprop_3zmq_4core_6socket_6Socket_socket_type, __pyx_setprop_3zmq_4core_6socket_6Socket_socket_type, 0, 0},
  7440. {(char *)"context", __pyx_getprop_3zmq_4core_6socket_6Socket_context, __pyx_setprop_3zmq_4core_6socket_6Socket_context, 0, 0},
  7441. {(char *)"closed", __pyx_getprop_3zmq_4core_6socket_6Socket_closed, __pyx_setprop_3zmq_4core_6socket_6Socket_closed, 0, 0},
  7442. {0, 0, 0, 0, 0}
  7443. };
  7444. static PyNumberMethods __pyx_tp_as_number_Socket = {
  7445. 0, /*nb_add*/
  7446. 0, /*nb_subtract*/
  7447. 0, /*nb_multiply*/
  7448. #if PY_MAJOR_VERSION < 3
  7449. 0, /*nb_divide*/
  7450. #endif
  7451. 0, /*nb_remainder*/
  7452. 0, /*nb_divmod*/
  7453. 0, /*nb_power*/
  7454. 0, /*nb_negative*/
  7455. 0, /*nb_positive*/
  7456. 0, /*nb_absolute*/
  7457. 0, /*nb_nonzero*/
  7458. 0, /*nb_invert*/
  7459. 0, /*nb_lshift*/
  7460. 0, /*nb_rshift*/
  7461. 0, /*nb_and*/
  7462. 0, /*nb_xor*/
  7463. 0, /*nb_or*/
  7464. #if PY_MAJOR_VERSION < 3
  7465. 0, /*nb_coerce*/
  7466. #endif
  7467. 0, /*nb_int*/
  7468. #if PY_MAJOR_VERSION < 3
  7469. 0, /*nb_long*/
  7470. #else
  7471. 0, /*reserved*/
  7472. #endif
  7473. 0, /*nb_float*/
  7474. #if PY_MAJOR_VERSION < 3
  7475. 0, /*nb_oct*/
  7476. #endif
  7477. #if PY_MAJOR_VERSION < 3
  7478. 0, /*nb_hex*/
  7479. #endif
  7480. 0, /*nb_inplace_add*/
  7481. 0, /*nb_inplace_subtract*/
  7482. 0, /*nb_inplace_multiply*/
  7483. #if PY_MAJOR_VERSION < 3
  7484. 0, /*nb_inplace_divide*/
  7485. #endif
  7486. 0, /*nb_inplace_remainder*/
  7487. 0, /*nb_inplace_power*/
  7488. 0, /*nb_inplace_lshift*/
  7489. 0, /*nb_inplace_rshift*/
  7490. 0, /*nb_inplace_and*/
  7491. 0, /*nb_inplace_xor*/
  7492. 0, /*nb_inplace_or*/
  7493. 0, /*nb_floor_divide*/
  7494. 0, /*nb_true_divide*/
  7495. 0, /*nb_inplace_floor_divide*/
  7496. 0, /*nb_inplace_true_divide*/
  7497. #if PY_VERSION_HEX >= 0x02050000
  7498. 0, /*nb_index*/
  7499. #endif
  7500. };
  7501. static PySequenceMethods __pyx_tp_as_sequence_Socket = {
  7502. 0, /*sq_length*/
  7503. 0, /*sq_concat*/
  7504. 0, /*sq_repeat*/
  7505. 0, /*sq_item*/
  7506. 0, /*sq_slice*/
  7507. 0, /*sq_ass_item*/
  7508. 0, /*sq_ass_slice*/
  7509. 0, /*sq_contains*/
  7510. 0, /*sq_inplace_concat*/
  7511. 0, /*sq_inplace_repeat*/
  7512. };
  7513. static PyMappingMethods __pyx_tp_as_mapping_Socket = {
  7514. 0, /*mp_length*/
  7515. 0, /*mp_subscript*/
  7516. 0, /*mp_ass_subscript*/
  7517. };
  7518. static PyBufferProcs __pyx_tp_as_buffer_Socket = {
  7519. #if PY_MAJOR_VERSION < 3
  7520. 0, /*bf_getreadbuffer*/
  7521. #endif
  7522. #if PY_MAJOR_VERSION < 3
  7523. 0, /*bf_getwritebuffer*/
  7524. #endif
  7525. #if PY_MAJOR_VERSION < 3
  7526. 0, /*bf_getsegcount*/
  7527. #endif
  7528. #if PY_MAJOR_VERSION < 3
  7529. 0, /*bf_getcharbuffer*/
  7530. #endif
  7531. #if PY_VERSION_HEX >= 0x02060000
  7532. 0, /*bf_getbuffer*/
  7533. #endif
  7534. #if PY_VERSION_HEX >= 0x02060000
  7535. 0, /*bf_releasebuffer*/
  7536. #endif
  7537. };
  7538. static PyTypeObject __pyx_type_3zmq_4core_6socket_Socket = {
  7539. PyVarObject_HEAD_INIT(0, 0)
  7540. __Pyx_NAMESTR("zmq.core.socket.Socket"), /*tp_name*/
  7541. sizeof(struct __pyx_obj_3zmq_4core_6socket_Socket), /*tp_basicsize*/
  7542. 0, /*tp_itemsize*/
  7543. __pyx_tp_dealloc_3zmq_4core_6socket_Socket, /*tp_dealloc*/
  7544. 0, /*tp_print*/
  7545. 0, /*tp_getattr*/
  7546. 0, /*tp_setattr*/
  7547. #if PY_MAJOR_VERSION < 3
  7548. 0, /*tp_compare*/
  7549. #else
  7550. 0, /*reserved*/
  7551. #endif
  7552. 0, /*tp_repr*/
  7553. &__pyx_tp_as_number_Socket, /*tp_as_number*/
  7554. &__pyx_tp_as_sequence_Socket, /*tp_as_sequence*/
  7555. &__pyx_tp_as_mapping_Socket, /*tp_as_mapping*/
  7556. 0, /*tp_hash*/
  7557. 0, /*tp_call*/
  7558. 0, /*tp_str*/
  7559. 0, /*tp_getattro*/
  7560. 0, /*tp_setattro*/
  7561. &__pyx_tp_as_buffer_Socket, /*tp_as_buffer*/
  7562. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  7563. __Pyx_DOCSTR("Socket(context, socket_type)\n\n A 0MQ socket.\n\n These objects will generally be constructed via the socket() method of a Context object.\n \n Parameters\n ----------\n context : Context\n The 0MQ Context this Socket belongs to.\n socket_type : int\n The socket type, which can be any of the 0MQ socket types: \n REQ, REP, PUB, SUB, PAIR, XREQ, XREP, PULL, PUSH, XPUB, XSUB.\n \n See Also\n --------\n .Context.socket : method for creating a socket bound to a Context.\n "), /*tp_doc*/
  7564. __pyx_tp_traverse_3zmq_4core_6socket_Socket, /*tp_traverse*/
  7565. __pyx_tp_clear_3zmq_4core_6socket_Socket, /*tp_clear*/
  7566. 0, /*tp_richcompare*/
  7567. 0, /*tp_weaklistoffset*/
  7568. 0, /*tp_iter*/
  7569. 0, /*tp_iternext*/
  7570. __pyx_methods_3zmq_4core_6socket_Socket, /*tp_methods*/
  7571. 0, /*tp_members*/
  7572. __pyx_getsets_3zmq_4core_6socket_Socket, /*tp_getset*/
  7573. 0, /*tp_base*/
  7574. 0, /*tp_dict*/
  7575. 0, /*tp_descr_get*/
  7576. 0, /*tp_descr_set*/
  7577. 0, /*tp_dictoffset*/
  7578. 0, /*tp_init*/
  7579. 0, /*tp_alloc*/
  7580. __pyx_tp_new_3zmq_4core_6socket_Socket, /*tp_new*/
  7581. 0, /*tp_free*/
  7582. 0, /*tp_is_gc*/
  7583. 0, /*tp_bases*/
  7584. 0, /*tp_mro*/
  7585. 0, /*tp_cache*/
  7586. 0, /*tp_subclasses*/
  7587. 0, /*tp_weaklist*/
  7588. 0, /*tp_del*/
  7589. #if PY_VERSION_HEX >= 0x02060000
  7590. 0, /*tp_version_tag*/
  7591. #endif
  7592. };
  7593. static PyMethodDef __pyx_methods[] = {
  7594. {0, 0, 0, 0}
  7595. };
  7596. char* __pyx_import_star_type_names[] = {
  7597. "__pyx_opt_args_3zmq_4core_6socket__send_copy",
  7598. "Socket",
  7599. "__pyx_opt_args_3zmq_4core_6socket_6Socket_send",
  7600. "const_void_ptr",
  7601. "zmq_pollitem_t",
  7602. "Message",
  7603. "zmq_free_fn",
  7604. "__pyx_opt_args_3zmq_4core_6socket__recv_message",
  7605. "zmq_msg_t",
  7606. "int64_t",
  7607. "__pyx_opt_args_3zmq_4core_6socket_6Socket_recv",
  7608. "__pyx_opt_args_3zmq_4core_6socket__recv_copy",
  7609. "__pyx_opt_args_3zmq_4core_6socket__send_message",
  7610. "Py_ssize_t",
  7611. 0
  7612. };
  7613. static int __pyx_import_star_set(PyObject *o, PyObject* py_name, char *name) {
  7614. char** type_name = __pyx_import_star_type_names;
  7615. while (*type_name) {
  7616. if (__Pyx_StrEq(name, *type_name)) {
  7617. PyErr_Format(PyExc_TypeError, "Cannot overwrite C type %s", name);
  7618. goto bad;
  7619. }
  7620. type_name++;
  7621. }
  7622. if (0);
  7623. else {
  7624. if (PyObject_SetAttr(__pyx_m, py_name, o) < 0) goto bad;
  7625. }
  7626. return 0;
  7627. bad:
  7628. return -1;
  7629. }
  7630. /* import_all_from is an unexposed function from ceval.c */
  7631. static int
  7632. __Pyx_import_all_from(PyObject *locals, PyObject *v)
  7633. {
  7634. PyObject *all = __Pyx_GetAttrString(v, "__all__");
  7635. PyObject *dict, *name, *value;
  7636. int skip_leading_underscores = 0;
  7637. int pos, err;
  7638. if (all == NULL) {
  7639. if (!PyErr_ExceptionMatches(PyExc_AttributeError))
  7640. return -1; /* Unexpected error */
  7641. PyErr_Clear();
  7642. dict = __Pyx_GetAttrString(v, "__dict__");
  7643. if (dict == NULL) {
  7644. if (!PyErr_ExceptionMatches(PyExc_AttributeError))
  7645. return -1;
  7646. PyErr_SetString(PyExc_ImportError,
  7647. "from-import-* object has no __dict__ and no __all__");
  7648. return -1;
  7649. }
  7650. all = PyMapping_Keys(dict);
  7651. Py_DECREF(dict);
  7652. if (all == NULL)
  7653. return -1;
  7654. skip_leading_underscores = 1;
  7655. }
  7656. for (pos = 0, err = 0; ; pos++) {
  7657. name = PySequence_GetItem(all, pos);
  7658. if (name == NULL) {
  7659. if (!PyErr_ExceptionMatches(PyExc_IndexError))
  7660. err = -1;
  7661. else
  7662. PyErr_Clear();
  7663. break;
  7664. }
  7665. if (skip_leading_underscores &&
  7666. #if PY_MAJOR_VERSION < 3
  7667. PyString_Check(name) &&
  7668. PyString_AS_STRING(name)[0] == '_')
  7669. #else
  7670. PyUnicode_Check(name) &&
  7671. PyUnicode_AS_UNICODE(name)[0] == '_')
  7672. #endif
  7673. {
  7674. Py_DECREF(name);
  7675. continue;
  7676. }
  7677. value = PyObject_GetAttr(v, name);
  7678. if (value == NULL)
  7679. err = -1;
  7680. else if (PyDict_CheckExact(locals))
  7681. err = PyDict_SetItem(locals, name, value);
  7682. else
  7683. err = PyObject_SetItem(locals, name, value);
  7684. Py_DECREF(name);
  7685. Py_XDECREF(value);
  7686. if (err != 0)
  7687. break;
  7688. }
  7689. Py_DECREF(all);
  7690. return err;
  7691. }
  7692. static int __pyx_import_star(PyObject* m) {
  7693. int i;
  7694. int ret = -1;
  7695. char* s;
  7696. PyObject *locals = 0;
  7697. PyObject *list = 0;
  7698. #if PY_MAJOR_VERSION >= 3
  7699. PyObject *utf8_name = 0;
  7700. #endif
  7701. PyObject *name;
  7702. PyObject *item;
  7703. locals = PyDict_New(); if (!locals) goto bad;
  7704. if (__Pyx_import_all_from(locals, m) < 0) goto bad;
  7705. list = PyDict_Items(locals); if (!list) goto bad;
  7706. for(i=0; i<PyList_GET_SIZE(list); i++) {
  7707. name = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 0);
  7708. item = PyTuple_GET_ITEM(PyList_GET_ITEM(list, i), 1);
  7709. #if PY_MAJOR_VERSION >= 3
  7710. utf8_name = PyUnicode_AsUTF8String(name);
  7711. if (!utf8_name) goto bad;
  7712. s = PyBytes_AS_STRING(utf8_name);
  7713. if (__pyx_import_star_set(item, name, s) < 0) goto bad;
  7714. Py_DECREF(utf8_name); utf8_name = 0;
  7715. #else
  7716. s = PyString_AsString(name);
  7717. if (!s) goto bad;
  7718. if (__pyx_import_star_set(item, name, s) < 0) goto bad;
  7719. #endif
  7720. }
  7721. ret = 0;
  7722. bad:
  7723. Py_XDECREF(locals);
  7724. Py_XDECREF(list);
  7725. #if PY_MAJOR_VERSION >= 3
  7726. Py_XDECREF(utf8_name);
  7727. #endif
  7728. return ret;
  7729. }
  7730. #if PY_MAJOR_VERSION >= 3
  7731. static struct PyModuleDef __pyx_moduledef = {
  7732. PyModuleDef_HEAD_INIT,
  7733. __Pyx_NAMESTR("socket"),
  7734. __Pyx_DOCSTR(__pyx_k_39), /* m_doc */
  7735. -1, /* m_size */
  7736. __pyx_methods /* m_methods */,
  7737. NULL, /* m_reload */
  7738. NULL, /* m_traverse */
  7739. NULL, /* m_clear */
  7740. NULL /* m_free */
  7741. };
  7742. #endif
  7743. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  7744. {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
  7745. {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
  7746. {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
  7747. {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
  7748. {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  7749. {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
  7750. {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0},
  7751. {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0},
  7752. {&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0},
  7753. {&__pyx_kp_s_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 0, 1, 0},
  7754. {&__pyx_kp_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 0},
  7755. {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  7756. {&__pyx_n_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 1},
  7757. {&__pyx_n_s_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 1, 1},
  7758. {&__pyx_n_s_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 0, 1, 1},
  7759. {&__pyx_n_s_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 1, 1},
  7760. {&__pyx_n_s_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 1},
  7761. {&__pyx_n_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 1},
  7762. {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  7763. {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  7764. {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  7765. {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
  7766. {&__pyx_n_s__AttributeError, __pyx_k__AttributeError, sizeof(__pyx_k__AttributeError), 0, 0, 1, 1},
  7767. {&__pyx_n_s__B, __pyx_k__B, sizeof(__pyx_k__B), 0, 0, 1, 1},
  7768. {&__pyx_n_s__EINVAL, __pyx_k__EINVAL, sizeof(__pyx_k__EINVAL), 0, 0, 1, 1},
  7769. {&__pyx_n_s__ENOTSUP, __pyx_k__ENOTSUP, sizeof(__pyx_k__ENOTSUP), 0, 0, 1, 1},
  7770. {&__pyx_n_s__IDENTITY, __pyx_k__IDENTITY, sizeof(__pyx_k__IDENTITY), 0, 0, 1, 1},
  7771. {&__pyx_n_s__ImportError, __pyx_k__ImportError, sizeof(__pyx_k__ImportError), 0, 0, 1, 1},
  7772. {&__pyx_n_s__NotImplementedError, __pyx_k__NotImplementedError, sizeof(__pyx_k__NotImplementedError), 0, 0, 1, 1},
  7773. {&__pyx_n_s__RCVMORE, __pyx_k__RCVMORE, sizeof(__pyx_k__RCVMORE), 0, 0, 1, 1},
  7774. {&__pyx_n_s__SNDMORE, __pyx_k__SNDMORE, sizeof(__pyx_k__SNDMORE), 0, 0, 1, 1},
  7775. {&__pyx_n_s__Socket, __pyx_k__Socket, sizeof(__pyx_k__Socket), 0, 0, 1, 1},
  7776. {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
  7777. {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  7778. {&__pyx_n_s__ZMQBindError, __pyx_k__ZMQBindError, sizeof(__pyx_k__ZMQBindError), 0, 0, 1, 1},
  7779. {&__pyx_n_s__ZMQError, __pyx_k__ZMQError, sizeof(__pyx_k__ZMQError), 0, 0, 1, 1},
  7780. {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
  7781. {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  7782. {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  7783. {&__pyx_n_s___handle, __pyx_k___handle, sizeof(__pyx_k___handle), 0, 0, 1, 1},
  7784. {&__pyx_n_s__addr, __pyx_k__addr, sizeof(__pyx_k__addr), 0, 0, 1, 1},
  7785. {&__pyx_n_s__append, __pyx_k__append, sizeof(__pyx_k__append), 0, 0, 1, 1},
  7786. {&__pyx_n_s__basestring, __pyx_k__basestring, sizeof(__pyx_k__basestring), 0, 0, 1, 1},
  7787. {&__pyx_n_s__bind, __pyx_k__bind, sizeof(__pyx_k__bind), 0, 0, 1, 1},
  7788. {&__pyx_n_s__buf, __pyx_k__buf, sizeof(__pyx_k__buf), 0, 0, 1, 1},
  7789. {&__pyx_n_s__buffer, __pyx_k__buffer, sizeof(__pyx_k__buffer), 0, 0, 1, 1},
  7790. {&__pyx_n_s__bytes, __pyx_k__bytes, sizeof(__pyx_k__bytes), 0, 0, 1, 1},
  7791. {&__pyx_n_s__bytes_sockopts, __pyx_k__bytes_sockopts, sizeof(__pyx_k__bytes_sockopts), 0, 0, 1, 1},
  7792. {&__pyx_n_s__cPickle, __pyx_k__cPickle, sizeof(__pyx_k__cPickle), 0, 0, 1, 1},
  7793. {&__pyx_n_s__char, __pyx_k__char, sizeof(__pyx_k__char), 0, 0, 1, 1},
  7794. {&__pyx_n_s__close, __pyx_k__close, sizeof(__pyx_k__close), 0, 0, 1, 1},
  7795. {&__pyx_n_s__closed, __pyx_k__closed, sizeof(__pyx_k__closed), 0, 0, 1, 1},
  7796. {&__pyx_n_s__codecs, __pyx_k__codecs, sizeof(__pyx_k__codecs), 0, 0, 1, 1},
  7797. {&__pyx_n_s__constants, __pyx_k__constants, sizeof(__pyx_k__constants), 0, 0, 1, 1},
  7798. {&__pyx_n_s__context, __pyx_k__context, sizeof(__pyx_k__context), 0, 0, 1, 1},
  7799. {&__pyx_n_s__copy, __pyx_k__copy, sizeof(__pyx_k__copy), 0, 0, 1, 1},
  7800. {&__pyx_n_s__copy_mod, __pyx_k__copy_mod, sizeof(__pyx_k__copy_mod), 0, 0, 1, 1},
  7801. {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
  7802. {&__pyx_n_s__decode, __pyx_k__decode, sizeof(__pyx_k__decode), 0, 0, 1, 1},
  7803. {&__pyx_n_s__dtype, __pyx_k__dtype, sizeof(__pyx_k__dtype), 0, 0, 1, 1},
  7804. {&__pyx_n_s__dumps, __pyx_k__dumps, sizeof(__pyx_k__dumps), 0, 0, 1, 1},
  7805. {&__pyx_n_s__encode, __pyx_k__encode, sizeof(__pyx_k__encode), 0, 0, 1, 1},
  7806. {&__pyx_n_s__encoding, __pyx_k__encoding, sizeof(__pyx_k__encoding), 0, 0, 1, 1},
  7807. {&__pyx_n_s__fast_copy, __pyx_k__fast_copy, sizeof(__pyx_k__fast_copy), 0, 0, 1, 1},
  7808. {&__pyx_n_s__flags, __pyx_k__flags, sizeof(__pyx_k__flags), 0, 0, 1, 1},
  7809. {&__pyx_n_s__format, __pyx_k__format, sizeof(__pyx_k__format), 0, 0, 1, 1},
  7810. {&__pyx_n_s__getsockopt, __pyx_k__getsockopt, sizeof(__pyx_k__getsockopt), 0, 0, 1, 1},
  7811. {&__pyx_n_s__handle, __pyx_k__handle, sizeof(__pyx_k__handle), 0, 0, 1, 1},
  7812. {&__pyx_n_s__int64_sockopts, __pyx_k__int64_sockopts, sizeof(__pyx_k__int64_sockopts), 0, 0, 1, 1},
  7813. {&__pyx_n_s__int_sockopts, __pyx_k__int_sockopts, sizeof(__pyx_k__int_sockopts), 0, 0, 1, 1},
  7814. {&__pyx_n_s__itemsize, __pyx_k__itemsize, sizeof(__pyx_k__itemsize), 0, 0, 1, 1},
  7815. {&__pyx_n_s__jsonapi, __pyx_k__jsonapi, sizeof(__pyx_k__jsonapi), 0, 0, 1, 1},
  7816. {&__pyx_n_s__jsonmod, __pyx_k__jsonmod, sizeof(__pyx_k__jsonmod), 0, 0, 1, 1},
  7817. {&__pyx_n_s__len, __pyx_k__len, sizeof(__pyx_k__len), 0, 0, 1, 1},
  7818. {&__pyx_n_s__loads, __pyx_k__loads, sizeof(__pyx_k__loads), 0, 0, 1, 1},
  7819. {&__pyx_n_s__max_port, __pyx_k__max_port, sizeof(__pyx_k__max_port), 0, 0, 1, 1},
  7820. {&__pyx_n_s__max_tries, __pyx_k__max_tries, sizeof(__pyx_k__max_tries), 0, 0, 1, 1},
  7821. {&__pyx_n_s__min_port, __pyx_k__min_port, sizeof(__pyx_k__min_port), 0, 0, 1, 1},
  7822. {&__pyx_n_s__msg_parts, __pyx_k__msg_parts, sizeof(__pyx_k__msg_parts), 0, 0, 1, 1},
  7823. {&__pyx_n_s__obj, __pyx_k__obj, sizeof(__pyx_k__obj), 0, 0, 1, 1},
  7824. {&__pyx_n_s__option, __pyx_k__option, sizeof(__pyx_k__option), 0, 0, 1, 1},
  7825. {&__pyx_n_s__optval, __pyx_k__optval, sizeof(__pyx_k__optval), 0, 0, 1, 1},
  7826. {&__pyx_n_s__pickle, __pyx_k__pickle, sizeof(__pyx_k__pickle), 0, 0, 1, 1},
  7827. {&__pyx_n_s__protocol, __pyx_k__protocol, sizeof(__pyx_k__protocol), 0, 0, 1, 1},
  7828. {&__pyx_n_s__random, __pyx_k__random, sizeof(__pyx_k__random), 0, 0, 1, 1},
  7829. {&__pyx_n_s__randrange, __pyx_k__randrange, sizeof(__pyx_k__randrange), 0, 0, 1, 1},
  7830. {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
  7831. {&__pyx_n_s__rcvmore, __pyx_k__rcvmore, sizeof(__pyx_k__rcvmore), 0, 0, 1, 1},
  7832. {&__pyx_n_s__recv, __pyx_k__recv, sizeof(__pyx_k__recv), 0, 0, 1, 1},
  7833. {&__pyx_n_s__send, __pyx_k__send, sizeof(__pyx_k__send), 0, 0, 1, 1},
  7834. {&__pyx_n_s__setsockopt, __pyx_k__setsockopt, sizeof(__pyx_k__setsockopt), 0, 0, 1, 1},
  7835. {&__pyx_n_s__shape, __pyx_k__shape, sizeof(__pyx_k__shape), 0, 0, 1, 1},
  7836. {&__pyx_n_s__socket_type, __pyx_k__socket_type, sizeof(__pyx_k__socket_type), 0, 0, 1, 1},
  7837. {&__pyx_n_s__struct, __pyx_k__struct, sizeof(__pyx_k__struct), 0, 0, 1, 1},
  7838. {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
  7839. {&__pyx_n_s__time, __pyx_k__time, sizeof(__pyx_k__time), 0, 0, 1, 1},
  7840. {&__pyx_n_s__track, __pyx_k__track, sizeof(__pyx_k__track), 0, 0, 1, 1},
  7841. {&__pyx_n_s__tracker, __pyx_k__tracker, sizeof(__pyx_k__tracker), 0, 0, 1, 1},
  7842. {&__pyx_n_s__typecode, __pyx_k__typecode, sizeof(__pyx_k__typecode), 0, 0, 1, 1},
  7843. {&__pyx_n_s__u, __pyx_k__u, sizeof(__pyx_k__u), 0, 0, 1, 1},
  7844. {&__pyx_n_s__unicode, __pyx_k__unicode, sizeof(__pyx_k__unicode), 0, 0, 1, 1},
  7845. {&__pyx_n_s__xrange, __pyx_k__xrange, sizeof(__pyx_k__xrange), 0, 0, 1, 1},
  7846. {&__pyx_n_s__zmq_msg, __pyx_k__zmq_msg, sizeof(__pyx_k__zmq_msg), 0, 0, 1, 1},
  7847. {0, 0, 0, 0, 0, 0, 0}
  7848. };
  7849. static int __Pyx_InitCachedBuiltins(void) {
  7850. __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7851. #if PY_MAJOR_VERSION >= 3
  7852. __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7853. #else
  7854. __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7855. #endif
  7856. __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7857. __pyx_builtin_ImportError = __Pyx_GetName(__pyx_b, __pyx_n_s__ImportError); if (!__pyx_builtin_ImportError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7858. __pyx_builtin_AttributeError = __Pyx_GetName(__pyx_b, __pyx_n_s__AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7859. __pyx_builtin_NotImplementedError = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7860. return 0;
  7861. __pyx_L1_error:;
  7862. return -1;
  7863. }
  7864. static int __Pyx_InitCachedConstants(void) {
  7865. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");
  7866. /* "zmq/core/socket.pyx":229
  7867. * _check_closed(self)
  7868. * if isinstance(optval, unicode):
  7869. * raise TypeError("unicode not allowed, use setsockopt_unicode") # <<<<<<<<<<<<<<
  7870. *
  7871. * if option in constants.bytes_sockopts:
  7872. */
  7873. __pyx_k_tuple_3 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7874. __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_3));
  7875. __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
  7876. PyTuple_SET_ITEM(__pyx_k_tuple_3, 0, ((PyObject *)__pyx_kp_s_2));
  7877. __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
  7878. __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_3));
  7879. /* "zmq/core/socket.pyx":337
  7880. * """
  7881. * if not isinstance(optval, unicode):
  7882. * raise TypeError("unicode strings only") # <<<<<<<<<<<<<<
  7883. * return self.setsockopt(option, optval.encode(encoding))
  7884. *
  7885. */
  7886. __pyx_k_tuple_8 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7887. __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_8));
  7888. __Pyx_INCREF(((PyObject *)__pyx_kp_s_7));
  7889. PyTuple_SET_ITEM(__pyx_k_tuple_8, 0, ((PyObject *)__pyx_kp_s_7));
  7890. __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_7));
  7891. __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8));
  7892. /* "zmq/core/socket.pyx":384
  7893. * _check_closed(self)
  7894. * if isinstance(addr, unicode):
  7895. * addr = addr.encode('utf-8') # <<<<<<<<<<<<<<
  7896. * if not isinstance(addr, bytes):
  7897. * raise TypeError('expected str, got: %r' % addr)
  7898. */
  7899. __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7900. __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_10));
  7901. __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
  7902. PyTuple_SET_ITEM(__pyx_k_tuple_10, 0, ((PyObject *)__pyx_kp_s_6));
  7903. __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
  7904. __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10));
  7905. /* "zmq/core/socket.pyx":426
  7906. * else:
  7907. * return port
  7908. * raise ZMQBindError("Could not bind socket to random port.") # <<<<<<<<<<<<<<
  7909. *
  7910. * def connect(self, addr):
  7911. */
  7912. __pyx_k_tuple_13 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7913. __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_13));
  7914. __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
  7915. PyTuple_SET_ITEM(__pyx_k_tuple_13, 0, ((PyObject *)__pyx_kp_s_12));
  7916. __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
  7917. __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_13));
  7918. /* "zmq/core/socket.pyx":445
  7919. * _check_closed(self)
  7920. * if isinstance(addr, unicode):
  7921. * addr = addr.encode('utf-8') # <<<<<<<<<<<<<<
  7922. * if not isinstance(addr, bytes):
  7923. * raise TypeError('expected str, got: %r' % addr)
  7924. */
  7925. __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7926. __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_14));
  7927. __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
  7928. PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, ((PyObject *)__pyx_kp_s_6));
  7929. __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
  7930. __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14));
  7931. /* "zmq/core/socket.pyx":497
  7932. *
  7933. * if isinstance(data, unicode):
  7934. * raise TypeError("unicode not allowed, use send_unicode") # <<<<<<<<<<<<<<
  7935. *
  7936. * if copy:
  7937. */
  7938. __pyx_k_tuple_18 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7939. __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_18));
  7940. __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
  7941. PyTuple_SET_ITEM(__pyx_k_tuple_18, 0, ((PyObject *)__pyx_kp_s_17));
  7942. __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
  7943. __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_18));
  7944. /* "zmq/core/socket.pyx":508
  7945. * if isinstance(data, Message):
  7946. * if track and not data.tracker:
  7947. * raise ValueError('Not a tracked message') # <<<<<<<<<<<<<<
  7948. * msg = data
  7949. * else:
  7950. */
  7951. __pyx_k_tuple_20 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7952. __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_20));
  7953. __Pyx_INCREF(((PyObject *)__pyx_kp_s_19));
  7954. PyTuple_SET_ITEM(__pyx_k_tuple_20, 0, ((PyObject *)__pyx_kp_s_19));
  7955. __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19));
  7956. __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_20));
  7957. /* "zmq/core/socket.pyx":647
  7958. * """
  7959. * if not isinstance(u, basestring):
  7960. * raise TypeError("unicode/str objects only") # <<<<<<<<<<<<<<
  7961. * return self.send(u.encode(encoding), flags=flags, copy=copy)
  7962. *
  7963. */
  7964. __pyx_k_tuple_29 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7965. __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_29));
  7966. __Pyx_INCREF(((PyObject *)__pyx_kp_s_28));
  7967. PyTuple_SET_ITEM(__pyx_k_tuple_29, 0, ((PyObject *)__pyx_kp_s_28));
  7968. __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_28));
  7969. __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_29));
  7970. /* "zmq/core/socket.pyx":720
  7971. * """
  7972. * if jsonapi.jsonmod is None:
  7973. * raise ImportError('jsonlib{1,2}, json or simplejson library is required.') # <<<<<<<<<<<<<<
  7974. * else:
  7975. * msg = jsonapi.dumps(obj)
  7976. */
  7977. __pyx_k_tuple_31 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7978. __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_31));
  7979. __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
  7980. PyTuple_SET_ITEM(__pyx_k_tuple_31, 0, ((PyObject *)__pyx_kp_s_30));
  7981. __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
  7982. __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_31));
  7983. /* "zmq/core/socket.pyx":741
  7984. * """
  7985. * if jsonapi.jsonmod is None:
  7986. * raise ImportError('jsonlib{1,2}, json or simplejson library is required.') # <<<<<<<<<<<<<<
  7987. * else:
  7988. * msg = self.recv(flags)
  7989. */
  7990. __pyx_k_tuple_32 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  7991. __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_32));
  7992. __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
  7993. PyTuple_SET_ITEM(__pyx_k_tuple_32, 0, ((PyObject *)__pyx_kp_s_30));
  7994. __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
  7995. __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_32));
  7996. /* "buffers.pxd":213
  7997. * return PyMemoryView_FromBuffer(&pybuf)
  7998. * else:
  7999. * raise NotImplementedError("New style buffers not available.") # <<<<<<<<<<<<<<
  8000. *
  8001. *
  8002. */
  8003. __pyx_k_tuple_36 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_36)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8004. __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_36));
  8005. __Pyx_INCREF(((PyObject *)__pyx_kp_s_35));
  8006. PyTuple_SET_ITEM(__pyx_k_tuple_36, 0, ((PyObject *)__pyx_kp_s_35));
  8007. __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_35));
  8008. __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_36));
  8009. /* "buffers.pxd":228
  8010. * return PyBuffer_FromReadWriteMemory(ptr, s)
  8011. * else:
  8012. * raise NotImplementedError("Old style buffers not available.") # <<<<<<<<<<<<<<
  8013. *
  8014. *
  8015. */
  8016. __pyx_k_tuple_38 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_38)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8017. __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_38));
  8018. __Pyx_INCREF(((PyObject *)__pyx_kp_s_37));
  8019. PyTuple_SET_ITEM(__pyx_k_tuple_38, 0, ((PyObject *)__pyx_kp_s_37));
  8020. __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_37));
  8021. __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_38));
  8022. __Pyx_RefNannyFinishContext();
  8023. return 0;
  8024. __pyx_L1_error:;
  8025. __Pyx_RefNannyFinishContext();
  8026. return -1;
  8027. }
  8028. static int __Pyx_InitGlobals(void) {
  8029. if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  8030. __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;};
  8031. __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  8032. __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  8033. __pyx_int_49152 = PyInt_FromLong(49152); if (unlikely(!__pyx_int_49152)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  8034. __pyx_int_65536 = PyInt_FromLong(65536); if (unlikely(!__pyx_int_65536)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  8035. return 0;
  8036. __pyx_L1_error:;
  8037. return -1;
  8038. }
  8039. #if PY_MAJOR_VERSION < 3
  8040. PyMODINIT_FUNC initsocket(void); /*proto*/
  8041. PyMODINIT_FUNC initsocket(void)
  8042. #else
  8043. PyMODINIT_FUNC PyInit_socket(void); /*proto*/
  8044. PyMODINIT_FUNC PyInit_socket(void)
  8045. #endif
  8046. {
  8047. PyObject *__pyx_t_1 = NULL;
  8048. PyObject *__pyx_t_2 = NULL;
  8049. PyObject *__pyx_t_3 = NULL;
  8050. PyObject *__pyx_t_4 = NULL;
  8051. PyObject *__pyx_t_5 = NULL;
  8052. #if CYTHON_REFNANNY
  8053. void* __pyx_refnanny = NULL;
  8054. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  8055. if (!__Pyx_RefNanny) {
  8056. PyErr_Clear();
  8057. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  8058. if (!__Pyx_RefNanny)
  8059. Py_FatalError("failed to import 'refnanny' module");
  8060. }
  8061. __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_socket(void)", __LINE__, __FILE__);
  8062. #endif
  8063. __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;}
  8064. __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;}
  8065. #ifdef __pyx_binding_PyCFunctionType_USED
  8066. if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8067. #endif
  8068. /*--- Library function declarations ---*/
  8069. /*--- Threads initialization code ---*/
  8070. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  8071. #ifdef WITH_THREAD /* Python build with threading support? */
  8072. PyEval_InitThreads();
  8073. #endif
  8074. #endif
  8075. /*--- Module creation code ---*/
  8076. #if PY_MAJOR_VERSION < 3
  8077. __pyx_m = Py_InitModule4(__Pyx_NAMESTR("socket"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_39), 0, PYTHON_API_VERSION);
  8078. #else
  8079. __pyx_m = PyModule_Create(&__pyx_moduledef);
  8080. #endif
  8081. if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  8082. #if PY_MAJOR_VERSION < 3
  8083. Py_INCREF(__pyx_m);
  8084. #endif
  8085. __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  8086. if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  8087. if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  8088. /*--- Initialize various global constants etc. ---*/
  8089. if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8090. if (__pyx_module_is_main_zmq__core__socket) {
  8091. if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  8092. }
  8093. /*--- Builtin init code ---*/
  8094. if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8095. /*--- Constants init code ---*/
  8096. if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8097. /*--- Global init code ---*/
  8098. /*--- Function export code ---*/
  8099. /*--- Type init code ---*/
  8100. __pyx_vtabptr_3zmq_4core_6socket_Socket = &__pyx_vtable_3zmq_4core_6socket_Socket;
  8101. __pyx_vtable_3zmq_4core_6socket_Socket.send = (PyObject *(*)(struct __pyx_obj_3zmq_4core_6socket_Socket *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_send *__pyx_optional_args))__pyx_f_3zmq_4core_6socket_6Socket_send;
  8102. __pyx_vtable_3zmq_4core_6socket_Socket.recv = (PyObject *(*)(struct __pyx_obj_3zmq_4core_6socket_Socket *, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_4core_6socket_6Socket_recv *__pyx_optional_args))__pyx_f_3zmq_4core_6socket_6Socket_recv;
  8103. if (PyType_Ready(&__pyx_type_3zmq_4core_6socket_Socket) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8104. if (__Pyx_SetVtable(__pyx_type_3zmq_4core_6socket_Socket.tp_dict, __pyx_vtabptr_3zmq_4core_6socket_Socket) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8105. if (__Pyx_SetAttrString(__pyx_m, "Socket", (PyObject *)&__pyx_type_3zmq_4core_6socket_Socket) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8106. __pyx_ptype_3zmq_4core_6socket_Socket = &__pyx_type_3zmq_4core_6socket_Socket;
  8107. /*--- Type import code ---*/
  8108. __pyx_ptype_3zmq_4core_7message_MessageTracker = __Pyx_ImportType("zmq.core.message", "MessageTracker", sizeof(struct __pyx_obj_3zmq_4core_7message_MessageTracker), 1); if (unlikely(!__pyx_ptype_3zmq_4core_7message_MessageTracker)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8109. __pyx_ptype_3zmq_4core_7message_Message = __Pyx_ImportType("zmq.core.message", "Message", sizeof(struct __pyx_obj_3zmq_4core_7message_Message), 1); if (unlikely(!__pyx_ptype_3zmq_4core_7message_Message)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8110. __pyx_vtabptr_3zmq_4core_7message_Message = (struct __pyx_vtabstruct_3zmq_4core_7message_Message*)__Pyx_GetVtable(__pyx_ptype_3zmq_4core_7message_Message->tp_dict); if (unlikely(!__pyx_vtabptr_3zmq_4core_7message_Message)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8111. __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;}
  8112. __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;}
  8113. /*--- Function import code ---*/
  8114. __pyx_t_1 = __Pyx_ImportModule("zmq.core.message"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8115. if (__Pyx_ImportFunction(__pyx_t_1, "copy_zmq_msg_bytes", (void (**)(void))&__pyx_f_3zmq_4core_7message_copy_zmq_msg_bytes, "PyObject *(zmq_msg_t *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8116. Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  8117. /*--- Execution code ---*/
  8118. /* "zmq/core/socket.pyx":47
  8119. * #-----------------------------------------------------------------------------
  8120. *
  8121. * import copy as copy_mod # <<<<<<<<<<<<<<
  8122. * import time
  8123. * import sys
  8124. */
  8125. __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__copy), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8126. __Pyx_GOTREF(__pyx_t_2);
  8127. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__copy_mod, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8128. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8129. /* "zmq/core/socket.pyx":48
  8130. *
  8131. * import copy as copy_mod
  8132. * import time # <<<<<<<<<<<<<<
  8133. * import sys
  8134. * import random
  8135. */
  8136. __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__time), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8137. __Pyx_GOTREF(__pyx_t_2);
  8138. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__time, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8139. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8140. /* "zmq/core/socket.pyx":49
  8141. * import copy as copy_mod
  8142. * import time
  8143. * import sys # <<<<<<<<<<<<<<
  8144. * import random
  8145. * import struct
  8146. */
  8147. __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8148. __Pyx_GOTREF(__pyx_t_2);
  8149. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8150. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8151. /* "zmq/core/socket.pyx":50
  8152. * import time
  8153. * import sys
  8154. * import random # <<<<<<<<<<<<<<
  8155. * import struct
  8156. * import codecs
  8157. */
  8158. __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__random), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8159. __Pyx_GOTREF(__pyx_t_2);
  8160. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__random, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8161. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8162. /* "zmq/core/socket.pyx":51
  8163. * import sys
  8164. * import random
  8165. * import struct # <<<<<<<<<<<<<<
  8166. * import codecs
  8167. *
  8168. */
  8169. __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__struct), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8170. __Pyx_GOTREF(__pyx_t_2);
  8171. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__struct, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8172. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8173. /* "zmq/core/socket.pyx":52
  8174. * import random
  8175. * import struct
  8176. * import codecs # <<<<<<<<<<<<<<
  8177. *
  8178. * from zmq.utils import jsonapi
  8179. */
  8180. __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__codecs), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8181. __Pyx_GOTREF(__pyx_t_2);
  8182. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__codecs, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8183. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8184. /* "zmq/core/socket.pyx":54
  8185. * import codecs
  8186. *
  8187. * from zmq.utils import jsonapi # <<<<<<<<<<<<<<
  8188. *
  8189. * try:
  8190. */
  8191. __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8192. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  8193. __Pyx_INCREF(((PyObject *)__pyx_n_s__jsonapi));
  8194. PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__jsonapi));
  8195. __Pyx_GIVEREF(((PyObject *)__pyx_n_s__jsonapi));
  8196. __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s_40), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8197. __Pyx_GOTREF(__pyx_t_3);
  8198. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  8199. __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__jsonapi); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8200. __Pyx_GOTREF(__pyx_t_2);
  8201. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__jsonapi, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8202. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8203. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8204. /* "zmq/core/socket.pyx":56
  8205. * from zmq.utils import jsonapi
  8206. *
  8207. * try: # <<<<<<<<<<<<<<
  8208. * import cPickle
  8209. * pickle = cPickle
  8210. */
  8211. {
  8212. PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
  8213. __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
  8214. __Pyx_XGOTREF(__pyx_save_exc_type);
  8215. __Pyx_XGOTREF(__pyx_save_exc_value);
  8216. __Pyx_XGOTREF(__pyx_save_exc_tb);
  8217. /*try:*/ {
  8218. /* "zmq/core/socket.pyx":57
  8219. *
  8220. * try:
  8221. * import cPickle # <<<<<<<<<<<<<<
  8222. * pickle = cPickle
  8223. * except:
  8224. */
  8225. __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s__cPickle), 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
  8226. __Pyx_GOTREF(__pyx_t_3);
  8227. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__cPickle, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
  8228. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8229. /* "zmq/core/socket.pyx":58
  8230. * try:
  8231. * import cPickle
  8232. * pickle = cPickle # <<<<<<<<<<<<<<
  8233. * except:
  8234. * cPickle = None
  8235. */
  8236. __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__cPickle); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
  8237. __Pyx_GOTREF(__pyx_t_3);
  8238. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__pickle, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L2_error;}
  8239. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8240. }
  8241. __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
  8242. __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
  8243. __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
  8244. goto __pyx_L9_try_end;
  8245. __pyx_L2_error:;
  8246. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  8247. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  8248. /* "zmq/core/socket.pyx":59
  8249. * import cPickle
  8250. * pickle = cPickle
  8251. * except: # <<<<<<<<<<<<<<
  8252. * cPickle = None
  8253. * import pickle
  8254. */
  8255. /*except:*/ {
  8256. __Pyx_AddTraceback("zmq.core.socket");
  8257. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
  8258. __Pyx_GOTREF(__pyx_t_3);
  8259. __Pyx_GOTREF(__pyx_t_2);
  8260. __Pyx_GOTREF(__pyx_t_4);
  8261. /* "zmq/core/socket.pyx":60
  8262. * pickle = cPickle
  8263. * except:
  8264. * cPickle = None # <<<<<<<<<<<<<<
  8265. * import pickle
  8266. *
  8267. */
  8268. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__cPickle, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
  8269. /* "zmq/core/socket.pyx":61
  8270. * except:
  8271. * cPickle = None
  8272. * import pickle # <<<<<<<<<<<<<<
  8273. *
  8274. * from zmq.core import constants
  8275. */
  8276. __pyx_t_5 = __Pyx_Import(((PyObject *)__pyx_n_s__pickle), 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
  8277. __Pyx_GOTREF(__pyx_t_5);
  8278. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__pickle, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L4_except_error;}
  8279. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  8280. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  8281. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8282. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8283. goto __pyx_L3_exception_handled;
  8284. }
  8285. __pyx_L4_except_error:;
  8286. __Pyx_XGIVEREF(__pyx_save_exc_type);
  8287. __Pyx_XGIVEREF(__pyx_save_exc_value);
  8288. __Pyx_XGIVEREF(__pyx_save_exc_tb);
  8289. __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
  8290. goto __pyx_L1_error;
  8291. __pyx_L3_exception_handled:;
  8292. __Pyx_XGIVEREF(__pyx_save_exc_type);
  8293. __Pyx_XGIVEREF(__pyx_save_exc_value);
  8294. __Pyx_XGIVEREF(__pyx_save_exc_tb);
  8295. __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
  8296. __pyx_L9_try_end:;
  8297. }
  8298. /* "zmq/core/socket.pyx":63
  8299. * import pickle
  8300. *
  8301. * from zmq.core import constants # <<<<<<<<<<<<<<
  8302. * from zmq.core.constants import *
  8303. * from zmq.core.error import ZMQError, ZMQBindError
  8304. */
  8305. __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8306. __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  8307. __Pyx_INCREF(((PyObject *)__pyx_n_s__constants));
  8308. PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__constants));
  8309. __Pyx_GIVEREF(((PyObject *)__pyx_n_s__constants));
  8310. __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_41), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8311. __Pyx_GOTREF(__pyx_t_2);
  8312. __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  8313. __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__constants); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8314. __Pyx_GOTREF(__pyx_t_4);
  8315. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__constants, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8316. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8317. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8318. /* "zmq/core/socket.pyx":64
  8319. *
  8320. * from zmq.core import constants
  8321. * from zmq.core.constants import * # <<<<<<<<<<<<<<
  8322. * from zmq.core.error import ZMQError, ZMQBindError
  8323. * from zmq.utils.strtypes import bytes,unicode,basestring
  8324. */
  8325. __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8326. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  8327. __Pyx_INCREF(((PyObject *)__pyx_n_s_43));
  8328. PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s_43));
  8329. __Pyx_GIVEREF(((PyObject *)__pyx_n_s_43));
  8330. __pyx_t_4 = __Pyx_Import(((PyObject *)__pyx_n_s_42), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8331. __Pyx_GOTREF(__pyx_t_4);
  8332. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  8333. if (__pyx_import_star(__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  8334. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8335. /* "zmq/core/socket.pyx":65
  8336. * from zmq.core import constants
  8337. * from zmq.core.constants import *
  8338. * from zmq.core.error import ZMQError, ZMQBindError # <<<<<<<<<<<<<<
  8339. * from zmq.utils.strtypes import bytes,unicode,basestring
  8340. *
  8341. */
  8342. __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8343. __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  8344. __Pyx_INCREF(((PyObject *)__pyx_n_s__ZMQError));
  8345. PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__ZMQError));
  8346. __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ZMQError));
  8347. __Pyx_INCREF(((PyObject *)__pyx_n_s__ZMQBindError));
  8348. PyList_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__ZMQBindError));
  8349. __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ZMQBindError));
  8350. __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_44), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8351. __Pyx_GOTREF(__pyx_t_2);
  8352. __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  8353. __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__ZMQError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8354. __Pyx_GOTREF(__pyx_t_4);
  8355. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ZMQError, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8356. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8357. __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__ZMQBindError); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8358. __Pyx_GOTREF(__pyx_t_4);
  8359. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ZMQBindError, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8360. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8361. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8362. /* "zmq/core/socket.pyx":66
  8363. * from zmq.core.constants import *
  8364. * from zmq.core.error import ZMQError, ZMQBindError
  8365. * from zmq.utils.strtypes import bytes,unicode,basestring # <<<<<<<<<<<<<<
  8366. *
  8367. * #-----------------------------------------------------------------------------
  8368. */
  8369. __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8370. __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  8371. __Pyx_INCREF(((PyObject *)__pyx_n_s__bytes));
  8372. PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__bytes));
  8373. __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bytes));
  8374. __Pyx_INCREF(((PyObject *)__pyx_n_s__unicode));
  8375. PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__unicode));
  8376. __Pyx_GIVEREF(((PyObject *)__pyx_n_s__unicode));
  8377. __Pyx_INCREF(((PyObject *)__pyx_n_s__basestring));
  8378. PyList_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_n_s__basestring));
  8379. __Pyx_GIVEREF(((PyObject *)__pyx_n_s__basestring));
  8380. __pyx_t_4 = __Pyx_Import(((PyObject *)__pyx_n_s_45), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8381. __Pyx_GOTREF(__pyx_t_4);
  8382. __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  8383. __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__bytes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8384. __Pyx_GOTREF(__pyx_t_2);
  8385. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__bytes, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8386. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8387. __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__unicode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8388. __Pyx_GOTREF(__pyx_t_2);
  8389. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__unicode, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8390. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8391. __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__basestring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8392. __Pyx_GOTREF(__pyx_t_2);
  8393. if (PyObject_SetAttr(__pyx_m, __pyx_n_s__basestring, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8394. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  8395. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8396. /* "zmq/core/socket.pyx":79
  8397. * raise ZMQError(ENOTSUP)
  8398. *
  8399. * cdef inline Message _recv_message(void *handle, int flags=0, track=False): # <<<<<<<<<<<<<<
  8400. * """Receive a message in a non-copying manner and return a Message."""
  8401. * cdef int rc
  8402. */
  8403. __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8404. __Pyx_GOTREF(__pyx_t_4);
  8405. __pyx_k_1 = __pyx_t_4;
  8406. __Pyx_GIVEREF(__pyx_t_4);
  8407. __pyx_t_4 = 0;
  8408. /* "zmq/core/socket.pyx":457
  8409. * #-------------------------------------------------------------------------
  8410. *
  8411. * cpdef object send(self, object data, int flags=0, copy=True, track=False): # <<<<<<<<<<<<<<
  8412. * """s.send(data, flags=0, copy=True, track=False)
  8413. *
  8414. */
  8415. __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8416. __Pyx_GOTREF(__pyx_t_4);
  8417. __pyx_k_15 = __pyx_t_4;
  8418. __Pyx_GIVEREF(__pyx_t_4);
  8419. __pyx_t_4 = 0;
  8420. __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8421. __Pyx_GOTREF(__pyx_t_4);
  8422. __pyx_k_16 = __pyx_t_4;
  8423. __Pyx_GIVEREF(__pyx_t_4);
  8424. __pyx_t_4 = 0;
  8425. /* "zmq/core/socket.pyx":514
  8426. * return _send_message(self.handle, msg, flags)
  8427. *
  8428. * cpdef object recv(self, int flags=0, copy=True, track=False): # <<<<<<<<<<<<<<
  8429. * """s.recv(flags=0, copy=True, track=False)
  8430. *
  8431. */
  8432. __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8433. __Pyx_GOTREF(__pyx_t_4);
  8434. __pyx_k_21 = __pyx_t_4;
  8435. __Pyx_GIVEREF(__pyx_t_4);
  8436. __pyx_t_4 = 0;
  8437. __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8438. __Pyx_GOTREF(__pyx_t_4);
  8439. __pyx_k_22 = __pyx_t_4;
  8440. __Pyx_GIVEREF(__pyx_t_4);
  8441. __pyx_t_4 = 0;
  8442. /* "zmq/core/socket.pyx":552
  8443. * return _recv_message(self.handle, flags, track)
  8444. *
  8445. * def send_multipart(self, msg_parts, int flags=0, copy=True, track=False): # <<<<<<<<<<<<<<
  8446. * """s.send_multipart(msg_parts, flags=0, copy=True, track=False)
  8447. *
  8448. */
  8449. __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8450. __Pyx_GOTREF(__pyx_t_4);
  8451. __pyx_k_23 = __pyx_t_4;
  8452. __Pyx_GIVEREF(__pyx_t_4);
  8453. __pyx_t_4 = 0;
  8454. __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8455. __Pyx_GOTREF(__pyx_t_4);
  8456. __pyx_k_24 = __pyx_t_4;
  8457. __Pyx_GIVEREF(__pyx_t_4);
  8458. __pyx_t_4 = 0;
  8459. /* "zmq/core/socket.pyx":583
  8460. * return self.send(msg_parts[-1], flags, copy=copy, track=track)
  8461. *
  8462. * def recv_multipart(self, int flags=0, copy=True, track=False): # <<<<<<<<<<<<<<
  8463. * """s.recv_multipart(flags=0, copy=True, track=False)
  8464. *
  8465. */
  8466. __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8467. __Pyx_GOTREF(__pyx_t_4);
  8468. __pyx_k_25 = __pyx_t_4;
  8469. __Pyx_GIVEREF(__pyx_t_4);
  8470. __pyx_t_4 = 0;
  8471. __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8472. __Pyx_GOTREF(__pyx_t_4);
  8473. __pyx_k_26 = __pyx_t_4;
  8474. __Pyx_GIVEREF(__pyx_t_4);
  8475. __pyx_t_4 = 0;
  8476. /* "zmq/core/socket.pyx":632
  8477. * return bool(more)
  8478. *
  8479. * def send_unicode(self, u, int flags=0, copy=False, encoding='utf-8'): # <<<<<<<<<<<<<<
  8480. * """s.send_unicode(u, flags=0, copy=False, encoding='utf-8')
  8481. *
  8482. */
  8483. __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8484. __Pyx_GOTREF(__pyx_t_4);
  8485. __pyx_k_27 = __pyx_t_4;
  8486. __Pyx_GIVEREF(__pyx_t_4);
  8487. __pyx_t_4 = 0;
  8488. /* "zmq/core/socket.pyx":747
  8489. *
  8490. *
  8491. * __all__ = ['Socket'] # <<<<<<<<<<<<<<
  8492. */
  8493. __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8494. __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  8495. __Pyx_INCREF(((PyObject *)__pyx_n_s__Socket));
  8496. PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__Socket));
  8497. __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Socket));
  8498. if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8499. __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  8500. /* "zmq/core/socket.pyx":1
  8501. * """0MQ Socket class.""" # <<<<<<<<<<<<<<
  8502. *
  8503. * #
  8504. */
  8505. __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8506. __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  8507. if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  8508. __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  8509. /* "cpython/type.pxd":2
  8510. *
  8511. * cdef extern from "Python.h": # <<<<<<<<<<<<<<
  8512. * # The C structure of the objects used to describe built-in types.
  8513. *
  8514. */
  8515. goto __pyx_L0;
  8516. __pyx_L1_error:;
  8517. __Pyx_XDECREF(__pyx_t_1);
  8518. __Pyx_XDECREF(__pyx_t_2);
  8519. __Pyx_XDECREF(__pyx_t_3);
  8520. __Pyx_XDECREF(__pyx_t_4);
  8521. __Pyx_XDECREF(__pyx_t_5);
  8522. if (__pyx_m) {
  8523. __Pyx_AddTraceback("init zmq.core.socket");
  8524. Py_DECREF(__pyx_m); __pyx_m = 0;
  8525. } else if (!PyErr_Occurred()) {
  8526. PyErr_SetString(PyExc_ImportError, "init zmq.core.socket");
  8527. }
  8528. __pyx_L0:;
  8529. __Pyx_RefNannyFinishContext();
  8530. #if PY_MAJOR_VERSION < 3
  8531. return;
  8532. #else
  8533. return __pyx_m;
  8534. #endif
  8535. }
  8536. /* Runtime support code */
  8537. static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
  8538. PyObject *result;
  8539. result = PyObject_GetAttr(dict, name);
  8540. if (!result)
  8541. PyErr_SetObject(PyExc_NameError, name);
  8542. return result;
  8543. }
  8544. static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
  8545. PyObject *tmp_type, *tmp_value, *tmp_tb;
  8546. PyThreadState *tstate = PyThreadState_GET();
  8547. tmp_type = tstate->curexc_type;
  8548. tmp_value = tstate->curexc_value;
  8549. tmp_tb = tstate->curexc_traceback;
  8550. tstate->curexc_type = type;
  8551. tstate->curexc_value = value;
  8552. tstate->curexc_traceback = tb;
  8553. Py_XDECREF(tmp_type);
  8554. Py_XDECREF(tmp_value);
  8555. Py_XDECREF(tmp_tb);
  8556. }
  8557. static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
  8558. PyThreadState *tstate = PyThreadState_GET();
  8559. *type = tstate->curexc_type;
  8560. *value = tstate->curexc_value;
  8561. *tb = tstate->curexc_traceback;
  8562. tstate->curexc_type = 0;
  8563. tstate->curexc_value = 0;
  8564. tstate->curexc_traceback = 0;
  8565. }
  8566. #if PY_MAJOR_VERSION < 3
  8567. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
  8568. Py_XINCREF(type);
  8569. Py_XINCREF(value);
  8570. Py_XINCREF(tb);
  8571. /* First, check the traceback argument, replacing None with NULL. */
  8572. if (tb == Py_None) {
  8573. Py_DECREF(tb);
  8574. tb = 0;
  8575. }
  8576. else if (tb != NULL && !PyTraceBack_Check(tb)) {
  8577. PyErr_SetString(PyExc_TypeError,
  8578. "raise: arg 3 must be a traceback or None");
  8579. goto raise_error;
  8580. }
  8581. /* Next, replace a missing value with None */
  8582. if (value == NULL) {
  8583. value = Py_None;
  8584. Py_INCREF(value);
  8585. }
  8586. #if PY_VERSION_HEX < 0x02050000
  8587. if (!PyClass_Check(type))
  8588. #else
  8589. if (!PyType_Check(type))
  8590. #endif
  8591. {
  8592. /* Raising an instance. The value should be a dummy. */
  8593. if (value != Py_None) {
  8594. PyErr_SetString(PyExc_TypeError,
  8595. "instance exception may not have a separate value");
  8596. goto raise_error;
  8597. }
  8598. /* Normalize to raise <class>, <instance> */
  8599. Py_DECREF(value);
  8600. value = type;
  8601. #if PY_VERSION_HEX < 0x02050000
  8602. if (PyInstance_Check(type)) {
  8603. type = (PyObject*) ((PyInstanceObject*)type)->in_class;
  8604. Py_INCREF(type);
  8605. }
  8606. else {
  8607. type = 0;
  8608. PyErr_SetString(PyExc_TypeError,
  8609. "raise: exception must be an old-style class or instance");
  8610. goto raise_error;
  8611. }
  8612. #else
  8613. type = (PyObject*) Py_TYPE(type);
  8614. Py_INCREF(type);
  8615. if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
  8616. PyErr_SetString(PyExc_TypeError,
  8617. "raise: exception class must be a subclass of BaseException");
  8618. goto raise_error;
  8619. }
  8620. #endif
  8621. }
  8622. __Pyx_ErrRestore(type, value, tb);
  8623. return;
  8624. raise_error:
  8625. Py_XDECREF(value);
  8626. Py_XDECREF(type);
  8627. Py_XDECREF(tb);
  8628. return;
  8629. }
  8630. #else /* Python 3+ */
  8631. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
  8632. if (tb == Py_None) {
  8633. tb = 0;
  8634. } else if (tb && !PyTraceBack_Check(tb)) {
  8635. PyErr_SetString(PyExc_TypeError,
  8636. "raise: arg 3 must be a traceback or None");
  8637. goto bad;
  8638. }
  8639. if (value == Py_None)
  8640. value = 0;
  8641. if (PyExceptionInstance_Check(type)) {
  8642. if (value) {
  8643. PyErr_SetString(PyExc_TypeError,
  8644. "instance exception may not have a separate value");
  8645. goto bad;
  8646. }
  8647. value = type;
  8648. type = (PyObject*) Py_TYPE(value);
  8649. } else if (!PyExceptionClass_Check(type)) {
  8650. PyErr_SetString(PyExc_TypeError,
  8651. "raise: exception class must be a subclass of BaseException");
  8652. goto bad;
  8653. }
  8654. PyErr_SetObject(type, value);
  8655. if (tb) {
  8656. PyThreadState *tstate = PyThreadState_GET();
  8657. PyObject* tmp_tb = tstate->curexc_traceback;
  8658. if (tb != tmp_tb) {
  8659. Py_INCREF(tb);
  8660. tstate->curexc_traceback = tb;
  8661. Py_XDECREF(tmp_tb);
  8662. }
  8663. }
  8664. bad:
  8665. return;
  8666. }
  8667. #endif
  8668. static void __Pyx_RaiseArgtupleInvalid(
  8669. const char* func_name,
  8670. int exact,
  8671. Py_ssize_t num_min,
  8672. Py_ssize_t num_max,
  8673. Py_ssize_t num_found)
  8674. {
  8675. Py_ssize_t num_expected;
  8676. const char *number, *more_or_less;
  8677. if (num_found < num_min) {
  8678. num_expected = num_min;
  8679. more_or_less = "at least";
  8680. } else {
  8681. num_expected = num_max;
  8682. more_or_less = "at most";
  8683. }
  8684. if (exact) {
  8685. more_or_less = "exactly";
  8686. }
  8687. number = (num_expected == 1) ? "" : "s";
  8688. PyErr_Format(PyExc_TypeError,
  8689. #if PY_VERSION_HEX < 0x02050000
  8690. "%s() takes %s %d positional argument%s (%d given)",
  8691. #else
  8692. "%s() takes %s %zd positional argument%s (%zd given)",
  8693. #endif
  8694. func_name, more_or_less, num_expected, number, num_found);
  8695. }
  8696. static void __Pyx_RaiseDoubleKeywordsError(
  8697. const char* func_name,
  8698. PyObject* kw_name)
  8699. {
  8700. PyErr_Format(PyExc_TypeError,
  8701. #if PY_MAJOR_VERSION >= 3
  8702. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  8703. #else
  8704. "%s() got multiple values for keyword argument '%s'", func_name,
  8705. PyString_AS_STRING(kw_name));
  8706. #endif
  8707. }
  8708. static int __Pyx_ParseOptionalKeywords(
  8709. PyObject *kwds,
  8710. PyObject **argnames[],
  8711. PyObject *kwds2,
  8712. PyObject *values[],
  8713. Py_ssize_t num_pos_args,
  8714. const char* function_name)
  8715. {
  8716. PyObject *key = 0, *value = 0;
  8717. Py_ssize_t pos = 0;
  8718. PyObject*** name;
  8719. PyObject*** first_kw_arg = argnames + num_pos_args;
  8720. while (PyDict_Next(kwds, &pos, &key, &value)) {
  8721. name = first_kw_arg;
  8722. while (*name && (**name != key)) name++;
  8723. if (*name) {
  8724. values[name-argnames] = value;
  8725. } else {
  8726. #if PY_MAJOR_VERSION < 3
  8727. if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
  8728. #else
  8729. if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
  8730. #endif
  8731. goto invalid_keyword_type;
  8732. } else {
  8733. for (name = first_kw_arg; *name; name++) {
  8734. #if PY_MAJOR_VERSION >= 3
  8735. if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
  8736. PyUnicode_Compare(**name, key) == 0) break;
  8737. #else
  8738. if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
  8739. _PyString_Eq(**name, key)) break;
  8740. #endif
  8741. }
  8742. if (*name) {
  8743. values[name-argnames] = value;
  8744. } else {
  8745. /* unexpected keyword found */
  8746. for (name=argnames; name != first_kw_arg; name++) {
  8747. if (**name == key) goto arg_passed_twice;
  8748. #if PY_MAJOR_VERSION >= 3
  8749. if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
  8750. PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
  8751. #else
  8752. if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
  8753. _PyString_Eq(**name, key)) goto arg_passed_twice;
  8754. #endif
  8755. }
  8756. if (kwds2) {
  8757. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  8758. } else {
  8759. goto invalid_keyword;
  8760. }
  8761. }
  8762. }
  8763. }
  8764. }
  8765. return 0;
  8766. arg_passed_twice:
  8767. __Pyx_RaiseDoubleKeywordsError(function_name, **name);
  8768. goto bad;
  8769. invalid_keyword_type:
  8770. PyErr_Format(PyExc_TypeError,
  8771. "%s() keywords must be strings", function_name);
  8772. goto bad;
  8773. invalid_keyword:
  8774. PyErr_Format(PyExc_TypeError,
  8775. #if PY_MAJOR_VERSION < 3
  8776. "%s() got an unexpected keyword argument '%s'",
  8777. function_name, PyString_AsString(key));
  8778. #else
  8779. "%s() got an unexpected keyword argument '%U'",
  8780. function_name, key);
  8781. #endif
  8782. bad:
  8783. return -1;
  8784. }
  8785. static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
  8786. if (unlikely(!type)) {
  8787. PyErr_Format(PyExc_SystemError, "Missing type object");
  8788. return 0;
  8789. }
  8790. if (likely(PyObject_TypeCheck(obj, type)))
  8791. return 1;
  8792. PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
  8793. Py_TYPE(obj)->tp_name, type->tp_name);
  8794. return 0;
  8795. }
  8796. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
  8797. PyObject *local_type, *local_value, *local_tb;
  8798. PyObject *tmp_type, *tmp_value, *tmp_tb;
  8799. PyThreadState *tstate = PyThreadState_GET();
  8800. local_type = tstate->curexc_type;
  8801. local_value = tstate->curexc_value;
  8802. local_tb = tstate->curexc_traceback;
  8803. tstate->curexc_type = 0;
  8804. tstate->curexc_value = 0;
  8805. tstate->curexc_traceback = 0;
  8806. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  8807. if (unlikely(tstate->curexc_type))
  8808. goto bad;
  8809. #if PY_MAJOR_VERSION >= 3
  8810. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  8811. goto bad;
  8812. #endif
  8813. *type = local_type;
  8814. *value = local_value;
  8815. *tb = local_tb;
  8816. Py_INCREF(local_type);
  8817. Py_INCREF(local_value);
  8818. Py_INCREF(local_tb);
  8819. tmp_type = tstate->exc_type;
  8820. tmp_value = tstate->exc_value;
  8821. tmp_tb = tstate->exc_traceback;
  8822. tstate->exc_type = local_type;
  8823. tstate->exc_value = local_value;
  8824. tstate->exc_traceback = local_tb;
  8825. /* Make sure tstate is in a consistent state when we XDECREF
  8826. these objects (XDECREF may run arbitrary code). */
  8827. Py_XDECREF(tmp_type);
  8828. Py_XDECREF(tmp_value);
  8829. Py_XDECREF(tmp_tb);
  8830. return 0;
  8831. bad:
  8832. *type = 0;
  8833. *value = 0;
  8834. *tb = 0;
  8835. Py_XDECREF(local_type);
  8836. Py_XDECREF(local_value);
  8837. Py_XDECREF(local_tb);
  8838. return -1;
  8839. }
  8840. static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
  8841. PyThreadState *tstate = PyThreadState_GET();
  8842. *type = tstate->exc_type;
  8843. *value = tstate->exc_value;
  8844. *tb = tstate->exc_traceback;
  8845. Py_XINCREF(*type);
  8846. Py_XINCREF(*value);
  8847. Py_XINCREF(*tb);
  8848. }
  8849. static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
  8850. PyObject *tmp_type, *tmp_value, *tmp_tb;
  8851. PyThreadState *tstate = PyThreadState_GET();
  8852. tmp_type = tstate->exc_type;
  8853. tmp_value = tstate->exc_value;
  8854. tmp_tb = tstate->exc_traceback;
  8855. tstate->exc_type = type;
  8856. tstate->exc_value = value;
  8857. tstate->exc_traceback = tb;
  8858. Py_XDECREF(tmp_type);
  8859. Py_XDECREF(tmp_value);
  8860. Py_XDECREF(tmp_tb);
  8861. }
  8862. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
  8863. PyObject *py_import = 0;
  8864. PyObject *empty_list = 0;
  8865. PyObject *module = 0;
  8866. PyObject *global_dict = 0;
  8867. PyObject *empty_dict = 0;
  8868. PyObject *list;
  8869. py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
  8870. if (!py_import)
  8871. goto bad;
  8872. if (from_list)
  8873. list = from_list;
  8874. else {
  8875. empty_list = PyList_New(0);
  8876. if (!empty_list)
  8877. goto bad;
  8878. list = empty_list;
  8879. }
  8880. global_dict = PyModule_GetDict(__pyx_m);
  8881. if (!global_dict)
  8882. goto bad;
  8883. empty_dict = PyDict_New();
  8884. if (!empty_dict)
  8885. goto bad;
  8886. module = PyObject_CallFunctionObjArgs(py_import,
  8887. name, global_dict, empty_dict, list, NULL);
  8888. bad:
  8889. Py_XDECREF(empty_list);
  8890. Py_XDECREF(py_import);
  8891. Py_XDECREF(empty_dict);
  8892. return module;
  8893. }
  8894. static CYTHON_INLINE pyzmq_int64_t __Pyx_PyInt_from_py_pyzmq_int64_t(PyObject* x) {
  8895. const pyzmq_int64_t neg_one = (pyzmq_int64_t)-1, const_zero = (pyzmq_int64_t)0;
  8896. const int is_unsigned = const_zero < neg_one;
  8897. if (sizeof(pyzmq_int64_t) == sizeof(char)) {
  8898. if (is_unsigned)
  8899. return (pyzmq_int64_t)__Pyx_PyInt_AsUnsignedChar(x);
  8900. else
  8901. return (pyzmq_int64_t)__Pyx_PyInt_AsSignedChar(x);
  8902. } else if (sizeof(pyzmq_int64_t) == sizeof(short)) {
  8903. if (is_unsigned)
  8904. return (pyzmq_int64_t)__Pyx_PyInt_AsUnsignedShort(x);
  8905. else
  8906. return (pyzmq_int64_t)__Pyx_PyInt_AsSignedShort(x);
  8907. } else if (sizeof(pyzmq_int64_t) == sizeof(int)) {
  8908. if (is_unsigned)
  8909. return (pyzmq_int64_t)__Pyx_PyInt_AsUnsignedInt(x);
  8910. else
  8911. return (pyzmq_int64_t)__Pyx_PyInt_AsSignedInt(x);
  8912. } else if (sizeof(pyzmq_int64_t) == sizeof(long)) {
  8913. if (is_unsigned)
  8914. return (pyzmq_int64_t)__Pyx_PyInt_AsUnsignedLong(x);
  8915. else
  8916. return (pyzmq_int64_t)__Pyx_PyInt_AsSignedLong(x);
  8917. } else if (sizeof(pyzmq_int64_t) == sizeof(PY_LONG_LONG)) {
  8918. if (is_unsigned)
  8919. return (pyzmq_int64_t)__Pyx_PyInt_AsUnsignedLongLong(x);
  8920. else
  8921. return (pyzmq_int64_t)__Pyx_PyInt_AsSignedLongLong(x);
  8922. } else {
  8923. pyzmq_int64_t val;
  8924. PyObject *v = __Pyx_PyNumber_Int(x);
  8925. #if PY_VERSION_HEX < 0x03000000
  8926. if (likely(v) && !PyLong_Check(v)) {
  8927. PyObject *tmp = v;
  8928. v = PyNumber_Long(tmp);
  8929. Py_DECREF(tmp);
  8930. }
  8931. #endif
  8932. if (likely(v)) {
  8933. int one = 1; int is_little = (int)*(unsigned char *)&one;
  8934. unsigned char *bytes = (unsigned char *)&val;
  8935. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  8936. bytes, sizeof(val),
  8937. is_little, !is_unsigned);
  8938. Py_DECREF(v);
  8939. if (likely(!ret))
  8940. return val;
  8941. }
  8942. return (pyzmq_int64_t)-1;
  8943. }
  8944. }
  8945. static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_pyzmq_int64_t(pyzmq_int64_t val) {
  8946. const pyzmq_int64_t neg_one = (pyzmq_int64_t)-1, const_zero = (pyzmq_int64_t)0;
  8947. const int is_unsigned = const_zero < neg_one;
  8948. if ((sizeof(pyzmq_int64_t) == sizeof(char)) ||
  8949. (sizeof(pyzmq_int64_t) == sizeof(short))) {
  8950. return PyInt_FromLong((long)val);
  8951. } else if ((sizeof(pyzmq_int64_t) == sizeof(int)) ||
  8952. (sizeof(pyzmq_int64_t) == sizeof(long))) {
  8953. if (is_unsigned)
  8954. return PyLong_FromUnsignedLong((unsigned long)val);
  8955. else
  8956. return PyInt_FromLong((long)val);
  8957. } else if (sizeof(pyzmq_int64_t) == sizeof(PY_LONG_LONG)) {
  8958. if (is_unsigned)
  8959. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
  8960. else
  8961. return PyLong_FromLongLong((PY_LONG_LONG)val);
  8962. } else {
  8963. int one = 1; int little = (int)*(unsigned char *)&one;
  8964. unsigned char *bytes = (unsigned char *)&val;
  8965. return _PyLong_FromByteArray(bytes, sizeof(pyzmq_int64_t),
  8966. little, !is_unsigned);
  8967. }
  8968. }
  8969. static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
  8970. const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
  8971. const int is_unsigned = neg_one > const_zero;
  8972. if (sizeof(unsigned char) < sizeof(long)) {
  8973. long val = __Pyx_PyInt_AsLong(x);
  8974. if (unlikely(val != (long)(unsigned char)val)) {
  8975. if (!unlikely(val == -1 && PyErr_Occurred())) {
  8976. PyErr_SetString(PyExc_OverflowError,
  8977. (is_unsigned && unlikely(val < 0)) ?
  8978. "can't convert negative value to unsigned char" :
  8979. "value too large to convert to unsigned char");
  8980. }
  8981. return (unsigned char)-1;
  8982. }
  8983. return (unsigned char)val;
  8984. }
  8985. return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
  8986. }
  8987. static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
  8988. const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
  8989. const int is_unsigned = neg_one > const_zero;
  8990. if (sizeof(unsigned short) < sizeof(long)) {
  8991. long val = __Pyx_PyInt_AsLong(x);
  8992. if (unlikely(val != (long)(unsigned short)val)) {
  8993. if (!unlikely(val == -1 && PyErr_Occurred())) {
  8994. PyErr_SetString(PyExc_OverflowError,
  8995. (is_unsigned && unlikely(val < 0)) ?
  8996. "can't convert negative value to unsigned short" :
  8997. "value too large to convert to unsigned short");
  8998. }
  8999. return (unsigned short)-1;
  9000. }
  9001. return (unsigned short)val;
  9002. }
  9003. return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
  9004. }
  9005. static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
  9006. const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
  9007. const int is_unsigned = neg_one > const_zero;
  9008. if (sizeof(unsigned int) < sizeof(long)) {
  9009. long val = __Pyx_PyInt_AsLong(x);
  9010. if (unlikely(val != (long)(unsigned int)val)) {
  9011. if (!unlikely(val == -1 && PyErr_Occurred())) {
  9012. PyErr_SetString(PyExc_OverflowError,
  9013. (is_unsigned && unlikely(val < 0)) ?
  9014. "can't convert negative value to unsigned int" :
  9015. "value too large to convert to unsigned int");
  9016. }
  9017. return (unsigned int)-1;
  9018. }
  9019. return (unsigned int)val;
  9020. }
  9021. return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
  9022. }
  9023. static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
  9024. const char neg_one = (char)-1, const_zero = 0;
  9025. const int is_unsigned = neg_one > const_zero;
  9026. if (sizeof(char) < sizeof(long)) {
  9027. long val = __Pyx_PyInt_AsLong(x);
  9028. if (unlikely(val != (long)(char)val)) {
  9029. if (!unlikely(val == -1 && PyErr_Occurred())) {
  9030. PyErr_SetString(PyExc_OverflowError,
  9031. (is_unsigned && unlikely(val < 0)) ?
  9032. "can't convert negative value to char" :
  9033. "value too large to convert to char");
  9034. }
  9035. return (char)-1;
  9036. }
  9037. return (char)val;
  9038. }
  9039. return (char)__Pyx_PyInt_AsLong(x);
  9040. }
  9041. static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
  9042. const short neg_one = (short)-1, const_zero = 0;
  9043. const int is_unsigned = neg_one > const_zero;
  9044. if (sizeof(short) < sizeof(long)) {
  9045. long val = __Pyx_PyInt_AsLong(x);
  9046. if (unlikely(val != (long)(short)val)) {
  9047. if (!unlikely(val == -1 && PyErr_Occurred())) {
  9048. PyErr_SetString(PyExc_OverflowError,
  9049. (is_unsigned && unlikely(val < 0)) ?
  9050. "can't convert negative value to short" :
  9051. "value too large to convert to short");
  9052. }
  9053. return (short)-1;
  9054. }
  9055. return (short)val;
  9056. }
  9057. return (short)__Pyx_PyInt_AsLong(x);
  9058. }
  9059. static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
  9060. const int neg_one = (int)-1, const_zero = 0;
  9061. const int is_unsigned = neg_one > const_zero;
  9062. if (sizeof(int) < sizeof(long)) {
  9063. long val = __Pyx_PyInt_AsLong(x);
  9064. if (unlikely(val != (long)(int)val)) {
  9065. if (!unlikely(val == -1 && PyErr_Occurred())) {
  9066. PyErr_SetString(PyExc_OverflowError,
  9067. (is_unsigned && unlikely(val < 0)) ?
  9068. "can't convert negative value to int" :
  9069. "value too large to convert to int");
  9070. }
  9071. return (int)-1;
  9072. }
  9073. return (int)val;
  9074. }
  9075. return (int)__Pyx_PyInt_AsLong(x);
  9076. }
  9077. static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
  9078. const signed char neg_one = (signed char)-1, const_zero = 0;
  9079. const int is_unsigned = neg_one > const_zero;
  9080. if (sizeof(signed char) < sizeof(long)) {
  9081. long val = __Pyx_PyInt_AsLong(x);
  9082. if (unlikely(val != (long)(signed char)val)) {
  9083. if (!unlikely(val == -1 && PyErr_Occurred())) {
  9084. PyErr_SetString(PyExc_OverflowError,
  9085. (is_unsigned && unlikely(val < 0)) ?
  9086. "can't convert negative value to signed char" :
  9087. "value too large to convert to signed char");
  9088. }
  9089. return (signed char)-1;
  9090. }
  9091. return (signed char)val;
  9092. }
  9093. return (signed char)__Pyx_PyInt_AsSignedLong(x);
  9094. }
  9095. static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
  9096. const signed short neg_one = (signed short)-1, const_zero = 0;
  9097. const int is_unsigned = neg_one > const_zero;
  9098. if (sizeof(signed short) < sizeof(long)) {
  9099. long val = __Pyx_PyInt_AsLong(x);
  9100. if (unlikely(val != (long)(signed short)val)) {
  9101. if (!unlikely(val == -1 && PyErr_Occurred())) {
  9102. PyErr_SetString(PyExc_OverflowError,
  9103. (is_unsigned && unlikely(val < 0)) ?
  9104. "can't convert negative value to signed short" :
  9105. "value too large to convert to signed short");
  9106. }
  9107. return (signed short)-1;
  9108. }
  9109. return (signed short)val;
  9110. }
  9111. return (signed short)__Pyx_PyInt_AsSignedLong(x);
  9112. }
  9113. static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
  9114. const signed int neg_one = (signed int)-1, const_zero = 0;
  9115. const int is_unsigned = neg_one > const_zero;
  9116. if (sizeof(signed int) < sizeof(long)) {
  9117. long val = __Pyx_PyInt_AsLong(x);
  9118. if (unlikely(val != (long)(signed int)val)) {
  9119. if (!unlikely(val == -1 && PyErr_Occurred())) {
  9120. PyErr_SetString(PyExc_OverflowError,
  9121. (is_unsigned && unlikely(val < 0)) ?
  9122. "can't convert negative value to signed int" :
  9123. "value too large to convert to signed int");
  9124. }
  9125. return (signed int)-1;
  9126. }
  9127. return (signed int)val;
  9128. }
  9129. return (signed int)__Pyx_PyInt_AsSignedLong(x);
  9130. }
  9131. static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
  9132. const int neg_one = (int)-1, const_zero = 0;
  9133. const int is_unsigned = neg_one > const_zero;
  9134. if (sizeof(int) < sizeof(long)) {
  9135. long val = __Pyx_PyInt_AsLong(x);
  9136. if (unlikely(val != (long)(int)val)) {
  9137. if (!unlikely(val == -1 && PyErr_Occurred())) {
  9138. PyErr_SetString(PyExc_OverflowError,
  9139. (is_unsigned && unlikely(val < 0)) ?
  9140. "can't convert negative value to int" :
  9141. "value too large to convert to int");
  9142. }
  9143. return (int)-1;
  9144. }
  9145. return (int)val;
  9146. }
  9147. return (int)__Pyx_PyInt_AsLong(x);
  9148. }
  9149. static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
  9150. const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
  9151. const int is_unsigned = neg_one > const_zero;
  9152. #if PY_VERSION_HEX < 0x03000000
  9153. if (likely(PyInt_Check(x))) {
  9154. long val = PyInt_AS_LONG(x);
  9155. if (is_unsigned && unlikely(val < 0)) {
  9156. PyErr_SetString(PyExc_OverflowError,
  9157. "can't convert negative value to unsigned long");
  9158. return (unsigned long)-1;
  9159. }
  9160. return (unsigned long)val;
  9161. } else
  9162. #endif
  9163. if (likely(PyLong_Check(x))) {
  9164. if (is_unsigned) {
  9165. if (unlikely(Py_SIZE(x) < 0)) {
  9166. PyErr_SetString(PyExc_OverflowError,
  9167. "can't convert negative value to unsigned long");
  9168. return (unsigned long)-1;
  9169. }
  9170. return PyLong_AsUnsignedLong(x);
  9171. } else {
  9172. return PyLong_AsLong(x);
  9173. }
  9174. } else {
  9175. unsigned long val;
  9176. PyObject *tmp = __Pyx_PyNumber_Int(x);
  9177. if (!tmp) return (unsigned long)-1;
  9178. val = __Pyx_PyInt_AsUnsignedLong(tmp);
  9179. Py_DECREF(tmp);
  9180. return val;
  9181. }
  9182. }
  9183. static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
  9184. const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
  9185. const int is_unsigned = neg_one > const_zero;
  9186. #if PY_VERSION_HEX < 0x03000000
  9187. if (likely(PyInt_Check(x))) {
  9188. long val = PyInt_AS_LONG(x);
  9189. if (is_unsigned && unlikely(val < 0)) {
  9190. PyErr_SetString(PyExc_OverflowError,
  9191. "can't convert negative value to unsigned PY_LONG_LONG");
  9192. return (unsigned PY_LONG_LONG)-1;
  9193. }
  9194. return (unsigned PY_LONG_LONG)val;
  9195. } else
  9196. #endif
  9197. if (likely(PyLong_Check(x))) {
  9198. if (is_unsigned) {
  9199. if (unlikely(Py_SIZE(x) < 0)) {
  9200. PyErr_SetString(PyExc_OverflowError,
  9201. "can't convert negative value to unsigned PY_LONG_LONG");
  9202. return (unsigned PY_LONG_LONG)-1;
  9203. }
  9204. return PyLong_AsUnsignedLongLong(x);
  9205. } else {
  9206. return PyLong_AsLongLong(x);
  9207. }
  9208. } else {
  9209. unsigned PY_LONG_LONG val;
  9210. PyObject *tmp = __Pyx_PyNumber_Int(x);
  9211. if (!tmp) return (unsigned PY_LONG_LONG)-1;
  9212. val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
  9213. Py_DECREF(tmp);
  9214. return val;
  9215. }
  9216. }
  9217. static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
  9218. const long neg_one = (long)-1, const_zero = 0;
  9219. const int is_unsigned = neg_one > const_zero;
  9220. #if PY_VERSION_HEX < 0x03000000
  9221. if (likely(PyInt_Check(x))) {
  9222. long val = PyInt_AS_LONG(x);
  9223. if (is_unsigned && unlikely(val < 0)) {
  9224. PyErr_SetString(PyExc_OverflowError,
  9225. "can't convert negative value to long");
  9226. return (long)-1;
  9227. }
  9228. return (long)val;
  9229. } else
  9230. #endif
  9231. if (likely(PyLong_Check(x))) {
  9232. if (is_unsigned) {
  9233. if (unlikely(Py_SIZE(x) < 0)) {
  9234. PyErr_SetString(PyExc_OverflowError,
  9235. "can't convert negative value to long");
  9236. return (long)-1;
  9237. }
  9238. return PyLong_AsUnsignedLong(x);
  9239. } else {
  9240. return PyLong_AsLong(x);
  9241. }
  9242. } else {
  9243. long val;
  9244. PyObject *tmp = __Pyx_PyNumber_Int(x);
  9245. if (!tmp) return (long)-1;
  9246. val = __Pyx_PyInt_AsLong(tmp);
  9247. Py_DECREF(tmp);
  9248. return val;
  9249. }
  9250. }
  9251. static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
  9252. const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
  9253. const int is_unsigned = neg_one > const_zero;
  9254. #if PY_VERSION_HEX < 0x03000000
  9255. if (likely(PyInt_Check(x))) {
  9256. long val = PyInt_AS_LONG(x);
  9257. if (is_unsigned && unlikely(val < 0)) {
  9258. PyErr_SetString(PyExc_OverflowError,
  9259. "can't convert negative value to PY_LONG_LONG");
  9260. return (PY_LONG_LONG)-1;
  9261. }
  9262. return (PY_LONG_LONG)val;
  9263. } else
  9264. #endif
  9265. if (likely(PyLong_Check(x))) {
  9266. if (is_unsigned) {
  9267. if (unlikely(Py_SIZE(x) < 0)) {
  9268. PyErr_SetString(PyExc_OverflowError,
  9269. "can't convert negative value to PY_LONG_LONG");
  9270. return (PY_LONG_LONG)-1;
  9271. }
  9272. return PyLong_AsUnsignedLongLong(x);
  9273. } else {
  9274. return PyLong_AsLongLong(x);
  9275. }
  9276. } else {
  9277. PY_LONG_LONG val;
  9278. PyObject *tmp = __Pyx_PyNumber_Int(x);
  9279. if (!tmp) return (PY_LONG_LONG)-1;
  9280. val = __Pyx_PyInt_AsLongLong(tmp);
  9281. Py_DECREF(tmp);
  9282. return val;
  9283. }
  9284. }
  9285. static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
  9286. const signed long neg_one = (signed long)-1, const_zero = 0;
  9287. const int is_unsigned = neg_one > const_zero;
  9288. #if PY_VERSION_HEX < 0x03000000
  9289. if (likely(PyInt_Check(x))) {
  9290. long val = PyInt_AS_LONG(x);
  9291. if (is_unsigned && unlikely(val < 0)) {
  9292. PyErr_SetString(PyExc_OverflowError,
  9293. "can't convert negative value to signed long");
  9294. return (signed long)-1;
  9295. }
  9296. return (signed long)val;
  9297. } else
  9298. #endif
  9299. if (likely(PyLong_Check(x))) {
  9300. if (is_unsigned) {
  9301. if (unlikely(Py_SIZE(x) < 0)) {
  9302. PyErr_SetString(PyExc_OverflowError,
  9303. "can't convert negative value to signed long");
  9304. return (signed long)-1;
  9305. }
  9306. return PyLong_AsUnsignedLong(x);
  9307. } else {
  9308. return PyLong_AsLong(x);
  9309. }
  9310. } else {
  9311. signed long val;
  9312. PyObject *tmp = __Pyx_PyNumber_Int(x);
  9313. if (!tmp) return (signed long)-1;
  9314. val = __Pyx_PyInt_AsSignedLong(tmp);
  9315. Py_DECREF(tmp);
  9316. return val;
  9317. }
  9318. }
  9319. static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
  9320. const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
  9321. const int is_unsigned = neg_one > const_zero;
  9322. #if PY_VERSION_HEX < 0x03000000
  9323. if (likely(PyInt_Check(x))) {
  9324. long val = PyInt_AS_LONG(x);
  9325. if (is_unsigned && unlikely(val < 0)) {
  9326. PyErr_SetString(PyExc_OverflowError,
  9327. "can't convert negative value to signed PY_LONG_LONG");
  9328. return (signed PY_LONG_LONG)-1;
  9329. }
  9330. return (signed PY_LONG_LONG)val;
  9331. } else
  9332. #endif
  9333. if (likely(PyLong_Check(x))) {
  9334. if (is_unsigned) {
  9335. if (unlikely(Py_SIZE(x) < 0)) {
  9336. PyErr_SetString(PyExc_OverflowError,
  9337. "can't convert negative value to signed PY_LONG_LONG");
  9338. return (signed PY_LONG_LONG)-1;
  9339. }
  9340. return PyLong_AsUnsignedLongLong(x);
  9341. } else {
  9342. return PyLong_AsLongLong(x);
  9343. }
  9344. } else {
  9345. signed PY_LONG_LONG val;
  9346. PyObject *tmp = __Pyx_PyNumber_Int(x);
  9347. if (!tmp) return (signed PY_LONG_LONG)-1;
  9348. val = __Pyx_PyInt_AsSignedLongLong(tmp);
  9349. Py_DECREF(tmp);
  9350. return val;
  9351. }
  9352. }
  9353. static CYTHON_INLINE int __Pyx_StrEq(const char *s1, const char *s2) {
  9354. while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
  9355. return *s1 == *s2;
  9356. }
  9357. static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
  9358. #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
  9359. PyObject *ob = PyCapsule_New(vtable, 0, 0);
  9360. #else
  9361. PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
  9362. #endif
  9363. if (!ob)
  9364. goto bad;
  9365. if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
  9366. goto bad;
  9367. Py_DECREF(ob);
  9368. return 0;
  9369. bad:
  9370. Py_XDECREF(ob);
  9371. return -1;
  9372. }
  9373. #ifndef __PYX_HAVE_RT_ImportType
  9374. #define __PYX_HAVE_RT_ImportType
  9375. static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
  9376. long size, int strict)
  9377. {
  9378. PyObject *py_module = 0;
  9379. PyObject *result = 0;
  9380. PyObject *py_name = 0;
  9381. char warning[200];
  9382. py_module = __Pyx_ImportModule(module_name);
  9383. if (!py_module)
  9384. goto bad;
  9385. #if PY_MAJOR_VERSION < 3
  9386. py_name = PyString_FromString(class_name);
  9387. #else
  9388. py_name = PyUnicode_FromString(class_name);
  9389. #endif
  9390. if (!py_name)
  9391. goto bad;
  9392. result = PyObject_GetAttr(py_module, py_name);
  9393. Py_DECREF(py_name);
  9394. py_name = 0;
  9395. Py_DECREF(py_module);
  9396. py_module = 0;
  9397. if (!result)
  9398. goto bad;
  9399. if (!PyType_Check(result)) {
  9400. PyErr_Format(PyExc_TypeError,
  9401. "%s.%s is not a type object",
  9402. module_name, class_name);
  9403. goto bad;
  9404. }
  9405. if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
  9406. PyOS_snprintf(warning, sizeof(warning),
  9407. "%s.%s size changed, may indicate binary incompatibility",
  9408. module_name, class_name);
  9409. #if PY_VERSION_HEX < 0x02050000
  9410. PyErr_Warn(NULL, warning);
  9411. #else
  9412. PyErr_WarnEx(NULL, warning, 0);
  9413. #endif
  9414. }
  9415. else if (((PyTypeObject *)result)->tp_basicsize != size) {
  9416. PyErr_Format(PyExc_ValueError,
  9417. "%s.%s has the wrong size, try recompiling",
  9418. module_name, class_name);
  9419. goto bad;
  9420. }
  9421. return (PyTypeObject *)result;
  9422. bad:
  9423. Py_XDECREF(py_module);
  9424. Py_XDECREF(result);
  9425. return 0;
  9426. }
  9427. #endif
  9428. #ifndef __PYX_HAVE_RT_ImportModule
  9429. #define __PYX_HAVE_RT_ImportModule
  9430. static PyObject *__Pyx_ImportModule(const char *name) {
  9431. PyObject *py_name = 0;
  9432. PyObject *py_module = 0;
  9433. #if PY_MAJOR_VERSION < 3
  9434. py_name = PyString_FromString(name);
  9435. #else
  9436. py_name = PyUnicode_FromString(name);
  9437. #endif
  9438. if (!py_name)
  9439. goto bad;
  9440. py_module = PyImport_Import(py_name);
  9441. Py_DECREF(py_name);
  9442. return py_module;
  9443. bad:
  9444. Py_XDECREF(py_name);
  9445. return 0;
  9446. }
  9447. #endif
  9448. static void* __Pyx_GetVtable(PyObject *dict) {
  9449. void* ptr;
  9450. PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
  9451. if (!ob)
  9452. goto bad;
  9453. #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
  9454. ptr = PyCapsule_GetPointer(ob, 0);
  9455. #else
  9456. ptr = PyCObject_AsVoidPtr(ob);
  9457. #endif
  9458. if (!ptr && !PyErr_Occurred())
  9459. PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
  9460. Py_DECREF(ob);
  9461. return ptr;
  9462. bad:
  9463. Py_XDECREF(ob);
  9464. return NULL;
  9465. }
  9466. #ifndef __PYX_HAVE_RT_ImportFunction
  9467. #define __PYX_HAVE_RT_ImportFunction
  9468. static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
  9469. PyObject *d = 0;
  9470. PyObject *cobj = 0;
  9471. union {
  9472. void (*fp)(void);
  9473. void *p;
  9474. } tmp;
  9475. d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
  9476. if (!d)
  9477. goto bad;
  9478. cobj = PyDict_GetItemString(d, funcname);
  9479. if (!cobj) {
  9480. PyErr_Format(PyExc_ImportError,
  9481. "%s does not export expected C function %s",
  9482. PyModule_GetName(module), funcname);
  9483. goto bad;
  9484. }
  9485. #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
  9486. if (!PyCapsule_IsValid(cobj, sig)) {
  9487. PyErr_Format(PyExc_TypeError,
  9488. "C function %s.%s has wrong signature (expected %s, got %s)",
  9489. PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
  9490. goto bad;
  9491. }
  9492. tmp.p = PyCapsule_GetPointer(cobj, sig);
  9493. #else
  9494. {const char *desc, *s1, *s2;
  9495. desc = (const char *)PyCObject_GetDesc(cobj);
  9496. if (!desc)
  9497. goto bad;
  9498. s1 = desc; s2 = sig;
  9499. while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
  9500. if (*s1 != *s2) {
  9501. PyErr_Format(PyExc_TypeError,
  9502. "C function %s.%s has wrong signature (expected %s, got %s)",
  9503. PyModule_GetName(module), funcname, sig, desc);
  9504. goto bad;
  9505. }
  9506. tmp.p = PyCObject_AsVoidPtr(cobj);}
  9507. #endif
  9508. *f = tmp.fp;
  9509. if (!(*f))
  9510. goto bad;
  9511. Py_DECREF(d);
  9512. return 0;
  9513. bad:
  9514. Py_XDECREF(d);
  9515. return -1;
  9516. }
  9517. #endif
  9518. #include "compile.h"
  9519. #include "frameobject.h"
  9520. #include "traceback.h"
  9521. static void __Pyx_AddTraceback(const char *funcname) {
  9522. PyObject *py_srcfile = 0;
  9523. PyObject *py_funcname = 0;
  9524. PyObject *py_globals = 0;
  9525. PyCodeObject *py_code = 0;
  9526. PyFrameObject *py_frame = 0;
  9527. #if PY_MAJOR_VERSION < 3
  9528. py_srcfile = PyString_FromString(__pyx_filename);
  9529. #else
  9530. py_srcfile = PyUnicode_FromString(__pyx_filename);
  9531. #endif
  9532. if (!py_srcfile) goto bad;
  9533. if (__pyx_clineno) {
  9534. #if PY_MAJOR_VERSION < 3
  9535. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
  9536. #else
  9537. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
  9538. #endif
  9539. }
  9540. else {
  9541. #if PY_MAJOR_VERSION < 3
  9542. py_funcname = PyString_FromString(funcname);
  9543. #else
  9544. py_funcname = PyUnicode_FromString(funcname);
  9545. #endif
  9546. }
  9547. if (!py_funcname) goto bad;
  9548. py_globals = PyModule_GetDict(__pyx_m);
  9549. if (!py_globals) goto bad;
  9550. py_code = PyCode_New(
  9551. 0, /*int argcount,*/
  9552. #if PY_MAJOR_VERSION >= 3
  9553. 0, /*int kwonlyargcount,*/
  9554. #endif
  9555. 0, /*int nlocals,*/
  9556. 0, /*int stacksize,*/
  9557. 0, /*int flags,*/
  9558. __pyx_empty_bytes, /*PyObject *code,*/
  9559. __pyx_empty_tuple, /*PyObject *consts,*/
  9560. __pyx_empty_tuple, /*PyObject *names,*/
  9561. __pyx_empty_tuple, /*PyObject *varnames,*/
  9562. __pyx_empty_tuple, /*PyObject *freevars,*/
  9563. __pyx_empty_tuple, /*PyObject *cellvars,*/
  9564. py_srcfile, /*PyObject *filename,*/
  9565. py_funcname, /*PyObject *name,*/
  9566. __pyx_lineno, /*int firstlineno,*/
  9567. __pyx_empty_bytes /*PyObject *lnotab*/
  9568. );
  9569. if (!py_code) goto bad;
  9570. py_frame = PyFrame_New(
  9571. PyThreadState_GET(), /*PyThreadState *tstate,*/
  9572. py_code, /*PyCodeObject *code,*/
  9573. py_globals, /*PyObject *globals,*/
  9574. 0 /*PyObject *locals*/
  9575. );
  9576. if (!py_frame) goto bad;
  9577. py_frame->f_lineno = __pyx_lineno;
  9578. PyTraceBack_Here(py_frame);
  9579. bad:
  9580. Py_XDECREF(py_srcfile);
  9581. Py_XDECREF(py_funcname);
  9582. Py_XDECREF(py_code);
  9583. Py_XDECREF(py_frame);
  9584. }
  9585. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  9586. while (t->p) {
  9587. #if PY_MAJOR_VERSION < 3
  9588. if (t->is_unicode) {
  9589. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  9590. } else if (t->intern) {
  9591. *t->p = PyString_InternFromString(t->s);
  9592. } else {
  9593. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  9594. }
  9595. #else /* Python 3+ has unicode identifiers */
  9596. if (t->is_unicode | t->is_str) {
  9597. if (t->intern) {
  9598. *t->p = PyUnicode_InternFromString(t->s);
  9599. } else if (t->encoding) {
  9600. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  9601. } else {
  9602. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  9603. }
  9604. } else {
  9605. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  9606. }
  9607. #endif
  9608. if (!*t->p)
  9609. return -1;
  9610. ++t;
  9611. }
  9612. return 0;
  9613. }
  9614. /* Type Conversion Functions */
  9615. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  9616. int is_true = x == Py_True;
  9617. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  9618. else return PyObject_IsTrue(x);
  9619. }
  9620. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  9621. PyNumberMethods *m;
  9622. const char *name = NULL;
  9623. PyObject *res = NULL;
  9624. #if PY_VERSION_HEX < 0x03000000
  9625. if (PyInt_Check(x) || PyLong_Check(x))
  9626. #else
  9627. if (PyLong_Check(x))
  9628. #endif
  9629. return Py_INCREF(x), x;
  9630. m = Py_TYPE(x)->tp_as_number;
  9631. #if PY_VERSION_HEX < 0x03000000
  9632. if (m && m->nb_int) {
  9633. name = "int";
  9634. res = PyNumber_Int(x);
  9635. }
  9636. else if (m && m->nb_long) {
  9637. name = "long";
  9638. res = PyNumber_Long(x);
  9639. }
  9640. #else
  9641. if (m && m->nb_int) {
  9642. name = "int";
  9643. res = PyNumber_Long(x);
  9644. }
  9645. #endif
  9646. if (res) {
  9647. #if PY_VERSION_HEX < 0x03000000
  9648. if (!PyInt_Check(res) && !PyLong_Check(res)) {
  9649. #else
  9650. if (!PyLong_Check(res)) {
  9651. #endif
  9652. PyErr_Format(PyExc_TypeError,
  9653. "__%s__ returned non-%s (type %.200s)",
  9654. name, name, Py_TYPE(res)->tp_name);
  9655. Py_DECREF(res);
  9656. return NULL;
  9657. }
  9658. }
  9659. else if (!PyErr_Occurred()) {
  9660. PyErr_SetString(PyExc_TypeError,
  9661. "an integer is required");
  9662. }
  9663. return res;
  9664. }
  9665. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  9666. Py_ssize_t ival;
  9667. PyObject* x = PyNumber_Index(b);
  9668. if (!x) return -1;
  9669. ival = PyInt_AsSsize_t(x);
  9670. Py_DECREF(x);
  9671. return ival;
  9672. }
  9673. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  9674. #if PY_VERSION_HEX < 0x02050000
  9675. if (ival <= LONG_MAX)
  9676. return PyInt_FromLong((long)ival);
  9677. else {
  9678. unsigned char *bytes = (unsigned char *) &ival;
  9679. int one = 1; int little = (int)*(unsigned char*)&one;
  9680. return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
  9681. }
  9682. #else
  9683. return PyInt_FromSize_t(ival);
  9684. #endif
  9685. }
  9686. static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
  9687. unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
  9688. if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
  9689. return (size_t)-1;
  9690. } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
  9691. PyErr_SetString(PyExc_OverflowError,
  9692. "value too large to convert to size_t");
  9693. return (size_t)-1;
  9694. }
  9695. return (size_t)val;
  9696. }
  9697. #endif /* Py_PYTHON_H */