cylmdb.c 90 KB

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