url_parser.c 231 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031
  1. /* Generated by Cython 0.29.28 */
  2. /* BEGIN: Cython Metadata
  3. {
  4. "distutils": {
  5. "depends": [],
  6. "extra_compile_args": [
  7. "-O2"
  8. ],
  9. "name": "httptools.parser.url_parser",
  10. "sources": [
  11. "httptools/parser/url_parser.pyx"
  12. ]
  13. },
  14. "module_name": "httptools.parser.url_parser"
  15. }
  16. END: Cython Metadata */
  17. #ifndef PY_SSIZE_T_CLEAN
  18. #define PY_SSIZE_T_CLEAN
  19. #endif /* PY_SSIZE_T_CLEAN */
  20. #include "Python.h"
  21. #ifndef Py_PYTHON_H
  22. #error Python headers needed to compile C extensions, please install development version of Python.
  23. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
  24. #error Cython requires Python 2.6+ or Python 3.3+.
  25. #else
  26. #define CYTHON_ABI "0_29_28"
  27. #define CYTHON_HEX_VERSION 0x001D1CF0
  28. #define CYTHON_FUTURE_DIVISION 1
  29. #include <stddef.h>
  30. #ifndef offsetof
  31. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  32. #endif
  33. #if !defined(WIN32) && !defined(MS_WINDOWS)
  34. #ifndef __stdcall
  35. #define __stdcall
  36. #endif
  37. #ifndef __cdecl
  38. #define __cdecl
  39. #endif
  40. #ifndef __fastcall
  41. #define __fastcall
  42. #endif
  43. #endif
  44. #ifndef DL_IMPORT
  45. #define DL_IMPORT(t) t
  46. #endif
  47. #ifndef DL_EXPORT
  48. #define DL_EXPORT(t) t
  49. #endif
  50. #define __PYX_COMMA ,
  51. #ifndef HAVE_LONG_LONG
  52. #if PY_VERSION_HEX >= 0x02070000
  53. #define HAVE_LONG_LONG
  54. #endif
  55. #endif
  56. #ifndef PY_LONG_LONG
  57. #define PY_LONG_LONG LONG_LONG
  58. #endif
  59. #ifndef Py_HUGE_VAL
  60. #define Py_HUGE_VAL HUGE_VAL
  61. #endif
  62. #ifdef PYPY_VERSION
  63. #define CYTHON_COMPILING_IN_PYPY 1
  64. #define CYTHON_COMPILING_IN_PYSTON 0
  65. #define CYTHON_COMPILING_IN_CPYTHON 0
  66. #undef CYTHON_USE_TYPE_SLOTS
  67. #define CYTHON_USE_TYPE_SLOTS 0
  68. #undef CYTHON_USE_PYTYPE_LOOKUP
  69. #define CYTHON_USE_PYTYPE_LOOKUP 0
  70. #if PY_VERSION_HEX < 0x03050000
  71. #undef CYTHON_USE_ASYNC_SLOTS
  72. #define CYTHON_USE_ASYNC_SLOTS 0
  73. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  74. #define CYTHON_USE_ASYNC_SLOTS 1
  75. #endif
  76. #undef CYTHON_USE_PYLIST_INTERNALS
  77. #define CYTHON_USE_PYLIST_INTERNALS 0
  78. #undef CYTHON_USE_UNICODE_INTERNALS
  79. #define CYTHON_USE_UNICODE_INTERNALS 0
  80. #undef CYTHON_USE_UNICODE_WRITER
  81. #define CYTHON_USE_UNICODE_WRITER 0
  82. #undef CYTHON_USE_PYLONG_INTERNALS
  83. #define CYTHON_USE_PYLONG_INTERNALS 0
  84. #undef CYTHON_AVOID_BORROWED_REFS
  85. #define CYTHON_AVOID_BORROWED_REFS 1
  86. #undef CYTHON_ASSUME_SAFE_MACROS
  87. #define CYTHON_ASSUME_SAFE_MACROS 0
  88. #undef CYTHON_UNPACK_METHODS
  89. #define CYTHON_UNPACK_METHODS 0
  90. #undef CYTHON_FAST_THREAD_STATE
  91. #define CYTHON_FAST_THREAD_STATE 0
  92. #undef CYTHON_FAST_PYCALL
  93. #define CYTHON_FAST_PYCALL 0
  94. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  95. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  96. #undef CYTHON_USE_TP_FINALIZE
  97. #define CYTHON_USE_TP_FINALIZE 0
  98. #undef CYTHON_USE_DICT_VERSIONS
  99. #define CYTHON_USE_DICT_VERSIONS 0
  100. #undef CYTHON_USE_EXC_INFO_STACK
  101. #define CYTHON_USE_EXC_INFO_STACK 0
  102. #elif defined(PYSTON_VERSION)
  103. #define CYTHON_COMPILING_IN_PYPY 0
  104. #define CYTHON_COMPILING_IN_PYSTON 1
  105. #define CYTHON_COMPILING_IN_CPYTHON 0
  106. #ifndef CYTHON_USE_TYPE_SLOTS
  107. #define CYTHON_USE_TYPE_SLOTS 1
  108. #endif
  109. #undef CYTHON_USE_PYTYPE_LOOKUP
  110. #define CYTHON_USE_PYTYPE_LOOKUP 0
  111. #undef CYTHON_USE_ASYNC_SLOTS
  112. #define CYTHON_USE_ASYNC_SLOTS 0
  113. #undef CYTHON_USE_PYLIST_INTERNALS
  114. #define CYTHON_USE_PYLIST_INTERNALS 0
  115. #ifndef CYTHON_USE_UNICODE_INTERNALS
  116. #define CYTHON_USE_UNICODE_INTERNALS 1
  117. #endif
  118. #undef CYTHON_USE_UNICODE_WRITER
  119. #define CYTHON_USE_UNICODE_WRITER 0
  120. #undef CYTHON_USE_PYLONG_INTERNALS
  121. #define CYTHON_USE_PYLONG_INTERNALS 0
  122. #ifndef CYTHON_AVOID_BORROWED_REFS
  123. #define CYTHON_AVOID_BORROWED_REFS 0
  124. #endif
  125. #ifndef CYTHON_ASSUME_SAFE_MACROS
  126. #define CYTHON_ASSUME_SAFE_MACROS 1
  127. #endif
  128. #ifndef CYTHON_UNPACK_METHODS
  129. #define CYTHON_UNPACK_METHODS 1
  130. #endif
  131. #undef CYTHON_FAST_THREAD_STATE
  132. #define CYTHON_FAST_THREAD_STATE 0
  133. #undef CYTHON_FAST_PYCALL
  134. #define CYTHON_FAST_PYCALL 0
  135. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  136. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  137. #undef CYTHON_USE_TP_FINALIZE
  138. #define CYTHON_USE_TP_FINALIZE 0
  139. #undef CYTHON_USE_DICT_VERSIONS
  140. #define CYTHON_USE_DICT_VERSIONS 0
  141. #undef CYTHON_USE_EXC_INFO_STACK
  142. #define CYTHON_USE_EXC_INFO_STACK 0
  143. #else
  144. #define CYTHON_COMPILING_IN_PYPY 0
  145. #define CYTHON_COMPILING_IN_PYSTON 0
  146. #define CYTHON_COMPILING_IN_CPYTHON 1
  147. #ifndef CYTHON_USE_TYPE_SLOTS
  148. #define CYTHON_USE_TYPE_SLOTS 1
  149. #endif
  150. #if PY_VERSION_HEX < 0x02070000
  151. #undef CYTHON_USE_PYTYPE_LOOKUP
  152. #define CYTHON_USE_PYTYPE_LOOKUP 0
  153. #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
  154. #define CYTHON_USE_PYTYPE_LOOKUP 1
  155. #endif
  156. #if PY_MAJOR_VERSION < 3
  157. #undef CYTHON_USE_ASYNC_SLOTS
  158. #define CYTHON_USE_ASYNC_SLOTS 0
  159. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  160. #define CYTHON_USE_ASYNC_SLOTS 1
  161. #endif
  162. #if PY_VERSION_HEX < 0x02070000
  163. #undef CYTHON_USE_PYLONG_INTERNALS
  164. #define CYTHON_USE_PYLONG_INTERNALS 0
  165. #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
  166. #define CYTHON_USE_PYLONG_INTERNALS 1
  167. #endif
  168. #ifndef CYTHON_USE_PYLIST_INTERNALS
  169. #define CYTHON_USE_PYLIST_INTERNALS 1
  170. #endif
  171. #ifndef CYTHON_USE_UNICODE_INTERNALS
  172. #define CYTHON_USE_UNICODE_INTERNALS 1
  173. #endif
  174. #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2
  175. #undef CYTHON_USE_UNICODE_WRITER
  176. #define CYTHON_USE_UNICODE_WRITER 0
  177. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  178. #define CYTHON_USE_UNICODE_WRITER 1
  179. #endif
  180. #ifndef CYTHON_AVOID_BORROWED_REFS
  181. #define CYTHON_AVOID_BORROWED_REFS 0
  182. #endif
  183. #ifndef CYTHON_ASSUME_SAFE_MACROS
  184. #define CYTHON_ASSUME_SAFE_MACROS 1
  185. #endif
  186. #ifndef CYTHON_UNPACK_METHODS
  187. #define CYTHON_UNPACK_METHODS 1
  188. #endif
  189. #if PY_VERSION_HEX >= 0x030B00A4
  190. #undef CYTHON_FAST_THREAD_STATE
  191. #define CYTHON_FAST_THREAD_STATE 0
  192. #elif !defined(CYTHON_FAST_THREAD_STATE)
  193. #define CYTHON_FAST_THREAD_STATE 1
  194. #endif
  195. #ifndef CYTHON_FAST_PYCALL
  196. #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030B00A1)
  197. #endif
  198. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  199. #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  200. #endif
  201. #ifndef CYTHON_USE_TP_FINALIZE
  202. #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  203. #endif
  204. #ifndef CYTHON_USE_DICT_VERSIONS
  205. #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  206. #endif
  207. #if PY_VERSION_HEX >= 0x030B00A4
  208. #undef CYTHON_USE_EXC_INFO_STACK
  209. #define CYTHON_USE_EXC_INFO_STACK 0
  210. #elif !defined(CYTHON_USE_EXC_INFO_STACK)
  211. #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  212. #endif
  213. #endif
  214. #if !defined(CYTHON_FAST_PYCCALL)
  215. #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
  216. #endif
  217. #if CYTHON_USE_PYLONG_INTERNALS
  218. #if PY_MAJOR_VERSION < 3
  219. #include "longintrepr.h"
  220. #endif
  221. #undef SHIFT
  222. #undef BASE
  223. #undef MASK
  224. #ifdef SIZEOF_VOID_P
  225. enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  226. #endif
  227. #endif
  228. #ifndef __has_attribute
  229. #define __has_attribute(x) 0
  230. #endif
  231. #ifndef __has_cpp_attribute
  232. #define __has_cpp_attribute(x) 0
  233. #endif
  234. #ifndef CYTHON_RESTRICT
  235. #if defined(__GNUC__)
  236. #define CYTHON_RESTRICT __restrict__
  237. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  238. #define CYTHON_RESTRICT __restrict
  239. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  240. #define CYTHON_RESTRICT restrict
  241. #else
  242. #define CYTHON_RESTRICT
  243. #endif
  244. #endif
  245. #ifndef CYTHON_UNUSED
  246. # if defined(__GNUC__)
  247. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  248. # define CYTHON_UNUSED __attribute__ ((__unused__))
  249. # else
  250. # define CYTHON_UNUSED
  251. # endif
  252. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  253. # define CYTHON_UNUSED __attribute__ ((__unused__))
  254. # else
  255. # define CYTHON_UNUSED
  256. # endif
  257. #endif
  258. #ifndef CYTHON_MAYBE_UNUSED_VAR
  259. # if defined(__cplusplus)
  260. template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
  261. # else
  262. # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
  263. # endif
  264. #endif
  265. #ifndef CYTHON_NCP_UNUSED
  266. # if CYTHON_COMPILING_IN_CPYTHON
  267. # define CYTHON_NCP_UNUSED
  268. # else
  269. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  270. # endif
  271. #endif
  272. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  273. #ifdef _MSC_VER
  274. #ifndef _MSC_STDINT_H_
  275. #if _MSC_VER < 1300
  276. typedef unsigned char uint8_t;
  277. typedef unsigned int uint32_t;
  278. #else
  279. typedef unsigned __int8 uint8_t;
  280. typedef unsigned __int32 uint32_t;
  281. #endif
  282. #endif
  283. #else
  284. #include <stdint.h>
  285. #endif
  286. #ifndef CYTHON_FALLTHROUGH
  287. #if defined(__cplusplus) && __cplusplus >= 201103L
  288. #if __has_cpp_attribute(fallthrough)
  289. #define CYTHON_FALLTHROUGH [[fallthrough]]
  290. #elif __has_cpp_attribute(clang::fallthrough)
  291. #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
  292. #elif __has_cpp_attribute(gnu::fallthrough)
  293. #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
  294. #endif
  295. #endif
  296. #ifndef CYTHON_FALLTHROUGH
  297. #if __has_attribute(fallthrough)
  298. #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
  299. #else
  300. #define CYTHON_FALLTHROUGH
  301. #endif
  302. #endif
  303. #if defined(__clang__ ) && defined(__apple_build_version__)
  304. #if __apple_build_version__ < 7000000
  305. #undef CYTHON_FALLTHROUGH
  306. #define CYTHON_FALLTHROUGH
  307. #endif
  308. #endif
  309. #endif
  310. #ifndef CYTHON_INLINE
  311. #if defined(__clang__)
  312. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  313. #elif defined(__GNUC__)
  314. #define CYTHON_INLINE __inline__
  315. #elif defined(_MSC_VER)
  316. #define CYTHON_INLINE __inline
  317. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  318. #define CYTHON_INLINE inline
  319. #else
  320. #define CYTHON_INLINE
  321. #endif
  322. #endif
  323. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  324. #define Py_OptimizeFlag 0
  325. #endif
  326. #define __PYX_BUILD_PY_SSIZE_T "n"
  327. #define CYTHON_FORMAT_SSIZE_T "z"
  328. #if PY_MAJOR_VERSION < 3
  329. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  330. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  331. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  332. #define __Pyx_DefaultClassType PyClass_Type
  333. #else
  334. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  335. #define __Pyx_DefaultClassType PyType_Type
  336. #if PY_VERSION_HEX >= 0x030B00A1
  337. static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f,
  338. PyObject *code, PyObject *c, PyObject* n, PyObject *v,
  339. PyObject *fv, PyObject *cell, PyObject* fn,
  340. PyObject *name, int fline, PyObject *lnos) {
  341. PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL;
  342. PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL;
  343. const char *fn_cstr=NULL;
  344. const char *name_cstr=NULL;
  345. PyCodeObject* co=NULL;
  346. PyObject *type, *value, *traceback;
  347. PyErr_Fetch(&type, &value, &traceback);
  348. if (!(kwds=PyDict_New())) goto end;
  349. if (!(argcount=PyLong_FromLong(a))) goto end;
  350. if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end;
  351. if (!(posonlyargcount=PyLong_FromLong(0))) goto end;
  352. if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end;
  353. if (!(kwonlyargcount=PyLong_FromLong(k))) goto end;
  354. if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end;
  355. if (!(nlocals=PyLong_FromLong(l))) goto end;
  356. if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end;
  357. if (!(stacksize=PyLong_FromLong(s))) goto end;
  358. if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end;
  359. if (!(flags=PyLong_FromLong(f))) goto end;
  360. if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end;
  361. if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end;
  362. if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end;
  363. if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end;
  364. if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end;
  365. if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end;
  366. if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end;
  367. if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end;
  368. if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end;
  369. if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end;
  370. if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end;
  371. if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too;
  372. if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here
  373. if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too;
  374. Py_XDECREF((PyObject*)co);
  375. co = (PyCodeObject*)call_result;
  376. call_result = NULL;
  377. if (0) {
  378. cleanup_code_too:
  379. Py_XDECREF((PyObject*)co);
  380. co = NULL;
  381. }
  382. end:
  383. Py_XDECREF(kwds);
  384. Py_XDECREF(argcount);
  385. Py_XDECREF(posonlyargcount);
  386. Py_XDECREF(kwonlyargcount);
  387. Py_XDECREF(nlocals);
  388. Py_XDECREF(stacksize);
  389. Py_XDECREF(replace);
  390. Py_XDECREF(call_result);
  391. Py_XDECREF(empty);
  392. if (type) {
  393. PyErr_Restore(type, value, traceback);
  394. }
  395. return co;
  396. }
  397. #else
  398. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  399. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  400. #endif
  401. #define __Pyx_DefaultClassType PyType_Type
  402. #endif
  403. #ifndef Py_TPFLAGS_CHECKTYPES
  404. #define Py_TPFLAGS_CHECKTYPES 0
  405. #endif
  406. #ifndef Py_TPFLAGS_HAVE_INDEX
  407. #define Py_TPFLAGS_HAVE_INDEX 0
  408. #endif
  409. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  410. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  411. #endif
  412. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  413. #define Py_TPFLAGS_HAVE_FINALIZE 0
  414. #endif
  415. #ifndef METH_STACKLESS
  416. #define METH_STACKLESS 0
  417. #endif
  418. #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  419. #ifndef METH_FASTCALL
  420. #define METH_FASTCALL 0x80
  421. #endif
  422. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  423. typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
  424. Py_ssize_t nargs, PyObject *kwnames);
  425. #else
  426. #define __Pyx_PyCFunctionFast _PyCFunctionFast
  427. #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  428. #endif
  429. #if CYTHON_FAST_PYCCALL
  430. #define __Pyx_PyFastCFunction_Check(func)\
  431. ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
  432. #else
  433. #define __Pyx_PyFastCFunction_Check(func) 0
  434. #endif
  435. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  436. #define PyObject_Malloc(s) PyMem_Malloc(s)
  437. #define PyObject_Free(p) PyMem_Free(p)
  438. #define PyObject_Realloc(p) PyMem_Realloc(p)
  439. #endif
  440. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  441. #define PyMem_RawMalloc(n) PyMem_Malloc(n)
  442. #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
  443. #define PyMem_RawFree(p) PyMem_Free(p)
  444. #endif
  445. #if CYTHON_COMPILING_IN_PYSTON
  446. #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
  447. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
  448. #else
  449. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  450. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  451. #endif
  452. #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  453. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  454. #elif PY_VERSION_HEX >= 0x03060000
  455. #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
  456. #elif PY_VERSION_HEX >= 0x03000000
  457. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  458. #else
  459. #define __Pyx_PyThreadState_Current _PyThreadState_Current
  460. #endif
  461. #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
  462. #include "pythread.h"
  463. #define Py_tss_NEEDS_INIT 0
  464. typedef int Py_tss_t;
  465. static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  466. *key = PyThread_create_key();
  467. return 0;
  468. }
  469. static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  470. Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  471. *key = Py_tss_NEEDS_INIT;
  472. return key;
  473. }
  474. static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  475. PyObject_Free(key);
  476. }
  477. static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  478. return *key != Py_tss_NEEDS_INIT;
  479. }
  480. static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  481. PyThread_delete_key(*key);
  482. *key = Py_tss_NEEDS_INIT;
  483. }
  484. static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  485. return PyThread_set_key_value(*key, value);
  486. }
  487. static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  488. return PyThread_get_key_value(*key);
  489. }
  490. #endif
  491. #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
  492. #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
  493. #else
  494. #define __Pyx_PyDict_NewPresized(n) PyDict_New()
  495. #endif
  496. #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  497. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  498. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  499. #else
  500. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  501. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  502. #endif
  503. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
  504. #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
  505. #else
  506. #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
  507. #endif
  508. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  509. #define CYTHON_PEP393_ENABLED 1
  510. #if defined(PyUnicode_IS_READY)
  511. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  512. 0 : _PyUnicode_Ready((PyObject *)(op)))
  513. #else
  514. #define __Pyx_PyUnicode_READY(op) (0)
  515. #endif
  516. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  517. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  518. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  519. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  520. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  521. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  522. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
  523. #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
  524. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
  525. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
  526. #else
  527. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  528. #endif
  529. #else
  530. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
  531. #endif
  532. #else
  533. #define CYTHON_PEP393_ENABLED 0
  534. #define PyUnicode_1BYTE_KIND 1
  535. #define PyUnicode_2BYTE_KIND 2
  536. #define PyUnicode_4BYTE_KIND 4
  537. #define __Pyx_PyUnicode_READY(op) (0)
  538. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  539. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  540. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  541. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  542. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  543. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  544. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  545. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
  546. #endif
  547. #if CYTHON_COMPILING_IN_PYPY
  548. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  549. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  550. #else
  551. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  552. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  553. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  554. #endif
  555. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  556. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  557. #endif
  558. #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  559. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  560. #endif
  561. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  562. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  563. #endif
  564. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  565. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  566. #if PY_MAJOR_VERSION >= 3
  567. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  568. #else
  569. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  570. #endif
  571. #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  572. #define PyObject_ASCII(o) PyObject_Repr(o)
  573. #endif
  574. #if PY_MAJOR_VERSION >= 3
  575. #define PyBaseString_Type PyUnicode_Type
  576. #define PyStringObject PyUnicodeObject
  577. #define PyString_Type PyUnicode_Type
  578. #define PyString_Check PyUnicode_Check
  579. #define PyString_CheckExact PyUnicode_CheckExact
  580. #ifndef PyObject_Unicode
  581. #define PyObject_Unicode PyObject_Str
  582. #endif
  583. #endif
  584. #if PY_MAJOR_VERSION >= 3
  585. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  586. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  587. #else
  588. #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  589. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  590. #endif
  591. #ifndef PySet_CheckExact
  592. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  593. #endif
  594. #if PY_VERSION_HEX >= 0x030900A4
  595. #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  596. #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
  597. #else
  598. #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  599. #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
  600. #endif
  601. #if CYTHON_ASSUME_SAFE_MACROS
  602. #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
  603. #else
  604. #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
  605. #endif
  606. #if PY_MAJOR_VERSION >= 3
  607. #define PyIntObject PyLongObject
  608. #define PyInt_Type PyLong_Type
  609. #define PyInt_Check(op) PyLong_Check(op)
  610. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  611. #define PyInt_FromString PyLong_FromString
  612. #define PyInt_FromUnicode PyLong_FromUnicode
  613. #define PyInt_FromLong PyLong_FromLong
  614. #define PyInt_FromSize_t PyLong_FromSize_t
  615. #define PyInt_FromSsize_t PyLong_FromSsize_t
  616. #define PyInt_AsLong PyLong_AsLong
  617. #define PyInt_AS_LONG PyLong_AS_LONG
  618. #define PyInt_AsSsize_t PyLong_AsSsize_t
  619. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  620. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  621. #define PyNumber_Int PyNumber_Long
  622. #endif
  623. #if PY_MAJOR_VERSION >= 3
  624. #define PyBoolObject PyLongObject
  625. #endif
  626. #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  627. #ifndef PyUnicode_InternFromString
  628. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  629. #endif
  630. #endif
  631. #if PY_VERSION_HEX < 0x030200A4
  632. typedef long Py_hash_t;
  633. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  634. #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t
  635. #else
  636. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  637. #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t
  638. #endif
  639. #if PY_MAJOR_VERSION >= 3
  640. #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
  641. #else
  642. #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
  643. #endif
  644. #if CYTHON_USE_ASYNC_SLOTS
  645. #if PY_VERSION_HEX >= 0x030500B1
  646. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  647. #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  648. #else
  649. #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  650. #endif
  651. #else
  652. #define __Pyx_PyType_AsAsync(obj) NULL
  653. #endif
  654. #ifndef __Pyx_PyAsyncMethodsStruct
  655. typedef struct {
  656. unaryfunc am_await;
  657. unaryfunc am_aiter;
  658. unaryfunc am_anext;
  659. } __Pyx_PyAsyncMethodsStruct;
  660. #endif
  661. #if defined(WIN32) || defined(MS_WINDOWS)
  662. #define _USE_MATH_DEFINES
  663. #endif
  664. #include <math.h>
  665. #ifdef NAN
  666. #define __PYX_NAN() ((float) NAN)
  667. #else
  668. static CYTHON_INLINE float __PYX_NAN() {
  669. float value;
  670. memset(&value, 0xFF, sizeof(value));
  671. return value;
  672. }
  673. #endif
  674. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  675. #define __Pyx_truncl trunc
  676. #else
  677. #define __Pyx_truncl truncl
  678. #endif
  679. #define __PYX_MARK_ERR_POS(f_index, lineno) \
  680. { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
  681. #define __PYX_ERR(f_index, lineno, Ln_error) \
  682. { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
  683. #ifndef __PYX_EXTERN_C
  684. #ifdef __cplusplus
  685. #define __PYX_EXTERN_C extern "C"
  686. #else
  687. #define __PYX_EXTERN_C extern
  688. #endif
  689. #endif
  690. #define __PYX_HAVE__httptools__parser__url_parser
  691. #define __PYX_HAVE_API__httptools__parser__url_parser
  692. /* Early includes */
  693. #include <string.h>
  694. #include <stdio.h>
  695. #include "pythread.h"
  696. #include <stdint.h>
  697. #include "http_parser.h"
  698. #ifdef _OPENMP
  699. #include <omp.h>
  700. #endif /* _OPENMP */
  701. #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
  702. #define CYTHON_WITHOUT_ASSERTIONS
  703. #endif
  704. typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
  705. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
  706. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  707. #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
  708. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
  709. #define __PYX_DEFAULT_STRING_ENCODING ""
  710. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  711. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  712. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  713. #define __Pyx_long_cast(x) ((long)x)
  714. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  715. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  716. (sizeof(type) > sizeof(Py_ssize_t) &&\
  717. likely(v < (type)PY_SSIZE_T_MAX ||\
  718. v == (type)PY_SSIZE_T_MAX) &&\
  719. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  720. v == (type)PY_SSIZE_T_MIN))) ||\
  721. (sizeof(type) == sizeof(Py_ssize_t) &&\
  722. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  723. v == (type)PY_SSIZE_T_MAX))) )
  724. static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
  725. return (size_t) i < (size_t) limit;
  726. }
  727. #if defined (__cplusplus) && __cplusplus >= 201103L
  728. #include <cstdlib>
  729. #define __Pyx_sst_abs(value) std::abs(value)
  730. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  731. #define __Pyx_sst_abs(value) abs(value)
  732. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  733. #define __Pyx_sst_abs(value) labs(value)
  734. #elif defined (_MSC_VER)
  735. #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
  736. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  737. #define __Pyx_sst_abs(value) llabs(value)
  738. #elif defined (__GNUC__)
  739. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  740. #else
  741. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  742. #endif
  743. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  744. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  745. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  746. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  747. #define __Pyx_PyBytes_FromString PyBytes_FromString
  748. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  749. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  750. #if PY_MAJOR_VERSION < 3
  751. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  752. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  753. #else
  754. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  755. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  756. #endif
  757. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
  758. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
  759. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
  760. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
  761. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
  762. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
  763. #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
  764. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  765. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  766. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  767. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  768. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  769. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  770. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  771. #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
  772. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  773. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
  774. const Py_UNICODE *u_end = u;
  775. while (*u_end++) ;
  776. return (size_t)(u_end - u - 1);
  777. }
  778. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  779. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  780. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  781. #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
  782. #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
  783. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
  784. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  785. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
  786. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
  787. #define __Pyx_PySequence_Tuple(obj)\
  788. (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
  789. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  790. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  791. static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
  792. #if CYTHON_ASSUME_SAFE_MACROS
  793. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  794. #else
  795. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  796. #endif
  797. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  798. #if PY_MAJOR_VERSION >= 3
  799. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  800. #else
  801. #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
  802. #endif
  803. #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
  804. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  805. static int __Pyx_sys_getdefaultencoding_not_ascii;
  806. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  807. PyObject* sys;
  808. PyObject* default_encoding = NULL;
  809. PyObject* ascii_chars_u = NULL;
  810. PyObject* ascii_chars_b = NULL;
  811. const char* default_encoding_c;
  812. sys = PyImport_ImportModule("sys");
  813. if (!sys) goto bad;
  814. default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
  815. Py_DECREF(sys);
  816. if (!default_encoding) goto bad;
  817. default_encoding_c = PyBytes_AsString(default_encoding);
  818. if (!default_encoding_c) goto bad;
  819. if (strcmp(default_encoding_c, "ascii") == 0) {
  820. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  821. } else {
  822. char ascii_chars[128];
  823. int c;
  824. for (c = 0; c < 128; c++) {
  825. ascii_chars[c] = c;
  826. }
  827. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  828. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  829. if (!ascii_chars_u) goto bad;
  830. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  831. if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  832. PyErr_Format(
  833. PyExc_ValueError,
  834. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  835. default_encoding_c);
  836. goto bad;
  837. }
  838. Py_DECREF(ascii_chars_u);
  839. Py_DECREF(ascii_chars_b);
  840. }
  841. Py_DECREF(default_encoding);
  842. return 0;
  843. bad:
  844. Py_XDECREF(default_encoding);
  845. Py_XDECREF(ascii_chars_u);
  846. Py_XDECREF(ascii_chars_b);
  847. return -1;
  848. }
  849. #endif
  850. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  851. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  852. #else
  853. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  854. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  855. static char* __PYX_DEFAULT_STRING_ENCODING;
  856. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  857. PyObject* sys;
  858. PyObject* default_encoding = NULL;
  859. char* default_encoding_c;
  860. sys = PyImport_ImportModule("sys");
  861. if (!sys) goto bad;
  862. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  863. Py_DECREF(sys);
  864. if (!default_encoding) goto bad;
  865. default_encoding_c = PyBytes_AsString(default_encoding);
  866. if (!default_encoding_c) goto bad;
  867. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
  868. if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
  869. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  870. Py_DECREF(default_encoding);
  871. return 0;
  872. bad:
  873. Py_XDECREF(default_encoding);
  874. return -1;
  875. }
  876. #endif
  877. #endif
  878. /* Test for GCC > 2.95 */
  879. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  880. #define likely(x) __builtin_expect(!!(x), 1)
  881. #define unlikely(x) __builtin_expect(!!(x), 0)
  882. #else /* !__GNUC__ or GCC < 2.95 */
  883. #define likely(x) (x)
  884. #define unlikely(x) (x)
  885. #endif /* __GNUC__ */
  886. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  887. static PyObject *__pyx_m = NULL;
  888. static PyObject *__pyx_d;
  889. static PyObject *__pyx_b;
  890. static PyObject *__pyx_cython_runtime = NULL;
  891. static PyObject *__pyx_empty_tuple;
  892. static PyObject *__pyx_empty_bytes;
  893. static PyObject *__pyx_empty_unicode;
  894. static int __pyx_lineno;
  895. static int __pyx_clineno = 0;
  896. static const char * __pyx_cfilenm= __FILE__;
  897. static const char *__pyx_filename;
  898. static const char *__pyx_f[] = {
  899. "stringsource",
  900. "httptools\\parser\\url_parser.pyx",
  901. "type.pxd",
  902. "bool.pxd",
  903. "complex.pxd",
  904. };
  905. /*--- Type declarations ---*/
  906. struct __pyx_obj_9httptools_6parser_10url_parser_URL;
  907. /* "httptools/parser/url_parser.pyx":16
  908. *
  909. * @cython.freelist(250)
  910. * cdef class URL: # <<<<<<<<<<<<<<
  911. * cdef readonly bytes schema
  912. * cdef readonly bytes host
  913. */
  914. struct __pyx_obj_9httptools_6parser_10url_parser_URL {
  915. PyObject_HEAD
  916. PyObject *schema;
  917. PyObject *host;
  918. PyObject *port;
  919. PyObject *path;
  920. PyObject *query;
  921. PyObject *fragment;
  922. PyObject *userinfo;
  923. };
  924. /* --- Runtime support code (head) --- */
  925. /* Refnanny.proto */
  926. #ifndef CYTHON_REFNANNY
  927. #define CYTHON_REFNANNY 0
  928. #endif
  929. #if CYTHON_REFNANNY
  930. typedef struct {
  931. void (*INCREF)(void*, PyObject*, int);
  932. void (*DECREF)(void*, PyObject*, int);
  933. void (*GOTREF)(void*, PyObject*, int);
  934. void (*GIVEREF)(void*, PyObject*, int);
  935. void* (*SetupContext)(const char*, int, const char*);
  936. void (*FinishContext)(void**);
  937. } __Pyx_RefNannyAPIStruct;
  938. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  939. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  940. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  941. #ifdef WITH_THREAD
  942. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  943. if (acquire_gil) {\
  944. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  945. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  946. PyGILState_Release(__pyx_gilstate_save);\
  947. } else {\
  948. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  949. }
  950. #else
  951. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  952. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  953. #endif
  954. #define __Pyx_RefNannyFinishContext()\
  955. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  956. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  957. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  958. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  959. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  960. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  961. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  962. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  963. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  964. #else
  965. #define __Pyx_RefNannyDeclarations
  966. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  967. #define __Pyx_RefNannyFinishContext()
  968. #define __Pyx_INCREF(r) Py_INCREF(r)
  969. #define __Pyx_DECREF(r) Py_DECREF(r)
  970. #define __Pyx_GOTREF(r)
  971. #define __Pyx_GIVEREF(r)
  972. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  973. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  974. #define __Pyx_XGOTREF(r)
  975. #define __Pyx_XGIVEREF(r)
  976. #endif
  977. #define __Pyx_XDECREF_SET(r, v) do {\
  978. PyObject *tmp = (PyObject *) r;\
  979. r = v; __Pyx_XDECREF(tmp);\
  980. } while (0)
  981. #define __Pyx_DECREF_SET(r, v) do {\
  982. PyObject *tmp = (PyObject *) r;\
  983. r = v; __Pyx_DECREF(tmp);\
  984. } while (0)
  985. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  986. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  987. /* PyObjectGetAttrStr.proto */
  988. #if CYTHON_USE_TYPE_SLOTS
  989. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  990. #else
  991. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  992. #endif
  993. /* GetBuiltinName.proto */
  994. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  995. /* RaiseArgTupleInvalid.proto */
  996. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  997. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  998. /* RaiseDoubleKeywords.proto */
  999. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  1000. /* ParseKeywords.proto */
  1001. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
  1002. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
  1003. const char* function_name);
  1004. /* ArgTypeTest.proto */
  1005. #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
  1006. ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
  1007. __Pyx__ArgTypeTest(obj, type, name, exact))
  1008. static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
  1009. /* PyFunctionFastCall.proto */
  1010. #if CYTHON_FAST_PYCALL
  1011. #define __Pyx_PyFunction_FastCall(func, args, nargs)\
  1012. __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
  1013. #if 1 || PY_VERSION_HEX < 0x030600B1
  1014. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
  1015. #else
  1016. #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
  1017. #endif
  1018. #define __Pyx_BUILD_ASSERT_EXPR(cond)\
  1019. (sizeof(char [1 - 2*!(cond)]) - 1)
  1020. #ifndef Py_MEMBER_SIZE
  1021. #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
  1022. #endif
  1023. #if CYTHON_FAST_PYCALL
  1024. static size_t __pyx_pyframe_localsplus_offset = 0;
  1025. #include "frameobject.h"
  1026. #define __Pxy_PyFrame_Initialize_Offsets()\
  1027. ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
  1028. (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  1029. #define __Pyx_PyFrame_GetLocalsplus(frame)\
  1030. (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
  1031. #endif // CYTHON_FAST_PYCALL
  1032. #endif
  1033. /* PyCFunctionFastCall.proto */
  1034. #if CYTHON_FAST_PYCCALL
  1035. static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
  1036. #else
  1037. #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
  1038. #endif
  1039. /* PyObjectCall.proto */
  1040. #if CYTHON_COMPILING_IN_CPYTHON
  1041. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  1042. #else
  1043. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  1044. #endif
  1045. /* PyThreadStateGet.proto */
  1046. #if CYTHON_FAST_THREAD_STATE
  1047. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  1048. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  1049. #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
  1050. #else
  1051. #define __Pyx_PyThreadState_declare
  1052. #define __Pyx_PyThreadState_assign
  1053. #define __Pyx_PyErr_Occurred() PyErr_Occurred()
  1054. #endif
  1055. /* PyErrFetchRestore.proto */
  1056. #if CYTHON_FAST_THREAD_STATE
  1057. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  1058. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  1059. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  1060. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  1061. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  1062. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1063. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1064. #if CYTHON_COMPILING_IN_CPYTHON
  1065. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  1066. #else
  1067. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1068. #endif
  1069. #else
  1070. #define __Pyx_PyErr_Clear() PyErr_Clear()
  1071. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1072. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  1073. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  1074. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  1075. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  1076. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  1077. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  1078. #endif
  1079. /* RaiseException.proto */
  1080. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  1081. /* PyDictVersioning.proto */
  1082. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  1083. #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
  1084. #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
  1085. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
  1086. (version_var) = __PYX_GET_DICT_VERSION(dict);\
  1087. (cache_var) = (value);
  1088. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
  1089. static PY_UINT64_T __pyx_dict_version = 0;\
  1090. static PyObject *__pyx_dict_cached_value = NULL;\
  1091. if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
  1092. (VAR) = __pyx_dict_cached_value;\
  1093. } else {\
  1094. (VAR) = __pyx_dict_cached_value = (LOOKUP);\
  1095. __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
  1096. }\
  1097. }
  1098. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
  1099. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
  1100. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
  1101. #else
  1102. #define __PYX_GET_DICT_VERSION(dict) (0)
  1103. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
  1104. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
  1105. #endif
  1106. /* GetModuleGlobalName.proto */
  1107. #if CYTHON_USE_DICT_VERSIONS
  1108. #define __Pyx_GetModuleGlobalName(var, name) {\
  1109. static PY_UINT64_T __pyx_dict_version = 0;\
  1110. static PyObject *__pyx_dict_cached_value = NULL;\
  1111. (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
  1112. (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
  1113. __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  1114. }
  1115. #define __Pyx_GetModuleGlobalNameUncached(var, name) {\
  1116. PY_UINT64_T __pyx_dict_version;\
  1117. PyObject *__pyx_dict_cached_value;\
  1118. (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  1119. }
  1120. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
  1121. #else
  1122. #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  1123. #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  1124. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
  1125. #endif
  1126. /* PyObjectCall2Args.proto */
  1127. static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
  1128. /* PyObjectCallMethO.proto */
  1129. #if CYTHON_COMPILING_IN_CPYTHON
  1130. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  1131. #endif
  1132. /* PyObjectCallOneArg.proto */
  1133. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  1134. /* GetException.proto */
  1135. #if CYTHON_FAST_THREAD_STATE
  1136. #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
  1137. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1138. #else
  1139. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
  1140. #endif
  1141. /* SwapException.proto */
  1142. #if CYTHON_FAST_THREAD_STATE
  1143. #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
  1144. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1145. #else
  1146. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
  1147. #endif
  1148. /* GetTopmostException.proto */
  1149. #if CYTHON_USE_EXC_INFO_STACK
  1150. static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
  1151. #endif
  1152. /* SaveResetException.proto */
  1153. #if CYTHON_FAST_THREAD_STATE
  1154. #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
  1155. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1156. #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
  1157. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1158. #else
  1159. #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
  1160. #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
  1161. #endif
  1162. /* IncludeStringH.proto */
  1163. #include <string.h>
  1164. /* PyObject_GenericGetAttrNoDict.proto */
  1165. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1166. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
  1167. #else
  1168. #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
  1169. #endif
  1170. /* PyObject_GenericGetAttr.proto */
  1171. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  1172. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
  1173. #else
  1174. #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
  1175. #endif
  1176. /* PyErrExceptionMatches.proto */
  1177. #if CYTHON_FAST_THREAD_STATE
  1178. #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
  1179. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
  1180. #else
  1181. #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
  1182. #endif
  1183. /* PyObjectGetAttrStrNoError.proto */
  1184. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
  1185. /* SetupReduce.proto */
  1186. static int __Pyx_setup_reduce(PyObject* type_obj);
  1187. /* TypeImport.proto */
  1188. #ifndef __PYX_HAVE_RT_ImportType_proto
  1189. #define __PYX_HAVE_RT_ImportType_proto
  1190. enum __Pyx_ImportType_CheckSize {
  1191. __Pyx_ImportType_CheckSize_Error = 0,
  1192. __Pyx_ImportType_CheckSize_Warn = 1,
  1193. __Pyx_ImportType_CheckSize_Ignore = 2
  1194. };
  1195. static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
  1196. #endif
  1197. /* Import.proto */
  1198. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
  1199. /* ImportFrom.proto */
  1200. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
  1201. /* CLineInTraceback.proto */
  1202. #ifdef CYTHON_CLINE_IN_TRACEBACK
  1203. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  1204. #else
  1205. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  1206. #endif
  1207. /* CodeObjectCache.proto */
  1208. typedef struct {
  1209. PyCodeObject* code_object;
  1210. int code_line;
  1211. } __Pyx_CodeObjectCacheEntry;
  1212. struct __Pyx_CodeObjectCache {
  1213. int count;
  1214. int max_count;
  1215. __Pyx_CodeObjectCacheEntry* entries;
  1216. };
  1217. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  1218. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  1219. static PyCodeObject *__pyx_find_code_object(int code_line);
  1220. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  1221. /* AddTraceback.proto */
  1222. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  1223. int py_line, const char *filename);
  1224. /* GCCDiagnostics.proto */
  1225. #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
  1226. #define __Pyx_HAS_GCC_DIAGNOSTIC
  1227. #endif
  1228. /* CIntToPy.proto */
  1229. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint16_t(uint16_t value);
  1230. /* CIntToPy.proto */
  1231. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  1232. /* CIntFromPy.proto */
  1233. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  1234. /* CIntFromPy.proto */
  1235. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  1236. /* FastTypeChecks.proto */
  1237. #if CYTHON_COMPILING_IN_CPYTHON
  1238. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  1239. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  1240. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  1241. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  1242. #else
  1243. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  1244. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  1245. #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
  1246. #endif
  1247. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  1248. /* CheckBinaryVersion.proto */
  1249. static int __Pyx_check_binary_version(void);
  1250. /* InitStrings.proto */
  1251. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  1252. /* Module declarations from 'cpython.mem' */
  1253. /* Module declarations from 'cpython.version' */
  1254. /* Module declarations from '__builtin__' */
  1255. /* Module declarations from 'cpython.type' */
  1256. static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
  1257. /* Module declarations from 'libc.string' */
  1258. /* Module declarations from 'libc.stdio' */
  1259. /* Module declarations from 'cpython.object' */
  1260. /* Module declarations from 'cpython.ref' */
  1261. /* Module declarations from 'cpython.exc' */
  1262. /* Module declarations from 'cpython.module' */
  1263. /* Module declarations from 'cpython.tuple' */
  1264. /* Module declarations from 'cpython.list' */
  1265. /* Module declarations from 'cpython.sequence' */
  1266. /* Module declarations from 'cpython.mapping' */
  1267. /* Module declarations from 'cpython.iterator' */
  1268. /* Module declarations from 'cpython.number' */
  1269. /* Module declarations from 'cpython.int' */
  1270. /* Module declarations from '__builtin__' */
  1271. /* Module declarations from 'cpython.bool' */
  1272. static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
  1273. /* Module declarations from 'cpython.long' */
  1274. /* Module declarations from 'cpython.float' */
  1275. /* Module declarations from '__builtin__' */
  1276. /* Module declarations from 'cpython.complex' */
  1277. static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
  1278. /* Module declarations from 'cpython.string' */
  1279. /* Module declarations from 'cpython.unicode' */
  1280. /* Module declarations from 'cpython.dict' */
  1281. /* Module declarations from 'cpython.instance' */
  1282. /* Module declarations from 'cpython.function' */
  1283. /* Module declarations from 'cpython.method' */
  1284. /* Module declarations from 'cpython.weakref' */
  1285. /* Module declarations from 'cpython.getargs' */
  1286. /* Module declarations from 'cpython.pythread' */
  1287. /* Module declarations from 'cpython.pystate' */
  1288. /* Module declarations from 'cpython.cobject' */
  1289. /* Module declarations from 'cpython.oldbuffer' */
  1290. /* Module declarations from 'cpython.set' */
  1291. /* Module declarations from 'cpython.buffer' */
  1292. /* Module declarations from 'cpython.bytes' */
  1293. /* Module declarations from 'cpython.pycapsule' */
  1294. /* Module declarations from 'cpython' */
  1295. /* Module declarations from 'cython' */
  1296. /* Module declarations from 'httptools.parser' */
  1297. /* Module declarations from 'libc.stdint' */
  1298. /* Module declarations from 'httptools.parser.url_cparser' */
  1299. /* Module declarations from 'httptools.parser.url_parser' */
  1300. static PyTypeObject *__pyx_ptype_9httptools_6parser_10url_parser_URL = 0;
  1301. #define __Pyx_MODULE_NAME "httptools.parser.url_parser"
  1302. extern int __pyx_module_is_main_httptools__parser__url_parser;
  1303. int __pyx_module_is_main_httptools__parser__url_parser = 0;
  1304. /* Implementation of 'httptools.parser.url_parser' */
  1305. static PyObject *__pyx_builtin_TypeError;
  1306. static const char __pyx_k_ln[] = "ln";
  1307. static const char __pyx_k_URL[] = "URL";
  1308. static const char __pyx_k_all[] = "__all__";
  1309. static const char __pyx_k_off[] = "off";
  1310. static const char __pyx_k_res[] = "res";
  1311. static const char __pyx_k_url[] = "url";
  1312. static const char __pyx_k_host[] = "host";
  1313. static const char __pyx_k_main[] = "__main__";
  1314. static const char __pyx_k_name[] = "__name__";
  1315. static const char __pyx_k_path[] = "path";
  1316. static const char __pyx_k_port[] = "port";
  1317. static const char __pyx_k_test[] = "__test__";
  1318. static const char __pyx_k_query[] = "query";
  1319. static const char __pyx_k_errors[] = "errors";
  1320. static const char __pyx_k_format[] = "format";
  1321. static const char __pyx_k_import[] = "__import__";
  1322. static const char __pyx_k_parsed[] = "parsed";
  1323. static const char __pyx_k_py_buf[] = "py_buf";
  1324. static const char __pyx_k_reduce[] = "__reduce__";
  1325. static const char __pyx_k_result[] = "result";
  1326. static const char __pyx_k_schema[] = "schema";
  1327. static const char __pyx_k_buf_data[] = "buf_data";
  1328. static const char __pyx_k_fragment[] = "fragment";
  1329. static const char __pyx_k_getstate[] = "__getstate__";
  1330. static const char __pyx_k_setstate[] = "__setstate__";
  1331. static const char __pyx_k_userinfo[] = "userinfo";
  1332. static const char __pyx_k_TypeError[] = "TypeError";
  1333. static const char __pyx_k_parse_url[] = "parse_url";
  1334. static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
  1335. static const char __pyx_k_invalid_url_r[] = "invalid url {!r}";
  1336. static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
  1337. static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
  1338. static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
  1339. static const char __pyx_k_HttpParserInvalidURLError[] = "HttpParserInvalidURLError";
  1340. static const char __pyx_k_httptools_parser_url_parser[] = "httptools.parser.url_parser";
  1341. static const char __pyx_k_URL_schema_r_host_r_port_r_path[] = "<URL schema: {!r}, host: {!r}, port: {!r}, path: {!r}, query: {!r}, fragment: {!r}, userinfo: {!r}>";
  1342. static const char __pyx_k_httptools_parser_url_parser_pyx[] = "httptools\\parser\\url_parser.pyx";
  1343. static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
  1344. static PyObject *__pyx_n_s_HttpParserInvalidURLError;
  1345. static PyObject *__pyx_n_s_TypeError;
  1346. static PyObject *__pyx_n_s_URL;
  1347. static PyObject *__pyx_kp_u_URL_schema_r_host_r_port_r_path;
  1348. static PyObject *__pyx_n_s_all;
  1349. static PyObject *__pyx_n_s_buf_data;
  1350. static PyObject *__pyx_n_s_cline_in_traceback;
  1351. static PyObject *__pyx_n_s_errors;
  1352. static PyObject *__pyx_n_s_format;
  1353. static PyObject *__pyx_n_s_fragment;
  1354. static PyObject *__pyx_n_s_getstate;
  1355. static PyObject *__pyx_n_s_host;
  1356. static PyObject *__pyx_n_s_httptools_parser_url_parser;
  1357. static PyObject *__pyx_kp_s_httptools_parser_url_parser_pyx;
  1358. static PyObject *__pyx_n_s_import;
  1359. static PyObject *__pyx_kp_u_invalid_url_r;
  1360. static PyObject *__pyx_n_s_ln;
  1361. static PyObject *__pyx_n_s_main;
  1362. static PyObject *__pyx_n_s_name;
  1363. static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
  1364. static PyObject *__pyx_n_s_off;
  1365. static PyObject *__pyx_n_s_parse_url;
  1366. static PyObject *__pyx_n_u_parse_url;
  1367. static PyObject *__pyx_n_s_parsed;
  1368. static PyObject *__pyx_n_s_path;
  1369. static PyObject *__pyx_n_s_port;
  1370. static PyObject *__pyx_n_s_py_buf;
  1371. static PyObject *__pyx_n_s_query;
  1372. static PyObject *__pyx_n_s_reduce;
  1373. static PyObject *__pyx_n_s_reduce_cython;
  1374. static PyObject *__pyx_n_s_reduce_ex;
  1375. static PyObject *__pyx_n_s_res;
  1376. static PyObject *__pyx_n_s_result;
  1377. static PyObject *__pyx_n_s_schema;
  1378. static PyObject *__pyx_n_s_setstate;
  1379. static PyObject *__pyx_n_s_setstate_cython;
  1380. static PyObject *__pyx_n_s_test;
  1381. static PyObject *__pyx_n_s_url;
  1382. static PyObject *__pyx_n_s_userinfo;
  1383. static int __pyx_pf_9httptools_6parser_10url_parser_3URL___cinit__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self, PyObject *__pyx_v_schema, PyObject *__pyx_v_host, PyObject *__pyx_v_port, PyObject *__pyx_v_path, PyObject *__pyx_v_query, PyObject *__pyx_v_fragment, PyObject *__pyx_v_userinfo); /* proto */
  1384. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_2__repr__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self); /* proto */
  1385. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_6schema___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self); /* proto */
  1386. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_4host___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self); /* proto */
  1387. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_4port___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self); /* proto */
  1388. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_4path___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self); /* proto */
  1389. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_5query___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self); /* proto */
  1390. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_8fragment___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self); /* proto */
  1391. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_8userinfo___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self); /* proto */
  1392. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self); /* proto */
  1393. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
  1394. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_parse_url(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url); /* proto */
  1395. static PyObject *__pyx_tp_new_9httptools_6parser_10url_parser_URL(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1396. static PyObject *__pyx_tuple_;
  1397. static PyObject *__pyx_tuple__2;
  1398. static PyObject *__pyx_tuple__3;
  1399. static PyObject *__pyx_tuple__4;
  1400. static PyObject *__pyx_codeobj__5;
  1401. /* Late includes */
  1402. /* "httptools/parser/url_parser.pyx":25
  1403. * cdef readonly bytes userinfo
  1404. *
  1405. * def __cinit__(self, bytes schema, bytes host, object port, bytes path, # <<<<<<<<<<<<<<
  1406. * bytes query, bytes fragment, bytes userinfo):
  1407. *
  1408. */
  1409. /* Python wrapper */
  1410. static int __pyx_pw_9httptools_6parser_10url_parser_3URL_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1411. static int __pyx_pw_9httptools_6parser_10url_parser_3URL_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1412. PyObject *__pyx_v_schema = 0;
  1413. PyObject *__pyx_v_host = 0;
  1414. PyObject *__pyx_v_port = 0;
  1415. PyObject *__pyx_v_path = 0;
  1416. PyObject *__pyx_v_query = 0;
  1417. PyObject *__pyx_v_fragment = 0;
  1418. PyObject *__pyx_v_userinfo = 0;
  1419. int __pyx_lineno = 0;
  1420. const char *__pyx_filename = NULL;
  1421. int __pyx_clineno = 0;
  1422. int __pyx_r;
  1423. __Pyx_RefNannyDeclarations
  1424. __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
  1425. {
  1426. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_schema,&__pyx_n_s_host,&__pyx_n_s_port,&__pyx_n_s_path,&__pyx_n_s_query,&__pyx_n_s_fragment,&__pyx_n_s_userinfo,0};
  1427. PyObject* values[7] = {0,0,0,0,0,0,0};
  1428. if (unlikely(__pyx_kwds)) {
  1429. Py_ssize_t kw_args;
  1430. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1431. switch (pos_args) {
  1432. case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
  1433. CYTHON_FALLTHROUGH;
  1434. case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
  1435. CYTHON_FALLTHROUGH;
  1436. case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
  1437. CYTHON_FALLTHROUGH;
  1438. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  1439. CYTHON_FALLTHROUGH;
  1440. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  1441. CYTHON_FALLTHROUGH;
  1442. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1443. CYTHON_FALLTHROUGH;
  1444. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1445. CYTHON_FALLTHROUGH;
  1446. case 0: break;
  1447. default: goto __pyx_L5_argtuple_error;
  1448. }
  1449. kw_args = PyDict_Size(__pyx_kwds);
  1450. switch (pos_args) {
  1451. case 0:
  1452. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_schema)) != 0)) kw_args--;
  1453. else goto __pyx_L5_argtuple_error;
  1454. CYTHON_FALLTHROUGH;
  1455. case 1:
  1456. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_host)) != 0)) kw_args--;
  1457. else {
  1458. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 1); __PYX_ERR(1, 25, __pyx_L3_error)
  1459. }
  1460. CYTHON_FALLTHROUGH;
  1461. case 2:
  1462. if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_port)) != 0)) kw_args--;
  1463. else {
  1464. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 2); __PYX_ERR(1, 25, __pyx_L3_error)
  1465. }
  1466. CYTHON_FALLTHROUGH;
  1467. case 3:
  1468. if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--;
  1469. else {
  1470. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 3); __PYX_ERR(1, 25, __pyx_L3_error)
  1471. }
  1472. CYTHON_FALLTHROUGH;
  1473. case 4:
  1474. if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_query)) != 0)) kw_args--;
  1475. else {
  1476. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 4); __PYX_ERR(1, 25, __pyx_L3_error)
  1477. }
  1478. CYTHON_FALLTHROUGH;
  1479. case 5:
  1480. if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fragment)) != 0)) kw_args--;
  1481. else {
  1482. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 5); __PYX_ERR(1, 25, __pyx_L3_error)
  1483. }
  1484. CYTHON_FALLTHROUGH;
  1485. case 6:
  1486. if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_userinfo)) != 0)) kw_args--;
  1487. else {
  1488. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 6); __PYX_ERR(1, 25, __pyx_L3_error)
  1489. }
  1490. }
  1491. if (unlikely(kw_args > 0)) {
  1492. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 25, __pyx_L3_error)
  1493. }
  1494. } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
  1495. goto __pyx_L5_argtuple_error;
  1496. } else {
  1497. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1498. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1499. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  1500. values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  1501. values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
  1502. values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
  1503. values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
  1504. }
  1505. __pyx_v_schema = ((PyObject*)values[0]);
  1506. __pyx_v_host = ((PyObject*)values[1]);
  1507. __pyx_v_port = values[2];
  1508. __pyx_v_path = ((PyObject*)values[3]);
  1509. __pyx_v_query = ((PyObject*)values[4]);
  1510. __pyx_v_fragment = ((PyObject*)values[5]);
  1511. __pyx_v_userinfo = ((PyObject*)values[6]);
  1512. }
  1513. goto __pyx_L4_argument_unpacking_done;
  1514. __pyx_L5_argtuple_error:;
  1515. __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 25, __pyx_L3_error)
  1516. __pyx_L3_error:;
  1517. __Pyx_AddTraceback("httptools.parser.url_parser.URL.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1518. __Pyx_RefNannyFinishContext();
  1519. return -1;
  1520. __pyx_L4_argument_unpacking_done:;
  1521. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_schema), (&PyBytes_Type), 1, "schema", 1))) __PYX_ERR(1, 25, __pyx_L1_error)
  1522. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_host), (&PyBytes_Type), 1, "host", 1))) __PYX_ERR(1, 25, __pyx_L1_error)
  1523. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_path), (&PyBytes_Type), 1, "path", 1))) __PYX_ERR(1, 25, __pyx_L1_error)
  1524. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_query), (&PyBytes_Type), 1, "query", 1))) __PYX_ERR(1, 26, __pyx_L1_error)
  1525. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fragment), (&PyBytes_Type), 1, "fragment", 1))) __PYX_ERR(1, 26, __pyx_L1_error)
  1526. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_userinfo), (&PyBytes_Type), 1, "userinfo", 1))) __PYX_ERR(1, 26, __pyx_L1_error)
  1527. __pyx_r = __pyx_pf_9httptools_6parser_10url_parser_3URL___cinit__(((struct __pyx_obj_9httptools_6parser_10url_parser_URL *)__pyx_v_self), __pyx_v_schema, __pyx_v_host, __pyx_v_port, __pyx_v_path, __pyx_v_query, __pyx_v_fragment, __pyx_v_userinfo);
  1528. /* function exit code */
  1529. goto __pyx_L0;
  1530. __pyx_L1_error:;
  1531. __pyx_r = -1;
  1532. __pyx_L0:;
  1533. __Pyx_RefNannyFinishContext();
  1534. return __pyx_r;
  1535. }
  1536. static int __pyx_pf_9httptools_6parser_10url_parser_3URL___cinit__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self, PyObject *__pyx_v_schema, PyObject *__pyx_v_host, PyObject *__pyx_v_port, PyObject *__pyx_v_path, PyObject *__pyx_v_query, PyObject *__pyx_v_fragment, PyObject *__pyx_v_userinfo) {
  1537. int __pyx_r;
  1538. __Pyx_RefNannyDeclarations
  1539. __Pyx_RefNannySetupContext("__cinit__", 0);
  1540. /* "httptools/parser/url_parser.pyx":28
  1541. * bytes query, bytes fragment, bytes userinfo):
  1542. *
  1543. * self.schema = schema # <<<<<<<<<<<<<<
  1544. * self.host = host
  1545. * self.port = port
  1546. */
  1547. __Pyx_INCREF(__pyx_v_schema);
  1548. __Pyx_GIVEREF(__pyx_v_schema);
  1549. __Pyx_GOTREF(__pyx_v_self->schema);
  1550. __Pyx_DECREF(__pyx_v_self->schema);
  1551. __pyx_v_self->schema = __pyx_v_schema;
  1552. /* "httptools/parser/url_parser.pyx":29
  1553. *
  1554. * self.schema = schema
  1555. * self.host = host # <<<<<<<<<<<<<<
  1556. * self.port = port
  1557. * self.path = path
  1558. */
  1559. __Pyx_INCREF(__pyx_v_host);
  1560. __Pyx_GIVEREF(__pyx_v_host);
  1561. __Pyx_GOTREF(__pyx_v_self->host);
  1562. __Pyx_DECREF(__pyx_v_self->host);
  1563. __pyx_v_self->host = __pyx_v_host;
  1564. /* "httptools/parser/url_parser.pyx":30
  1565. * self.schema = schema
  1566. * self.host = host
  1567. * self.port = port # <<<<<<<<<<<<<<
  1568. * self.path = path
  1569. * self.query = query
  1570. */
  1571. __Pyx_INCREF(__pyx_v_port);
  1572. __Pyx_GIVEREF(__pyx_v_port);
  1573. __Pyx_GOTREF(__pyx_v_self->port);
  1574. __Pyx_DECREF(__pyx_v_self->port);
  1575. __pyx_v_self->port = __pyx_v_port;
  1576. /* "httptools/parser/url_parser.pyx":31
  1577. * self.host = host
  1578. * self.port = port
  1579. * self.path = path # <<<<<<<<<<<<<<
  1580. * self.query = query
  1581. * self.fragment = fragment
  1582. */
  1583. __Pyx_INCREF(__pyx_v_path);
  1584. __Pyx_GIVEREF(__pyx_v_path);
  1585. __Pyx_GOTREF(__pyx_v_self->path);
  1586. __Pyx_DECREF(__pyx_v_self->path);
  1587. __pyx_v_self->path = __pyx_v_path;
  1588. /* "httptools/parser/url_parser.pyx":32
  1589. * self.port = port
  1590. * self.path = path
  1591. * self.query = query # <<<<<<<<<<<<<<
  1592. * self.fragment = fragment
  1593. * self.userinfo = userinfo
  1594. */
  1595. __Pyx_INCREF(__pyx_v_query);
  1596. __Pyx_GIVEREF(__pyx_v_query);
  1597. __Pyx_GOTREF(__pyx_v_self->query);
  1598. __Pyx_DECREF(__pyx_v_self->query);
  1599. __pyx_v_self->query = __pyx_v_query;
  1600. /* "httptools/parser/url_parser.pyx":33
  1601. * self.path = path
  1602. * self.query = query
  1603. * self.fragment = fragment # <<<<<<<<<<<<<<
  1604. * self.userinfo = userinfo
  1605. *
  1606. */
  1607. __Pyx_INCREF(__pyx_v_fragment);
  1608. __Pyx_GIVEREF(__pyx_v_fragment);
  1609. __Pyx_GOTREF(__pyx_v_self->fragment);
  1610. __Pyx_DECREF(__pyx_v_self->fragment);
  1611. __pyx_v_self->fragment = __pyx_v_fragment;
  1612. /* "httptools/parser/url_parser.pyx":34
  1613. * self.query = query
  1614. * self.fragment = fragment
  1615. * self.userinfo = userinfo # <<<<<<<<<<<<<<
  1616. *
  1617. * def __repr__(self):
  1618. */
  1619. __Pyx_INCREF(__pyx_v_userinfo);
  1620. __Pyx_GIVEREF(__pyx_v_userinfo);
  1621. __Pyx_GOTREF(__pyx_v_self->userinfo);
  1622. __Pyx_DECREF(__pyx_v_self->userinfo);
  1623. __pyx_v_self->userinfo = __pyx_v_userinfo;
  1624. /* "httptools/parser/url_parser.pyx":25
  1625. * cdef readonly bytes userinfo
  1626. *
  1627. * def __cinit__(self, bytes schema, bytes host, object port, bytes path, # <<<<<<<<<<<<<<
  1628. * bytes query, bytes fragment, bytes userinfo):
  1629. *
  1630. */
  1631. /* function exit code */
  1632. __pyx_r = 0;
  1633. __Pyx_RefNannyFinishContext();
  1634. return __pyx_r;
  1635. }
  1636. /* "httptools/parser/url_parser.pyx":36
  1637. * self.userinfo = userinfo
  1638. *
  1639. * def __repr__(self): # <<<<<<<<<<<<<<
  1640. * return ('<URL schema: {!r}, host: {!r}, port: {!r}, path: {!r}, '
  1641. * 'query: {!r}, fragment: {!r}, userinfo: {!r}>'
  1642. */
  1643. /* Python wrapper */
  1644. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_3__repr__(PyObject *__pyx_v_self); /*proto*/
  1645. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_3__repr__(PyObject *__pyx_v_self) {
  1646. PyObject *__pyx_r = 0;
  1647. __Pyx_RefNannyDeclarations
  1648. __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  1649. __pyx_r = __pyx_pf_9httptools_6parser_10url_parser_3URL_2__repr__(((struct __pyx_obj_9httptools_6parser_10url_parser_URL *)__pyx_v_self));
  1650. /* function exit code */
  1651. __Pyx_RefNannyFinishContext();
  1652. return __pyx_r;
  1653. }
  1654. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_2__repr__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self) {
  1655. PyObject *__pyx_r = NULL;
  1656. __Pyx_RefNannyDeclarations
  1657. PyObject *__pyx_t_1 = NULL;
  1658. PyObject *__pyx_t_2 = NULL;
  1659. PyObject *__pyx_t_3 = NULL;
  1660. int __pyx_t_4;
  1661. PyObject *__pyx_t_5 = NULL;
  1662. int __pyx_lineno = 0;
  1663. const char *__pyx_filename = NULL;
  1664. int __pyx_clineno = 0;
  1665. __Pyx_RefNannySetupContext("__repr__", 0);
  1666. /* "httptools/parser/url_parser.pyx":37
  1667. *
  1668. * def __repr__(self):
  1669. * return ('<URL schema: {!r}, host: {!r}, port: {!r}, path: {!r}, ' # <<<<<<<<<<<<<<
  1670. * 'query: {!r}, fragment: {!r}, userinfo: {!r}>'
  1671. * .format(self.schema, self.host, self.port, self.path,
  1672. */
  1673. __Pyx_XDECREF(__pyx_r);
  1674. /* "httptools/parser/url_parser.pyx":39
  1675. * return ('<URL schema: {!r}, host: {!r}, port: {!r}, path: {!r}, '
  1676. * 'query: {!r}, fragment: {!r}, userinfo: {!r}>'
  1677. * .format(self.schema, self.host, self.port, self.path, # <<<<<<<<<<<<<<
  1678. * self.query, self.fragment, self.userinfo))
  1679. *
  1680. */
  1681. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_URL_schema_r_host_r_port_r_path, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 39, __pyx_L1_error)
  1682. __Pyx_GOTREF(__pyx_t_2);
  1683. /* "httptools/parser/url_parser.pyx":40
  1684. * 'query: {!r}, fragment: {!r}, userinfo: {!r}>'
  1685. * .format(self.schema, self.host, self.port, self.path,
  1686. * self.query, self.fragment, self.userinfo)) # <<<<<<<<<<<<<<
  1687. *
  1688. *
  1689. */
  1690. __pyx_t_3 = NULL;
  1691. __pyx_t_4 = 0;
  1692. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  1693. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  1694. if (likely(__pyx_t_3)) {
  1695. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  1696. __Pyx_INCREF(__pyx_t_3);
  1697. __Pyx_INCREF(function);
  1698. __Pyx_DECREF_SET(__pyx_t_2, function);
  1699. __pyx_t_4 = 1;
  1700. }
  1701. }
  1702. #if CYTHON_FAST_PYCALL
  1703. if (PyFunction_Check(__pyx_t_2)) {
  1704. PyObject *__pyx_temp[8] = {__pyx_t_3, __pyx_v_self->schema, __pyx_v_self->host, __pyx_v_self->port, __pyx_v_self->path, __pyx_v_self->query, __pyx_v_self->fragment, __pyx_v_self->userinfo};
  1705. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 7+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 39, __pyx_L1_error)
  1706. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  1707. __Pyx_GOTREF(__pyx_t_1);
  1708. } else
  1709. #endif
  1710. #if CYTHON_FAST_PYCCALL
  1711. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  1712. PyObject *__pyx_temp[8] = {__pyx_t_3, __pyx_v_self->schema, __pyx_v_self->host, __pyx_v_self->port, __pyx_v_self->path, __pyx_v_self->query, __pyx_v_self->fragment, __pyx_v_self->userinfo};
  1713. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 7+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 39, __pyx_L1_error)
  1714. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  1715. __Pyx_GOTREF(__pyx_t_1);
  1716. } else
  1717. #endif
  1718. {
  1719. __pyx_t_5 = PyTuple_New(7+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 39, __pyx_L1_error)
  1720. __Pyx_GOTREF(__pyx_t_5);
  1721. if (__pyx_t_3) {
  1722. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  1723. }
  1724. __Pyx_INCREF(__pyx_v_self->schema);
  1725. __Pyx_GIVEREF(__pyx_v_self->schema);
  1726. PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_self->schema);
  1727. __Pyx_INCREF(__pyx_v_self->host);
  1728. __Pyx_GIVEREF(__pyx_v_self->host);
  1729. PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_self->host);
  1730. __Pyx_INCREF(__pyx_v_self->port);
  1731. __Pyx_GIVEREF(__pyx_v_self->port);
  1732. PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_self->port);
  1733. __Pyx_INCREF(__pyx_v_self->path);
  1734. __Pyx_GIVEREF(__pyx_v_self->path);
  1735. PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_self->path);
  1736. __Pyx_INCREF(__pyx_v_self->query);
  1737. __Pyx_GIVEREF(__pyx_v_self->query);
  1738. PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_v_self->query);
  1739. __Pyx_INCREF(__pyx_v_self->fragment);
  1740. __Pyx_GIVEREF(__pyx_v_self->fragment);
  1741. PyTuple_SET_ITEM(__pyx_t_5, 5+__pyx_t_4, __pyx_v_self->fragment);
  1742. __Pyx_INCREF(__pyx_v_self->userinfo);
  1743. __Pyx_GIVEREF(__pyx_v_self->userinfo);
  1744. PyTuple_SET_ITEM(__pyx_t_5, 6+__pyx_t_4, __pyx_v_self->userinfo);
  1745. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 39, __pyx_L1_error)
  1746. __Pyx_GOTREF(__pyx_t_1);
  1747. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1748. }
  1749. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1750. __pyx_r = __pyx_t_1;
  1751. __pyx_t_1 = 0;
  1752. goto __pyx_L0;
  1753. /* "httptools/parser/url_parser.pyx":36
  1754. * self.userinfo = userinfo
  1755. *
  1756. * def __repr__(self): # <<<<<<<<<<<<<<
  1757. * return ('<URL schema: {!r}, host: {!r}, port: {!r}, path: {!r}, '
  1758. * 'query: {!r}, fragment: {!r}, userinfo: {!r}>'
  1759. */
  1760. /* function exit code */
  1761. __pyx_L1_error:;
  1762. __Pyx_XDECREF(__pyx_t_1);
  1763. __Pyx_XDECREF(__pyx_t_2);
  1764. __Pyx_XDECREF(__pyx_t_3);
  1765. __Pyx_XDECREF(__pyx_t_5);
  1766. __Pyx_AddTraceback("httptools.parser.url_parser.URL.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1767. __pyx_r = NULL;
  1768. __pyx_L0:;
  1769. __Pyx_XGIVEREF(__pyx_r);
  1770. __Pyx_RefNannyFinishContext();
  1771. return __pyx_r;
  1772. }
  1773. /* "httptools/parser/url_parser.pyx":17
  1774. * @cython.freelist(250)
  1775. * cdef class URL:
  1776. * cdef readonly bytes schema # <<<<<<<<<<<<<<
  1777. * cdef readonly bytes host
  1778. * cdef readonly object port
  1779. */
  1780. /* Python wrapper */
  1781. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_6schema_1__get__(PyObject *__pyx_v_self); /*proto*/
  1782. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_6schema_1__get__(PyObject *__pyx_v_self) {
  1783. PyObject *__pyx_r = 0;
  1784. __Pyx_RefNannyDeclarations
  1785. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  1786. __pyx_r = __pyx_pf_9httptools_6parser_10url_parser_3URL_6schema___get__(((struct __pyx_obj_9httptools_6parser_10url_parser_URL *)__pyx_v_self));
  1787. /* function exit code */
  1788. __Pyx_RefNannyFinishContext();
  1789. return __pyx_r;
  1790. }
  1791. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_6schema___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self) {
  1792. PyObject *__pyx_r = NULL;
  1793. __Pyx_RefNannyDeclarations
  1794. __Pyx_RefNannySetupContext("__get__", 0);
  1795. __Pyx_XDECREF(__pyx_r);
  1796. __Pyx_INCREF(__pyx_v_self->schema);
  1797. __pyx_r = __pyx_v_self->schema;
  1798. goto __pyx_L0;
  1799. /* function exit code */
  1800. __pyx_L0:;
  1801. __Pyx_XGIVEREF(__pyx_r);
  1802. __Pyx_RefNannyFinishContext();
  1803. return __pyx_r;
  1804. }
  1805. /* "httptools/parser/url_parser.pyx":18
  1806. * cdef class URL:
  1807. * cdef readonly bytes schema
  1808. * cdef readonly bytes host # <<<<<<<<<<<<<<
  1809. * cdef readonly object port
  1810. * cdef readonly bytes path
  1811. */
  1812. /* Python wrapper */
  1813. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_4host_1__get__(PyObject *__pyx_v_self); /*proto*/
  1814. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_4host_1__get__(PyObject *__pyx_v_self) {
  1815. PyObject *__pyx_r = 0;
  1816. __Pyx_RefNannyDeclarations
  1817. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  1818. __pyx_r = __pyx_pf_9httptools_6parser_10url_parser_3URL_4host___get__(((struct __pyx_obj_9httptools_6parser_10url_parser_URL *)__pyx_v_self));
  1819. /* function exit code */
  1820. __Pyx_RefNannyFinishContext();
  1821. return __pyx_r;
  1822. }
  1823. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_4host___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self) {
  1824. PyObject *__pyx_r = NULL;
  1825. __Pyx_RefNannyDeclarations
  1826. __Pyx_RefNannySetupContext("__get__", 0);
  1827. __Pyx_XDECREF(__pyx_r);
  1828. __Pyx_INCREF(__pyx_v_self->host);
  1829. __pyx_r = __pyx_v_self->host;
  1830. goto __pyx_L0;
  1831. /* function exit code */
  1832. __pyx_L0:;
  1833. __Pyx_XGIVEREF(__pyx_r);
  1834. __Pyx_RefNannyFinishContext();
  1835. return __pyx_r;
  1836. }
  1837. /* "httptools/parser/url_parser.pyx":19
  1838. * cdef readonly bytes schema
  1839. * cdef readonly bytes host
  1840. * cdef readonly object port # <<<<<<<<<<<<<<
  1841. * cdef readonly bytes path
  1842. * cdef readonly bytes query
  1843. */
  1844. /* Python wrapper */
  1845. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_4port_1__get__(PyObject *__pyx_v_self); /*proto*/
  1846. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_4port_1__get__(PyObject *__pyx_v_self) {
  1847. PyObject *__pyx_r = 0;
  1848. __Pyx_RefNannyDeclarations
  1849. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  1850. __pyx_r = __pyx_pf_9httptools_6parser_10url_parser_3URL_4port___get__(((struct __pyx_obj_9httptools_6parser_10url_parser_URL *)__pyx_v_self));
  1851. /* function exit code */
  1852. __Pyx_RefNannyFinishContext();
  1853. return __pyx_r;
  1854. }
  1855. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_4port___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self) {
  1856. PyObject *__pyx_r = NULL;
  1857. __Pyx_RefNannyDeclarations
  1858. __Pyx_RefNannySetupContext("__get__", 0);
  1859. __Pyx_XDECREF(__pyx_r);
  1860. __Pyx_INCREF(__pyx_v_self->port);
  1861. __pyx_r = __pyx_v_self->port;
  1862. goto __pyx_L0;
  1863. /* function exit code */
  1864. __pyx_L0:;
  1865. __Pyx_XGIVEREF(__pyx_r);
  1866. __Pyx_RefNannyFinishContext();
  1867. return __pyx_r;
  1868. }
  1869. /* "httptools/parser/url_parser.pyx":20
  1870. * cdef readonly bytes host
  1871. * cdef readonly object port
  1872. * cdef readonly bytes path # <<<<<<<<<<<<<<
  1873. * cdef readonly bytes query
  1874. * cdef readonly bytes fragment
  1875. */
  1876. /* Python wrapper */
  1877. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_4path_1__get__(PyObject *__pyx_v_self); /*proto*/
  1878. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_4path_1__get__(PyObject *__pyx_v_self) {
  1879. PyObject *__pyx_r = 0;
  1880. __Pyx_RefNannyDeclarations
  1881. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  1882. __pyx_r = __pyx_pf_9httptools_6parser_10url_parser_3URL_4path___get__(((struct __pyx_obj_9httptools_6parser_10url_parser_URL *)__pyx_v_self));
  1883. /* function exit code */
  1884. __Pyx_RefNannyFinishContext();
  1885. return __pyx_r;
  1886. }
  1887. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_4path___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self) {
  1888. PyObject *__pyx_r = NULL;
  1889. __Pyx_RefNannyDeclarations
  1890. __Pyx_RefNannySetupContext("__get__", 0);
  1891. __Pyx_XDECREF(__pyx_r);
  1892. __Pyx_INCREF(__pyx_v_self->path);
  1893. __pyx_r = __pyx_v_self->path;
  1894. goto __pyx_L0;
  1895. /* function exit code */
  1896. __pyx_L0:;
  1897. __Pyx_XGIVEREF(__pyx_r);
  1898. __Pyx_RefNannyFinishContext();
  1899. return __pyx_r;
  1900. }
  1901. /* "httptools/parser/url_parser.pyx":21
  1902. * cdef readonly object port
  1903. * cdef readonly bytes path
  1904. * cdef readonly bytes query # <<<<<<<<<<<<<<
  1905. * cdef readonly bytes fragment
  1906. * cdef readonly bytes userinfo
  1907. */
  1908. /* Python wrapper */
  1909. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_5query_1__get__(PyObject *__pyx_v_self); /*proto*/
  1910. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_5query_1__get__(PyObject *__pyx_v_self) {
  1911. PyObject *__pyx_r = 0;
  1912. __Pyx_RefNannyDeclarations
  1913. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  1914. __pyx_r = __pyx_pf_9httptools_6parser_10url_parser_3URL_5query___get__(((struct __pyx_obj_9httptools_6parser_10url_parser_URL *)__pyx_v_self));
  1915. /* function exit code */
  1916. __Pyx_RefNannyFinishContext();
  1917. return __pyx_r;
  1918. }
  1919. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_5query___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self) {
  1920. PyObject *__pyx_r = NULL;
  1921. __Pyx_RefNannyDeclarations
  1922. __Pyx_RefNannySetupContext("__get__", 0);
  1923. __Pyx_XDECREF(__pyx_r);
  1924. __Pyx_INCREF(__pyx_v_self->query);
  1925. __pyx_r = __pyx_v_self->query;
  1926. goto __pyx_L0;
  1927. /* function exit code */
  1928. __pyx_L0:;
  1929. __Pyx_XGIVEREF(__pyx_r);
  1930. __Pyx_RefNannyFinishContext();
  1931. return __pyx_r;
  1932. }
  1933. /* "httptools/parser/url_parser.pyx":22
  1934. * cdef readonly bytes path
  1935. * cdef readonly bytes query
  1936. * cdef readonly bytes fragment # <<<<<<<<<<<<<<
  1937. * cdef readonly bytes userinfo
  1938. *
  1939. */
  1940. /* Python wrapper */
  1941. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_8fragment_1__get__(PyObject *__pyx_v_self); /*proto*/
  1942. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_8fragment_1__get__(PyObject *__pyx_v_self) {
  1943. PyObject *__pyx_r = 0;
  1944. __Pyx_RefNannyDeclarations
  1945. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  1946. __pyx_r = __pyx_pf_9httptools_6parser_10url_parser_3URL_8fragment___get__(((struct __pyx_obj_9httptools_6parser_10url_parser_URL *)__pyx_v_self));
  1947. /* function exit code */
  1948. __Pyx_RefNannyFinishContext();
  1949. return __pyx_r;
  1950. }
  1951. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_8fragment___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self) {
  1952. PyObject *__pyx_r = NULL;
  1953. __Pyx_RefNannyDeclarations
  1954. __Pyx_RefNannySetupContext("__get__", 0);
  1955. __Pyx_XDECREF(__pyx_r);
  1956. __Pyx_INCREF(__pyx_v_self->fragment);
  1957. __pyx_r = __pyx_v_self->fragment;
  1958. goto __pyx_L0;
  1959. /* function exit code */
  1960. __pyx_L0:;
  1961. __Pyx_XGIVEREF(__pyx_r);
  1962. __Pyx_RefNannyFinishContext();
  1963. return __pyx_r;
  1964. }
  1965. /* "httptools/parser/url_parser.pyx":23
  1966. * cdef readonly bytes query
  1967. * cdef readonly bytes fragment
  1968. * cdef readonly bytes userinfo # <<<<<<<<<<<<<<
  1969. *
  1970. * def __cinit__(self, bytes schema, bytes host, object port, bytes path,
  1971. */
  1972. /* Python wrapper */
  1973. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_8userinfo_1__get__(PyObject *__pyx_v_self); /*proto*/
  1974. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_8userinfo_1__get__(PyObject *__pyx_v_self) {
  1975. PyObject *__pyx_r = 0;
  1976. __Pyx_RefNannyDeclarations
  1977. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  1978. __pyx_r = __pyx_pf_9httptools_6parser_10url_parser_3URL_8userinfo___get__(((struct __pyx_obj_9httptools_6parser_10url_parser_URL *)__pyx_v_self));
  1979. /* function exit code */
  1980. __Pyx_RefNannyFinishContext();
  1981. return __pyx_r;
  1982. }
  1983. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_8userinfo___get__(struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self) {
  1984. PyObject *__pyx_r = NULL;
  1985. __Pyx_RefNannyDeclarations
  1986. __Pyx_RefNannySetupContext("__get__", 0);
  1987. __Pyx_XDECREF(__pyx_r);
  1988. __Pyx_INCREF(__pyx_v_self->userinfo);
  1989. __pyx_r = __pyx_v_self->userinfo;
  1990. goto __pyx_L0;
  1991. /* function exit code */
  1992. __pyx_L0:;
  1993. __Pyx_XGIVEREF(__pyx_r);
  1994. __Pyx_RefNannyFinishContext();
  1995. return __pyx_r;
  1996. }
  1997. /* "(tree fragment)":1
  1998. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  1999. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2000. * def __setstate_cython__(self, __pyx_state):
  2001. */
  2002. /* Python wrapper */
  2003. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  2004. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  2005. PyObject *__pyx_r = 0;
  2006. __Pyx_RefNannyDeclarations
  2007. __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  2008. __pyx_r = __pyx_pf_9httptools_6parser_10url_parser_3URL_4__reduce_cython__(((struct __pyx_obj_9httptools_6parser_10url_parser_URL *)__pyx_v_self));
  2009. /* function exit code */
  2010. __Pyx_RefNannyFinishContext();
  2011. return __pyx_r;
  2012. }
  2013. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_4__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self) {
  2014. PyObject *__pyx_r = NULL;
  2015. __Pyx_RefNannyDeclarations
  2016. PyObject *__pyx_t_1 = NULL;
  2017. int __pyx_lineno = 0;
  2018. const char *__pyx_filename = NULL;
  2019. int __pyx_clineno = 0;
  2020. __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  2021. /* "(tree fragment)":2
  2022. * def __reduce_cython__(self):
  2023. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  2024. * def __setstate_cython__(self, __pyx_state):
  2025. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2026. */
  2027. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error)
  2028. __Pyx_GOTREF(__pyx_t_1);
  2029. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  2030. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2031. __PYX_ERR(0, 2, __pyx_L1_error)
  2032. /* "(tree fragment)":1
  2033. * def __reduce_cython__(self): # <<<<<<<<<<<<<<
  2034. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2035. * def __setstate_cython__(self, __pyx_state):
  2036. */
  2037. /* function exit code */
  2038. __pyx_L1_error:;
  2039. __Pyx_XDECREF(__pyx_t_1);
  2040. __Pyx_AddTraceback("httptools.parser.url_parser.URL.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2041. __pyx_r = NULL;
  2042. __Pyx_XGIVEREF(__pyx_r);
  2043. __Pyx_RefNannyFinishContext();
  2044. return __pyx_r;
  2045. }
  2046. /* "(tree fragment)":3
  2047. * def __reduce_cython__(self):
  2048. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2049. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  2050. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2051. */
  2052. /* Python wrapper */
  2053. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
  2054. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_3URL_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  2055. PyObject *__pyx_r = 0;
  2056. __Pyx_RefNannyDeclarations
  2057. __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  2058. __pyx_r = __pyx_pf_9httptools_6parser_10url_parser_3URL_6__setstate_cython__(((struct __pyx_obj_9httptools_6parser_10url_parser_URL *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
  2059. /* function exit code */
  2060. __Pyx_RefNannyFinishContext();
  2061. return __pyx_r;
  2062. }
  2063. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_3URL_6__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
  2064. PyObject *__pyx_r = NULL;
  2065. __Pyx_RefNannyDeclarations
  2066. PyObject *__pyx_t_1 = NULL;
  2067. int __pyx_lineno = 0;
  2068. const char *__pyx_filename = NULL;
  2069. int __pyx_clineno = 0;
  2070. __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  2071. /* "(tree fragment)":4
  2072. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2073. * def __setstate_cython__(self, __pyx_state):
  2074. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  2075. */
  2076. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
  2077. __Pyx_GOTREF(__pyx_t_1);
  2078. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  2079. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2080. __PYX_ERR(0, 4, __pyx_L1_error)
  2081. /* "(tree fragment)":3
  2082. * def __reduce_cython__(self):
  2083. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2084. * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
  2085. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  2086. */
  2087. /* function exit code */
  2088. __pyx_L1_error:;
  2089. __Pyx_XDECREF(__pyx_t_1);
  2090. __Pyx_AddTraceback("httptools.parser.url_parser.URL.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2091. __pyx_r = NULL;
  2092. __Pyx_XGIVEREF(__pyx_r);
  2093. __Pyx_RefNannyFinishContext();
  2094. return __pyx_r;
  2095. }
  2096. /* "httptools/parser/url_parser.pyx":43
  2097. *
  2098. *
  2099. * def parse_url(url): # <<<<<<<<<<<<<<
  2100. * cdef:
  2101. * Py_buffer py_buf
  2102. */
  2103. /* Python wrapper */
  2104. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_1parse_url(PyObject *__pyx_self, PyObject *__pyx_v_url); /*proto*/
  2105. static PyMethodDef __pyx_mdef_9httptools_6parser_10url_parser_1parse_url = {"parse_url", (PyCFunction)__pyx_pw_9httptools_6parser_10url_parser_1parse_url, METH_O, 0};
  2106. static PyObject *__pyx_pw_9httptools_6parser_10url_parser_1parse_url(PyObject *__pyx_self, PyObject *__pyx_v_url) {
  2107. PyObject *__pyx_r = 0;
  2108. __Pyx_RefNannyDeclarations
  2109. __Pyx_RefNannySetupContext("parse_url (wrapper)", 0);
  2110. __pyx_r = __pyx_pf_9httptools_6parser_10url_parser_parse_url(__pyx_self, ((PyObject *)__pyx_v_url));
  2111. /* function exit code */
  2112. __Pyx_RefNannyFinishContext();
  2113. return __pyx_r;
  2114. }
  2115. static PyObject *__pyx_pf_9httptools_6parser_10url_parser_parse_url(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url) {
  2116. Py_buffer __pyx_v_py_buf;
  2117. char *__pyx_v_buf_data;
  2118. struct http_parser_url *__pyx_v_parsed;
  2119. int __pyx_v_res;
  2120. PyObject *__pyx_v_schema = 0;
  2121. PyObject *__pyx_v_host = 0;
  2122. PyObject *__pyx_v_port = 0;
  2123. PyObject *__pyx_v_path = 0;
  2124. PyObject *__pyx_v_query = 0;
  2125. PyObject *__pyx_v_fragment = 0;
  2126. PyObject *__pyx_v_userinfo = 0;
  2127. CYTHON_UNUSED PyObject *__pyx_v_result = 0;
  2128. int __pyx_v_off;
  2129. int __pyx_v_ln;
  2130. PyObject *__pyx_r = NULL;
  2131. __Pyx_RefNannyDeclarations
  2132. int __pyx_t_1;
  2133. int __pyx_t_2;
  2134. uint16_t __pyx_t_3;
  2135. PyObject *__pyx_t_4 = NULL;
  2136. PyObject *__pyx_t_5 = NULL;
  2137. PyObject *__pyx_t_6 = NULL;
  2138. PyObject *__pyx_t_7 = NULL;
  2139. PyObject *__pyx_t_8 = NULL;
  2140. int __pyx_t_9;
  2141. char const *__pyx_t_10;
  2142. PyObject *__pyx_t_11 = NULL;
  2143. PyObject *__pyx_t_12 = NULL;
  2144. PyObject *__pyx_t_13 = NULL;
  2145. PyObject *__pyx_t_14 = NULL;
  2146. PyObject *__pyx_t_15 = NULL;
  2147. PyObject *__pyx_t_16 = NULL;
  2148. int __pyx_lineno = 0;
  2149. const char *__pyx_filename = NULL;
  2150. int __pyx_clineno = 0;
  2151. __Pyx_RefNannySetupContext("parse_url", 0);
  2152. /* "httptools/parser/url_parser.pyx":49
  2153. * uparser.http_parser_url* parsed
  2154. * int res
  2155. * bytes schema = None # <<<<<<<<<<<<<<
  2156. * bytes host = None
  2157. * object port = None
  2158. */
  2159. __Pyx_INCREF(Py_None);
  2160. __pyx_v_schema = ((PyObject*)Py_None);
  2161. /* "httptools/parser/url_parser.pyx":50
  2162. * int res
  2163. * bytes schema = None
  2164. * bytes host = None # <<<<<<<<<<<<<<
  2165. * object port = None
  2166. * bytes path = None
  2167. */
  2168. __Pyx_INCREF(Py_None);
  2169. __pyx_v_host = ((PyObject*)Py_None);
  2170. /* "httptools/parser/url_parser.pyx":51
  2171. * bytes schema = None
  2172. * bytes host = None
  2173. * object port = None # <<<<<<<<<<<<<<
  2174. * bytes path = None
  2175. * bytes query = None
  2176. */
  2177. __Pyx_INCREF(Py_None);
  2178. __pyx_v_port = Py_None;
  2179. /* "httptools/parser/url_parser.pyx":52
  2180. * bytes host = None
  2181. * object port = None
  2182. * bytes path = None # <<<<<<<<<<<<<<
  2183. * bytes query = None
  2184. * bytes fragment = None
  2185. */
  2186. __Pyx_INCREF(Py_None);
  2187. __pyx_v_path = ((PyObject*)Py_None);
  2188. /* "httptools/parser/url_parser.pyx":53
  2189. * object port = None
  2190. * bytes path = None
  2191. * bytes query = None # <<<<<<<<<<<<<<
  2192. * bytes fragment = None
  2193. * bytes userinfo = None
  2194. */
  2195. __Pyx_INCREF(Py_None);
  2196. __pyx_v_query = ((PyObject*)Py_None);
  2197. /* "httptools/parser/url_parser.pyx":54
  2198. * bytes path = None
  2199. * bytes query = None
  2200. * bytes fragment = None # <<<<<<<<<<<<<<
  2201. * bytes userinfo = None
  2202. * object result = None
  2203. */
  2204. __Pyx_INCREF(Py_None);
  2205. __pyx_v_fragment = ((PyObject*)Py_None);
  2206. /* "httptools/parser/url_parser.pyx":55
  2207. * bytes query = None
  2208. * bytes fragment = None
  2209. * bytes userinfo = None # <<<<<<<<<<<<<<
  2210. * object result = None
  2211. * int off
  2212. */
  2213. __Pyx_INCREF(Py_None);
  2214. __pyx_v_userinfo = ((PyObject*)Py_None);
  2215. /* "httptools/parser/url_parser.pyx":56
  2216. * bytes fragment = None
  2217. * bytes userinfo = None
  2218. * object result = None # <<<<<<<<<<<<<<
  2219. * int off
  2220. * int ln
  2221. */
  2222. __Pyx_INCREF(Py_None);
  2223. __pyx_v_result = Py_None;
  2224. /* "httptools/parser/url_parser.pyx":60
  2225. * int ln
  2226. *
  2227. * parsed = <uparser.http_parser_url*> \ # <<<<<<<<<<<<<<
  2228. * PyMem_Malloc(sizeof(uparser.http_parser_url))
  2229. * uparser.http_parser_url_init(parsed)
  2230. */
  2231. __pyx_v_parsed = ((struct http_parser_url *)PyMem_Malloc((sizeof(struct http_parser_url))));
  2232. /* "httptools/parser/url_parser.pyx":62
  2233. * parsed = <uparser.http_parser_url*> \
  2234. * PyMem_Malloc(sizeof(uparser.http_parser_url))
  2235. * uparser.http_parser_url_init(parsed) # <<<<<<<<<<<<<<
  2236. *
  2237. * PyObject_GetBuffer(url, &py_buf, PyBUF_SIMPLE)
  2238. */
  2239. http_parser_url_init(__pyx_v_parsed);
  2240. /* "httptools/parser/url_parser.pyx":64
  2241. * uparser.http_parser_url_init(parsed)
  2242. *
  2243. * PyObject_GetBuffer(url, &py_buf, PyBUF_SIMPLE) # <<<<<<<<<<<<<<
  2244. * try:
  2245. * buf_data = <char*>py_buf.buf
  2246. */
  2247. __pyx_t_1 = PyObject_GetBuffer(__pyx_v_url, (&__pyx_v_py_buf), PyBUF_SIMPLE); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(1, 64, __pyx_L1_error)
  2248. /* "httptools/parser/url_parser.pyx":65
  2249. *
  2250. * PyObject_GetBuffer(url, &py_buf, PyBUF_SIMPLE)
  2251. * try: # <<<<<<<<<<<<<<
  2252. * buf_data = <char*>py_buf.buf
  2253. * res = uparser.http_parser_parse_url(buf_data, py_buf.len, 0, parsed)
  2254. */
  2255. /*try:*/ {
  2256. /* "httptools/parser/url_parser.pyx":66
  2257. * PyObject_GetBuffer(url, &py_buf, PyBUF_SIMPLE)
  2258. * try:
  2259. * buf_data = <char*>py_buf.buf # <<<<<<<<<<<<<<
  2260. * res = uparser.http_parser_parse_url(buf_data, py_buf.len, 0, parsed)
  2261. *
  2262. */
  2263. __pyx_v_buf_data = ((char *)__pyx_v_py_buf.buf);
  2264. /* "httptools/parser/url_parser.pyx":67
  2265. * try:
  2266. * buf_data = <char*>py_buf.buf
  2267. * res = uparser.http_parser_parse_url(buf_data, py_buf.len, 0, parsed) # <<<<<<<<<<<<<<
  2268. *
  2269. * if res == 0:
  2270. */
  2271. __pyx_v_res = http_parser_parse_url(__pyx_v_buf_data, __pyx_v_py_buf.len, 0, __pyx_v_parsed);
  2272. /* "httptools/parser/url_parser.pyx":69
  2273. * res = uparser.http_parser_parse_url(buf_data, py_buf.len, 0, parsed)
  2274. *
  2275. * if res == 0: # <<<<<<<<<<<<<<
  2276. * if parsed.field_set & (1 << uparser.UF_SCHEMA):
  2277. * off = parsed.field_data[<int>uparser.UF_SCHEMA].off
  2278. */
  2279. __pyx_t_2 = ((__pyx_v_res == 0) != 0);
  2280. if (likely(__pyx_t_2)) {
  2281. /* "httptools/parser/url_parser.pyx":70
  2282. *
  2283. * if res == 0:
  2284. * if parsed.field_set & (1 << uparser.UF_SCHEMA): # <<<<<<<<<<<<<<
  2285. * off = parsed.field_data[<int>uparser.UF_SCHEMA].off
  2286. * ln = parsed.field_data[<int>uparser.UF_SCHEMA].len
  2287. */
  2288. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_SCHEMA)) != 0);
  2289. if (__pyx_t_2) {
  2290. /* "httptools/parser/url_parser.pyx":71
  2291. * if res == 0:
  2292. * if parsed.field_set & (1 << uparser.UF_SCHEMA):
  2293. * off = parsed.field_data[<int>uparser.UF_SCHEMA].off # <<<<<<<<<<<<<<
  2294. * ln = parsed.field_data[<int>uparser.UF_SCHEMA].len
  2295. * schema = buf_data[off:off+ln]
  2296. */
  2297. __pyx_t_3 = (__pyx_v_parsed->field_data[((int)UF_SCHEMA)]).off;
  2298. __pyx_v_off = __pyx_t_3;
  2299. /* "httptools/parser/url_parser.pyx":72
  2300. * if parsed.field_set & (1 << uparser.UF_SCHEMA):
  2301. * off = parsed.field_data[<int>uparser.UF_SCHEMA].off
  2302. * ln = parsed.field_data[<int>uparser.UF_SCHEMA].len # <<<<<<<<<<<<<<
  2303. * schema = buf_data[off:off+ln]
  2304. *
  2305. */
  2306. __pyx_t_3 = (__pyx_v_parsed->field_data[((int)UF_SCHEMA)]).len;
  2307. __pyx_v_ln = __pyx_t_3;
  2308. /* "httptools/parser/url_parser.pyx":73
  2309. * off = parsed.field_data[<int>uparser.UF_SCHEMA].off
  2310. * ln = parsed.field_data[<int>uparser.UF_SCHEMA].len
  2311. * schema = buf_data[off:off+ln] # <<<<<<<<<<<<<<
  2312. *
  2313. * if parsed.field_set & (1 << uparser.UF_HOST):
  2314. */
  2315. __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_buf_data + __pyx_v_off, (__pyx_v_off + __pyx_v_ln) - __pyx_v_off); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 73, __pyx_L4_error)
  2316. __Pyx_GOTREF(__pyx_t_4);
  2317. __Pyx_DECREF_SET(__pyx_v_schema, ((PyObject*)__pyx_t_4));
  2318. __pyx_t_4 = 0;
  2319. /* "httptools/parser/url_parser.pyx":70
  2320. *
  2321. * if res == 0:
  2322. * if parsed.field_set & (1 << uparser.UF_SCHEMA): # <<<<<<<<<<<<<<
  2323. * off = parsed.field_data[<int>uparser.UF_SCHEMA].off
  2324. * ln = parsed.field_data[<int>uparser.UF_SCHEMA].len
  2325. */
  2326. }
  2327. /* "httptools/parser/url_parser.pyx":75
  2328. * schema = buf_data[off:off+ln]
  2329. *
  2330. * if parsed.field_set & (1 << uparser.UF_HOST): # <<<<<<<<<<<<<<
  2331. * off = parsed.field_data[<int>uparser.UF_HOST].off
  2332. * ln = parsed.field_data[<int>uparser.UF_HOST].len
  2333. */
  2334. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_HOST)) != 0);
  2335. if (__pyx_t_2) {
  2336. /* "httptools/parser/url_parser.pyx":76
  2337. *
  2338. * if parsed.field_set & (1 << uparser.UF_HOST):
  2339. * off = parsed.field_data[<int>uparser.UF_HOST].off # <<<<<<<<<<<<<<
  2340. * ln = parsed.field_data[<int>uparser.UF_HOST].len
  2341. * host = buf_data[off:off+ln]
  2342. */
  2343. __pyx_t_3 = (__pyx_v_parsed->field_data[((int)UF_HOST)]).off;
  2344. __pyx_v_off = __pyx_t_3;
  2345. /* "httptools/parser/url_parser.pyx":77
  2346. * if parsed.field_set & (1 << uparser.UF_HOST):
  2347. * off = parsed.field_data[<int>uparser.UF_HOST].off
  2348. * ln = parsed.field_data[<int>uparser.UF_HOST].len # <<<<<<<<<<<<<<
  2349. * host = buf_data[off:off+ln]
  2350. *
  2351. */
  2352. __pyx_t_3 = (__pyx_v_parsed->field_data[((int)UF_HOST)]).len;
  2353. __pyx_v_ln = __pyx_t_3;
  2354. /* "httptools/parser/url_parser.pyx":78
  2355. * off = parsed.field_data[<int>uparser.UF_HOST].off
  2356. * ln = parsed.field_data[<int>uparser.UF_HOST].len
  2357. * host = buf_data[off:off+ln] # <<<<<<<<<<<<<<
  2358. *
  2359. * if parsed.field_set & (1 << uparser.UF_PORT):
  2360. */
  2361. __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_buf_data + __pyx_v_off, (__pyx_v_off + __pyx_v_ln) - __pyx_v_off); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 78, __pyx_L4_error)
  2362. __Pyx_GOTREF(__pyx_t_4);
  2363. __Pyx_DECREF_SET(__pyx_v_host, ((PyObject*)__pyx_t_4));
  2364. __pyx_t_4 = 0;
  2365. /* "httptools/parser/url_parser.pyx":75
  2366. * schema = buf_data[off:off+ln]
  2367. *
  2368. * if parsed.field_set & (1 << uparser.UF_HOST): # <<<<<<<<<<<<<<
  2369. * off = parsed.field_data[<int>uparser.UF_HOST].off
  2370. * ln = parsed.field_data[<int>uparser.UF_HOST].len
  2371. */
  2372. }
  2373. /* "httptools/parser/url_parser.pyx":80
  2374. * host = buf_data[off:off+ln]
  2375. *
  2376. * if parsed.field_set & (1 << uparser.UF_PORT): # <<<<<<<<<<<<<<
  2377. * port = parsed.port
  2378. *
  2379. */
  2380. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_PORT)) != 0);
  2381. if (__pyx_t_2) {
  2382. /* "httptools/parser/url_parser.pyx":81
  2383. *
  2384. * if parsed.field_set & (1 << uparser.UF_PORT):
  2385. * port = parsed.port # <<<<<<<<<<<<<<
  2386. *
  2387. * if parsed.field_set & (1 << uparser.UF_PATH):
  2388. */
  2389. __pyx_t_4 = __Pyx_PyInt_From_uint16_t(__pyx_v_parsed->port); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 81, __pyx_L4_error)
  2390. __Pyx_GOTREF(__pyx_t_4);
  2391. __Pyx_DECREF_SET(__pyx_v_port, __pyx_t_4);
  2392. __pyx_t_4 = 0;
  2393. /* "httptools/parser/url_parser.pyx":80
  2394. * host = buf_data[off:off+ln]
  2395. *
  2396. * if parsed.field_set & (1 << uparser.UF_PORT): # <<<<<<<<<<<<<<
  2397. * port = parsed.port
  2398. *
  2399. */
  2400. }
  2401. /* "httptools/parser/url_parser.pyx":83
  2402. * port = parsed.port
  2403. *
  2404. * if parsed.field_set & (1 << uparser.UF_PATH): # <<<<<<<<<<<<<<
  2405. * off = parsed.field_data[<int>uparser.UF_PATH].off
  2406. * ln = parsed.field_data[<int>uparser.UF_PATH].len
  2407. */
  2408. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_PATH)) != 0);
  2409. if (__pyx_t_2) {
  2410. /* "httptools/parser/url_parser.pyx":84
  2411. *
  2412. * if parsed.field_set & (1 << uparser.UF_PATH):
  2413. * off = parsed.field_data[<int>uparser.UF_PATH].off # <<<<<<<<<<<<<<
  2414. * ln = parsed.field_data[<int>uparser.UF_PATH].len
  2415. * path = buf_data[off:off+ln]
  2416. */
  2417. __pyx_t_3 = (__pyx_v_parsed->field_data[((int)UF_PATH)]).off;
  2418. __pyx_v_off = __pyx_t_3;
  2419. /* "httptools/parser/url_parser.pyx":85
  2420. * if parsed.field_set & (1 << uparser.UF_PATH):
  2421. * off = parsed.field_data[<int>uparser.UF_PATH].off
  2422. * ln = parsed.field_data[<int>uparser.UF_PATH].len # <<<<<<<<<<<<<<
  2423. * path = buf_data[off:off+ln]
  2424. *
  2425. */
  2426. __pyx_t_3 = (__pyx_v_parsed->field_data[((int)UF_PATH)]).len;
  2427. __pyx_v_ln = __pyx_t_3;
  2428. /* "httptools/parser/url_parser.pyx":86
  2429. * off = parsed.field_data[<int>uparser.UF_PATH].off
  2430. * ln = parsed.field_data[<int>uparser.UF_PATH].len
  2431. * path = buf_data[off:off+ln] # <<<<<<<<<<<<<<
  2432. *
  2433. * if parsed.field_set & (1 << uparser.UF_QUERY):
  2434. */
  2435. __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_buf_data + __pyx_v_off, (__pyx_v_off + __pyx_v_ln) - __pyx_v_off); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 86, __pyx_L4_error)
  2436. __Pyx_GOTREF(__pyx_t_4);
  2437. __Pyx_DECREF_SET(__pyx_v_path, ((PyObject*)__pyx_t_4));
  2438. __pyx_t_4 = 0;
  2439. /* "httptools/parser/url_parser.pyx":83
  2440. * port = parsed.port
  2441. *
  2442. * if parsed.field_set & (1 << uparser.UF_PATH): # <<<<<<<<<<<<<<
  2443. * off = parsed.field_data[<int>uparser.UF_PATH].off
  2444. * ln = parsed.field_data[<int>uparser.UF_PATH].len
  2445. */
  2446. }
  2447. /* "httptools/parser/url_parser.pyx":88
  2448. * path = buf_data[off:off+ln]
  2449. *
  2450. * if parsed.field_set & (1 << uparser.UF_QUERY): # <<<<<<<<<<<<<<
  2451. * off = parsed.field_data[<int>uparser.UF_QUERY].off
  2452. * ln = parsed.field_data[<int>uparser.UF_QUERY].len
  2453. */
  2454. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_QUERY)) != 0);
  2455. if (__pyx_t_2) {
  2456. /* "httptools/parser/url_parser.pyx":89
  2457. *
  2458. * if parsed.field_set & (1 << uparser.UF_QUERY):
  2459. * off = parsed.field_data[<int>uparser.UF_QUERY].off # <<<<<<<<<<<<<<
  2460. * ln = parsed.field_data[<int>uparser.UF_QUERY].len
  2461. * query = buf_data[off:off+ln]
  2462. */
  2463. __pyx_t_3 = (__pyx_v_parsed->field_data[((int)UF_QUERY)]).off;
  2464. __pyx_v_off = __pyx_t_3;
  2465. /* "httptools/parser/url_parser.pyx":90
  2466. * if parsed.field_set & (1 << uparser.UF_QUERY):
  2467. * off = parsed.field_data[<int>uparser.UF_QUERY].off
  2468. * ln = parsed.field_data[<int>uparser.UF_QUERY].len # <<<<<<<<<<<<<<
  2469. * query = buf_data[off:off+ln]
  2470. *
  2471. */
  2472. __pyx_t_3 = (__pyx_v_parsed->field_data[((int)UF_QUERY)]).len;
  2473. __pyx_v_ln = __pyx_t_3;
  2474. /* "httptools/parser/url_parser.pyx":91
  2475. * off = parsed.field_data[<int>uparser.UF_QUERY].off
  2476. * ln = parsed.field_data[<int>uparser.UF_QUERY].len
  2477. * query = buf_data[off:off+ln] # <<<<<<<<<<<<<<
  2478. *
  2479. * if parsed.field_set & (1 << uparser.UF_FRAGMENT):
  2480. */
  2481. __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_buf_data + __pyx_v_off, (__pyx_v_off + __pyx_v_ln) - __pyx_v_off); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 91, __pyx_L4_error)
  2482. __Pyx_GOTREF(__pyx_t_4);
  2483. __Pyx_DECREF_SET(__pyx_v_query, ((PyObject*)__pyx_t_4));
  2484. __pyx_t_4 = 0;
  2485. /* "httptools/parser/url_parser.pyx":88
  2486. * path = buf_data[off:off+ln]
  2487. *
  2488. * if parsed.field_set & (1 << uparser.UF_QUERY): # <<<<<<<<<<<<<<
  2489. * off = parsed.field_data[<int>uparser.UF_QUERY].off
  2490. * ln = parsed.field_data[<int>uparser.UF_QUERY].len
  2491. */
  2492. }
  2493. /* "httptools/parser/url_parser.pyx":93
  2494. * query = buf_data[off:off+ln]
  2495. *
  2496. * if parsed.field_set & (1 << uparser.UF_FRAGMENT): # <<<<<<<<<<<<<<
  2497. * off = parsed.field_data[<int>uparser.UF_FRAGMENT].off
  2498. * ln = parsed.field_data[<int>uparser.UF_FRAGMENT].len
  2499. */
  2500. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_FRAGMENT)) != 0);
  2501. if (__pyx_t_2) {
  2502. /* "httptools/parser/url_parser.pyx":94
  2503. *
  2504. * if parsed.field_set & (1 << uparser.UF_FRAGMENT):
  2505. * off = parsed.field_data[<int>uparser.UF_FRAGMENT].off # <<<<<<<<<<<<<<
  2506. * ln = parsed.field_data[<int>uparser.UF_FRAGMENT].len
  2507. * fragment = buf_data[off:off+ln]
  2508. */
  2509. __pyx_t_3 = (__pyx_v_parsed->field_data[((int)UF_FRAGMENT)]).off;
  2510. __pyx_v_off = __pyx_t_3;
  2511. /* "httptools/parser/url_parser.pyx":95
  2512. * if parsed.field_set & (1 << uparser.UF_FRAGMENT):
  2513. * off = parsed.field_data[<int>uparser.UF_FRAGMENT].off
  2514. * ln = parsed.field_data[<int>uparser.UF_FRAGMENT].len # <<<<<<<<<<<<<<
  2515. * fragment = buf_data[off:off+ln]
  2516. *
  2517. */
  2518. __pyx_t_3 = (__pyx_v_parsed->field_data[((int)UF_FRAGMENT)]).len;
  2519. __pyx_v_ln = __pyx_t_3;
  2520. /* "httptools/parser/url_parser.pyx":96
  2521. * off = parsed.field_data[<int>uparser.UF_FRAGMENT].off
  2522. * ln = parsed.field_data[<int>uparser.UF_FRAGMENT].len
  2523. * fragment = buf_data[off:off+ln] # <<<<<<<<<<<<<<
  2524. *
  2525. * if parsed.field_set & (1 << uparser.UF_USERINFO):
  2526. */
  2527. __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_buf_data + __pyx_v_off, (__pyx_v_off + __pyx_v_ln) - __pyx_v_off); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 96, __pyx_L4_error)
  2528. __Pyx_GOTREF(__pyx_t_4);
  2529. __Pyx_DECREF_SET(__pyx_v_fragment, ((PyObject*)__pyx_t_4));
  2530. __pyx_t_4 = 0;
  2531. /* "httptools/parser/url_parser.pyx":93
  2532. * query = buf_data[off:off+ln]
  2533. *
  2534. * if parsed.field_set & (1 << uparser.UF_FRAGMENT): # <<<<<<<<<<<<<<
  2535. * off = parsed.field_data[<int>uparser.UF_FRAGMENT].off
  2536. * ln = parsed.field_data[<int>uparser.UF_FRAGMENT].len
  2537. */
  2538. }
  2539. /* "httptools/parser/url_parser.pyx":98
  2540. * fragment = buf_data[off:off+ln]
  2541. *
  2542. * if parsed.field_set & (1 << uparser.UF_USERINFO): # <<<<<<<<<<<<<<
  2543. * off = parsed.field_data[<int>uparser.UF_USERINFO].off
  2544. * ln = parsed.field_data[<int>uparser.UF_USERINFO].len
  2545. */
  2546. __pyx_t_2 = ((__pyx_v_parsed->field_set & (1 << UF_USERINFO)) != 0);
  2547. if (__pyx_t_2) {
  2548. /* "httptools/parser/url_parser.pyx":99
  2549. *
  2550. * if parsed.field_set & (1 << uparser.UF_USERINFO):
  2551. * off = parsed.field_data[<int>uparser.UF_USERINFO].off # <<<<<<<<<<<<<<
  2552. * ln = parsed.field_data[<int>uparser.UF_USERINFO].len
  2553. * userinfo = buf_data[off:off+ln]
  2554. */
  2555. __pyx_t_3 = (__pyx_v_parsed->field_data[((int)UF_USERINFO)]).off;
  2556. __pyx_v_off = __pyx_t_3;
  2557. /* "httptools/parser/url_parser.pyx":100
  2558. * if parsed.field_set & (1 << uparser.UF_USERINFO):
  2559. * off = parsed.field_data[<int>uparser.UF_USERINFO].off
  2560. * ln = parsed.field_data[<int>uparser.UF_USERINFO].len # <<<<<<<<<<<<<<
  2561. * userinfo = buf_data[off:off+ln]
  2562. *
  2563. */
  2564. __pyx_t_3 = (__pyx_v_parsed->field_data[((int)UF_USERINFO)]).len;
  2565. __pyx_v_ln = __pyx_t_3;
  2566. /* "httptools/parser/url_parser.pyx":101
  2567. * off = parsed.field_data[<int>uparser.UF_USERINFO].off
  2568. * ln = parsed.field_data[<int>uparser.UF_USERINFO].len
  2569. * userinfo = buf_data[off:off+ln] # <<<<<<<<<<<<<<
  2570. *
  2571. * return URL(schema, host, port, path, query, fragment, userinfo)
  2572. */
  2573. __pyx_t_4 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_buf_data + __pyx_v_off, (__pyx_v_off + __pyx_v_ln) - __pyx_v_off); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 101, __pyx_L4_error)
  2574. __Pyx_GOTREF(__pyx_t_4);
  2575. __Pyx_DECREF_SET(__pyx_v_userinfo, ((PyObject*)__pyx_t_4));
  2576. __pyx_t_4 = 0;
  2577. /* "httptools/parser/url_parser.pyx":98
  2578. * fragment = buf_data[off:off+ln]
  2579. *
  2580. * if parsed.field_set & (1 << uparser.UF_USERINFO): # <<<<<<<<<<<<<<
  2581. * off = parsed.field_data[<int>uparser.UF_USERINFO].off
  2582. * ln = parsed.field_data[<int>uparser.UF_USERINFO].len
  2583. */
  2584. }
  2585. /* "httptools/parser/url_parser.pyx":103
  2586. * userinfo = buf_data[off:off+ln]
  2587. *
  2588. * return URL(schema, host, port, path, query, fragment, userinfo) # <<<<<<<<<<<<<<
  2589. * else:
  2590. * raise HttpParserInvalidURLError("invalid url {!r}".format(url))
  2591. */
  2592. __Pyx_XDECREF(__pyx_r);
  2593. __pyx_t_4 = PyTuple_New(7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 103, __pyx_L4_error)
  2594. __Pyx_GOTREF(__pyx_t_4);
  2595. __Pyx_INCREF(__pyx_v_schema);
  2596. __Pyx_GIVEREF(__pyx_v_schema);
  2597. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_schema);
  2598. __Pyx_INCREF(__pyx_v_host);
  2599. __Pyx_GIVEREF(__pyx_v_host);
  2600. PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_host);
  2601. __Pyx_INCREF(__pyx_v_port);
  2602. __Pyx_GIVEREF(__pyx_v_port);
  2603. PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_port);
  2604. __Pyx_INCREF(__pyx_v_path);
  2605. __Pyx_GIVEREF(__pyx_v_path);
  2606. PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_path);
  2607. __Pyx_INCREF(__pyx_v_query);
  2608. __Pyx_GIVEREF(__pyx_v_query);
  2609. PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_v_query);
  2610. __Pyx_INCREF(__pyx_v_fragment);
  2611. __Pyx_GIVEREF(__pyx_v_fragment);
  2612. PyTuple_SET_ITEM(__pyx_t_4, 5, __pyx_v_fragment);
  2613. __Pyx_INCREF(__pyx_v_userinfo);
  2614. __Pyx_GIVEREF(__pyx_v_userinfo);
  2615. PyTuple_SET_ITEM(__pyx_t_4, 6, __pyx_v_userinfo);
  2616. __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_9httptools_6parser_10url_parser_URL), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 103, __pyx_L4_error)
  2617. __Pyx_GOTREF(__pyx_t_5);
  2618. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2619. __pyx_r = __pyx_t_5;
  2620. __pyx_t_5 = 0;
  2621. goto __pyx_L3_return;
  2622. /* "httptools/parser/url_parser.pyx":69
  2623. * res = uparser.http_parser_parse_url(buf_data, py_buf.len, 0, parsed)
  2624. *
  2625. * if res == 0: # <<<<<<<<<<<<<<
  2626. * if parsed.field_set & (1 << uparser.UF_SCHEMA):
  2627. * off = parsed.field_data[<int>uparser.UF_SCHEMA].off
  2628. */
  2629. }
  2630. /* "httptools/parser/url_parser.pyx":105
  2631. * return URL(schema, host, port, path, query, fragment, userinfo)
  2632. * else:
  2633. * raise HttpParserInvalidURLError("invalid url {!r}".format(url)) # <<<<<<<<<<<<<<
  2634. * finally:
  2635. * PyBuffer_Release(&py_buf)
  2636. */
  2637. /*else*/ {
  2638. __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_HttpParserInvalidURLError); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 105, __pyx_L4_error)
  2639. __Pyx_GOTREF(__pyx_t_4);
  2640. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_invalid_url_r, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 105, __pyx_L4_error)
  2641. __Pyx_GOTREF(__pyx_t_7);
  2642. __pyx_t_8 = NULL;
  2643. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
  2644. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
  2645. if (likely(__pyx_t_8)) {
  2646. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  2647. __Pyx_INCREF(__pyx_t_8);
  2648. __Pyx_INCREF(function);
  2649. __Pyx_DECREF_SET(__pyx_t_7, function);
  2650. }
  2651. }
  2652. __pyx_t_6 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_v_url) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_url);
  2653. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2654. if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 105, __pyx_L4_error)
  2655. __Pyx_GOTREF(__pyx_t_6);
  2656. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  2657. __pyx_t_7 = NULL;
  2658. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  2659. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
  2660. if (likely(__pyx_t_7)) {
  2661. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  2662. __Pyx_INCREF(__pyx_t_7);
  2663. __Pyx_INCREF(function);
  2664. __Pyx_DECREF_SET(__pyx_t_4, function);
  2665. }
  2666. }
  2667. __pyx_t_5 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6);
  2668. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  2669. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2670. if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 105, __pyx_L4_error)
  2671. __Pyx_GOTREF(__pyx_t_5);
  2672. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2673. __Pyx_Raise(__pyx_t_5, 0, 0, 0);
  2674. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2675. __PYX_ERR(1, 105, __pyx_L4_error)
  2676. }
  2677. }
  2678. /* "httptools/parser/url_parser.pyx":107
  2679. * raise HttpParserInvalidURLError("invalid url {!r}".format(url))
  2680. * finally:
  2681. * PyBuffer_Release(&py_buf) # <<<<<<<<<<<<<<
  2682. * PyMem_Free(parsed)
  2683. */
  2684. /*finally:*/ {
  2685. __pyx_L4_error:;
  2686. /*exception exit:*/{
  2687. __Pyx_PyThreadState_declare
  2688. __Pyx_PyThreadState_assign
  2689. __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
  2690. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2691. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2692. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2693. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  2694. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  2695. if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
  2696. if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
  2697. __Pyx_XGOTREF(__pyx_t_11);
  2698. __Pyx_XGOTREF(__pyx_t_12);
  2699. __Pyx_XGOTREF(__pyx_t_13);
  2700. __Pyx_XGOTREF(__pyx_t_14);
  2701. __Pyx_XGOTREF(__pyx_t_15);
  2702. __Pyx_XGOTREF(__pyx_t_16);
  2703. __pyx_t_1 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename;
  2704. {
  2705. PyBuffer_Release((&__pyx_v_py_buf));
  2706. /* "httptools/parser/url_parser.pyx":108
  2707. * finally:
  2708. * PyBuffer_Release(&py_buf)
  2709. * PyMem_Free(parsed) # <<<<<<<<<<<<<<
  2710. */
  2711. PyMem_Free(__pyx_v_parsed);
  2712. }
  2713. if (PY_MAJOR_VERSION >= 3) {
  2714. __Pyx_XGIVEREF(__pyx_t_14);
  2715. __Pyx_XGIVEREF(__pyx_t_15);
  2716. __Pyx_XGIVEREF(__pyx_t_16);
  2717. __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
  2718. }
  2719. __Pyx_XGIVEREF(__pyx_t_11);
  2720. __Pyx_XGIVEREF(__pyx_t_12);
  2721. __Pyx_XGIVEREF(__pyx_t_13);
  2722. __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
  2723. __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
  2724. __pyx_lineno = __pyx_t_1; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10;
  2725. goto __pyx_L1_error;
  2726. }
  2727. __pyx_L3_return: {
  2728. __pyx_t_16 = __pyx_r;
  2729. __pyx_r = 0;
  2730. /* "httptools/parser/url_parser.pyx":107
  2731. * raise HttpParserInvalidURLError("invalid url {!r}".format(url))
  2732. * finally:
  2733. * PyBuffer_Release(&py_buf) # <<<<<<<<<<<<<<
  2734. * PyMem_Free(parsed)
  2735. */
  2736. PyBuffer_Release((&__pyx_v_py_buf));
  2737. /* "httptools/parser/url_parser.pyx":108
  2738. * finally:
  2739. * PyBuffer_Release(&py_buf)
  2740. * PyMem_Free(parsed) # <<<<<<<<<<<<<<
  2741. */
  2742. PyMem_Free(__pyx_v_parsed);
  2743. __pyx_r = __pyx_t_16;
  2744. __pyx_t_16 = 0;
  2745. goto __pyx_L0;
  2746. }
  2747. }
  2748. /* "httptools/parser/url_parser.pyx":43
  2749. *
  2750. *
  2751. * def parse_url(url): # <<<<<<<<<<<<<<
  2752. * cdef:
  2753. * Py_buffer py_buf
  2754. */
  2755. /* function exit code */
  2756. __pyx_L1_error:;
  2757. __Pyx_XDECREF(__pyx_t_4);
  2758. __Pyx_XDECREF(__pyx_t_5);
  2759. __Pyx_XDECREF(__pyx_t_6);
  2760. __Pyx_XDECREF(__pyx_t_7);
  2761. __Pyx_XDECREF(__pyx_t_8);
  2762. __Pyx_AddTraceback("httptools.parser.url_parser.parse_url", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2763. __pyx_r = NULL;
  2764. __pyx_L0:;
  2765. __Pyx_XDECREF(__pyx_v_schema);
  2766. __Pyx_XDECREF(__pyx_v_host);
  2767. __Pyx_XDECREF(__pyx_v_port);
  2768. __Pyx_XDECREF(__pyx_v_path);
  2769. __Pyx_XDECREF(__pyx_v_query);
  2770. __Pyx_XDECREF(__pyx_v_fragment);
  2771. __Pyx_XDECREF(__pyx_v_userinfo);
  2772. __Pyx_XDECREF(__pyx_v_result);
  2773. __Pyx_XGIVEREF(__pyx_r);
  2774. __Pyx_RefNannyFinishContext();
  2775. return __pyx_r;
  2776. }
  2777. static struct __pyx_obj_9httptools_6parser_10url_parser_URL *__pyx_freelist_9httptools_6parser_10url_parser_URL[250];
  2778. static int __pyx_freecount_9httptools_6parser_10url_parser_URL = 0;
  2779. static PyObject *__pyx_tp_new_9httptools_6parser_10url_parser_URL(PyTypeObject *t, PyObject *a, PyObject *k) {
  2780. struct __pyx_obj_9httptools_6parser_10url_parser_URL *p;
  2781. PyObject *o;
  2782. if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9httptools_6parser_10url_parser_URL > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9httptools_6parser_10url_parser_URL)) & ((t->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)) == 0))) {
  2783. o = (PyObject*)__pyx_freelist_9httptools_6parser_10url_parser_URL[--__pyx_freecount_9httptools_6parser_10url_parser_URL];
  2784. memset(o, 0, sizeof(struct __pyx_obj_9httptools_6parser_10url_parser_URL));
  2785. (void) PyObject_INIT(o, t);
  2786. PyObject_GC_Track(o);
  2787. } else {
  2788. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  2789. o = (*t->tp_alloc)(t, 0);
  2790. } else {
  2791. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  2792. }
  2793. if (unlikely(!o)) return 0;
  2794. }
  2795. p = ((struct __pyx_obj_9httptools_6parser_10url_parser_URL *)o);
  2796. p->schema = ((PyObject*)Py_None); Py_INCREF(Py_None);
  2797. p->host = ((PyObject*)Py_None); Py_INCREF(Py_None);
  2798. p->port = Py_None; Py_INCREF(Py_None);
  2799. p->path = ((PyObject*)Py_None); Py_INCREF(Py_None);
  2800. p->query = ((PyObject*)Py_None); Py_INCREF(Py_None);
  2801. p->fragment = ((PyObject*)Py_None); Py_INCREF(Py_None);
  2802. p->userinfo = ((PyObject*)Py_None); Py_INCREF(Py_None);
  2803. if (unlikely(__pyx_pw_9httptools_6parser_10url_parser_3URL_1__cinit__(o, a, k) < 0)) goto bad;
  2804. return o;
  2805. bad:
  2806. Py_DECREF(o); o = 0;
  2807. return NULL;
  2808. }
  2809. static void __pyx_tp_dealloc_9httptools_6parser_10url_parser_URL(PyObject *o) {
  2810. struct __pyx_obj_9httptools_6parser_10url_parser_URL *p = (struct __pyx_obj_9httptools_6parser_10url_parser_URL *)o;
  2811. #if CYTHON_USE_TP_FINALIZE
  2812. if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
  2813. if (PyObject_CallFinalizerFromDealloc(o)) return;
  2814. }
  2815. #endif
  2816. PyObject_GC_UnTrack(o);
  2817. Py_CLEAR(p->schema);
  2818. Py_CLEAR(p->host);
  2819. Py_CLEAR(p->port);
  2820. Py_CLEAR(p->path);
  2821. Py_CLEAR(p->query);
  2822. Py_CLEAR(p->fragment);
  2823. Py_CLEAR(p->userinfo);
  2824. if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9httptools_6parser_10url_parser_URL < 250) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9httptools_6parser_10url_parser_URL)) & ((Py_TYPE(o)->tp_flags & (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)) == 0))) {
  2825. __pyx_freelist_9httptools_6parser_10url_parser_URL[__pyx_freecount_9httptools_6parser_10url_parser_URL++] = ((struct __pyx_obj_9httptools_6parser_10url_parser_URL *)o);
  2826. } else {
  2827. (*Py_TYPE(o)->tp_free)(o);
  2828. }
  2829. }
  2830. static int __pyx_tp_traverse_9httptools_6parser_10url_parser_URL(PyObject *o, visitproc v, void *a) {
  2831. int e;
  2832. struct __pyx_obj_9httptools_6parser_10url_parser_URL *p = (struct __pyx_obj_9httptools_6parser_10url_parser_URL *)o;
  2833. if (p->port) {
  2834. e = (*v)(p->port, a); if (e) return e;
  2835. }
  2836. return 0;
  2837. }
  2838. static int __pyx_tp_clear_9httptools_6parser_10url_parser_URL(PyObject *o) {
  2839. PyObject* tmp;
  2840. struct __pyx_obj_9httptools_6parser_10url_parser_URL *p = (struct __pyx_obj_9httptools_6parser_10url_parser_URL *)o;
  2841. tmp = ((PyObject*)p->port);
  2842. p->port = Py_None; Py_INCREF(Py_None);
  2843. Py_XDECREF(tmp);
  2844. return 0;
  2845. }
  2846. static PyObject *__pyx_getprop_9httptools_6parser_10url_parser_3URL_schema(PyObject *o, CYTHON_UNUSED void *x) {
  2847. return __pyx_pw_9httptools_6parser_10url_parser_3URL_6schema_1__get__(o);
  2848. }
  2849. static PyObject *__pyx_getprop_9httptools_6parser_10url_parser_3URL_host(PyObject *o, CYTHON_UNUSED void *x) {
  2850. return __pyx_pw_9httptools_6parser_10url_parser_3URL_4host_1__get__(o);
  2851. }
  2852. static PyObject *__pyx_getprop_9httptools_6parser_10url_parser_3URL_port(PyObject *o, CYTHON_UNUSED void *x) {
  2853. return __pyx_pw_9httptools_6parser_10url_parser_3URL_4port_1__get__(o);
  2854. }
  2855. static PyObject *__pyx_getprop_9httptools_6parser_10url_parser_3URL_path(PyObject *o, CYTHON_UNUSED void *x) {
  2856. return __pyx_pw_9httptools_6parser_10url_parser_3URL_4path_1__get__(o);
  2857. }
  2858. static PyObject *__pyx_getprop_9httptools_6parser_10url_parser_3URL_query(PyObject *o, CYTHON_UNUSED void *x) {
  2859. return __pyx_pw_9httptools_6parser_10url_parser_3URL_5query_1__get__(o);
  2860. }
  2861. static PyObject *__pyx_getprop_9httptools_6parser_10url_parser_3URL_fragment(PyObject *o, CYTHON_UNUSED void *x) {
  2862. return __pyx_pw_9httptools_6parser_10url_parser_3URL_8fragment_1__get__(o);
  2863. }
  2864. static PyObject *__pyx_getprop_9httptools_6parser_10url_parser_3URL_userinfo(PyObject *o, CYTHON_UNUSED void *x) {
  2865. return __pyx_pw_9httptools_6parser_10url_parser_3URL_8userinfo_1__get__(o);
  2866. }
  2867. static PyMethodDef __pyx_methods_9httptools_6parser_10url_parser_URL[] = {
  2868. {"__reduce_cython__", (PyCFunction)__pyx_pw_9httptools_6parser_10url_parser_3URL_5__reduce_cython__, METH_NOARGS, 0},
  2869. {"__setstate_cython__", (PyCFunction)__pyx_pw_9httptools_6parser_10url_parser_3URL_7__setstate_cython__, METH_O, 0},
  2870. {0, 0, 0, 0}
  2871. };
  2872. static struct PyGetSetDef __pyx_getsets_9httptools_6parser_10url_parser_URL[] = {
  2873. {(char *)"schema", __pyx_getprop_9httptools_6parser_10url_parser_3URL_schema, 0, (char *)0, 0},
  2874. {(char *)"host", __pyx_getprop_9httptools_6parser_10url_parser_3URL_host, 0, (char *)0, 0},
  2875. {(char *)"port", __pyx_getprop_9httptools_6parser_10url_parser_3URL_port, 0, (char *)0, 0},
  2876. {(char *)"path", __pyx_getprop_9httptools_6parser_10url_parser_3URL_path, 0, (char *)0, 0},
  2877. {(char *)"query", __pyx_getprop_9httptools_6parser_10url_parser_3URL_query, 0, (char *)0, 0},
  2878. {(char *)"fragment", __pyx_getprop_9httptools_6parser_10url_parser_3URL_fragment, 0, (char *)0, 0},
  2879. {(char *)"userinfo", __pyx_getprop_9httptools_6parser_10url_parser_3URL_userinfo, 0, (char *)0, 0},
  2880. {0, 0, 0, 0, 0}
  2881. };
  2882. static PyTypeObject __pyx_type_9httptools_6parser_10url_parser_URL = {
  2883. PyVarObject_HEAD_INIT(0, 0)
  2884. "httptools.parser.url_parser.URL", /*tp_name*/
  2885. sizeof(struct __pyx_obj_9httptools_6parser_10url_parser_URL), /*tp_basicsize*/
  2886. 0, /*tp_itemsize*/
  2887. __pyx_tp_dealloc_9httptools_6parser_10url_parser_URL, /*tp_dealloc*/
  2888. #if PY_VERSION_HEX < 0x030800b4
  2889. 0, /*tp_print*/
  2890. #endif
  2891. #if PY_VERSION_HEX >= 0x030800b4
  2892. 0, /*tp_vectorcall_offset*/
  2893. #endif
  2894. 0, /*tp_getattr*/
  2895. 0, /*tp_setattr*/
  2896. #if PY_MAJOR_VERSION < 3
  2897. 0, /*tp_compare*/
  2898. #endif
  2899. #if PY_MAJOR_VERSION >= 3
  2900. 0, /*tp_as_async*/
  2901. #endif
  2902. __pyx_pw_9httptools_6parser_10url_parser_3URL_3__repr__, /*tp_repr*/
  2903. 0, /*tp_as_number*/
  2904. 0, /*tp_as_sequence*/
  2905. 0, /*tp_as_mapping*/
  2906. 0, /*tp_hash*/
  2907. 0, /*tp_call*/
  2908. 0, /*tp_str*/
  2909. 0, /*tp_getattro*/
  2910. 0, /*tp_setattro*/
  2911. 0, /*tp_as_buffer*/
  2912. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  2913. 0, /*tp_doc*/
  2914. __pyx_tp_traverse_9httptools_6parser_10url_parser_URL, /*tp_traverse*/
  2915. __pyx_tp_clear_9httptools_6parser_10url_parser_URL, /*tp_clear*/
  2916. 0, /*tp_richcompare*/
  2917. 0, /*tp_weaklistoffset*/
  2918. 0, /*tp_iter*/
  2919. 0, /*tp_iternext*/
  2920. __pyx_methods_9httptools_6parser_10url_parser_URL, /*tp_methods*/
  2921. 0, /*tp_members*/
  2922. __pyx_getsets_9httptools_6parser_10url_parser_URL, /*tp_getset*/
  2923. 0, /*tp_base*/
  2924. 0, /*tp_dict*/
  2925. 0, /*tp_descr_get*/
  2926. 0, /*tp_descr_set*/
  2927. 0, /*tp_dictoffset*/
  2928. 0, /*tp_init*/
  2929. 0, /*tp_alloc*/
  2930. __pyx_tp_new_9httptools_6parser_10url_parser_URL, /*tp_new*/
  2931. 0, /*tp_free*/
  2932. 0, /*tp_is_gc*/
  2933. 0, /*tp_bases*/
  2934. 0, /*tp_mro*/
  2935. 0, /*tp_cache*/
  2936. 0, /*tp_subclasses*/
  2937. 0, /*tp_weaklist*/
  2938. 0, /*tp_del*/
  2939. 0, /*tp_version_tag*/
  2940. #if PY_VERSION_HEX >= 0x030400a1
  2941. 0, /*tp_finalize*/
  2942. #endif
  2943. #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  2944. 0, /*tp_vectorcall*/
  2945. #endif
  2946. #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  2947. 0, /*tp_print*/
  2948. #endif
  2949. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  2950. 0, /*tp_pypy_flags*/
  2951. #endif
  2952. };
  2953. static PyMethodDef __pyx_methods[] = {
  2954. {0, 0, 0, 0}
  2955. };
  2956. #if PY_MAJOR_VERSION >= 3
  2957. #if CYTHON_PEP489_MULTI_PHASE_INIT
  2958. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  2959. static int __pyx_pymod_exec_url_parser(PyObject* module); /*proto*/
  2960. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  2961. {Py_mod_create, (void*)__pyx_pymod_create},
  2962. {Py_mod_exec, (void*)__pyx_pymod_exec_url_parser},
  2963. {0, NULL}
  2964. };
  2965. #endif
  2966. static struct PyModuleDef __pyx_moduledef = {
  2967. PyModuleDef_HEAD_INIT,
  2968. "url_parser",
  2969. 0, /* m_doc */
  2970. #if CYTHON_PEP489_MULTI_PHASE_INIT
  2971. 0, /* m_size */
  2972. #else
  2973. -1, /* m_size */
  2974. #endif
  2975. __pyx_methods /* m_methods */,
  2976. #if CYTHON_PEP489_MULTI_PHASE_INIT
  2977. __pyx_moduledef_slots, /* m_slots */
  2978. #else
  2979. NULL, /* m_reload */
  2980. #endif
  2981. NULL, /* m_traverse */
  2982. NULL, /* m_clear */
  2983. NULL /* m_free */
  2984. };
  2985. #endif
  2986. #ifndef CYTHON_SMALL_CODE
  2987. #if defined(__clang__)
  2988. #define CYTHON_SMALL_CODE
  2989. #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  2990. #define CYTHON_SMALL_CODE __attribute__((cold))
  2991. #else
  2992. #define CYTHON_SMALL_CODE
  2993. #endif
  2994. #endif
  2995. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  2996. {&__pyx_n_s_HttpParserInvalidURLError, __pyx_k_HttpParserInvalidURLError, sizeof(__pyx_k_HttpParserInvalidURLError), 0, 0, 1, 1},
  2997. {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  2998. {&__pyx_n_s_URL, __pyx_k_URL, sizeof(__pyx_k_URL), 0, 0, 1, 1},
  2999. {&__pyx_kp_u_URL_schema_r_host_r_port_r_path, __pyx_k_URL_schema_r_host_r_port_r_path, sizeof(__pyx_k_URL_schema_r_host_r_port_r_path), 0, 1, 0, 0},
  3000. {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
  3001. {&__pyx_n_s_buf_data, __pyx_k_buf_data, sizeof(__pyx_k_buf_data), 0, 0, 1, 1},
  3002. {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  3003. {&__pyx_n_s_errors, __pyx_k_errors, sizeof(__pyx_k_errors), 0, 0, 1, 1},
  3004. {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
  3005. {&__pyx_n_s_fragment, __pyx_k_fragment, sizeof(__pyx_k_fragment), 0, 0, 1, 1},
  3006. {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  3007. {&__pyx_n_s_host, __pyx_k_host, sizeof(__pyx_k_host), 0, 0, 1, 1},
  3008. {&__pyx_n_s_httptools_parser_url_parser, __pyx_k_httptools_parser_url_parser, sizeof(__pyx_k_httptools_parser_url_parser), 0, 0, 1, 1},
  3009. {&__pyx_kp_s_httptools_parser_url_parser_pyx, __pyx_k_httptools_parser_url_parser_pyx, sizeof(__pyx_k_httptools_parser_url_parser_pyx), 0, 0, 1, 0},
  3010. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  3011. {&__pyx_kp_u_invalid_url_r, __pyx_k_invalid_url_r, sizeof(__pyx_k_invalid_url_r), 0, 1, 0, 0},
  3012. {&__pyx_n_s_ln, __pyx_k_ln, sizeof(__pyx_k_ln), 0, 0, 1, 1},
  3013. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  3014. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  3015. {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
  3016. {&__pyx_n_s_off, __pyx_k_off, sizeof(__pyx_k_off), 0, 0, 1, 1},
  3017. {&__pyx_n_s_parse_url, __pyx_k_parse_url, sizeof(__pyx_k_parse_url), 0, 0, 1, 1},
  3018. {&__pyx_n_u_parse_url, __pyx_k_parse_url, sizeof(__pyx_k_parse_url), 0, 1, 0, 1},
  3019. {&__pyx_n_s_parsed, __pyx_k_parsed, sizeof(__pyx_k_parsed), 0, 0, 1, 1},
  3020. {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
  3021. {&__pyx_n_s_port, __pyx_k_port, sizeof(__pyx_k_port), 0, 0, 1, 1},
  3022. {&__pyx_n_s_py_buf, __pyx_k_py_buf, sizeof(__pyx_k_py_buf), 0, 0, 1, 1},
  3023. {&__pyx_n_s_query, __pyx_k_query, sizeof(__pyx_k_query), 0, 0, 1, 1},
  3024. {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  3025. {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  3026. {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  3027. {&__pyx_n_s_res, __pyx_k_res, sizeof(__pyx_k_res), 0, 0, 1, 1},
  3028. {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1},
  3029. {&__pyx_n_s_schema, __pyx_k_schema, sizeof(__pyx_k_schema), 0, 0, 1, 1},
  3030. {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  3031. {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  3032. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  3033. {&__pyx_n_s_url, __pyx_k_url, sizeof(__pyx_k_url), 0, 0, 1, 1},
  3034. {&__pyx_n_s_userinfo, __pyx_k_userinfo, sizeof(__pyx_k_userinfo), 0, 0, 1, 1},
  3035. {0, 0, 0, 0, 0, 0, 0}
  3036. };
  3037. static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  3038. __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 2, __pyx_L1_error)
  3039. return 0;
  3040. __pyx_L1_error:;
  3041. return -1;
  3042. }
  3043. static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  3044. __Pyx_RefNannyDeclarations
  3045. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  3046. /* "(tree fragment)":2
  3047. * def __reduce_cython__(self):
  3048. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  3049. * def __setstate_cython__(self, __pyx_state):
  3050. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3051. */
  3052. __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 2, __pyx_L1_error)
  3053. __Pyx_GOTREF(__pyx_tuple_);
  3054. __Pyx_GIVEREF(__pyx_tuple_);
  3055. /* "(tree fragment)":4
  3056. * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
  3057. * def __setstate_cython__(self, __pyx_state):
  3058. * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
  3059. */
  3060. __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 4, __pyx_L1_error)
  3061. __Pyx_GOTREF(__pyx_tuple__2);
  3062. __Pyx_GIVEREF(__pyx_tuple__2);
  3063. /* "httptools/parser/url_parser.pyx":13
  3064. * from . cimport url_cparser as uparser
  3065. *
  3066. * __all__ = ('parse_url',) # <<<<<<<<<<<<<<
  3067. *
  3068. * @cython.freelist(250)
  3069. */
  3070. __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_u_parse_url); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 13, __pyx_L1_error)
  3071. __Pyx_GOTREF(__pyx_tuple__3);
  3072. __Pyx_GIVEREF(__pyx_tuple__3);
  3073. /* "httptools/parser/url_parser.pyx":43
  3074. *
  3075. *
  3076. * def parse_url(url): # <<<<<<<<<<<<<<
  3077. * cdef:
  3078. * Py_buffer py_buf
  3079. */
  3080. __pyx_tuple__4 = PyTuple_Pack(15, __pyx_n_s_url, __pyx_n_s_py_buf, __pyx_n_s_buf_data, __pyx_n_s_parsed, __pyx_n_s_res, __pyx_n_s_schema, __pyx_n_s_host, __pyx_n_s_port, __pyx_n_s_path, __pyx_n_s_query, __pyx_n_s_fragment, __pyx_n_s_userinfo, __pyx_n_s_result, __pyx_n_s_off, __pyx_n_s_ln); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 43, __pyx_L1_error)
  3081. __Pyx_GOTREF(__pyx_tuple__4);
  3082. __Pyx_GIVEREF(__pyx_tuple__4);
  3083. __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(1, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_httptools_parser_url_parser_pyx, __pyx_n_s_parse_url, 43, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(1, 43, __pyx_L1_error)
  3084. __Pyx_RefNannyFinishContext();
  3085. return 0;
  3086. __pyx_L1_error:;
  3087. __Pyx_RefNannyFinishContext();
  3088. return -1;
  3089. }
  3090. static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  3091. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(1, 1, __pyx_L1_error);
  3092. return 0;
  3093. __pyx_L1_error:;
  3094. return -1;
  3095. }
  3096. static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
  3097. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
  3098. static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
  3099. static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
  3100. static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
  3101. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
  3102. static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
  3103. static int __Pyx_modinit_global_init_code(void) {
  3104. __Pyx_RefNannyDeclarations
  3105. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  3106. /*--- Global init code ---*/
  3107. __Pyx_RefNannyFinishContext();
  3108. return 0;
  3109. }
  3110. static int __Pyx_modinit_variable_export_code(void) {
  3111. __Pyx_RefNannyDeclarations
  3112. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  3113. /*--- Variable export code ---*/
  3114. __Pyx_RefNannyFinishContext();
  3115. return 0;
  3116. }
  3117. static int __Pyx_modinit_function_export_code(void) {
  3118. __Pyx_RefNannyDeclarations
  3119. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  3120. /*--- Function export code ---*/
  3121. __Pyx_RefNannyFinishContext();
  3122. return 0;
  3123. }
  3124. static int __Pyx_modinit_type_init_code(void) {
  3125. __Pyx_RefNannyDeclarations
  3126. int __pyx_lineno = 0;
  3127. const char *__pyx_filename = NULL;
  3128. int __pyx_clineno = 0;
  3129. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  3130. /*--- Type init code ---*/
  3131. if (PyType_Ready(&__pyx_type_9httptools_6parser_10url_parser_URL) < 0) __PYX_ERR(1, 16, __pyx_L1_error)
  3132. #if PY_VERSION_HEX < 0x030800B1
  3133. __pyx_type_9httptools_6parser_10url_parser_URL.tp_print = 0;
  3134. #endif
  3135. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_9httptools_6parser_10url_parser_URL.tp_dictoffset && __pyx_type_9httptools_6parser_10url_parser_URL.tp_getattro == PyObject_GenericGetAttr)) {
  3136. __pyx_type_9httptools_6parser_10url_parser_URL.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  3137. }
  3138. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_URL, (PyObject *)&__pyx_type_9httptools_6parser_10url_parser_URL) < 0) __PYX_ERR(1, 16, __pyx_L1_error)
  3139. if (__Pyx_setup_reduce((PyObject*)&__pyx_type_9httptools_6parser_10url_parser_URL) < 0) __PYX_ERR(1, 16, __pyx_L1_error)
  3140. __pyx_ptype_9httptools_6parser_10url_parser_URL = &__pyx_type_9httptools_6parser_10url_parser_URL;
  3141. __Pyx_RefNannyFinishContext();
  3142. return 0;
  3143. __pyx_L1_error:;
  3144. __Pyx_RefNannyFinishContext();
  3145. return -1;
  3146. }
  3147. static int __Pyx_modinit_type_import_code(void) {
  3148. __Pyx_RefNannyDeclarations
  3149. PyObject *__pyx_t_1 = NULL;
  3150. int __pyx_lineno = 0;
  3151. const char *__pyx_filename = NULL;
  3152. int __pyx_clineno = 0;
  3153. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  3154. /*--- Type import code ---*/
  3155. __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error)
  3156. __Pyx_GOTREF(__pyx_t_1);
  3157. __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
  3158. #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  3159. sizeof(PyTypeObject),
  3160. #else
  3161. sizeof(PyHeapTypeObject),
  3162. #endif
  3163. __Pyx_ImportType_CheckSize_Warn);
  3164. if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error)
  3165. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3166. __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 8, __pyx_L1_error)
  3167. __Pyx_GOTREF(__pyx_t_1);
  3168. __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), __Pyx_ImportType_CheckSize_Warn);
  3169. if (!__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(3, 8, __pyx_L1_error)
  3170. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3171. __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 15, __pyx_L1_error)
  3172. __Pyx_GOTREF(__pyx_t_1);
  3173. __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), __Pyx_ImportType_CheckSize_Warn);
  3174. if (!__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(4, 15, __pyx_L1_error)
  3175. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3176. __Pyx_RefNannyFinishContext();
  3177. return 0;
  3178. __pyx_L1_error:;
  3179. __Pyx_XDECREF(__pyx_t_1);
  3180. __Pyx_RefNannyFinishContext();
  3181. return -1;
  3182. }
  3183. static int __Pyx_modinit_variable_import_code(void) {
  3184. __Pyx_RefNannyDeclarations
  3185. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  3186. /*--- Variable import code ---*/
  3187. __Pyx_RefNannyFinishContext();
  3188. return 0;
  3189. }
  3190. static int __Pyx_modinit_function_import_code(void) {
  3191. __Pyx_RefNannyDeclarations
  3192. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  3193. /*--- Function import code ---*/
  3194. __Pyx_RefNannyFinishContext();
  3195. return 0;
  3196. }
  3197. #ifndef CYTHON_NO_PYINIT_EXPORT
  3198. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  3199. #elif PY_MAJOR_VERSION < 3
  3200. #ifdef __cplusplus
  3201. #define __Pyx_PyMODINIT_FUNC extern "C" void
  3202. #else
  3203. #define __Pyx_PyMODINIT_FUNC void
  3204. #endif
  3205. #else
  3206. #ifdef __cplusplus
  3207. #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
  3208. #else
  3209. #define __Pyx_PyMODINIT_FUNC PyObject *
  3210. #endif
  3211. #endif
  3212. #if PY_MAJOR_VERSION < 3
  3213. __Pyx_PyMODINIT_FUNC initurl_parser(void) CYTHON_SMALL_CODE; /*proto*/
  3214. __Pyx_PyMODINIT_FUNC initurl_parser(void)
  3215. #else
  3216. __Pyx_PyMODINIT_FUNC PyInit_url_parser(void) CYTHON_SMALL_CODE; /*proto*/
  3217. __Pyx_PyMODINIT_FUNC PyInit_url_parser(void)
  3218. #if CYTHON_PEP489_MULTI_PHASE_INIT
  3219. {
  3220. return PyModuleDef_Init(&__pyx_moduledef);
  3221. }
  3222. static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
  3223. #if PY_VERSION_HEX >= 0x030700A1
  3224. static PY_INT64_T main_interpreter_id = -1;
  3225. PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
  3226. if (main_interpreter_id == -1) {
  3227. main_interpreter_id = current_id;
  3228. return (unlikely(current_id == -1)) ? -1 : 0;
  3229. } else if (unlikely(main_interpreter_id != current_id))
  3230. #else
  3231. static PyInterpreterState *main_interpreter = NULL;
  3232. PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
  3233. if (!main_interpreter) {
  3234. main_interpreter = current_interpreter;
  3235. } else if (unlikely(main_interpreter != current_interpreter))
  3236. #endif
  3237. {
  3238. PyErr_SetString(
  3239. PyExc_ImportError,
  3240. "Interpreter change detected - this module can only be loaded into one interpreter per process.");
  3241. return -1;
  3242. }
  3243. return 0;
  3244. }
  3245. static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
  3246. PyObject *value = PyObject_GetAttrString(spec, from_name);
  3247. int result = 0;
  3248. if (likely(value)) {
  3249. if (allow_none || value != Py_None) {
  3250. result = PyDict_SetItemString(moddict, to_name, value);
  3251. }
  3252. Py_DECREF(value);
  3253. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  3254. PyErr_Clear();
  3255. } else {
  3256. result = -1;
  3257. }
  3258. return result;
  3259. }
  3260. static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
  3261. PyObject *module = NULL, *moddict, *modname;
  3262. if (__Pyx_check_single_interpreter())
  3263. return NULL;
  3264. if (__pyx_m)
  3265. return __Pyx_NewRef(__pyx_m);
  3266. modname = PyObject_GetAttrString(spec, "name");
  3267. if (unlikely(!modname)) goto bad;
  3268. module = PyModule_NewObject(modname);
  3269. Py_DECREF(modname);
  3270. if (unlikely(!module)) goto bad;
  3271. moddict = PyModule_GetDict(module);
  3272. if (unlikely(!moddict)) goto bad;
  3273. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
  3274. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
  3275. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
  3276. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
  3277. return module;
  3278. bad:
  3279. Py_XDECREF(module);
  3280. return NULL;
  3281. }
  3282. static CYTHON_SMALL_CODE int __pyx_pymod_exec_url_parser(PyObject *__pyx_pyinit_module)
  3283. #endif
  3284. #endif
  3285. {
  3286. PyObject *__pyx_t_1 = NULL;
  3287. PyObject *__pyx_t_2 = NULL;
  3288. int __pyx_lineno = 0;
  3289. const char *__pyx_filename = NULL;
  3290. int __pyx_clineno = 0;
  3291. __Pyx_RefNannyDeclarations
  3292. #if CYTHON_PEP489_MULTI_PHASE_INIT
  3293. if (__pyx_m) {
  3294. if (__pyx_m == __pyx_pyinit_module) return 0;
  3295. PyErr_SetString(PyExc_RuntimeError, "Module 'url_parser' has already been imported. Re-initialisation is not supported.");
  3296. return -1;
  3297. }
  3298. #elif PY_MAJOR_VERSION >= 3
  3299. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  3300. #endif
  3301. #if CYTHON_REFNANNY
  3302. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  3303. if (!__Pyx_RefNanny) {
  3304. PyErr_Clear();
  3305. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  3306. if (!__Pyx_RefNanny)
  3307. Py_FatalError("failed to import 'refnanny' module");
  3308. }
  3309. #endif
  3310. __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_url_parser(void)", 0);
  3311. if (__Pyx_check_binary_version() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3312. #ifdef __Pxy_PyFrame_Initialize_Offsets
  3313. __Pxy_PyFrame_Initialize_Offsets();
  3314. #endif
  3315. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(1, 1, __pyx_L1_error)
  3316. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(1, 1, __pyx_L1_error)
  3317. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(1, 1, __pyx_L1_error)
  3318. #ifdef __Pyx_CyFunction_USED
  3319. if (__pyx_CyFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3320. #endif
  3321. #ifdef __Pyx_FusedFunction_USED
  3322. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3323. #endif
  3324. #ifdef __Pyx_Coroutine_USED
  3325. if (__pyx_Coroutine_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3326. #endif
  3327. #ifdef __Pyx_Generator_USED
  3328. if (__pyx_Generator_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3329. #endif
  3330. #ifdef __Pyx_AsyncGen_USED
  3331. if (__pyx_AsyncGen_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3332. #endif
  3333. #ifdef __Pyx_StopAsyncIteration_USED
  3334. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3335. #endif
  3336. /*--- Library function declarations ---*/
  3337. /*--- Threads initialization code ---*/
  3338. #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  3339. PyEval_InitThreads();
  3340. #endif
  3341. /*--- Module creation code ---*/
  3342. #if CYTHON_PEP489_MULTI_PHASE_INIT
  3343. __pyx_m = __pyx_pyinit_module;
  3344. Py_INCREF(__pyx_m);
  3345. #else
  3346. #if PY_MAJOR_VERSION < 3
  3347. __pyx_m = Py_InitModule4("url_parser", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  3348. #else
  3349. __pyx_m = PyModule_Create(&__pyx_moduledef);
  3350. #endif
  3351. if (unlikely(!__pyx_m)) __PYX_ERR(1, 1, __pyx_L1_error)
  3352. #endif
  3353. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(1, 1, __pyx_L1_error)
  3354. Py_INCREF(__pyx_d);
  3355. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(1, 1, __pyx_L1_error)
  3356. Py_INCREF(__pyx_b);
  3357. __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(1, 1, __pyx_L1_error)
  3358. Py_INCREF(__pyx_cython_runtime);
  3359. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(1, 1, __pyx_L1_error);
  3360. /*--- Initialize various global constants etc. ---*/
  3361. if (__Pyx_InitGlobals() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3362. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  3363. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3364. #endif
  3365. if (__pyx_module_is_main_httptools__parser__url_parser) {
  3366. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3367. }
  3368. #if PY_MAJOR_VERSION >= 3
  3369. {
  3370. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(1, 1, __pyx_L1_error)
  3371. if (!PyDict_GetItemString(modules, "httptools.parser.url_parser")) {
  3372. if (unlikely(PyDict_SetItemString(modules, "httptools.parser.url_parser", __pyx_m) < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
  3373. }
  3374. }
  3375. #endif
  3376. /*--- Builtin init code ---*/
  3377. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3378. /*--- Constants init code ---*/
  3379. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3380. /*--- Global type/function init code ---*/
  3381. (void)__Pyx_modinit_global_init_code();
  3382. (void)__Pyx_modinit_variable_export_code();
  3383. (void)__Pyx_modinit_function_export_code();
  3384. if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
  3385. if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(1, 1, __pyx_L1_error)
  3386. (void)__Pyx_modinit_variable_import_code();
  3387. (void)__Pyx_modinit_function_import_code();
  3388. /*--- Execution code ---*/
  3389. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  3390. if (__Pyx_patch_abc() < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3391. #endif
  3392. /* "httptools/parser/url_parser.pyx":8
  3393. * Py_buffer
  3394. *
  3395. * from .errors import HttpParserInvalidURLError # <<<<<<<<<<<<<<
  3396. *
  3397. * cimport cython
  3398. */
  3399. __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
  3400. __Pyx_GOTREF(__pyx_t_1);
  3401. __Pyx_INCREF(__pyx_n_s_HttpParserInvalidURLError);
  3402. __Pyx_GIVEREF(__pyx_n_s_HttpParserInvalidURLError);
  3403. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_HttpParserInvalidURLError);
  3404. __pyx_t_2 = __Pyx_Import(__pyx_n_s_errors, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
  3405. __Pyx_GOTREF(__pyx_t_2);
  3406. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3407. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_HttpParserInvalidURLError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
  3408. __Pyx_GOTREF(__pyx_t_1);
  3409. if (PyDict_SetItem(__pyx_d, __pyx_n_s_HttpParserInvalidURLError, __pyx_t_1) < 0) __PYX_ERR(1, 8, __pyx_L1_error)
  3410. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3411. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3412. /* "httptools/parser/url_parser.pyx":13
  3413. * from . cimport url_cparser as uparser
  3414. *
  3415. * __all__ = ('parse_url',) # <<<<<<<<<<<<<<
  3416. *
  3417. * @cython.freelist(250)
  3418. */
  3419. if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_tuple__3) < 0) __PYX_ERR(1, 13, __pyx_L1_error)
  3420. /* "httptools/parser/url_parser.pyx":43
  3421. *
  3422. *
  3423. * def parse_url(url): # <<<<<<<<<<<<<<
  3424. * cdef:
  3425. * Py_buffer py_buf
  3426. */
  3427. __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_9httptools_6parser_10url_parser_1parse_url, NULL, __pyx_n_s_httptools_parser_url_parser); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 43, __pyx_L1_error)
  3428. __Pyx_GOTREF(__pyx_t_2);
  3429. if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_url, __pyx_t_2) < 0) __PYX_ERR(1, 43, __pyx_L1_error)
  3430. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3431. /* "httptools/parser/url_parser.pyx":1
  3432. * #cython: language_level=3 # <<<<<<<<<<<<<<
  3433. *
  3434. * from __future__ import print_function
  3435. */
  3436. __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error)
  3437. __Pyx_GOTREF(__pyx_t_2);
  3438. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
  3439. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3440. /*--- Wrapped vars code ---*/
  3441. goto __pyx_L0;
  3442. __pyx_L1_error:;
  3443. __Pyx_XDECREF(__pyx_t_1);
  3444. __Pyx_XDECREF(__pyx_t_2);
  3445. if (__pyx_m) {
  3446. if (__pyx_d) {
  3447. __Pyx_AddTraceback("init httptools.parser.url_parser", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3448. }
  3449. Py_CLEAR(__pyx_m);
  3450. } else if (!PyErr_Occurred()) {
  3451. PyErr_SetString(PyExc_ImportError, "init httptools.parser.url_parser");
  3452. }
  3453. __pyx_L0:;
  3454. __Pyx_RefNannyFinishContext();
  3455. #if CYTHON_PEP489_MULTI_PHASE_INIT
  3456. return (__pyx_m != NULL) ? 0 : -1;
  3457. #elif PY_MAJOR_VERSION >= 3
  3458. return __pyx_m;
  3459. #else
  3460. return;
  3461. #endif
  3462. }
  3463. /* --- Runtime support code --- */
  3464. /* Refnanny */
  3465. #if CYTHON_REFNANNY
  3466. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  3467. PyObject *m = NULL, *p = NULL;
  3468. void *r = NULL;
  3469. m = PyImport_ImportModule(modname);
  3470. if (!m) goto end;
  3471. p = PyObject_GetAttrString(m, "RefNannyAPI");
  3472. if (!p) goto end;
  3473. r = PyLong_AsVoidPtr(p);
  3474. end:
  3475. Py_XDECREF(p);
  3476. Py_XDECREF(m);
  3477. return (__Pyx_RefNannyAPIStruct *)r;
  3478. }
  3479. #endif
  3480. /* PyObjectGetAttrStr */
  3481. #if CYTHON_USE_TYPE_SLOTS
  3482. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  3483. PyTypeObject* tp = Py_TYPE(obj);
  3484. if (likely(tp->tp_getattro))
  3485. return tp->tp_getattro(obj, attr_name);
  3486. #if PY_MAJOR_VERSION < 3
  3487. if (likely(tp->tp_getattr))
  3488. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  3489. #endif
  3490. return PyObject_GetAttr(obj, attr_name);
  3491. }
  3492. #endif
  3493. /* GetBuiltinName */
  3494. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  3495. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  3496. if (unlikely(!result)) {
  3497. PyErr_Format(PyExc_NameError,
  3498. #if PY_MAJOR_VERSION >= 3
  3499. "name '%U' is not defined", name);
  3500. #else
  3501. "name '%.200s' is not defined", PyString_AS_STRING(name));
  3502. #endif
  3503. }
  3504. return result;
  3505. }
  3506. /* RaiseArgTupleInvalid */
  3507. static void __Pyx_RaiseArgtupleInvalid(
  3508. const char* func_name,
  3509. int exact,
  3510. Py_ssize_t num_min,
  3511. Py_ssize_t num_max,
  3512. Py_ssize_t num_found)
  3513. {
  3514. Py_ssize_t num_expected;
  3515. const char *more_or_less;
  3516. if (num_found < num_min) {
  3517. num_expected = num_min;
  3518. more_or_less = "at least";
  3519. } else {
  3520. num_expected = num_max;
  3521. more_or_less = "at most";
  3522. }
  3523. if (exact) {
  3524. more_or_less = "exactly";
  3525. }
  3526. PyErr_Format(PyExc_TypeError,
  3527. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  3528. func_name, more_or_less, num_expected,
  3529. (num_expected == 1) ? "" : "s", num_found);
  3530. }
  3531. /* RaiseDoubleKeywords */
  3532. static void __Pyx_RaiseDoubleKeywordsError(
  3533. const char* func_name,
  3534. PyObject* kw_name)
  3535. {
  3536. PyErr_Format(PyExc_TypeError,
  3537. #if PY_MAJOR_VERSION >= 3
  3538. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  3539. #else
  3540. "%s() got multiple values for keyword argument '%s'", func_name,
  3541. PyString_AsString(kw_name));
  3542. #endif
  3543. }
  3544. /* ParseKeywords */
  3545. static int __Pyx_ParseOptionalKeywords(
  3546. PyObject *kwds,
  3547. PyObject **argnames[],
  3548. PyObject *kwds2,
  3549. PyObject *values[],
  3550. Py_ssize_t num_pos_args,
  3551. const char* function_name)
  3552. {
  3553. PyObject *key = 0, *value = 0;
  3554. Py_ssize_t pos = 0;
  3555. PyObject*** name;
  3556. PyObject*** first_kw_arg = argnames + num_pos_args;
  3557. while (PyDict_Next(kwds, &pos, &key, &value)) {
  3558. name = first_kw_arg;
  3559. while (*name && (**name != key)) name++;
  3560. if (*name) {
  3561. values[name-argnames] = value;
  3562. continue;
  3563. }
  3564. name = first_kw_arg;
  3565. #if PY_MAJOR_VERSION < 3
  3566. if (likely(PyString_Check(key))) {
  3567. while (*name) {
  3568. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  3569. && _PyString_Eq(**name, key)) {
  3570. values[name-argnames] = value;
  3571. break;
  3572. }
  3573. name++;
  3574. }
  3575. if (*name) continue;
  3576. else {
  3577. PyObject*** argname = argnames;
  3578. while (argname != first_kw_arg) {
  3579. if ((**argname == key) || (
  3580. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  3581. && _PyString_Eq(**argname, key))) {
  3582. goto arg_passed_twice;
  3583. }
  3584. argname++;
  3585. }
  3586. }
  3587. } else
  3588. #endif
  3589. if (likely(PyUnicode_Check(key))) {
  3590. while (*name) {
  3591. int cmp = (**name == key) ? 0 :
  3592. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  3593. (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
  3594. #endif
  3595. PyUnicode_Compare(**name, key);
  3596. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  3597. if (cmp == 0) {
  3598. values[name-argnames] = value;
  3599. break;
  3600. }
  3601. name++;
  3602. }
  3603. if (*name) continue;
  3604. else {
  3605. PyObject*** argname = argnames;
  3606. while (argname != first_kw_arg) {
  3607. int cmp = (**argname == key) ? 0 :
  3608. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  3609. (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
  3610. #endif
  3611. PyUnicode_Compare(**argname, key);
  3612. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  3613. if (cmp == 0) goto arg_passed_twice;
  3614. argname++;
  3615. }
  3616. }
  3617. } else
  3618. goto invalid_keyword_type;
  3619. if (kwds2) {
  3620. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  3621. } else {
  3622. goto invalid_keyword;
  3623. }
  3624. }
  3625. return 0;
  3626. arg_passed_twice:
  3627. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  3628. goto bad;
  3629. invalid_keyword_type:
  3630. PyErr_Format(PyExc_TypeError,
  3631. "%.200s() keywords must be strings", function_name);
  3632. goto bad;
  3633. invalid_keyword:
  3634. PyErr_Format(PyExc_TypeError,
  3635. #if PY_MAJOR_VERSION < 3
  3636. "%.200s() got an unexpected keyword argument '%.200s'",
  3637. function_name, PyString_AsString(key));
  3638. #else
  3639. "%s() got an unexpected keyword argument '%U'",
  3640. function_name, key);
  3641. #endif
  3642. bad:
  3643. return -1;
  3644. }
  3645. /* ArgTypeTest */
  3646. static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
  3647. {
  3648. if (unlikely(!type)) {
  3649. PyErr_SetString(PyExc_SystemError, "Missing type object");
  3650. return 0;
  3651. }
  3652. else if (exact) {
  3653. #if PY_MAJOR_VERSION == 2
  3654. if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
  3655. #endif
  3656. }
  3657. else {
  3658. if (likely(__Pyx_TypeCheck(obj, type))) return 1;
  3659. }
  3660. PyErr_Format(PyExc_TypeError,
  3661. "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
  3662. name, type->tp_name, Py_TYPE(obj)->tp_name);
  3663. return 0;
  3664. }
  3665. /* PyFunctionFastCall */
  3666. #if CYTHON_FAST_PYCALL
  3667. static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
  3668. PyObject *globals) {
  3669. PyFrameObject *f;
  3670. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  3671. PyObject **fastlocals;
  3672. Py_ssize_t i;
  3673. PyObject *result;
  3674. assert(globals != NULL);
  3675. /* XXX Perhaps we should create a specialized
  3676. PyFrame_New() that doesn't take locals, but does
  3677. take builtins without sanity checking them.
  3678. */
  3679. assert(tstate != NULL);
  3680. f = PyFrame_New(tstate, co, globals, NULL);
  3681. if (f == NULL) {
  3682. return NULL;
  3683. }
  3684. fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
  3685. for (i = 0; i < na; i++) {
  3686. Py_INCREF(*args);
  3687. fastlocals[i] = *args++;
  3688. }
  3689. result = PyEval_EvalFrameEx(f,0);
  3690. ++tstate->recursion_depth;
  3691. Py_DECREF(f);
  3692. --tstate->recursion_depth;
  3693. return result;
  3694. }
  3695. #if 1 || PY_VERSION_HEX < 0x030600B1
  3696. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
  3697. PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
  3698. PyObject *globals = PyFunction_GET_GLOBALS(func);
  3699. PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
  3700. PyObject *closure;
  3701. #if PY_MAJOR_VERSION >= 3
  3702. PyObject *kwdefs;
  3703. #endif
  3704. PyObject *kwtuple, **k;
  3705. PyObject **d;
  3706. Py_ssize_t nd;
  3707. Py_ssize_t nk;
  3708. PyObject *result;
  3709. assert(kwargs == NULL || PyDict_Check(kwargs));
  3710. nk = kwargs ? PyDict_Size(kwargs) : 0;
  3711. if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
  3712. return NULL;
  3713. }
  3714. if (
  3715. #if PY_MAJOR_VERSION >= 3
  3716. co->co_kwonlyargcount == 0 &&
  3717. #endif
  3718. likely(kwargs == NULL || nk == 0) &&
  3719. co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
  3720. if (argdefs == NULL && co->co_argcount == nargs) {
  3721. result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
  3722. goto done;
  3723. }
  3724. else if (nargs == 0 && argdefs != NULL
  3725. && co->co_argcount == Py_SIZE(argdefs)) {
  3726. /* function called with no arguments, but all parameters have
  3727. a default value: use default values as arguments .*/
  3728. args = &PyTuple_GET_ITEM(argdefs, 0);
  3729. result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
  3730. goto done;
  3731. }
  3732. }
  3733. if (kwargs != NULL) {
  3734. Py_ssize_t pos, i;
  3735. kwtuple = PyTuple_New(2 * nk);
  3736. if (kwtuple == NULL) {
  3737. result = NULL;
  3738. goto done;
  3739. }
  3740. k = &PyTuple_GET_ITEM(kwtuple, 0);
  3741. pos = i = 0;
  3742. while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
  3743. Py_INCREF(k[i]);
  3744. Py_INCREF(k[i+1]);
  3745. i += 2;
  3746. }
  3747. nk = i / 2;
  3748. }
  3749. else {
  3750. kwtuple = NULL;
  3751. k = NULL;
  3752. }
  3753. closure = PyFunction_GET_CLOSURE(func);
  3754. #if PY_MAJOR_VERSION >= 3
  3755. kwdefs = PyFunction_GET_KW_DEFAULTS(func);
  3756. #endif
  3757. if (argdefs != NULL) {
  3758. d = &PyTuple_GET_ITEM(argdefs, 0);
  3759. nd = Py_SIZE(argdefs);
  3760. }
  3761. else {
  3762. d = NULL;
  3763. nd = 0;
  3764. }
  3765. #if PY_MAJOR_VERSION >= 3
  3766. result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
  3767. args, (int)nargs,
  3768. k, (int)nk,
  3769. d, (int)nd, kwdefs, closure);
  3770. #else
  3771. result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
  3772. args, (int)nargs,
  3773. k, (int)nk,
  3774. d, (int)nd, closure);
  3775. #endif
  3776. Py_XDECREF(kwtuple);
  3777. done:
  3778. Py_LeaveRecursiveCall();
  3779. return result;
  3780. }
  3781. #endif
  3782. #endif
  3783. /* PyCFunctionFastCall */
  3784. #if CYTHON_FAST_PYCCALL
  3785. static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
  3786. PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
  3787. PyCFunction meth = PyCFunction_GET_FUNCTION(func);
  3788. PyObject *self = PyCFunction_GET_SELF(func);
  3789. int flags = PyCFunction_GET_FLAGS(func);
  3790. assert(PyCFunction_Check(func));
  3791. assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
  3792. assert(nargs >= 0);
  3793. assert(nargs == 0 || args != NULL);
  3794. /* _PyCFunction_FastCallDict() must not be called with an exception set,
  3795. because it may clear it (directly or indirectly) and so the
  3796. caller loses its exception */
  3797. assert(!PyErr_Occurred());
  3798. if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
  3799. return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
  3800. } else {
  3801. return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
  3802. }
  3803. }
  3804. #endif
  3805. /* PyObjectCall */
  3806. #if CYTHON_COMPILING_IN_CPYTHON
  3807. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  3808. PyObject *result;
  3809. ternaryfunc call = Py_TYPE(func)->tp_call;
  3810. if (unlikely(!call))
  3811. return PyObject_Call(func, arg, kw);
  3812. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  3813. return NULL;
  3814. result = (*call)(func, arg, kw);
  3815. Py_LeaveRecursiveCall();
  3816. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  3817. PyErr_SetString(
  3818. PyExc_SystemError,
  3819. "NULL result without error in PyObject_Call");
  3820. }
  3821. return result;
  3822. }
  3823. #endif
  3824. /* PyErrFetchRestore */
  3825. #if CYTHON_FAST_THREAD_STATE
  3826. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  3827. PyObject *tmp_type, *tmp_value, *tmp_tb;
  3828. tmp_type = tstate->curexc_type;
  3829. tmp_value = tstate->curexc_value;
  3830. tmp_tb = tstate->curexc_traceback;
  3831. tstate->curexc_type = type;
  3832. tstate->curexc_value = value;
  3833. tstate->curexc_traceback = tb;
  3834. Py_XDECREF(tmp_type);
  3835. Py_XDECREF(tmp_value);
  3836. Py_XDECREF(tmp_tb);
  3837. }
  3838. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  3839. *type = tstate->curexc_type;
  3840. *value = tstate->curexc_value;
  3841. *tb = tstate->curexc_traceback;
  3842. tstate->curexc_type = 0;
  3843. tstate->curexc_value = 0;
  3844. tstate->curexc_traceback = 0;
  3845. }
  3846. #endif
  3847. /* RaiseException */
  3848. #if PY_MAJOR_VERSION < 3
  3849. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
  3850. CYTHON_UNUSED PyObject *cause) {
  3851. __Pyx_PyThreadState_declare
  3852. Py_XINCREF(type);
  3853. if (!value || value == Py_None)
  3854. value = NULL;
  3855. else
  3856. Py_INCREF(value);
  3857. if (!tb || tb == Py_None)
  3858. tb = NULL;
  3859. else {
  3860. Py_INCREF(tb);
  3861. if (!PyTraceBack_Check(tb)) {
  3862. PyErr_SetString(PyExc_TypeError,
  3863. "raise: arg 3 must be a traceback or None");
  3864. goto raise_error;
  3865. }
  3866. }
  3867. if (PyType_Check(type)) {
  3868. #if CYTHON_COMPILING_IN_PYPY
  3869. if (!value) {
  3870. Py_INCREF(Py_None);
  3871. value = Py_None;
  3872. }
  3873. #endif
  3874. PyErr_NormalizeException(&type, &value, &tb);
  3875. } else {
  3876. if (value) {
  3877. PyErr_SetString(PyExc_TypeError,
  3878. "instance exception may not have a separate value");
  3879. goto raise_error;
  3880. }
  3881. value = type;
  3882. type = (PyObject*) Py_TYPE(type);
  3883. Py_INCREF(type);
  3884. if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
  3885. PyErr_SetString(PyExc_TypeError,
  3886. "raise: exception class must be a subclass of BaseException");
  3887. goto raise_error;
  3888. }
  3889. }
  3890. __Pyx_PyThreadState_assign
  3891. __Pyx_ErrRestore(type, value, tb);
  3892. return;
  3893. raise_error:
  3894. Py_XDECREF(value);
  3895. Py_XDECREF(type);
  3896. Py_XDECREF(tb);
  3897. return;
  3898. }
  3899. #else
  3900. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  3901. PyObject* owned_instance = NULL;
  3902. if (tb == Py_None) {
  3903. tb = 0;
  3904. } else if (tb && !PyTraceBack_Check(tb)) {
  3905. PyErr_SetString(PyExc_TypeError,
  3906. "raise: arg 3 must be a traceback or None");
  3907. goto bad;
  3908. }
  3909. if (value == Py_None)
  3910. value = 0;
  3911. if (PyExceptionInstance_Check(type)) {
  3912. if (value) {
  3913. PyErr_SetString(PyExc_TypeError,
  3914. "instance exception may not have a separate value");
  3915. goto bad;
  3916. }
  3917. value = type;
  3918. type = (PyObject*) Py_TYPE(value);
  3919. } else if (PyExceptionClass_Check(type)) {
  3920. PyObject *instance_class = NULL;
  3921. if (value && PyExceptionInstance_Check(value)) {
  3922. instance_class = (PyObject*) Py_TYPE(value);
  3923. if (instance_class != type) {
  3924. int is_subclass = PyObject_IsSubclass(instance_class, type);
  3925. if (!is_subclass) {
  3926. instance_class = NULL;
  3927. } else if (unlikely(is_subclass == -1)) {
  3928. goto bad;
  3929. } else {
  3930. type = instance_class;
  3931. }
  3932. }
  3933. }
  3934. if (!instance_class) {
  3935. PyObject *args;
  3936. if (!value)
  3937. args = PyTuple_New(0);
  3938. else if (PyTuple_Check(value)) {
  3939. Py_INCREF(value);
  3940. args = value;
  3941. } else
  3942. args = PyTuple_Pack(1, value);
  3943. if (!args)
  3944. goto bad;
  3945. owned_instance = PyObject_Call(type, args, NULL);
  3946. Py_DECREF(args);
  3947. if (!owned_instance)
  3948. goto bad;
  3949. value = owned_instance;
  3950. if (!PyExceptionInstance_Check(value)) {
  3951. PyErr_Format(PyExc_TypeError,
  3952. "calling %R should have returned an instance of "
  3953. "BaseException, not %R",
  3954. type, Py_TYPE(value));
  3955. goto bad;
  3956. }
  3957. }
  3958. } else {
  3959. PyErr_SetString(PyExc_TypeError,
  3960. "raise: exception class must be a subclass of BaseException");
  3961. goto bad;
  3962. }
  3963. if (cause) {
  3964. PyObject *fixed_cause;
  3965. if (cause == Py_None) {
  3966. fixed_cause = NULL;
  3967. } else if (PyExceptionClass_Check(cause)) {
  3968. fixed_cause = PyObject_CallObject(cause, NULL);
  3969. if (fixed_cause == NULL)
  3970. goto bad;
  3971. } else if (PyExceptionInstance_Check(cause)) {
  3972. fixed_cause = cause;
  3973. Py_INCREF(fixed_cause);
  3974. } else {
  3975. PyErr_SetString(PyExc_TypeError,
  3976. "exception causes must derive from "
  3977. "BaseException");
  3978. goto bad;
  3979. }
  3980. PyException_SetCause(value, fixed_cause);
  3981. }
  3982. PyErr_SetObject(type, value);
  3983. if (tb) {
  3984. #if CYTHON_COMPILING_IN_PYPY
  3985. PyObject *tmp_type, *tmp_value, *tmp_tb;
  3986. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  3987. Py_INCREF(tb);
  3988. PyErr_Restore(tmp_type, tmp_value, tb);
  3989. Py_XDECREF(tmp_tb);
  3990. #else
  3991. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  3992. PyObject* tmp_tb = tstate->curexc_traceback;
  3993. if (tb != tmp_tb) {
  3994. Py_INCREF(tb);
  3995. tstate->curexc_traceback = tb;
  3996. Py_XDECREF(tmp_tb);
  3997. }
  3998. #endif
  3999. }
  4000. bad:
  4001. Py_XDECREF(owned_instance);
  4002. return;
  4003. }
  4004. #endif
  4005. /* PyDictVersioning */
  4006. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  4007. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
  4008. PyObject *dict = Py_TYPE(obj)->tp_dict;
  4009. return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
  4010. }
  4011. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
  4012. PyObject **dictptr = NULL;
  4013. Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
  4014. if (offset) {
  4015. #if CYTHON_COMPILING_IN_CPYTHON
  4016. dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
  4017. #else
  4018. dictptr = _PyObject_GetDictPtr(obj);
  4019. #endif
  4020. }
  4021. return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
  4022. }
  4023. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
  4024. PyObject *dict = Py_TYPE(obj)->tp_dict;
  4025. if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
  4026. return 0;
  4027. return obj_dict_version == __Pyx_get_object_dict_version(obj);
  4028. }
  4029. #endif
  4030. /* GetModuleGlobalName */
  4031. #if CYTHON_USE_DICT_VERSIONS
  4032. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
  4033. #else
  4034. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
  4035. #endif
  4036. {
  4037. PyObject *result;
  4038. #if !CYTHON_AVOID_BORROWED_REFS
  4039. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
  4040. result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
  4041. __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
  4042. if (likely(result)) {
  4043. return __Pyx_NewRef(result);
  4044. } else if (unlikely(PyErr_Occurred())) {
  4045. return NULL;
  4046. }
  4047. #else
  4048. result = PyDict_GetItem(__pyx_d, name);
  4049. __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
  4050. if (likely(result)) {
  4051. return __Pyx_NewRef(result);
  4052. }
  4053. #endif
  4054. #else
  4055. result = PyObject_GetItem(__pyx_d, name);
  4056. __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
  4057. if (likely(result)) {
  4058. return __Pyx_NewRef(result);
  4059. }
  4060. PyErr_Clear();
  4061. #endif
  4062. return __Pyx_GetBuiltinName(name);
  4063. }
  4064. /* PyObjectCall2Args */
  4065. static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
  4066. PyObject *args, *result = NULL;
  4067. #if CYTHON_FAST_PYCALL
  4068. if (PyFunction_Check(function)) {
  4069. PyObject *args[2] = {arg1, arg2};
  4070. return __Pyx_PyFunction_FastCall(function, args, 2);
  4071. }
  4072. #endif
  4073. #if CYTHON_FAST_PYCCALL
  4074. if (__Pyx_PyFastCFunction_Check(function)) {
  4075. PyObject *args[2] = {arg1, arg2};
  4076. return __Pyx_PyCFunction_FastCall(function, args, 2);
  4077. }
  4078. #endif
  4079. args = PyTuple_New(2);
  4080. if (unlikely(!args)) goto done;
  4081. Py_INCREF(arg1);
  4082. PyTuple_SET_ITEM(args, 0, arg1);
  4083. Py_INCREF(arg2);
  4084. PyTuple_SET_ITEM(args, 1, arg2);
  4085. Py_INCREF(function);
  4086. result = __Pyx_PyObject_Call(function, args, NULL);
  4087. Py_DECREF(args);
  4088. Py_DECREF(function);
  4089. done:
  4090. return result;
  4091. }
  4092. /* PyObjectCallMethO */
  4093. #if CYTHON_COMPILING_IN_CPYTHON
  4094. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  4095. PyObject *self, *result;
  4096. PyCFunction cfunc;
  4097. cfunc = PyCFunction_GET_FUNCTION(func);
  4098. self = PyCFunction_GET_SELF(func);
  4099. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  4100. return NULL;
  4101. result = cfunc(self, arg);
  4102. Py_LeaveRecursiveCall();
  4103. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  4104. PyErr_SetString(
  4105. PyExc_SystemError,
  4106. "NULL result without error in PyObject_Call");
  4107. }
  4108. return result;
  4109. }
  4110. #endif
  4111. /* PyObjectCallOneArg */
  4112. #if CYTHON_COMPILING_IN_CPYTHON
  4113. static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  4114. PyObject *result;
  4115. PyObject *args = PyTuple_New(1);
  4116. if (unlikely(!args)) return NULL;
  4117. Py_INCREF(arg);
  4118. PyTuple_SET_ITEM(args, 0, arg);
  4119. result = __Pyx_PyObject_Call(func, args, NULL);
  4120. Py_DECREF(args);
  4121. return result;
  4122. }
  4123. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  4124. #if CYTHON_FAST_PYCALL
  4125. if (PyFunction_Check(func)) {
  4126. return __Pyx_PyFunction_FastCall(func, &arg, 1);
  4127. }
  4128. #endif
  4129. if (likely(PyCFunction_Check(func))) {
  4130. if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
  4131. return __Pyx_PyObject_CallMethO(func, arg);
  4132. #if CYTHON_FAST_PYCCALL
  4133. } else if (__Pyx_PyFastCFunction_Check(func)) {
  4134. return __Pyx_PyCFunction_FastCall(func, &arg, 1);
  4135. #endif
  4136. }
  4137. }
  4138. return __Pyx__PyObject_CallOneArg(func, arg);
  4139. }
  4140. #else
  4141. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  4142. PyObject *result;
  4143. PyObject *args = PyTuple_Pack(1, arg);
  4144. if (unlikely(!args)) return NULL;
  4145. result = __Pyx_PyObject_Call(func, args, NULL);
  4146. Py_DECREF(args);
  4147. return result;
  4148. }
  4149. #endif
  4150. /* GetException */
  4151. #if CYTHON_FAST_THREAD_STATE
  4152. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
  4153. #else
  4154. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
  4155. #endif
  4156. {
  4157. PyObject *local_type, *local_value, *local_tb;
  4158. #if CYTHON_FAST_THREAD_STATE
  4159. PyObject *tmp_type, *tmp_value, *tmp_tb;
  4160. local_type = tstate->curexc_type;
  4161. local_value = tstate->curexc_value;
  4162. local_tb = tstate->curexc_traceback;
  4163. tstate->curexc_type = 0;
  4164. tstate->curexc_value = 0;
  4165. tstate->curexc_traceback = 0;
  4166. #else
  4167. PyErr_Fetch(&local_type, &local_value, &local_tb);
  4168. #endif
  4169. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  4170. #if CYTHON_FAST_THREAD_STATE
  4171. if (unlikely(tstate->curexc_type))
  4172. #else
  4173. if (unlikely(PyErr_Occurred()))
  4174. #endif
  4175. goto bad;
  4176. #if PY_MAJOR_VERSION >= 3
  4177. if (local_tb) {
  4178. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  4179. goto bad;
  4180. }
  4181. #endif
  4182. Py_XINCREF(local_tb);
  4183. Py_XINCREF(local_type);
  4184. Py_XINCREF(local_value);
  4185. *type = local_type;
  4186. *value = local_value;
  4187. *tb = local_tb;
  4188. #if CYTHON_FAST_THREAD_STATE
  4189. #if CYTHON_USE_EXC_INFO_STACK
  4190. {
  4191. _PyErr_StackItem *exc_info = tstate->exc_info;
  4192. tmp_type = exc_info->exc_type;
  4193. tmp_value = exc_info->exc_value;
  4194. tmp_tb = exc_info->exc_traceback;
  4195. exc_info->exc_type = local_type;
  4196. exc_info->exc_value = local_value;
  4197. exc_info->exc_traceback = local_tb;
  4198. }
  4199. #else
  4200. tmp_type = tstate->exc_type;
  4201. tmp_value = tstate->exc_value;
  4202. tmp_tb = tstate->exc_traceback;
  4203. tstate->exc_type = local_type;
  4204. tstate->exc_value = local_value;
  4205. tstate->exc_traceback = local_tb;
  4206. #endif
  4207. Py_XDECREF(tmp_type);
  4208. Py_XDECREF(tmp_value);
  4209. Py_XDECREF(tmp_tb);
  4210. #else
  4211. PyErr_SetExcInfo(local_type, local_value, local_tb);
  4212. #endif
  4213. return 0;
  4214. bad:
  4215. *type = 0;
  4216. *value = 0;
  4217. *tb = 0;
  4218. Py_XDECREF(local_type);
  4219. Py_XDECREF(local_value);
  4220. Py_XDECREF(local_tb);
  4221. return -1;
  4222. }
  4223. /* SwapException */
  4224. #if CYTHON_FAST_THREAD_STATE
  4225. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  4226. PyObject *tmp_type, *tmp_value, *tmp_tb;
  4227. #if CYTHON_USE_EXC_INFO_STACK
  4228. _PyErr_StackItem *exc_info = tstate->exc_info;
  4229. tmp_type = exc_info->exc_type;
  4230. tmp_value = exc_info->exc_value;
  4231. tmp_tb = exc_info->exc_traceback;
  4232. exc_info->exc_type = *type;
  4233. exc_info->exc_value = *value;
  4234. exc_info->exc_traceback = *tb;
  4235. #else
  4236. tmp_type = tstate->exc_type;
  4237. tmp_value = tstate->exc_value;
  4238. tmp_tb = tstate->exc_traceback;
  4239. tstate->exc_type = *type;
  4240. tstate->exc_value = *value;
  4241. tstate->exc_traceback = *tb;
  4242. #endif
  4243. *type = tmp_type;
  4244. *value = tmp_value;
  4245. *tb = tmp_tb;
  4246. }
  4247. #else
  4248. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
  4249. PyObject *tmp_type, *tmp_value, *tmp_tb;
  4250. PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
  4251. PyErr_SetExcInfo(*type, *value, *tb);
  4252. *type = tmp_type;
  4253. *value = tmp_value;
  4254. *tb = tmp_tb;
  4255. }
  4256. #endif
  4257. /* GetTopmostException */
  4258. #if CYTHON_USE_EXC_INFO_STACK
  4259. static _PyErr_StackItem *
  4260. __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
  4261. {
  4262. _PyErr_StackItem *exc_info = tstate->exc_info;
  4263. while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
  4264. exc_info->previous_item != NULL)
  4265. {
  4266. exc_info = exc_info->previous_item;
  4267. }
  4268. return exc_info;
  4269. }
  4270. #endif
  4271. /* SaveResetException */
  4272. #if CYTHON_FAST_THREAD_STATE
  4273. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  4274. #if CYTHON_USE_EXC_INFO_STACK
  4275. _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
  4276. *type = exc_info->exc_type;
  4277. *value = exc_info->exc_value;
  4278. *tb = exc_info->exc_traceback;
  4279. #else
  4280. *type = tstate->exc_type;
  4281. *value = tstate->exc_value;
  4282. *tb = tstate->exc_traceback;
  4283. #endif
  4284. Py_XINCREF(*type);
  4285. Py_XINCREF(*value);
  4286. Py_XINCREF(*tb);
  4287. }
  4288. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  4289. PyObject *tmp_type, *tmp_value, *tmp_tb;
  4290. #if CYTHON_USE_EXC_INFO_STACK
  4291. _PyErr_StackItem *exc_info = tstate->exc_info;
  4292. tmp_type = exc_info->exc_type;
  4293. tmp_value = exc_info->exc_value;
  4294. tmp_tb = exc_info->exc_traceback;
  4295. exc_info->exc_type = type;
  4296. exc_info->exc_value = value;
  4297. exc_info->exc_traceback = tb;
  4298. #else
  4299. tmp_type = tstate->exc_type;
  4300. tmp_value = tstate->exc_value;
  4301. tmp_tb = tstate->exc_traceback;
  4302. tstate->exc_type = type;
  4303. tstate->exc_value = value;
  4304. tstate->exc_traceback = tb;
  4305. #endif
  4306. Py_XDECREF(tmp_type);
  4307. Py_XDECREF(tmp_value);
  4308. Py_XDECREF(tmp_tb);
  4309. }
  4310. #endif
  4311. /* PyObject_GenericGetAttrNoDict */
  4312. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  4313. static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
  4314. PyErr_Format(PyExc_AttributeError,
  4315. #if PY_MAJOR_VERSION >= 3
  4316. "'%.50s' object has no attribute '%U'",
  4317. tp->tp_name, attr_name);
  4318. #else
  4319. "'%.50s' object has no attribute '%.400s'",
  4320. tp->tp_name, PyString_AS_STRING(attr_name));
  4321. #endif
  4322. return NULL;
  4323. }
  4324. static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
  4325. PyObject *descr;
  4326. PyTypeObject *tp = Py_TYPE(obj);
  4327. if (unlikely(!PyString_Check(attr_name))) {
  4328. return PyObject_GenericGetAttr(obj, attr_name);
  4329. }
  4330. assert(!tp->tp_dictoffset);
  4331. descr = _PyType_Lookup(tp, attr_name);
  4332. if (unlikely(!descr)) {
  4333. return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
  4334. }
  4335. Py_INCREF(descr);
  4336. #if PY_MAJOR_VERSION < 3
  4337. if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
  4338. #endif
  4339. {
  4340. descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
  4341. if (unlikely(f)) {
  4342. PyObject *res = f(descr, obj, (PyObject *)tp);
  4343. Py_DECREF(descr);
  4344. return res;
  4345. }
  4346. }
  4347. return descr;
  4348. }
  4349. #endif
  4350. /* PyObject_GenericGetAttr */
  4351. #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
  4352. static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
  4353. if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
  4354. return PyObject_GenericGetAttr(obj, attr_name);
  4355. }
  4356. return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
  4357. }
  4358. #endif
  4359. /* PyErrExceptionMatches */
  4360. #if CYTHON_FAST_THREAD_STATE
  4361. static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  4362. Py_ssize_t i, n;
  4363. n = PyTuple_GET_SIZE(tuple);
  4364. #if PY_MAJOR_VERSION >= 3
  4365. for (i=0; i<n; i++) {
  4366. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  4367. }
  4368. #endif
  4369. for (i=0; i<n; i++) {
  4370. if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
  4371. }
  4372. return 0;
  4373. }
  4374. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
  4375. PyObject *exc_type = tstate->curexc_type;
  4376. if (exc_type == err) return 1;
  4377. if (unlikely(!exc_type)) return 0;
  4378. if (unlikely(PyTuple_Check(err)))
  4379. return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
  4380. return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
  4381. }
  4382. #endif
  4383. /* PyObjectGetAttrStrNoError */
  4384. static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
  4385. __Pyx_PyThreadState_declare
  4386. __Pyx_PyThreadState_assign
  4387. if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
  4388. __Pyx_PyErr_Clear();
  4389. }
  4390. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
  4391. PyObject *result;
  4392. #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
  4393. PyTypeObject* tp = Py_TYPE(obj);
  4394. if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
  4395. return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
  4396. }
  4397. #endif
  4398. result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
  4399. if (unlikely(!result)) {
  4400. __Pyx_PyObject_GetAttrStr_ClearAttributeError();
  4401. }
  4402. return result;
  4403. }
  4404. /* SetupReduce */
  4405. static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  4406. int ret;
  4407. PyObject *name_attr;
  4408. name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  4409. if (likely(name_attr)) {
  4410. ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  4411. } else {
  4412. ret = -1;
  4413. }
  4414. if (unlikely(ret < 0)) {
  4415. PyErr_Clear();
  4416. ret = 0;
  4417. }
  4418. Py_XDECREF(name_attr);
  4419. return ret;
  4420. }
  4421. static int __Pyx_setup_reduce(PyObject* type_obj) {
  4422. int ret = 0;
  4423. PyObject *object_reduce = NULL;
  4424. PyObject *object_reduce_ex = NULL;
  4425. PyObject *reduce = NULL;
  4426. PyObject *reduce_ex = NULL;
  4427. PyObject *reduce_cython = NULL;
  4428. PyObject *setstate = NULL;
  4429. PyObject *setstate_cython = NULL;
  4430. #if CYTHON_USE_PYTYPE_LOOKUP
  4431. if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
  4432. #else
  4433. if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
  4434. #endif
  4435. #if CYTHON_USE_PYTYPE_LOOKUP
  4436. object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
  4437. #else
  4438. object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
  4439. #endif
  4440. reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
  4441. if (reduce_ex == object_reduce_ex) {
  4442. #if CYTHON_USE_PYTYPE_LOOKUP
  4443. object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
  4444. #else
  4445. object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
  4446. #endif
  4447. reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
  4448. if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
  4449. reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
  4450. if (likely(reduce_cython)) {
  4451. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
  4452. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
  4453. } else if (reduce == object_reduce || PyErr_Occurred()) {
  4454. goto __PYX_BAD;
  4455. }
  4456. setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
  4457. if (!setstate) PyErr_Clear();
  4458. if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
  4459. setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
  4460. if (likely(setstate_cython)) {
  4461. ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
  4462. ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
  4463. } else if (!setstate || PyErr_Occurred()) {
  4464. goto __PYX_BAD;
  4465. }
  4466. }
  4467. PyType_Modified((PyTypeObject*)type_obj);
  4468. }
  4469. }
  4470. goto __PYX_GOOD;
  4471. __PYX_BAD:
  4472. if (!PyErr_Occurred())
  4473. PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
  4474. ret = -1;
  4475. __PYX_GOOD:
  4476. #if !CYTHON_USE_PYTYPE_LOOKUP
  4477. Py_XDECREF(object_reduce);
  4478. Py_XDECREF(object_reduce_ex);
  4479. #endif
  4480. Py_XDECREF(reduce);
  4481. Py_XDECREF(reduce_ex);
  4482. Py_XDECREF(reduce_cython);
  4483. Py_XDECREF(setstate);
  4484. Py_XDECREF(setstate_cython);
  4485. return ret;
  4486. }
  4487. /* TypeImport */
  4488. #ifndef __PYX_HAVE_RT_ImportType
  4489. #define __PYX_HAVE_RT_ImportType
  4490. static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
  4491. size_t size, enum __Pyx_ImportType_CheckSize check_size)
  4492. {
  4493. PyObject *result = 0;
  4494. char warning[200];
  4495. Py_ssize_t basicsize;
  4496. #ifdef Py_LIMITED_API
  4497. PyObject *py_basicsize;
  4498. #endif
  4499. result = PyObject_GetAttrString(module, class_name);
  4500. if (!result)
  4501. goto bad;
  4502. if (!PyType_Check(result)) {
  4503. PyErr_Format(PyExc_TypeError,
  4504. "%.200s.%.200s is not a type object",
  4505. module_name, class_name);
  4506. goto bad;
  4507. }
  4508. #ifndef Py_LIMITED_API
  4509. basicsize = ((PyTypeObject *)result)->tp_basicsize;
  4510. #else
  4511. py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
  4512. if (!py_basicsize)
  4513. goto bad;
  4514. basicsize = PyLong_AsSsize_t(py_basicsize);
  4515. Py_DECREF(py_basicsize);
  4516. py_basicsize = 0;
  4517. if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
  4518. goto bad;
  4519. #endif
  4520. if ((size_t)basicsize < size) {
  4521. PyErr_Format(PyExc_ValueError,
  4522. "%.200s.%.200s size changed, may indicate binary incompatibility. "
  4523. "Expected %zd from C header, got %zd from PyObject",
  4524. module_name, class_name, size, basicsize);
  4525. goto bad;
  4526. }
  4527. if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
  4528. PyErr_Format(PyExc_ValueError,
  4529. "%.200s.%.200s size changed, may indicate binary incompatibility. "
  4530. "Expected %zd from C header, got %zd from PyObject",
  4531. module_name, class_name, size, basicsize);
  4532. goto bad;
  4533. }
  4534. else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
  4535. PyOS_snprintf(warning, sizeof(warning),
  4536. "%s.%s size changed, may indicate binary incompatibility. "
  4537. "Expected %zd from C header, got %zd from PyObject",
  4538. module_name, class_name, size, basicsize);
  4539. if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
  4540. }
  4541. return (PyTypeObject *)result;
  4542. bad:
  4543. Py_XDECREF(result);
  4544. return NULL;
  4545. }
  4546. #endif
  4547. /* Import */
  4548. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  4549. PyObject *empty_list = 0;
  4550. PyObject *module = 0;
  4551. PyObject *global_dict = 0;
  4552. PyObject *empty_dict = 0;
  4553. PyObject *list;
  4554. #if PY_MAJOR_VERSION < 3
  4555. PyObject *py_import;
  4556. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  4557. if (!py_import)
  4558. goto bad;
  4559. #endif
  4560. if (from_list)
  4561. list = from_list;
  4562. else {
  4563. empty_list = PyList_New(0);
  4564. if (!empty_list)
  4565. goto bad;
  4566. list = empty_list;
  4567. }
  4568. global_dict = PyModule_GetDict(__pyx_m);
  4569. if (!global_dict)
  4570. goto bad;
  4571. empty_dict = PyDict_New();
  4572. if (!empty_dict)
  4573. goto bad;
  4574. {
  4575. #if PY_MAJOR_VERSION >= 3
  4576. if (level == -1) {
  4577. if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
  4578. module = PyImport_ImportModuleLevelObject(
  4579. name, global_dict, empty_dict, list, 1);
  4580. if (!module) {
  4581. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  4582. goto bad;
  4583. PyErr_Clear();
  4584. }
  4585. }
  4586. level = 0;
  4587. }
  4588. #endif
  4589. if (!module) {
  4590. #if PY_MAJOR_VERSION < 3
  4591. PyObject *py_level = PyInt_FromLong(level);
  4592. if (!py_level)
  4593. goto bad;
  4594. module = PyObject_CallFunctionObjArgs(py_import,
  4595. name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
  4596. Py_DECREF(py_level);
  4597. #else
  4598. module = PyImport_ImportModuleLevelObject(
  4599. name, global_dict, empty_dict, list, level);
  4600. #endif
  4601. }
  4602. }
  4603. bad:
  4604. #if PY_MAJOR_VERSION < 3
  4605. Py_XDECREF(py_import);
  4606. #endif
  4607. Py_XDECREF(empty_list);
  4608. Py_XDECREF(empty_dict);
  4609. return module;
  4610. }
  4611. /* ImportFrom */
  4612. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  4613. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  4614. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  4615. PyErr_Format(PyExc_ImportError,
  4616. #if PY_MAJOR_VERSION < 3
  4617. "cannot import name %.230s", PyString_AS_STRING(name));
  4618. #else
  4619. "cannot import name %S", name);
  4620. #endif
  4621. }
  4622. return value;
  4623. }
  4624. /* CLineInTraceback */
  4625. #ifndef CYTHON_CLINE_IN_TRACEBACK
  4626. static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
  4627. PyObject *use_cline;
  4628. PyObject *ptype, *pvalue, *ptraceback;
  4629. #if CYTHON_COMPILING_IN_CPYTHON
  4630. PyObject **cython_runtime_dict;
  4631. #endif
  4632. if (unlikely(!__pyx_cython_runtime)) {
  4633. return c_line;
  4634. }
  4635. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  4636. #if CYTHON_COMPILING_IN_CPYTHON
  4637. cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
  4638. if (likely(cython_runtime_dict)) {
  4639. __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
  4640. use_cline, *cython_runtime_dict,
  4641. __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
  4642. } else
  4643. #endif
  4644. {
  4645. PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
  4646. if (use_cline_obj) {
  4647. use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
  4648. Py_DECREF(use_cline_obj);
  4649. } else {
  4650. PyErr_Clear();
  4651. use_cline = NULL;
  4652. }
  4653. }
  4654. if (!use_cline) {
  4655. c_line = 0;
  4656. (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
  4657. }
  4658. else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
  4659. c_line = 0;
  4660. }
  4661. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  4662. return c_line;
  4663. }
  4664. #endif
  4665. /* CodeObjectCache */
  4666. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  4667. int start = 0, mid = 0, end = count - 1;
  4668. if (end >= 0 && code_line > entries[end].code_line) {
  4669. return count;
  4670. }
  4671. while (start < end) {
  4672. mid = start + (end - start) / 2;
  4673. if (code_line < entries[mid].code_line) {
  4674. end = mid;
  4675. } else if (code_line > entries[mid].code_line) {
  4676. start = mid + 1;
  4677. } else {
  4678. return mid;
  4679. }
  4680. }
  4681. if (code_line <= entries[mid].code_line) {
  4682. return mid;
  4683. } else {
  4684. return mid + 1;
  4685. }
  4686. }
  4687. static PyCodeObject *__pyx_find_code_object(int code_line) {
  4688. PyCodeObject* code_object;
  4689. int pos;
  4690. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  4691. return NULL;
  4692. }
  4693. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  4694. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  4695. return NULL;
  4696. }
  4697. code_object = __pyx_code_cache.entries[pos].code_object;
  4698. Py_INCREF(code_object);
  4699. return code_object;
  4700. }
  4701. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  4702. int pos, i;
  4703. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  4704. if (unlikely(!code_line)) {
  4705. return;
  4706. }
  4707. if (unlikely(!entries)) {
  4708. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  4709. if (likely(entries)) {
  4710. __pyx_code_cache.entries = entries;
  4711. __pyx_code_cache.max_count = 64;
  4712. __pyx_code_cache.count = 1;
  4713. entries[0].code_line = code_line;
  4714. entries[0].code_object = code_object;
  4715. Py_INCREF(code_object);
  4716. }
  4717. return;
  4718. }
  4719. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  4720. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  4721. PyCodeObject* tmp = entries[pos].code_object;
  4722. entries[pos].code_object = code_object;
  4723. Py_DECREF(tmp);
  4724. return;
  4725. }
  4726. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  4727. int new_max = __pyx_code_cache.max_count + 64;
  4728. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  4729. __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
  4730. if (unlikely(!entries)) {
  4731. return;
  4732. }
  4733. __pyx_code_cache.entries = entries;
  4734. __pyx_code_cache.max_count = new_max;
  4735. }
  4736. for (i=__pyx_code_cache.count; i>pos; i--) {
  4737. entries[i] = entries[i-1];
  4738. }
  4739. entries[pos].code_line = code_line;
  4740. entries[pos].code_object = code_object;
  4741. __pyx_code_cache.count++;
  4742. Py_INCREF(code_object);
  4743. }
  4744. /* AddTraceback */
  4745. #include "compile.h"
  4746. #include "frameobject.h"
  4747. #include "traceback.h"
  4748. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  4749. const char *funcname, int c_line,
  4750. int py_line, const char *filename) {
  4751. PyCodeObject *py_code = NULL;
  4752. PyObject *py_funcname = NULL;
  4753. #if PY_MAJOR_VERSION < 3
  4754. PyObject *py_srcfile = NULL;
  4755. py_srcfile = PyString_FromString(filename);
  4756. if (!py_srcfile) goto bad;
  4757. #endif
  4758. if (c_line) {
  4759. #if PY_MAJOR_VERSION < 3
  4760. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  4761. if (!py_funcname) goto bad;
  4762. #else
  4763. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  4764. if (!py_funcname) goto bad;
  4765. funcname = PyUnicode_AsUTF8(py_funcname);
  4766. if (!funcname) goto bad;
  4767. #endif
  4768. }
  4769. else {
  4770. #if PY_MAJOR_VERSION < 3
  4771. py_funcname = PyString_FromString(funcname);
  4772. if (!py_funcname) goto bad;
  4773. #endif
  4774. }
  4775. #if PY_MAJOR_VERSION < 3
  4776. py_code = __Pyx_PyCode_New(
  4777. 0,
  4778. 0,
  4779. 0,
  4780. 0,
  4781. 0,
  4782. __pyx_empty_bytes, /*PyObject *code,*/
  4783. __pyx_empty_tuple, /*PyObject *consts,*/
  4784. __pyx_empty_tuple, /*PyObject *names,*/
  4785. __pyx_empty_tuple, /*PyObject *varnames,*/
  4786. __pyx_empty_tuple, /*PyObject *freevars,*/
  4787. __pyx_empty_tuple, /*PyObject *cellvars,*/
  4788. py_srcfile, /*PyObject *filename,*/
  4789. py_funcname, /*PyObject *name,*/
  4790. py_line,
  4791. __pyx_empty_bytes /*PyObject *lnotab*/
  4792. );
  4793. Py_DECREF(py_srcfile);
  4794. #else
  4795. py_code = PyCode_NewEmpty(filename, funcname, py_line);
  4796. #endif
  4797. Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline
  4798. return py_code;
  4799. bad:
  4800. Py_XDECREF(py_funcname);
  4801. #if PY_MAJOR_VERSION < 3
  4802. Py_XDECREF(py_srcfile);
  4803. #endif
  4804. return NULL;
  4805. }
  4806. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  4807. int py_line, const char *filename) {
  4808. PyCodeObject *py_code = 0;
  4809. PyFrameObject *py_frame = 0;
  4810. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  4811. if (c_line) {
  4812. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  4813. }
  4814. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  4815. if (!py_code) {
  4816. py_code = __Pyx_CreateCodeObjectForTraceback(
  4817. funcname, c_line, py_line, filename);
  4818. if (!py_code) goto bad;
  4819. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  4820. }
  4821. py_frame = PyFrame_New(
  4822. tstate, /*PyThreadState *tstate,*/
  4823. py_code, /*PyCodeObject *code,*/
  4824. __pyx_d, /*PyObject *globals,*/
  4825. 0 /*PyObject *locals*/
  4826. );
  4827. if (!py_frame) goto bad;
  4828. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  4829. PyTraceBack_Here(py_frame);
  4830. bad:
  4831. Py_XDECREF(py_code);
  4832. Py_XDECREF(py_frame);
  4833. }
  4834. /* CIntToPy */
  4835. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_uint16_t(uint16_t value) {
  4836. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  4837. #pragma GCC diagnostic push
  4838. #pragma GCC diagnostic ignored "-Wconversion"
  4839. #endif
  4840. const uint16_t neg_one = (uint16_t) -1, const_zero = (uint16_t) 0;
  4841. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  4842. #pragma GCC diagnostic pop
  4843. #endif
  4844. const int is_unsigned = neg_one > const_zero;
  4845. if (is_unsigned) {
  4846. if (sizeof(uint16_t) < sizeof(long)) {
  4847. return PyInt_FromLong((long) value);
  4848. } else if (sizeof(uint16_t) <= sizeof(unsigned long)) {
  4849. return PyLong_FromUnsignedLong((unsigned long) value);
  4850. #ifdef HAVE_LONG_LONG
  4851. } else if (sizeof(uint16_t) <= sizeof(unsigned PY_LONG_LONG)) {
  4852. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  4853. #endif
  4854. }
  4855. } else {
  4856. if (sizeof(uint16_t) <= sizeof(long)) {
  4857. return PyInt_FromLong((long) value);
  4858. #ifdef HAVE_LONG_LONG
  4859. } else if (sizeof(uint16_t) <= sizeof(PY_LONG_LONG)) {
  4860. return PyLong_FromLongLong((PY_LONG_LONG) value);
  4861. #endif
  4862. }
  4863. }
  4864. {
  4865. int one = 1; int little = (int)*(unsigned char *)&one;
  4866. unsigned char *bytes = (unsigned char *)&value;
  4867. return _PyLong_FromByteArray(bytes, sizeof(uint16_t),
  4868. little, !is_unsigned);
  4869. }
  4870. }
  4871. /* CIntToPy */
  4872. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  4873. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  4874. #pragma GCC diagnostic push
  4875. #pragma GCC diagnostic ignored "-Wconversion"
  4876. #endif
  4877. const long neg_one = (long) -1, const_zero = (long) 0;
  4878. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  4879. #pragma GCC diagnostic pop
  4880. #endif
  4881. const int is_unsigned = neg_one > const_zero;
  4882. if (is_unsigned) {
  4883. if (sizeof(long) < sizeof(long)) {
  4884. return PyInt_FromLong((long) value);
  4885. } else if (sizeof(long) <= sizeof(unsigned long)) {
  4886. return PyLong_FromUnsignedLong((unsigned long) value);
  4887. #ifdef HAVE_LONG_LONG
  4888. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  4889. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  4890. #endif
  4891. }
  4892. } else {
  4893. if (sizeof(long) <= sizeof(long)) {
  4894. return PyInt_FromLong((long) value);
  4895. #ifdef HAVE_LONG_LONG
  4896. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  4897. return PyLong_FromLongLong((PY_LONG_LONG) value);
  4898. #endif
  4899. }
  4900. }
  4901. {
  4902. int one = 1; int little = (int)*(unsigned char *)&one;
  4903. unsigned char *bytes = (unsigned char *)&value;
  4904. return _PyLong_FromByteArray(bytes, sizeof(long),
  4905. little, !is_unsigned);
  4906. }
  4907. }
  4908. /* CIntFromPyVerify */
  4909. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  4910. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  4911. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  4912. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  4913. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  4914. {\
  4915. func_type value = func_value;\
  4916. if (sizeof(target_type) < sizeof(func_type)) {\
  4917. if (unlikely(value != (func_type) (target_type) value)) {\
  4918. func_type zero = 0;\
  4919. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  4920. return (target_type) -1;\
  4921. if (is_unsigned && unlikely(value < zero))\
  4922. goto raise_neg_overflow;\
  4923. else\
  4924. goto raise_overflow;\
  4925. }\
  4926. }\
  4927. return (target_type) value;\
  4928. }
  4929. /* CIntFromPy */
  4930. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  4931. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  4932. #pragma GCC diagnostic push
  4933. #pragma GCC diagnostic ignored "-Wconversion"
  4934. #endif
  4935. const long neg_one = (long) -1, const_zero = (long) 0;
  4936. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  4937. #pragma GCC diagnostic pop
  4938. #endif
  4939. const int is_unsigned = neg_one > const_zero;
  4940. #if PY_MAJOR_VERSION < 3
  4941. if (likely(PyInt_Check(x))) {
  4942. if (sizeof(long) < sizeof(long)) {
  4943. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  4944. } else {
  4945. long val = PyInt_AS_LONG(x);
  4946. if (is_unsigned && unlikely(val < 0)) {
  4947. goto raise_neg_overflow;
  4948. }
  4949. return (long) val;
  4950. }
  4951. } else
  4952. #endif
  4953. if (likely(PyLong_Check(x))) {
  4954. if (is_unsigned) {
  4955. #if CYTHON_USE_PYLONG_INTERNALS
  4956. const digit* digits = ((PyLongObject*)x)->ob_digit;
  4957. switch (Py_SIZE(x)) {
  4958. case 0: return (long) 0;
  4959. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  4960. case 2:
  4961. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  4962. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  4963. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  4964. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  4965. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  4966. }
  4967. }
  4968. break;
  4969. case 3:
  4970. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  4971. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  4972. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  4973. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  4974. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  4975. }
  4976. }
  4977. break;
  4978. case 4:
  4979. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  4980. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  4981. __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])))
  4982. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  4983. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  4984. }
  4985. }
  4986. break;
  4987. }
  4988. #endif
  4989. #if CYTHON_COMPILING_IN_CPYTHON
  4990. if (unlikely(Py_SIZE(x) < 0)) {
  4991. goto raise_neg_overflow;
  4992. }
  4993. #else
  4994. {
  4995. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  4996. if (unlikely(result < 0))
  4997. return (long) -1;
  4998. if (unlikely(result == 1))
  4999. goto raise_neg_overflow;
  5000. }
  5001. #endif
  5002. if (sizeof(long) <= sizeof(unsigned long)) {
  5003. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  5004. #ifdef HAVE_LONG_LONG
  5005. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  5006. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  5007. #endif
  5008. }
  5009. } else {
  5010. #if CYTHON_USE_PYLONG_INTERNALS
  5011. const digit* digits = ((PyLongObject*)x)->ob_digit;
  5012. switch (Py_SIZE(x)) {
  5013. case 0: return (long) 0;
  5014. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  5015. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  5016. case -2:
  5017. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  5018. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5019. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5020. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  5021. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  5022. }
  5023. }
  5024. break;
  5025. case 2:
  5026. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  5027. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5028. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5029. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  5030. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  5031. }
  5032. }
  5033. break;
  5034. case -3:
  5035. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  5036. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5037. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5038. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  5039. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  5040. }
  5041. }
  5042. break;
  5043. case 3:
  5044. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  5045. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5046. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5047. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  5048. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  5049. }
  5050. }
  5051. break;
  5052. case -4:
  5053. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  5054. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5055. __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])))
  5056. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  5057. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  5058. }
  5059. }
  5060. break;
  5061. case 4:
  5062. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  5063. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5064. __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])))
  5065. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  5066. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  5067. }
  5068. }
  5069. break;
  5070. }
  5071. #endif
  5072. if (sizeof(long) <= sizeof(long)) {
  5073. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  5074. #ifdef HAVE_LONG_LONG
  5075. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  5076. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  5077. #endif
  5078. }
  5079. }
  5080. {
  5081. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  5082. PyErr_SetString(PyExc_RuntimeError,
  5083. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  5084. #else
  5085. long val;
  5086. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  5087. #if PY_MAJOR_VERSION < 3
  5088. if (likely(v) && !PyLong_Check(v)) {
  5089. PyObject *tmp = v;
  5090. v = PyNumber_Long(tmp);
  5091. Py_DECREF(tmp);
  5092. }
  5093. #endif
  5094. if (likely(v)) {
  5095. int one = 1; int is_little = (int)*(unsigned char *)&one;
  5096. unsigned char *bytes = (unsigned char *)&val;
  5097. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  5098. bytes, sizeof(val),
  5099. is_little, !is_unsigned);
  5100. Py_DECREF(v);
  5101. if (likely(!ret))
  5102. return val;
  5103. }
  5104. #endif
  5105. return (long) -1;
  5106. }
  5107. } else {
  5108. long val;
  5109. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  5110. if (!tmp) return (long) -1;
  5111. val = __Pyx_PyInt_As_long(tmp);
  5112. Py_DECREF(tmp);
  5113. return val;
  5114. }
  5115. raise_overflow:
  5116. PyErr_SetString(PyExc_OverflowError,
  5117. "value too large to convert to long");
  5118. return (long) -1;
  5119. raise_neg_overflow:
  5120. PyErr_SetString(PyExc_OverflowError,
  5121. "can't convert negative value to long");
  5122. return (long) -1;
  5123. }
  5124. /* CIntFromPy */
  5125. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  5126. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  5127. #pragma GCC diagnostic push
  5128. #pragma GCC diagnostic ignored "-Wconversion"
  5129. #endif
  5130. const int neg_one = (int) -1, const_zero = (int) 0;
  5131. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  5132. #pragma GCC diagnostic pop
  5133. #endif
  5134. const int is_unsigned = neg_one > const_zero;
  5135. #if PY_MAJOR_VERSION < 3
  5136. if (likely(PyInt_Check(x))) {
  5137. if (sizeof(int) < sizeof(long)) {
  5138. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  5139. } else {
  5140. long val = PyInt_AS_LONG(x);
  5141. if (is_unsigned && unlikely(val < 0)) {
  5142. goto raise_neg_overflow;
  5143. }
  5144. return (int) val;
  5145. }
  5146. } else
  5147. #endif
  5148. if (likely(PyLong_Check(x))) {
  5149. if (is_unsigned) {
  5150. #if CYTHON_USE_PYLONG_INTERNALS
  5151. const digit* digits = ((PyLongObject*)x)->ob_digit;
  5152. switch (Py_SIZE(x)) {
  5153. case 0: return (int) 0;
  5154. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  5155. case 2:
  5156. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  5157. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5158. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5159. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  5160. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  5161. }
  5162. }
  5163. break;
  5164. case 3:
  5165. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  5166. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5167. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5168. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  5169. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  5170. }
  5171. }
  5172. break;
  5173. case 4:
  5174. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  5175. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5176. __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])))
  5177. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  5178. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  5179. }
  5180. }
  5181. break;
  5182. }
  5183. #endif
  5184. #if CYTHON_COMPILING_IN_CPYTHON
  5185. if (unlikely(Py_SIZE(x) < 0)) {
  5186. goto raise_neg_overflow;
  5187. }
  5188. #else
  5189. {
  5190. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  5191. if (unlikely(result < 0))
  5192. return (int) -1;
  5193. if (unlikely(result == 1))
  5194. goto raise_neg_overflow;
  5195. }
  5196. #endif
  5197. if (sizeof(int) <= sizeof(unsigned long)) {
  5198. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  5199. #ifdef HAVE_LONG_LONG
  5200. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  5201. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  5202. #endif
  5203. }
  5204. } else {
  5205. #if CYTHON_USE_PYLONG_INTERNALS
  5206. const digit* digits = ((PyLongObject*)x)->ob_digit;
  5207. switch (Py_SIZE(x)) {
  5208. case 0: return (int) 0;
  5209. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  5210. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  5211. case -2:
  5212. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  5213. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5214. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5215. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  5216. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  5217. }
  5218. }
  5219. break;
  5220. case 2:
  5221. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  5222. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  5223. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5224. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  5225. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  5226. }
  5227. }
  5228. break;
  5229. case -3:
  5230. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  5231. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5232. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5233. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  5234. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  5235. }
  5236. }
  5237. break;
  5238. case 3:
  5239. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  5240. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  5241. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  5242. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  5243. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  5244. }
  5245. }
  5246. break;
  5247. case -4:
  5248. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  5249. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5250. __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])))
  5251. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  5252. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  5253. }
  5254. }
  5255. break;
  5256. case 4:
  5257. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  5258. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  5259. __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])))
  5260. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  5261. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  5262. }
  5263. }
  5264. break;
  5265. }
  5266. #endif
  5267. if (sizeof(int) <= sizeof(long)) {
  5268. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  5269. #ifdef HAVE_LONG_LONG
  5270. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  5271. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  5272. #endif
  5273. }
  5274. }
  5275. {
  5276. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  5277. PyErr_SetString(PyExc_RuntimeError,
  5278. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  5279. #else
  5280. int val;
  5281. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  5282. #if PY_MAJOR_VERSION < 3
  5283. if (likely(v) && !PyLong_Check(v)) {
  5284. PyObject *tmp = v;
  5285. v = PyNumber_Long(tmp);
  5286. Py_DECREF(tmp);
  5287. }
  5288. #endif
  5289. if (likely(v)) {
  5290. int one = 1; int is_little = (int)*(unsigned char *)&one;
  5291. unsigned char *bytes = (unsigned char *)&val;
  5292. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  5293. bytes, sizeof(val),
  5294. is_little, !is_unsigned);
  5295. Py_DECREF(v);
  5296. if (likely(!ret))
  5297. return val;
  5298. }
  5299. #endif
  5300. return (int) -1;
  5301. }
  5302. } else {
  5303. int val;
  5304. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  5305. if (!tmp) return (int) -1;
  5306. val = __Pyx_PyInt_As_int(tmp);
  5307. Py_DECREF(tmp);
  5308. return val;
  5309. }
  5310. raise_overflow:
  5311. PyErr_SetString(PyExc_OverflowError,
  5312. "value too large to convert to int");
  5313. return (int) -1;
  5314. raise_neg_overflow:
  5315. PyErr_SetString(PyExc_OverflowError,
  5316. "can't convert negative value to int");
  5317. return (int) -1;
  5318. }
  5319. /* FastTypeChecks */
  5320. #if CYTHON_COMPILING_IN_CPYTHON
  5321. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  5322. while (a) {
  5323. a = a->tp_base;
  5324. if (a == b)
  5325. return 1;
  5326. }
  5327. return b == &PyBaseObject_Type;
  5328. }
  5329. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  5330. PyObject *mro;
  5331. if (a == b) return 1;
  5332. mro = a->tp_mro;
  5333. if (likely(mro)) {
  5334. Py_ssize_t i, n;
  5335. n = PyTuple_GET_SIZE(mro);
  5336. for (i = 0; i < n; i++) {
  5337. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  5338. return 1;
  5339. }
  5340. return 0;
  5341. }
  5342. return __Pyx_InBases(a, b);
  5343. }
  5344. #if PY_MAJOR_VERSION == 2
  5345. static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
  5346. PyObject *exception, *value, *tb;
  5347. int res;
  5348. __Pyx_PyThreadState_declare
  5349. __Pyx_PyThreadState_assign
  5350. __Pyx_ErrFetch(&exception, &value, &tb);
  5351. res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
  5352. if (unlikely(res == -1)) {
  5353. PyErr_WriteUnraisable(err);
  5354. res = 0;
  5355. }
  5356. if (!res) {
  5357. res = PyObject_IsSubclass(err, exc_type2);
  5358. if (unlikely(res == -1)) {
  5359. PyErr_WriteUnraisable(err);
  5360. res = 0;
  5361. }
  5362. }
  5363. __Pyx_ErrRestore(exception, value, tb);
  5364. return res;
  5365. }
  5366. #else
  5367. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  5368. int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
  5369. if (!res) {
  5370. res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  5371. }
  5372. return res;
  5373. }
  5374. #endif
  5375. static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  5376. Py_ssize_t i, n;
  5377. assert(PyExceptionClass_Check(exc_type));
  5378. n = PyTuple_GET_SIZE(tuple);
  5379. #if PY_MAJOR_VERSION >= 3
  5380. for (i=0; i<n; i++) {
  5381. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  5382. }
  5383. #endif
  5384. for (i=0; i<n; i++) {
  5385. PyObject *t = PyTuple_GET_ITEM(tuple, i);
  5386. #if PY_MAJOR_VERSION < 3
  5387. if (likely(exc_type == t)) return 1;
  5388. #endif
  5389. if (likely(PyExceptionClass_Check(t))) {
  5390. if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
  5391. } else {
  5392. }
  5393. }
  5394. return 0;
  5395. }
  5396. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  5397. if (likely(err == exc_type)) return 1;
  5398. if (likely(PyExceptionClass_Check(err))) {
  5399. if (likely(PyExceptionClass_Check(exc_type))) {
  5400. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  5401. } else if (likely(PyTuple_Check(exc_type))) {
  5402. return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
  5403. } else {
  5404. }
  5405. }
  5406. return PyErr_GivenExceptionMatches(err, exc_type);
  5407. }
  5408. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  5409. assert(PyExceptionClass_Check(exc_type1));
  5410. assert(PyExceptionClass_Check(exc_type2));
  5411. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  5412. if (likely(PyExceptionClass_Check(err))) {
  5413. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  5414. }
  5415. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  5416. }
  5417. #endif
  5418. /* CheckBinaryVersion */
  5419. static int __Pyx_check_binary_version(void) {
  5420. char ctversion[4], rtversion[4];
  5421. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  5422. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  5423. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  5424. char message[200];
  5425. PyOS_snprintf(message, sizeof(message),
  5426. "compiletime version %s of module '%.100s' "
  5427. "does not match runtime version %s",
  5428. ctversion, __Pyx_MODULE_NAME, rtversion);
  5429. return PyErr_WarnEx(NULL, message, 1);
  5430. }
  5431. return 0;
  5432. }
  5433. /* InitStrings */
  5434. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  5435. while (t->p) {
  5436. #if PY_MAJOR_VERSION < 3
  5437. if (t->is_unicode) {
  5438. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  5439. } else if (t->intern) {
  5440. *t->p = PyString_InternFromString(t->s);
  5441. } else {
  5442. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  5443. }
  5444. #else
  5445. if (t->is_unicode | t->is_str) {
  5446. if (t->intern) {
  5447. *t->p = PyUnicode_InternFromString(t->s);
  5448. } else if (t->encoding) {
  5449. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  5450. } else {
  5451. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  5452. }
  5453. } else {
  5454. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  5455. }
  5456. #endif
  5457. if (!*t->p)
  5458. return -1;
  5459. if (PyObject_Hash(*t->p) == -1)
  5460. return -1;
  5461. ++t;
  5462. }
  5463. return 0;
  5464. }
  5465. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  5466. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  5467. }
  5468. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  5469. Py_ssize_t ignore;
  5470. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  5471. }
  5472. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  5473. #if !CYTHON_PEP393_ENABLED
  5474. static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  5475. char* defenc_c;
  5476. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  5477. if (!defenc) return NULL;
  5478. defenc_c = PyBytes_AS_STRING(defenc);
  5479. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  5480. {
  5481. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  5482. char* c;
  5483. for (c = defenc_c; c < end; c++) {
  5484. if ((unsigned char) (*c) >= 128) {
  5485. PyUnicode_AsASCIIString(o);
  5486. return NULL;
  5487. }
  5488. }
  5489. }
  5490. #endif
  5491. *length = PyBytes_GET_SIZE(defenc);
  5492. return defenc_c;
  5493. }
  5494. #else
  5495. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  5496. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  5497. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  5498. if (likely(PyUnicode_IS_ASCII(o))) {
  5499. *length = PyUnicode_GET_LENGTH(o);
  5500. return PyUnicode_AsUTF8(o);
  5501. } else {
  5502. PyUnicode_AsASCIIString(o);
  5503. return NULL;
  5504. }
  5505. #else
  5506. return PyUnicode_AsUTF8AndSize(o, length);
  5507. #endif
  5508. }
  5509. #endif
  5510. #endif
  5511. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  5512. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  5513. if (
  5514. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  5515. __Pyx_sys_getdefaultencoding_not_ascii &&
  5516. #endif
  5517. PyUnicode_Check(o)) {
  5518. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  5519. } else
  5520. #endif
  5521. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  5522. if (PyByteArray_Check(o)) {
  5523. *length = PyByteArray_GET_SIZE(o);
  5524. return PyByteArray_AS_STRING(o);
  5525. } else
  5526. #endif
  5527. {
  5528. char* result;
  5529. int r = PyBytes_AsStringAndSize(o, &result, length);
  5530. if (unlikely(r < 0)) {
  5531. return NULL;
  5532. } else {
  5533. return result;
  5534. }
  5535. }
  5536. }
  5537. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  5538. int is_true = x == Py_True;
  5539. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  5540. else return PyObject_IsTrue(x);
  5541. }
  5542. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
  5543. int retval;
  5544. if (unlikely(!x)) return -1;
  5545. retval = __Pyx_PyObject_IsTrue(x);
  5546. Py_DECREF(x);
  5547. return retval;
  5548. }
  5549. static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
  5550. #if PY_MAJOR_VERSION >= 3
  5551. if (PyLong_Check(result)) {
  5552. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  5553. "__int__ returned non-int (type %.200s). "
  5554. "The ability to return an instance of a strict subclass of int "
  5555. "is deprecated, and may be removed in a future version of Python.",
  5556. Py_TYPE(result)->tp_name)) {
  5557. Py_DECREF(result);
  5558. return NULL;
  5559. }
  5560. return result;
  5561. }
  5562. #endif
  5563. PyErr_Format(PyExc_TypeError,
  5564. "__%.4s__ returned non-%.4s (type %.200s)",
  5565. type_name, type_name, Py_TYPE(result)->tp_name);
  5566. Py_DECREF(result);
  5567. return NULL;
  5568. }
  5569. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  5570. #if CYTHON_USE_TYPE_SLOTS
  5571. PyNumberMethods *m;
  5572. #endif
  5573. const char *name = NULL;
  5574. PyObject *res = NULL;
  5575. #if PY_MAJOR_VERSION < 3
  5576. if (likely(PyInt_Check(x) || PyLong_Check(x)))
  5577. #else
  5578. if (likely(PyLong_Check(x)))
  5579. #endif
  5580. return __Pyx_NewRef(x);
  5581. #if CYTHON_USE_TYPE_SLOTS
  5582. m = Py_TYPE(x)->tp_as_number;
  5583. #if PY_MAJOR_VERSION < 3
  5584. if (m && m->nb_int) {
  5585. name = "int";
  5586. res = m->nb_int(x);
  5587. }
  5588. else if (m && m->nb_long) {
  5589. name = "long";
  5590. res = m->nb_long(x);
  5591. }
  5592. #else
  5593. if (likely(m && m->nb_int)) {
  5594. name = "int";
  5595. res = m->nb_int(x);
  5596. }
  5597. #endif
  5598. #else
  5599. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  5600. res = PyNumber_Int(x);
  5601. }
  5602. #endif
  5603. if (likely(res)) {
  5604. #if PY_MAJOR_VERSION < 3
  5605. if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
  5606. #else
  5607. if (unlikely(!PyLong_CheckExact(res))) {
  5608. #endif
  5609. return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
  5610. }
  5611. }
  5612. else if (!PyErr_Occurred()) {
  5613. PyErr_SetString(PyExc_TypeError,
  5614. "an integer is required");
  5615. }
  5616. return res;
  5617. }
  5618. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  5619. Py_ssize_t ival;
  5620. PyObject *x;
  5621. #if PY_MAJOR_VERSION < 3
  5622. if (likely(PyInt_CheckExact(b))) {
  5623. if (sizeof(Py_ssize_t) >= sizeof(long))
  5624. return PyInt_AS_LONG(b);
  5625. else
  5626. return PyInt_AsSsize_t(b);
  5627. }
  5628. #endif
  5629. if (likely(PyLong_CheckExact(b))) {
  5630. #if CYTHON_USE_PYLONG_INTERNALS
  5631. const digit* digits = ((PyLongObject*)b)->ob_digit;
  5632. const Py_ssize_t size = Py_SIZE(b);
  5633. if (likely(__Pyx_sst_abs(size) <= 1)) {
  5634. ival = likely(size) ? digits[0] : 0;
  5635. if (size == -1) ival = -ival;
  5636. return ival;
  5637. } else {
  5638. switch (size) {
  5639. case 2:
  5640. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  5641. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  5642. }
  5643. break;
  5644. case -2:
  5645. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  5646. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  5647. }
  5648. break;
  5649. case 3:
  5650. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  5651. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  5652. }
  5653. break;
  5654. case -3:
  5655. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  5656. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  5657. }
  5658. break;
  5659. case 4:
  5660. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  5661. 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]));
  5662. }
  5663. break;
  5664. case -4:
  5665. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  5666. 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]));
  5667. }
  5668. break;
  5669. }
  5670. }
  5671. #endif
  5672. return PyLong_AsSsize_t(b);
  5673. }
  5674. x = PyNumber_Index(b);
  5675. if (!x) return -1;
  5676. ival = PyInt_AsSsize_t(x);
  5677. Py_DECREF(x);
  5678. return ival;
  5679. }
  5680. static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
  5681. if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
  5682. return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
  5683. #if PY_MAJOR_VERSION < 3
  5684. } else if (likely(PyInt_CheckExact(o))) {
  5685. return PyInt_AS_LONG(o);
  5686. #endif
  5687. } else {
  5688. Py_ssize_t ival;
  5689. PyObject *x;
  5690. x = PyNumber_Index(o);
  5691. if (!x) return -1;
  5692. ival = PyInt_AsLong(x);
  5693. Py_DECREF(x);
  5694. return ival;
  5695. }
  5696. }
  5697. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  5698. return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
  5699. }
  5700. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  5701. return PyInt_FromSize_t(ival);
  5702. }
  5703. #endif /* Py_PYTHON_H */