raiser.c 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168
  1. /* Generated by Cython 0.24 */
  2. #define PY_SSIZE_T_CLEAN
  3. #include "Python.h"
  4. #ifndef Py_PYTHON_H
  5. #error Python headers needed to compile C extensions, please install development version of Python.
  6. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
  7. #error Cython requires Python 2.6+ or Python 3.2+.
  8. #else
  9. #define CYTHON_ABI "0_24"
  10. #include <stddef.h>
  11. #ifndef offsetof
  12. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  13. #endif
  14. #if !defined(WIN32) && !defined(MS_WINDOWS)
  15. #ifndef __stdcall
  16. #define __stdcall
  17. #endif
  18. #ifndef __cdecl
  19. #define __cdecl
  20. #endif
  21. #ifndef __fastcall
  22. #define __fastcall
  23. #endif
  24. #endif
  25. #ifndef DL_IMPORT
  26. #define DL_IMPORT(t) t
  27. #endif
  28. #ifndef DL_EXPORT
  29. #define DL_EXPORT(t) t
  30. #endif
  31. #ifndef PY_LONG_LONG
  32. #define PY_LONG_LONG LONG_LONG
  33. #endif
  34. #ifndef Py_HUGE_VAL
  35. #define Py_HUGE_VAL HUGE_VAL
  36. #endif
  37. #ifdef PYPY_VERSION
  38. #define CYTHON_COMPILING_IN_PYPY 1
  39. #define CYTHON_COMPILING_IN_CPYTHON 0
  40. #else
  41. #define CYTHON_COMPILING_IN_PYPY 0
  42. #define CYTHON_COMPILING_IN_CPYTHON 1
  43. #endif
  44. #if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000
  45. #define CYTHON_USE_PYLONG_INTERNALS 1
  46. #endif
  47. #if CYTHON_USE_PYLONG_INTERNALS
  48. #include "longintrepr.h"
  49. #undef SHIFT
  50. #undef BASE
  51. #undef MASK
  52. #endif
  53. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  54. #define Py_OptimizeFlag 0
  55. #endif
  56. #define __PYX_BUILD_PY_SSIZE_T "n"
  57. #define CYTHON_FORMAT_SSIZE_T "z"
  58. #if PY_MAJOR_VERSION < 3
  59. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  60. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  61. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  62. #define __Pyx_DefaultClassType PyClass_Type
  63. #else
  64. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  65. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  66. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  67. #define __Pyx_DefaultClassType PyType_Type
  68. #endif
  69. #ifndef Py_TPFLAGS_CHECKTYPES
  70. #define Py_TPFLAGS_CHECKTYPES 0
  71. #endif
  72. #ifndef Py_TPFLAGS_HAVE_INDEX
  73. #define Py_TPFLAGS_HAVE_INDEX 0
  74. #endif
  75. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  76. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  77. #endif
  78. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  79. #define Py_TPFLAGS_HAVE_FINALIZE 0
  80. #endif
  81. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  82. #define CYTHON_PEP393_ENABLED 1
  83. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  84. 0 : _PyUnicode_Ready((PyObject *)(op)))
  85. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  86. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  87. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  88. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  89. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  90. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  91. #else
  92. #define CYTHON_PEP393_ENABLED 0
  93. #define __Pyx_PyUnicode_READY(op) (0)
  94. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  95. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  96. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  97. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  98. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  99. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
  100. #endif
  101. #if CYTHON_COMPILING_IN_PYPY
  102. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  103. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  104. #else
  105. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  106. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  107. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  108. #endif
  109. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  110. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  111. #endif
  112. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  113. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  114. #endif
  115. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  116. #define PyObject_Malloc(s) PyMem_Malloc(s)
  117. #define PyObject_Free(p) PyMem_Free(p)
  118. #define PyObject_Realloc(p) PyMem_Realloc(p)
  119. #endif
  120. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  121. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  122. #if PY_MAJOR_VERSION >= 3
  123. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  124. #else
  125. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  126. #endif
  127. #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  128. #define PyObject_ASCII(o) PyObject_Repr(o)
  129. #endif
  130. #if PY_MAJOR_VERSION >= 3
  131. #define PyBaseString_Type PyUnicode_Type
  132. #define PyStringObject PyUnicodeObject
  133. #define PyString_Type PyUnicode_Type
  134. #define PyString_Check PyUnicode_Check
  135. #define PyString_CheckExact PyUnicode_CheckExact
  136. #endif
  137. #if PY_MAJOR_VERSION >= 3
  138. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  139. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  140. #else
  141. #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  142. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  143. #endif
  144. #ifndef PySet_CheckExact
  145. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  146. #endif
  147. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  148. #if PY_MAJOR_VERSION >= 3
  149. #define PyIntObject PyLongObject
  150. #define PyInt_Type PyLong_Type
  151. #define PyInt_Check(op) PyLong_Check(op)
  152. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  153. #define PyInt_FromString PyLong_FromString
  154. #define PyInt_FromUnicode PyLong_FromUnicode
  155. #define PyInt_FromLong PyLong_FromLong
  156. #define PyInt_FromSize_t PyLong_FromSize_t
  157. #define PyInt_FromSsize_t PyLong_FromSsize_t
  158. #define PyInt_AsLong PyLong_AsLong
  159. #define PyInt_AS_LONG PyLong_AS_LONG
  160. #define PyInt_AsSsize_t PyLong_AsSsize_t
  161. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  162. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  163. #define PyNumber_Int PyNumber_Long
  164. #endif
  165. #if PY_MAJOR_VERSION >= 3
  166. #define PyBoolObject PyLongObject
  167. #endif
  168. #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  169. #ifndef PyUnicode_InternFromString
  170. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  171. #endif
  172. #endif
  173. #if PY_VERSION_HEX < 0x030200A4
  174. typedef long Py_hash_t;
  175. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  176. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  177. #else
  178. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  179. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  180. #endif
  181. #if PY_MAJOR_VERSION >= 3
  182. #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
  183. #else
  184. #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
  185. #endif
  186. #if PY_VERSION_HEX >= 0x030500B1
  187. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  188. #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  189. #elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  190. typedef struct {
  191. unaryfunc am_await;
  192. unaryfunc am_aiter;
  193. unaryfunc am_anext;
  194. } __Pyx_PyAsyncMethodsStruct;
  195. #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  196. #else
  197. #define __Pyx_PyType_AsAsync(obj) NULL
  198. #endif
  199. #ifndef CYTHON_RESTRICT
  200. #if defined(__GNUC__)
  201. #define CYTHON_RESTRICT __restrict__
  202. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  203. #define CYTHON_RESTRICT __restrict
  204. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  205. #define CYTHON_RESTRICT restrict
  206. #else
  207. #define CYTHON_RESTRICT
  208. #endif
  209. #endif
  210. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  211. #ifndef CYTHON_INLINE
  212. #if defined(__GNUC__)
  213. #define CYTHON_INLINE __inline__
  214. #elif defined(_MSC_VER)
  215. #define CYTHON_INLINE __inline
  216. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  217. #define CYTHON_INLINE inline
  218. #else
  219. #define CYTHON_INLINE
  220. #endif
  221. #endif
  222. #if defined(WIN32) || defined(MS_WINDOWS)
  223. #define _USE_MATH_DEFINES
  224. #endif
  225. #include <math.h>
  226. #ifdef NAN
  227. #define __PYX_NAN() ((float) NAN)
  228. #else
  229. static CYTHON_INLINE float __PYX_NAN() {
  230. float value;
  231. memset(&value, 0xFF, sizeof(value));
  232. return value;
  233. }
  234. #endif
  235. #define __PYX_ERR(f_index, lineno, Ln_error) \
  236. { \
  237. __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
  238. }
  239. #if PY_MAJOR_VERSION >= 3
  240. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  241. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  242. #else
  243. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  244. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  245. #endif
  246. #ifndef __PYX_EXTERN_C
  247. #ifdef __cplusplus
  248. #define __PYX_EXTERN_C extern "C"
  249. #else
  250. #define __PYX_EXTERN_C extern
  251. #endif
  252. #endif
  253. #define __PYX_HAVE__twisted__test__raiser
  254. #define __PYX_HAVE_API__twisted__test__raiser
  255. #ifdef _OPENMP
  256. #include <omp.h>
  257. #endif /* _OPENMP */
  258. #ifdef PYREX_WITHOUT_ASSERTIONS
  259. #define CYTHON_WITHOUT_ASSERTIONS
  260. #endif
  261. #ifndef CYTHON_UNUSED
  262. # if defined(__GNUC__)
  263. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  264. # define CYTHON_UNUSED __attribute__ ((__unused__))
  265. # else
  266. # define CYTHON_UNUSED
  267. # endif
  268. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  269. # define CYTHON_UNUSED __attribute__ ((__unused__))
  270. # else
  271. # define CYTHON_UNUSED
  272. # endif
  273. #endif
  274. #ifndef CYTHON_NCP_UNUSED
  275. # if CYTHON_COMPILING_IN_CPYTHON
  276. # define CYTHON_NCP_UNUSED
  277. # else
  278. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  279. # endif
  280. #endif
  281. typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
  282. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
  283. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  284. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
  285. #define __PYX_DEFAULT_STRING_ENCODING ""
  286. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  287. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  288. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  289. #define __Pyx_long_cast(x) ((long)x)
  290. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  291. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  292. (sizeof(type) > sizeof(Py_ssize_t) &&\
  293. likely(v < (type)PY_SSIZE_T_MAX ||\
  294. v == (type)PY_SSIZE_T_MAX) &&\
  295. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  296. v == (type)PY_SSIZE_T_MIN))) ||\
  297. (sizeof(type) == sizeof(Py_ssize_t) &&\
  298. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  299. v == (type)PY_SSIZE_T_MAX))) )
  300. #if defined (__cplusplus) && __cplusplus >= 201103L
  301. #include <cstdlib>
  302. #define __Pyx_sst_abs(value) std::abs(value)
  303. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  304. #define __Pyx_sst_abs(value) abs(value)
  305. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  306. #define __Pyx_sst_abs(value) labs(value)
  307. #elif defined (_MSC_VER) && defined (_M_X64)
  308. #define __Pyx_sst_abs(value) _abs64(value)
  309. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  310. #define __Pyx_sst_abs(value) llabs(value)
  311. #elif defined (__GNUC__)
  312. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  313. #else
  314. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  315. #endif
  316. static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
  317. static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  318. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  319. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  320. #define __Pyx_PyBytes_FromString PyBytes_FromString
  321. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  322. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  323. #if PY_MAJOR_VERSION < 3
  324. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  325. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  326. #else
  327. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  328. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  329. #endif
  330. #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  331. #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  332. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  333. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  334. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  335. #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
  336. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  337. #if PY_MAJOR_VERSION < 3
  338. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
  339. {
  340. const Py_UNICODE *u_end = u;
  341. while (*u_end++) ;
  342. return (size_t)(u_end - u - 1);
  343. }
  344. #else
  345. #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
  346. #endif
  347. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  348. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  349. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  350. #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
  351. #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
  352. #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
  353. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  354. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
  355. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  356. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  357. #if CYTHON_COMPILING_IN_CPYTHON
  358. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  359. #else
  360. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  361. #endif
  362. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  363. #if PY_MAJOR_VERSION >= 3
  364. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  365. #else
  366. #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
  367. #endif
  368. #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
  369. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  370. static int __Pyx_sys_getdefaultencoding_not_ascii;
  371. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  372. PyObject* sys;
  373. PyObject* default_encoding = NULL;
  374. PyObject* ascii_chars_u = NULL;
  375. PyObject* ascii_chars_b = NULL;
  376. const char* default_encoding_c;
  377. sys = PyImport_ImportModule("sys");
  378. if (!sys) goto bad;
  379. default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
  380. Py_DECREF(sys);
  381. if (!default_encoding) goto bad;
  382. default_encoding_c = PyBytes_AsString(default_encoding);
  383. if (!default_encoding_c) goto bad;
  384. if (strcmp(default_encoding_c, "ascii") == 0) {
  385. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  386. } else {
  387. char ascii_chars[128];
  388. int c;
  389. for (c = 0; c < 128; c++) {
  390. ascii_chars[c] = c;
  391. }
  392. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  393. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  394. if (!ascii_chars_u) goto bad;
  395. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  396. if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  397. PyErr_Format(
  398. PyExc_ValueError,
  399. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  400. default_encoding_c);
  401. goto bad;
  402. }
  403. Py_DECREF(ascii_chars_u);
  404. Py_DECREF(ascii_chars_b);
  405. }
  406. Py_DECREF(default_encoding);
  407. return 0;
  408. bad:
  409. Py_XDECREF(default_encoding);
  410. Py_XDECREF(ascii_chars_u);
  411. Py_XDECREF(ascii_chars_b);
  412. return -1;
  413. }
  414. #endif
  415. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  416. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  417. #else
  418. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  419. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  420. static char* __PYX_DEFAULT_STRING_ENCODING;
  421. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  422. PyObject* sys;
  423. PyObject* default_encoding = NULL;
  424. char* default_encoding_c;
  425. sys = PyImport_ImportModule("sys");
  426. if (!sys) goto bad;
  427. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  428. Py_DECREF(sys);
  429. if (!default_encoding) goto bad;
  430. default_encoding_c = PyBytes_AsString(default_encoding);
  431. if (!default_encoding_c) goto bad;
  432. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
  433. if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
  434. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  435. Py_DECREF(default_encoding);
  436. return 0;
  437. bad:
  438. Py_XDECREF(default_encoding);
  439. return -1;
  440. }
  441. #endif
  442. #endif
  443. /* Test for GCC > 2.95 */
  444. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  445. #define likely(x) __builtin_expect(!!(x), 1)
  446. #define unlikely(x) __builtin_expect(!!(x), 0)
  447. #else /* !__GNUC__ or GCC < 2.95 */
  448. #define likely(x) (x)
  449. #define unlikely(x) (x)
  450. #endif /* __GNUC__ */
  451. static PyObject *__pyx_m;
  452. static PyObject *__pyx_d;
  453. static PyObject *__pyx_b;
  454. static PyObject *__pyx_empty_tuple;
  455. static PyObject *__pyx_empty_bytes;
  456. static PyObject *__pyx_empty_unicode;
  457. static int __pyx_lineno;
  458. static int __pyx_clineno = 0;
  459. static const char * __pyx_cfilenm= __FILE__;
  460. static const char *__pyx_filename;
  461. static const char *__pyx_f[] = {
  462. "twisted/test/raiser.pyx",
  463. };
  464. /*--- Type declarations ---*/
  465. /* --- Runtime support code (head) --- */
  466. /* Refnanny.proto */
  467. #ifndef CYTHON_REFNANNY
  468. #define CYTHON_REFNANNY 0
  469. #endif
  470. #if CYTHON_REFNANNY
  471. typedef struct {
  472. void (*INCREF)(void*, PyObject*, int);
  473. void (*DECREF)(void*, PyObject*, int);
  474. void (*GOTREF)(void*, PyObject*, int);
  475. void (*GIVEREF)(void*, PyObject*, int);
  476. void* (*SetupContext)(const char*, int, const char*);
  477. void (*FinishContext)(void**);
  478. } __Pyx_RefNannyAPIStruct;
  479. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  480. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  481. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  482. #ifdef WITH_THREAD
  483. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  484. if (acquire_gil) {\
  485. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  486. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  487. PyGILState_Release(__pyx_gilstate_save);\
  488. } else {\
  489. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  490. }
  491. #else
  492. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  493. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  494. #endif
  495. #define __Pyx_RefNannyFinishContext()\
  496. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  497. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  498. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  499. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  500. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  501. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  502. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  503. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  504. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  505. #else
  506. #define __Pyx_RefNannyDeclarations
  507. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  508. #define __Pyx_RefNannyFinishContext()
  509. #define __Pyx_INCREF(r) Py_INCREF(r)
  510. #define __Pyx_DECREF(r) Py_DECREF(r)
  511. #define __Pyx_GOTREF(r)
  512. #define __Pyx_GIVEREF(r)
  513. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  514. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  515. #define __Pyx_XGOTREF(r)
  516. #define __Pyx_XGIVEREF(r)
  517. #endif
  518. #define __Pyx_XDECREF_SET(r, v) do {\
  519. PyObject *tmp = (PyObject *) r;\
  520. r = v; __Pyx_XDECREF(tmp);\
  521. } while (0)
  522. #define __Pyx_DECREF_SET(r, v) do {\
  523. PyObject *tmp = (PyObject *) r;\
  524. r = v; __Pyx_DECREF(tmp);\
  525. } while (0)
  526. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  527. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  528. /* PyObjectGetAttrStr.proto */
  529. #if CYTHON_COMPILING_IN_CPYTHON
  530. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  531. PyTypeObject* tp = Py_TYPE(obj);
  532. if (likely(tp->tp_getattro))
  533. return tp->tp_getattro(obj, attr_name);
  534. #if PY_MAJOR_VERSION < 3
  535. if (likely(tp->tp_getattr))
  536. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  537. #endif
  538. return PyObject_GetAttr(obj, attr_name);
  539. }
  540. #else
  541. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  542. #endif
  543. /* GetBuiltinName.proto */
  544. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  545. /* GetModuleGlobalName.proto */
  546. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
  547. /* PyObjectCall.proto */
  548. #if CYTHON_COMPILING_IN_CPYTHON
  549. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  550. #else
  551. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  552. #endif
  553. /* PyThreadStateGet.proto */
  554. #if CYTHON_COMPILING_IN_CPYTHON
  555. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  556. #define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET();
  557. #else
  558. #define __Pyx_PyThreadState_declare
  559. #define __Pyx_PyThreadState_assign
  560. #endif
  561. /* PyErrFetchRestore.proto */
  562. #if CYTHON_COMPILING_IN_CPYTHON
  563. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  564. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  565. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  566. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  567. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  568. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  569. #else
  570. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  571. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  572. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  573. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  574. #endif
  575. /* RaiseException.proto */
  576. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  577. /* CalculateMetaclass.proto */
  578. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
  579. /* Py3ClassCreate.proto */
  580. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
  581. PyObject *mkw, PyObject *modname, PyObject *doc);
  582. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
  583. PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
  584. /* CodeObjectCache.proto */
  585. typedef struct {
  586. PyCodeObject* code_object;
  587. int code_line;
  588. } __Pyx_CodeObjectCacheEntry;
  589. struct __Pyx_CodeObjectCache {
  590. int count;
  591. int max_count;
  592. __Pyx_CodeObjectCacheEntry* entries;
  593. };
  594. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  595. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  596. static PyCodeObject *__pyx_find_code_object(int code_line);
  597. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  598. /* AddTraceback.proto */
  599. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  600. int py_line, const char *filename);
  601. /* CIntToPy.proto */
  602. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  603. /* CIntFromPy.proto */
  604. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  605. /* CIntFromPy.proto */
  606. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  607. /* CheckBinaryVersion.proto */
  608. static int __Pyx_check_binary_version(void);
  609. /* InitStrings.proto */
  610. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  611. /* Module declarations from 'twisted.test.raiser' */
  612. #define __Pyx_MODULE_NAME "twisted.test.raiser"
  613. int __pyx_module_is_main_twisted__test__raiser = 0;
  614. /* Implementation of 'twisted.test.raiser' */
  615. static PyObject *__pyx_builtin_Exception;
  616. static const char __pyx_k_doc[] = "__doc__";
  617. static const char __pyx_k_main[] = "__main__";
  618. static const char __pyx_k_test[] = "__test__";
  619. static const char __pyx_k_module[] = "__module__";
  620. static const char __pyx_k_prepare[] = "__prepare__";
  621. static const char __pyx_k_qualname[] = "__qualname__";
  622. static const char __pyx_k_Exception[] = "Exception";
  623. static const char __pyx_k_metaclass[] = "__metaclass__";
  624. static const char __pyx_k_raiseException[] = "raiseException";
  625. static const char __pyx_k_RaiserException[] = "RaiserException";
  626. static const char __pyx_k_twisted_test_raiser[] = "twisted.test.raiser";
  627. static const char __pyx_k_A_speficic_exception_only_used[] = "\n A speficic exception only used to be identified in tests.\n ";
  628. static const char __pyx_k_A_trivial_extension_that_just_r[] = "\nA trivial extension that just raises an exception.\nSee L{twisted.test.test_failure.test_failureConstructionWithMungedStackSucceeds}.\n";
  629. static const char __pyx_k_Users_crodrigues_twisted_twiste[] = "/Users/crodrigues/twisted/twisted/test/raiser.pyx";
  630. static const char __pyx_k_This_function_is_intentionally_b[] = "This function is intentionally broken";
  631. static PyObject *__pyx_kp_s_A_speficic_exception_only_used;
  632. static PyObject *__pyx_n_s_Exception;
  633. static PyObject *__pyx_n_s_RaiserException;
  634. static PyObject *__pyx_kp_s_This_function_is_intentionally_b;
  635. static PyObject *__pyx_kp_s_Users_crodrigues_twisted_twiste;
  636. static PyObject *__pyx_n_s_doc;
  637. static PyObject *__pyx_n_s_main;
  638. static PyObject *__pyx_n_s_metaclass;
  639. static PyObject *__pyx_n_s_module;
  640. static PyObject *__pyx_n_s_prepare;
  641. static PyObject *__pyx_n_s_qualname;
  642. static PyObject *__pyx_n_s_raiseException;
  643. static PyObject *__pyx_n_s_test;
  644. static PyObject *__pyx_n_s_twisted_test_raiser;
  645. static PyObject *__pyx_pf_7twisted_4test_6raiser_raiseException(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  646. static PyObject *__pyx_tuple_;
  647. static PyObject *__pyx_codeobj__2;
  648. /* "twisted/test/raiser.pyx":17
  649. *
  650. *
  651. * def raiseException(): # <<<<<<<<<<<<<<
  652. * """
  653. * Raise L{RaiserException}.
  654. */
  655. /* Python wrapper */
  656. static PyObject *__pyx_pw_7twisted_4test_6raiser_1raiseException(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  657. static char __pyx_doc_7twisted_4test_6raiser_raiseException[] = "\n Raise L{RaiserException}.\n ";
  658. static PyMethodDef __pyx_mdef_7twisted_4test_6raiser_1raiseException = {"raiseException", (PyCFunction)__pyx_pw_7twisted_4test_6raiser_1raiseException, METH_NOARGS, __pyx_doc_7twisted_4test_6raiser_raiseException};
  659. static PyObject *__pyx_pw_7twisted_4test_6raiser_1raiseException(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  660. PyObject *__pyx_r = 0;
  661. __Pyx_RefNannyDeclarations
  662. __Pyx_RefNannySetupContext("raiseException (wrapper)", 0);
  663. __pyx_r = __pyx_pf_7twisted_4test_6raiser_raiseException(__pyx_self);
  664. /* function exit code */
  665. __Pyx_RefNannyFinishContext();
  666. return __pyx_r;
  667. }
  668. static PyObject *__pyx_pf_7twisted_4test_6raiser_raiseException(CYTHON_UNUSED PyObject *__pyx_self) {
  669. PyObject *__pyx_r = NULL;
  670. __Pyx_RefNannyDeclarations
  671. PyObject *__pyx_t_1 = NULL;
  672. PyObject *__pyx_t_2 = NULL;
  673. __Pyx_RefNannySetupContext("raiseException", 0);
  674. /* "twisted/test/raiser.pyx":21
  675. * Raise L{RaiserException}.
  676. * """
  677. * raise RaiserException("This function is intentionally broken") # <<<<<<<<<<<<<<
  678. */
  679. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_RaiserException); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
  680. __Pyx_GOTREF(__pyx_t_1);
  681. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error)
  682. __Pyx_GOTREF(__pyx_t_2);
  683. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  684. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  685. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  686. __PYX_ERR(0, 21, __pyx_L1_error)
  687. /* "twisted/test/raiser.pyx":17
  688. *
  689. *
  690. * def raiseException(): # <<<<<<<<<<<<<<
  691. * """
  692. * Raise L{RaiserException}.
  693. */
  694. /* function exit code */
  695. __pyx_L1_error:;
  696. __Pyx_XDECREF(__pyx_t_1);
  697. __Pyx_XDECREF(__pyx_t_2);
  698. __Pyx_AddTraceback("twisted.test.raiser.raiseException", __pyx_clineno, __pyx_lineno, __pyx_filename);
  699. __pyx_r = NULL;
  700. __Pyx_XGIVEREF(__pyx_r);
  701. __Pyx_RefNannyFinishContext();
  702. return __pyx_r;
  703. }
  704. static PyMethodDef __pyx_methods[] = {
  705. {0, 0, 0, 0}
  706. };
  707. #if PY_MAJOR_VERSION >= 3
  708. static struct PyModuleDef __pyx_moduledef = {
  709. #if PY_VERSION_HEX < 0x03020000
  710. { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  711. #else
  712. PyModuleDef_HEAD_INIT,
  713. #endif
  714. "raiser",
  715. __pyx_k_A_trivial_extension_that_just_r, /* m_doc */
  716. -1, /* m_size */
  717. __pyx_methods /* m_methods */,
  718. NULL, /* m_reload */
  719. NULL, /* m_traverse */
  720. NULL, /* m_clear */
  721. NULL /* m_free */
  722. };
  723. #endif
  724. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  725. {&__pyx_kp_s_A_speficic_exception_only_used, __pyx_k_A_speficic_exception_only_used, sizeof(__pyx_k_A_speficic_exception_only_used), 0, 0, 1, 0},
  726. {&__pyx_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1},
  727. {&__pyx_n_s_RaiserException, __pyx_k_RaiserException, sizeof(__pyx_k_RaiserException), 0, 0, 1, 1},
  728. {&__pyx_kp_s_This_function_is_intentionally_b, __pyx_k_This_function_is_intentionally_b, sizeof(__pyx_k_This_function_is_intentionally_b), 0, 0, 1, 0},
  729. {&__pyx_kp_s_Users_crodrigues_twisted_twiste, __pyx_k_Users_crodrigues_twisted_twiste, sizeof(__pyx_k_Users_crodrigues_twisted_twiste), 0, 0, 1, 0},
  730. {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  731. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  732. {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  733. {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  734. {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  735. {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  736. {&__pyx_n_s_raiseException, __pyx_k_raiseException, sizeof(__pyx_k_raiseException), 0, 0, 1, 1},
  737. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  738. {&__pyx_n_s_twisted_test_raiser, __pyx_k_twisted_test_raiser, sizeof(__pyx_k_twisted_test_raiser), 0, 0, 1, 1},
  739. {0, 0, 0, 0, 0, 0, 0}
  740. };
  741. static int __Pyx_InitCachedBuiltins(void) {
  742. __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) __PYX_ERR(0, 11, __pyx_L1_error)
  743. return 0;
  744. __pyx_L1_error:;
  745. return -1;
  746. }
  747. static int __Pyx_InitCachedConstants(void) {
  748. __Pyx_RefNannyDeclarations
  749. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  750. /* "twisted/test/raiser.pyx":21
  751. * Raise L{RaiserException}.
  752. * """
  753. * raise RaiserException("This function is intentionally broken") # <<<<<<<<<<<<<<
  754. */
  755. __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_This_function_is_intentionally_b); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 21, __pyx_L1_error)
  756. __Pyx_GOTREF(__pyx_tuple_);
  757. __Pyx_GIVEREF(__pyx_tuple_);
  758. /* "twisted/test/raiser.pyx":17
  759. *
  760. *
  761. * def raiseException(): # <<<<<<<<<<<<<<
  762. * """
  763. * Raise L{RaiserException}.
  764. */
  765. __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_crodrigues_twisted_twiste, __pyx_n_s_raiseException, 17, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 17, __pyx_L1_error)
  766. __Pyx_RefNannyFinishContext();
  767. return 0;
  768. __pyx_L1_error:;
  769. __Pyx_RefNannyFinishContext();
  770. return -1;
  771. }
  772. static int __Pyx_InitGlobals(void) {
  773. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  774. return 0;
  775. __pyx_L1_error:;
  776. return -1;
  777. }
  778. #if PY_MAJOR_VERSION < 3
  779. PyMODINIT_FUNC initraiser(void); /*proto*/
  780. PyMODINIT_FUNC initraiser(void)
  781. #else
  782. PyMODINIT_FUNC PyInit_raiser(void); /*proto*/
  783. PyMODINIT_FUNC PyInit_raiser(void)
  784. #endif
  785. {
  786. PyObject *__pyx_t_1 = NULL;
  787. PyObject *__pyx_t_2 = NULL;
  788. PyObject *__pyx_t_3 = NULL;
  789. PyObject *__pyx_t_4 = NULL;
  790. __Pyx_RefNannyDeclarations
  791. #if CYTHON_REFNANNY
  792. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  793. if (!__Pyx_RefNanny) {
  794. PyErr_Clear();
  795. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  796. if (!__Pyx_RefNanny)
  797. Py_FatalError("failed to import 'refnanny' module");
  798. }
  799. #endif
  800. __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_raiser(void)", 0);
  801. if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  802. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  803. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  804. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  805. #ifdef __Pyx_CyFunction_USED
  806. if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  807. #endif
  808. #ifdef __Pyx_FusedFunction_USED
  809. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  810. #endif
  811. #ifdef __Pyx_Coroutine_USED
  812. if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  813. #endif
  814. #ifdef __Pyx_Generator_USED
  815. if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  816. #endif
  817. #ifdef __Pyx_StopAsyncIteration_USED
  818. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  819. #endif
  820. /*--- Library function declarations ---*/
  821. /*--- Threads initialization code ---*/
  822. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  823. #ifdef WITH_THREAD /* Python build with threading support? */
  824. PyEval_InitThreads();
  825. #endif
  826. #endif
  827. /*--- Module creation code ---*/
  828. #if PY_MAJOR_VERSION < 3
  829. __pyx_m = Py_InitModule4("raiser", __pyx_methods, __pyx_k_A_trivial_extension_that_just_r, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  830. #else
  831. __pyx_m = PyModule_Create(&__pyx_moduledef);
  832. #endif
  833. if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  834. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  835. Py_INCREF(__pyx_d);
  836. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  837. #if CYTHON_COMPILING_IN_PYPY
  838. Py_INCREF(__pyx_b);
  839. #endif
  840. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  841. /*--- Initialize various global constants etc. ---*/
  842. if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  843. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  844. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  845. #endif
  846. if (__pyx_module_is_main_twisted__test__raiser) {
  847. if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  848. }
  849. #if PY_MAJOR_VERSION >= 3
  850. {
  851. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  852. if (!PyDict_GetItemString(modules, "twisted.test.raiser")) {
  853. if (unlikely(PyDict_SetItemString(modules, "twisted.test.raiser", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  854. }
  855. }
  856. #endif
  857. /*--- Builtin init code ---*/
  858. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  859. /*--- Constants init code ---*/
  860. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  861. /*--- Global init code ---*/
  862. /*--- Variable export code ---*/
  863. /*--- Function export code ---*/
  864. /*--- Type init code ---*/
  865. /*--- Type import code ---*/
  866. /*--- Variable import code ---*/
  867. /*--- Function import code ---*/
  868. /*--- Execution code ---*/
  869. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  870. if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  871. #endif
  872. /* "twisted/test/raiser.pyx":11
  873. *
  874. *
  875. * class RaiserException(Exception): # <<<<<<<<<<<<<<
  876. * """
  877. * A speficic exception only used to be identified in tests.
  878. */
  879. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
  880. __Pyx_GOTREF(__pyx_t_1);
  881. __Pyx_INCREF(__pyx_builtin_Exception);
  882. __Pyx_GIVEREF(__pyx_builtin_Exception);
  883. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_builtin_Exception);
  884. __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
  885. __Pyx_GOTREF(__pyx_t_2);
  886. __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_RaiserException, __pyx_n_s_RaiserException, (PyObject *) NULL, __pyx_n_s_twisted_test_raiser, __pyx_kp_s_A_speficic_exception_only_used); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 11, __pyx_L1_error)
  887. __Pyx_GOTREF(__pyx_t_3);
  888. __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_RaiserException, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 11, __pyx_L1_error)
  889. __Pyx_GOTREF(__pyx_t_4);
  890. if (PyDict_SetItem(__pyx_d, __pyx_n_s_RaiserException, __pyx_t_4) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
  891. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  892. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  893. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  894. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  895. /* "twisted/test/raiser.pyx":17
  896. *
  897. *
  898. * def raiseException(): # <<<<<<<<<<<<<<
  899. * """
  900. * Raise L{RaiserException}.
  901. */
  902. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7twisted_4test_6raiser_1raiseException, NULL, __pyx_n_s_twisted_test_raiser); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  903. __Pyx_GOTREF(__pyx_t_1);
  904. if (PyDict_SetItem(__pyx_d, __pyx_n_s_raiseException, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  905. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  906. /* "twisted/test/raiser.pyx":1
  907. * # Copyright (c) Twisted Matrix Laboratories. # <<<<<<<<<<<<<<
  908. * # See LICENSE for details.
  909. *
  910. */
  911. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  912. __Pyx_GOTREF(__pyx_t_1);
  913. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  914. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  915. /*--- Wrapped vars code ---*/
  916. goto __pyx_L0;
  917. __pyx_L1_error:;
  918. __Pyx_XDECREF(__pyx_t_1);
  919. __Pyx_XDECREF(__pyx_t_2);
  920. __Pyx_XDECREF(__pyx_t_3);
  921. __Pyx_XDECREF(__pyx_t_4);
  922. if (__pyx_m) {
  923. if (__pyx_d) {
  924. __Pyx_AddTraceback("init twisted.test.raiser", __pyx_clineno, __pyx_lineno, __pyx_filename);
  925. }
  926. Py_DECREF(__pyx_m); __pyx_m = 0;
  927. } else if (!PyErr_Occurred()) {
  928. PyErr_SetString(PyExc_ImportError, "init twisted.test.raiser");
  929. }
  930. __pyx_L0:;
  931. __Pyx_RefNannyFinishContext();
  932. #if PY_MAJOR_VERSION < 3
  933. return;
  934. #else
  935. return __pyx_m;
  936. #endif
  937. }
  938. /* --- Runtime support code --- */
  939. /* Refnanny */
  940. #if CYTHON_REFNANNY
  941. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  942. PyObject *m = NULL, *p = NULL;
  943. void *r = NULL;
  944. m = PyImport_ImportModule((char *)modname);
  945. if (!m) goto end;
  946. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  947. if (!p) goto end;
  948. r = PyLong_AsVoidPtr(p);
  949. end:
  950. Py_XDECREF(p);
  951. Py_XDECREF(m);
  952. return (__Pyx_RefNannyAPIStruct *)r;
  953. }
  954. #endif
  955. /* GetBuiltinName */
  956. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  957. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  958. if (unlikely(!result)) {
  959. PyErr_Format(PyExc_NameError,
  960. #if PY_MAJOR_VERSION >= 3
  961. "name '%U' is not defined", name);
  962. #else
  963. "name '%.200s' is not defined", PyString_AS_STRING(name));
  964. #endif
  965. }
  966. return result;
  967. }
  968. /* GetModuleGlobalName */
  969. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
  970. PyObject *result;
  971. #if CYTHON_COMPILING_IN_CPYTHON
  972. result = PyDict_GetItem(__pyx_d, name);
  973. if (likely(result)) {
  974. Py_INCREF(result);
  975. } else {
  976. #else
  977. result = PyObject_GetItem(__pyx_d, name);
  978. if (!result) {
  979. PyErr_Clear();
  980. #endif
  981. result = __Pyx_GetBuiltinName(name);
  982. }
  983. return result;
  984. }
  985. /* PyObjectCall */
  986. #if CYTHON_COMPILING_IN_CPYTHON
  987. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  988. PyObject *result;
  989. ternaryfunc call = func->ob_type->tp_call;
  990. if (unlikely(!call))
  991. return PyObject_Call(func, arg, kw);
  992. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  993. return NULL;
  994. result = (*call)(func, arg, kw);
  995. Py_LeaveRecursiveCall();
  996. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  997. PyErr_SetString(
  998. PyExc_SystemError,
  999. "NULL result without error in PyObject_Call");
  1000. }
  1001. return result;
  1002. }
  1003. #endif
  1004. /* PyErrFetchRestore */
  1005. #if CYTHON_COMPILING_IN_CPYTHON
  1006. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  1007. PyObject *tmp_type, *tmp_value, *tmp_tb;
  1008. tmp_type = tstate->curexc_type;
  1009. tmp_value = tstate->curexc_value;
  1010. tmp_tb = tstate->curexc_traceback;
  1011. tstate->curexc_type = type;
  1012. tstate->curexc_value = value;
  1013. tstate->curexc_traceback = tb;
  1014. Py_XDECREF(tmp_type);
  1015. Py_XDECREF(tmp_value);
  1016. Py_XDECREF(tmp_tb);
  1017. }
  1018. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  1019. *type = tstate->curexc_type;
  1020. *value = tstate->curexc_value;
  1021. *tb = tstate->curexc_traceback;
  1022. tstate->curexc_type = 0;
  1023. tstate->curexc_value = 0;
  1024. tstate->curexc_traceback = 0;
  1025. }
  1026. #endif
  1027. /* RaiseException */
  1028. #if PY_MAJOR_VERSION < 3
  1029. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
  1030. CYTHON_UNUSED PyObject *cause) {
  1031. __Pyx_PyThreadState_declare
  1032. Py_XINCREF(type);
  1033. if (!value || value == Py_None)
  1034. value = NULL;
  1035. else
  1036. Py_INCREF(value);
  1037. if (!tb || tb == Py_None)
  1038. tb = NULL;
  1039. else {
  1040. Py_INCREF(tb);
  1041. if (!PyTraceBack_Check(tb)) {
  1042. PyErr_SetString(PyExc_TypeError,
  1043. "raise: arg 3 must be a traceback or None");
  1044. goto raise_error;
  1045. }
  1046. }
  1047. if (PyType_Check(type)) {
  1048. #if CYTHON_COMPILING_IN_PYPY
  1049. if (!value) {
  1050. Py_INCREF(Py_None);
  1051. value = Py_None;
  1052. }
  1053. #endif
  1054. PyErr_NormalizeException(&type, &value, &tb);
  1055. } else {
  1056. if (value) {
  1057. PyErr_SetString(PyExc_TypeError,
  1058. "instance exception may not have a separate value");
  1059. goto raise_error;
  1060. }
  1061. value = type;
  1062. type = (PyObject*) Py_TYPE(type);
  1063. Py_INCREF(type);
  1064. if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
  1065. PyErr_SetString(PyExc_TypeError,
  1066. "raise: exception class must be a subclass of BaseException");
  1067. goto raise_error;
  1068. }
  1069. }
  1070. __Pyx_PyThreadState_assign
  1071. __Pyx_ErrRestore(type, value, tb);
  1072. return;
  1073. raise_error:
  1074. Py_XDECREF(value);
  1075. Py_XDECREF(type);
  1076. Py_XDECREF(tb);
  1077. return;
  1078. }
  1079. #else
  1080. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  1081. PyObject* owned_instance = NULL;
  1082. if (tb == Py_None) {
  1083. tb = 0;
  1084. } else if (tb && !PyTraceBack_Check(tb)) {
  1085. PyErr_SetString(PyExc_TypeError,
  1086. "raise: arg 3 must be a traceback or None");
  1087. goto bad;
  1088. }
  1089. if (value == Py_None)
  1090. value = 0;
  1091. if (PyExceptionInstance_Check(type)) {
  1092. if (value) {
  1093. PyErr_SetString(PyExc_TypeError,
  1094. "instance exception may not have a separate value");
  1095. goto bad;
  1096. }
  1097. value = type;
  1098. type = (PyObject*) Py_TYPE(value);
  1099. } else if (PyExceptionClass_Check(type)) {
  1100. PyObject *instance_class = NULL;
  1101. if (value && PyExceptionInstance_Check(value)) {
  1102. instance_class = (PyObject*) Py_TYPE(value);
  1103. if (instance_class != type) {
  1104. int is_subclass = PyObject_IsSubclass(instance_class, type);
  1105. if (!is_subclass) {
  1106. instance_class = NULL;
  1107. } else if (unlikely(is_subclass == -1)) {
  1108. goto bad;
  1109. } else {
  1110. type = instance_class;
  1111. }
  1112. }
  1113. }
  1114. if (!instance_class) {
  1115. PyObject *args;
  1116. if (!value)
  1117. args = PyTuple_New(0);
  1118. else if (PyTuple_Check(value)) {
  1119. Py_INCREF(value);
  1120. args = value;
  1121. } else
  1122. args = PyTuple_Pack(1, value);
  1123. if (!args)
  1124. goto bad;
  1125. owned_instance = PyObject_Call(type, args, NULL);
  1126. Py_DECREF(args);
  1127. if (!owned_instance)
  1128. goto bad;
  1129. value = owned_instance;
  1130. if (!PyExceptionInstance_Check(value)) {
  1131. PyErr_Format(PyExc_TypeError,
  1132. "calling %R should have returned an instance of "
  1133. "BaseException, not %R",
  1134. type, Py_TYPE(value));
  1135. goto bad;
  1136. }
  1137. }
  1138. } else {
  1139. PyErr_SetString(PyExc_TypeError,
  1140. "raise: exception class must be a subclass of BaseException");
  1141. goto bad;
  1142. }
  1143. #if PY_VERSION_HEX >= 0x03030000
  1144. if (cause) {
  1145. #else
  1146. if (cause && cause != Py_None) {
  1147. #endif
  1148. PyObject *fixed_cause;
  1149. if (cause == Py_None) {
  1150. fixed_cause = NULL;
  1151. } else if (PyExceptionClass_Check(cause)) {
  1152. fixed_cause = PyObject_CallObject(cause, NULL);
  1153. if (fixed_cause == NULL)
  1154. goto bad;
  1155. } else if (PyExceptionInstance_Check(cause)) {
  1156. fixed_cause = cause;
  1157. Py_INCREF(fixed_cause);
  1158. } else {
  1159. PyErr_SetString(PyExc_TypeError,
  1160. "exception causes must derive from "
  1161. "BaseException");
  1162. goto bad;
  1163. }
  1164. PyException_SetCause(value, fixed_cause);
  1165. }
  1166. PyErr_SetObject(type, value);
  1167. if (tb) {
  1168. #if CYTHON_COMPILING_IN_PYPY
  1169. PyObject *tmp_type, *tmp_value, *tmp_tb;
  1170. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  1171. Py_INCREF(tb);
  1172. PyErr_Restore(tmp_type, tmp_value, tb);
  1173. Py_XDECREF(tmp_tb);
  1174. #else
  1175. PyThreadState *tstate = PyThreadState_GET();
  1176. PyObject* tmp_tb = tstate->curexc_traceback;
  1177. if (tb != tmp_tb) {
  1178. Py_INCREF(tb);
  1179. tstate->curexc_traceback = tb;
  1180. Py_XDECREF(tmp_tb);
  1181. }
  1182. #endif
  1183. }
  1184. bad:
  1185. Py_XDECREF(owned_instance);
  1186. return;
  1187. }
  1188. #endif
  1189. /* CalculateMetaclass */
  1190. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
  1191. Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
  1192. for (i=0; i < nbases; i++) {
  1193. PyTypeObject *tmptype;
  1194. PyObject *tmp = PyTuple_GET_ITEM(bases, i);
  1195. tmptype = Py_TYPE(tmp);
  1196. #if PY_MAJOR_VERSION < 3
  1197. if (tmptype == &PyClass_Type)
  1198. continue;
  1199. #endif
  1200. if (!metaclass) {
  1201. metaclass = tmptype;
  1202. continue;
  1203. }
  1204. if (PyType_IsSubtype(metaclass, tmptype))
  1205. continue;
  1206. if (PyType_IsSubtype(tmptype, metaclass)) {
  1207. metaclass = tmptype;
  1208. continue;
  1209. }
  1210. PyErr_SetString(PyExc_TypeError,
  1211. "metaclass conflict: "
  1212. "the metaclass of a derived class "
  1213. "must be a (non-strict) subclass "
  1214. "of the metaclasses of all its bases");
  1215. return NULL;
  1216. }
  1217. if (!metaclass) {
  1218. #if PY_MAJOR_VERSION < 3
  1219. metaclass = &PyClass_Type;
  1220. #else
  1221. metaclass = &PyType_Type;
  1222. #endif
  1223. }
  1224. Py_INCREF((PyObject*) metaclass);
  1225. return (PyObject*) metaclass;
  1226. }
  1227. /* Py3ClassCreate */
  1228. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
  1229. PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
  1230. PyObject *ns;
  1231. if (metaclass) {
  1232. PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
  1233. if (prep) {
  1234. PyObject *pargs = PyTuple_Pack(2, name, bases);
  1235. if (unlikely(!pargs)) {
  1236. Py_DECREF(prep);
  1237. return NULL;
  1238. }
  1239. ns = PyObject_Call(prep, pargs, mkw);
  1240. Py_DECREF(prep);
  1241. Py_DECREF(pargs);
  1242. } else {
  1243. if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
  1244. return NULL;
  1245. PyErr_Clear();
  1246. ns = PyDict_New();
  1247. }
  1248. } else {
  1249. ns = PyDict_New();
  1250. }
  1251. if (unlikely(!ns))
  1252. return NULL;
  1253. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
  1254. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
  1255. if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
  1256. return ns;
  1257. bad:
  1258. Py_DECREF(ns);
  1259. return NULL;
  1260. }
  1261. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
  1262. PyObject *dict, PyObject *mkw,
  1263. int calculate_metaclass, int allow_py2_metaclass) {
  1264. PyObject *result, *margs;
  1265. PyObject *owned_metaclass = NULL;
  1266. if (allow_py2_metaclass) {
  1267. owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
  1268. if (owned_metaclass) {
  1269. metaclass = owned_metaclass;
  1270. } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
  1271. PyErr_Clear();
  1272. } else {
  1273. return NULL;
  1274. }
  1275. }
  1276. if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
  1277. metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
  1278. Py_XDECREF(owned_metaclass);
  1279. if (unlikely(!metaclass))
  1280. return NULL;
  1281. owned_metaclass = metaclass;
  1282. }
  1283. margs = PyTuple_Pack(3, name, bases, dict);
  1284. if (unlikely(!margs)) {
  1285. result = NULL;
  1286. } else {
  1287. result = PyObject_Call(metaclass, margs, mkw);
  1288. Py_DECREF(margs);
  1289. }
  1290. Py_XDECREF(owned_metaclass);
  1291. return result;
  1292. }
  1293. /* CodeObjectCache */
  1294. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  1295. int start = 0, mid = 0, end = count - 1;
  1296. if (end >= 0 && code_line > entries[end].code_line) {
  1297. return count;
  1298. }
  1299. while (start < end) {
  1300. mid = start + (end - start) / 2;
  1301. if (code_line < entries[mid].code_line) {
  1302. end = mid;
  1303. } else if (code_line > entries[mid].code_line) {
  1304. start = mid + 1;
  1305. } else {
  1306. return mid;
  1307. }
  1308. }
  1309. if (code_line <= entries[mid].code_line) {
  1310. return mid;
  1311. } else {
  1312. return mid + 1;
  1313. }
  1314. }
  1315. static PyCodeObject *__pyx_find_code_object(int code_line) {
  1316. PyCodeObject* code_object;
  1317. int pos;
  1318. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  1319. return NULL;
  1320. }
  1321. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  1322. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  1323. return NULL;
  1324. }
  1325. code_object = __pyx_code_cache.entries[pos].code_object;
  1326. Py_INCREF(code_object);
  1327. return code_object;
  1328. }
  1329. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  1330. int pos, i;
  1331. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  1332. if (unlikely(!code_line)) {
  1333. return;
  1334. }
  1335. if (unlikely(!entries)) {
  1336. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  1337. if (likely(entries)) {
  1338. __pyx_code_cache.entries = entries;
  1339. __pyx_code_cache.max_count = 64;
  1340. __pyx_code_cache.count = 1;
  1341. entries[0].code_line = code_line;
  1342. entries[0].code_object = code_object;
  1343. Py_INCREF(code_object);
  1344. }
  1345. return;
  1346. }
  1347. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  1348. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  1349. PyCodeObject* tmp = entries[pos].code_object;
  1350. entries[pos].code_object = code_object;
  1351. Py_DECREF(tmp);
  1352. return;
  1353. }
  1354. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  1355. int new_max = __pyx_code_cache.max_count + 64;
  1356. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  1357. __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  1358. if (unlikely(!entries)) {
  1359. return;
  1360. }
  1361. __pyx_code_cache.entries = entries;
  1362. __pyx_code_cache.max_count = new_max;
  1363. }
  1364. for (i=__pyx_code_cache.count; i>pos; i--) {
  1365. entries[i] = entries[i-1];
  1366. }
  1367. entries[pos].code_line = code_line;
  1368. entries[pos].code_object = code_object;
  1369. __pyx_code_cache.count++;
  1370. Py_INCREF(code_object);
  1371. }
  1372. /* AddTraceback */
  1373. #include "compile.h"
  1374. #include "frameobject.h"
  1375. #include "traceback.h"
  1376. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  1377. const char *funcname, int c_line,
  1378. int py_line, const char *filename) {
  1379. PyCodeObject *py_code = 0;
  1380. PyObject *py_srcfile = 0;
  1381. PyObject *py_funcname = 0;
  1382. #if PY_MAJOR_VERSION < 3
  1383. py_srcfile = PyString_FromString(filename);
  1384. #else
  1385. py_srcfile = PyUnicode_FromString(filename);
  1386. #endif
  1387. if (!py_srcfile) goto bad;
  1388. if (c_line) {
  1389. #if PY_MAJOR_VERSION < 3
  1390. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  1391. #else
  1392. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  1393. #endif
  1394. }
  1395. else {
  1396. #if PY_MAJOR_VERSION < 3
  1397. py_funcname = PyString_FromString(funcname);
  1398. #else
  1399. py_funcname = PyUnicode_FromString(funcname);
  1400. #endif
  1401. }
  1402. if (!py_funcname) goto bad;
  1403. py_code = __Pyx_PyCode_New(
  1404. 0,
  1405. 0,
  1406. 0,
  1407. 0,
  1408. 0,
  1409. __pyx_empty_bytes, /*PyObject *code,*/
  1410. __pyx_empty_tuple, /*PyObject *consts,*/
  1411. __pyx_empty_tuple, /*PyObject *names,*/
  1412. __pyx_empty_tuple, /*PyObject *varnames,*/
  1413. __pyx_empty_tuple, /*PyObject *freevars,*/
  1414. __pyx_empty_tuple, /*PyObject *cellvars,*/
  1415. py_srcfile, /*PyObject *filename,*/
  1416. py_funcname, /*PyObject *name,*/
  1417. py_line,
  1418. __pyx_empty_bytes /*PyObject *lnotab*/
  1419. );
  1420. Py_DECREF(py_srcfile);
  1421. Py_DECREF(py_funcname);
  1422. return py_code;
  1423. bad:
  1424. Py_XDECREF(py_srcfile);
  1425. Py_XDECREF(py_funcname);
  1426. return NULL;
  1427. }
  1428. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  1429. int py_line, const char *filename) {
  1430. PyCodeObject *py_code = 0;
  1431. PyFrameObject *py_frame = 0;
  1432. py_code = __pyx_find_code_object(c_line ? c_line : py_line);
  1433. if (!py_code) {
  1434. py_code = __Pyx_CreateCodeObjectForTraceback(
  1435. funcname, c_line, py_line, filename);
  1436. if (!py_code) goto bad;
  1437. __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
  1438. }
  1439. py_frame = PyFrame_New(
  1440. PyThreadState_GET(), /*PyThreadState *tstate,*/
  1441. py_code, /*PyCodeObject *code,*/
  1442. __pyx_d, /*PyObject *globals,*/
  1443. 0 /*PyObject *locals*/
  1444. );
  1445. if (!py_frame) goto bad;
  1446. py_frame->f_lineno = py_line;
  1447. PyTraceBack_Here(py_frame);
  1448. bad:
  1449. Py_XDECREF(py_code);
  1450. Py_XDECREF(py_frame);
  1451. }
  1452. /* CIntToPy */
  1453. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  1454. const long neg_one = (long) -1, const_zero = (long) 0;
  1455. const int is_unsigned = neg_one > const_zero;
  1456. if (is_unsigned) {
  1457. if (sizeof(long) < sizeof(long)) {
  1458. return PyInt_FromLong((long) value);
  1459. } else if (sizeof(long) <= sizeof(unsigned long)) {
  1460. return PyLong_FromUnsignedLong((unsigned long) value);
  1461. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  1462. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  1463. }
  1464. } else {
  1465. if (sizeof(long) <= sizeof(long)) {
  1466. return PyInt_FromLong((long) value);
  1467. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  1468. return PyLong_FromLongLong((PY_LONG_LONG) value);
  1469. }
  1470. }
  1471. {
  1472. int one = 1; int little = (int)*(unsigned char *)&one;
  1473. unsigned char *bytes = (unsigned char *)&value;
  1474. return _PyLong_FromByteArray(bytes, sizeof(long),
  1475. little, !is_unsigned);
  1476. }
  1477. }
  1478. /* CIntFromPyVerify */
  1479. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  1480. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  1481. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  1482. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  1483. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  1484. {\
  1485. func_type value = func_value;\
  1486. if (sizeof(target_type) < sizeof(func_type)) {\
  1487. if (unlikely(value != (func_type) (target_type) value)) {\
  1488. func_type zero = 0;\
  1489. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  1490. return (target_type) -1;\
  1491. if (is_unsigned && unlikely(value < zero))\
  1492. goto raise_neg_overflow;\
  1493. else\
  1494. goto raise_overflow;\
  1495. }\
  1496. }\
  1497. return (target_type) value;\
  1498. }
  1499. /* CIntFromPy */
  1500. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  1501. const long neg_one = (long) -1, const_zero = (long) 0;
  1502. const int is_unsigned = neg_one > const_zero;
  1503. #if PY_MAJOR_VERSION < 3
  1504. if (likely(PyInt_Check(x))) {
  1505. if (sizeof(long) < sizeof(long)) {
  1506. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  1507. } else {
  1508. long val = PyInt_AS_LONG(x);
  1509. if (is_unsigned && unlikely(val < 0)) {
  1510. goto raise_neg_overflow;
  1511. }
  1512. return (long) val;
  1513. }
  1514. } else
  1515. #endif
  1516. if (likely(PyLong_Check(x))) {
  1517. if (is_unsigned) {
  1518. #if CYTHON_USE_PYLONG_INTERNALS
  1519. const digit* digits = ((PyLongObject*)x)->ob_digit;
  1520. switch (Py_SIZE(x)) {
  1521. case 0: return (long) 0;
  1522. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  1523. case 2:
  1524. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  1525. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  1526. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1527. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  1528. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  1529. }
  1530. }
  1531. break;
  1532. case 3:
  1533. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  1534. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  1535. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1536. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  1537. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  1538. }
  1539. }
  1540. break;
  1541. case 4:
  1542. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  1543. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  1544. __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])))
  1545. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  1546. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  1547. }
  1548. }
  1549. break;
  1550. }
  1551. #endif
  1552. #if CYTHON_COMPILING_IN_CPYTHON
  1553. if (unlikely(Py_SIZE(x) < 0)) {
  1554. goto raise_neg_overflow;
  1555. }
  1556. #else
  1557. {
  1558. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  1559. if (unlikely(result < 0))
  1560. return (long) -1;
  1561. if (unlikely(result == 1))
  1562. goto raise_neg_overflow;
  1563. }
  1564. #endif
  1565. if (sizeof(long) <= sizeof(unsigned long)) {
  1566. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  1567. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  1568. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  1569. }
  1570. } else {
  1571. #if CYTHON_USE_PYLONG_INTERNALS
  1572. const digit* digits = ((PyLongObject*)x)->ob_digit;
  1573. switch (Py_SIZE(x)) {
  1574. case 0: return (long) 0;
  1575. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  1576. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  1577. case -2:
  1578. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  1579. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  1580. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1581. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  1582. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  1583. }
  1584. }
  1585. break;
  1586. case 2:
  1587. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  1588. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  1589. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1590. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  1591. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  1592. }
  1593. }
  1594. break;
  1595. case -3:
  1596. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  1597. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  1598. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1599. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  1600. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  1601. }
  1602. }
  1603. break;
  1604. case 3:
  1605. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  1606. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  1607. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1608. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  1609. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  1610. }
  1611. }
  1612. break;
  1613. case -4:
  1614. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  1615. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  1616. __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])))
  1617. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  1618. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  1619. }
  1620. }
  1621. break;
  1622. case 4:
  1623. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  1624. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  1625. __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])))
  1626. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  1627. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  1628. }
  1629. }
  1630. break;
  1631. }
  1632. #endif
  1633. if (sizeof(long) <= sizeof(long)) {
  1634. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  1635. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  1636. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  1637. }
  1638. }
  1639. {
  1640. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  1641. PyErr_SetString(PyExc_RuntimeError,
  1642. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  1643. #else
  1644. long val;
  1645. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  1646. #if PY_MAJOR_VERSION < 3
  1647. if (likely(v) && !PyLong_Check(v)) {
  1648. PyObject *tmp = v;
  1649. v = PyNumber_Long(tmp);
  1650. Py_DECREF(tmp);
  1651. }
  1652. #endif
  1653. if (likely(v)) {
  1654. int one = 1; int is_little = (int)*(unsigned char *)&one;
  1655. unsigned char *bytes = (unsigned char *)&val;
  1656. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  1657. bytes, sizeof(val),
  1658. is_little, !is_unsigned);
  1659. Py_DECREF(v);
  1660. if (likely(!ret))
  1661. return val;
  1662. }
  1663. #endif
  1664. return (long) -1;
  1665. }
  1666. } else {
  1667. long val;
  1668. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  1669. if (!tmp) return (long) -1;
  1670. val = __Pyx_PyInt_As_long(tmp);
  1671. Py_DECREF(tmp);
  1672. return val;
  1673. }
  1674. raise_overflow:
  1675. PyErr_SetString(PyExc_OverflowError,
  1676. "value too large to convert to long");
  1677. return (long) -1;
  1678. raise_neg_overflow:
  1679. PyErr_SetString(PyExc_OverflowError,
  1680. "can't convert negative value to long");
  1681. return (long) -1;
  1682. }
  1683. /* CIntFromPy */
  1684. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  1685. const int neg_one = (int) -1, const_zero = (int) 0;
  1686. const int is_unsigned = neg_one > const_zero;
  1687. #if PY_MAJOR_VERSION < 3
  1688. if (likely(PyInt_Check(x))) {
  1689. if (sizeof(int) < sizeof(long)) {
  1690. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  1691. } else {
  1692. long val = PyInt_AS_LONG(x);
  1693. if (is_unsigned && unlikely(val < 0)) {
  1694. goto raise_neg_overflow;
  1695. }
  1696. return (int) val;
  1697. }
  1698. } else
  1699. #endif
  1700. if (likely(PyLong_Check(x))) {
  1701. if (is_unsigned) {
  1702. #if CYTHON_USE_PYLONG_INTERNALS
  1703. const digit* digits = ((PyLongObject*)x)->ob_digit;
  1704. switch (Py_SIZE(x)) {
  1705. case 0: return (int) 0;
  1706. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  1707. case 2:
  1708. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  1709. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  1710. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1711. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  1712. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  1713. }
  1714. }
  1715. break;
  1716. case 3:
  1717. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  1718. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  1719. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1720. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  1721. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  1722. }
  1723. }
  1724. break;
  1725. case 4:
  1726. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  1727. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  1728. __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])))
  1729. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  1730. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  1731. }
  1732. }
  1733. break;
  1734. }
  1735. #endif
  1736. #if CYTHON_COMPILING_IN_CPYTHON
  1737. if (unlikely(Py_SIZE(x) < 0)) {
  1738. goto raise_neg_overflow;
  1739. }
  1740. #else
  1741. {
  1742. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  1743. if (unlikely(result < 0))
  1744. return (int) -1;
  1745. if (unlikely(result == 1))
  1746. goto raise_neg_overflow;
  1747. }
  1748. #endif
  1749. if (sizeof(int) <= sizeof(unsigned long)) {
  1750. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  1751. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  1752. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  1753. }
  1754. } else {
  1755. #if CYTHON_USE_PYLONG_INTERNALS
  1756. const digit* digits = ((PyLongObject*)x)->ob_digit;
  1757. switch (Py_SIZE(x)) {
  1758. case 0: return (int) 0;
  1759. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  1760. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  1761. case -2:
  1762. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  1763. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  1764. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1765. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  1766. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  1767. }
  1768. }
  1769. break;
  1770. case 2:
  1771. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  1772. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  1773. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1774. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  1775. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  1776. }
  1777. }
  1778. break;
  1779. case -3:
  1780. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  1781. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  1782. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1783. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  1784. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  1785. }
  1786. }
  1787. break;
  1788. case 3:
  1789. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  1790. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  1791. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1792. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  1793. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  1794. }
  1795. }
  1796. break;
  1797. case -4:
  1798. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  1799. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  1800. __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])))
  1801. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  1802. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  1803. }
  1804. }
  1805. break;
  1806. case 4:
  1807. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  1808. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  1809. __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])))
  1810. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  1811. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  1812. }
  1813. }
  1814. break;
  1815. }
  1816. #endif
  1817. if (sizeof(int) <= sizeof(long)) {
  1818. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  1819. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  1820. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  1821. }
  1822. }
  1823. {
  1824. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  1825. PyErr_SetString(PyExc_RuntimeError,
  1826. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  1827. #else
  1828. int val;
  1829. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  1830. #if PY_MAJOR_VERSION < 3
  1831. if (likely(v) && !PyLong_Check(v)) {
  1832. PyObject *tmp = v;
  1833. v = PyNumber_Long(tmp);
  1834. Py_DECREF(tmp);
  1835. }
  1836. #endif
  1837. if (likely(v)) {
  1838. int one = 1; int is_little = (int)*(unsigned char *)&one;
  1839. unsigned char *bytes = (unsigned char *)&val;
  1840. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  1841. bytes, sizeof(val),
  1842. is_little, !is_unsigned);
  1843. Py_DECREF(v);
  1844. if (likely(!ret))
  1845. return val;
  1846. }
  1847. #endif
  1848. return (int) -1;
  1849. }
  1850. } else {
  1851. int val;
  1852. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  1853. if (!tmp) return (int) -1;
  1854. val = __Pyx_PyInt_As_int(tmp);
  1855. Py_DECREF(tmp);
  1856. return val;
  1857. }
  1858. raise_overflow:
  1859. PyErr_SetString(PyExc_OverflowError,
  1860. "value too large to convert to int");
  1861. return (int) -1;
  1862. raise_neg_overflow:
  1863. PyErr_SetString(PyExc_OverflowError,
  1864. "can't convert negative value to int");
  1865. return (int) -1;
  1866. }
  1867. /* CheckBinaryVersion */
  1868. static int __Pyx_check_binary_version(void) {
  1869. char ctversion[4], rtversion[4];
  1870. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  1871. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  1872. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  1873. char message[200];
  1874. PyOS_snprintf(message, sizeof(message),
  1875. "compiletime version %s of module '%.100s' "
  1876. "does not match runtime version %s",
  1877. ctversion, __Pyx_MODULE_NAME, rtversion);
  1878. return PyErr_WarnEx(NULL, message, 1);
  1879. }
  1880. return 0;
  1881. }
  1882. /* InitStrings */
  1883. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  1884. while (t->p) {
  1885. #if PY_MAJOR_VERSION < 3
  1886. if (t->is_unicode) {
  1887. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  1888. } else if (t->intern) {
  1889. *t->p = PyString_InternFromString(t->s);
  1890. } else {
  1891. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  1892. }
  1893. #else
  1894. if (t->is_unicode | t->is_str) {
  1895. if (t->intern) {
  1896. *t->p = PyUnicode_InternFromString(t->s);
  1897. } else if (t->encoding) {
  1898. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  1899. } else {
  1900. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  1901. }
  1902. } else {
  1903. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  1904. }
  1905. #endif
  1906. if (!*t->p)
  1907. return -1;
  1908. ++t;
  1909. }
  1910. return 0;
  1911. }
  1912. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  1913. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  1914. }
  1915. static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
  1916. Py_ssize_t ignore;
  1917. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  1918. }
  1919. static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  1920. #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  1921. if (
  1922. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  1923. __Pyx_sys_getdefaultencoding_not_ascii &&
  1924. #endif
  1925. PyUnicode_Check(o)) {
  1926. #if PY_VERSION_HEX < 0x03030000
  1927. char* defenc_c;
  1928. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  1929. if (!defenc) return NULL;
  1930. defenc_c = PyBytes_AS_STRING(defenc);
  1931. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  1932. {
  1933. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  1934. char* c;
  1935. for (c = defenc_c; c < end; c++) {
  1936. if ((unsigned char) (*c) >= 128) {
  1937. PyUnicode_AsASCIIString(o);
  1938. return NULL;
  1939. }
  1940. }
  1941. }
  1942. #endif
  1943. *length = PyBytes_GET_SIZE(defenc);
  1944. return defenc_c;
  1945. #else
  1946. if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
  1947. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  1948. if (PyUnicode_IS_ASCII(o)) {
  1949. *length = PyUnicode_GET_LENGTH(o);
  1950. return PyUnicode_AsUTF8(o);
  1951. } else {
  1952. PyUnicode_AsASCIIString(o);
  1953. return NULL;
  1954. }
  1955. #else
  1956. return PyUnicode_AsUTF8AndSize(o, length);
  1957. #endif
  1958. #endif
  1959. } else
  1960. #endif
  1961. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  1962. if (PyByteArray_Check(o)) {
  1963. *length = PyByteArray_GET_SIZE(o);
  1964. return PyByteArray_AS_STRING(o);
  1965. } else
  1966. #endif
  1967. {
  1968. char* result;
  1969. int r = PyBytes_AsStringAndSize(o, &result, length);
  1970. if (unlikely(r < 0)) {
  1971. return NULL;
  1972. } else {
  1973. return result;
  1974. }
  1975. }
  1976. }
  1977. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  1978. int is_true = x == Py_True;
  1979. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  1980. else return PyObject_IsTrue(x);
  1981. }
  1982. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  1983. PyNumberMethods *m;
  1984. const char *name = NULL;
  1985. PyObject *res = NULL;
  1986. #if PY_MAJOR_VERSION < 3
  1987. if (PyInt_Check(x) || PyLong_Check(x))
  1988. #else
  1989. if (PyLong_Check(x))
  1990. #endif
  1991. return __Pyx_NewRef(x);
  1992. m = Py_TYPE(x)->tp_as_number;
  1993. #if PY_MAJOR_VERSION < 3
  1994. if (m && m->nb_int) {
  1995. name = "int";
  1996. res = PyNumber_Int(x);
  1997. }
  1998. else if (m && m->nb_long) {
  1999. name = "long";
  2000. res = PyNumber_Long(x);
  2001. }
  2002. #else
  2003. if (m && m->nb_int) {
  2004. name = "int";
  2005. res = PyNumber_Long(x);
  2006. }
  2007. #endif
  2008. if (res) {
  2009. #if PY_MAJOR_VERSION < 3
  2010. if (!PyInt_Check(res) && !PyLong_Check(res)) {
  2011. #else
  2012. if (!PyLong_Check(res)) {
  2013. #endif
  2014. PyErr_Format(PyExc_TypeError,
  2015. "__%.4s__ returned non-%.4s (type %.200s)",
  2016. name, name, Py_TYPE(res)->tp_name);
  2017. Py_DECREF(res);
  2018. return NULL;
  2019. }
  2020. }
  2021. else if (!PyErr_Occurred()) {
  2022. PyErr_SetString(PyExc_TypeError,
  2023. "an integer is required");
  2024. }
  2025. return res;
  2026. }
  2027. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  2028. Py_ssize_t ival;
  2029. PyObject *x;
  2030. #if PY_MAJOR_VERSION < 3
  2031. if (likely(PyInt_CheckExact(b))) {
  2032. if (sizeof(Py_ssize_t) >= sizeof(long))
  2033. return PyInt_AS_LONG(b);
  2034. else
  2035. return PyInt_AsSsize_t(x);
  2036. }
  2037. #endif
  2038. if (likely(PyLong_CheckExact(b))) {
  2039. #if CYTHON_USE_PYLONG_INTERNALS
  2040. const digit* digits = ((PyLongObject*)b)->ob_digit;
  2041. const Py_ssize_t size = Py_SIZE(b);
  2042. if (likely(__Pyx_sst_abs(size) <= 1)) {
  2043. ival = likely(size) ? digits[0] : 0;
  2044. if (size == -1) ival = -ival;
  2045. return ival;
  2046. } else {
  2047. switch (size) {
  2048. case 2:
  2049. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  2050. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  2051. }
  2052. break;
  2053. case -2:
  2054. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  2055. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  2056. }
  2057. break;
  2058. case 3:
  2059. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  2060. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  2061. }
  2062. break;
  2063. case -3:
  2064. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  2065. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  2066. }
  2067. break;
  2068. case 4:
  2069. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  2070. 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]));
  2071. }
  2072. break;
  2073. case -4:
  2074. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  2075. 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]));
  2076. }
  2077. break;
  2078. }
  2079. }
  2080. #endif
  2081. return PyLong_AsSsize_t(b);
  2082. }
  2083. x = PyNumber_Index(b);
  2084. if (!x) return -1;
  2085. ival = PyInt_AsSsize_t(x);
  2086. Py_DECREF(x);
  2087. return ival;
  2088. }
  2089. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  2090. return PyInt_FromSize_t(ival);
  2091. }
  2092. #endif /* Py_PYTHON_H */