Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wiseplat
GitHub Repository: wiseplat/python-code
Path: blob/master/ invest-robot-contest_TinkoffBotTwitch-main/venv/lib/python3.8/site-packages/aiohttp/_websocket.c
7763 views
1
/* Generated by Cython 0.29.24 */
2
3
#ifndef PY_SSIZE_T_CLEAN
4
#define PY_SSIZE_T_CLEAN
5
#endif /* PY_SSIZE_T_CLEAN */
6
#include "Python.h"
7
#ifndef Py_PYTHON_H
8
#error Python headers needed to compile C extensions, please install development version of Python.
9
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
10
#error Cython requires Python 2.6+ or Python 3.3+.
11
#else
12
#define CYTHON_ABI "0_29_24"
13
#define CYTHON_HEX_VERSION 0x001D18F0
14
#define CYTHON_FUTURE_DIVISION 1
15
#include <stddef.h>
16
#ifndef offsetof
17
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
18
#endif
19
#if !defined(WIN32) && !defined(MS_WINDOWS)
20
#ifndef __stdcall
21
#define __stdcall
22
#endif
23
#ifndef __cdecl
24
#define __cdecl
25
#endif
26
#ifndef __fastcall
27
#define __fastcall
28
#endif
29
#endif
30
#ifndef DL_IMPORT
31
#define DL_IMPORT(t) t
32
#endif
33
#ifndef DL_EXPORT
34
#define DL_EXPORT(t) t
35
#endif
36
#define __PYX_COMMA ,
37
#ifndef HAVE_LONG_LONG
38
#if PY_VERSION_HEX >= 0x02070000
39
#define HAVE_LONG_LONG
40
#endif
41
#endif
42
#ifndef PY_LONG_LONG
43
#define PY_LONG_LONG LONG_LONG
44
#endif
45
#ifndef Py_HUGE_VAL
46
#define Py_HUGE_VAL HUGE_VAL
47
#endif
48
#ifdef PYPY_VERSION
49
#define CYTHON_COMPILING_IN_PYPY 1
50
#define CYTHON_COMPILING_IN_PYSTON 0
51
#define CYTHON_COMPILING_IN_CPYTHON 0
52
#undef CYTHON_USE_TYPE_SLOTS
53
#define CYTHON_USE_TYPE_SLOTS 0
54
#undef CYTHON_USE_PYTYPE_LOOKUP
55
#define CYTHON_USE_PYTYPE_LOOKUP 0
56
#if PY_VERSION_HEX < 0x03050000
57
#undef CYTHON_USE_ASYNC_SLOTS
58
#define CYTHON_USE_ASYNC_SLOTS 0
59
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
60
#define CYTHON_USE_ASYNC_SLOTS 1
61
#endif
62
#undef CYTHON_USE_PYLIST_INTERNALS
63
#define CYTHON_USE_PYLIST_INTERNALS 0
64
#undef CYTHON_USE_UNICODE_INTERNALS
65
#define CYTHON_USE_UNICODE_INTERNALS 0
66
#undef CYTHON_USE_UNICODE_WRITER
67
#define CYTHON_USE_UNICODE_WRITER 0
68
#undef CYTHON_USE_PYLONG_INTERNALS
69
#define CYTHON_USE_PYLONG_INTERNALS 0
70
#undef CYTHON_AVOID_BORROWED_REFS
71
#define CYTHON_AVOID_BORROWED_REFS 1
72
#undef CYTHON_ASSUME_SAFE_MACROS
73
#define CYTHON_ASSUME_SAFE_MACROS 0
74
#undef CYTHON_UNPACK_METHODS
75
#define CYTHON_UNPACK_METHODS 0
76
#undef CYTHON_FAST_THREAD_STATE
77
#define CYTHON_FAST_THREAD_STATE 0
78
#undef CYTHON_FAST_PYCALL
79
#define CYTHON_FAST_PYCALL 0
80
#undef CYTHON_PEP489_MULTI_PHASE_INIT
81
#define CYTHON_PEP489_MULTI_PHASE_INIT 0
82
#undef CYTHON_USE_TP_FINALIZE
83
#define CYTHON_USE_TP_FINALIZE 0
84
#undef CYTHON_USE_DICT_VERSIONS
85
#define CYTHON_USE_DICT_VERSIONS 0
86
#undef CYTHON_USE_EXC_INFO_STACK
87
#define CYTHON_USE_EXC_INFO_STACK 0
88
#elif defined(PYSTON_VERSION)
89
#define CYTHON_COMPILING_IN_PYPY 0
90
#define CYTHON_COMPILING_IN_PYSTON 1
91
#define CYTHON_COMPILING_IN_CPYTHON 0
92
#ifndef CYTHON_USE_TYPE_SLOTS
93
#define CYTHON_USE_TYPE_SLOTS 1
94
#endif
95
#undef CYTHON_USE_PYTYPE_LOOKUP
96
#define CYTHON_USE_PYTYPE_LOOKUP 0
97
#undef CYTHON_USE_ASYNC_SLOTS
98
#define CYTHON_USE_ASYNC_SLOTS 0
99
#undef CYTHON_USE_PYLIST_INTERNALS
100
#define CYTHON_USE_PYLIST_INTERNALS 0
101
#ifndef CYTHON_USE_UNICODE_INTERNALS
102
#define CYTHON_USE_UNICODE_INTERNALS 1
103
#endif
104
#undef CYTHON_USE_UNICODE_WRITER
105
#define CYTHON_USE_UNICODE_WRITER 0
106
#undef CYTHON_USE_PYLONG_INTERNALS
107
#define CYTHON_USE_PYLONG_INTERNALS 0
108
#ifndef CYTHON_AVOID_BORROWED_REFS
109
#define CYTHON_AVOID_BORROWED_REFS 0
110
#endif
111
#ifndef CYTHON_ASSUME_SAFE_MACROS
112
#define CYTHON_ASSUME_SAFE_MACROS 1
113
#endif
114
#ifndef CYTHON_UNPACK_METHODS
115
#define CYTHON_UNPACK_METHODS 1
116
#endif
117
#undef CYTHON_FAST_THREAD_STATE
118
#define CYTHON_FAST_THREAD_STATE 0
119
#undef CYTHON_FAST_PYCALL
120
#define CYTHON_FAST_PYCALL 0
121
#undef CYTHON_PEP489_MULTI_PHASE_INIT
122
#define CYTHON_PEP489_MULTI_PHASE_INIT 0
123
#undef CYTHON_USE_TP_FINALIZE
124
#define CYTHON_USE_TP_FINALIZE 0
125
#undef CYTHON_USE_DICT_VERSIONS
126
#define CYTHON_USE_DICT_VERSIONS 0
127
#undef CYTHON_USE_EXC_INFO_STACK
128
#define CYTHON_USE_EXC_INFO_STACK 0
129
#else
130
#define CYTHON_COMPILING_IN_PYPY 0
131
#define CYTHON_COMPILING_IN_PYSTON 0
132
#define CYTHON_COMPILING_IN_CPYTHON 1
133
#ifndef CYTHON_USE_TYPE_SLOTS
134
#define CYTHON_USE_TYPE_SLOTS 1
135
#endif
136
#if PY_VERSION_HEX < 0x02070000
137
#undef CYTHON_USE_PYTYPE_LOOKUP
138
#define CYTHON_USE_PYTYPE_LOOKUP 0
139
#elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
140
#define CYTHON_USE_PYTYPE_LOOKUP 1
141
#endif
142
#if PY_MAJOR_VERSION < 3
143
#undef CYTHON_USE_ASYNC_SLOTS
144
#define CYTHON_USE_ASYNC_SLOTS 0
145
#elif !defined(CYTHON_USE_ASYNC_SLOTS)
146
#define CYTHON_USE_ASYNC_SLOTS 1
147
#endif
148
#if PY_VERSION_HEX < 0x02070000
149
#undef CYTHON_USE_PYLONG_INTERNALS
150
#define CYTHON_USE_PYLONG_INTERNALS 0
151
#elif !defined(CYTHON_USE_PYLONG_INTERNALS)
152
#define CYTHON_USE_PYLONG_INTERNALS 1
153
#endif
154
#ifndef CYTHON_USE_PYLIST_INTERNALS
155
#define CYTHON_USE_PYLIST_INTERNALS 1
156
#endif
157
#ifndef CYTHON_USE_UNICODE_INTERNALS
158
#define CYTHON_USE_UNICODE_INTERNALS 1
159
#endif
160
#if PY_VERSION_HEX < 0x030300F0
161
#undef CYTHON_USE_UNICODE_WRITER
162
#define CYTHON_USE_UNICODE_WRITER 0
163
#elif !defined(CYTHON_USE_UNICODE_WRITER)
164
#define CYTHON_USE_UNICODE_WRITER 1
165
#endif
166
#ifndef CYTHON_AVOID_BORROWED_REFS
167
#define CYTHON_AVOID_BORROWED_REFS 0
168
#endif
169
#ifndef CYTHON_ASSUME_SAFE_MACROS
170
#define CYTHON_ASSUME_SAFE_MACROS 1
171
#endif
172
#ifndef CYTHON_UNPACK_METHODS
173
#define CYTHON_UNPACK_METHODS 1
174
#endif
175
#ifndef CYTHON_FAST_THREAD_STATE
176
#define CYTHON_FAST_THREAD_STATE 1
177
#endif
178
#ifndef CYTHON_FAST_PYCALL
179
#define CYTHON_FAST_PYCALL 1
180
#endif
181
#ifndef CYTHON_PEP489_MULTI_PHASE_INIT
182
#define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
183
#endif
184
#ifndef CYTHON_USE_TP_FINALIZE
185
#define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
186
#endif
187
#ifndef CYTHON_USE_DICT_VERSIONS
188
#define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
189
#endif
190
#ifndef CYTHON_USE_EXC_INFO_STACK
191
#define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
192
#endif
193
#endif
194
#if !defined(CYTHON_FAST_PYCCALL)
195
#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
196
#endif
197
#if CYTHON_USE_PYLONG_INTERNALS
198
#include "longintrepr.h"
199
#undef SHIFT
200
#undef BASE
201
#undef MASK
202
#ifdef SIZEOF_VOID_P
203
enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
204
#endif
205
#endif
206
#ifndef __has_attribute
207
#define __has_attribute(x) 0
208
#endif
209
#ifndef __has_cpp_attribute
210
#define __has_cpp_attribute(x) 0
211
#endif
212
#ifndef CYTHON_RESTRICT
213
#if defined(__GNUC__)
214
#define CYTHON_RESTRICT __restrict__
215
#elif defined(_MSC_VER) && _MSC_VER >= 1400
216
#define CYTHON_RESTRICT __restrict
217
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
218
#define CYTHON_RESTRICT restrict
219
#else
220
#define CYTHON_RESTRICT
221
#endif
222
#endif
223
#ifndef CYTHON_UNUSED
224
# if defined(__GNUC__)
225
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
226
# define CYTHON_UNUSED __attribute__ ((__unused__))
227
# else
228
# define CYTHON_UNUSED
229
# endif
230
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
231
# define CYTHON_UNUSED __attribute__ ((__unused__))
232
# else
233
# define CYTHON_UNUSED
234
# endif
235
#endif
236
#ifndef CYTHON_MAYBE_UNUSED_VAR
237
# if defined(__cplusplus)
238
template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
239
# else
240
# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
241
# endif
242
#endif
243
#ifndef CYTHON_NCP_UNUSED
244
# if CYTHON_COMPILING_IN_CPYTHON
245
# define CYTHON_NCP_UNUSED
246
# else
247
# define CYTHON_NCP_UNUSED CYTHON_UNUSED
248
# endif
249
#endif
250
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
251
#ifdef _MSC_VER
252
#ifndef _MSC_STDINT_H_
253
#if _MSC_VER < 1300
254
typedef unsigned char uint8_t;
255
typedef unsigned int uint32_t;
256
#else
257
typedef unsigned __int8 uint8_t;
258
typedef unsigned __int32 uint32_t;
259
#endif
260
#endif
261
#else
262
#include <stdint.h>
263
#endif
264
#ifndef CYTHON_FALLTHROUGH
265
#if defined(__cplusplus) && __cplusplus >= 201103L
266
#if __has_cpp_attribute(fallthrough)
267
#define CYTHON_FALLTHROUGH [[fallthrough]]
268
#elif __has_cpp_attribute(clang::fallthrough)
269
#define CYTHON_FALLTHROUGH [[clang::fallthrough]]
270
#elif __has_cpp_attribute(gnu::fallthrough)
271
#define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
272
#endif
273
#endif
274
#ifndef CYTHON_FALLTHROUGH
275
#if __has_attribute(fallthrough)
276
#define CYTHON_FALLTHROUGH __attribute__((fallthrough))
277
#else
278
#define CYTHON_FALLTHROUGH
279
#endif
280
#endif
281
#if defined(__clang__ ) && defined(__apple_build_version__)
282
#if __apple_build_version__ < 7000000
283
#undef CYTHON_FALLTHROUGH
284
#define CYTHON_FALLTHROUGH
285
#endif
286
#endif
287
#endif
288
289
#ifndef CYTHON_INLINE
290
#if defined(__clang__)
291
#define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
292
#elif defined(__GNUC__)
293
#define CYTHON_INLINE __inline__
294
#elif defined(_MSC_VER)
295
#define CYTHON_INLINE __inline
296
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
297
#define CYTHON_INLINE inline
298
#else
299
#define CYTHON_INLINE
300
#endif
301
#endif
302
303
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
304
#define Py_OptimizeFlag 0
305
#endif
306
#define __PYX_BUILD_PY_SSIZE_T "n"
307
#define CYTHON_FORMAT_SSIZE_T "z"
308
#if PY_MAJOR_VERSION < 3
309
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
310
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
311
PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
312
#define __Pyx_DefaultClassType PyClass_Type
313
#else
314
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
315
#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
316
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
317
PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
318
#else
319
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
320
PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
321
#endif
322
#define __Pyx_DefaultClassType PyType_Type
323
#endif
324
#ifndef Py_TPFLAGS_CHECKTYPES
325
#define Py_TPFLAGS_CHECKTYPES 0
326
#endif
327
#ifndef Py_TPFLAGS_HAVE_INDEX
328
#define Py_TPFLAGS_HAVE_INDEX 0
329
#endif
330
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
331
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
332
#endif
333
#ifndef Py_TPFLAGS_HAVE_FINALIZE
334
#define Py_TPFLAGS_HAVE_FINALIZE 0
335
#endif
336
#ifndef METH_STACKLESS
337
#define METH_STACKLESS 0
338
#endif
339
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
340
#ifndef METH_FASTCALL
341
#define METH_FASTCALL 0x80
342
#endif
343
typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
344
typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
345
Py_ssize_t nargs, PyObject *kwnames);
346
#else
347
#define __Pyx_PyCFunctionFast _PyCFunctionFast
348
#define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
349
#endif
350
#if CYTHON_FAST_PYCCALL
351
#define __Pyx_PyFastCFunction_Check(func)\
352
((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
353
#else
354
#define __Pyx_PyFastCFunction_Check(func) 0
355
#endif
356
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
357
#define PyObject_Malloc(s) PyMem_Malloc(s)
358
#define PyObject_Free(p) PyMem_Free(p)
359
#define PyObject_Realloc(p) PyMem_Realloc(p)
360
#endif
361
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
362
#define PyMem_RawMalloc(n) PyMem_Malloc(n)
363
#define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
364
#define PyMem_RawFree(p) PyMem_Free(p)
365
#endif
366
#if CYTHON_COMPILING_IN_PYSTON
367
#define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
368
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
369
#else
370
#define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
371
#define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
372
#endif
373
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
374
#define __Pyx_PyThreadState_Current PyThreadState_GET()
375
#elif PY_VERSION_HEX >= 0x03060000
376
#define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
377
#elif PY_VERSION_HEX >= 0x03000000
378
#define __Pyx_PyThreadState_Current PyThreadState_GET()
379
#else
380
#define __Pyx_PyThreadState_Current _PyThreadState_Current
381
#endif
382
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
383
#include "pythread.h"
384
#define Py_tss_NEEDS_INIT 0
385
typedef int Py_tss_t;
386
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
387
*key = PyThread_create_key();
388
return 0;
389
}
390
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
391
Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
392
*key = Py_tss_NEEDS_INIT;
393
return key;
394
}
395
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
396
PyObject_Free(key);
397
}
398
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
399
return *key != Py_tss_NEEDS_INIT;
400
}
401
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
402
PyThread_delete_key(*key);
403
*key = Py_tss_NEEDS_INIT;
404
}
405
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
406
return PyThread_set_key_value(*key, value);
407
}
408
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
409
return PyThread_get_key_value(*key);
410
}
411
#endif
412
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
413
#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
414
#else
415
#define __Pyx_PyDict_NewPresized(n) PyDict_New()
416
#endif
417
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
418
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
419
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
420
#else
421
#define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
422
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
423
#endif
424
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
425
#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
426
#else
427
#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
428
#endif
429
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
430
#define CYTHON_PEP393_ENABLED 1
431
#if defined(PyUnicode_IS_READY)
432
#define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
433
0 : _PyUnicode_Ready((PyObject *)(op)))
434
#else
435
#define __Pyx_PyUnicode_READY(op) (0)
436
#endif
437
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
438
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
439
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
440
#define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
441
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
442
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
443
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
444
#if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
445
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
446
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
447
#else
448
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
449
#endif
450
#else
451
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
452
#endif
453
#else
454
#define CYTHON_PEP393_ENABLED 0
455
#define PyUnicode_1BYTE_KIND 1
456
#define PyUnicode_2BYTE_KIND 2
457
#define PyUnicode_4BYTE_KIND 4
458
#define __Pyx_PyUnicode_READY(op) (0)
459
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
460
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
461
#define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
462
#define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
463
#define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
464
#define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
465
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
466
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
467
#endif
468
#if CYTHON_COMPILING_IN_PYPY
469
#define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
470
#define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
471
#else
472
#define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
473
#define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
474
PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
475
#endif
476
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
477
#define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
478
#endif
479
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
480
#define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
481
#endif
482
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
483
#define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
484
#endif
485
#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
486
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
487
#if PY_MAJOR_VERSION >= 3
488
#define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
489
#else
490
#define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
491
#endif
492
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
493
#define PyObject_ASCII(o) PyObject_Repr(o)
494
#endif
495
#if PY_MAJOR_VERSION >= 3
496
#define PyBaseString_Type PyUnicode_Type
497
#define PyStringObject PyUnicodeObject
498
#define PyString_Type PyUnicode_Type
499
#define PyString_Check PyUnicode_Check
500
#define PyString_CheckExact PyUnicode_CheckExact
501
#ifndef PyObject_Unicode
502
#define PyObject_Unicode PyObject_Str
503
#endif
504
#endif
505
#if PY_MAJOR_VERSION >= 3
506
#define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
507
#define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
508
#else
509
#define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
510
#define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
511
#endif
512
#ifndef PySet_CheckExact
513
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
514
#endif
515
#if PY_VERSION_HEX >= 0x030900A4
516
#define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
517
#define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
518
#else
519
#define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
520
#define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
521
#endif
522
#if CYTHON_ASSUME_SAFE_MACROS
523
#define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
524
#else
525
#define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
526
#endif
527
#if PY_MAJOR_VERSION >= 3
528
#define PyIntObject PyLongObject
529
#define PyInt_Type PyLong_Type
530
#define PyInt_Check(op) PyLong_Check(op)
531
#define PyInt_CheckExact(op) PyLong_CheckExact(op)
532
#define PyInt_FromString PyLong_FromString
533
#define PyInt_FromUnicode PyLong_FromUnicode
534
#define PyInt_FromLong PyLong_FromLong
535
#define PyInt_FromSize_t PyLong_FromSize_t
536
#define PyInt_FromSsize_t PyLong_FromSsize_t
537
#define PyInt_AsLong PyLong_AsLong
538
#define PyInt_AS_LONG PyLong_AS_LONG
539
#define PyInt_AsSsize_t PyLong_AsSsize_t
540
#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
541
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
542
#define PyNumber_Int PyNumber_Long
543
#endif
544
#if PY_MAJOR_VERSION >= 3
545
#define PyBoolObject PyLongObject
546
#endif
547
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
548
#ifndef PyUnicode_InternFromString
549
#define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
550
#endif
551
#endif
552
#if PY_VERSION_HEX < 0x030200A4
553
typedef long Py_hash_t;
554
#define __Pyx_PyInt_FromHash_t PyInt_FromLong
555
#define __Pyx_PyInt_AsHash_t PyInt_AsLong
556
#else
557
#define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
558
#define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
559
#endif
560
#if PY_MAJOR_VERSION >= 3
561
#define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
562
#else
563
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
564
#endif
565
#if CYTHON_USE_ASYNC_SLOTS
566
#if PY_VERSION_HEX >= 0x030500B1
567
#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
568
#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
569
#else
570
#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
571
#endif
572
#else
573
#define __Pyx_PyType_AsAsync(obj) NULL
574
#endif
575
#ifndef __Pyx_PyAsyncMethodsStruct
576
typedef struct {
577
unaryfunc am_await;
578
unaryfunc am_aiter;
579
unaryfunc am_anext;
580
} __Pyx_PyAsyncMethodsStruct;
581
#endif
582
583
#if defined(WIN32) || defined(MS_WINDOWS)
584
#define _USE_MATH_DEFINES
585
#endif
586
#include <math.h>
587
#ifdef NAN
588
#define __PYX_NAN() ((float) NAN)
589
#else
590
static CYTHON_INLINE float __PYX_NAN() {
591
float value;
592
memset(&value, 0xFF, sizeof(value));
593
return value;
594
}
595
#endif
596
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
597
#define __Pyx_truncl trunc
598
#else
599
#define __Pyx_truncl truncl
600
#endif
601
602
#define __PYX_MARK_ERR_POS(f_index, lineno) \
603
{ __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
604
#define __PYX_ERR(f_index, lineno, Ln_error) \
605
{ __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
606
607
#ifndef __PYX_EXTERN_C
608
#ifdef __cplusplus
609
#define __PYX_EXTERN_C extern "C"
610
#else
611
#define __PYX_EXTERN_C extern
612
#endif
613
#endif
614
615
#define __PYX_HAVE__aiohttp___websocket
616
#define __PYX_HAVE_API__aiohttp___websocket
617
/* Early includes */
618
#include <string.h>
619
#include <stdio.h>
620
#include "pythread.h"
621
#include <stdint.h>
622
#ifdef _OPENMP
623
#include <omp.h>
624
#endif /* _OPENMP */
625
626
#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
627
#define CYTHON_WITHOUT_ASSERTIONS
628
#endif
629
630
typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
631
const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
632
633
#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
634
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
635
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
636
#define __PYX_DEFAULT_STRING_ENCODING ""
637
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
638
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
639
#define __Pyx_uchar_cast(c) ((unsigned char)c)
640
#define __Pyx_long_cast(x) ((long)x)
641
#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
642
(sizeof(type) < sizeof(Py_ssize_t)) ||\
643
(sizeof(type) > sizeof(Py_ssize_t) &&\
644
likely(v < (type)PY_SSIZE_T_MAX ||\
645
v == (type)PY_SSIZE_T_MAX) &&\
646
(!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
647
v == (type)PY_SSIZE_T_MIN))) ||\
648
(sizeof(type) == sizeof(Py_ssize_t) &&\
649
(is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
650
v == (type)PY_SSIZE_T_MAX))) )
651
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
652
return (size_t) i < (size_t) limit;
653
}
654
#if defined (__cplusplus) && __cplusplus >= 201103L
655
#include <cstdlib>
656
#define __Pyx_sst_abs(value) std::abs(value)
657
#elif SIZEOF_INT >= SIZEOF_SIZE_T
658
#define __Pyx_sst_abs(value) abs(value)
659
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
660
#define __Pyx_sst_abs(value) labs(value)
661
#elif defined (_MSC_VER)
662
#define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
663
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
664
#define __Pyx_sst_abs(value) llabs(value)
665
#elif defined (__GNUC__)
666
#define __Pyx_sst_abs(value) __builtin_llabs(value)
667
#else
668
#define __Pyx_sst_abs(value) ((value<0) ? -value : value)
669
#endif
670
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
671
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
672
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
673
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
674
#define __Pyx_PyBytes_FromString PyBytes_FromString
675
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
676
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
677
#if PY_MAJOR_VERSION < 3
678
#define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
679
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
680
#else
681
#define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
682
#define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
683
#endif
684
#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
685
#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
686
#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
687
#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
688
#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
689
#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
690
#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
691
#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
692
#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
693
#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
694
#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
695
#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
696
#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
697
#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
698
#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
699
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
700
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
701
const Py_UNICODE *u_end = u;
702
while (*u_end++) ;
703
return (size_t)(u_end - u - 1);
704
}
705
#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
706
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
707
#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
708
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
709
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
710
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
711
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
712
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
713
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
714
#define __Pyx_PySequence_Tuple(obj)\
715
(likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
716
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
717
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
718
#if CYTHON_ASSUME_SAFE_MACROS
719
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
720
#else
721
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
722
#endif
723
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
724
#if PY_MAJOR_VERSION >= 3
725
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
726
#else
727
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
728
#endif
729
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
730
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
731
static int __Pyx_sys_getdefaultencoding_not_ascii;
732
static int __Pyx_init_sys_getdefaultencoding_params(void) {
733
PyObject* sys;
734
PyObject* default_encoding = NULL;
735
PyObject* ascii_chars_u = NULL;
736
PyObject* ascii_chars_b = NULL;
737
const char* default_encoding_c;
738
sys = PyImport_ImportModule("sys");
739
if (!sys) goto bad;
740
default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
741
Py_DECREF(sys);
742
if (!default_encoding) goto bad;
743
default_encoding_c = PyBytes_AsString(default_encoding);
744
if (!default_encoding_c) goto bad;
745
if (strcmp(default_encoding_c, "ascii") == 0) {
746
__Pyx_sys_getdefaultencoding_not_ascii = 0;
747
} else {
748
char ascii_chars[128];
749
int c;
750
for (c = 0; c < 128; c++) {
751
ascii_chars[c] = c;
752
}
753
__Pyx_sys_getdefaultencoding_not_ascii = 1;
754
ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
755
if (!ascii_chars_u) goto bad;
756
ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
757
if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
758
PyErr_Format(
759
PyExc_ValueError,
760
"This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
761
default_encoding_c);
762
goto bad;
763
}
764
Py_DECREF(ascii_chars_u);
765
Py_DECREF(ascii_chars_b);
766
}
767
Py_DECREF(default_encoding);
768
return 0;
769
bad:
770
Py_XDECREF(default_encoding);
771
Py_XDECREF(ascii_chars_u);
772
Py_XDECREF(ascii_chars_b);
773
return -1;
774
}
775
#endif
776
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
777
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
778
#else
779
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
780
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
781
static char* __PYX_DEFAULT_STRING_ENCODING;
782
static int __Pyx_init_sys_getdefaultencoding_params(void) {
783
PyObject* sys;
784
PyObject* default_encoding = NULL;
785
char* default_encoding_c;
786
sys = PyImport_ImportModule("sys");
787
if (!sys) goto bad;
788
default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
789
Py_DECREF(sys);
790
if (!default_encoding) goto bad;
791
default_encoding_c = PyBytes_AsString(default_encoding);
792
if (!default_encoding_c) goto bad;
793
__PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
794
if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
795
strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
796
Py_DECREF(default_encoding);
797
return 0;
798
bad:
799
Py_XDECREF(default_encoding);
800
return -1;
801
}
802
#endif
803
#endif
804
805
806
/* Test for GCC > 2.95 */
807
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
808
#define likely(x) __builtin_expect(!!(x), 1)
809
#define unlikely(x) __builtin_expect(!!(x), 0)
810
#else /* !__GNUC__ or GCC < 2.95 */
811
#define likely(x) (x)
812
#define unlikely(x) (x)
813
#endif /* __GNUC__ */
814
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
815
816
static PyObject *__pyx_m = NULL;
817
static PyObject *__pyx_d;
818
static PyObject *__pyx_b;
819
static PyObject *__pyx_cython_runtime = NULL;
820
static PyObject *__pyx_empty_tuple;
821
static PyObject *__pyx_empty_bytes;
822
static PyObject *__pyx_empty_unicode;
823
static int __pyx_lineno;
824
static int __pyx_clineno = 0;
825
static const char * __pyx_cfilenm= __FILE__;
826
static const char *__pyx_filename;
827
828
829
static const char *__pyx_f[] = {
830
"aiohttp/_websocket.pyx",
831
"type.pxd",
832
"bool.pxd",
833
"complex.pxd",
834
};
835
836
/*--- Type declarations ---*/
837
838
/* --- Runtime support code (head) --- */
839
/* Refnanny.proto */
840
#ifndef CYTHON_REFNANNY
841
#define CYTHON_REFNANNY 0
842
#endif
843
#if CYTHON_REFNANNY
844
typedef struct {
845
void (*INCREF)(void*, PyObject*, int);
846
void (*DECREF)(void*, PyObject*, int);
847
void (*GOTREF)(void*, PyObject*, int);
848
void (*GIVEREF)(void*, PyObject*, int);
849
void* (*SetupContext)(const char*, int, const char*);
850
void (*FinishContext)(void**);
851
} __Pyx_RefNannyAPIStruct;
852
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
853
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
854
#define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
855
#ifdef WITH_THREAD
856
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
857
if (acquire_gil) {\
858
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
859
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
860
PyGILState_Release(__pyx_gilstate_save);\
861
} else {\
862
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
863
}
864
#else
865
#define __Pyx_RefNannySetupContext(name, acquire_gil)\
866
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
867
#endif
868
#define __Pyx_RefNannyFinishContext()\
869
__Pyx_RefNanny->FinishContext(&__pyx_refnanny)
870
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
871
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
872
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
873
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
874
#define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
875
#define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
876
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
877
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
878
#else
879
#define __Pyx_RefNannyDeclarations
880
#define __Pyx_RefNannySetupContext(name, acquire_gil)
881
#define __Pyx_RefNannyFinishContext()
882
#define __Pyx_INCREF(r) Py_INCREF(r)
883
#define __Pyx_DECREF(r) Py_DECREF(r)
884
#define __Pyx_GOTREF(r)
885
#define __Pyx_GIVEREF(r)
886
#define __Pyx_XINCREF(r) Py_XINCREF(r)
887
#define __Pyx_XDECREF(r) Py_XDECREF(r)
888
#define __Pyx_XGOTREF(r)
889
#define __Pyx_XGIVEREF(r)
890
#endif
891
#define __Pyx_XDECREF_SET(r, v) do {\
892
PyObject *tmp = (PyObject *) r;\
893
r = v; __Pyx_XDECREF(tmp);\
894
} while (0)
895
#define __Pyx_DECREF_SET(r, v) do {\
896
PyObject *tmp = (PyObject *) r;\
897
r = v; __Pyx_DECREF(tmp);\
898
} while (0)
899
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
900
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
901
902
/* PyObjectGetAttrStr.proto */
903
#if CYTHON_USE_TYPE_SLOTS
904
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
905
#else
906
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
907
#endif
908
909
/* GetBuiltinName.proto */
910
static PyObject *__Pyx_GetBuiltinName(PyObject *name);
911
912
/* RaiseArgTupleInvalid.proto */
913
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
914
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
915
916
/* RaiseDoubleKeywords.proto */
917
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
918
919
/* ParseKeywords.proto */
920
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
921
PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
922
const char* function_name);
923
924
/* PyCFunctionFastCall.proto */
925
#if CYTHON_FAST_PYCCALL
926
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
927
#else
928
#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
929
#endif
930
931
/* PyFunctionFastCall.proto */
932
#if CYTHON_FAST_PYCALL
933
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
934
__Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
935
#if 1 || PY_VERSION_HEX < 0x030600B1
936
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
937
#else
938
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
939
#endif
940
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
941
(sizeof(char [1 - 2*!(cond)]) - 1)
942
#ifndef Py_MEMBER_SIZE
943
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
944
#endif
945
static size_t __pyx_pyframe_localsplus_offset = 0;
946
#include "frameobject.h"
947
#define __Pxy_PyFrame_Initialize_Offsets()\
948
((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
949
(void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
950
#define __Pyx_PyFrame_GetLocalsplus(frame)\
951
(assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
952
#endif
953
954
/* PyObjectCall.proto */
955
#if CYTHON_COMPILING_IN_CPYTHON
956
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
957
#else
958
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
959
#endif
960
961
/* PyObjectCallMethO.proto */
962
#if CYTHON_COMPILING_IN_CPYTHON
963
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
964
#endif
965
966
/* PyObjectCallOneArg.proto */
967
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
968
969
/* TypeImport.proto */
970
#ifndef __PYX_HAVE_RT_ImportType_proto
971
#define __PYX_HAVE_RT_ImportType_proto
972
enum __Pyx_ImportType_CheckSize {
973
__Pyx_ImportType_CheckSize_Error = 0,
974
__Pyx_ImportType_CheckSize_Warn = 1,
975
__Pyx_ImportType_CheckSize_Ignore = 2
976
};
977
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
978
#endif
979
980
/* PyDictVersioning.proto */
981
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
982
#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
983
#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
984
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
985
(version_var) = __PYX_GET_DICT_VERSION(dict);\
986
(cache_var) = (value);
987
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
988
static PY_UINT64_T __pyx_dict_version = 0;\
989
static PyObject *__pyx_dict_cached_value = NULL;\
990
if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
991
(VAR) = __pyx_dict_cached_value;\
992
} else {\
993
(VAR) = __pyx_dict_cached_value = (LOOKUP);\
994
__pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
995
}\
996
}
997
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
998
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
999
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
1000
#else
1001
#define __PYX_GET_DICT_VERSION(dict) (0)
1002
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
1003
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
1004
#endif
1005
1006
/* PyThreadStateGet.proto */
1007
#if CYTHON_FAST_THREAD_STATE
1008
#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1009
#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1010
#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1011
#else
1012
#define __Pyx_PyThreadState_declare
1013
#define __Pyx_PyThreadState_assign
1014
#define __Pyx_PyErr_Occurred() PyErr_Occurred()
1015
#endif
1016
1017
/* PyErrFetchRestore.proto */
1018
#if CYTHON_FAST_THREAD_STATE
1019
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1020
#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1021
#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1022
#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1023
#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1024
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1025
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1026
#if CYTHON_COMPILING_IN_CPYTHON
1027
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1028
#else
1029
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1030
#endif
1031
#else
1032
#define __Pyx_PyErr_Clear() PyErr_Clear()
1033
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1034
#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1035
#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1036
#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1037
#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1038
#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1039
#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1040
#endif
1041
1042
/* CLineInTraceback.proto */
1043
#ifdef CYTHON_CLINE_IN_TRACEBACK
1044
#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1045
#else
1046
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1047
#endif
1048
1049
/* CodeObjectCache.proto */
1050
typedef struct {
1051
PyCodeObject* code_object;
1052
int code_line;
1053
} __Pyx_CodeObjectCacheEntry;
1054
struct __Pyx_CodeObjectCache {
1055
int count;
1056
int max_count;
1057
__Pyx_CodeObjectCacheEntry* entries;
1058
};
1059
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1060
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1061
static PyCodeObject *__pyx_find_code_object(int code_line);
1062
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1063
1064
/* AddTraceback.proto */
1065
static void __Pyx_AddTraceback(const char *funcname, int c_line,
1066
int py_line, const char *filename);
1067
1068
/* GCCDiagnostics.proto */
1069
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
1070
#define __Pyx_HAS_GCC_DIAGNOSTIC
1071
#endif
1072
1073
/* CIntToPy.proto */
1074
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1075
1076
/* CIntFromPy.proto */
1077
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1078
1079
/* CIntFromPy.proto */
1080
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1081
1082
/* FastTypeChecks.proto */
1083
#if CYTHON_COMPILING_IN_CPYTHON
1084
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1085
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1086
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1087
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1088
#else
1089
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1090
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1091
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1092
#endif
1093
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1094
1095
/* CheckBinaryVersion.proto */
1096
static int __Pyx_check_binary_version(void);
1097
1098
/* InitStrings.proto */
1099
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1100
1101
1102
/* Module declarations from 'cpython.version' */
1103
1104
/* Module declarations from '__builtin__' */
1105
1106
/* Module declarations from 'cpython.type' */
1107
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
1108
1109
/* Module declarations from 'libc.string' */
1110
1111
/* Module declarations from 'libc.stdio' */
1112
1113
/* Module declarations from 'cpython.object' */
1114
1115
/* Module declarations from 'cpython.ref' */
1116
1117
/* Module declarations from 'cpython.exc' */
1118
1119
/* Module declarations from 'cpython.module' */
1120
1121
/* Module declarations from 'cpython.mem' */
1122
1123
/* Module declarations from 'cpython.tuple' */
1124
1125
/* Module declarations from 'cpython.list' */
1126
1127
/* Module declarations from 'cpython.sequence' */
1128
1129
/* Module declarations from 'cpython.mapping' */
1130
1131
/* Module declarations from 'cpython.iterator' */
1132
1133
/* Module declarations from 'cpython.number' */
1134
1135
/* Module declarations from 'cpython.int' */
1136
1137
/* Module declarations from '__builtin__' */
1138
1139
/* Module declarations from 'cpython.bool' */
1140
static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
1141
1142
/* Module declarations from 'cpython.long' */
1143
1144
/* Module declarations from 'cpython.float' */
1145
1146
/* Module declarations from '__builtin__' */
1147
1148
/* Module declarations from 'cpython.complex' */
1149
static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
1150
1151
/* Module declarations from 'cpython.string' */
1152
1153
/* Module declarations from 'cpython.unicode' */
1154
1155
/* Module declarations from 'cpython.dict' */
1156
1157
/* Module declarations from 'cpython.instance' */
1158
1159
/* Module declarations from 'cpython.function' */
1160
1161
/* Module declarations from 'cpython.method' */
1162
1163
/* Module declarations from 'cpython.weakref' */
1164
1165
/* Module declarations from 'cpython.getargs' */
1166
1167
/* Module declarations from 'cpython.pythread' */
1168
1169
/* Module declarations from 'cpython.pystate' */
1170
1171
/* Module declarations from 'cpython.cobject' */
1172
1173
/* Module declarations from 'cpython.oldbuffer' */
1174
1175
/* Module declarations from 'cpython.set' */
1176
1177
/* Module declarations from 'cpython.buffer' */
1178
1179
/* Module declarations from 'cpython.bytes' */
1180
1181
/* Module declarations from 'cpython.pycapsule' */
1182
1183
/* Module declarations from 'cpython' */
1184
1185
/* Module declarations from 'libc.stdint' */
1186
1187
/* Module declarations from 'aiohttp._websocket' */
1188
#define __Pyx_MODULE_NAME "aiohttp._websocket"
1189
extern int __pyx_module_is_main_aiohttp___websocket;
1190
int __pyx_module_is_main_aiohttp___websocket = 0;
1191
1192
/* Implementation of 'aiohttp._websocket' */
1193
static PyObject *__pyx_builtin_range;
1194
static const char __pyx_k_i[] = "i";
1195
static const char __pyx_k_data[] = "data";
1196
static const char __pyx_k_main[] = "__main__";
1197
static const char __pyx_k_mask[] = "mask";
1198
static const char __pyx_k_name[] = "__name__";
1199
static const char __pyx_k_test[] = "__test__";
1200
static const char __pyx_k_range[] = "range";
1201
static const char __pyx_k_in_buf[] = "in_buf";
1202
static const char __pyx_k_data_len[] = "data_len";
1203
static const char __pyx_k_mask_buf[] = "mask_buf";
1204
static const char __pyx_k_uint32_msk[] = "uint32_msk";
1205
static const char __pyx_k_uint64_msk[] = "uint64_msk";
1206
static const char __pyx_k_aiohttp__websocket[] = "aiohttp._websocket";
1207
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1208
static const char __pyx_k_websocket_mask_cython[] = "_websocket_mask_cython";
1209
static const char __pyx_k_aiohttp__websocket_pyx[] = "aiohttp/_websocket.pyx";
1210
static PyObject *__pyx_n_s_aiohttp__websocket;
1211
static PyObject *__pyx_kp_s_aiohttp__websocket_pyx;
1212
static PyObject *__pyx_n_s_cline_in_traceback;
1213
static PyObject *__pyx_n_s_data;
1214
static PyObject *__pyx_n_s_data_len;
1215
static PyObject *__pyx_n_s_i;
1216
static PyObject *__pyx_n_s_in_buf;
1217
static PyObject *__pyx_n_s_main;
1218
static PyObject *__pyx_n_s_mask;
1219
static PyObject *__pyx_n_s_mask_buf;
1220
static PyObject *__pyx_n_s_name;
1221
static PyObject *__pyx_n_s_range;
1222
static PyObject *__pyx_n_s_test;
1223
static PyObject *__pyx_n_s_uint32_msk;
1224
static PyObject *__pyx_n_s_uint64_msk;
1225
static PyObject *__pyx_n_s_websocket_mask_cython;
1226
static PyObject *__pyx_pf_7aiohttp_10_websocket__websocket_mask_cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mask, PyObject *__pyx_v_data); /* proto */
1227
static PyObject *__pyx_tuple_;
1228
static PyObject *__pyx_codeobj__2;
1229
/* Late includes */
1230
1231
/* "aiohttp/_websocket.pyx":11
1232
*
1233
*
1234
* def _websocket_mask_cython(object mask, object data): # <<<<<<<<<<<<<<
1235
* """Note, this function mutates its `data` argument
1236
* """
1237
*/
1238
1239
/* Python wrapper */
1240
static PyObject *__pyx_pw_7aiohttp_10_websocket_1_websocket_mask_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1241
static char __pyx_doc_7aiohttp_10_websocket__websocket_mask_cython[] = "Note, this function mutates its `data` argument\n ";
1242
static PyMethodDef __pyx_mdef_7aiohttp_10_websocket_1_websocket_mask_cython = {"_websocket_mask_cython", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7aiohttp_10_websocket_1_websocket_mask_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7aiohttp_10_websocket__websocket_mask_cython};
1243
static PyObject *__pyx_pw_7aiohttp_10_websocket_1_websocket_mask_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1244
PyObject *__pyx_v_mask = 0;
1245
PyObject *__pyx_v_data = 0;
1246
int __pyx_lineno = 0;
1247
const char *__pyx_filename = NULL;
1248
int __pyx_clineno = 0;
1249
PyObject *__pyx_r = 0;
1250
__Pyx_RefNannyDeclarations
1251
__Pyx_RefNannySetupContext("_websocket_mask_cython (wrapper)", 0);
1252
{
1253
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mask,&__pyx_n_s_data,0};
1254
PyObject* values[2] = {0,0};
1255
if (unlikely(__pyx_kwds)) {
1256
Py_ssize_t kw_args;
1257
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1258
switch (pos_args) {
1259
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1260
CYTHON_FALLTHROUGH;
1261
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1262
CYTHON_FALLTHROUGH;
1263
case 0: break;
1264
default: goto __pyx_L5_argtuple_error;
1265
}
1266
kw_args = PyDict_Size(__pyx_kwds);
1267
switch (pos_args) {
1268
case 0:
1269
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--;
1270
else goto __pyx_L5_argtuple_error;
1271
CYTHON_FALLTHROUGH;
1272
case 1:
1273
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
1274
else {
1275
__Pyx_RaiseArgtupleInvalid("_websocket_mask_cython", 1, 2, 2, 1); __PYX_ERR(0, 11, __pyx_L3_error)
1276
}
1277
}
1278
if (unlikely(kw_args > 0)) {
1279
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_websocket_mask_cython") < 0)) __PYX_ERR(0, 11, __pyx_L3_error)
1280
}
1281
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
1282
goto __pyx_L5_argtuple_error;
1283
} else {
1284
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1285
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1286
}
1287
__pyx_v_mask = values[0];
1288
__pyx_v_data = values[1];
1289
}
1290
goto __pyx_L4_argument_unpacking_done;
1291
__pyx_L5_argtuple_error:;
1292
__Pyx_RaiseArgtupleInvalid("_websocket_mask_cython", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 11, __pyx_L3_error)
1293
__pyx_L3_error:;
1294
__Pyx_AddTraceback("aiohttp._websocket._websocket_mask_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
1295
__Pyx_RefNannyFinishContext();
1296
return NULL;
1297
__pyx_L4_argument_unpacking_done:;
1298
__pyx_r = __pyx_pf_7aiohttp_10_websocket__websocket_mask_cython(__pyx_self, __pyx_v_mask, __pyx_v_data);
1299
1300
/* function exit code */
1301
__Pyx_RefNannyFinishContext();
1302
return __pyx_r;
1303
}
1304
1305
static PyObject *__pyx_pf_7aiohttp_10_websocket__websocket_mask_cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mask, PyObject *__pyx_v_data) {
1306
Py_ssize_t __pyx_v_data_len;
1307
Py_ssize_t __pyx_v_i;
1308
unsigned char *__pyx_v_in_buf;
1309
unsigned char const *__pyx_v_mask_buf;
1310
uint32_t __pyx_v_uint32_msk;
1311
uint64_t __pyx_v_uint64_msk;
1312
PyObject *__pyx_r = NULL;
1313
__Pyx_RefNannyDeclarations
1314
Py_ssize_t __pyx_t_1;
1315
int __pyx_t_2;
1316
int __pyx_t_3;
1317
PyObject *__pyx_t_4 = NULL;
1318
char *__pyx_t_5;
1319
uint64_t *__pyx_t_6;
1320
long __pyx_t_7;
1321
uint32_t *__pyx_t_8;
1322
Py_ssize_t __pyx_t_9;
1323
Py_ssize_t __pyx_t_10;
1324
Py_ssize_t __pyx_t_11;
1325
int __pyx_lineno = 0;
1326
const char *__pyx_filename = NULL;
1327
int __pyx_clineno = 0;
1328
__Pyx_RefNannySetupContext("_websocket_mask_cython", 0);
1329
__Pyx_INCREF(__pyx_v_mask);
1330
__Pyx_INCREF(__pyx_v_data);
1331
1332
/* "aiohttp/_websocket.pyx":22
1333
* uint64_t uint64_msk
1334
*
1335
* assert len(mask) == 4 # <<<<<<<<<<<<<<
1336
*
1337
* if not isinstance(mask, bytes):
1338
*/
1339
#ifndef CYTHON_WITHOUT_ASSERTIONS
1340
if (unlikely(!Py_OptimizeFlag)) {
1341
__pyx_t_1 = PyObject_Length(__pyx_v_mask); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 22, __pyx_L1_error)
1342
if (unlikely(!((__pyx_t_1 == 4) != 0))) {
1343
PyErr_SetNone(PyExc_AssertionError);
1344
__PYX_ERR(0, 22, __pyx_L1_error)
1345
}
1346
}
1347
#endif
1348
1349
/* "aiohttp/_websocket.pyx":24
1350
* assert len(mask) == 4
1351
*
1352
* if not isinstance(mask, bytes): # <<<<<<<<<<<<<<
1353
* mask = bytes(mask)
1354
*
1355
*/
1356
__pyx_t_2 = PyBytes_Check(__pyx_v_mask);
1357
__pyx_t_3 = ((!(__pyx_t_2 != 0)) != 0);
1358
if (__pyx_t_3) {
1359
1360
/* "aiohttp/_websocket.pyx":25
1361
*
1362
* if not isinstance(mask, bytes):
1363
* mask = bytes(mask) # <<<<<<<<<<<<<<
1364
*
1365
* if isinstance(data, bytearray):
1366
*/
1367
__pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_v_mask); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 25, __pyx_L1_error)
1368
__Pyx_GOTREF(__pyx_t_4);
1369
__Pyx_DECREF_SET(__pyx_v_mask, __pyx_t_4);
1370
__pyx_t_4 = 0;
1371
1372
/* "aiohttp/_websocket.pyx":24
1373
* assert len(mask) == 4
1374
*
1375
* if not isinstance(mask, bytes): # <<<<<<<<<<<<<<
1376
* mask = bytes(mask)
1377
*
1378
*/
1379
}
1380
1381
/* "aiohttp/_websocket.pyx":27
1382
* mask = bytes(mask)
1383
*
1384
* if isinstance(data, bytearray): # <<<<<<<<<<<<<<
1385
* data = <bytearray>data
1386
* else:
1387
*/
1388
__pyx_t_3 = PyByteArray_Check(__pyx_v_data);
1389
__pyx_t_2 = (__pyx_t_3 != 0);
1390
if (__pyx_t_2) {
1391
1392
/* "aiohttp/_websocket.pyx":28
1393
*
1394
* if isinstance(data, bytearray):
1395
* data = <bytearray>data # <<<<<<<<<<<<<<
1396
* else:
1397
* data = bytearray(data)
1398
*/
1399
__pyx_t_4 = __pyx_v_data;
1400
__Pyx_INCREF(__pyx_t_4);
1401
__Pyx_DECREF_SET(__pyx_v_data, __pyx_t_4);
1402
__pyx_t_4 = 0;
1403
1404
/* "aiohttp/_websocket.pyx":27
1405
* mask = bytes(mask)
1406
*
1407
* if isinstance(data, bytearray): # <<<<<<<<<<<<<<
1408
* data = <bytearray>data
1409
* else:
1410
*/
1411
goto __pyx_L4;
1412
}
1413
1414
/* "aiohttp/_websocket.pyx":30
1415
* data = <bytearray>data
1416
* else:
1417
* data = bytearray(data) # <<<<<<<<<<<<<<
1418
*
1419
* data_len = len(data)
1420
*/
1421
/*else*/ {
1422
__pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyByteArray_Type)), __pyx_v_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 30, __pyx_L1_error)
1423
__Pyx_GOTREF(__pyx_t_4);
1424
__Pyx_DECREF_SET(__pyx_v_data, __pyx_t_4);
1425
__pyx_t_4 = 0;
1426
}
1427
__pyx_L4:;
1428
1429
/* "aiohttp/_websocket.pyx":32
1430
* data = bytearray(data)
1431
*
1432
* data_len = len(data) # <<<<<<<<<<<<<<
1433
* in_buf = <unsigned char*>PyByteArray_AsString(data)
1434
* mask_buf = <const unsigned char*>PyBytes_AsString(mask)
1435
*/
1436
__pyx_t_1 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 32, __pyx_L1_error)
1437
__pyx_v_data_len = __pyx_t_1;
1438
1439
/* "aiohttp/_websocket.pyx":33
1440
*
1441
* data_len = len(data)
1442
* in_buf = <unsigned char*>PyByteArray_AsString(data) # <<<<<<<<<<<<<<
1443
* mask_buf = <const unsigned char*>PyBytes_AsString(mask)
1444
* uint32_msk = (<uint32_t*>mask_buf)[0]
1445
*/
1446
if (!(likely(PyByteArray_CheckExact(__pyx_v_data))||((__pyx_v_data) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_v_data)->tp_name), 0))) __PYX_ERR(0, 33, __pyx_L1_error)
1447
__pyx_t_5 = PyByteArray_AsString(((PyObject*)__pyx_v_data)); if (unlikely(__pyx_t_5 == ((char *)NULL))) __PYX_ERR(0, 33, __pyx_L1_error)
1448
__pyx_v_in_buf = ((unsigned char *)__pyx_t_5);
1449
1450
/* "aiohttp/_websocket.pyx":34
1451
* data_len = len(data)
1452
* in_buf = <unsigned char*>PyByteArray_AsString(data)
1453
* mask_buf = <const unsigned char*>PyBytes_AsString(mask) # <<<<<<<<<<<<<<
1454
* uint32_msk = (<uint32_t*>mask_buf)[0]
1455
*
1456
*/
1457
__pyx_t_5 = PyBytes_AsString(__pyx_v_mask); if (unlikely(__pyx_t_5 == ((char *)NULL))) __PYX_ERR(0, 34, __pyx_L1_error)
1458
__pyx_v_mask_buf = ((unsigned char const *)__pyx_t_5);
1459
1460
/* "aiohttp/_websocket.pyx":35
1461
* in_buf = <unsigned char*>PyByteArray_AsString(data)
1462
* mask_buf = <const unsigned char*>PyBytes_AsString(mask)
1463
* uint32_msk = (<uint32_t*>mask_buf)[0] # <<<<<<<<<<<<<<
1464
*
1465
* # TODO: align in_data ptr to achieve even faster speeds
1466
*/
1467
__pyx_v_uint32_msk = (((uint32_t *)__pyx_v_mask_buf)[0]);
1468
1469
/* "aiohttp/_websocket.pyx":40
1470
* # does it need in python ?! malloc() always aligns to sizeof(long) bytes
1471
*
1472
* if sizeof(size_t) >= 8: # <<<<<<<<<<<<<<
1473
* uint64_msk = uint32_msk
1474
* uint64_msk = (uint64_msk << 32) | uint32_msk
1475
*/
1476
__pyx_t_2 = (((sizeof(size_t)) >= 8) != 0);
1477
if (__pyx_t_2) {
1478
1479
/* "aiohttp/_websocket.pyx":41
1480
*
1481
* if sizeof(size_t) >= 8:
1482
* uint64_msk = uint32_msk # <<<<<<<<<<<<<<
1483
* uint64_msk = (uint64_msk << 32) | uint32_msk
1484
*
1485
*/
1486
__pyx_v_uint64_msk = __pyx_v_uint32_msk;
1487
1488
/* "aiohttp/_websocket.pyx":42
1489
* if sizeof(size_t) >= 8:
1490
* uint64_msk = uint32_msk
1491
* uint64_msk = (uint64_msk << 32) | uint32_msk # <<<<<<<<<<<<<<
1492
*
1493
* while data_len >= 8:
1494
*/
1495
__pyx_v_uint64_msk = ((__pyx_v_uint64_msk << 32) | __pyx_v_uint32_msk);
1496
1497
/* "aiohttp/_websocket.pyx":44
1498
* uint64_msk = (uint64_msk << 32) | uint32_msk
1499
*
1500
* while data_len >= 8: # <<<<<<<<<<<<<<
1501
* (<uint64_t*>in_buf)[0] ^= uint64_msk
1502
* in_buf += 8
1503
*/
1504
while (1) {
1505
__pyx_t_2 = ((__pyx_v_data_len >= 8) != 0);
1506
if (!__pyx_t_2) break;
1507
1508
/* "aiohttp/_websocket.pyx":45
1509
*
1510
* while data_len >= 8:
1511
* (<uint64_t*>in_buf)[0] ^= uint64_msk # <<<<<<<<<<<<<<
1512
* in_buf += 8
1513
* data_len -= 8
1514
*/
1515
__pyx_t_6 = ((uint64_t *)__pyx_v_in_buf);
1516
__pyx_t_7 = 0;
1517
(__pyx_t_6[__pyx_t_7]) = ((__pyx_t_6[__pyx_t_7]) ^ __pyx_v_uint64_msk);
1518
1519
/* "aiohttp/_websocket.pyx":46
1520
* while data_len >= 8:
1521
* (<uint64_t*>in_buf)[0] ^= uint64_msk
1522
* in_buf += 8 # <<<<<<<<<<<<<<
1523
* data_len -= 8
1524
*
1525
*/
1526
__pyx_v_in_buf = (__pyx_v_in_buf + 8);
1527
1528
/* "aiohttp/_websocket.pyx":47
1529
* (<uint64_t*>in_buf)[0] ^= uint64_msk
1530
* in_buf += 8
1531
* data_len -= 8 # <<<<<<<<<<<<<<
1532
*
1533
*
1534
*/
1535
__pyx_v_data_len = (__pyx_v_data_len - 8);
1536
}
1537
1538
/* "aiohttp/_websocket.pyx":40
1539
* # does it need in python ?! malloc() always aligns to sizeof(long) bytes
1540
*
1541
* if sizeof(size_t) >= 8: # <<<<<<<<<<<<<<
1542
* uint64_msk = uint32_msk
1543
* uint64_msk = (uint64_msk << 32) | uint32_msk
1544
*/
1545
}
1546
1547
/* "aiohttp/_websocket.pyx":50
1548
*
1549
*
1550
* while data_len >= 4: # <<<<<<<<<<<<<<
1551
* (<uint32_t*>in_buf)[0] ^= uint32_msk
1552
* in_buf += 4
1553
*/
1554
while (1) {
1555
__pyx_t_2 = ((__pyx_v_data_len >= 4) != 0);
1556
if (!__pyx_t_2) break;
1557
1558
/* "aiohttp/_websocket.pyx":51
1559
*
1560
* while data_len >= 4:
1561
* (<uint32_t*>in_buf)[0] ^= uint32_msk # <<<<<<<<<<<<<<
1562
* in_buf += 4
1563
* data_len -= 4
1564
*/
1565
__pyx_t_8 = ((uint32_t *)__pyx_v_in_buf);
1566
__pyx_t_7 = 0;
1567
(__pyx_t_8[__pyx_t_7]) = ((__pyx_t_8[__pyx_t_7]) ^ __pyx_v_uint32_msk);
1568
1569
/* "aiohttp/_websocket.pyx":52
1570
* while data_len >= 4:
1571
* (<uint32_t*>in_buf)[0] ^= uint32_msk
1572
* in_buf += 4 # <<<<<<<<<<<<<<
1573
* data_len -= 4
1574
*
1575
*/
1576
__pyx_v_in_buf = (__pyx_v_in_buf + 4);
1577
1578
/* "aiohttp/_websocket.pyx":53
1579
* (<uint32_t*>in_buf)[0] ^= uint32_msk
1580
* in_buf += 4
1581
* data_len -= 4 # <<<<<<<<<<<<<<
1582
*
1583
* for i in range(0, data_len):
1584
*/
1585
__pyx_v_data_len = (__pyx_v_data_len - 4);
1586
}
1587
1588
/* "aiohttp/_websocket.pyx":55
1589
* data_len -= 4
1590
*
1591
* for i in range(0, data_len): # <<<<<<<<<<<<<<
1592
* in_buf[i] ^= mask_buf[i]
1593
*/
1594
__pyx_t_1 = __pyx_v_data_len;
1595
__pyx_t_9 = __pyx_t_1;
1596
for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
1597
__pyx_v_i = __pyx_t_10;
1598
1599
/* "aiohttp/_websocket.pyx":56
1600
*
1601
* for i in range(0, data_len):
1602
* in_buf[i] ^= mask_buf[i] # <<<<<<<<<<<<<<
1603
*/
1604
__pyx_t_11 = __pyx_v_i;
1605
(__pyx_v_in_buf[__pyx_t_11]) = ((__pyx_v_in_buf[__pyx_t_11]) ^ (__pyx_v_mask_buf[__pyx_v_i]));
1606
}
1607
1608
/* "aiohttp/_websocket.pyx":11
1609
*
1610
*
1611
* def _websocket_mask_cython(object mask, object data): # <<<<<<<<<<<<<<
1612
* """Note, this function mutates its `data` argument
1613
* """
1614
*/
1615
1616
/* function exit code */
1617
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
1618
goto __pyx_L0;
1619
__pyx_L1_error:;
1620
__Pyx_XDECREF(__pyx_t_4);
1621
__Pyx_AddTraceback("aiohttp._websocket._websocket_mask_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
1622
__pyx_r = NULL;
1623
__pyx_L0:;
1624
__Pyx_XDECREF(__pyx_v_mask);
1625
__Pyx_XDECREF(__pyx_v_data);
1626
__Pyx_XGIVEREF(__pyx_r);
1627
__Pyx_RefNannyFinishContext();
1628
return __pyx_r;
1629
}
1630
1631
static PyMethodDef __pyx_methods[] = {
1632
{0, 0, 0, 0}
1633
};
1634
1635
#if PY_MAJOR_VERSION >= 3
1636
#if CYTHON_PEP489_MULTI_PHASE_INIT
1637
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
1638
static int __pyx_pymod_exec__websocket(PyObject* module); /*proto*/
1639
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
1640
{Py_mod_create, (void*)__pyx_pymod_create},
1641
{Py_mod_exec, (void*)__pyx_pymod_exec__websocket},
1642
{0, NULL}
1643
};
1644
#endif
1645
1646
static struct PyModuleDef __pyx_moduledef = {
1647
PyModuleDef_HEAD_INIT,
1648
"_websocket",
1649
0, /* m_doc */
1650
#if CYTHON_PEP489_MULTI_PHASE_INIT
1651
0, /* m_size */
1652
#else
1653
-1, /* m_size */
1654
#endif
1655
__pyx_methods /* m_methods */,
1656
#if CYTHON_PEP489_MULTI_PHASE_INIT
1657
__pyx_moduledef_slots, /* m_slots */
1658
#else
1659
NULL, /* m_reload */
1660
#endif
1661
NULL, /* m_traverse */
1662
NULL, /* m_clear */
1663
NULL /* m_free */
1664
};
1665
#endif
1666
#ifndef CYTHON_SMALL_CODE
1667
#if defined(__clang__)
1668
#define CYTHON_SMALL_CODE
1669
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
1670
#define CYTHON_SMALL_CODE __attribute__((cold))
1671
#else
1672
#define CYTHON_SMALL_CODE
1673
#endif
1674
#endif
1675
1676
static __Pyx_StringTabEntry __pyx_string_tab[] = {
1677
{&__pyx_n_s_aiohttp__websocket, __pyx_k_aiohttp__websocket, sizeof(__pyx_k_aiohttp__websocket), 0, 0, 1, 1},
1678
{&__pyx_kp_s_aiohttp__websocket_pyx, __pyx_k_aiohttp__websocket_pyx, sizeof(__pyx_k_aiohttp__websocket_pyx), 0, 0, 1, 0},
1679
{&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
1680
{&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
1681
{&__pyx_n_s_data_len, __pyx_k_data_len, sizeof(__pyx_k_data_len), 0, 0, 1, 1},
1682
{&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
1683
{&__pyx_n_s_in_buf, __pyx_k_in_buf, sizeof(__pyx_k_in_buf), 0, 0, 1, 1},
1684
{&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
1685
{&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1},
1686
{&__pyx_n_s_mask_buf, __pyx_k_mask_buf, sizeof(__pyx_k_mask_buf), 0, 0, 1, 1},
1687
{&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
1688
{&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
1689
{&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
1690
{&__pyx_n_s_uint32_msk, __pyx_k_uint32_msk, sizeof(__pyx_k_uint32_msk), 0, 0, 1, 1},
1691
{&__pyx_n_s_uint64_msk, __pyx_k_uint64_msk, sizeof(__pyx_k_uint64_msk), 0, 0, 1, 1},
1692
{&__pyx_n_s_websocket_mask_cython, __pyx_k_websocket_mask_cython, sizeof(__pyx_k_websocket_mask_cython), 0, 0, 1, 1},
1693
{0, 0, 0, 0, 0, 0, 0}
1694
};
1695
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
1696
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 55, __pyx_L1_error)
1697
return 0;
1698
__pyx_L1_error:;
1699
return -1;
1700
}
1701
1702
static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
1703
__Pyx_RefNannyDeclarations
1704
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
1705
1706
/* "aiohttp/_websocket.pyx":11
1707
*
1708
*
1709
* def _websocket_mask_cython(object mask, object data): # <<<<<<<<<<<<<<
1710
* """Note, this function mutates its `data` argument
1711
* """
1712
*/
1713
__pyx_tuple_ = PyTuple_Pack(8, __pyx_n_s_mask, __pyx_n_s_data, __pyx_n_s_data_len, __pyx_n_s_i, __pyx_n_s_in_buf, __pyx_n_s_mask_buf, __pyx_n_s_uint32_msk, __pyx_n_s_uint64_msk); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 11, __pyx_L1_error)
1714
__Pyx_GOTREF(__pyx_tuple_);
1715
__Pyx_GIVEREF(__pyx_tuple_);
1716
__pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_aiohttp__websocket_pyx, __pyx_n_s_websocket_mask_cython, 11, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 11, __pyx_L1_error)
1717
__Pyx_RefNannyFinishContext();
1718
return 0;
1719
__pyx_L1_error:;
1720
__Pyx_RefNannyFinishContext();
1721
return -1;
1722
}
1723
1724
static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
1725
if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
1726
return 0;
1727
__pyx_L1_error:;
1728
return -1;
1729
}
1730
1731
static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
1732
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
1733
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
1734
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
1735
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
1736
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
1737
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
1738
1739
static int __Pyx_modinit_global_init_code(void) {
1740
__Pyx_RefNannyDeclarations
1741
__Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
1742
/*--- Global init code ---*/
1743
__Pyx_RefNannyFinishContext();
1744
return 0;
1745
}
1746
1747
static int __Pyx_modinit_variable_export_code(void) {
1748
__Pyx_RefNannyDeclarations
1749
__Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
1750
/*--- Variable export code ---*/
1751
__Pyx_RefNannyFinishContext();
1752
return 0;
1753
}
1754
1755
static int __Pyx_modinit_function_export_code(void) {
1756
__Pyx_RefNannyDeclarations
1757
__Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
1758
/*--- Function export code ---*/
1759
__Pyx_RefNannyFinishContext();
1760
return 0;
1761
}
1762
1763
static int __Pyx_modinit_type_init_code(void) {
1764
__Pyx_RefNannyDeclarations
1765
__Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
1766
/*--- Type init code ---*/
1767
__Pyx_RefNannyFinishContext();
1768
return 0;
1769
}
1770
1771
static int __Pyx_modinit_type_import_code(void) {
1772
__Pyx_RefNannyDeclarations
1773
PyObject *__pyx_t_1 = NULL;
1774
int __pyx_lineno = 0;
1775
const char *__pyx_filename = NULL;
1776
int __pyx_clineno = 0;
1777
__Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
1778
/*--- Type import code ---*/
1779
__pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 9, __pyx_L1_error)
1780
__Pyx_GOTREF(__pyx_t_1);
1781
__pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
1782
#if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
1783
sizeof(PyTypeObject),
1784
#else
1785
sizeof(PyHeapTypeObject),
1786
#endif
1787
__Pyx_ImportType_CheckSize_Warn);
1788
if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(1, 9, __pyx_L1_error)
1789
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1790
__pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 8, __pyx_L1_error)
1791
__Pyx_GOTREF(__pyx_t_1);
1792
__pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), __Pyx_ImportType_CheckSize_Warn);
1793
if (!__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(2, 8, __pyx_L1_error)
1794
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1795
__pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 15, __pyx_L1_error)
1796
__Pyx_GOTREF(__pyx_t_1);
1797
__pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), __Pyx_ImportType_CheckSize_Warn);
1798
if (!__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(3, 15, __pyx_L1_error)
1799
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1800
__Pyx_RefNannyFinishContext();
1801
return 0;
1802
__pyx_L1_error:;
1803
__Pyx_XDECREF(__pyx_t_1);
1804
__Pyx_RefNannyFinishContext();
1805
return -1;
1806
}
1807
1808
static int __Pyx_modinit_variable_import_code(void) {
1809
__Pyx_RefNannyDeclarations
1810
__Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
1811
/*--- Variable import code ---*/
1812
__Pyx_RefNannyFinishContext();
1813
return 0;
1814
}
1815
1816
static int __Pyx_modinit_function_import_code(void) {
1817
__Pyx_RefNannyDeclarations
1818
__Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
1819
/*--- Function import code ---*/
1820
__Pyx_RefNannyFinishContext();
1821
return 0;
1822
}
1823
1824
1825
#ifndef CYTHON_NO_PYINIT_EXPORT
1826
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
1827
#elif PY_MAJOR_VERSION < 3
1828
#ifdef __cplusplus
1829
#define __Pyx_PyMODINIT_FUNC extern "C" void
1830
#else
1831
#define __Pyx_PyMODINIT_FUNC void
1832
#endif
1833
#else
1834
#ifdef __cplusplus
1835
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
1836
#else
1837
#define __Pyx_PyMODINIT_FUNC PyObject *
1838
#endif
1839
#endif
1840
1841
1842
#if PY_MAJOR_VERSION < 3
1843
__Pyx_PyMODINIT_FUNC init_websocket(void) CYTHON_SMALL_CODE; /*proto*/
1844
__Pyx_PyMODINIT_FUNC init_websocket(void)
1845
#else
1846
__Pyx_PyMODINIT_FUNC PyInit__websocket(void) CYTHON_SMALL_CODE; /*proto*/
1847
__Pyx_PyMODINIT_FUNC PyInit__websocket(void)
1848
#if CYTHON_PEP489_MULTI_PHASE_INIT
1849
{
1850
return PyModuleDef_Init(&__pyx_moduledef);
1851
}
1852
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
1853
#if PY_VERSION_HEX >= 0x030700A1
1854
static PY_INT64_T main_interpreter_id = -1;
1855
PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
1856
if (main_interpreter_id == -1) {
1857
main_interpreter_id = current_id;
1858
return (unlikely(current_id == -1)) ? -1 : 0;
1859
} else if (unlikely(main_interpreter_id != current_id))
1860
#else
1861
static PyInterpreterState *main_interpreter = NULL;
1862
PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
1863
if (!main_interpreter) {
1864
main_interpreter = current_interpreter;
1865
} else if (unlikely(main_interpreter != current_interpreter))
1866
#endif
1867
{
1868
PyErr_SetString(
1869
PyExc_ImportError,
1870
"Interpreter change detected - this module can only be loaded into one interpreter per process.");
1871
return -1;
1872
}
1873
return 0;
1874
}
1875
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
1876
PyObject *value = PyObject_GetAttrString(spec, from_name);
1877
int result = 0;
1878
if (likely(value)) {
1879
if (allow_none || value != Py_None) {
1880
result = PyDict_SetItemString(moddict, to_name, value);
1881
}
1882
Py_DECREF(value);
1883
} else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
1884
PyErr_Clear();
1885
} else {
1886
result = -1;
1887
}
1888
return result;
1889
}
1890
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
1891
PyObject *module = NULL, *moddict, *modname;
1892
if (__Pyx_check_single_interpreter())
1893
return NULL;
1894
if (__pyx_m)
1895
return __Pyx_NewRef(__pyx_m);
1896
modname = PyObject_GetAttrString(spec, "name");
1897
if (unlikely(!modname)) goto bad;
1898
module = PyModule_NewObject(modname);
1899
Py_DECREF(modname);
1900
if (unlikely(!module)) goto bad;
1901
moddict = PyModule_GetDict(module);
1902
if (unlikely(!moddict)) goto bad;
1903
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
1904
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
1905
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
1906
if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
1907
return module;
1908
bad:
1909
Py_XDECREF(module);
1910
return NULL;
1911
}
1912
1913
1914
static CYTHON_SMALL_CODE int __pyx_pymod_exec__websocket(PyObject *__pyx_pyinit_module)
1915
#endif
1916
#endif
1917
{
1918
PyObject *__pyx_t_1 = NULL;
1919
int __pyx_lineno = 0;
1920
const char *__pyx_filename = NULL;
1921
int __pyx_clineno = 0;
1922
__Pyx_RefNannyDeclarations
1923
#if CYTHON_PEP489_MULTI_PHASE_INIT
1924
if (__pyx_m) {
1925
if (__pyx_m == __pyx_pyinit_module) return 0;
1926
PyErr_SetString(PyExc_RuntimeError, "Module '_websocket' has already been imported. Re-initialisation is not supported.");
1927
return -1;
1928
}
1929
#elif PY_MAJOR_VERSION >= 3
1930
if (__pyx_m) return __Pyx_NewRef(__pyx_m);
1931
#endif
1932
#if CYTHON_REFNANNY
1933
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
1934
if (!__Pyx_RefNanny) {
1935
PyErr_Clear();
1936
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
1937
if (!__Pyx_RefNanny)
1938
Py_FatalError("failed to import 'refnanny' module");
1939
}
1940
#endif
1941
__Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__websocket(void)", 0);
1942
if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1943
#ifdef __Pxy_PyFrame_Initialize_Offsets
1944
__Pxy_PyFrame_Initialize_Offsets();
1945
#endif
1946
__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
1947
__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
1948
__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
1949
#ifdef __Pyx_CyFunction_USED
1950
if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1951
#endif
1952
#ifdef __Pyx_FusedFunction_USED
1953
if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1954
#endif
1955
#ifdef __Pyx_Coroutine_USED
1956
if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1957
#endif
1958
#ifdef __Pyx_Generator_USED
1959
if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1960
#endif
1961
#ifdef __Pyx_AsyncGen_USED
1962
if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1963
#endif
1964
#ifdef __Pyx_StopAsyncIteration_USED
1965
if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1966
#endif
1967
/*--- Library function declarations ---*/
1968
/*--- Threads initialization code ---*/
1969
#if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
1970
PyEval_InitThreads();
1971
#endif
1972
/*--- Module creation code ---*/
1973
#if CYTHON_PEP489_MULTI_PHASE_INIT
1974
__pyx_m = __pyx_pyinit_module;
1975
Py_INCREF(__pyx_m);
1976
#else
1977
#if PY_MAJOR_VERSION < 3
1978
__pyx_m = Py_InitModule4("_websocket", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
1979
#else
1980
__pyx_m = PyModule_Create(&__pyx_moduledef);
1981
#endif
1982
if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
1983
#endif
1984
__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
1985
Py_INCREF(__pyx_d);
1986
__pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
1987
Py_INCREF(__pyx_b);
1988
__pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
1989
Py_INCREF(__pyx_cython_runtime);
1990
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
1991
/*--- Initialize various global constants etc. ---*/
1992
if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1993
#if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
1994
if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1995
#endif
1996
if (__pyx_module_is_main_aiohttp___websocket) {
1997
if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1998
}
1999
#if PY_MAJOR_VERSION >= 3
2000
{
2001
PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
2002
if (!PyDict_GetItemString(modules, "aiohttp._websocket")) {
2003
if (unlikely(PyDict_SetItemString(modules, "aiohttp._websocket", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
2004
}
2005
}
2006
#endif
2007
/*--- Builtin init code ---*/
2008
if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2009
/*--- Constants init code ---*/
2010
if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2011
/*--- Global type/function init code ---*/
2012
(void)__Pyx_modinit_global_init_code();
2013
(void)__Pyx_modinit_variable_export_code();
2014
(void)__Pyx_modinit_function_export_code();
2015
(void)__Pyx_modinit_type_init_code();
2016
if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
2017
(void)__Pyx_modinit_variable_import_code();
2018
(void)__Pyx_modinit_function_import_code();
2019
/*--- Execution code ---*/
2020
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
2021
if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2022
#endif
2023
2024
/* "aiohttp/_websocket.pyx":11
2025
*
2026
*
2027
* def _websocket_mask_cython(object mask, object data): # <<<<<<<<<<<<<<
2028
* """Note, this function mutates its `data` argument
2029
* """
2030
*/
2031
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7aiohttp_10_websocket_1_websocket_mask_cython, NULL, __pyx_n_s_aiohttp__websocket); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
2032
__Pyx_GOTREF(__pyx_t_1);
2033
if (PyDict_SetItem(__pyx_d, __pyx_n_s_websocket_mask_cython, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
2034
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2035
2036
/* "aiohttp/_websocket.pyx":1
2037
* from cpython cimport PyBytes_AsString # <<<<<<<<<<<<<<
2038
*
2039
*
2040
*/
2041
__pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
2042
__Pyx_GOTREF(__pyx_t_1);
2043
if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
2044
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2045
2046
/*--- Wrapped vars code ---*/
2047
2048
goto __pyx_L0;
2049
__pyx_L1_error:;
2050
__Pyx_XDECREF(__pyx_t_1);
2051
if (__pyx_m) {
2052
if (__pyx_d) {
2053
__Pyx_AddTraceback("init aiohttp._websocket", __pyx_clineno, __pyx_lineno, __pyx_filename);
2054
}
2055
Py_CLEAR(__pyx_m);
2056
} else if (!PyErr_Occurred()) {
2057
PyErr_SetString(PyExc_ImportError, "init aiohttp._websocket");
2058
}
2059
__pyx_L0:;
2060
__Pyx_RefNannyFinishContext();
2061
#if CYTHON_PEP489_MULTI_PHASE_INIT
2062
return (__pyx_m != NULL) ? 0 : -1;
2063
#elif PY_MAJOR_VERSION >= 3
2064
return __pyx_m;
2065
#else
2066
return;
2067
#endif
2068
}
2069
2070
/* --- Runtime support code --- */
2071
/* Refnanny */
2072
#if CYTHON_REFNANNY
2073
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
2074
PyObject *m = NULL, *p = NULL;
2075
void *r = NULL;
2076
m = PyImport_ImportModule(modname);
2077
if (!m) goto end;
2078
p = PyObject_GetAttrString(m, "RefNannyAPI");
2079
if (!p) goto end;
2080
r = PyLong_AsVoidPtr(p);
2081
end:
2082
Py_XDECREF(p);
2083
Py_XDECREF(m);
2084
return (__Pyx_RefNannyAPIStruct *)r;
2085
}
2086
#endif
2087
2088
/* PyObjectGetAttrStr */
2089
#if CYTHON_USE_TYPE_SLOTS
2090
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
2091
PyTypeObject* tp = Py_TYPE(obj);
2092
if (likely(tp->tp_getattro))
2093
return tp->tp_getattro(obj, attr_name);
2094
#if PY_MAJOR_VERSION < 3
2095
if (likely(tp->tp_getattr))
2096
return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
2097
#endif
2098
return PyObject_GetAttr(obj, attr_name);
2099
}
2100
#endif
2101
2102
/* GetBuiltinName */
2103
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
2104
PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
2105
if (unlikely(!result)) {
2106
PyErr_Format(PyExc_NameError,
2107
#if PY_MAJOR_VERSION >= 3
2108
"name '%U' is not defined", name);
2109
#else
2110
"name '%.200s' is not defined", PyString_AS_STRING(name));
2111
#endif
2112
}
2113
return result;
2114
}
2115
2116
/* RaiseArgTupleInvalid */
2117
static void __Pyx_RaiseArgtupleInvalid(
2118
const char* func_name,
2119
int exact,
2120
Py_ssize_t num_min,
2121
Py_ssize_t num_max,
2122
Py_ssize_t num_found)
2123
{
2124
Py_ssize_t num_expected;
2125
const char *more_or_less;
2126
if (num_found < num_min) {
2127
num_expected = num_min;
2128
more_or_less = "at least";
2129
} else {
2130
num_expected = num_max;
2131
more_or_less = "at most";
2132
}
2133
if (exact) {
2134
more_or_less = "exactly";
2135
}
2136
PyErr_Format(PyExc_TypeError,
2137
"%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
2138
func_name, more_or_less, num_expected,
2139
(num_expected == 1) ? "" : "s", num_found);
2140
}
2141
2142
/* RaiseDoubleKeywords */
2143
static void __Pyx_RaiseDoubleKeywordsError(
2144
const char* func_name,
2145
PyObject* kw_name)
2146
{
2147
PyErr_Format(PyExc_TypeError,
2148
#if PY_MAJOR_VERSION >= 3
2149
"%s() got multiple values for keyword argument '%U'", func_name, kw_name);
2150
#else
2151
"%s() got multiple values for keyword argument '%s'", func_name,
2152
PyString_AsString(kw_name));
2153
#endif
2154
}
2155
2156
/* ParseKeywords */
2157
static int __Pyx_ParseOptionalKeywords(
2158
PyObject *kwds,
2159
PyObject **argnames[],
2160
PyObject *kwds2,
2161
PyObject *values[],
2162
Py_ssize_t num_pos_args,
2163
const char* function_name)
2164
{
2165
PyObject *key = 0, *value = 0;
2166
Py_ssize_t pos = 0;
2167
PyObject*** name;
2168
PyObject*** first_kw_arg = argnames + num_pos_args;
2169
while (PyDict_Next(kwds, &pos, &key, &value)) {
2170
name = first_kw_arg;
2171
while (*name && (**name != key)) name++;
2172
if (*name) {
2173
values[name-argnames] = value;
2174
continue;
2175
}
2176
name = first_kw_arg;
2177
#if PY_MAJOR_VERSION < 3
2178
if (likely(PyString_Check(key))) {
2179
while (*name) {
2180
if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
2181
&& _PyString_Eq(**name, key)) {
2182
values[name-argnames] = value;
2183
break;
2184
}
2185
name++;
2186
}
2187
if (*name) continue;
2188
else {
2189
PyObject*** argname = argnames;
2190
while (argname != first_kw_arg) {
2191
if ((**argname == key) || (
2192
(CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
2193
&& _PyString_Eq(**argname, key))) {
2194
goto arg_passed_twice;
2195
}
2196
argname++;
2197
}
2198
}
2199
} else
2200
#endif
2201
if (likely(PyUnicode_Check(key))) {
2202
while (*name) {
2203
int cmp = (**name == key) ? 0 :
2204
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2205
(__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
2206
#endif
2207
PyUnicode_Compare(**name, key);
2208
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2209
if (cmp == 0) {
2210
values[name-argnames] = value;
2211
break;
2212
}
2213
name++;
2214
}
2215
if (*name) continue;
2216
else {
2217
PyObject*** argname = argnames;
2218
while (argname != first_kw_arg) {
2219
int cmp = (**argname == key) ? 0 :
2220
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2221
(__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
2222
#endif
2223
PyUnicode_Compare(**argname, key);
2224
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2225
if (cmp == 0) goto arg_passed_twice;
2226
argname++;
2227
}
2228
}
2229
} else
2230
goto invalid_keyword_type;
2231
if (kwds2) {
2232
if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
2233
} else {
2234
goto invalid_keyword;
2235
}
2236
}
2237
return 0;
2238
arg_passed_twice:
2239
__Pyx_RaiseDoubleKeywordsError(function_name, key);
2240
goto bad;
2241
invalid_keyword_type:
2242
PyErr_Format(PyExc_TypeError,
2243
"%.200s() keywords must be strings", function_name);
2244
goto bad;
2245
invalid_keyword:
2246
PyErr_Format(PyExc_TypeError,
2247
#if PY_MAJOR_VERSION < 3
2248
"%.200s() got an unexpected keyword argument '%.200s'",
2249
function_name, PyString_AsString(key));
2250
#else
2251
"%s() got an unexpected keyword argument '%U'",
2252
function_name, key);
2253
#endif
2254
bad:
2255
return -1;
2256
}
2257
2258
/* PyCFunctionFastCall */
2259
#if CYTHON_FAST_PYCCALL
2260
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
2261
PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
2262
PyCFunction meth = PyCFunction_GET_FUNCTION(func);
2263
PyObject *self = PyCFunction_GET_SELF(func);
2264
int flags = PyCFunction_GET_FLAGS(func);
2265
assert(PyCFunction_Check(func));
2266
assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
2267
assert(nargs >= 0);
2268
assert(nargs == 0 || args != NULL);
2269
/* _PyCFunction_FastCallDict() must not be called with an exception set,
2270
because it may clear it (directly or indirectly) and so the
2271
caller loses its exception */
2272
assert(!PyErr_Occurred());
2273
if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
2274
return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
2275
} else {
2276
return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
2277
}
2278
}
2279
#endif
2280
2281
/* PyFunctionFastCall */
2282
#if CYTHON_FAST_PYCALL
2283
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
2284
PyObject *globals) {
2285
PyFrameObject *f;
2286
PyThreadState *tstate = __Pyx_PyThreadState_Current;
2287
PyObject **fastlocals;
2288
Py_ssize_t i;
2289
PyObject *result;
2290
assert(globals != NULL);
2291
/* XXX Perhaps we should create a specialized
2292
PyFrame_New() that doesn't take locals, but does
2293
take builtins without sanity checking them.
2294
*/
2295
assert(tstate != NULL);
2296
f = PyFrame_New(tstate, co, globals, NULL);
2297
if (f == NULL) {
2298
return NULL;
2299
}
2300
fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
2301
for (i = 0; i < na; i++) {
2302
Py_INCREF(*args);
2303
fastlocals[i] = *args++;
2304
}
2305
result = PyEval_EvalFrameEx(f,0);
2306
++tstate->recursion_depth;
2307
Py_DECREF(f);
2308
--tstate->recursion_depth;
2309
return result;
2310
}
2311
#if 1 || PY_VERSION_HEX < 0x030600B1
2312
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
2313
PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
2314
PyObject *globals = PyFunction_GET_GLOBALS(func);
2315
PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
2316
PyObject *closure;
2317
#if PY_MAJOR_VERSION >= 3
2318
PyObject *kwdefs;
2319
#endif
2320
PyObject *kwtuple, **k;
2321
PyObject **d;
2322
Py_ssize_t nd;
2323
Py_ssize_t nk;
2324
PyObject *result;
2325
assert(kwargs == NULL || PyDict_Check(kwargs));
2326
nk = kwargs ? PyDict_Size(kwargs) : 0;
2327
if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
2328
return NULL;
2329
}
2330
if (
2331
#if PY_MAJOR_VERSION >= 3
2332
co->co_kwonlyargcount == 0 &&
2333
#endif
2334
likely(kwargs == NULL || nk == 0) &&
2335
co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
2336
if (argdefs == NULL && co->co_argcount == nargs) {
2337
result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
2338
goto done;
2339
}
2340
else if (nargs == 0 && argdefs != NULL
2341
&& co->co_argcount == Py_SIZE(argdefs)) {
2342
/* function called with no arguments, but all parameters have
2343
a default value: use default values as arguments .*/
2344
args = &PyTuple_GET_ITEM(argdefs, 0);
2345
result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
2346
goto done;
2347
}
2348
}
2349
if (kwargs != NULL) {
2350
Py_ssize_t pos, i;
2351
kwtuple = PyTuple_New(2 * nk);
2352
if (kwtuple == NULL) {
2353
result = NULL;
2354
goto done;
2355
}
2356
k = &PyTuple_GET_ITEM(kwtuple, 0);
2357
pos = i = 0;
2358
while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
2359
Py_INCREF(k[i]);
2360
Py_INCREF(k[i+1]);
2361
i += 2;
2362
}
2363
nk = i / 2;
2364
}
2365
else {
2366
kwtuple = NULL;
2367
k = NULL;
2368
}
2369
closure = PyFunction_GET_CLOSURE(func);
2370
#if PY_MAJOR_VERSION >= 3
2371
kwdefs = PyFunction_GET_KW_DEFAULTS(func);
2372
#endif
2373
if (argdefs != NULL) {
2374
d = &PyTuple_GET_ITEM(argdefs, 0);
2375
nd = Py_SIZE(argdefs);
2376
}
2377
else {
2378
d = NULL;
2379
nd = 0;
2380
}
2381
#if PY_MAJOR_VERSION >= 3
2382
result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
2383
args, (int)nargs,
2384
k, (int)nk,
2385
d, (int)nd, kwdefs, closure);
2386
#else
2387
result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
2388
args, (int)nargs,
2389
k, (int)nk,
2390
d, (int)nd, closure);
2391
#endif
2392
Py_XDECREF(kwtuple);
2393
done:
2394
Py_LeaveRecursiveCall();
2395
return result;
2396
}
2397
#endif
2398
#endif
2399
2400
/* PyObjectCall */
2401
#if CYTHON_COMPILING_IN_CPYTHON
2402
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
2403
PyObject *result;
2404
ternaryfunc call = Py_TYPE(func)->tp_call;
2405
if (unlikely(!call))
2406
return PyObject_Call(func, arg, kw);
2407
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
2408
return NULL;
2409
result = (*call)(func, arg, kw);
2410
Py_LeaveRecursiveCall();
2411
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
2412
PyErr_SetString(
2413
PyExc_SystemError,
2414
"NULL result without error in PyObject_Call");
2415
}
2416
return result;
2417
}
2418
#endif
2419
2420
/* PyObjectCallMethO */
2421
#if CYTHON_COMPILING_IN_CPYTHON
2422
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
2423
PyObject *self, *result;
2424
PyCFunction cfunc;
2425
cfunc = PyCFunction_GET_FUNCTION(func);
2426
self = PyCFunction_GET_SELF(func);
2427
if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
2428
return NULL;
2429
result = cfunc(self, arg);
2430
Py_LeaveRecursiveCall();
2431
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
2432
PyErr_SetString(
2433
PyExc_SystemError,
2434
"NULL result without error in PyObject_Call");
2435
}
2436
return result;
2437
}
2438
#endif
2439
2440
/* PyObjectCallOneArg */
2441
#if CYTHON_COMPILING_IN_CPYTHON
2442
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2443
PyObject *result;
2444
PyObject *args = PyTuple_New(1);
2445
if (unlikely(!args)) return NULL;
2446
Py_INCREF(arg);
2447
PyTuple_SET_ITEM(args, 0, arg);
2448
result = __Pyx_PyObject_Call(func, args, NULL);
2449
Py_DECREF(args);
2450
return result;
2451
}
2452
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2453
#if CYTHON_FAST_PYCALL
2454
if (PyFunction_Check(func)) {
2455
return __Pyx_PyFunction_FastCall(func, &arg, 1);
2456
}
2457
#endif
2458
if (likely(PyCFunction_Check(func))) {
2459
if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
2460
return __Pyx_PyObject_CallMethO(func, arg);
2461
#if CYTHON_FAST_PYCCALL
2462
} else if (__Pyx_PyFastCFunction_Check(func)) {
2463
return __Pyx_PyCFunction_FastCall(func, &arg, 1);
2464
#endif
2465
}
2466
}
2467
return __Pyx__PyObject_CallOneArg(func, arg);
2468
}
2469
#else
2470
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2471
PyObject *result;
2472
PyObject *args = PyTuple_Pack(1, arg);
2473
if (unlikely(!args)) return NULL;
2474
result = __Pyx_PyObject_Call(func, args, NULL);
2475
Py_DECREF(args);
2476
return result;
2477
}
2478
#endif
2479
2480
/* TypeImport */
2481
#ifndef __PYX_HAVE_RT_ImportType
2482
#define __PYX_HAVE_RT_ImportType
2483
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
2484
size_t size, enum __Pyx_ImportType_CheckSize check_size)
2485
{
2486
PyObject *result = 0;
2487
char warning[200];
2488
Py_ssize_t basicsize;
2489
#ifdef Py_LIMITED_API
2490
PyObject *py_basicsize;
2491
#endif
2492
result = PyObject_GetAttrString(module, class_name);
2493
if (!result)
2494
goto bad;
2495
if (!PyType_Check(result)) {
2496
PyErr_Format(PyExc_TypeError,
2497
"%.200s.%.200s is not a type object",
2498
module_name, class_name);
2499
goto bad;
2500
}
2501
#ifndef Py_LIMITED_API
2502
basicsize = ((PyTypeObject *)result)->tp_basicsize;
2503
#else
2504
py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
2505
if (!py_basicsize)
2506
goto bad;
2507
basicsize = PyLong_AsSsize_t(py_basicsize);
2508
Py_DECREF(py_basicsize);
2509
py_basicsize = 0;
2510
if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
2511
goto bad;
2512
#endif
2513
if ((size_t)basicsize < size) {
2514
PyErr_Format(PyExc_ValueError,
2515
"%.200s.%.200s size changed, may indicate binary incompatibility. "
2516
"Expected %zd from C header, got %zd from PyObject",
2517
module_name, class_name, size, basicsize);
2518
goto bad;
2519
}
2520
if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
2521
PyErr_Format(PyExc_ValueError,
2522
"%.200s.%.200s size changed, may indicate binary incompatibility. "
2523
"Expected %zd from C header, got %zd from PyObject",
2524
module_name, class_name, size, basicsize);
2525
goto bad;
2526
}
2527
else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
2528
PyOS_snprintf(warning, sizeof(warning),
2529
"%s.%s size changed, may indicate binary incompatibility. "
2530
"Expected %zd from C header, got %zd from PyObject",
2531
module_name, class_name, size, basicsize);
2532
if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
2533
}
2534
return (PyTypeObject *)result;
2535
bad:
2536
Py_XDECREF(result);
2537
return NULL;
2538
}
2539
#endif
2540
2541
/* PyDictVersioning */
2542
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
2543
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
2544
PyObject *dict = Py_TYPE(obj)->tp_dict;
2545
return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
2546
}
2547
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
2548
PyObject **dictptr = NULL;
2549
Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
2550
if (offset) {
2551
#if CYTHON_COMPILING_IN_CPYTHON
2552
dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
2553
#else
2554
dictptr = _PyObject_GetDictPtr(obj);
2555
#endif
2556
}
2557
return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
2558
}
2559
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
2560
PyObject *dict = Py_TYPE(obj)->tp_dict;
2561
if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
2562
return 0;
2563
return obj_dict_version == __Pyx_get_object_dict_version(obj);
2564
}
2565
#endif
2566
2567
/* PyErrFetchRestore */
2568
#if CYTHON_FAST_THREAD_STATE
2569
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
2570
PyObject *tmp_type, *tmp_value, *tmp_tb;
2571
tmp_type = tstate->curexc_type;
2572
tmp_value = tstate->curexc_value;
2573
tmp_tb = tstate->curexc_traceback;
2574
tstate->curexc_type = type;
2575
tstate->curexc_value = value;
2576
tstate->curexc_traceback = tb;
2577
Py_XDECREF(tmp_type);
2578
Py_XDECREF(tmp_value);
2579
Py_XDECREF(tmp_tb);
2580
}
2581
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
2582
*type = tstate->curexc_type;
2583
*value = tstate->curexc_value;
2584
*tb = tstate->curexc_traceback;
2585
tstate->curexc_type = 0;
2586
tstate->curexc_value = 0;
2587
tstate->curexc_traceback = 0;
2588
}
2589
#endif
2590
2591
/* CLineInTraceback */
2592
#ifndef CYTHON_CLINE_IN_TRACEBACK
2593
static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
2594
PyObject *use_cline;
2595
PyObject *ptype, *pvalue, *ptraceback;
2596
#if CYTHON_COMPILING_IN_CPYTHON
2597
PyObject **cython_runtime_dict;
2598
#endif
2599
if (unlikely(!__pyx_cython_runtime)) {
2600
return c_line;
2601
}
2602
__Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
2603
#if CYTHON_COMPILING_IN_CPYTHON
2604
cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
2605
if (likely(cython_runtime_dict)) {
2606
__PYX_PY_DICT_LOOKUP_IF_MODIFIED(
2607
use_cline, *cython_runtime_dict,
2608
__Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
2609
} else
2610
#endif
2611
{
2612
PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
2613
if (use_cline_obj) {
2614
use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
2615
Py_DECREF(use_cline_obj);
2616
} else {
2617
PyErr_Clear();
2618
use_cline = NULL;
2619
}
2620
}
2621
if (!use_cline) {
2622
c_line = 0;
2623
PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
2624
}
2625
else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
2626
c_line = 0;
2627
}
2628
__Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
2629
return c_line;
2630
}
2631
#endif
2632
2633
/* CodeObjectCache */
2634
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
2635
int start = 0, mid = 0, end = count - 1;
2636
if (end >= 0 && code_line > entries[end].code_line) {
2637
return count;
2638
}
2639
while (start < end) {
2640
mid = start + (end - start) / 2;
2641
if (code_line < entries[mid].code_line) {
2642
end = mid;
2643
} else if (code_line > entries[mid].code_line) {
2644
start = mid + 1;
2645
} else {
2646
return mid;
2647
}
2648
}
2649
if (code_line <= entries[mid].code_line) {
2650
return mid;
2651
} else {
2652
return mid + 1;
2653
}
2654
}
2655
static PyCodeObject *__pyx_find_code_object(int code_line) {
2656
PyCodeObject* code_object;
2657
int pos;
2658
if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
2659
return NULL;
2660
}
2661
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
2662
if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
2663
return NULL;
2664
}
2665
code_object = __pyx_code_cache.entries[pos].code_object;
2666
Py_INCREF(code_object);
2667
return code_object;
2668
}
2669
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
2670
int pos, i;
2671
__Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
2672
if (unlikely(!code_line)) {
2673
return;
2674
}
2675
if (unlikely(!entries)) {
2676
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
2677
if (likely(entries)) {
2678
__pyx_code_cache.entries = entries;
2679
__pyx_code_cache.max_count = 64;
2680
__pyx_code_cache.count = 1;
2681
entries[0].code_line = code_line;
2682
entries[0].code_object = code_object;
2683
Py_INCREF(code_object);
2684
}
2685
return;
2686
}
2687
pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
2688
if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
2689
PyCodeObject* tmp = entries[pos].code_object;
2690
entries[pos].code_object = code_object;
2691
Py_DECREF(tmp);
2692
return;
2693
}
2694
if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
2695
int new_max = __pyx_code_cache.max_count + 64;
2696
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
2697
__pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
2698
if (unlikely(!entries)) {
2699
return;
2700
}
2701
__pyx_code_cache.entries = entries;
2702
__pyx_code_cache.max_count = new_max;
2703
}
2704
for (i=__pyx_code_cache.count; i>pos; i--) {
2705
entries[i] = entries[i-1];
2706
}
2707
entries[pos].code_line = code_line;
2708
entries[pos].code_object = code_object;
2709
__pyx_code_cache.count++;
2710
Py_INCREF(code_object);
2711
}
2712
2713
/* AddTraceback */
2714
#include "compile.h"
2715
#include "frameobject.h"
2716
#include "traceback.h"
2717
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
2718
const char *funcname, int c_line,
2719
int py_line, const char *filename) {
2720
PyCodeObject *py_code = 0;
2721
PyObject *py_srcfile = 0;
2722
PyObject *py_funcname = 0;
2723
#if PY_MAJOR_VERSION < 3
2724
py_srcfile = PyString_FromString(filename);
2725
#else
2726
py_srcfile = PyUnicode_FromString(filename);
2727
#endif
2728
if (!py_srcfile) goto bad;
2729
if (c_line) {
2730
#if PY_MAJOR_VERSION < 3
2731
py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
2732
#else
2733
py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
2734
#endif
2735
}
2736
else {
2737
#if PY_MAJOR_VERSION < 3
2738
py_funcname = PyString_FromString(funcname);
2739
#else
2740
py_funcname = PyUnicode_FromString(funcname);
2741
#endif
2742
}
2743
if (!py_funcname) goto bad;
2744
py_code = __Pyx_PyCode_New(
2745
0,
2746
0,
2747
0,
2748
0,
2749
0,
2750
__pyx_empty_bytes, /*PyObject *code,*/
2751
__pyx_empty_tuple, /*PyObject *consts,*/
2752
__pyx_empty_tuple, /*PyObject *names,*/
2753
__pyx_empty_tuple, /*PyObject *varnames,*/
2754
__pyx_empty_tuple, /*PyObject *freevars,*/
2755
__pyx_empty_tuple, /*PyObject *cellvars,*/
2756
py_srcfile, /*PyObject *filename,*/
2757
py_funcname, /*PyObject *name,*/
2758
py_line,
2759
__pyx_empty_bytes /*PyObject *lnotab*/
2760
);
2761
Py_DECREF(py_srcfile);
2762
Py_DECREF(py_funcname);
2763
return py_code;
2764
bad:
2765
Py_XDECREF(py_srcfile);
2766
Py_XDECREF(py_funcname);
2767
return NULL;
2768
}
2769
static void __Pyx_AddTraceback(const char *funcname, int c_line,
2770
int py_line, const char *filename) {
2771
PyCodeObject *py_code = 0;
2772
PyFrameObject *py_frame = 0;
2773
PyThreadState *tstate = __Pyx_PyThreadState_Current;
2774
if (c_line) {
2775
c_line = __Pyx_CLineForTraceback(tstate, c_line);
2776
}
2777
py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
2778
if (!py_code) {
2779
py_code = __Pyx_CreateCodeObjectForTraceback(
2780
funcname, c_line, py_line, filename);
2781
if (!py_code) goto bad;
2782
__pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
2783
}
2784
py_frame = PyFrame_New(
2785
tstate, /*PyThreadState *tstate,*/
2786
py_code, /*PyCodeObject *code,*/
2787
__pyx_d, /*PyObject *globals,*/
2788
0 /*PyObject *locals*/
2789
);
2790
if (!py_frame) goto bad;
2791
__Pyx_PyFrame_SetLineNumber(py_frame, py_line);
2792
PyTraceBack_Here(py_frame);
2793
bad:
2794
Py_XDECREF(py_code);
2795
Py_XDECREF(py_frame);
2796
}
2797
2798
/* CIntToPy */
2799
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
2800
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
2801
#pragma GCC diagnostic push
2802
#pragma GCC diagnostic ignored "-Wconversion"
2803
#endif
2804
const long neg_one = (long) -1, const_zero = (long) 0;
2805
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
2806
#pragma GCC diagnostic pop
2807
#endif
2808
const int is_unsigned = neg_one > const_zero;
2809
if (is_unsigned) {
2810
if (sizeof(long) < sizeof(long)) {
2811
return PyInt_FromLong((long) value);
2812
} else if (sizeof(long) <= sizeof(unsigned long)) {
2813
return PyLong_FromUnsignedLong((unsigned long) value);
2814
#ifdef HAVE_LONG_LONG
2815
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
2816
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
2817
#endif
2818
}
2819
} else {
2820
if (sizeof(long) <= sizeof(long)) {
2821
return PyInt_FromLong((long) value);
2822
#ifdef HAVE_LONG_LONG
2823
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
2824
return PyLong_FromLongLong((PY_LONG_LONG) value);
2825
#endif
2826
}
2827
}
2828
{
2829
int one = 1; int little = (int)*(unsigned char *)&one;
2830
unsigned char *bytes = (unsigned char *)&value;
2831
return _PyLong_FromByteArray(bytes, sizeof(long),
2832
little, !is_unsigned);
2833
}
2834
}
2835
2836
/* CIntFromPyVerify */
2837
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
2838
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
2839
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
2840
__PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
2841
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
2842
{\
2843
func_type value = func_value;\
2844
if (sizeof(target_type) < sizeof(func_type)) {\
2845
if (unlikely(value != (func_type) (target_type) value)) {\
2846
func_type zero = 0;\
2847
if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
2848
return (target_type) -1;\
2849
if (is_unsigned && unlikely(value < zero))\
2850
goto raise_neg_overflow;\
2851
else\
2852
goto raise_overflow;\
2853
}\
2854
}\
2855
return (target_type) value;\
2856
}
2857
2858
/* CIntFromPy */
2859
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
2860
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
2861
#pragma GCC diagnostic push
2862
#pragma GCC diagnostic ignored "-Wconversion"
2863
#endif
2864
const long neg_one = (long) -1, const_zero = (long) 0;
2865
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
2866
#pragma GCC diagnostic pop
2867
#endif
2868
const int is_unsigned = neg_one > const_zero;
2869
#if PY_MAJOR_VERSION < 3
2870
if (likely(PyInt_Check(x))) {
2871
if (sizeof(long) < sizeof(long)) {
2872
__PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
2873
} else {
2874
long val = PyInt_AS_LONG(x);
2875
if (is_unsigned && unlikely(val < 0)) {
2876
goto raise_neg_overflow;
2877
}
2878
return (long) val;
2879
}
2880
} else
2881
#endif
2882
if (likely(PyLong_Check(x))) {
2883
if (is_unsigned) {
2884
#if CYTHON_USE_PYLONG_INTERNALS
2885
const digit* digits = ((PyLongObject*)x)->ob_digit;
2886
switch (Py_SIZE(x)) {
2887
case 0: return (long) 0;
2888
case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
2889
case 2:
2890
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
2891
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
2892
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2893
} else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
2894
return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
2895
}
2896
}
2897
break;
2898
case 3:
2899
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
2900
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
2901
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2902
} else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
2903
return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
2904
}
2905
}
2906
break;
2907
case 4:
2908
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
2909
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
2910
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2911
} else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
2912
return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
2913
}
2914
}
2915
break;
2916
}
2917
#endif
2918
#if CYTHON_COMPILING_IN_CPYTHON
2919
if (unlikely(Py_SIZE(x) < 0)) {
2920
goto raise_neg_overflow;
2921
}
2922
#else
2923
{
2924
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
2925
if (unlikely(result < 0))
2926
return (long) -1;
2927
if (unlikely(result == 1))
2928
goto raise_neg_overflow;
2929
}
2930
#endif
2931
if (sizeof(long) <= sizeof(unsigned long)) {
2932
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
2933
#ifdef HAVE_LONG_LONG
2934
} else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
2935
__PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
2936
#endif
2937
}
2938
} else {
2939
#if CYTHON_USE_PYLONG_INTERNALS
2940
const digit* digits = ((PyLongObject*)x)->ob_digit;
2941
switch (Py_SIZE(x)) {
2942
case 0: return (long) 0;
2943
case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
2944
case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
2945
case -2:
2946
if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
2947
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
2948
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2949
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
2950
return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
2951
}
2952
}
2953
break;
2954
case 2:
2955
if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
2956
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
2957
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2958
} else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
2959
return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
2960
}
2961
}
2962
break;
2963
case -3:
2964
if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
2965
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
2966
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2967
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
2968
return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
2969
}
2970
}
2971
break;
2972
case 3:
2973
if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
2974
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
2975
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2976
} else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
2977
return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
2978
}
2979
}
2980
break;
2981
case -4:
2982
if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
2983
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
2984
__PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2985
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
2986
return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
2987
}
2988
}
2989
break;
2990
case 4:
2991
if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
2992
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
2993
__PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2994
} else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
2995
return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
2996
}
2997
}
2998
break;
2999
}
3000
#endif
3001
if (sizeof(long) <= sizeof(long)) {
3002
__PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
3003
#ifdef HAVE_LONG_LONG
3004
} else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
3005
__PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
3006
#endif
3007
}
3008
}
3009
{
3010
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3011
PyErr_SetString(PyExc_RuntimeError,
3012
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3013
#else
3014
long val;
3015
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
3016
#if PY_MAJOR_VERSION < 3
3017
if (likely(v) && !PyLong_Check(v)) {
3018
PyObject *tmp = v;
3019
v = PyNumber_Long(tmp);
3020
Py_DECREF(tmp);
3021
}
3022
#endif
3023
if (likely(v)) {
3024
int one = 1; int is_little = (int)*(unsigned char *)&one;
3025
unsigned char *bytes = (unsigned char *)&val;
3026
int ret = _PyLong_AsByteArray((PyLongObject *)v,
3027
bytes, sizeof(val),
3028
is_little, !is_unsigned);
3029
Py_DECREF(v);
3030
if (likely(!ret))
3031
return val;
3032
}
3033
#endif
3034
return (long) -1;
3035
}
3036
} else {
3037
long val;
3038
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3039
if (!tmp) return (long) -1;
3040
val = __Pyx_PyInt_As_long(tmp);
3041
Py_DECREF(tmp);
3042
return val;
3043
}
3044
raise_overflow:
3045
PyErr_SetString(PyExc_OverflowError,
3046
"value too large to convert to long");
3047
return (long) -1;
3048
raise_neg_overflow:
3049
PyErr_SetString(PyExc_OverflowError,
3050
"can't convert negative value to long");
3051
return (long) -1;
3052
}
3053
3054
/* CIntFromPy */
3055
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
3056
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3057
#pragma GCC diagnostic push
3058
#pragma GCC diagnostic ignored "-Wconversion"
3059
#endif
3060
const int neg_one = (int) -1, const_zero = (int) 0;
3061
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
3062
#pragma GCC diagnostic pop
3063
#endif
3064
const int is_unsigned = neg_one > const_zero;
3065
#if PY_MAJOR_VERSION < 3
3066
if (likely(PyInt_Check(x))) {
3067
if (sizeof(int) < sizeof(long)) {
3068
__PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
3069
} else {
3070
long val = PyInt_AS_LONG(x);
3071
if (is_unsigned && unlikely(val < 0)) {
3072
goto raise_neg_overflow;
3073
}
3074
return (int) val;
3075
}
3076
} else
3077
#endif
3078
if (likely(PyLong_Check(x))) {
3079
if (is_unsigned) {
3080
#if CYTHON_USE_PYLONG_INTERNALS
3081
const digit* digits = ((PyLongObject*)x)->ob_digit;
3082
switch (Py_SIZE(x)) {
3083
case 0: return (int) 0;
3084
case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
3085
case 2:
3086
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3087
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3088
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3089
} else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
3090
return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3091
}
3092
}
3093
break;
3094
case 3:
3095
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3096
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3097
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3098
} else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
3099
return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3100
}
3101
}
3102
break;
3103
case 4:
3104
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3105
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3106
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3107
} else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
3108
return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
3109
}
3110
}
3111
break;
3112
}
3113
#endif
3114
#if CYTHON_COMPILING_IN_CPYTHON
3115
if (unlikely(Py_SIZE(x) < 0)) {
3116
goto raise_neg_overflow;
3117
}
3118
#else
3119
{
3120
int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
3121
if (unlikely(result < 0))
3122
return (int) -1;
3123
if (unlikely(result == 1))
3124
goto raise_neg_overflow;
3125
}
3126
#endif
3127
if (sizeof(int) <= sizeof(unsigned long)) {
3128
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
3129
#ifdef HAVE_LONG_LONG
3130
} else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
3131
__PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
3132
#endif
3133
}
3134
} else {
3135
#if CYTHON_USE_PYLONG_INTERNALS
3136
const digit* digits = ((PyLongObject*)x)->ob_digit;
3137
switch (Py_SIZE(x)) {
3138
case 0: return (int) 0;
3139
case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
3140
case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
3141
case -2:
3142
if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
3143
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3144
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3145
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3146
return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3147
}
3148
}
3149
break;
3150
case 2:
3151
if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
3152
if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
3153
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3154
} else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3155
return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3156
}
3157
}
3158
break;
3159
case -3:
3160
if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
3161
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3162
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3163
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3164
return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3165
}
3166
}
3167
break;
3168
case 3:
3169
if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
3170
if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
3171
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3172
} else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3173
return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3174
}
3175
}
3176
break;
3177
case -4:
3178
if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
3179
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3180
__PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3181
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3182
return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3183
}
3184
}
3185
break;
3186
case 4:
3187
if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
3188
if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3189
__PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3190
} else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
3191
return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
3192
}
3193
}
3194
break;
3195
}
3196
#endif
3197
if (sizeof(int) <= sizeof(long)) {
3198
__PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
3199
#ifdef HAVE_LONG_LONG
3200
} else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
3201
__PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
3202
#endif
3203
}
3204
}
3205
{
3206
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3207
PyErr_SetString(PyExc_RuntimeError,
3208
"_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3209
#else
3210
int val;
3211
PyObject *v = __Pyx_PyNumber_IntOrLong(x);
3212
#if PY_MAJOR_VERSION < 3
3213
if (likely(v) && !PyLong_Check(v)) {
3214
PyObject *tmp = v;
3215
v = PyNumber_Long(tmp);
3216
Py_DECREF(tmp);
3217
}
3218
#endif
3219
if (likely(v)) {
3220
int one = 1; int is_little = (int)*(unsigned char *)&one;
3221
unsigned char *bytes = (unsigned char *)&val;
3222
int ret = _PyLong_AsByteArray((PyLongObject *)v,
3223
bytes, sizeof(val),
3224
is_little, !is_unsigned);
3225
Py_DECREF(v);
3226
if (likely(!ret))
3227
return val;
3228
}
3229
#endif
3230
return (int) -1;
3231
}
3232
} else {
3233
int val;
3234
PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3235
if (!tmp) return (int) -1;
3236
val = __Pyx_PyInt_As_int(tmp);
3237
Py_DECREF(tmp);
3238
return val;
3239
}
3240
raise_overflow:
3241
PyErr_SetString(PyExc_OverflowError,
3242
"value too large to convert to int");
3243
return (int) -1;
3244
raise_neg_overflow:
3245
PyErr_SetString(PyExc_OverflowError,
3246
"can't convert negative value to int");
3247
return (int) -1;
3248
}
3249
3250
/* FastTypeChecks */
3251
#if CYTHON_COMPILING_IN_CPYTHON
3252
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
3253
while (a) {
3254
a = a->tp_base;
3255
if (a == b)
3256
return 1;
3257
}
3258
return b == &PyBaseObject_Type;
3259
}
3260
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
3261
PyObject *mro;
3262
if (a == b) return 1;
3263
mro = a->tp_mro;
3264
if (likely(mro)) {
3265
Py_ssize_t i, n;
3266
n = PyTuple_GET_SIZE(mro);
3267
for (i = 0; i < n; i++) {
3268
if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
3269
return 1;
3270
}
3271
return 0;
3272
}
3273
return __Pyx_InBases(a, b);
3274
}
3275
#if PY_MAJOR_VERSION == 2
3276
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
3277
PyObject *exception, *value, *tb;
3278
int res;
3279
__Pyx_PyThreadState_declare
3280
__Pyx_PyThreadState_assign
3281
__Pyx_ErrFetch(&exception, &value, &tb);
3282
res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
3283
if (unlikely(res == -1)) {
3284
PyErr_WriteUnraisable(err);
3285
res = 0;
3286
}
3287
if (!res) {
3288
res = PyObject_IsSubclass(err, exc_type2);
3289
if (unlikely(res == -1)) {
3290
PyErr_WriteUnraisable(err);
3291
res = 0;
3292
}
3293
}
3294
__Pyx_ErrRestore(exception, value, tb);
3295
return res;
3296
}
3297
#else
3298
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
3299
int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
3300
if (!res) {
3301
res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
3302
}
3303
return res;
3304
}
3305
#endif
3306
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
3307
Py_ssize_t i, n;
3308
assert(PyExceptionClass_Check(exc_type));
3309
n = PyTuple_GET_SIZE(tuple);
3310
#if PY_MAJOR_VERSION >= 3
3311
for (i=0; i<n; i++) {
3312
if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
3313
}
3314
#endif
3315
for (i=0; i<n; i++) {
3316
PyObject *t = PyTuple_GET_ITEM(tuple, i);
3317
#if PY_MAJOR_VERSION < 3
3318
if (likely(exc_type == t)) return 1;
3319
#endif
3320
if (likely(PyExceptionClass_Check(t))) {
3321
if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
3322
} else {
3323
}
3324
}
3325
return 0;
3326
}
3327
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
3328
if (likely(err == exc_type)) return 1;
3329
if (likely(PyExceptionClass_Check(err))) {
3330
if (likely(PyExceptionClass_Check(exc_type))) {
3331
return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
3332
} else if (likely(PyTuple_Check(exc_type))) {
3333
return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
3334
} else {
3335
}
3336
}
3337
return PyErr_GivenExceptionMatches(err, exc_type);
3338
}
3339
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
3340
assert(PyExceptionClass_Check(exc_type1));
3341
assert(PyExceptionClass_Check(exc_type2));
3342
if (likely(err == exc_type1 || err == exc_type2)) return 1;
3343
if (likely(PyExceptionClass_Check(err))) {
3344
return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
3345
}
3346
return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
3347
}
3348
#endif
3349
3350
/* CheckBinaryVersion */
3351
static int __Pyx_check_binary_version(void) {
3352
char ctversion[4], rtversion[4];
3353
PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
3354
PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
3355
if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
3356
char message[200];
3357
PyOS_snprintf(message, sizeof(message),
3358
"compiletime version %s of module '%.100s' "
3359
"does not match runtime version %s",
3360
ctversion, __Pyx_MODULE_NAME, rtversion);
3361
return PyErr_WarnEx(NULL, message, 1);
3362
}
3363
return 0;
3364
}
3365
3366
/* InitStrings */
3367
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
3368
while (t->p) {
3369
#if PY_MAJOR_VERSION < 3
3370
if (t->is_unicode) {
3371
*t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
3372
} else if (t->intern) {
3373
*t->p = PyString_InternFromString(t->s);
3374
} else {
3375
*t->p = PyString_FromStringAndSize(t->s, t->n - 1);
3376
}
3377
#else
3378
if (t->is_unicode | t->is_str) {
3379
if (t->intern) {
3380
*t->p = PyUnicode_InternFromString(t->s);
3381
} else if (t->encoding) {
3382
*t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
3383
} else {
3384
*t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
3385
}
3386
} else {
3387
*t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
3388
}
3389
#endif
3390
if (!*t->p)
3391
return -1;
3392
if (PyObject_Hash(*t->p) == -1)
3393
return -1;
3394
++t;
3395
}
3396
return 0;
3397
}
3398
3399
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
3400
return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
3401
}
3402
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
3403
Py_ssize_t ignore;
3404
return __Pyx_PyObject_AsStringAndSize(o, &ignore);
3405
}
3406
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
3407
#if !CYTHON_PEP393_ENABLED
3408
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
3409
char* defenc_c;
3410
PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
3411
if (!defenc) return NULL;
3412
defenc_c = PyBytes_AS_STRING(defenc);
3413
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3414
{
3415
char* end = defenc_c + PyBytes_GET_SIZE(defenc);
3416
char* c;
3417
for (c = defenc_c; c < end; c++) {
3418
if ((unsigned char) (*c) >= 128) {
3419
PyUnicode_AsASCIIString(o);
3420
return NULL;
3421
}
3422
}
3423
}
3424
#endif
3425
*length = PyBytes_GET_SIZE(defenc);
3426
return defenc_c;
3427
}
3428
#else
3429
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
3430
if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
3431
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3432
if (likely(PyUnicode_IS_ASCII(o))) {
3433
*length = PyUnicode_GET_LENGTH(o);
3434
return PyUnicode_AsUTF8(o);
3435
} else {
3436
PyUnicode_AsASCIIString(o);
3437
return NULL;
3438
}
3439
#else
3440
return PyUnicode_AsUTF8AndSize(o, length);
3441
#endif
3442
}
3443
#endif
3444
#endif
3445
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
3446
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
3447
if (
3448
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3449
__Pyx_sys_getdefaultencoding_not_ascii &&
3450
#endif
3451
PyUnicode_Check(o)) {
3452
return __Pyx_PyUnicode_AsStringAndSize(o, length);
3453
} else
3454
#endif
3455
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
3456
if (PyByteArray_Check(o)) {
3457
*length = PyByteArray_GET_SIZE(o);
3458
return PyByteArray_AS_STRING(o);
3459
} else
3460
#endif
3461
{
3462
char* result;
3463
int r = PyBytes_AsStringAndSize(o, &result, length);
3464
if (unlikely(r < 0)) {
3465
return NULL;
3466
} else {
3467
return result;
3468
}
3469
}
3470
}
3471
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
3472
int is_true = x == Py_True;
3473
if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
3474
else return PyObject_IsTrue(x);
3475
}
3476
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
3477
int retval;
3478
if (unlikely(!x)) return -1;
3479
retval = __Pyx_PyObject_IsTrue(x);
3480
Py_DECREF(x);
3481
return retval;
3482
}
3483
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
3484
#if PY_MAJOR_VERSION >= 3
3485
if (PyLong_Check(result)) {
3486
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
3487
"__int__ returned non-int (type %.200s). "
3488
"The ability to return an instance of a strict subclass of int "
3489
"is deprecated, and may be removed in a future version of Python.",
3490
Py_TYPE(result)->tp_name)) {
3491
Py_DECREF(result);
3492
return NULL;
3493
}
3494
return result;
3495
}
3496
#endif
3497
PyErr_Format(PyExc_TypeError,
3498
"__%.4s__ returned non-%.4s (type %.200s)",
3499
type_name, type_name, Py_TYPE(result)->tp_name);
3500
Py_DECREF(result);
3501
return NULL;
3502
}
3503
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
3504
#if CYTHON_USE_TYPE_SLOTS
3505
PyNumberMethods *m;
3506
#endif
3507
const char *name = NULL;
3508
PyObject *res = NULL;
3509
#if PY_MAJOR_VERSION < 3
3510
if (likely(PyInt_Check(x) || PyLong_Check(x)))
3511
#else
3512
if (likely(PyLong_Check(x)))
3513
#endif
3514
return __Pyx_NewRef(x);
3515
#if CYTHON_USE_TYPE_SLOTS
3516
m = Py_TYPE(x)->tp_as_number;
3517
#if PY_MAJOR_VERSION < 3
3518
if (m && m->nb_int) {
3519
name = "int";
3520
res = m->nb_int(x);
3521
}
3522
else if (m && m->nb_long) {
3523
name = "long";
3524
res = m->nb_long(x);
3525
}
3526
#else
3527
if (likely(m && m->nb_int)) {
3528
name = "int";
3529
res = m->nb_int(x);
3530
}
3531
#endif
3532
#else
3533
if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
3534
res = PyNumber_Int(x);
3535
}
3536
#endif
3537
if (likely(res)) {
3538
#if PY_MAJOR_VERSION < 3
3539
if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
3540
#else
3541
if (unlikely(!PyLong_CheckExact(res))) {
3542
#endif
3543
return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
3544
}
3545
}
3546
else if (!PyErr_Occurred()) {
3547
PyErr_SetString(PyExc_TypeError,
3548
"an integer is required");
3549
}
3550
return res;
3551
}
3552
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
3553
Py_ssize_t ival;
3554
PyObject *x;
3555
#if PY_MAJOR_VERSION < 3
3556
if (likely(PyInt_CheckExact(b))) {
3557
if (sizeof(Py_ssize_t) >= sizeof(long))
3558
return PyInt_AS_LONG(b);
3559
else
3560
return PyInt_AsSsize_t(b);
3561
}
3562
#endif
3563
if (likely(PyLong_CheckExact(b))) {
3564
#if CYTHON_USE_PYLONG_INTERNALS
3565
const digit* digits = ((PyLongObject*)b)->ob_digit;
3566
const Py_ssize_t size = Py_SIZE(b);
3567
if (likely(__Pyx_sst_abs(size) <= 1)) {
3568
ival = likely(size) ? digits[0] : 0;
3569
if (size == -1) ival = -ival;
3570
return ival;
3571
} else {
3572
switch (size) {
3573
case 2:
3574
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
3575
return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3576
}
3577
break;
3578
case -2:
3579
if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
3580
return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3581
}
3582
break;
3583
case 3:
3584
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
3585
return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3586
}
3587
break;
3588
case -3:
3589
if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
3590
return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3591
}
3592
break;
3593
case 4:
3594
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
3595
return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3596
}
3597
break;
3598
case -4:
3599
if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
3600
return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
3601
}
3602
break;
3603
}
3604
}
3605
#endif
3606
return PyLong_AsSsize_t(b);
3607
}
3608
x = PyNumber_Index(b);
3609
if (!x) return -1;
3610
ival = PyInt_AsSsize_t(x);
3611
Py_DECREF(x);
3612
return ival;
3613
}
3614
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
3615
return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
3616
}
3617
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
3618
return PyInt_FromSize_t(ival);
3619
}
3620
3621
3622
#endif /* Py_PYTHON_H */
3623
3624