Ticket #4247: raiser.diff
| File raiser.diff, 56.0 KB (added by loewis, 3 years ago) |
|---|
-
twisted/test/raiser.c
1 /* Generated by Pyrex 0.9.5.1a on Wed Apr 9 19:55:33 2008*/1 /* Generated by Cython 0.12 on Sat Jan 30 18:57:30 2010 */ 2 2 3 #define PY_SSIZE_T_CLEAN 3 4 #include "Python.h" 4 5 #include "structmember.h" 6 #ifndef Py_PYTHON_H 7 #error Python headers needed to compile C extensions, please install development version of Python. 8 #else 5 9 #ifndef PY_LONG_LONG 6 10 #define PY_LONG_LONG LONG_LONG 7 11 #endif 12 #ifndef DL_EXPORT 13 #define DL_EXPORT(t) t 14 #endif 15 #if PY_VERSION_HEX < 0x02040000 16 #define METH_COEXIST 0 17 #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type) 18 #define PyDict_Contains(d,o) PySequence_Contains(d,o) 19 #endif 20 #if PY_VERSION_HEX < 0x02050000 21 typedef int Py_ssize_t; 22 #define PY_SSIZE_T_MAX INT_MAX 23 #define PY_SSIZE_T_MIN INT_MIN 24 #define PY_FORMAT_SIZE_T "" 25 #define PyInt_FromSsize_t(z) PyInt_FromLong(z) 26 #define PyInt_AsSsize_t(o) PyInt_AsLong(o) 27 #define PyNumber_Index(o) PyNumber_Int(o) 28 #define PyIndex_Check(o) PyNumber_Check(o) 29 #endif 30 #if PY_VERSION_HEX < 0x02060000 31 #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) 32 #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) 33 #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) 34 #define PyVarObject_HEAD_INIT(type, size) \ 35 PyObject_HEAD_INIT(type) size, 36 #define PyType_Modified(t) 37 38 typedef struct { 39 void *buf; 40 PyObject *obj; 41 Py_ssize_t len; 42 Py_ssize_t itemsize; 43 int readonly; 44 int ndim; 45 char *format; 46 Py_ssize_t *shape; 47 Py_ssize_t *strides; 48 Py_ssize_t *suboffsets; 49 void *internal; 50 } Py_buffer; 51 52 #define PyBUF_SIMPLE 0 53 #define PyBUF_WRITABLE 0x0001 54 #define PyBUF_FORMAT 0x0004 55 #define PyBUF_ND 0x0008 56 #define PyBUF_STRIDES (0x0010 | PyBUF_ND) 57 #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) 58 #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) 59 #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) 60 #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) 61 62 #endif 63 #if PY_MAJOR_VERSION < 3 64 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" 65 #else 66 #define __Pyx_BUILTIN_MODULE_NAME "builtins" 67 #endif 68 #if PY_MAJOR_VERSION >= 3 69 #define Py_TPFLAGS_CHECKTYPES 0 70 #define Py_TPFLAGS_HAVE_INDEX 0 71 #endif 72 #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) 73 #define Py_TPFLAGS_HAVE_NEWBUFFER 0 74 #endif 75 #if PY_MAJOR_VERSION >= 3 76 #define PyBaseString_Type PyUnicode_Type 77 #define PyString_Type PyUnicode_Type 78 #define PyString_CheckExact PyUnicode_CheckExact 79 #else 80 #define PyBytes_Type PyString_Type 81 #define PyBytes_CheckExact PyString_CheckExact 82 #endif 83 #if PY_MAJOR_VERSION >= 3 84 #define PyInt_Type PyLong_Type 85 #define PyInt_Check(op) PyLong_Check(op) 86 #define PyInt_CheckExact(op) PyLong_CheckExact(op) 87 #define PyInt_FromString PyLong_FromString 88 #define PyInt_FromUnicode PyLong_FromUnicode 89 #define PyInt_FromLong PyLong_FromLong 90 #define PyInt_FromSize_t PyLong_FromSize_t 91 #define PyInt_FromSsize_t PyLong_FromSsize_t 92 #define PyInt_AsLong PyLong_AsLong 93 #define PyInt_AS_LONG PyLong_AS_LONG 94 #define PyInt_AsSsize_t PyLong_AsSsize_t 95 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask 96 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask 97 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) 98 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) 99 #else 100 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) 101 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) 102 #endif 103 #if PY_MAJOR_VERSION >= 3 104 #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func) 105 #endif 106 #if !defined(WIN32) && !defined(MS_WINDOWS) 107 #ifndef __stdcall 108 #define __stdcall 109 #endif 110 #ifndef __cdecl 111 #define __cdecl 112 #endif 113 #ifndef __fastcall 114 #define __fastcall 115 #endif 116 #else 117 #define _USE_MATH_DEFINES 118 #endif 119 #if PY_VERSION_HEX < 0x02050000 120 #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) 121 #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) 122 #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n))) 123 #else 124 #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n)) 125 #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) 126 #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) 127 #endif 128 #if PY_VERSION_HEX < 0x02050000 129 #define __Pyx_NAMESTR(n) ((char *)(n)) 130 #define __Pyx_DOCSTR(n) ((char *)(n)) 131 #else 132 #define __Pyx_NAMESTR(n) (n) 133 #define __Pyx_DOCSTR(n) (n) 134 #endif 8 135 #ifdef __cplusplus 9 136 #define __PYX_EXTERN_C extern "C" 10 137 #else 11 138 #define __PYX_EXTERN_C extern 12 139 #endif 13 __PYX_EXTERN_C double pow(double, double); 140 #include <math.h> 141 #define __PYX_HAVE_API__twisted__test__raiser 14 142 143 #ifdef __GNUC__ 144 #define INLINE __inline__ 145 #elif _WIN32 146 #define INLINE __inline 147 #else 148 #define INLINE 149 #endif 15 150 16 typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ 17 typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ 151 typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ 18 152 153 154 /* Type Conversion Predeclarations */ 155 156 #if PY_MAJOR_VERSION < 3 157 #define __Pyx_PyBytes_FromString PyString_FromString 158 #define __Pyx_PyBytes_FromStringAndSize PyString_FromStringAndSize 159 #define __Pyx_PyBytes_AsString PyString_AsString 160 #else 161 #define __Pyx_PyBytes_FromString PyBytes_FromString 162 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize 163 #define __Pyx_PyBytes_AsString PyBytes_AsString 164 #endif 165 166 #define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s) 167 #define __Pyx_PyBytes_AsUString(s) ((unsigned char*) __Pyx_PyBytes_AsString(s)) 168 169 #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) 170 static INLINE int __Pyx_PyObject_IsTrue(PyObject*); 171 static INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); 172 173 #if !defined(T_PYSSIZET) 174 #if PY_VERSION_HEX < 0x02050000 175 #define T_PYSSIZET T_INT 176 #elif !defined(T_LONGLONG) 177 #define T_PYSSIZET \ 178 ((sizeof(Py_ssize_t) == sizeof(int)) ? T_INT : \ 179 ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : -1)) 180 #else 181 #define T_PYSSIZET \ 182 ((sizeof(Py_ssize_t) == sizeof(int)) ? T_INT : \ 183 ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : \ 184 ((sizeof(Py_ssize_t) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1))) 185 #endif 186 #endif 187 188 189 #if !defined(T_ULONGLONG) 190 #define __Pyx_T_UNSIGNED_INT(x) \ 191 ((sizeof(x) == sizeof(unsigned char)) ? T_UBYTE : \ 192 ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \ 193 ((sizeof(x) == sizeof(unsigned int)) ? T_UINT : \ 194 ((sizeof(x) == sizeof(unsigned long)) ? T_ULONG : -1)))) 195 #else 196 #define __Pyx_T_UNSIGNED_INT(x) \ 197 ((sizeof(x) == sizeof(unsigned char)) ? T_UBYTE : \ 198 ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \ 199 ((sizeof(x) == sizeof(unsigned int)) ? T_UINT : \ 200 ((sizeof(x) == sizeof(unsigned long)) ? T_ULONG : \ 201 ((sizeof(x) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1))))) 202 #endif 203 #if !defined(T_LONGLONG) 204 #define __Pyx_T_SIGNED_INT(x) \ 205 ((sizeof(x) == sizeof(char)) ? T_BYTE : \ 206 ((sizeof(x) == sizeof(short)) ? T_SHORT : \ 207 ((sizeof(x) == sizeof(int)) ? T_INT : \ 208 ((sizeof(x) == sizeof(long)) ? T_LONG : -1)))) 209 #else 210 #define __Pyx_T_SIGNED_INT(x) \ 211 ((sizeof(x) == sizeof(char)) ? T_BYTE : \ 212 ((sizeof(x) == sizeof(short)) ? T_SHORT : \ 213 ((sizeof(x) == sizeof(int)) ? T_INT : \ 214 ((sizeof(x) == sizeof(long)) ? T_LONG : \ 215 ((sizeof(x) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1))))) 216 #endif 217 218 #define __Pyx_T_FLOATING(x) \ 219 ((sizeof(x) == sizeof(float)) ? T_FLOAT : \ 220 ((sizeof(x) == sizeof(double)) ? T_DOUBLE : -1)) 221 222 #if !defined(T_SIZET) 223 #if !defined(T_ULONGLONG) 224 #define T_SIZET \ 225 ((sizeof(size_t) == sizeof(unsigned int)) ? T_UINT : \ 226 ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : -1)) 227 #else 228 #define T_SIZET \ 229 ((sizeof(size_t) == sizeof(unsigned int)) ? T_UINT : \ 230 ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : \ 231 ((sizeof(size_t) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1))) 232 #endif 233 #endif 234 235 static INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); 236 static INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); 237 static INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); 238 239 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) 240 241 242 #ifdef __GNUC__ 243 /* Test for GCC > 2.95 */ 244 #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 245 #define likely(x) __builtin_expect(!!(x), 1) 246 #define unlikely(x) __builtin_expect(!!(x), 0) 247 #else /* __GNUC__ > 2 ... */ 248 #define likely(x) (x) 249 #define unlikely(x) (x) 250 #endif /* __GNUC__ > 2 ... */ 251 #else /* __GNUC__ */ 252 #define likely(x) (x) 253 #define unlikely(x) (x) 254 #endif /* __GNUC__ */ 255 19 256 static PyObject *__pyx_m; 20 257 static PyObject *__pyx_b; 258 static PyObject *__pyx_empty_tuple; 259 static PyObject *__pyx_empty_bytes; 21 260 static int __pyx_lineno; 22 static char *__pyx_filename; 23 static char **__pyx_f; 261 static int __pyx_clineno = 0; 262 static const char * __pyx_cfilenm= __FILE__; 263 static const char *__pyx_filename; 264 static const char **__pyx_f; 24 265 25 static char __pyx_mdoc[] = "\nA trivial extension that just raises an exception.\nSee L{twisted.test.test_failure.test_failureConstructionWithMungedStackSucceeds}.\n";26 266 267 /* Type declarations */ 268 269 #ifndef CYTHON_REFNANNY 270 #define CYTHON_REFNANNY 0 271 #endif 272 273 #if CYTHON_REFNANNY 274 typedef struct { 275 void (*INCREF)(void*, PyObject*, int); 276 void (*DECREF)(void*, PyObject*, int); 277 void (*GOTREF)(void*, PyObject*, int); 278 void (*GIVEREF)(void*, PyObject*, int); 279 void* (*SetupContext)(const char*, int, const char*); 280 void (*FinishContext)(void**); 281 } __Pyx_RefNannyAPIStruct; 282 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; 283 static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) { 284 PyObject *m = NULL, *p = NULL; 285 void *r = NULL; 286 m = PyImport_ImportModule((char *)modname); 287 if (!m) goto end; 288 p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); 289 if (!p) goto end; 290 r = PyLong_AsVoidPtr(p); 291 end: 292 Py_XDECREF(p); 293 Py_XDECREF(m); 294 return (__Pyx_RefNannyAPIStruct *)r; 295 } 296 #define __Pyx_RefNannySetupContext(name) void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) 297 #define __Pyx_RefNannyFinishContext() __Pyx_RefNanny->FinishContext(&__pyx_refnanny) 298 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 299 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 300 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 301 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) 302 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0) 303 #else 304 #define __Pyx_RefNannySetupContext(name) 305 #define __Pyx_RefNannyFinishContext() 306 #define __Pyx_INCREF(r) Py_INCREF(r) 307 #define __Pyx_DECREF(r) Py_DECREF(r) 308 #define __Pyx_GOTREF(r) 309 #define __Pyx_GIVEREF(r) 310 #define __Pyx_XDECREF(r) Py_XDECREF(r) 311 #endif /* CYTHON_REFNANNY */ 312 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0) 313 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0) 314 27 315 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ 28 316 29 static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, c har *modname); /*proto*/317 static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, const char *modname); /*proto*/ 30 318 319 static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ 320 static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ 321 31 322 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ 32 323 33 static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/324 static INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); 34 325 35 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/326 static INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); 36 327 37 static void __Pyx_AddTraceback(char *funcname); /*proto*/328 static INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *); 38 329 39 /* Declarations from raiser */ 330 static INLINE char __Pyx_PyInt_AsChar(PyObject *); 40 331 332 static INLINE short __Pyx_PyInt_AsShort(PyObject *); 41 333 334 static INLINE int __Pyx_PyInt_AsInt(PyObject *); 42 335 43 /* Implementation of raiser */ 336 static INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *); 44 337 45 static char (__pyx_k2[]) = "\n A speficic exception only used to be identified in tests.\n ";338 static INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *); 46 339 47 static PyObject *__pyx_n_RaiserException; 48 static PyObject *__pyx_n_raiseException; 49 static PyObject *__pyx_n_Exception; 340 static INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *); 50 341 51 static PyObject *__pyx_k2p;342 static INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *); 52 343 53 static PyObject *__pyx_k3p;344 static INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *); 54 345 55 static char (__pyx_k3[]) = "This function is intentionally broken";346 static INLINE long __Pyx_PyInt_AsLong(PyObject *); 56 347 57 static PyObject *__pyx_f_6raiser_raiseException(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ 58 static char __pyx_doc_6raiser_raiseException[] = "\n Raise L{RaiserException}.\n "; 59 static PyObject *__pyx_f_6raiser_raiseException(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { 60 PyObject *__pyx_r; 61 PyObject *__pyx_1 = 0; 62 PyObject *__pyx_2 = 0; 63 PyObject *__pyx_3 = 0; 64 static char *__pyx_argnames[] = {0}; 65 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0; 348 static INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *); 66 349 67 /* "/home/therve/Projects/Twisted/branches/failure-c-extension-3132/twisted/test/raiser.pyx":21 */ 68 __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_RaiserException); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} 69 __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} 70 Py_INCREF(__pyx_k3p); 71 PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k3p); 72 __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} 73 Py_DECREF(__pyx_1); __pyx_1 = 0; 74 Py_DECREF(__pyx_2); __pyx_2 = 0; 75 __Pyx_Raise(__pyx_3, 0, 0); 76 Py_DECREF(__pyx_3); __pyx_3 = 0; 77 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; goto __pyx_L1;} 350 static INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); 78 351 79 __pyx_r = Py_None; Py_INCREF(Py_None); 352 static INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); 353 354 static void __Pyx_AddTraceback(const char *funcname); /*proto*/ 355 356 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ 357 /* Module declarations from b'twisted.test.raiser' */ 358 359 #define __Pyx_MODULE_NAME "twisted.test.raiser" 360 int __pyx_module_is_main_twisted__test__raiser = 0; 361 362 /* Implementation of twisted.test.raiser */ 363 static PyObject *__pyx_builtin_Exception; 364 static char __pyx_k_1[] = "This function is intentionally broken"; 365 static char __pyx_k_2[] = "\nA trivial extension that just raises an exception.\nSee L{twisted.test.test_failure.test_failureConstructionWithMungedStackSucceeds}.\n"; 366 static char __pyx_k_3[] = "\n A speficic exception only used to be identified in tests.\n "; 367 static char __pyx_k_4[] = "raiseException (line 17)"; 368 static char __pyx_k____main__[] = "__main__"; 369 static char __pyx_k____test__[] = "__test__"; 370 static char __pyx_k__Exception[] = "Exception"; 371 static char __pyx_k__raiseException[] = "raiseException"; 372 static char __pyx_k__RaiserException[] = "RaiserException"; 373 static PyObject *__pyx_kp_s_1; 374 static PyObject *__pyx_kp_s_3; 375 static PyObject *__pyx_kp_u_4; 376 static PyObject *__pyx_n_s__Exception; 377 static PyObject *__pyx_n_s__RaiserException; 378 static PyObject *__pyx_n_s____main__; 379 static PyObject *__pyx_n_s____test__; 380 static PyObject *__pyx_n_s__raiseException; 381 382 /* "/home/martin/work/twisted.3k/twisted/test/raiser.pyx":17 383 * 384 * 385 * def raiseException(): # <<<<<<<<<<<<<< 386 * """ 387 * Raise L{RaiserException}. 388 */ 389 390 static PyObject *__pyx_pf_7twisted_4test_6raiser_raiseException(PyObject *__pyx_self, PyObject *unused); /*proto*/ 391 static char __pyx_doc_7twisted_4test_6raiser_raiseException[] = "\n Raise L{RaiserException}.\n "; 392 static PyObject *__pyx_pf_7twisted_4test_6raiser_raiseException(PyObject *__pyx_self, PyObject *unused) { 393 PyObject *__pyx_r = NULL; 394 PyObject *__pyx_t_1 = NULL; 395 PyObject *__pyx_t_2 = NULL; 396 PyObject *__pyx_t_3 = NULL; 397 __Pyx_RefNannySetupContext("raiseException"); 398 __pyx_self = __pyx_self; 399 400 /* "/home/martin/work/twisted.3k/twisted/test/raiser.pyx":21 401 * Raise L{RaiserException}. 402 * """ 403 * raise RaiserException("This function is intentionally broken") # <<<<<<<<<<<<<< 404 */ 405 __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__RaiserException); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 406 __Pyx_GOTREF(__pyx_t_1); 407 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 408 __Pyx_GOTREF(__pyx_t_2); 409 __Pyx_INCREF(((PyObject *)__pyx_kp_s_1)); 410 PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_1)); 411 __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1)); 412 __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 413 __Pyx_GOTREF(__pyx_t_3); 414 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; 415 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 416 __Pyx_Raise(__pyx_t_3, 0, 0); 417 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; 418 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 419 420 __pyx_r = Py_None; __Pyx_INCREF(Py_None); 80 421 goto __pyx_L0; 81 __pyx_L1 :;82 Py_XDECREF(__pyx_1);83 Py_XDECREF(__pyx_2);84 Py_XDECREF(__pyx_3);85 __Pyx_AddTraceback(" raiser.raiseException");86 __pyx_r = 0;422 __pyx_L1_error:; 423 __Pyx_XDECREF(__pyx_t_1); 424 __Pyx_XDECREF(__pyx_t_2); 425 __Pyx_XDECREF(__pyx_t_3); 426 __Pyx_AddTraceback("twisted.test.raiser.raiseException"); 427 __pyx_r = NULL; 87 428 __pyx_L0:; 429 __Pyx_XGIVEREF(__pyx_r); 430 __Pyx_RefNannyFinishContext(); 88 431 return __pyx_r; 89 432 } 90 433 91 static __Pyx_InternTabEntry __pyx_intern_tab[] = { 92 {&__pyx_n_Exception, "Exception"}, 93 {&__pyx_n_RaiserException, "RaiserException"}, 94 {&__pyx_n_raiseException, "raiseException"}, 95 {0, 0} 434 static struct PyMethodDef __pyx_methods[] = { 435 {__Pyx_NAMESTR("raiseException"), (PyCFunction)__pyx_pf_7twisted_4test_6raiser_raiseException, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_7twisted_4test_6raiser_raiseException)}, 436 {0, 0, 0, 0} 96 437 }; 97 438 98 static __Pyx_StringTabEntry __pyx_string_tab[] = { 99 {&__pyx_k2p, __pyx_k2, sizeof(__pyx_k2)}, 100 {&__pyx_k3p, __pyx_k3, sizeof(__pyx_k3)}, 101 {0, 0, 0} 439 static void __pyx_init_filenames(void); /*proto*/ 440 441 #if PY_MAJOR_VERSION >= 3 442 static struct PyModuleDef __pyx_moduledef = { 443 PyModuleDef_HEAD_INIT, 444 __Pyx_NAMESTR("raiser"), 445 __Pyx_DOCSTR(__pyx_k_2), /* m_doc */ 446 -1, /* m_size */ 447 __pyx_methods /* m_methods */, 448 NULL, /* m_reload */ 449 NULL, /* m_traverse */ 450 NULL, /* m_clear */ 451 NULL /* m_free */ 102 452 }; 453 #endif 103 454 104 static struct PyMethodDef __pyx_methods[] = { 105 {"raiseException", (PyCFunction)__pyx_f_6raiser_raiseException, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6raiser_raiseException}, 106 {0, 0, 0, 0} 455 static __Pyx_StringTabEntry __pyx_string_tab[] = { 456 {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0}, 457 {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0}, 458 {&__pyx_kp_u_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 1, 0, 0}, 459 {&__pyx_n_s__Exception, __pyx_k__Exception, sizeof(__pyx_k__Exception), 0, 0, 1, 1}, 460 {&__pyx_n_s__RaiserException, __pyx_k__RaiserException, sizeof(__pyx_k__RaiserException), 0, 0, 1, 1}, 461 {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, 462 {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, 463 {&__pyx_n_s__raiseException, __pyx_k__raiseException, sizeof(__pyx_k__raiseException), 0, 0, 1, 1}, 464 {0, 0, 0, 0, 0, 0, 0} 107 465 }; 466 static int __Pyx_InitCachedBuiltins(void) { 467 __pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 468 return 0; 469 __pyx_L1_error:; 470 return -1; 471 } 108 472 109 static void __pyx_init_filenames(void); /*proto*/ 473 static int __Pyx_InitGlobals(void) { 474 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 475 return 0; 476 __pyx_L1_error:; 477 return -1; 478 } 110 479 480 #if PY_MAJOR_VERSION < 3 111 481 PyMODINIT_FUNC initraiser(void); /*proto*/ 112 PyMODINIT_FUNC initraiser(void) { 113 PyObject *__pyx_1 = 0; 114 PyObject *__pyx_2 = 0; 115 PyObject *__pyx_3 = 0; 482 PyMODINIT_FUNC initraiser(void) 483 #else 484 PyMODINIT_FUNC PyInit_raiser(void); /*proto*/ 485 PyMODINIT_FUNC PyInit_raiser(void) 486 #endif 487 { 488 PyObject *__pyx_t_1 = NULL; 489 PyObject *__pyx_t_2 = NULL; 490 PyObject *__pyx_t_3 = NULL; 491 #if CYTHON_REFNANNY 492 void* __pyx_refnanny = NULL; 493 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); 494 if (!__Pyx_RefNanny) { 495 PyErr_Clear(); 496 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); 497 if (!__Pyx_RefNanny) 498 Py_FatalError("failed to import 'refnanny' module"); 499 } 500 __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_raiser(void)", __LINE__, __FILE__); 501 #endif 116 502 __pyx_init_filenames(); 117 __pyx_m = Py_InitModule4("raiser", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION); 118 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}; 119 __pyx_b = PyImport_AddModule("__builtin__"); 120 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}; 121 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}; 122 if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}; 123 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}; 503 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 504 #if PY_MAJOR_VERSION < 3 505 __pyx_empty_bytes = PyString_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 506 #else 507 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 508 #endif 509 /*--- Library function declarations ---*/ 510 /*--- Threads initialization code ---*/ 511 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS 512 #ifdef WITH_THREAD /* Python build with threading support? */ 513 PyEval_InitThreads(); 514 #endif 515 #endif 516 /*--- Module creation code ---*/ 517 #if PY_MAJOR_VERSION < 3 518 __pyx_m = Py_InitModule4(__Pyx_NAMESTR("raiser"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_2), 0, PYTHON_API_VERSION); 519 #else 520 __pyx_m = PyModule_Create(&__pyx_moduledef); 521 #endif 522 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 523 #if PY_MAJOR_VERSION < 3 524 Py_INCREF(__pyx_m); 525 #endif 526 __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); 527 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 528 if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 529 /*--- Initialize various global constants etc. ---*/ 530 if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 531 if (__pyx_module_is_main_twisted__test__raiser) { 532 if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; 533 } 534 /*--- Builtin init code ---*/ 535 if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 536 /*--- Global init code ---*/ 537 /*--- Function export code ---*/ 538 /*--- Type init code ---*/ 539 /*--- Type import code ---*/ 540 /*--- Function import code ---*/ 541 /*--- Execution code ---*/ 124 542 125 /* "/home/therve/Projects/Twisted/branches/failure-c-extension-3132/twisted/test/raiser.pyx":11 */ 126 __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;} 127 __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_Exception); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;} 128 __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;} 129 PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); 130 __pyx_2 = 0; 131 if (PyDict_SetItemString(__pyx_1, "__doc__", __pyx_k2p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;} 132 __pyx_2 = __Pyx_CreateClass(__pyx_3, __pyx_1, __pyx_n_RaiserException, "raiser"); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;} 133 Py_DECREF(__pyx_3); __pyx_3 = 0; 134 if (PyObject_SetAttr(__pyx_m, __pyx_n_RaiserException, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; goto __pyx_L1;} 135 Py_DECREF(__pyx_2); __pyx_2 = 0; 136 Py_DECREF(__pyx_1); __pyx_1 = 0; 543 /* "/home/martin/work/twisted.3k/twisted/test/raiser.pyx":11 544 * 545 * 546 * class RaiserException(Exception): # <<<<<<<<<<<<<< 547 * """ 548 * A speficic exception only used to be identified in tests. 549 */ 550 __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 551 __Pyx_GOTREF(((PyObject *)__pyx_t_1)); 552 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 553 __Pyx_GOTREF(__pyx_t_2); 554 __Pyx_INCREF(__pyx_builtin_Exception); 555 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_Exception); 556 __Pyx_GIVEREF(__pyx_builtin_Exception); 557 if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 558 __pyx_t_3 = __Pyx_CreateClass(__pyx_t_2, ((PyObject *)__pyx_t_1), __pyx_n_s__RaiserException, "twisted.test.raiser"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 559 __Pyx_GOTREF(__pyx_t_3); 560 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 561 if (PyObject_SetAttr(__pyx_m, __pyx_n_s__RaiserException, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 562 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; 563 __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; 137 564 138 /* "/home/therve/Projects/Twisted/branches/failure-c-extension-3132/twisted/test/raiser.pyx":17 */ 565 /* "/home/martin/work/twisted.3k/twisted/test/raiser.pyx":1 566 * # Copyright (c) 2008 Twisted Matrix Laboratories. # <<<<<<<<<<<<<< 567 * # See LICENSE for details. 568 * 569 */ 570 __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 571 __Pyx_GOTREF(((PyObject *)__pyx_t_1)); 572 __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__raiseException); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 573 __Pyx_GOTREF(__pyx_t_3); 574 __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); 575 __Pyx_GOTREF(__pyx_t_2); 576 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; 577 if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_4), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 578 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; 579 if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 580 __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; 581 goto __pyx_L0; 582 __pyx_L1_error:; 583 __Pyx_XDECREF(__pyx_t_1); 584 __Pyx_XDECREF(__pyx_t_2); 585 __Pyx_XDECREF(__pyx_t_3); 586 if (__pyx_m) { 587 __Pyx_AddTraceback("init twisted.test.raiser"); 588 Py_DECREF(__pyx_m); __pyx_m = 0; 589 } else if (!PyErr_Occurred()) { 590 PyErr_SetString(PyExc_ImportError, "init twisted.test.raiser"); 591 } 592 __pyx_L0:; 593 __Pyx_RefNannyFinishContext(); 594 #if PY_MAJOR_VERSION < 3 139 595 return; 140 __pyx_L1:; 141 Py_XDECREF(__pyx_1); 142 Py_XDECREF(__pyx_2); 143 Py_XDECREF(__pyx_3); 144 __Pyx_AddTraceback("raiser"); 596 #else 597 return __pyx_m; 598 #endif 145 599 } 146 600 147 static c har *__pyx_filenames[] = {601 static const char *__pyx_filenames[] = { 148 602 "raiser.pyx", 149 603 }; 150 604 … … 163 617 } 164 618 165 619 static PyObject *__Pyx_CreateClass( 166 PyObject *bases, PyObject *dict, PyObject *name, c har *modname)620 PyObject *bases, PyObject *dict, PyObject *name, const char *modname) 167 621 { 168 622 PyObject *py_modname; 169 623 PyObject *result = 0; 170 624 625 #if PY_MAJOR_VERSION < 3 171 626 py_modname = PyString_FromString(modname); 627 #else 628 py_modname = PyUnicode_FromString(modname); 629 #endif 172 630 if (!py_modname) 173 631 goto bad; 174 632 if (PyDict_SetItemString(dict, "__module__", py_modname) < 0) 175 633 goto bad; 634 #if PY_MAJOR_VERSION < 3 176 635 result = PyClass_New(bases, dict, name); 636 #else 637 result = PyObject_CallFunctionObjArgs((PyObject *)&PyType_Type, name, bases, dict, NULL); 638 #endif 177 639 bad: 178 640 Py_XDECREF(py_modname); 179 641 return result; 180 642 } 181 643 644 static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { 645 PyObject *tmp_type, *tmp_value, *tmp_tb; 646 PyThreadState *tstate = PyThreadState_GET(); 647 648 tmp_type = tstate->curexc_type; 649 tmp_value = tstate->curexc_value; 650 tmp_tb = tstate->curexc_traceback; 651 tstate->curexc_type = type; 652 tstate->curexc_value = value; 653 tstate->curexc_traceback = tb; 654 Py_XDECREF(tmp_type); 655 Py_XDECREF(tmp_value); 656 Py_XDECREF(tmp_tb); 657 } 658 659 static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { 660 PyThreadState *tstate = PyThreadState_GET(); 661 *type = tstate->curexc_type; 662 *value = tstate->curexc_value; 663 *tb = tstate->curexc_traceback; 664 665 tstate->curexc_type = 0; 666 tstate->curexc_value = 0; 667 tstate->curexc_traceback = 0; 668 } 669 670 671 #if PY_MAJOR_VERSION < 3 182 672 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { 183 673 Py_XINCREF(type); 184 674 Py_XINCREF(value); … … 198 688 value = Py_None; 199 689 Py_INCREF(value); 200 690 } 201 /* Next, repeatedly, replace a tuple exception with its first item */ 202 while (PyTuple_Check(type) && PyTuple_Size(type) > 0) { 203 PyObject *tmp = type; 204 type = PyTuple_GET_ITEM(type, 0); 205 Py_INCREF(type); 206 Py_DECREF(tmp); 207 } 208 if (PyString_Check(type)) { 209 if (PyErr_Warn(PyExc_DeprecationWarning, 210 "raising a string exception is deprecated")) 211 goto raise_error; 212 } 213 else if (PyType_Check(type) || PyClass_Check(type)) 214 ; /*PyErr_NormalizeException(&type, &value, &tb);*/ 215 else { 691 #if PY_VERSION_HEX < 0x02050000 692 if (!PyClass_Check(type)) 693 #else 694 if (!PyType_Check(type)) 695 #endif 696 { 216 697 /* Raising an instance. The value should be a dummy. */ 217 698 if (value != Py_None) { 218 699 PyErr_SetString(PyExc_TypeError, … … 222 703 /* Normalize to raise <class>, <instance> */ 223 704 Py_DECREF(value); 224 705 value = type; 225 if (PyInstance_Check(type)) 226 type = (PyObject*) ((PyInstanceObject*)type)->in_class; 227 else 228 type = (PyObject*) type->ob_type; 229 Py_INCREF(type); 706 #if PY_VERSION_HEX < 0x02050000 707 if (PyInstance_Check(type)) { 708 type = (PyObject*) ((PyInstanceObject*)type)->in_class; 709 Py_INCREF(type); 710 } 711 else { 712 type = 0; 713 PyErr_SetString(PyExc_TypeError, 714 "raise: exception must be an old-style class or instance"); 715 goto raise_error; 716 } 717 #else 718 type = (PyObject*) Py_TYPE(type); 719 Py_INCREF(type); 720 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { 721 PyErr_SetString(PyExc_TypeError, 722 "raise: exception class must be a subclass of BaseException"); 723 goto raise_error; 724 } 725 #endif 230 726 } 231 PyErr_Restore(type, value, tb); 727 728 __Pyx_ErrRestore(type, value, tb); 232 729 return; 233 730 raise_error: 234 731 Py_XDECREF(value); … … 237 734 return; 238 735 } 239 736 240 static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) { 241 while (t->p) { 242 *t->p = PyString_InternFromString(t->s); 243 if (!*t->p) 244 return -1; 245 ++t; 737 #else /* Python 3+ */ 738 739 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { 740 if (tb == Py_None) { 741 tb = 0; 742 } else if (tb && !PyTraceBack_Check(tb)) { 743 PyErr_SetString(PyExc_TypeError, 744 "raise: arg 3 must be a traceback or None"); 745 goto bad; 246 746 } 247 return 0; 747 if (value == Py_None) 748 value = 0; 749 750 if (PyExceptionInstance_Check(type)) { 751 if (value) { 752 PyErr_SetString(PyExc_TypeError, 753 "instance exception may not have a separate value"); 754 goto bad; 755 } 756 value = type; 757 type = (PyObject*) Py_TYPE(value); 758 } else if (!PyExceptionClass_Check(type)) { 759 PyErr_SetString(PyExc_TypeError, 760 "raise: exception class must be a subclass of BaseException"); 761 goto bad; 762 } 763 764 PyErr_SetObject(type, value); 765 766 if (tb) { 767 PyThreadState *tstate = PyThreadState_GET(); 768 PyObject* tmp_tb = tstate->curexc_traceback; 769 if (tb != tmp_tb) { 770 Py_INCREF(tb); 771 tstate->curexc_traceback = tb; 772 Py_XDECREF(tmp_tb); 773 } 774 } 775 776 bad: 777 return; 248 778 } 779 #endif 249 780 250 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { 251 while (t->p) { 252 *t->p = PyString_FromStringAndSize(t->s, t->n - 1); 253 if (!*t->p) 254 return -1; 255 ++t; 781 static INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { 782 const unsigned char neg_one = (unsigned char)-1, const_zero = 0; 783 const int is_unsigned = neg_one > const_zero; 784 if (sizeof(unsigned char) < sizeof(long)) { 785 long val = __Pyx_PyInt_AsLong(x); 786 if (unlikely(val != (long)(unsigned char)val)) { 787 if (!unlikely(val == -1 && PyErr_Occurred())) { 788 PyErr_SetString(PyExc_OverflowError, 789 (is_unsigned && unlikely(val < 0)) ? 790 "can't convert negative value to unsigned char" : 791 "value too large to convert to unsigned char"); 792 } 793 return (unsigned char)-1; 794 } 795 return (unsigned char)val; 256 796 } 257 return 0;797 return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x); 258 798 } 259 799 800 static INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) { 801 const unsigned short neg_one = (unsigned short)-1, const_zero = 0; 802 const int is_unsigned = neg_one > const_zero; 803 if (sizeof(unsigned short) < sizeof(long)) { 804 long val = __Pyx_PyInt_AsLong(x); 805 if (unlikely(val != (long)(unsigned short)val)) { 806 if (!unlikely(val == -1 && PyErr_Occurred())) { 807 PyErr_SetString(PyExc_OverflowError, 808 (is_unsigned && unlikely(val < 0)) ? 809 "can't convert negative value to unsigned short" : 810 "value too large to convert to unsigned short"); 811 } 812 return (unsigned short)-1; 813 } 814 return (unsigned short)val; 815 } 816 return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x); 817 } 818 819 static INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) { 820 const unsigned int neg_one = (unsigned int)-1, const_zero = 0; 821 const int is_unsigned = neg_one > const_zero; 822 if (sizeof(unsigned int) < sizeof(long)) { 823 long val = __Pyx_PyInt_AsLong(x); 824 if (unlikely(val != (long)(unsigned int)val)) { 825 if (!unlikely(val == -1 && PyErr_Occurred())) { 826 PyErr_SetString(PyExc_OverflowError, 827 (is_unsigned && unlikely(val < 0)) ? 828 "can't convert negative value to unsigned int" : 829 "value too large to convert to unsigned int"); 830 } 831 return (unsigned int)-1; 832 } 833 return (unsigned int)val; 834 } 835 return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x); 836 } 837 838 static INLINE char __Pyx_PyInt_AsChar(PyObject* x) { 839 const char neg_one = (char)-1, const_zero = 0; 840 const int is_unsigned = neg_one > const_zero; 841 if (sizeof(char) < sizeof(long)) { 842 long val = __Pyx_PyInt_AsLong(x); 843 if (unlikely(val != (long)(char)val)) { 844 if (!unlikely(val == -1 && PyErr_Occurred())) { 845 PyErr_SetString(PyExc_OverflowError, 846 (is_unsigned && unlikely(val < 0)) ? 847 "can't convert negative value to char" : 848 "value too large to convert to char"); 849 } 850 return (char)-1; 851 } 852 return (char)val; 853 } 854 return (char)__Pyx_PyInt_AsLong(x); 855 } 856 857 static INLINE short __Pyx_PyInt_AsShort(PyObject* x) { 858 const short neg_one = (short)-1, const_zero = 0; 859 const int is_unsigned = neg_one > const_zero; 860 if (sizeof(short) < sizeof(long)) { 861 long val = __Pyx_PyInt_AsLong(x); 862 if (unlikely(val != (long)(short)val)) { 863 if (!unlikely(val == -1 && PyErr_Occurred())) { 864 PyErr_SetString(PyExc_OverflowError, 865 (is_unsigned && unlikely(val < 0)) ? 866 "can't convert negative value to short" : 867 "value too large to convert to short"); 868 } 869 return (short)-1; 870 } 871 return (short)val; 872 } 873 return (short)__Pyx_PyInt_AsLong(x); 874 } 875 876 static INLINE int __Pyx_PyInt_AsInt(PyObject* x) { 877 const int neg_one = (int)-1, const_zero = 0; 878 const int is_unsigned = neg_one > const_zero; 879 if (sizeof(int) < sizeof(long)) { 880 long val = __Pyx_PyInt_AsLong(x); 881 if (unlikely(val != (long)(int)val)) { 882 if (!unlikely(val == -1 && PyErr_Occurred())) { 883 PyErr_SetString(PyExc_OverflowError, 884 (is_unsigned && unlikely(val < 0)) ? 885 "can't convert negative value to int" : 886 "value too large to convert to int"); 887 } 888 return (int)-1; 889 } 890 return (int)val; 891 } 892 return (int)__Pyx_PyInt_AsLong(x); 893 } 894 895 static INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) { 896 const signed char neg_one = (signed char)-1, const_zero = 0; 897 const int is_unsigned = neg_one > const_zero; 898 if (sizeof(signed char) < sizeof(long)) { 899 long val = __Pyx_PyInt_AsLong(x); 900 if (unlikely(val != (long)(signed char)val)) { 901 if (!unlikely(val == -1 && PyErr_Occurred())) { 902 PyErr_SetString(PyExc_OverflowError, 903 (is_unsigned && unlikely(val < 0)) ? 904 "can't convert negative value to signed char" : 905 "value too large to convert to signed char"); 906 } 907 return (signed char)-1; 908 } 909 return (signed char)val; 910 } 911 return (signed char)__Pyx_PyInt_AsSignedLong(x); 912 } 913 914 static INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) { 915 const signed short neg_one = (signed short)-1, const_zero = 0; 916 const int is_unsigned = neg_one > const_zero; 917 if (sizeof(signed short) < sizeof(long)) { 918 long val = __Pyx_PyInt_AsLong(x); 919 if (unlikely(val != (long)(signed short)val)) { 920 if (!unlikely(val == -1 && PyErr_Occurred())) { 921 PyErr_SetString(PyExc_OverflowError, 922 (is_unsigned && unlikely(val < 0)) ? 923 "can't convert negative value to signed short" : 924 "value too large to convert to signed short"); 925 } 926 return (signed short)-1; 927 } 928 return (signed short)val; 929 } 930 return (signed short)__Pyx_PyInt_AsSignedLong(x); 931 } 932 933 static INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) { 934 const signed int neg_one = (signed int)-1, const_zero = 0; 935 const int is_unsigned = neg_one > const_zero; 936 if (sizeof(signed int) < sizeof(long)) { 937 long val = __Pyx_PyInt_AsLong(x); 938 if (unlikely(val != (long)(signed int)val)) { 939 if (!unlikely(val == -1 && PyErr_Occurred())) { 940 PyErr_SetString(PyExc_OverflowError, 941 (is_unsigned && unlikely(val < 0)) ? 942 "can't convert negative value to signed int" : 943 "value too large to convert to signed int"); 944 } 945 return (signed int)-1; 946 } 947 return (signed int)val; 948 } 949 return (signed int)__Pyx_PyInt_AsSignedLong(x); 950 } 951 952 static INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { 953 const unsigned long neg_one = (unsigned long)-1, const_zero = 0; 954 const int is_unsigned = neg_one > const_zero; 955 #if PY_VERSION_HEX < 0x03000000 956 if (likely(PyInt_Check(x))) { 957 long val = PyInt_AS_LONG(x); 958 if (is_unsigned && unlikely(val < 0)) { 959 PyErr_SetString(PyExc_OverflowError, 960 "can't convert negative value to unsigned long"); 961 return (unsigned long)-1; 962 } 963 return (unsigned long)val; 964 } else 965 #endif 966 if (likely(PyLong_Check(x))) { 967 if (is_unsigned) { 968 if (unlikely(Py_SIZE(x) < 0)) { 969 PyErr_SetString(PyExc_OverflowError, 970 "can't convert negative value to unsigned long"); 971 return (unsigned long)-1; 972 } 973 return PyLong_AsUnsignedLong(x); 974 } else { 975 return PyLong_AsLong(x); 976 } 977 } else { 978 unsigned long val; 979 PyObject *tmp = __Pyx_PyNumber_Int(x); 980 if (!tmp) return (unsigned long)-1; 981 val = __Pyx_PyInt_AsUnsignedLong(tmp); 982 Py_DECREF(tmp); 983 return val; 984 } 985 } 986 987 static INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { 988 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; 989 const int is_unsigned = neg_one > const_zero; 990 #if PY_VERSION_HEX < 0x03000000 991 if (likely(PyInt_Check(x))) { 992 long val = PyInt_AS_LONG(x); 993 if (is_unsigned && unlikely(val < 0)) { 994 PyErr_SetString(PyExc_OverflowError, 995 "can't convert negative value to unsigned PY_LONG_LONG"); 996 return (unsigned PY_LONG_LONG)-1; 997 } 998 return (unsigned PY_LONG_LONG)val; 999 } else 1000 #endif 1001 if (likely(PyLong_Check(x))) { 1002 if (is_unsigned) { 1003 if (unlikely(Py_SIZE(x) < 0)) { 1004 PyErr_SetString(PyExc_OverflowError, 1005 "can't convert negative value to unsigned PY_LONG_LONG"); 1006 return (unsigned PY_LONG_LONG)-1; 1007 } 1008 return PyLong_AsUnsignedLongLong(x); 1009 } else { 1010 return PyLong_AsLongLong(x); 1011 } 1012 } else { 1013 unsigned PY_LONG_LONG val; 1014 PyObject *tmp = __Pyx_PyNumber_Int(x); 1015 if (!tmp) return (unsigned PY_LONG_LONG)-1; 1016 val = __Pyx_PyInt_AsUnsignedLongLong(tmp); 1017 Py_DECREF(tmp); 1018 return val; 1019 } 1020 } 1021 1022 static INLINE long __Pyx_PyInt_AsLong(PyObject* x) { 1023 const long neg_one = (long)-1, const_zero = 0; 1024 const int is_unsigned = neg_one > const_zero; 1025 #if PY_VERSION_HEX < 0x03000000 1026 if (likely(PyInt_Check(x))) { 1027 long val = PyInt_AS_LONG(x); 1028 if (is_unsigned && unlikely(val < 0)) { 1029 PyErr_SetString(PyExc_OverflowError, 1030 "can't convert negative value to long"); 1031 return (long)-1; 1032 } 1033 return (long)val; 1034 } else 1035 #endif 1036 if (likely(PyLong_Check(x))) { 1037 if (is_unsigned) { 1038 if (unlikely(Py_SIZE(x) < 0)) { 1039 PyErr_SetString(PyExc_OverflowError, 1040 "can't convert negative value to long"); 1041 return (long)-1; 1042 } 1043 return PyLong_AsUnsignedLong(x); 1044 } else { 1045 return PyLong_AsLong(x); 1046 } 1047 } else { 1048 long val; 1049 PyObject *tmp = __Pyx_PyNumber_Int(x); 1050 if (!tmp) return (long)-1; 1051 val = __Pyx_PyInt_AsLong(tmp); 1052 Py_DECREF(tmp); 1053 return val; 1054 } 1055 } 1056 1057 static INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { 1058 const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; 1059 const int is_unsigned = neg_one > const_zero; 1060 #if PY_VERSION_HEX < 0x03000000 1061 if (likely(PyInt_Check(x))) { 1062 long val = PyInt_AS_LONG(x); 1063 if (is_unsigned && unlikely(val < 0)) { 1064 PyErr_SetString(PyExc_OverflowError, 1065 "can't convert negative value to PY_LONG_LONG"); 1066 return (PY_LONG_LONG)-1; 1067 } 1068 return (PY_LONG_LONG)val; 1069 } else 1070 #endif 1071 if (likely(PyLong_Check(x))) { 1072 if (is_unsigned) { 1073 if (unlikely(Py_SIZE(x) < 0)) { 1074 PyErr_SetString(PyExc_OverflowError, 1075 "can't convert negative value to PY_LONG_LONG"); 1076 return (PY_LONG_LONG)-1; 1077 } 1078 return PyLong_AsUnsignedLongLong(x); 1079 } else { 1080 return PyLong_AsLongLong(x); 1081 } 1082 } else { 1083 PY_LONG_LONG val; 1084 PyObject *tmp = __Pyx_PyNumber_Int(x); 1085 if (!tmp) return (PY_LONG_LONG)-1; 1086 val = __Pyx_PyInt_AsLongLong(tmp); 1087 Py_DECREF(tmp); 1088 return val; 1089 } 1090 } 1091 1092 static INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { 1093 const signed long neg_one = (signed long)-1, const_zero = 0; 1094 const int is_unsigned = neg_one > const_zero; 1095 #if PY_VERSION_HEX < 0x03000000 1096 if (likely(PyInt_Check(x))) { 1097 long val = PyInt_AS_LONG(x); 1098 if (is_unsigned && unlikely(val < 0)) { 1099 PyErr_SetString(PyExc_OverflowError, 1100 "can't convert negative value to signed long"); 1101 return (signed long)-1; 1102 } 1103 return (signed long)val; 1104 } else 1105 #endif 1106 if (likely(PyLong_Check(x))) { 1107 if (is_unsigned) { 1108 if (unlikely(Py_SIZE(x) < 0)) { 1109 PyErr_SetString(PyExc_OverflowError, 1110 "can't convert negative value to signed long"); 1111 return (signed long)-1; 1112 } 1113 return PyLong_AsUnsignedLong(x); 1114 } else { 1115 return PyLong_AsLong(x); 1116 } 1117 } else { 1118 signed long val; 1119 PyObject *tmp = __Pyx_PyNumber_Int(x); 1120 if (!tmp) return (signed long)-1; 1121 val = __Pyx_PyInt_AsSignedLong(tmp); 1122 Py_DECREF(tmp); 1123 return val; 1124 } 1125 } 1126 1127 static INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { 1128 const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; 1129 const int is_unsigned = neg_one > const_zero; 1130 #if PY_VERSION_HEX < 0x03000000 1131 if (likely(PyInt_Check(x))) { 1132 long val = PyInt_AS_LONG(x); 1133 if (is_unsigned && unlikely(val < 0)) { 1134 PyErr_SetString(PyExc_OverflowError, 1135 "can't convert negative value to signed PY_LONG_LONG"); 1136 return (signed PY_LONG_LONG)-1; 1137 } 1138 return (signed PY_LONG_LONG)val; 1139 } else 1140 #endif 1141 if (likely(PyLong_Check(x))) { 1142 if (is_unsigned) { 1143 if (unlikely(Py_SIZE(x) < 0)) { 1144 PyErr_SetString(PyExc_OverflowError, 1145 "can't convert negative value to signed PY_LONG_LONG"); 1146 return (signed PY_LONG_LONG)-1; 1147 } 1148 return PyLong_AsUnsignedLongLong(x); 1149 } else { 1150 return PyLong_AsLongLong(x); 1151 } 1152 } else { 1153 signed PY_LONG_LONG val; 1154 PyObject *tmp = __Pyx_PyNumber_Int(x); 1155 if (!tmp) return (signed PY_LONG_LONG)-1; 1156 val = __Pyx_PyInt_AsSignedLongLong(tmp); 1157 Py_DECREF(tmp); 1158 return val; 1159 } 1160 } 1161 260 1162 #include "compile.h" 261 1163 #include "frameobject.h" 262 1164 #include "traceback.h" 263 1165 264 static void __Pyx_AddTraceback(c har *funcname) {1166 static void __Pyx_AddTraceback(const char *funcname) { 265 1167 PyObject *py_srcfile = 0; 266 1168 PyObject *py_funcname = 0; 267 1169 PyObject *py_globals = 0; 268 PyObject *empty_tuple = 0;269 PyObject *empty_string = 0;270 1170 PyCodeObject *py_code = 0; 271 1171 PyFrameObject *py_frame = 0; 272 1172 1173 #if PY_MAJOR_VERSION < 3 273 1174 py_srcfile = PyString_FromString(__pyx_filename); 1175 #else 1176 py_srcfile = PyUnicode_FromString(__pyx_filename); 1177 #endif 274 1178 if (!py_srcfile) goto bad; 275 py_funcname = PyString_FromString(funcname); 1179 if (__pyx_clineno) { 1180 #if PY_MAJOR_VERSION < 3 1181 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno); 1182 #else 1183 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno); 1184 #endif 1185 } 1186 else { 1187 #if PY_MAJOR_VERSION < 3 1188 py_funcname = PyString_FromString(funcname); 1189 #else 1190 py_funcname = PyUnicode_FromString(funcname); 1191 #endif 1192 } 276 1193 if (!py_funcname) goto bad; 277 1194 py_globals = PyModule_GetDict(__pyx_m); 278 1195 if (!py_globals) goto bad; 279 empty_tuple = PyTuple_New(0);280 if (!empty_tuple) goto bad;281 empty_string = PyString_FromString("");282 if (!empty_string) goto bad;283 1196 py_code = PyCode_New( 284 1197 0, /*int argcount,*/ 1198 #if PY_MAJOR_VERSION >= 3 1199 0, /*int kwonlyargcount,*/ 1200 #endif 285 1201 0, /*int nlocals,*/ 286 1202 0, /*int stacksize,*/ 287 1203 0, /*int flags,*/ 288 empty_string, /*PyObject *code,*/289 empty_tuple, /*PyObject *consts,*/290 empty_tuple, /*PyObject *names,*/291 empty_tuple, /*PyObject *varnames,*/292 empty_tuple, /*PyObject *freevars,*/293 empty_tuple, /*PyObject *cellvars,*/1204 __pyx_empty_bytes, /*PyObject *code,*/ 1205 __pyx_empty_tuple, /*PyObject *consts,*/ 1206 __pyx_empty_tuple, /*PyObject *names,*/ 1207 __pyx_empty_tuple, /*PyObject *varnames,*/ 1208 __pyx_empty_tuple, /*PyObject *freevars,*/ 1209 __pyx_empty_tuple, /*PyObject *cellvars,*/ 294 1210 py_srcfile, /*PyObject *filename,*/ 295 1211 py_funcname, /*PyObject *name,*/ 296 1212 __pyx_lineno, /*int firstlineno,*/ 297 empty_string/*PyObject *lnotab*/1213 __pyx_empty_bytes /*PyObject *lnotab*/ 298 1214 ); 299 1215 if (!py_code) goto bad; 300 1216 py_frame = PyFrame_New( 301 PyThreadState_G et(), /*PyThreadState *tstate,*/1217 PyThreadState_GET(), /*PyThreadState *tstate,*/ 302 1218 py_code, /*PyCodeObject *code,*/ 303 1219 py_globals, /*PyObject *globals,*/ 304 1220 0 /*PyObject *locals*/ … … 309 1225 bad: 310 1226 Py_XDECREF(py_srcfile); 311 1227 Py_XDECREF(py_funcname); 312 Py_XDECREF(empty_tuple);313 Py_XDECREF(empty_string);314 1228 Py_XDECREF(py_code); 315 1229 Py_XDECREF(py_frame); 316 1230 } 1231 1232 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { 1233 while (t->p) { 1234 #if PY_MAJOR_VERSION < 3 1235 if (t->is_unicode) { 1236 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); 1237 } else if (t->intern) { 1238 *t->p = PyString_InternFromString(t->s); 1239 } else { 1240 *t->p = PyString_FromStringAndSize(t->s, t->n - 1); 1241 } 1242 #else /* Python 3+ has unicode identifiers */ 1243 if (t->is_unicode | t->is_str) { 1244 if (t->intern) { 1245 *t->p = PyUnicode_InternFromString(t->s); 1246 } else if (t->encoding) { 1247 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); 1248 } else { 1249 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); 1250 } 1251 } else { 1252 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); 1253 } 1254 #endif 1255 if (!*t->p) 1256 return -1; 1257 ++t; 1258 } 1259 return 0; 1260 } 1261 1262 /* Type Conversion Functions */ 1263 1264 static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { 1265 if (x == Py_True) return 1; 1266 else if ((x == Py_False) | (x == Py_None)) return 0; 1267 else return PyObject_IsTrue(x); 1268 } 1269 1270 static INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { 1271 PyNumberMethods *m; 1272 const char *name = NULL; 1273 PyObject *res = NULL; 1274 #if PY_VERSION_HEX < 0x03000000 1275 if (PyInt_Check(x) || PyLong_Check(x)) 1276 #else 1277 if (PyLong_Check(x)) 1278 #endif 1279 return Py_INCREF(x), x; 1280 m = Py_TYPE(x)->tp_as_number; 1281 #if PY_VERSION_HEX < 0x03000000 1282 if (m && m->nb_int) { 1283 name = "int"; 1284 res = PyNumber_Int(x); 1285 } 1286 else if (m && m->nb_long) { 1287 name = "long"; 1288 res = PyNumber_Long(x); 1289 } 1290 #else 1291 if (m && m->nb_int) { 1292 name = "int"; 1293 res = PyNumber_Long(x); 1294 } 1295 #endif 1296 if (res) { 1297 #if PY_VERSION_HEX < 0x03000000 1298 if (!PyInt_Check(res) && !PyLong_Check(res)) { 1299 #else 1300 if (!PyLong_Check(res)) { 1301 #endif 1302 PyErr_Format(PyExc_TypeError, 1303 "__%s__ returned non-%s (type %.200s)", 1304 name, name, Py_TYPE(res)->tp_name); 1305 Py_DECREF(res); 1306 return NULL; 1307 } 1308 } 1309 else if (!PyErr_Occurred()) { 1310 PyErr_SetString(PyExc_TypeError, 1311 "an integer is required"); 1312 } 1313 return res; 1314 } 1315 1316 static INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { 1317 Py_ssize_t ival; 1318 PyObject* x = PyNumber_Index(b); 1319 if (!x) return -1; 1320 ival = PyInt_AsSsize_t(x); 1321 Py_DECREF(x); 1322 return ival; 1323 } 1324 1325 static INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { 1326 #if PY_VERSION_HEX < 0x02050000 1327 if (ival <= LONG_MAX) 1328 return PyInt_FromLong((long)ival); 1329 else { 1330 unsigned char *bytes = (unsigned char *) &ival; 1331 int one = 1; int little = (int)*(unsigned char*)&one; 1332 return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0); 1333 } 1334 #else 1335 return PyInt_FromSize_t(ival); 1336 #endif 1337 } 1338 1339 static INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { 1340 unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); 1341 if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) { 1342 return (size_t)-1; 1343 } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { 1344 PyErr_SetString(PyExc_OverflowError, 1345 "value too large to convert to size_t"); 1346 return (size_t)-1; 1347 } 1348 return (size_t)val; 1349 } 1350 1351 1352 #endif /* Py_PYTHON_H */
