python.c 109 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650
  1. /* Generated by Cython 0.20.1 on Sun Mar 16 22:58:15 2014 */
  2. #define PY_SSIZE_T_CLEAN
  3. #ifndef CYTHON_USE_PYLONG_INTERNALS
  4. #ifdef PYLONG_BITS_IN_DIGIT
  5. #define CYTHON_USE_PYLONG_INTERNALS 0
  6. #else
  7. #include "pyconfig.h"
  8. #ifdef PYLONG_BITS_IN_DIGIT
  9. #define CYTHON_USE_PYLONG_INTERNALS 1
  10. #else
  11. #define CYTHON_USE_PYLONG_INTERNALS 0
  12. #endif
  13. #endif
  14. #endif
  15. #include "Python.h"
  16. #ifndef Py_PYTHON_H
  17. #error Python headers needed to compile C extensions, please install development version of Python.
  18. #elif PY_VERSION_HEX < 0x02040000
  19. #error Cython requires Python 2.4+.
  20. #else
  21. #define CYTHON_ABI "0_20_1"
  22. #include <stddef.h> /* For offsetof */
  23. #ifndef offsetof
  24. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  25. #endif
  26. #if !defined(WIN32) && !defined(MS_WINDOWS)
  27. #ifndef __stdcall
  28. #define __stdcall
  29. #endif
  30. #ifndef __cdecl
  31. #define __cdecl
  32. #endif
  33. #ifndef __fastcall
  34. #define __fastcall
  35. #endif
  36. #endif
  37. #ifndef DL_IMPORT
  38. #define DL_IMPORT(t) t
  39. #endif
  40. #ifndef DL_EXPORT
  41. #define DL_EXPORT(t) t
  42. #endif
  43. #ifndef PY_LONG_LONG
  44. #define PY_LONG_LONG LONG_LONG
  45. #endif
  46. #ifndef Py_HUGE_VAL
  47. #define Py_HUGE_VAL HUGE_VAL
  48. #endif
  49. #ifdef PYPY_VERSION
  50. #define CYTHON_COMPILING_IN_PYPY 1
  51. #define CYTHON_COMPILING_IN_CPYTHON 0
  52. #else
  53. #define CYTHON_COMPILING_IN_PYPY 0
  54. #define CYTHON_COMPILING_IN_CPYTHON 1
  55. #endif
  56. #if CYTHON_COMPILING_IN_PYPY
  57. #define Py_OptimizeFlag 0
  58. #endif
  59. #if PY_VERSION_HEX < 0x02050000
  60. typedef int Py_ssize_t;
  61. #define PY_SSIZE_T_MAX INT_MAX
  62. #define PY_SSIZE_T_MIN INT_MIN
  63. #define PY_FORMAT_SIZE_T ""
  64. #define CYTHON_FORMAT_SSIZE_T ""
  65. #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  66. #define PyInt_AsSsize_t(o) __Pyx_PyInt_As_int(o)
  67. #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
  68. (PyErr_Format(PyExc_TypeError, \
  69. "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
  70. (PyObject*)0))
  71. #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \
  72. !PyComplex_Check(o))
  73. #define PyIndex_Check __Pyx_PyIndex_Check
  74. #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  75. #define __PYX_BUILD_PY_SSIZE_T "i"
  76. #else
  77. #define __PYX_BUILD_PY_SSIZE_T "n"
  78. #define CYTHON_FORMAT_SSIZE_T "z"
  79. #define __Pyx_PyIndex_Check PyIndex_Check
  80. #endif
  81. #if PY_VERSION_HEX < 0x02060000
  82. #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  83. #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
  84. #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
  85. #define PyVarObject_HEAD_INIT(type, size) \
  86. PyObject_HEAD_INIT(type) size,
  87. #define PyType_Modified(t)
  88. typedef struct {
  89. void *buf;
  90. PyObject *obj;
  91. Py_ssize_t len;
  92. Py_ssize_t itemsize;
  93. int readonly;
  94. int ndim;
  95. char *format;
  96. Py_ssize_t *shape;
  97. Py_ssize_t *strides;
  98. Py_ssize_t *suboffsets;
  99. void *internal;
  100. } Py_buffer;
  101. #define PyBUF_SIMPLE 0
  102. #define PyBUF_WRITABLE 0x0001
  103. #define PyBUF_FORMAT 0x0004
  104. #define PyBUF_ND 0x0008
  105. #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  106. #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  107. #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  108. #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  109. #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  110. #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
  111. #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
  112. typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
  113. typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
  114. #endif
  115. #if PY_MAJOR_VERSION < 3
  116. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  117. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
  118. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  119. #define __Pyx_DefaultClassType PyClass_Type
  120. #else
  121. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  122. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
  123. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  124. #define __Pyx_DefaultClassType PyType_Type
  125. #endif
  126. #if PY_VERSION_HEX < 0x02060000
  127. #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
  128. #endif
  129. #if PY_MAJOR_VERSION >= 3
  130. #define Py_TPFLAGS_CHECKTYPES 0
  131. #define Py_TPFLAGS_HAVE_INDEX 0
  132. #endif
  133. #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  134. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  135. #endif
  136. #if PY_VERSION_HEX < 0x02060000
  137. #define Py_TPFLAGS_HAVE_VERSION_TAG 0
  138. #endif
  139. #if PY_VERSION_HEX < 0x02060000 && !defined(Py_TPFLAGS_IS_ABSTRACT)
  140. #define Py_TPFLAGS_IS_ABSTRACT 0
  141. #endif
  142. #if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE)
  143. #define Py_TPFLAGS_HAVE_FINALIZE 0
  144. #endif
  145. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  146. #define CYTHON_PEP393_ENABLED 1
  147. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \
  148. 0 : _PyUnicode_Ready((PyObject *)(op)))
  149. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  150. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  151. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  152. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  153. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  154. #else
  155. #define CYTHON_PEP393_ENABLED 0
  156. #define __Pyx_PyUnicode_READY(op) (0)
  157. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  158. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  159. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  160. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  161. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  162. #endif
  163. #if CYTHON_COMPILING_IN_PYPY
  164. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  165. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  166. #else
  167. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  168. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
  169. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  170. #endif
  171. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  172. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  173. #if PY_MAJOR_VERSION >= 3
  174. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  175. #else
  176. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  177. #endif
  178. #if PY_MAJOR_VERSION >= 3
  179. #define PyBaseString_Type PyUnicode_Type
  180. #define PyStringObject PyUnicodeObject
  181. #define PyString_Type PyUnicode_Type
  182. #define PyString_Check PyUnicode_Check
  183. #define PyString_CheckExact PyUnicode_CheckExact
  184. #endif
  185. #if PY_VERSION_HEX < 0x02060000
  186. #define PyBytesObject PyStringObject
  187. #define PyBytes_Type PyString_Type
  188. #define PyBytes_Check PyString_Check
  189. #define PyBytes_CheckExact PyString_CheckExact
  190. #define PyBytes_FromString PyString_FromString
  191. #define PyBytes_FromStringAndSize PyString_FromStringAndSize
  192. #define PyBytes_FromFormat PyString_FromFormat
  193. #define PyBytes_DecodeEscape PyString_DecodeEscape
  194. #define PyBytes_AsString PyString_AsString
  195. #define PyBytes_AsStringAndSize PyString_AsStringAndSize
  196. #define PyBytes_Size PyString_Size
  197. #define PyBytes_AS_STRING PyString_AS_STRING
  198. #define PyBytes_GET_SIZE PyString_GET_SIZE
  199. #define PyBytes_Repr PyString_Repr
  200. #define PyBytes_Concat PyString_Concat
  201. #define PyBytes_ConcatAndDel PyString_ConcatAndDel
  202. #endif
  203. #if PY_MAJOR_VERSION >= 3
  204. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  205. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  206. #else
  207. #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \
  208. PyString_Check(obj) || PyUnicode_Check(obj))
  209. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  210. #endif
  211. #if PY_VERSION_HEX < 0x02060000
  212. #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type)
  213. #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type)
  214. #endif
  215. #ifndef PySet_CheckExact
  216. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  217. #endif
  218. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  219. #if PY_MAJOR_VERSION >= 3
  220. #define PyIntObject PyLongObject
  221. #define PyInt_Type PyLong_Type
  222. #define PyInt_Check(op) PyLong_Check(op)
  223. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  224. #define PyInt_FromString PyLong_FromString
  225. #define PyInt_FromUnicode PyLong_FromUnicode
  226. #define PyInt_FromLong PyLong_FromLong
  227. #define PyInt_FromSize_t PyLong_FromSize_t
  228. #define PyInt_FromSsize_t PyLong_FromSsize_t
  229. #define PyInt_AsLong PyLong_AsLong
  230. #define PyInt_AS_LONG PyLong_AS_LONG
  231. #define PyInt_AsSsize_t PyLong_AsSsize_t
  232. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  233. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  234. #define PyNumber_Int PyNumber_Long
  235. #endif
  236. #if PY_MAJOR_VERSION >= 3
  237. #define PyBoolObject PyLongObject
  238. #endif
  239. #if PY_VERSION_HEX < 0x030200A4
  240. typedef long Py_hash_t;
  241. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  242. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  243. #else
  244. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  245. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  246. #endif
  247. #if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  248. #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  249. #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  250. #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
  251. #else
  252. #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
  253. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
  254. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
  255. (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  256. #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
  257. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
  258. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
  259. (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  260. #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
  261. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
  262. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
  263. (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
  264. #endif
  265. #if PY_MAJOR_VERSION >= 3
  266. #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
  267. #endif
  268. #if PY_VERSION_HEX < 0x02050000
  269. #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n)))
  270. #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  271. #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n)))
  272. #else
  273. #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n))
  274. #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  275. #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n))
  276. #endif
  277. #if PY_VERSION_HEX < 0x02050000
  278. #define __Pyx_NAMESTR(n) ((char *)(n))
  279. #define __Pyx_DOCSTR(n) ((char *)(n))
  280. #else
  281. #define __Pyx_NAMESTR(n) (n)
  282. #define __Pyx_DOCSTR(n) (n)
  283. #endif
  284. #ifndef CYTHON_INLINE
  285. #if defined(__GNUC__)
  286. #define CYTHON_INLINE __inline__
  287. #elif defined(_MSC_VER)
  288. #define CYTHON_INLINE __inline
  289. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  290. #define CYTHON_INLINE inline
  291. #else
  292. #define CYTHON_INLINE
  293. #endif
  294. #endif
  295. #ifndef CYTHON_RESTRICT
  296. #if defined(__GNUC__)
  297. #define CYTHON_RESTRICT __restrict__
  298. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  299. #define CYTHON_RESTRICT __restrict
  300. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  301. #define CYTHON_RESTRICT restrict
  302. #else
  303. #define CYTHON_RESTRICT
  304. #endif
  305. #endif
  306. #ifdef NAN
  307. #define __PYX_NAN() ((float) NAN)
  308. #else
  309. static CYTHON_INLINE float __PYX_NAN() {
  310. /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
  311. a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
  312. a quiet NaN. */
  313. float value;
  314. memset(&value, 0xFF, sizeof(value));
  315. return value;
  316. }
  317. #endif
  318. #if PY_MAJOR_VERSION >= 3
  319. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  320. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  321. #else
  322. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  323. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  324. #endif
  325. #ifndef __PYX_EXTERN_C
  326. #ifdef __cplusplus
  327. #define __PYX_EXTERN_C extern "C"
  328. #else
  329. #define __PYX_EXTERN_C extern
  330. #endif
  331. #endif
  332. #if defined(WIN32) || defined(MS_WINDOWS)
  333. #define _USE_MATH_DEFINES
  334. #endif
  335. #include <math.h>
  336. #define __PYX_HAVE__lib__Naked__toolshed__c__python
  337. #define __PYX_HAVE_API__lib__Naked__toolshed__c__python
  338. #ifdef _OPENMP
  339. #include <omp.h>
  340. #endif /* _OPENMP */
  341. #ifdef PYREX_WITHOUT_ASSERTIONS
  342. #define CYTHON_WITHOUT_ASSERTIONS
  343. #endif
  344. #ifndef CYTHON_UNUSED
  345. # if defined(__GNUC__)
  346. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  347. # define CYTHON_UNUSED __attribute__ ((__unused__))
  348. # else
  349. # define CYTHON_UNUSED
  350. # endif
  351. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  352. # define CYTHON_UNUSED __attribute__ ((__unused__))
  353. # else
  354. # define CYTHON_UNUSED
  355. # endif
  356. #endif
  357. typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
  358. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
  359. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  360. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
  361. #define __PYX_DEFAULT_STRING_ENCODING ""
  362. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  363. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  364. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) ( \
  365. (sizeof(type) < sizeof(Py_ssize_t)) || \
  366. (sizeof(type) > sizeof(Py_ssize_t) && \
  367. likely(v < (type)PY_SSIZE_T_MAX || \
  368. v == (type)PY_SSIZE_T_MAX) && \
  369. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN || \
  370. v == (type)PY_SSIZE_T_MIN))) || \
  371. (sizeof(type) == sizeof(Py_ssize_t) && \
  372. (is_signed || likely(v < (type)PY_SSIZE_T_MAX || \
  373. v == (type)PY_SSIZE_T_MAX))) )
  374. static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
  375. static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  376. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  377. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  378. #define __Pyx_PyBytes_FromString PyBytes_FromString
  379. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  380. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*);
  381. #if PY_MAJOR_VERSION < 3
  382. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  383. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  384. #else
  385. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  386. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  387. #endif
  388. #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  389. #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  390. #define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s)
  391. #define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s)
  392. #define __Pyx_PyByteArray_FromUString(s) __Pyx_PyByteArray_FromString((char*)s)
  393. #define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s)
  394. #define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s)
  395. #if PY_MAJOR_VERSION < 3
  396. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
  397. {
  398. const Py_UNICODE *u_end = u;
  399. while (*u_end++) ;
  400. return u_end - u - 1;
  401. }
  402. #else
  403. #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
  404. #endif
  405. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  406. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  407. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  408. #define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
  409. #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
  410. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  411. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
  412. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  413. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  414. #if CYTHON_COMPILING_IN_CPYTHON
  415. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  416. #else
  417. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  418. #endif
  419. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  420. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  421. static int __Pyx_sys_getdefaultencoding_not_ascii;
  422. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  423. PyObject* sys = NULL;
  424. PyObject* default_encoding = NULL;
  425. PyObject* ascii_chars_u = NULL;
  426. PyObject* ascii_chars_b = NULL;
  427. sys = PyImport_ImportModule("sys");
  428. if (sys == NULL) goto bad;
  429. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  430. if (default_encoding == NULL) goto bad;
  431. if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) {
  432. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  433. } else {
  434. const char* default_encoding_c = PyBytes_AS_STRING(default_encoding);
  435. char ascii_chars[128];
  436. int c;
  437. for (c = 0; c < 128; c++) {
  438. ascii_chars[c] = c;
  439. }
  440. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  441. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  442. if (ascii_chars_u == NULL) goto bad;
  443. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  444. if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  445. PyErr_Format(
  446. PyExc_ValueError,
  447. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  448. default_encoding_c);
  449. goto bad;
  450. }
  451. }
  452. Py_XDECREF(sys);
  453. Py_XDECREF(default_encoding);
  454. Py_XDECREF(ascii_chars_u);
  455. Py_XDECREF(ascii_chars_b);
  456. return 0;
  457. bad:
  458. Py_XDECREF(sys);
  459. Py_XDECREF(default_encoding);
  460. Py_XDECREF(ascii_chars_u);
  461. Py_XDECREF(ascii_chars_b);
  462. return -1;
  463. }
  464. #endif
  465. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  466. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  467. #else
  468. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  469. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  470. static char* __PYX_DEFAULT_STRING_ENCODING;
  471. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  472. PyObject* sys = NULL;
  473. PyObject* default_encoding = NULL;
  474. char* default_encoding_c;
  475. sys = PyImport_ImportModule("sys");
  476. if (sys == NULL) goto bad;
  477. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  478. if (default_encoding == NULL) goto bad;
  479. default_encoding_c = PyBytes_AS_STRING(default_encoding);
  480. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
  481. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  482. Py_DECREF(sys);
  483. Py_DECREF(default_encoding);
  484. return 0;
  485. bad:
  486. Py_XDECREF(sys);
  487. Py_XDECREF(default_encoding);
  488. return -1;
  489. }
  490. #endif
  491. #endif
  492. #ifdef __GNUC__
  493. /* Test for GCC > 2.95 */
  494. #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
  495. #define likely(x) __builtin_expect(!!(x), 1)
  496. #define unlikely(x) __builtin_expect(!!(x), 0)
  497. #else /* __GNUC__ > 2 ... */
  498. #define likely(x) (x)
  499. #define unlikely(x) (x)
  500. #endif /* __GNUC__ > 2 ... */
  501. #else /* __GNUC__ */
  502. #define likely(x) (x)
  503. #define unlikely(x) (x)
  504. #endif /* __GNUC__ */
  505. static PyObject *__pyx_m;
  506. static PyObject *__pyx_d;
  507. static PyObject *__pyx_b;
  508. static PyObject *__pyx_empty_tuple;
  509. static PyObject *__pyx_empty_bytes;
  510. static int __pyx_lineno;
  511. static int __pyx_clineno = 0;
  512. static const char * __pyx_cfilenm= __FILE__;
  513. static const char *__pyx_filename;
  514. static const char *__pyx_f[] = {
  515. "python.pyx",
  516. };
  517. /*--- Type declarations ---*/
  518. #ifndef CYTHON_REFNANNY
  519. #define CYTHON_REFNANNY 0
  520. #endif
  521. #if CYTHON_REFNANNY
  522. typedef struct {
  523. void (*INCREF)(void*, PyObject*, int);
  524. void (*DECREF)(void*, PyObject*, int);
  525. void (*GOTREF)(void*, PyObject*, int);
  526. void (*GIVEREF)(void*, PyObject*, int);
  527. void* (*SetupContext)(const char*, int, const char*);
  528. void (*FinishContext)(void**);
  529. } __Pyx_RefNannyAPIStruct;
  530. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  531. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
  532. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  533. #ifdef WITH_THREAD
  534. #define __Pyx_RefNannySetupContext(name, acquire_gil) \
  535. if (acquire_gil) { \
  536. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
  537. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
  538. PyGILState_Release(__pyx_gilstate_save); \
  539. } else { \
  540. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
  541. }
  542. #else
  543. #define __Pyx_RefNannySetupContext(name, acquire_gil) \
  544. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  545. #endif
  546. #define __Pyx_RefNannyFinishContext() \
  547. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  548. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  549. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  550. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  551. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  552. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  553. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  554. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  555. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  556. #else
  557. #define __Pyx_RefNannyDeclarations
  558. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  559. #define __Pyx_RefNannyFinishContext()
  560. #define __Pyx_INCREF(r) Py_INCREF(r)
  561. #define __Pyx_DECREF(r) Py_DECREF(r)
  562. #define __Pyx_GOTREF(r)
  563. #define __Pyx_GIVEREF(r)
  564. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  565. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  566. #define __Pyx_XGOTREF(r)
  567. #define __Pyx_XGIVEREF(r)
  568. #endif /* CYTHON_REFNANNY */
  569. #define __Pyx_XDECREF_SET(r, v) do { \
  570. PyObject *tmp = (PyObject *) r; \
  571. r = v; __Pyx_XDECREF(tmp); \
  572. } while (0)
  573. #define __Pyx_DECREF_SET(r, v) do { \
  574. PyObject *tmp = (PyObject *) r; \
  575. r = v; __Pyx_DECREF(tmp); \
  576. } while (0)
  577. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  578. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  579. #ifndef CYTHON_PROFILE
  580. #define CYTHON_PROFILE 1
  581. #endif
  582. #ifndef CYTHON_TRACE
  583. #define CYTHON_TRACE 0
  584. #endif
  585. #if CYTHON_TRACE
  586. #undef CYTHON_PROFILE_REUSE_FRAME
  587. #endif
  588. #ifndef CYTHON_PROFILE_REUSE_FRAME
  589. #define CYTHON_PROFILE_REUSE_FRAME 0
  590. #endif
  591. #if CYTHON_PROFILE || CYTHON_TRACE
  592. #include "compile.h"
  593. #include "frameobject.h"
  594. #include "traceback.h"
  595. #if CYTHON_PROFILE_REUSE_FRAME
  596. #define CYTHON_FRAME_MODIFIER static
  597. #define CYTHON_FRAME_DEL
  598. #else
  599. #define CYTHON_FRAME_MODIFIER
  600. #define CYTHON_FRAME_DEL Py_CLEAR(__pyx_frame)
  601. #endif
  602. #define __Pyx_TraceDeclarations \
  603. static PyCodeObject *__pyx_frame_code = NULL; \
  604. CYTHON_FRAME_MODIFIER PyFrameObject *__pyx_frame = NULL; \
  605. int __Pyx_use_tracing = 0;
  606. #define __Pyx_TraceCall(funcname, srcfile, firstlineno) \
  607. if (unlikely(PyThreadState_GET()->use_tracing && \
  608. (PyThreadState_GET()->c_profilefunc || (CYTHON_TRACE && PyThreadState_GET()->c_tracefunc)))) { \
  609. __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, funcname, srcfile, firstlineno); \
  610. }
  611. #define __Pyx_TraceException() \
  612. if (unlikely(__Pyx_use_tracing) && PyThreadState_GET()->use_tracing && \
  613. (PyThreadState_GET()->c_profilefunc || (CYTHON_TRACE && PyThreadState_GET()->c_tracefunc))) { \
  614. PyThreadState* tstate = PyThreadState_GET(); \
  615. tstate->use_tracing = 0; \
  616. PyObject *exc_info = __Pyx_GetExceptionTuple(); \
  617. if (exc_info) { \
  618. if (CYTHON_TRACE && tstate->c_tracefunc) \
  619. tstate->c_tracefunc( \
  620. tstate->c_traceobj, __pyx_frame, PyTrace_EXCEPTION, exc_info); \
  621. tstate->c_profilefunc( \
  622. tstate->c_profileobj, __pyx_frame, PyTrace_EXCEPTION, exc_info); \
  623. Py_DECREF(exc_info); \
  624. } \
  625. tstate->use_tracing = 1; \
  626. }
  627. #define __Pyx_TraceReturn(result) \
  628. if (unlikely(__Pyx_use_tracing) && PyThreadState_GET()->use_tracing) { \
  629. PyThreadState* tstate = PyThreadState_GET(); \
  630. tstate->use_tracing = 0; \
  631. if (CYTHON_TRACE && tstate->c_tracefunc) \
  632. tstate->c_tracefunc( \
  633. tstate->c_traceobj, __pyx_frame, PyTrace_RETURN, (PyObject*)result); \
  634. if (tstate->c_profilefunc) \
  635. tstate->c_profilefunc( \
  636. tstate->c_profileobj, __pyx_frame, PyTrace_RETURN, (PyObject*)result); \
  637. CYTHON_FRAME_DEL; \
  638. tstate->use_tracing = 1; \
  639. }
  640. static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno); /*proto*/
  641. static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, const char *funcname, const char *srcfile, int firstlineno); /*proto*/
  642. #else
  643. #define __Pyx_TraceDeclarations
  644. #define __Pyx_TraceCall(funcname, srcfile, firstlineno)
  645. #define __Pyx_TraceException()
  646. #define __Pyx_TraceReturn(result)
  647. #endif /* CYTHON_PROFILE */
  648. #if CYTHON_TRACE
  649. #define __Pyx_TraceLine(lineno) \
  650. if (unlikely(__Pyx_use_tracing) && unlikely(PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_tracefunc)) { \
  651. PyThreadState* tstate = PyThreadState_GET(); \
  652. __pyx_frame->f_lineno = lineno; \
  653. tstate->use_tracing = 0; \
  654. tstate->c_tracefunc(tstate->c_traceobj, __pyx_frame, PyTrace_LINE, NULL); \
  655. tstate->use_tracing = 1; \
  656. }
  657. #else
  658. #define __Pyx_TraceLine(lineno)
  659. #endif
  660. #if CYTHON_COMPILING_IN_CPYTHON
  661. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  662. PyTypeObject* tp = Py_TYPE(obj);
  663. if (likely(tp->tp_getattro))
  664. return tp->tp_getattro(obj, attr_name);
  665. #if PY_MAJOR_VERSION < 3
  666. if (likely(tp->tp_getattr))
  667. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  668. #endif
  669. return PyObject_GetAttr(obj, attr_name);
  670. }
  671. #else
  672. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  673. #endif
  674. static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/
  675. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/
  676. #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
  677. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
  678. __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \
  679. (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \
  680. __Pyx_GetItemInt_Generic(o, to_py_func(i))))
  681. #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
  682. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
  683. __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
  684. (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
  685. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  686. int wraparound, int boundscheck);
  687. #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
  688. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
  689. __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
  690. (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
  691. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  692. int wraparound, int boundscheck);
  693. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
  694. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
  695. int is_list, int wraparound, int boundscheck);
  696. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /*proto*/
  697. #include <string.h>
  698. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
  699. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
  700. #if PY_MAJOR_VERSION >= 3
  701. #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
  702. #else
  703. #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
  704. #endif
  705. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/
  706. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  707. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  708. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  709. static int __Pyx_check_binary_version(void);
  710. typedef struct {
  711. int code_line;
  712. PyCodeObject* code_object;
  713. } __Pyx_CodeObjectCacheEntry;
  714. struct __Pyx_CodeObjectCache {
  715. int count;
  716. int max_count;
  717. __Pyx_CodeObjectCacheEntry* entries;
  718. };
  719. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  720. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  721. static PyCodeObject *__pyx_find_code_object(int code_line);
  722. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  723. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  724. int py_line, const char *filename); /*proto*/
  725. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
  726. /* Module declarations from 'lib.Naked.toolshed.c.python' */
  727. #define __Pyx_MODULE_NAME "lib.Naked.toolshed.c.python"
  728. int __pyx_module_is_main_lib__Naked__toolshed__c__python = 0;
  729. /* Implementation of 'lib.Naked.toolshed.c.python' */
  730. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_6python_py_version(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  731. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_6python_2py_major_version(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  732. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_6python_4py_minor_version(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  733. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_6python_6py_patch_version(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  734. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_6python_8is_py2(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  735. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_6python_10is_py3(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  736. static char __pyx_k_sys[] = "sys";
  737. static char __pyx_k_main[] = "__main__";
  738. static char __pyx_k_name[] = "__name__";
  739. static char __pyx_k_test[] = "__test__";
  740. static char __pyx_k_import[] = "__import__";
  741. static char __pyx_k_is_py2[] = "is_py2";
  742. static char __pyx_k_is_py3[] = "is_py3";
  743. static char __pyx_k_py_version[] = "py_version";
  744. static char __pyx_k_version_info[] = "version_info";
  745. static char __pyx_k_py_major_version[] = "py_major_version";
  746. static char __pyx_k_py_minor_version[] = "py_minor_version";
  747. static char __pyx_k_py_patch_version[] = "py_patch_version";
  748. static char __pyx_k_lib_Naked_toolshed_c_python[] = "lib.Naked.toolshed.c.python";
  749. static char __pyx_k_Users_ces_Desktop_code_naked_li[] = "/Users/ces/Desktop/code/naked/lib/Naked/toolshed/c/python.pyx";
  750. static PyObject *__pyx_kp_s_Users_ces_Desktop_code_naked_li;
  751. static PyObject *__pyx_n_s_import;
  752. static PyObject *__pyx_n_s_is_py2;
  753. static PyObject *__pyx_n_s_is_py3;
  754. static PyObject *__pyx_n_s_lib_Naked_toolshed_c_python;
  755. static PyObject *__pyx_n_s_main;
  756. static PyObject *__pyx_n_s_name;
  757. static PyObject *__pyx_n_s_py_major_version;
  758. static PyObject *__pyx_n_s_py_minor_version;
  759. static PyObject *__pyx_n_s_py_patch_version;
  760. static PyObject *__pyx_n_s_py_version;
  761. static PyObject *__pyx_n_s_sys;
  762. static PyObject *__pyx_n_s_test;
  763. static PyObject *__pyx_n_s_version_info;
  764. static PyObject *__pyx_int_2;
  765. static PyObject *__pyx_int_3;
  766. static PyObject *__pyx_codeobj_;
  767. static PyObject *__pyx_codeobj__2;
  768. static PyObject *__pyx_codeobj__3;
  769. static PyObject *__pyx_codeobj__4;
  770. static PyObject *__pyx_codeobj__5;
  771. static PyObject *__pyx_codeobj__6;
  772. /* "lib/Naked/toolshed/c/python.pyx":14
  773. * # [ py_version function ] (tuple of (major, minor, patch))
  774. * #------------------------------------------------------------------------------
  775. * def py_version(): # <<<<<<<<<<<<<<
  776. * return (version_info[0], version_info[1], version_info[2])
  777. *
  778. */
  779. /* Python wrapper */
  780. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_6python_1py_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  781. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_6python_1py_version = {__Pyx_NAMESTR("py_version"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_6python_1py_version, METH_NOARGS, __Pyx_DOCSTR(0)};
  782. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_6python_1py_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  783. PyObject *__pyx_r = 0;
  784. __Pyx_RefNannyDeclarations
  785. __Pyx_RefNannySetupContext("py_version (wrapper)", 0);
  786. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_6python_py_version(__pyx_self);
  787. /* function exit code */
  788. __Pyx_RefNannyFinishContext();
  789. return __pyx_r;
  790. }
  791. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_6python_py_version(CYTHON_UNUSED PyObject *__pyx_self) {
  792. PyObject *__pyx_r = NULL;
  793. __Pyx_RefNannyDeclarations
  794. PyObject *__pyx_t_1 = NULL;
  795. PyObject *__pyx_t_2 = NULL;
  796. PyObject *__pyx_t_3 = NULL;
  797. PyObject *__pyx_t_4 = NULL;
  798. int __pyx_lineno = 0;
  799. const char *__pyx_filename = NULL;
  800. int __pyx_clineno = 0;
  801. __Pyx_TraceDeclarations
  802. __Pyx_RefNannySetupContext("py_version", 0);
  803. __Pyx_TraceCall("py_version", __pyx_f[0], 14);
  804. /* "lib/Naked/toolshed/c/python.pyx":15
  805. * #------------------------------------------------------------------------------
  806. * def py_version():
  807. * return (version_info[0], version_info[1], version_info[2]) # <<<<<<<<<<<<<<
  808. *
  809. * #------------------------------------------------------------------------------
  810. */
  811. __Pyx_XDECREF(__pyx_r);
  812. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  813. __Pyx_GOTREF(__pyx_t_1);
  814. __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  815. __Pyx_GOTREF(__pyx_t_2);
  816. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  817. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  818. __Pyx_GOTREF(__pyx_t_1);
  819. __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  820. __Pyx_GOTREF(__pyx_t_3);
  821. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  822. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  823. __Pyx_GOTREF(__pyx_t_1);
  824. __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  825. __Pyx_GOTREF(__pyx_t_4);
  826. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  827. __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  828. __Pyx_GOTREF(__pyx_t_1);
  829. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  830. __Pyx_GIVEREF(__pyx_t_2);
  831. PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
  832. __Pyx_GIVEREF(__pyx_t_3);
  833. PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_4);
  834. __Pyx_GIVEREF(__pyx_t_4);
  835. __pyx_t_2 = 0;
  836. __pyx_t_3 = 0;
  837. __pyx_t_4 = 0;
  838. __pyx_r = __pyx_t_1;
  839. __pyx_t_1 = 0;
  840. goto __pyx_L0;
  841. /* "lib/Naked/toolshed/c/python.pyx":14
  842. * # [ py_version function ] (tuple of (major, minor, patch))
  843. * #------------------------------------------------------------------------------
  844. * def py_version(): # <<<<<<<<<<<<<<
  845. * return (version_info[0], version_info[1], version_info[2])
  846. *
  847. */
  848. /* function exit code */
  849. __pyx_L1_error:;
  850. __Pyx_XDECREF(__pyx_t_1);
  851. __Pyx_XDECREF(__pyx_t_2);
  852. __Pyx_XDECREF(__pyx_t_3);
  853. __Pyx_XDECREF(__pyx_t_4);
  854. __Pyx_AddTraceback("lib.Naked.toolshed.c.python.py_version", __pyx_clineno, __pyx_lineno, __pyx_filename);
  855. __pyx_r = NULL;
  856. __pyx_L0:;
  857. __Pyx_XGIVEREF(__pyx_r);
  858. __Pyx_TraceReturn(__pyx_r);
  859. __Pyx_RefNannyFinishContext();
  860. return __pyx_r;
  861. }
  862. /* "lib/Naked/toolshed/c/python.pyx":21
  863. * # Return Python interpreter major version number
  864. * #------------------------------------------------------------------------------
  865. * def py_major_version(): # <<<<<<<<<<<<<<
  866. * return (version_info[0])
  867. *
  868. */
  869. /* Python wrapper */
  870. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_6python_3py_major_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  871. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_6python_3py_major_version = {__Pyx_NAMESTR("py_major_version"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_6python_3py_major_version, METH_NOARGS, __Pyx_DOCSTR(0)};
  872. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_6python_3py_major_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  873. PyObject *__pyx_r = 0;
  874. __Pyx_RefNannyDeclarations
  875. __Pyx_RefNannySetupContext("py_major_version (wrapper)", 0);
  876. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_6python_2py_major_version(__pyx_self);
  877. /* function exit code */
  878. __Pyx_RefNannyFinishContext();
  879. return __pyx_r;
  880. }
  881. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_6python_2py_major_version(CYTHON_UNUSED PyObject *__pyx_self) {
  882. PyObject *__pyx_r = NULL;
  883. __Pyx_RefNannyDeclarations
  884. PyObject *__pyx_t_1 = NULL;
  885. PyObject *__pyx_t_2 = NULL;
  886. int __pyx_lineno = 0;
  887. const char *__pyx_filename = NULL;
  888. int __pyx_clineno = 0;
  889. __Pyx_TraceDeclarations
  890. __Pyx_RefNannySetupContext("py_major_version", 0);
  891. __Pyx_TraceCall("py_major_version", __pyx_f[0], 21);
  892. /* "lib/Naked/toolshed/c/python.pyx":22
  893. * #------------------------------------------------------------------------------
  894. * def py_major_version():
  895. * return (version_info[0]) # <<<<<<<<<<<<<<
  896. *
  897. * #------------------------------------------------------------------------------
  898. */
  899. __Pyx_XDECREF(__pyx_r);
  900. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  901. __Pyx_GOTREF(__pyx_t_1);
  902. __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  903. __Pyx_GOTREF(__pyx_t_2);
  904. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  905. __pyx_r = __pyx_t_2;
  906. __pyx_t_2 = 0;
  907. goto __pyx_L0;
  908. /* "lib/Naked/toolshed/c/python.pyx":21
  909. * # Return Python interpreter major version number
  910. * #------------------------------------------------------------------------------
  911. * def py_major_version(): # <<<<<<<<<<<<<<
  912. * return (version_info[0])
  913. *
  914. */
  915. /* function exit code */
  916. __pyx_L1_error:;
  917. __Pyx_XDECREF(__pyx_t_1);
  918. __Pyx_XDECREF(__pyx_t_2);
  919. __Pyx_AddTraceback("lib.Naked.toolshed.c.python.py_major_version", __pyx_clineno, __pyx_lineno, __pyx_filename);
  920. __pyx_r = NULL;
  921. __pyx_L0:;
  922. __Pyx_XGIVEREF(__pyx_r);
  923. __Pyx_TraceReturn(__pyx_r);
  924. __Pyx_RefNannyFinishContext();
  925. return __pyx_r;
  926. }
  927. /* "lib/Naked/toolshed/c/python.pyx":28
  928. * # Return Python interpreter minor version number
  929. * #------------------------------------------------------------------------------
  930. * def py_minor_version(): # <<<<<<<<<<<<<<
  931. * return (version_info[1])
  932. *
  933. */
  934. /* Python wrapper */
  935. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_6python_5py_minor_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  936. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_6python_5py_minor_version = {__Pyx_NAMESTR("py_minor_version"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_6python_5py_minor_version, METH_NOARGS, __Pyx_DOCSTR(0)};
  937. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_6python_5py_minor_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  938. PyObject *__pyx_r = 0;
  939. __Pyx_RefNannyDeclarations
  940. __Pyx_RefNannySetupContext("py_minor_version (wrapper)", 0);
  941. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_6python_4py_minor_version(__pyx_self);
  942. /* function exit code */
  943. __Pyx_RefNannyFinishContext();
  944. return __pyx_r;
  945. }
  946. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_6python_4py_minor_version(CYTHON_UNUSED PyObject *__pyx_self) {
  947. PyObject *__pyx_r = NULL;
  948. __Pyx_RefNannyDeclarations
  949. PyObject *__pyx_t_1 = NULL;
  950. PyObject *__pyx_t_2 = NULL;
  951. int __pyx_lineno = 0;
  952. const char *__pyx_filename = NULL;
  953. int __pyx_clineno = 0;
  954. __Pyx_TraceDeclarations
  955. __Pyx_RefNannySetupContext("py_minor_version", 0);
  956. __Pyx_TraceCall("py_minor_version", __pyx_f[0], 28);
  957. /* "lib/Naked/toolshed/c/python.pyx":29
  958. * #------------------------------------------------------------------------------
  959. * def py_minor_version():
  960. * return (version_info[1]) # <<<<<<<<<<<<<<
  961. *
  962. * #------------------------------------------------------------------------------
  963. */
  964. __Pyx_XDECREF(__pyx_r);
  965. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  966. __Pyx_GOTREF(__pyx_t_1);
  967. __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  968. __Pyx_GOTREF(__pyx_t_2);
  969. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  970. __pyx_r = __pyx_t_2;
  971. __pyx_t_2 = 0;
  972. goto __pyx_L0;
  973. /* "lib/Naked/toolshed/c/python.pyx":28
  974. * # Return Python interpreter minor version number
  975. * #------------------------------------------------------------------------------
  976. * def py_minor_version(): # <<<<<<<<<<<<<<
  977. * return (version_info[1])
  978. *
  979. */
  980. /* function exit code */
  981. __pyx_L1_error:;
  982. __Pyx_XDECREF(__pyx_t_1);
  983. __Pyx_XDECREF(__pyx_t_2);
  984. __Pyx_AddTraceback("lib.Naked.toolshed.c.python.py_minor_version", __pyx_clineno, __pyx_lineno, __pyx_filename);
  985. __pyx_r = NULL;
  986. __pyx_L0:;
  987. __Pyx_XGIVEREF(__pyx_r);
  988. __Pyx_TraceReturn(__pyx_r);
  989. __Pyx_RefNannyFinishContext();
  990. return __pyx_r;
  991. }
  992. /* "lib/Naked/toolshed/c/python.pyx":35
  993. * # Return Python interpreter patch version number
  994. * #------------------------------------------------------------------------------
  995. * def py_patch_version(): # <<<<<<<<<<<<<<
  996. * return (version_info[2])
  997. *
  998. */
  999. /* Python wrapper */
  1000. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_6python_7py_patch_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  1001. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_6python_7py_patch_version = {__Pyx_NAMESTR("py_patch_version"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_6python_7py_patch_version, METH_NOARGS, __Pyx_DOCSTR(0)};
  1002. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_6python_7py_patch_version(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  1003. PyObject *__pyx_r = 0;
  1004. __Pyx_RefNannyDeclarations
  1005. __Pyx_RefNannySetupContext("py_patch_version (wrapper)", 0);
  1006. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_6python_6py_patch_version(__pyx_self);
  1007. /* function exit code */
  1008. __Pyx_RefNannyFinishContext();
  1009. return __pyx_r;
  1010. }
  1011. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_6python_6py_patch_version(CYTHON_UNUSED PyObject *__pyx_self) {
  1012. PyObject *__pyx_r = NULL;
  1013. __Pyx_RefNannyDeclarations
  1014. PyObject *__pyx_t_1 = NULL;
  1015. PyObject *__pyx_t_2 = NULL;
  1016. int __pyx_lineno = 0;
  1017. const char *__pyx_filename = NULL;
  1018. int __pyx_clineno = 0;
  1019. __Pyx_TraceDeclarations
  1020. __Pyx_RefNannySetupContext("py_patch_version", 0);
  1021. __Pyx_TraceCall("py_patch_version", __pyx_f[0], 35);
  1022. /* "lib/Naked/toolshed/c/python.pyx":36
  1023. * #------------------------------------------------------------------------------
  1024. * def py_patch_version():
  1025. * return (version_info[2]) # <<<<<<<<<<<<<<
  1026. *
  1027. * #------------------------------------------------------------------------------
  1028. */
  1029. __Pyx_XDECREF(__pyx_r);
  1030. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1031. __Pyx_GOTREF(__pyx_t_1);
  1032. __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  1033. __Pyx_GOTREF(__pyx_t_2);
  1034. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1035. __pyx_r = __pyx_t_2;
  1036. __pyx_t_2 = 0;
  1037. goto __pyx_L0;
  1038. /* "lib/Naked/toolshed/c/python.pyx":35
  1039. * # Return Python interpreter patch version number
  1040. * #------------------------------------------------------------------------------
  1041. * def py_patch_version(): # <<<<<<<<<<<<<<
  1042. * return (version_info[2])
  1043. *
  1044. */
  1045. /* function exit code */
  1046. __pyx_L1_error:;
  1047. __Pyx_XDECREF(__pyx_t_1);
  1048. __Pyx_XDECREF(__pyx_t_2);
  1049. __Pyx_AddTraceback("lib.Naked.toolshed.c.python.py_patch_version", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1050. __pyx_r = NULL;
  1051. __pyx_L0:;
  1052. __Pyx_XGIVEREF(__pyx_r);
  1053. __Pyx_TraceReturn(__pyx_r);
  1054. __Pyx_RefNannyFinishContext();
  1055. return __pyx_r;
  1056. }
  1057. /* "lib/Naked/toolshed/c/python.pyx":42
  1058. * # Return truth result for question is interpreter running a version of Python 2
  1059. * #------------------------------------------------------------------------------
  1060. * def is_py2(): # <<<<<<<<<<<<<<
  1061. * return (version_info[0] == (2))
  1062. *
  1063. */
  1064. /* Python wrapper */
  1065. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_6python_9is_py2(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  1066. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_6python_9is_py2 = {__Pyx_NAMESTR("is_py2"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_6python_9is_py2, METH_NOARGS, __Pyx_DOCSTR(0)};
  1067. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_6python_9is_py2(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  1068. PyObject *__pyx_r = 0;
  1069. __Pyx_RefNannyDeclarations
  1070. __Pyx_RefNannySetupContext("is_py2 (wrapper)", 0);
  1071. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_6python_8is_py2(__pyx_self);
  1072. /* function exit code */
  1073. __Pyx_RefNannyFinishContext();
  1074. return __pyx_r;
  1075. }
  1076. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_6python_8is_py2(CYTHON_UNUSED PyObject *__pyx_self) {
  1077. PyObject *__pyx_r = NULL;
  1078. __Pyx_RefNannyDeclarations
  1079. PyObject *__pyx_t_1 = NULL;
  1080. PyObject *__pyx_t_2 = NULL;
  1081. int __pyx_lineno = 0;
  1082. const char *__pyx_filename = NULL;
  1083. int __pyx_clineno = 0;
  1084. __Pyx_TraceDeclarations
  1085. __Pyx_RefNannySetupContext("is_py2", 0);
  1086. __Pyx_TraceCall("is_py2", __pyx_f[0], 42);
  1087. /* "lib/Naked/toolshed/c/python.pyx":43
  1088. * #------------------------------------------------------------------------------
  1089. * def is_py2():
  1090. * return (version_info[0] == (2)) # <<<<<<<<<<<<<<
  1091. *
  1092. * #------------------------------------------------------------------------------
  1093. */
  1094. __Pyx_XDECREF(__pyx_r);
  1095. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1096. __Pyx_GOTREF(__pyx_t_1);
  1097. __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  1098. __Pyx_GOTREF(__pyx_t_2);
  1099. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1100. __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1101. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1102. __pyx_r = __pyx_t_1;
  1103. __pyx_t_1 = 0;
  1104. goto __pyx_L0;
  1105. /* "lib/Naked/toolshed/c/python.pyx":42
  1106. * # Return truth result for question is interpreter running a version of Python 2
  1107. * #------------------------------------------------------------------------------
  1108. * def is_py2(): # <<<<<<<<<<<<<<
  1109. * return (version_info[0] == (2))
  1110. *
  1111. */
  1112. /* function exit code */
  1113. __pyx_L1_error:;
  1114. __Pyx_XDECREF(__pyx_t_1);
  1115. __Pyx_XDECREF(__pyx_t_2);
  1116. __Pyx_AddTraceback("lib.Naked.toolshed.c.python.is_py2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1117. __pyx_r = NULL;
  1118. __pyx_L0:;
  1119. __Pyx_XGIVEREF(__pyx_r);
  1120. __Pyx_TraceReturn(__pyx_r);
  1121. __Pyx_RefNannyFinishContext();
  1122. return __pyx_r;
  1123. }
  1124. /* "lib/Naked/toolshed/c/python.pyx":49
  1125. * # Return truth result for question is interpreter running a version of Python 3
  1126. * #------------------------------------------------------------------------------
  1127. * def is_py3(): # <<<<<<<<<<<<<<
  1128. * return (version_info[0] == (3))
  1129. *
  1130. */
  1131. /* Python wrapper */
  1132. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_6python_11is_py3(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  1133. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_6python_11is_py3 = {__Pyx_NAMESTR("is_py3"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_6python_11is_py3, METH_NOARGS, __Pyx_DOCSTR(0)};
  1134. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_6python_11is_py3(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  1135. PyObject *__pyx_r = 0;
  1136. __Pyx_RefNannyDeclarations
  1137. __Pyx_RefNannySetupContext("is_py3 (wrapper)", 0);
  1138. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_6python_10is_py3(__pyx_self);
  1139. /* function exit code */
  1140. __Pyx_RefNannyFinishContext();
  1141. return __pyx_r;
  1142. }
  1143. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_6python_10is_py3(CYTHON_UNUSED PyObject *__pyx_self) {
  1144. PyObject *__pyx_r = NULL;
  1145. __Pyx_RefNannyDeclarations
  1146. PyObject *__pyx_t_1 = NULL;
  1147. PyObject *__pyx_t_2 = NULL;
  1148. int __pyx_lineno = 0;
  1149. const char *__pyx_filename = NULL;
  1150. int __pyx_clineno = 0;
  1151. __Pyx_TraceDeclarations
  1152. __Pyx_RefNannySetupContext("is_py3", 0);
  1153. __Pyx_TraceCall("is_py3", __pyx_f[0], 49);
  1154. /* "lib/Naked/toolshed/c/python.pyx":50
  1155. * #------------------------------------------------------------------------------
  1156. * def is_py3():
  1157. * return (version_info[0] == (3)) # <<<<<<<<<<<<<<
  1158. *
  1159. * if __name__ == '__main__':
  1160. */
  1161. __Pyx_XDECREF(__pyx_r);
  1162. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1163. __Pyx_GOTREF(__pyx_t_1);
  1164. __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  1165. __Pyx_GOTREF(__pyx_t_2);
  1166. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1167. __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1168. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1169. __pyx_r = __pyx_t_1;
  1170. __pyx_t_1 = 0;
  1171. goto __pyx_L0;
  1172. /* "lib/Naked/toolshed/c/python.pyx":49
  1173. * # Return truth result for question is interpreter running a version of Python 3
  1174. * #------------------------------------------------------------------------------
  1175. * def is_py3(): # <<<<<<<<<<<<<<
  1176. * return (version_info[0] == (3))
  1177. *
  1178. */
  1179. /* function exit code */
  1180. __pyx_L1_error:;
  1181. __Pyx_XDECREF(__pyx_t_1);
  1182. __Pyx_XDECREF(__pyx_t_2);
  1183. __Pyx_AddTraceback("lib.Naked.toolshed.c.python.is_py3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1184. __pyx_r = NULL;
  1185. __pyx_L0:;
  1186. __Pyx_XGIVEREF(__pyx_r);
  1187. __Pyx_TraceReturn(__pyx_r);
  1188. __Pyx_RefNannyFinishContext();
  1189. return __pyx_r;
  1190. }
  1191. static PyMethodDef __pyx_methods[] = {
  1192. {0, 0, 0, 0}
  1193. };
  1194. #if PY_MAJOR_VERSION >= 3
  1195. static struct PyModuleDef __pyx_moduledef = {
  1196. #if PY_VERSION_HEX < 0x03020000
  1197. { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  1198. #else
  1199. PyModuleDef_HEAD_INIT,
  1200. #endif
  1201. __Pyx_NAMESTR("python"),
  1202. 0, /* m_doc */
  1203. -1, /* m_size */
  1204. __pyx_methods /* m_methods */,
  1205. NULL, /* m_reload */
  1206. NULL, /* m_traverse */
  1207. NULL, /* m_clear */
  1208. NULL /* m_free */
  1209. };
  1210. #endif
  1211. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  1212. {&__pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_k_Users_ces_Desktop_code_naked_li, sizeof(__pyx_k_Users_ces_Desktop_code_naked_li), 0, 0, 1, 0},
  1213. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  1214. {&__pyx_n_s_is_py2, __pyx_k_is_py2, sizeof(__pyx_k_is_py2), 0, 0, 1, 1},
  1215. {&__pyx_n_s_is_py3, __pyx_k_is_py3, sizeof(__pyx_k_is_py3), 0, 0, 1, 1},
  1216. {&__pyx_n_s_lib_Naked_toolshed_c_python, __pyx_k_lib_Naked_toolshed_c_python, sizeof(__pyx_k_lib_Naked_toolshed_c_python), 0, 0, 1, 1},
  1217. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  1218. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  1219. {&__pyx_n_s_py_major_version, __pyx_k_py_major_version, sizeof(__pyx_k_py_major_version), 0, 0, 1, 1},
  1220. {&__pyx_n_s_py_minor_version, __pyx_k_py_minor_version, sizeof(__pyx_k_py_minor_version), 0, 0, 1, 1},
  1221. {&__pyx_n_s_py_patch_version, __pyx_k_py_patch_version, sizeof(__pyx_k_py_patch_version), 0, 0, 1, 1},
  1222. {&__pyx_n_s_py_version, __pyx_k_py_version, sizeof(__pyx_k_py_version), 0, 0, 1, 1},
  1223. {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  1224. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  1225. {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1},
  1226. {0, 0, 0, 0, 0, 0, 0}
  1227. };
  1228. static int __Pyx_InitCachedBuiltins(void) {
  1229. return 0;
  1230. }
  1231. static int __Pyx_InitCachedConstants(void) {
  1232. __Pyx_RefNannyDeclarations
  1233. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  1234. /* "lib/Naked/toolshed/c/python.pyx":14
  1235. * # [ py_version function ] (tuple of (major, minor, patch))
  1236. * #------------------------------------------------------------------------------
  1237. * def py_version(): # <<<<<<<<<<<<<<
  1238. * return (version_info[0], version_info[1], version_info[2])
  1239. *
  1240. */
  1241. __pyx_codeobj_ = (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_ces_Desktop_code_naked_li, __pyx_n_s_py_version, 14, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1242. /* "lib/Naked/toolshed/c/python.pyx":21
  1243. * # Return Python interpreter major version number
  1244. * #------------------------------------------------------------------------------
  1245. * def py_major_version(): # <<<<<<<<<<<<<<
  1246. * return (version_info[0])
  1247. *
  1248. */
  1249. __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_ces_Desktop_code_naked_li, __pyx_n_s_py_major_version, 21, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1250. /* "lib/Naked/toolshed/c/python.pyx":28
  1251. * # Return Python interpreter minor version number
  1252. * #------------------------------------------------------------------------------
  1253. * def py_minor_version(): # <<<<<<<<<<<<<<
  1254. * return (version_info[1])
  1255. *
  1256. */
  1257. __pyx_codeobj__3 = (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_ces_Desktop_code_naked_li, __pyx_n_s_py_minor_version, 28, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1258. /* "lib/Naked/toolshed/c/python.pyx":35
  1259. * # Return Python interpreter patch version number
  1260. * #------------------------------------------------------------------------------
  1261. * def py_patch_version(): # <<<<<<<<<<<<<<
  1262. * return (version_info[2])
  1263. *
  1264. */
  1265. __pyx_codeobj__4 = (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_ces_Desktop_code_naked_li, __pyx_n_s_py_patch_version, 35, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1266. /* "lib/Naked/toolshed/c/python.pyx":42
  1267. * # Return truth result for question is interpreter running a version of Python 2
  1268. * #------------------------------------------------------------------------------
  1269. * def is_py2(): # <<<<<<<<<<<<<<
  1270. * return (version_info[0] == (2))
  1271. *
  1272. */
  1273. __pyx_codeobj__5 = (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_ces_Desktop_code_naked_li, __pyx_n_s_is_py2, 42, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1274. /* "lib/Naked/toolshed/c/python.pyx":49
  1275. * # Return truth result for question is interpreter running a version of Python 3
  1276. * #------------------------------------------------------------------------------
  1277. * def is_py3(): # <<<<<<<<<<<<<<
  1278. * return (version_info[0] == (3))
  1279. *
  1280. */
  1281. __pyx_codeobj__6 = (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_ces_Desktop_code_naked_li, __pyx_n_s_is_py3, 49, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1282. __Pyx_RefNannyFinishContext();
  1283. return 0;
  1284. __pyx_L1_error:;
  1285. __Pyx_RefNannyFinishContext();
  1286. return -1;
  1287. }
  1288. static int __Pyx_InitGlobals(void) {
  1289. if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  1290. __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1291. __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1292. return 0;
  1293. __pyx_L1_error:;
  1294. return -1;
  1295. }
  1296. #if PY_MAJOR_VERSION < 3
  1297. PyMODINIT_FUNC initpython(void); /*proto*/
  1298. PyMODINIT_FUNC initpython(void)
  1299. #else
  1300. PyMODINIT_FUNC PyInit_python(void); /*proto*/
  1301. PyMODINIT_FUNC PyInit_python(void)
  1302. #endif
  1303. {
  1304. PyObject *__pyx_t_1 = NULL;
  1305. PyObject *__pyx_t_2 = NULL;
  1306. int __pyx_t_3;
  1307. int __pyx_lineno = 0;
  1308. const char *__pyx_filename = NULL;
  1309. int __pyx_clineno = 0;
  1310. __Pyx_RefNannyDeclarations
  1311. #if CYTHON_REFNANNY
  1312. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  1313. if (!__Pyx_RefNanny) {
  1314. PyErr_Clear();
  1315. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  1316. if (!__Pyx_RefNanny)
  1317. Py_FatalError("failed to import 'refnanny' module");
  1318. }
  1319. #endif
  1320. __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_python(void)", 0);
  1321. if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1322. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1323. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1324. #ifdef __Pyx_CyFunction_USED
  1325. if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1326. #endif
  1327. #ifdef __Pyx_FusedFunction_USED
  1328. if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1329. #endif
  1330. #ifdef __Pyx_Generator_USED
  1331. if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1332. #endif
  1333. /*--- Library function declarations ---*/
  1334. /*--- Threads initialization code ---*/
  1335. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  1336. #ifdef WITH_THREAD /* Python build with threading support? */
  1337. PyEval_InitThreads();
  1338. #endif
  1339. #endif
  1340. /*--- Module creation code ---*/
  1341. #if PY_MAJOR_VERSION < 3
  1342. __pyx_m = Py_InitModule4(__Pyx_NAMESTR("python"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  1343. #else
  1344. __pyx_m = PyModule_Create(&__pyx_moduledef);
  1345. #endif
  1346. if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1347. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1348. Py_INCREF(__pyx_d);
  1349. __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1350. #if CYTHON_COMPILING_IN_PYPY
  1351. Py_INCREF(__pyx_b);
  1352. #endif
  1353. if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  1354. /*--- Initialize various global constants etc. ---*/
  1355. if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1356. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  1357. if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1358. #endif
  1359. if (__pyx_module_is_main_lib__Naked__toolshed__c__python) {
  1360. if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  1361. }
  1362. #if PY_MAJOR_VERSION >= 3
  1363. {
  1364. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1365. if (!PyDict_GetItemString(modules, "lib.Naked.toolshed.c.python")) {
  1366. if (unlikely(PyDict_SetItemString(modules, "lib.Naked.toolshed.c.python", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1367. }
  1368. }
  1369. #endif
  1370. /*--- Builtin init code ---*/
  1371. if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1372. /*--- Constants init code ---*/
  1373. if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1374. /*--- Global init code ---*/
  1375. /*--- Variable export code ---*/
  1376. /*--- Function export code ---*/
  1377. /*--- Type init code ---*/
  1378. /*--- Type import code ---*/
  1379. /*--- Variable import code ---*/
  1380. /*--- Function import code ---*/
  1381. /*--- Execution code ---*/
  1382. /* "lib/Naked/toolshed/c/python.pyx":5
  1383. * # cython: profile=True
  1384. *
  1385. * from sys import version_info # <<<<<<<<<<<<<<
  1386. *
  1387. * #------------------------------------------------------------------------------
  1388. */
  1389. __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1390. __Pyx_GOTREF(__pyx_t_1);
  1391. __Pyx_INCREF(__pyx_n_s_version_info);
  1392. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_version_info);
  1393. __Pyx_GIVEREF(__pyx_n_s_version_info);
  1394. __pyx_t_2 = __Pyx_Import(__pyx_n_s_sys, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1395. __Pyx_GOTREF(__pyx_t_2);
  1396. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1397. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1398. __Pyx_GOTREF(__pyx_t_1);
  1399. if (PyDict_SetItem(__pyx_d, __pyx_n_s_version_info, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1400. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1401. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1402. /* "lib/Naked/toolshed/c/python.pyx":14
  1403. * # [ py_version function ] (tuple of (major, minor, patch))
  1404. * #------------------------------------------------------------------------------
  1405. * def py_version(): # <<<<<<<<<<<<<<
  1406. * return (version_info[0], version_info[1], version_info[2])
  1407. *
  1408. */
  1409. __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_6python_1py_version, NULL, __pyx_n_s_lib_Naked_toolshed_c_python); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1410. __Pyx_GOTREF(__pyx_t_2);
  1411. if (PyDict_SetItem(__pyx_d, __pyx_n_s_py_version, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1412. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1413. /* "lib/Naked/toolshed/c/python.pyx":21
  1414. * # Return Python interpreter major version number
  1415. * #------------------------------------------------------------------------------
  1416. * def py_major_version(): # <<<<<<<<<<<<<<
  1417. * return (version_info[0])
  1418. *
  1419. */
  1420. __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_6python_3py_major_version, NULL, __pyx_n_s_lib_Naked_toolshed_c_python); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1421. __Pyx_GOTREF(__pyx_t_2);
  1422. if (PyDict_SetItem(__pyx_d, __pyx_n_s_py_major_version, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1423. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1424. /* "lib/Naked/toolshed/c/python.pyx":28
  1425. * # Return Python interpreter minor version number
  1426. * #------------------------------------------------------------------------------
  1427. * def py_minor_version(): # <<<<<<<<<<<<<<
  1428. * return (version_info[1])
  1429. *
  1430. */
  1431. __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_6python_5py_minor_version, NULL, __pyx_n_s_lib_Naked_toolshed_c_python); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1432. __Pyx_GOTREF(__pyx_t_2);
  1433. if (PyDict_SetItem(__pyx_d, __pyx_n_s_py_minor_version, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1434. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1435. /* "lib/Naked/toolshed/c/python.pyx":35
  1436. * # Return Python interpreter patch version number
  1437. * #------------------------------------------------------------------------------
  1438. * def py_patch_version(): # <<<<<<<<<<<<<<
  1439. * return (version_info[2])
  1440. *
  1441. */
  1442. __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_6python_7py_patch_version, NULL, __pyx_n_s_lib_Naked_toolshed_c_python); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1443. __Pyx_GOTREF(__pyx_t_2);
  1444. if (PyDict_SetItem(__pyx_d, __pyx_n_s_py_patch_version, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1445. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1446. /* "lib/Naked/toolshed/c/python.pyx":42
  1447. * # Return truth result for question is interpreter running a version of Python 2
  1448. * #------------------------------------------------------------------------------
  1449. * def is_py2(): # <<<<<<<<<<<<<<
  1450. * return (version_info[0] == (2))
  1451. *
  1452. */
  1453. __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_6python_9is_py2, NULL, __pyx_n_s_lib_Naked_toolshed_c_python); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1454. __Pyx_GOTREF(__pyx_t_2);
  1455. if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_py2, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1456. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1457. /* "lib/Naked/toolshed/c/python.pyx":49
  1458. * # Return truth result for question is interpreter running a version of Python 3
  1459. * #------------------------------------------------------------------------------
  1460. * def is_py3(): # <<<<<<<<<<<<<<
  1461. * return (version_info[0] == (3))
  1462. *
  1463. */
  1464. __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_6python_11is_py3, NULL, __pyx_n_s_lib_Naked_toolshed_c_python); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1465. __Pyx_GOTREF(__pyx_t_2);
  1466. if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_py3, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1467. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1468. /* "lib/Naked/toolshed/c/python.pyx":52
  1469. * return (version_info[0] == (3))
  1470. *
  1471. * if __name__ == '__main__': # <<<<<<<<<<<<<<
  1472. * pass
  1473. */
  1474. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_name); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1475. __Pyx_GOTREF(__pyx_t_2);
  1476. __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_main, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1477. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1478. if (__pyx_t_3) {
  1479. goto __pyx_L2;
  1480. }
  1481. __pyx_L2:;
  1482. /* "lib/Naked/toolshed/c/python.pyx":1
  1483. * #!/usr/bin/env python # <<<<<<<<<<<<<<
  1484. * # encoding: utf-8
  1485. * # cython: profile=True
  1486. */
  1487. __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1488. __Pyx_GOTREF(__pyx_t_2);
  1489. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1490. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1491. goto __pyx_L0;
  1492. __pyx_L1_error:;
  1493. __Pyx_XDECREF(__pyx_t_1);
  1494. __Pyx_XDECREF(__pyx_t_2);
  1495. if (__pyx_m) {
  1496. __Pyx_AddTraceback("init lib.Naked.toolshed.c.python", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1497. Py_DECREF(__pyx_m); __pyx_m = 0;
  1498. } else if (!PyErr_Occurred()) {
  1499. PyErr_SetString(PyExc_ImportError, "init lib.Naked.toolshed.c.python");
  1500. }
  1501. __pyx_L0:;
  1502. __Pyx_RefNannyFinishContext();
  1503. #if PY_MAJOR_VERSION < 3
  1504. return;
  1505. #else
  1506. return __pyx_m;
  1507. #endif
  1508. }
  1509. /* Runtime support code */
  1510. #if CYTHON_REFNANNY
  1511. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  1512. PyObject *m = NULL, *p = NULL;
  1513. void *r = NULL;
  1514. m = PyImport_ImportModule((char *)modname);
  1515. if (!m) goto end;
  1516. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  1517. if (!p) goto end;
  1518. r = PyLong_AsVoidPtr(p);
  1519. end:
  1520. Py_XDECREF(p);
  1521. Py_XDECREF(m);
  1522. return (__Pyx_RefNannyAPIStruct *)r;
  1523. }
  1524. #endif /* CYTHON_REFNANNY */
  1525. #if CYTHON_PROFILE
  1526. static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
  1527. PyFrameObject** frame,
  1528. const char *funcname,
  1529. const char *srcfile,
  1530. int firstlineno) {
  1531. int retval;
  1532. PyThreadState* tstate = PyThreadState_GET();
  1533. if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) {
  1534. if (*code == NULL) {
  1535. *code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno);
  1536. if (*code == NULL) return 0;
  1537. }
  1538. *frame = PyFrame_New(
  1539. tstate, /*PyThreadState *tstate*/
  1540. *code, /*PyCodeObject *code*/
  1541. __pyx_d, /*PyObject *globals*/
  1542. 0 /*PyObject *locals*/
  1543. );
  1544. if (*frame == NULL) return 0;
  1545. if (CYTHON_TRACE && (*frame)->f_trace == NULL) {
  1546. Py_INCREF(Py_None);
  1547. (*frame)->f_trace = Py_None;
  1548. }
  1549. #if PY_VERSION_HEX < 0x030400B1
  1550. } else {
  1551. (*frame)->f_tstate = tstate;
  1552. #endif
  1553. }
  1554. (*frame)->f_lineno = firstlineno;
  1555. tstate->use_tracing = 0;
  1556. #if CYTHON_TRACE
  1557. if (tstate->c_tracefunc)
  1558. tstate->c_tracefunc(tstate->c_traceobj, *frame, PyTrace_CALL, NULL);
  1559. if (!tstate->c_profilefunc)
  1560. retval = 1;
  1561. else
  1562. #endif
  1563. retval = tstate->c_profilefunc(tstate->c_profileobj, *frame, PyTrace_CALL, NULL) == 0;
  1564. tstate->use_tracing = (tstate->c_profilefunc ||
  1565. (CYTHON_TRACE && tstate->c_tracefunc));
  1566. return tstate->use_tracing && retval;
  1567. }
  1568. static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno) {
  1569. PyObject *py_srcfile = 0;
  1570. PyObject *py_funcname = 0;
  1571. PyCodeObject *py_code = 0;
  1572. #if PY_MAJOR_VERSION < 3
  1573. py_funcname = PyString_FromString(funcname);
  1574. py_srcfile = PyString_FromString(srcfile);
  1575. #else
  1576. py_funcname = PyUnicode_FromString(funcname);
  1577. py_srcfile = PyUnicode_FromString(srcfile);
  1578. #endif
  1579. if (!py_funcname | !py_srcfile) goto bad;
  1580. py_code = PyCode_New(
  1581. 0, /*int argcount,*/
  1582. #if PY_MAJOR_VERSION >= 3
  1583. 0, /*int kwonlyargcount,*/
  1584. #endif
  1585. 0, /*int nlocals,*/
  1586. 0, /*int stacksize,*/
  1587. 0, /*int flags,*/
  1588. __pyx_empty_bytes, /*PyObject *code,*/
  1589. __pyx_empty_tuple, /*PyObject *consts,*/
  1590. __pyx_empty_tuple, /*PyObject *names,*/
  1591. __pyx_empty_tuple, /*PyObject *varnames,*/
  1592. __pyx_empty_tuple, /*PyObject *freevars,*/
  1593. __pyx_empty_tuple, /*PyObject *cellvars,*/
  1594. py_srcfile, /*PyObject *filename,*/
  1595. py_funcname, /*PyObject *name,*/
  1596. firstlineno, /*int firstlineno,*/
  1597. __pyx_empty_bytes /*PyObject *lnotab*/
  1598. );
  1599. bad:
  1600. Py_XDECREF(py_srcfile);
  1601. Py_XDECREF(py_funcname);
  1602. return py_code;
  1603. }
  1604. #endif /* CYTHON_PROFILE */
  1605. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  1606. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  1607. if (unlikely(!result)) {
  1608. PyErr_Format(PyExc_NameError,
  1609. #if PY_MAJOR_VERSION >= 3
  1610. "name '%U' is not defined", name);
  1611. #else
  1612. "name '%.200s' is not defined", PyString_AS_STRING(name));
  1613. #endif
  1614. }
  1615. return result;
  1616. }
  1617. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
  1618. PyObject *result;
  1619. #if CYTHON_COMPILING_IN_CPYTHON
  1620. result = PyDict_GetItem(__pyx_d, name);
  1621. if (result) {
  1622. Py_INCREF(result);
  1623. } else {
  1624. #else
  1625. result = PyObject_GetItem(__pyx_d, name);
  1626. if (!result) {
  1627. PyErr_Clear();
  1628. #endif
  1629. result = __Pyx_GetBuiltinName(name);
  1630. }
  1631. return result;
  1632. }
  1633. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
  1634. PyObject *r;
  1635. if (!j) return NULL;
  1636. r = PyObject_GetItem(o, j);
  1637. Py_DECREF(j);
  1638. return r;
  1639. }
  1640. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  1641. int wraparound, int boundscheck) {
  1642. #if CYTHON_COMPILING_IN_CPYTHON
  1643. if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
  1644. if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
  1645. PyObject *r = PyList_GET_ITEM(o, i);
  1646. Py_INCREF(r);
  1647. return r;
  1648. }
  1649. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  1650. #else
  1651. return PySequence_GetItem(o, i);
  1652. #endif
  1653. }
  1654. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  1655. int wraparound, int boundscheck) {
  1656. #if CYTHON_COMPILING_IN_CPYTHON
  1657. if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
  1658. if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
  1659. PyObject *r = PyTuple_GET_ITEM(o, i);
  1660. Py_INCREF(r);
  1661. return r;
  1662. }
  1663. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  1664. #else
  1665. return PySequence_GetItem(o, i);
  1666. #endif
  1667. }
  1668. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
  1669. int is_list, int wraparound, int boundscheck) {
  1670. #if CYTHON_COMPILING_IN_CPYTHON
  1671. if (is_list || PyList_CheckExact(o)) {
  1672. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
  1673. if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
  1674. PyObject *r = PyList_GET_ITEM(o, n);
  1675. Py_INCREF(r);
  1676. return r;
  1677. }
  1678. }
  1679. else if (PyTuple_CheckExact(o)) {
  1680. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
  1681. if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
  1682. PyObject *r = PyTuple_GET_ITEM(o, n);
  1683. Py_INCREF(r);
  1684. return r;
  1685. }
  1686. } else {
  1687. PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
  1688. if (likely(m && m->sq_item)) {
  1689. if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
  1690. Py_ssize_t l = m->sq_length(o);
  1691. if (likely(l >= 0)) {
  1692. i += l;
  1693. } else {
  1694. if (PyErr_ExceptionMatches(PyExc_OverflowError))
  1695. PyErr_Clear();
  1696. else
  1697. return NULL;
  1698. }
  1699. }
  1700. return m->sq_item(o, i);
  1701. }
  1702. }
  1703. #else
  1704. if (is_list || PySequence_Check(o)) {
  1705. return PySequence_GetItem(o, i);
  1706. }
  1707. #endif
  1708. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  1709. }
  1710. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  1711. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  1712. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  1713. PyErr_Format(PyExc_ImportError,
  1714. #if PY_MAJOR_VERSION < 3
  1715. "cannot import name %.230s", PyString_AS_STRING(name));
  1716. #else
  1717. "cannot import name %S", name);
  1718. #endif
  1719. }
  1720. return value;
  1721. }
  1722. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
  1723. #if CYTHON_COMPILING_IN_PYPY
  1724. return PyObject_RichCompareBool(s1, s2, equals);
  1725. #else
  1726. if (s1 == s2) {
  1727. return (equals == Py_EQ);
  1728. } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
  1729. const char *ps1, *ps2;
  1730. Py_ssize_t length = PyBytes_GET_SIZE(s1);
  1731. if (length != PyBytes_GET_SIZE(s2))
  1732. return (equals == Py_NE);
  1733. ps1 = PyBytes_AS_STRING(s1);
  1734. ps2 = PyBytes_AS_STRING(s2);
  1735. if (ps1[0] != ps2[0]) {
  1736. return (equals == Py_NE);
  1737. } else if (length == 1) {
  1738. return (equals == Py_EQ);
  1739. } else {
  1740. int result = memcmp(ps1, ps2, (size_t)length);
  1741. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  1742. }
  1743. } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
  1744. return (equals == Py_NE);
  1745. } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
  1746. return (equals == Py_NE);
  1747. } else {
  1748. int result;
  1749. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  1750. if (!py_result)
  1751. return -1;
  1752. result = __Pyx_PyObject_IsTrue(py_result);
  1753. Py_DECREF(py_result);
  1754. return result;
  1755. }
  1756. #endif
  1757. }
  1758. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
  1759. #if CYTHON_COMPILING_IN_PYPY
  1760. return PyObject_RichCompareBool(s1, s2, equals);
  1761. #else
  1762. #if PY_MAJOR_VERSION < 3
  1763. PyObject* owned_ref = NULL;
  1764. #endif
  1765. int s1_is_unicode, s2_is_unicode;
  1766. if (s1 == s2) {
  1767. goto return_eq;
  1768. }
  1769. s1_is_unicode = PyUnicode_CheckExact(s1);
  1770. s2_is_unicode = PyUnicode_CheckExact(s2);
  1771. #if PY_MAJOR_VERSION < 3
  1772. if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
  1773. owned_ref = PyUnicode_FromObject(s2);
  1774. if (unlikely(!owned_ref))
  1775. return -1;
  1776. s2 = owned_ref;
  1777. s2_is_unicode = 1;
  1778. } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
  1779. owned_ref = PyUnicode_FromObject(s1);
  1780. if (unlikely(!owned_ref))
  1781. return -1;
  1782. s1 = owned_ref;
  1783. s1_is_unicode = 1;
  1784. } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
  1785. return __Pyx_PyBytes_Equals(s1, s2, equals);
  1786. }
  1787. #endif
  1788. if (s1_is_unicode & s2_is_unicode) {
  1789. Py_ssize_t length;
  1790. int kind;
  1791. void *data1, *data2;
  1792. #if CYTHON_PEP393_ENABLED
  1793. if (unlikely(PyUnicode_READY(s1) < 0) || unlikely(PyUnicode_READY(s2) < 0))
  1794. return -1;
  1795. #endif
  1796. length = __Pyx_PyUnicode_GET_LENGTH(s1);
  1797. if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
  1798. goto return_ne;
  1799. }
  1800. kind = __Pyx_PyUnicode_KIND(s1);
  1801. if (kind != __Pyx_PyUnicode_KIND(s2)) {
  1802. goto return_ne;
  1803. }
  1804. data1 = __Pyx_PyUnicode_DATA(s1);
  1805. data2 = __Pyx_PyUnicode_DATA(s2);
  1806. if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
  1807. goto return_ne;
  1808. } else if (length == 1) {
  1809. goto return_eq;
  1810. } else {
  1811. int result = memcmp(data1, data2, length * kind);
  1812. #if PY_MAJOR_VERSION < 3
  1813. Py_XDECREF(owned_ref);
  1814. #endif
  1815. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  1816. }
  1817. } else if ((s1 == Py_None) & s2_is_unicode) {
  1818. goto return_ne;
  1819. } else if ((s2 == Py_None) & s1_is_unicode) {
  1820. goto return_ne;
  1821. } else {
  1822. int result;
  1823. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  1824. if (!py_result)
  1825. return -1;
  1826. result = __Pyx_PyObject_IsTrue(py_result);
  1827. Py_DECREF(py_result);
  1828. return result;
  1829. }
  1830. return_eq:
  1831. #if PY_MAJOR_VERSION < 3
  1832. Py_XDECREF(owned_ref);
  1833. #endif
  1834. return (equals == Py_EQ);
  1835. return_ne:
  1836. #if PY_MAJOR_VERSION < 3
  1837. Py_XDECREF(owned_ref);
  1838. #endif
  1839. return (equals == Py_NE);
  1840. #endif
  1841. }
  1842. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  1843. PyObject *empty_list = 0;
  1844. PyObject *module = 0;
  1845. PyObject *global_dict = 0;
  1846. PyObject *empty_dict = 0;
  1847. PyObject *list;
  1848. #if PY_VERSION_HEX < 0x03030000
  1849. PyObject *py_import;
  1850. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  1851. if (!py_import)
  1852. goto bad;
  1853. #endif
  1854. if (from_list)
  1855. list = from_list;
  1856. else {
  1857. empty_list = PyList_New(0);
  1858. if (!empty_list)
  1859. goto bad;
  1860. list = empty_list;
  1861. }
  1862. global_dict = PyModule_GetDict(__pyx_m);
  1863. if (!global_dict)
  1864. goto bad;
  1865. empty_dict = PyDict_New();
  1866. if (!empty_dict)
  1867. goto bad;
  1868. #if PY_VERSION_HEX >= 0x02050000
  1869. {
  1870. #if PY_MAJOR_VERSION >= 3
  1871. if (level == -1) {
  1872. if (strchr(__Pyx_MODULE_NAME, '.')) {
  1873. #if PY_VERSION_HEX < 0x03030000
  1874. PyObject *py_level = PyInt_FromLong(1);
  1875. if (!py_level)
  1876. goto bad;
  1877. module = PyObject_CallFunctionObjArgs(py_import,
  1878. name, global_dict, empty_dict, list, py_level, NULL);
  1879. Py_DECREF(py_level);
  1880. #else
  1881. module = PyImport_ImportModuleLevelObject(
  1882. name, global_dict, empty_dict, list, 1);
  1883. #endif
  1884. if (!module) {
  1885. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  1886. goto bad;
  1887. PyErr_Clear();
  1888. }
  1889. }
  1890. level = 0; /* try absolute import on failure */
  1891. }
  1892. #endif
  1893. if (!module) {
  1894. #if PY_VERSION_HEX < 0x03030000
  1895. PyObject *py_level = PyInt_FromLong(level);
  1896. if (!py_level)
  1897. goto bad;
  1898. module = PyObject_CallFunctionObjArgs(py_import,
  1899. name, global_dict, empty_dict, list, py_level, NULL);
  1900. Py_DECREF(py_level);
  1901. #else
  1902. module = PyImport_ImportModuleLevelObject(
  1903. name, global_dict, empty_dict, list, level);
  1904. #endif
  1905. }
  1906. }
  1907. #else
  1908. if (level>0) {
  1909. PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
  1910. goto bad;
  1911. }
  1912. module = PyObject_CallFunctionObjArgs(py_import,
  1913. name, global_dict, empty_dict, list, NULL);
  1914. #endif
  1915. bad:
  1916. #if PY_VERSION_HEX < 0x03030000
  1917. Py_XDECREF(py_import);
  1918. #endif
  1919. Py_XDECREF(empty_list);
  1920. Py_XDECREF(empty_dict);
  1921. return module;
  1922. }
  1923. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  1924. const long neg_one = (long) -1, const_zero = 0;
  1925. const int is_unsigned = neg_one > const_zero;
  1926. if (is_unsigned) {
  1927. if (sizeof(long) < sizeof(long)) {
  1928. return PyInt_FromLong((long) value);
  1929. } else if (sizeof(long) <= sizeof(unsigned long)) {
  1930. return PyLong_FromUnsignedLong((unsigned long) value);
  1931. } else if (sizeof(long) <= sizeof(unsigned long long)) {
  1932. return PyLong_FromUnsignedLongLong((unsigned long long) value);
  1933. }
  1934. } else {
  1935. if (sizeof(long) <= sizeof(long)) {
  1936. return PyInt_FromLong((long) value);
  1937. } else if (sizeof(long) <= sizeof(long long)) {
  1938. return PyLong_FromLongLong((long long) value);
  1939. }
  1940. }
  1941. {
  1942. int one = 1; int little = (int)*(unsigned char *)&one;
  1943. unsigned char *bytes = (unsigned char *)&value;
  1944. return _PyLong_FromByteArray(bytes, sizeof(long),
  1945. little, !is_unsigned);
  1946. }
  1947. }
  1948. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func) \
  1949. { \
  1950. func_type value = func(x); \
  1951. if (sizeof(target_type) < sizeof(func_type)) { \
  1952. if (unlikely(value != (func_type) (target_type) value)) { \
  1953. func_type zero = 0; \
  1954. PyErr_SetString(PyExc_OverflowError, \
  1955. (is_unsigned && unlikely(value < zero)) ? \
  1956. "can't convert negative value to " #target_type : \
  1957. "value too large to convert to " #target_type); \
  1958. return (target_type) -1; \
  1959. } \
  1960. } \
  1961. return (target_type) value; \
  1962. }
  1963. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  1964. #if CYTHON_USE_PYLONG_INTERNALS
  1965. #include "longintrepr.h"
  1966. #endif
  1967. #endif
  1968. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  1969. const long neg_one = (long) -1, const_zero = 0;
  1970. const int is_unsigned = neg_one > const_zero;
  1971. #if PY_MAJOR_VERSION < 3
  1972. if (likely(PyInt_Check(x))) {
  1973. if (sizeof(long) < sizeof(long)) {
  1974. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG)
  1975. } else {
  1976. long val = PyInt_AS_LONG(x);
  1977. if (is_unsigned && unlikely(val < 0)) {
  1978. PyErr_SetString(PyExc_OverflowError,
  1979. "can't convert negative value to long");
  1980. return (long) -1;
  1981. }
  1982. return (long) val;
  1983. }
  1984. } else
  1985. #endif
  1986. if (likely(PyLong_Check(x))) {
  1987. if (is_unsigned) {
  1988. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  1989. #if CYTHON_USE_PYLONG_INTERNALS
  1990. if (sizeof(digit) <= sizeof(long)) {
  1991. switch (Py_SIZE(x)) {
  1992. case 0: return 0;
  1993. case 1: return (long) ((PyLongObject*)x)->ob_digit[0];
  1994. }
  1995. }
  1996. #endif
  1997. #endif
  1998. if (unlikely(Py_SIZE(x) < 0)) {
  1999. PyErr_SetString(PyExc_OverflowError,
  2000. "can't convert negative value to long");
  2001. return (long) -1;
  2002. }
  2003. if (sizeof(long) <= sizeof(unsigned long)) {
  2004. __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong)
  2005. } else if (sizeof(long) <= sizeof(unsigned long long)) {
  2006. __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong)
  2007. }
  2008. } else {
  2009. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  2010. #if CYTHON_USE_PYLONG_INTERNALS
  2011. if (sizeof(digit) <= sizeof(long)) {
  2012. switch (Py_SIZE(x)) {
  2013. case 0: return 0;
  2014. case 1: return +(long) ((PyLongObject*)x)->ob_digit[0];
  2015. case -1: return -(long) ((PyLongObject*)x)->ob_digit[0];
  2016. }
  2017. }
  2018. #endif
  2019. #endif
  2020. if (sizeof(long) <= sizeof(long)) {
  2021. __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong)
  2022. } else if (sizeof(long) <= sizeof(long long)) {
  2023. __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong)
  2024. }
  2025. }
  2026. {
  2027. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  2028. PyErr_SetString(PyExc_RuntimeError,
  2029. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  2030. #else
  2031. long val;
  2032. PyObject *v = __Pyx_PyNumber_Int(x);
  2033. #if PY_MAJOR_VERSION < 3
  2034. if (likely(v) && !PyLong_Check(v)) {
  2035. PyObject *tmp = v;
  2036. v = PyNumber_Long(tmp);
  2037. Py_DECREF(tmp);
  2038. }
  2039. #endif
  2040. if (likely(v)) {
  2041. int one = 1; int is_little = (int)*(unsigned char *)&one;
  2042. unsigned char *bytes = (unsigned char *)&val;
  2043. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  2044. bytes, sizeof(val),
  2045. is_little, !is_unsigned);
  2046. Py_DECREF(v);
  2047. if (likely(!ret))
  2048. return val;
  2049. }
  2050. #endif
  2051. return (long) -1;
  2052. }
  2053. } else {
  2054. long val;
  2055. PyObject *tmp = __Pyx_PyNumber_Int(x);
  2056. if (!tmp) return (long) -1;
  2057. val = __Pyx_PyInt_As_long(tmp);
  2058. Py_DECREF(tmp);
  2059. return val;
  2060. }
  2061. }
  2062. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  2063. #if CYTHON_USE_PYLONG_INTERNALS
  2064. #include "longintrepr.h"
  2065. #endif
  2066. #endif
  2067. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  2068. const int neg_one = (int) -1, const_zero = 0;
  2069. const int is_unsigned = neg_one > const_zero;
  2070. #if PY_MAJOR_VERSION < 3
  2071. if (likely(PyInt_Check(x))) {
  2072. if (sizeof(int) < sizeof(long)) {
  2073. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG)
  2074. } else {
  2075. long val = PyInt_AS_LONG(x);
  2076. if (is_unsigned && unlikely(val < 0)) {
  2077. PyErr_SetString(PyExc_OverflowError,
  2078. "can't convert negative value to int");
  2079. return (int) -1;
  2080. }
  2081. return (int) val;
  2082. }
  2083. } else
  2084. #endif
  2085. if (likely(PyLong_Check(x))) {
  2086. if (is_unsigned) {
  2087. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  2088. #if CYTHON_USE_PYLONG_INTERNALS
  2089. if (sizeof(digit) <= sizeof(int)) {
  2090. switch (Py_SIZE(x)) {
  2091. case 0: return 0;
  2092. case 1: return (int) ((PyLongObject*)x)->ob_digit[0];
  2093. }
  2094. }
  2095. #endif
  2096. #endif
  2097. if (unlikely(Py_SIZE(x) < 0)) {
  2098. PyErr_SetString(PyExc_OverflowError,
  2099. "can't convert negative value to int");
  2100. return (int) -1;
  2101. }
  2102. if (sizeof(int) <= sizeof(unsigned long)) {
  2103. __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong)
  2104. } else if (sizeof(int) <= sizeof(unsigned long long)) {
  2105. __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong)
  2106. }
  2107. } else {
  2108. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  2109. #if CYTHON_USE_PYLONG_INTERNALS
  2110. if (sizeof(digit) <= sizeof(int)) {
  2111. switch (Py_SIZE(x)) {
  2112. case 0: return 0;
  2113. case 1: return +(int) ((PyLongObject*)x)->ob_digit[0];
  2114. case -1: return -(int) ((PyLongObject*)x)->ob_digit[0];
  2115. }
  2116. }
  2117. #endif
  2118. #endif
  2119. if (sizeof(int) <= sizeof(long)) {
  2120. __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong)
  2121. } else if (sizeof(int) <= sizeof(long long)) {
  2122. __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong)
  2123. }
  2124. }
  2125. {
  2126. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  2127. PyErr_SetString(PyExc_RuntimeError,
  2128. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  2129. #else
  2130. int val;
  2131. PyObject *v = __Pyx_PyNumber_Int(x);
  2132. #if PY_MAJOR_VERSION < 3
  2133. if (likely(v) && !PyLong_Check(v)) {
  2134. PyObject *tmp = v;
  2135. v = PyNumber_Long(tmp);
  2136. Py_DECREF(tmp);
  2137. }
  2138. #endif
  2139. if (likely(v)) {
  2140. int one = 1; int is_little = (int)*(unsigned char *)&one;
  2141. unsigned char *bytes = (unsigned char *)&val;
  2142. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  2143. bytes, sizeof(val),
  2144. is_little, !is_unsigned);
  2145. Py_DECREF(v);
  2146. if (likely(!ret))
  2147. return val;
  2148. }
  2149. #endif
  2150. return (int) -1;
  2151. }
  2152. } else {
  2153. int val;
  2154. PyObject *tmp = __Pyx_PyNumber_Int(x);
  2155. if (!tmp) return (int) -1;
  2156. val = __Pyx_PyInt_As_int(tmp);
  2157. Py_DECREF(tmp);
  2158. return val;
  2159. }
  2160. }
  2161. static int __Pyx_check_binary_version(void) {
  2162. char ctversion[4], rtversion[4];
  2163. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  2164. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  2165. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  2166. char message[200];
  2167. PyOS_snprintf(message, sizeof(message),
  2168. "compiletime version %s of module '%.100s' "
  2169. "does not match runtime version %s",
  2170. ctversion, __Pyx_MODULE_NAME, rtversion);
  2171. #if PY_VERSION_HEX < 0x02050000
  2172. return PyErr_Warn(NULL, message);
  2173. #else
  2174. return PyErr_WarnEx(NULL, message, 1);
  2175. #endif
  2176. }
  2177. return 0;
  2178. }
  2179. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  2180. int start = 0, mid = 0, end = count - 1;
  2181. if (end >= 0 && code_line > entries[end].code_line) {
  2182. return count;
  2183. }
  2184. while (start < end) {
  2185. mid = (start + end) / 2;
  2186. if (code_line < entries[mid].code_line) {
  2187. end = mid;
  2188. } else if (code_line > entries[mid].code_line) {
  2189. start = mid + 1;
  2190. } else {
  2191. return mid;
  2192. }
  2193. }
  2194. if (code_line <= entries[mid].code_line) {
  2195. return mid;
  2196. } else {
  2197. return mid + 1;
  2198. }
  2199. }
  2200. static PyCodeObject *__pyx_find_code_object(int code_line) {
  2201. PyCodeObject* code_object;
  2202. int pos;
  2203. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  2204. return NULL;
  2205. }
  2206. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  2207. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  2208. return NULL;
  2209. }
  2210. code_object = __pyx_code_cache.entries[pos].code_object;
  2211. Py_INCREF(code_object);
  2212. return code_object;
  2213. }
  2214. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  2215. int pos, i;
  2216. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  2217. if (unlikely(!code_line)) {
  2218. return;
  2219. }
  2220. if (unlikely(!entries)) {
  2221. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  2222. if (likely(entries)) {
  2223. __pyx_code_cache.entries = entries;
  2224. __pyx_code_cache.max_count = 64;
  2225. __pyx_code_cache.count = 1;
  2226. entries[0].code_line = code_line;
  2227. entries[0].code_object = code_object;
  2228. Py_INCREF(code_object);
  2229. }
  2230. return;
  2231. }
  2232. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  2233. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  2234. PyCodeObject* tmp = entries[pos].code_object;
  2235. entries[pos].code_object = code_object;
  2236. Py_DECREF(tmp);
  2237. return;
  2238. }
  2239. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  2240. int new_max = __pyx_code_cache.max_count + 64;
  2241. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  2242. __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  2243. if (unlikely(!entries)) {
  2244. return;
  2245. }
  2246. __pyx_code_cache.entries = entries;
  2247. __pyx_code_cache.max_count = new_max;
  2248. }
  2249. for (i=__pyx_code_cache.count; i>pos; i--) {
  2250. entries[i] = entries[i-1];
  2251. }
  2252. entries[pos].code_line = code_line;
  2253. entries[pos].code_object = code_object;
  2254. __pyx_code_cache.count++;
  2255. Py_INCREF(code_object);
  2256. }
  2257. #include "compile.h"
  2258. #include "frameobject.h"
  2259. #include "traceback.h"
  2260. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  2261. const char *funcname, int c_line,
  2262. int py_line, const char *filename) {
  2263. PyCodeObject *py_code = 0;
  2264. PyObject *py_srcfile = 0;
  2265. PyObject *py_funcname = 0;
  2266. #if PY_MAJOR_VERSION < 3
  2267. py_srcfile = PyString_FromString(filename);
  2268. #else
  2269. py_srcfile = PyUnicode_FromString(filename);
  2270. #endif
  2271. if (!py_srcfile) goto bad;
  2272. if (c_line) {
  2273. #if PY_MAJOR_VERSION < 3
  2274. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  2275. #else
  2276. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  2277. #endif
  2278. }
  2279. else {
  2280. #if PY_MAJOR_VERSION < 3
  2281. py_funcname = PyString_FromString(funcname);
  2282. #else
  2283. py_funcname = PyUnicode_FromString(funcname);
  2284. #endif
  2285. }
  2286. if (!py_funcname) goto bad;
  2287. py_code = __Pyx_PyCode_New(
  2288. 0, /*int argcount,*/
  2289. 0, /*int kwonlyargcount,*/
  2290. 0, /*int nlocals,*/
  2291. 0, /*int stacksize,*/
  2292. 0, /*int flags,*/
  2293. __pyx_empty_bytes, /*PyObject *code,*/
  2294. __pyx_empty_tuple, /*PyObject *consts,*/
  2295. __pyx_empty_tuple, /*PyObject *names,*/
  2296. __pyx_empty_tuple, /*PyObject *varnames,*/
  2297. __pyx_empty_tuple, /*PyObject *freevars,*/
  2298. __pyx_empty_tuple, /*PyObject *cellvars,*/
  2299. py_srcfile, /*PyObject *filename,*/
  2300. py_funcname, /*PyObject *name,*/
  2301. py_line, /*int firstlineno,*/
  2302. __pyx_empty_bytes /*PyObject *lnotab*/
  2303. );
  2304. Py_DECREF(py_srcfile);
  2305. Py_DECREF(py_funcname);
  2306. return py_code;
  2307. bad:
  2308. Py_XDECREF(py_srcfile);
  2309. Py_XDECREF(py_funcname);
  2310. return NULL;
  2311. }
  2312. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  2313. int py_line, const char *filename) {
  2314. PyCodeObject *py_code = 0;
  2315. PyObject *py_globals = 0;
  2316. PyFrameObject *py_frame = 0;
  2317. py_code = __pyx_find_code_object(c_line ? c_line : py_line);
  2318. if (!py_code) {
  2319. py_code = __Pyx_CreateCodeObjectForTraceback(
  2320. funcname, c_line, py_line, filename);
  2321. if (!py_code) goto bad;
  2322. __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
  2323. }
  2324. py_globals = PyModule_GetDict(__pyx_m);
  2325. if (!py_globals) goto bad;
  2326. py_frame = PyFrame_New(
  2327. PyThreadState_GET(), /*PyThreadState *tstate,*/
  2328. py_code, /*PyCodeObject *code,*/
  2329. py_globals, /*PyObject *globals,*/
  2330. 0 /*PyObject *locals*/
  2331. );
  2332. if (!py_frame) goto bad;
  2333. py_frame->f_lineno = py_line;
  2334. PyTraceBack_Here(py_frame);
  2335. bad:
  2336. Py_XDECREF(py_code);
  2337. Py_XDECREF(py_frame);
  2338. }
  2339. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  2340. while (t->p) {
  2341. #if PY_MAJOR_VERSION < 3
  2342. if (t->is_unicode) {
  2343. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  2344. } else if (t->intern) {
  2345. *t->p = PyString_InternFromString(t->s);
  2346. } else {
  2347. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  2348. }
  2349. #else /* Python 3+ has unicode identifiers */
  2350. if (t->is_unicode | t->is_str) {
  2351. if (t->intern) {
  2352. *t->p = PyUnicode_InternFromString(t->s);
  2353. } else if (t->encoding) {
  2354. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  2355. } else {
  2356. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  2357. }
  2358. } else {
  2359. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  2360. }
  2361. #endif
  2362. if (!*t->p)
  2363. return -1;
  2364. ++t;
  2365. }
  2366. return 0;
  2367. }
  2368. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) {
  2369. return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str));
  2370. }
  2371. static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
  2372. Py_ssize_t ignore;
  2373. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  2374. }
  2375. static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  2376. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  2377. if (
  2378. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  2379. __Pyx_sys_getdefaultencoding_not_ascii &&
  2380. #endif
  2381. PyUnicode_Check(o)) {
  2382. #if PY_VERSION_HEX < 0x03030000
  2383. char* defenc_c;
  2384. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  2385. if (!defenc) return NULL;
  2386. defenc_c = PyBytes_AS_STRING(defenc);
  2387. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  2388. {
  2389. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  2390. char* c;
  2391. for (c = defenc_c; c < end; c++) {
  2392. if ((unsigned char) (*c) >= 128) {
  2393. PyUnicode_AsASCIIString(o);
  2394. return NULL;
  2395. }
  2396. }
  2397. }
  2398. #endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/
  2399. *length = PyBytes_GET_SIZE(defenc);
  2400. return defenc_c;
  2401. #else /* PY_VERSION_HEX < 0x03030000 */
  2402. if (PyUnicode_READY(o) == -1) return NULL;
  2403. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  2404. if (PyUnicode_IS_ASCII(o)) {
  2405. *length = PyUnicode_GET_DATA_SIZE(o);
  2406. return PyUnicode_AsUTF8(o);
  2407. } else {
  2408. PyUnicode_AsASCIIString(o);
  2409. return NULL;
  2410. }
  2411. #else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
  2412. return PyUnicode_AsUTF8AndSize(o, length);
  2413. #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
  2414. #endif /* PY_VERSION_HEX < 0x03030000 */
  2415. } else
  2416. #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */
  2417. #if !CYTHON_COMPILING_IN_PYPY
  2418. #if PY_VERSION_HEX >= 0x02060000
  2419. if (PyByteArray_Check(o)) {
  2420. *length = PyByteArray_GET_SIZE(o);
  2421. return PyByteArray_AS_STRING(o);
  2422. } else
  2423. #endif
  2424. #endif
  2425. {
  2426. char* result;
  2427. int r = PyBytes_AsStringAndSize(o, &result, length);
  2428. if (unlikely(r < 0)) {
  2429. return NULL;
  2430. } else {
  2431. return result;
  2432. }
  2433. }
  2434. }
  2435. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  2436. int is_true = x == Py_True;
  2437. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  2438. else return PyObject_IsTrue(x);
  2439. }
  2440. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  2441. PyNumberMethods *m;
  2442. const char *name = NULL;
  2443. PyObject *res = NULL;
  2444. #if PY_MAJOR_VERSION < 3
  2445. if (PyInt_Check(x) || PyLong_Check(x))
  2446. #else
  2447. if (PyLong_Check(x))
  2448. #endif
  2449. return Py_INCREF(x), x;
  2450. m = Py_TYPE(x)->tp_as_number;
  2451. #if PY_MAJOR_VERSION < 3
  2452. if (m && m->nb_int) {
  2453. name = "int";
  2454. res = PyNumber_Int(x);
  2455. }
  2456. else if (m && m->nb_long) {
  2457. name = "long";
  2458. res = PyNumber_Long(x);
  2459. }
  2460. #else
  2461. if (m && m->nb_int) {
  2462. name = "int";
  2463. res = PyNumber_Long(x);
  2464. }
  2465. #endif
  2466. if (res) {
  2467. #if PY_MAJOR_VERSION < 3
  2468. if (!PyInt_Check(res) && !PyLong_Check(res)) {
  2469. #else
  2470. if (!PyLong_Check(res)) {
  2471. #endif
  2472. PyErr_Format(PyExc_TypeError,
  2473. "__%.4s__ returned non-%.4s (type %.200s)",
  2474. name, name, Py_TYPE(res)->tp_name);
  2475. Py_DECREF(res);
  2476. return NULL;
  2477. }
  2478. }
  2479. else if (!PyErr_Occurred()) {
  2480. PyErr_SetString(PyExc_TypeError,
  2481. "an integer is required");
  2482. }
  2483. return res;
  2484. }
  2485. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  2486. #if CYTHON_USE_PYLONG_INTERNALS
  2487. #include "longintrepr.h"
  2488. #endif
  2489. #endif
  2490. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  2491. Py_ssize_t ival;
  2492. PyObject *x;
  2493. #if PY_MAJOR_VERSION < 3
  2494. if (likely(PyInt_CheckExact(b)))
  2495. return PyInt_AS_LONG(b);
  2496. #endif
  2497. if (likely(PyLong_CheckExact(b))) {
  2498. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  2499. #if CYTHON_USE_PYLONG_INTERNALS
  2500. switch (Py_SIZE(b)) {
  2501. case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
  2502. case 0: return 0;
  2503. case 1: return ((PyLongObject*)b)->ob_digit[0];
  2504. }
  2505. #endif
  2506. #endif
  2507. #if PY_VERSION_HEX < 0x02060000
  2508. return PyInt_AsSsize_t(b);
  2509. #else
  2510. return PyLong_AsSsize_t(b);
  2511. #endif
  2512. }
  2513. x = PyNumber_Index(b);
  2514. if (!x) return -1;
  2515. ival = PyInt_AsSsize_t(x);
  2516. Py_DECREF(x);
  2517. return ival;
  2518. }
  2519. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  2520. #if PY_VERSION_HEX < 0x02050000
  2521. if (ival <= LONG_MAX)
  2522. return PyInt_FromLong((long)ival);
  2523. else {
  2524. unsigned char *bytes = (unsigned char *) &ival;
  2525. int one = 1; int little = (int)*(unsigned char*)&one;
  2526. return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
  2527. }
  2528. #else
  2529. return PyInt_FromSize_t(ival);
  2530. #endif
  2531. }
  2532. #endif /* Py_PYTHON_H */