gevent.ares.c 558 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103
  1. /* Generated by Cython 0.25.2 */
  2. #define PY_SSIZE_T_CLEAN
  3. #include "Python.h"
  4. #ifndef Py_PYTHON_H
  5. #error Python headers needed to compile C extensions, please install development version of Python.
  6. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
  7. #error Cython requires Python 2.6+ or Python 3.2+.
  8. #else
  9. #define CYTHON_ABI "0_25_2"
  10. #include <stddef.h>
  11. #ifndef offsetof
  12. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  13. #endif
  14. #if !defined(WIN32) && !defined(MS_WINDOWS)
  15. #ifndef __stdcall
  16. #define __stdcall
  17. #endif
  18. #ifndef __cdecl
  19. #define __cdecl
  20. #endif
  21. #ifndef __fastcall
  22. #define __fastcall
  23. #endif
  24. #endif
  25. #ifndef DL_IMPORT
  26. #define DL_IMPORT(t) t
  27. #endif
  28. #ifndef DL_EXPORT
  29. #define DL_EXPORT(t) t
  30. #endif
  31. #ifndef HAVE_LONG_LONG
  32. #if PY_VERSION_HEX >= 0x03030000 || (PY_MAJOR_VERSION == 2 && PY_VERSION_HEX >= 0x02070000)
  33. #define HAVE_LONG_LONG
  34. #endif
  35. #endif
  36. #ifndef PY_LONG_LONG
  37. #define PY_LONG_LONG LONG_LONG
  38. #endif
  39. #ifndef Py_HUGE_VAL
  40. #define Py_HUGE_VAL HUGE_VAL
  41. #endif
  42. #ifdef PYPY_VERSION
  43. #define CYTHON_COMPILING_IN_PYPY 1
  44. #define CYTHON_COMPILING_IN_PYSTON 0
  45. #define CYTHON_COMPILING_IN_CPYTHON 0
  46. #undef CYTHON_USE_TYPE_SLOTS
  47. #define CYTHON_USE_TYPE_SLOTS 0
  48. #undef CYTHON_USE_ASYNC_SLOTS
  49. #define CYTHON_USE_ASYNC_SLOTS 0
  50. #undef CYTHON_USE_PYLIST_INTERNALS
  51. #define CYTHON_USE_PYLIST_INTERNALS 0
  52. #undef CYTHON_USE_UNICODE_INTERNALS
  53. #define CYTHON_USE_UNICODE_INTERNALS 0
  54. #undef CYTHON_USE_UNICODE_WRITER
  55. #define CYTHON_USE_UNICODE_WRITER 0
  56. #undef CYTHON_USE_PYLONG_INTERNALS
  57. #define CYTHON_USE_PYLONG_INTERNALS 0
  58. #undef CYTHON_AVOID_BORROWED_REFS
  59. #define CYTHON_AVOID_BORROWED_REFS 1
  60. #undef CYTHON_ASSUME_SAFE_MACROS
  61. #define CYTHON_ASSUME_SAFE_MACROS 0
  62. #undef CYTHON_UNPACK_METHODS
  63. #define CYTHON_UNPACK_METHODS 0
  64. #undef CYTHON_FAST_THREAD_STATE
  65. #define CYTHON_FAST_THREAD_STATE 0
  66. #undef CYTHON_FAST_PYCALL
  67. #define CYTHON_FAST_PYCALL 0
  68. #elif defined(PYSTON_VERSION)
  69. #define CYTHON_COMPILING_IN_PYPY 0
  70. #define CYTHON_COMPILING_IN_PYSTON 1
  71. #define CYTHON_COMPILING_IN_CPYTHON 0
  72. #ifndef CYTHON_USE_TYPE_SLOTS
  73. #define CYTHON_USE_TYPE_SLOTS 1
  74. #endif
  75. #undef CYTHON_USE_ASYNC_SLOTS
  76. #define CYTHON_USE_ASYNC_SLOTS 0
  77. #undef CYTHON_USE_PYLIST_INTERNALS
  78. #define CYTHON_USE_PYLIST_INTERNALS 0
  79. #ifndef CYTHON_USE_UNICODE_INTERNALS
  80. #define CYTHON_USE_UNICODE_INTERNALS 1
  81. #endif
  82. #undef CYTHON_USE_UNICODE_WRITER
  83. #define CYTHON_USE_UNICODE_WRITER 0
  84. #undef CYTHON_USE_PYLONG_INTERNALS
  85. #define CYTHON_USE_PYLONG_INTERNALS 0
  86. #ifndef CYTHON_AVOID_BORROWED_REFS
  87. #define CYTHON_AVOID_BORROWED_REFS 0
  88. #endif
  89. #ifndef CYTHON_ASSUME_SAFE_MACROS
  90. #define CYTHON_ASSUME_SAFE_MACROS 1
  91. #endif
  92. #ifndef CYTHON_UNPACK_METHODS
  93. #define CYTHON_UNPACK_METHODS 1
  94. #endif
  95. #undef CYTHON_FAST_THREAD_STATE
  96. #define CYTHON_FAST_THREAD_STATE 0
  97. #undef CYTHON_FAST_PYCALL
  98. #define CYTHON_FAST_PYCALL 0
  99. #else
  100. #define CYTHON_COMPILING_IN_PYPY 0
  101. #define CYTHON_COMPILING_IN_PYSTON 0
  102. #define CYTHON_COMPILING_IN_CPYTHON 1
  103. #ifndef CYTHON_USE_TYPE_SLOTS
  104. #define CYTHON_USE_TYPE_SLOTS 1
  105. #endif
  106. #if PY_MAJOR_VERSION < 3
  107. #undef CYTHON_USE_ASYNC_SLOTS
  108. #define CYTHON_USE_ASYNC_SLOTS 0
  109. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  110. #define CYTHON_USE_ASYNC_SLOTS 1
  111. #endif
  112. #if PY_VERSION_HEX < 0x02070000
  113. #undef CYTHON_USE_PYLONG_INTERNALS
  114. #define CYTHON_USE_PYLONG_INTERNALS 0
  115. #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
  116. #define CYTHON_USE_PYLONG_INTERNALS 1
  117. #endif
  118. #ifndef CYTHON_USE_PYLIST_INTERNALS
  119. #define CYTHON_USE_PYLIST_INTERNALS 1
  120. #endif
  121. #ifndef CYTHON_USE_UNICODE_INTERNALS
  122. #define CYTHON_USE_UNICODE_INTERNALS 1
  123. #endif
  124. #if PY_VERSION_HEX < 0x030300F0
  125. #undef CYTHON_USE_UNICODE_WRITER
  126. #define CYTHON_USE_UNICODE_WRITER 0
  127. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  128. #define CYTHON_USE_UNICODE_WRITER 1
  129. #endif
  130. #ifndef CYTHON_AVOID_BORROWED_REFS
  131. #define CYTHON_AVOID_BORROWED_REFS 0
  132. #endif
  133. #ifndef CYTHON_ASSUME_SAFE_MACROS
  134. #define CYTHON_ASSUME_SAFE_MACROS 1
  135. #endif
  136. #ifndef CYTHON_UNPACK_METHODS
  137. #define CYTHON_UNPACK_METHODS 1
  138. #endif
  139. #ifndef CYTHON_FAST_THREAD_STATE
  140. #define CYTHON_FAST_THREAD_STATE 1
  141. #endif
  142. #ifndef CYTHON_FAST_PYCALL
  143. #define CYTHON_FAST_PYCALL 1
  144. #endif
  145. #endif
  146. #if !defined(CYTHON_FAST_PYCCALL)
  147. #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
  148. #endif
  149. #if CYTHON_USE_PYLONG_INTERNALS
  150. #include "longintrepr.h"
  151. #undef SHIFT
  152. #undef BASE
  153. #undef MASK
  154. #endif
  155. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  156. #define Py_OptimizeFlag 0
  157. #endif
  158. #define __PYX_BUILD_PY_SSIZE_T "n"
  159. #define CYTHON_FORMAT_SSIZE_T "z"
  160. #if PY_MAJOR_VERSION < 3
  161. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  162. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  163. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  164. #define __Pyx_DefaultClassType PyClass_Type
  165. #else
  166. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  167. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  168. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  169. #define __Pyx_DefaultClassType PyType_Type
  170. #endif
  171. #ifndef Py_TPFLAGS_CHECKTYPES
  172. #define Py_TPFLAGS_CHECKTYPES 0
  173. #endif
  174. #ifndef Py_TPFLAGS_HAVE_INDEX
  175. #define Py_TPFLAGS_HAVE_INDEX 0
  176. #endif
  177. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  178. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  179. #endif
  180. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  181. #define Py_TPFLAGS_HAVE_FINALIZE 0
  182. #endif
  183. #ifndef METH_FASTCALL
  184. #define METH_FASTCALL 0x80
  185. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args,
  186. Py_ssize_t nargs, PyObject *kwnames);
  187. #else
  188. #define __Pyx_PyCFunctionFast _PyCFunctionFast
  189. #endif
  190. #if CYTHON_FAST_PYCCALL
  191. #define __Pyx_PyFastCFunction_Check(func)\
  192. ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)))))
  193. #else
  194. #define __Pyx_PyFastCFunction_Check(func) 0
  195. #endif
  196. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  197. #define CYTHON_PEP393_ENABLED 1
  198. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  199. 0 : _PyUnicode_Ready((PyObject *)(op)))
  200. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  201. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  202. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  203. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  204. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  205. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  206. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
  207. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  208. #else
  209. #define CYTHON_PEP393_ENABLED 0
  210. #define PyUnicode_1BYTE_KIND 1
  211. #define PyUnicode_2BYTE_KIND 2
  212. #define PyUnicode_4BYTE_KIND 4
  213. #define __Pyx_PyUnicode_READY(op) (0)
  214. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  215. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  216. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  217. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  218. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  219. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  220. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  221. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
  222. #endif
  223. #if CYTHON_COMPILING_IN_PYPY
  224. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  225. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  226. #else
  227. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  228. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  229. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  230. #endif
  231. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  232. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  233. #endif
  234. #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  235. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  236. #endif
  237. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  238. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  239. #endif
  240. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  241. #define PyObject_Malloc(s) PyMem_Malloc(s)
  242. #define PyObject_Free(p) PyMem_Free(p)
  243. #define PyObject_Realloc(p) PyMem_Realloc(p)
  244. #endif
  245. #if CYTHON_COMPILING_IN_PYSTON
  246. #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
  247. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
  248. #else
  249. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  250. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  251. #endif
  252. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  253. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  254. #if PY_MAJOR_VERSION >= 3
  255. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  256. #else
  257. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  258. #endif
  259. #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  260. #define PyObject_ASCII(o) PyObject_Repr(o)
  261. #endif
  262. #if PY_MAJOR_VERSION >= 3
  263. #define PyBaseString_Type PyUnicode_Type
  264. #define PyStringObject PyUnicodeObject
  265. #define PyString_Type PyUnicode_Type
  266. #define PyString_Check PyUnicode_Check
  267. #define PyString_CheckExact PyUnicode_CheckExact
  268. #endif
  269. #if PY_MAJOR_VERSION >= 3
  270. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  271. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  272. #else
  273. #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  274. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  275. #endif
  276. #ifndef PySet_CheckExact
  277. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  278. #endif
  279. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  280. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  281. #if PY_MAJOR_VERSION >= 3
  282. #define PyIntObject PyLongObject
  283. #define PyInt_Type PyLong_Type
  284. #define PyInt_Check(op) PyLong_Check(op)
  285. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  286. #define PyInt_FromString PyLong_FromString
  287. #define PyInt_FromUnicode PyLong_FromUnicode
  288. #define PyInt_FromLong PyLong_FromLong
  289. #define PyInt_FromSize_t PyLong_FromSize_t
  290. #define PyInt_FromSsize_t PyLong_FromSsize_t
  291. #define PyInt_AsLong PyLong_AsLong
  292. #define PyInt_AS_LONG PyLong_AS_LONG
  293. #define PyInt_AsSsize_t PyLong_AsSsize_t
  294. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  295. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  296. #define PyNumber_Int PyNumber_Long
  297. #endif
  298. #if PY_MAJOR_VERSION >= 3
  299. #define PyBoolObject PyLongObject
  300. #endif
  301. #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  302. #ifndef PyUnicode_InternFromString
  303. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  304. #endif
  305. #endif
  306. #if PY_VERSION_HEX < 0x030200A4
  307. typedef long Py_hash_t;
  308. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  309. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  310. #else
  311. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  312. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  313. #endif
  314. #if PY_MAJOR_VERSION >= 3
  315. #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
  316. #else
  317. #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
  318. #endif
  319. #if CYTHON_USE_ASYNC_SLOTS
  320. #if PY_VERSION_HEX >= 0x030500B1
  321. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  322. #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  323. #else
  324. typedef struct {
  325. unaryfunc am_await;
  326. unaryfunc am_aiter;
  327. unaryfunc am_anext;
  328. } __Pyx_PyAsyncMethodsStruct;
  329. #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  330. #endif
  331. #else
  332. #define __Pyx_PyType_AsAsync(obj) NULL
  333. #endif
  334. #ifndef CYTHON_RESTRICT
  335. #if defined(__GNUC__)
  336. #define CYTHON_RESTRICT __restrict__
  337. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  338. #define CYTHON_RESTRICT __restrict
  339. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  340. #define CYTHON_RESTRICT restrict
  341. #else
  342. #define CYTHON_RESTRICT
  343. #endif
  344. #endif
  345. #ifndef CYTHON_UNUSED
  346. # if defined(__GNUC__)
  347. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  348. # define CYTHON_UNUSED __attribute__ ((__unused__))
  349. # else
  350. # define CYTHON_UNUSED
  351. # endif
  352. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  353. # define CYTHON_UNUSED __attribute__ ((__unused__))
  354. # else
  355. # define CYTHON_UNUSED
  356. # endif
  357. #endif
  358. #ifndef CYTHON_MAYBE_UNUSED_VAR
  359. # if defined(__cplusplus)
  360. template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
  361. # else
  362. # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
  363. # endif
  364. #endif
  365. #ifndef CYTHON_NCP_UNUSED
  366. # if CYTHON_COMPILING_IN_CPYTHON
  367. # define CYTHON_NCP_UNUSED
  368. # else
  369. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  370. # endif
  371. #endif
  372. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  373. #ifndef CYTHON_INLINE
  374. #if defined(__clang__)
  375. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  376. #elif defined(__GNUC__)
  377. #define CYTHON_INLINE __inline__
  378. #elif defined(_MSC_VER)
  379. #define CYTHON_INLINE __inline
  380. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  381. #define CYTHON_INLINE inline
  382. #else
  383. #define CYTHON_INLINE
  384. #endif
  385. #endif
  386. #if defined(WIN32) || defined(MS_WINDOWS)
  387. #define _USE_MATH_DEFINES
  388. #endif
  389. #include <math.h>
  390. #ifdef NAN
  391. #define __PYX_NAN() ((float) NAN)
  392. #else
  393. static CYTHON_INLINE float __PYX_NAN() {
  394. float value;
  395. memset(&value, 0xFF, sizeof(value));
  396. return value;
  397. }
  398. #endif
  399. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  400. #define __Pyx_truncl trunc
  401. #else
  402. #define __Pyx_truncl truncl
  403. #endif
  404. #define __PYX_ERR(f_index, lineno, Ln_error) \
  405. { \
  406. __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
  407. }
  408. #if PY_MAJOR_VERSION >= 3
  409. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  410. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  411. #else
  412. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  413. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  414. #endif
  415. #ifndef __PYX_EXTERN_C
  416. #ifdef __cplusplus
  417. #define __PYX_EXTERN_C extern "C"
  418. #else
  419. #define __PYX_EXTERN_C extern
  420. #endif
  421. #endif
  422. #define __PYX_HAVE__gevent__ares
  423. #define __PYX_HAVE_API__gevent__ares
  424. #include "ares.h"
  425. #include "cares_pton.h"
  426. #include "frameobject.h"
  427. #include "dnshelper.c"
  428. #ifdef _OPENMP
  429. #include <omp.h>
  430. #endif /* _OPENMP */
  431. #ifdef PYREX_WITHOUT_ASSERTIONS
  432. #define CYTHON_WITHOUT_ASSERTIONS
  433. #endif
  434. typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
  435. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
  436. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  437. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
  438. #define __PYX_DEFAULT_STRING_ENCODING ""
  439. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  440. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  441. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  442. #define __Pyx_long_cast(x) ((long)x)
  443. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  444. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  445. (sizeof(type) > sizeof(Py_ssize_t) &&\
  446. likely(v < (type)PY_SSIZE_T_MAX ||\
  447. v == (type)PY_SSIZE_T_MAX) &&\
  448. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  449. v == (type)PY_SSIZE_T_MIN))) ||\
  450. (sizeof(type) == sizeof(Py_ssize_t) &&\
  451. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  452. v == (type)PY_SSIZE_T_MAX))) )
  453. #if defined (__cplusplus) && __cplusplus >= 201103L
  454. #include <cstdlib>
  455. #define __Pyx_sst_abs(value) std::abs(value)
  456. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  457. #define __Pyx_sst_abs(value) abs(value)
  458. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  459. #define __Pyx_sst_abs(value) labs(value)
  460. #elif defined (_MSC_VER) && defined (_M_X64)
  461. #define __Pyx_sst_abs(value) _abs64(value)
  462. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  463. #define __Pyx_sst_abs(value) llabs(value)
  464. #elif defined (__GNUC__)
  465. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  466. #else
  467. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  468. #endif
  469. static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
  470. static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  471. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  472. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  473. #define __Pyx_PyBytes_FromString PyBytes_FromString
  474. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  475. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  476. #if PY_MAJOR_VERSION < 3
  477. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  478. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  479. #else
  480. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  481. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  482. #endif
  483. #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  484. #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  485. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  486. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  487. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  488. #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
  489. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  490. #if PY_MAJOR_VERSION < 3
  491. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
  492. {
  493. const Py_UNICODE *u_end = u;
  494. while (*u_end++) ;
  495. return (size_t)(u_end - u - 1);
  496. }
  497. #else
  498. #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
  499. #endif
  500. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  501. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  502. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  503. #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
  504. #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
  505. #define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
  506. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  507. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
  508. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  509. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  510. #if CYTHON_ASSUME_SAFE_MACROS
  511. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  512. #else
  513. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  514. #endif
  515. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  516. #if PY_MAJOR_VERSION >= 3
  517. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  518. #else
  519. #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
  520. #endif
  521. #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
  522. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  523. static int __Pyx_sys_getdefaultencoding_not_ascii;
  524. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  525. PyObject* sys;
  526. PyObject* default_encoding = NULL;
  527. PyObject* ascii_chars_u = NULL;
  528. PyObject* ascii_chars_b = NULL;
  529. const char* default_encoding_c;
  530. sys = PyImport_ImportModule("sys");
  531. if (!sys) goto bad;
  532. default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
  533. Py_DECREF(sys);
  534. if (!default_encoding) goto bad;
  535. default_encoding_c = PyBytes_AsString(default_encoding);
  536. if (!default_encoding_c) goto bad;
  537. if (strcmp(default_encoding_c, "ascii") == 0) {
  538. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  539. } else {
  540. char ascii_chars[128];
  541. int c;
  542. for (c = 0; c < 128; c++) {
  543. ascii_chars[c] = c;
  544. }
  545. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  546. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  547. if (!ascii_chars_u) goto bad;
  548. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  549. if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  550. PyErr_Format(
  551. PyExc_ValueError,
  552. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  553. default_encoding_c);
  554. goto bad;
  555. }
  556. Py_DECREF(ascii_chars_u);
  557. Py_DECREF(ascii_chars_b);
  558. }
  559. Py_DECREF(default_encoding);
  560. return 0;
  561. bad:
  562. Py_XDECREF(default_encoding);
  563. Py_XDECREF(ascii_chars_u);
  564. Py_XDECREF(ascii_chars_b);
  565. return -1;
  566. }
  567. #endif
  568. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  569. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  570. #else
  571. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  572. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  573. static char* __PYX_DEFAULT_STRING_ENCODING;
  574. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  575. PyObject* sys;
  576. PyObject* default_encoding = NULL;
  577. char* default_encoding_c;
  578. sys = PyImport_ImportModule("sys");
  579. if (!sys) goto bad;
  580. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  581. Py_DECREF(sys);
  582. if (!default_encoding) goto bad;
  583. default_encoding_c = PyBytes_AsString(default_encoding);
  584. if (!default_encoding_c) goto bad;
  585. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
  586. if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
  587. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  588. Py_DECREF(default_encoding);
  589. return 0;
  590. bad:
  591. Py_XDECREF(default_encoding);
  592. return -1;
  593. }
  594. #endif
  595. #endif
  596. /* Test for GCC > 2.95 */
  597. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  598. #define likely(x) __builtin_expect(!!(x), 1)
  599. #define unlikely(x) __builtin_expect(!!(x), 0)
  600. #else /* !__GNUC__ or GCC < 2.95 */
  601. #define likely(x) (x)
  602. #define unlikely(x) (x)
  603. #endif /* __GNUC__ */
  604. static PyObject *__pyx_m;
  605. static PyObject *__pyx_d;
  606. static PyObject *__pyx_b;
  607. static PyObject *__pyx_empty_tuple;
  608. static PyObject *__pyx_empty_bytes;
  609. static PyObject *__pyx_empty_unicode;
  610. static int __pyx_lineno;
  611. static int __pyx_clineno = 0;
  612. static const char * __pyx_cfilenm= __FILE__;
  613. static const char *__pyx_filename;
  614. static const char *__pyx_f[] = {
  615. "src\\gevent\\ares.pyx",
  616. };
  617. /*--- Type declarations ---*/
  618. struct __pyx_obj_6gevent_4ares_result;
  619. struct PyGeventAresChannelObject;
  620. struct __pyx_opt_args_6gevent_4ares__convert_cares_flags;
  621. /* "gevent/ares.pyx":137
  622. *
  623. *
  624. * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<<
  625. * if _cares_flag_map is None:
  626. * _prepare_cares_flag_map()
  627. */
  628. struct __pyx_opt_args_6gevent_4ares__convert_cares_flags {
  629. int __pyx_n;
  630. int __pyx_default;
  631. };
  632. /* "gevent/ares.pyx":164
  633. *
  634. *
  635. * cdef class result: # <<<<<<<<<<<<<<
  636. * cdef public object value
  637. * cdef public object exception
  638. */
  639. struct __pyx_obj_6gevent_4ares_result {
  640. PyObject_HEAD
  641. PyObject *value;
  642. PyObject *exception;
  643. };
  644. /* "gevent/ares.pyx":245
  645. *
  646. *
  647. * cdef public class channel [object PyGeventAresChannelObject, type PyGeventAresChannel_Type]: # <<<<<<<<<<<<<<
  648. *
  649. * cdef public object loop
  650. */
  651. struct PyGeventAresChannelObject {
  652. PyObject_HEAD
  653. struct __pyx_vtabstruct_6gevent_4ares_channel *__pyx_vtab;
  654. PyObject *loop;
  655. struct ares_channeldata *channel;
  656. PyObject *_watchers;
  657. PyObject *_timer;
  658. };
  659. __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventAresChannel_Type;
  660. __PYX_EXTERN_C DL_EXPORT(PyTypeObject) PyGeventAresChannel_Type;
  661. struct __pyx_vtabstruct_6gevent_4ares_channel {
  662. PyObject *(*_sock_state_callback)(struct PyGeventAresChannelObject *, int, int, int);
  663. PyObject *(*_getnameinfo)(struct PyGeventAresChannelObject *, PyObject *, PyObject *, int, int __pyx_skip_dispatch);
  664. };
  665. static struct __pyx_vtabstruct_6gevent_4ares_channel *__pyx_vtabptr_6gevent_4ares_channel;
  666. /* --- Runtime support code (head) --- */
  667. /* Refnanny.proto */
  668. #ifndef CYTHON_REFNANNY
  669. #define CYTHON_REFNANNY 0
  670. #endif
  671. #if CYTHON_REFNANNY
  672. typedef struct {
  673. void (*INCREF)(void*, PyObject*, int);
  674. void (*DECREF)(void*, PyObject*, int);
  675. void (*GOTREF)(void*, PyObject*, int);
  676. void (*GIVEREF)(void*, PyObject*, int);
  677. void* (*SetupContext)(const char*, int, const char*);
  678. void (*FinishContext)(void**);
  679. } __Pyx_RefNannyAPIStruct;
  680. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  681. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  682. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  683. #ifdef WITH_THREAD
  684. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  685. if (acquire_gil) {\
  686. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  687. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  688. PyGILState_Release(__pyx_gilstate_save);\
  689. } else {\
  690. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  691. }
  692. #else
  693. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  694. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  695. #endif
  696. #define __Pyx_RefNannyFinishContext()\
  697. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  698. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  699. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  700. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  701. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  702. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  703. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  704. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  705. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  706. #else
  707. #define __Pyx_RefNannyDeclarations
  708. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  709. #define __Pyx_RefNannyFinishContext()
  710. #define __Pyx_INCREF(r) Py_INCREF(r)
  711. #define __Pyx_DECREF(r) Py_DECREF(r)
  712. #define __Pyx_GOTREF(r)
  713. #define __Pyx_GIVEREF(r)
  714. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  715. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  716. #define __Pyx_XGOTREF(r)
  717. #define __Pyx_XGIVEREF(r)
  718. #endif
  719. #define __Pyx_XDECREF_SET(r, v) do {\
  720. PyObject *tmp = (PyObject *) r;\
  721. r = v; __Pyx_XDECREF(tmp);\
  722. } while (0)
  723. #define __Pyx_DECREF_SET(r, v) do {\
  724. PyObject *tmp = (PyObject *) r;\
  725. r = v; __Pyx_DECREF(tmp);\
  726. } while (0)
  727. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  728. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  729. /* PyObjectGetAttrStr.proto */
  730. #if CYTHON_USE_TYPE_SLOTS
  731. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  732. PyTypeObject* tp = Py_TYPE(obj);
  733. if (likely(tp->tp_getattro))
  734. return tp->tp_getattro(obj, attr_name);
  735. #if PY_MAJOR_VERSION < 3
  736. if (likely(tp->tp_getattr))
  737. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  738. #endif
  739. return PyObject_GetAttr(obj, attr_name);
  740. }
  741. #else
  742. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  743. #endif
  744. /* GetBuiltinName.proto */
  745. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  746. /* Import.proto */
  747. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
  748. /* GetAttr.proto */
  749. static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
  750. /* GetAttr3.proto */
  751. static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
  752. /* GetModuleGlobalName.proto */
  753. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
  754. /* RaiseTooManyValuesToUnpack.proto */
  755. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
  756. /* RaiseNeedMoreValuesToUnpack.proto */
  757. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
  758. /* IterFinish.proto */
  759. static CYTHON_INLINE int __Pyx_IterFinish(void);
  760. /* UnpackItemEndCheck.proto */
  761. static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
  762. /* PyFunctionFastCall.proto */
  763. #if CYTHON_FAST_PYCALL
  764. #define __Pyx_PyFunction_FastCall(func, args, nargs)\
  765. __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
  766. #if 1 || PY_VERSION_HEX < 0x030600B1
  767. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs);
  768. #else
  769. #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
  770. #endif
  771. #endif
  772. /* PyCFunctionFastCall.proto */
  773. #if CYTHON_FAST_PYCCALL
  774. static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
  775. #else
  776. #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
  777. #endif
  778. /* PyObjectCall.proto */
  779. #if CYTHON_COMPILING_IN_CPYTHON
  780. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  781. #else
  782. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  783. #endif
  784. /* PyThreadStateGet.proto */
  785. #if CYTHON_FAST_THREAD_STATE
  786. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  787. #define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET();
  788. #else
  789. #define __Pyx_PyThreadState_declare
  790. #define __Pyx_PyThreadState_assign
  791. #endif
  792. /* PyErrFetchRestore.proto */
  793. #if CYTHON_FAST_THREAD_STATE
  794. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  795. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  796. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  797. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  798. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  799. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  800. #else
  801. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  802. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  803. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  804. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  805. #endif
  806. /* RaiseException.proto */
  807. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  808. /* RaiseDoubleKeywords.proto */
  809. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  810. /* ParseKeywords.proto */
  811. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
  812. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
  813. const char* function_name);
  814. /* RaiseArgTupleInvalid.proto */
  815. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  816. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  817. /* PyObjectCallMethO.proto */
  818. #if CYTHON_COMPILING_IN_CPYTHON
  819. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  820. #endif
  821. /* PyObjectCallOneArg.proto */
  822. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  823. /* WriteUnraisableException.proto */
  824. static void __Pyx_WriteUnraisable(const char *name, int clineno,
  825. int lineno, const char *filename,
  826. int full_traceback, int nogil);
  827. /* PyObjectSetAttrStr.proto */
  828. #if CYTHON_USE_TYPE_SLOTS
  829. #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL)
  830. static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
  831. PyTypeObject* tp = Py_TYPE(obj);
  832. if (likely(tp->tp_setattro))
  833. return tp->tp_setattro(obj, attr_name, value);
  834. #if PY_MAJOR_VERSION < 3
  835. if (likely(tp->tp_setattr))
  836. return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
  837. #endif
  838. return PyObject_SetAttr(obj, attr_name, value);
  839. }
  840. #else
  841. #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
  842. #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
  843. #endif
  844. /* RaiseNoneIterError.proto */
  845. static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
  846. /* ExtTypeTest.proto */
  847. static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
  848. /* SaveResetException.proto */
  849. #if CYTHON_FAST_THREAD_STATE
  850. #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
  851. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  852. #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
  853. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  854. #else
  855. #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
  856. #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
  857. #endif
  858. /* GetException.proto */
  859. #if CYTHON_FAST_THREAD_STATE
  860. #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
  861. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  862. #else
  863. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
  864. #endif
  865. /* PyObjectCallNoArg.proto */
  866. #if CYTHON_COMPILING_IN_CPYTHON
  867. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
  868. #else
  869. #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
  870. #endif
  871. /* GetItemInt.proto */
  872. #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
  873. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  874. __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
  875. (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
  876. __Pyx_GetItemInt_Generic(o, to_py_func(i))))
  877. #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
  878. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  879. __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
  880. (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
  881. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  882. int wraparound, int boundscheck);
  883. #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
  884. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  885. __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
  886. (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
  887. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  888. int wraparound, int boundscheck);
  889. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
  890. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
  891. int is_list, int wraparound, int boundscheck);
  892. /* pyobject_as_double.proto */
  893. static double __Pyx__PyObject_AsDouble(PyObject* obj);
  894. #if CYTHON_COMPILING_IN_PYPY
  895. #define __Pyx_PyObject_AsDouble(obj)\
  896. (likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) :\
  897. likely(PyInt_CheckExact(obj)) ?\
  898. PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
  899. #else
  900. #define __Pyx_PyObject_AsDouble(obj)\
  901. ((likely(PyFloat_CheckExact(obj))) ?\
  902. PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
  903. #endif
  904. /* py_dict_clear.proto */
  905. #define __Pyx_PyDict_Clear(d) (PyDict_Clear(d), 0)
  906. /* SwapException.proto */
  907. #if CYTHON_FAST_THREAD_STATE
  908. #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
  909. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  910. #else
  911. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
  912. #endif
  913. /* dict_getitem_default.proto */
  914. static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);
  915. /* ArgTypeTest.proto */
  916. static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
  917. const char *name, int exact);
  918. /* PyErrExceptionMatches.proto */
  919. #if CYTHON_FAST_THREAD_STATE
  920. #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
  921. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
  922. #else
  923. #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
  924. #endif
  925. /* SetVTable.proto */
  926. static int __Pyx_SetVtable(PyObject *dict, void *vtable);
  927. /* ImportFrom.proto */
  928. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
  929. /* CalculateMetaclass.proto */
  930. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
  931. /* Py3ClassCreate.proto */
  932. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
  933. PyObject *mkw, PyObject *modname, PyObject *doc);
  934. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
  935. PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
  936. /* FetchCommonType.proto */
  937. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
  938. /* CythonFunction.proto */
  939. #define __Pyx_CyFunction_USED 1
  940. #include <structmember.h>
  941. #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
  942. #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
  943. #define __Pyx_CYFUNCTION_CCLASS 0x04
  944. #define __Pyx_CyFunction_GetClosure(f)\
  945. (((__pyx_CyFunctionObject *) (f))->func_closure)
  946. #define __Pyx_CyFunction_GetClassObj(f)\
  947. (((__pyx_CyFunctionObject *) (f))->func_classobj)
  948. #define __Pyx_CyFunction_Defaults(type, f)\
  949. ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
  950. #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
  951. ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
  952. typedef struct {
  953. PyCFunctionObject func;
  954. #if PY_VERSION_HEX < 0x030500A0
  955. PyObject *func_weakreflist;
  956. #endif
  957. PyObject *func_dict;
  958. PyObject *func_name;
  959. PyObject *func_qualname;
  960. PyObject *func_doc;
  961. PyObject *func_globals;
  962. PyObject *func_code;
  963. PyObject *func_closure;
  964. PyObject *func_classobj;
  965. void *defaults;
  966. int defaults_pyobjects;
  967. int flags;
  968. PyObject *defaults_tuple;
  969. PyObject *defaults_kwdict;
  970. PyObject *(*defaults_getter)(PyObject *);
  971. PyObject *func_annotations;
  972. } __pyx_CyFunctionObject;
  973. static PyTypeObject *__pyx_CyFunctionType = 0;
  974. #define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
  975. __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
  976. static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
  977. int flags, PyObject* qualname,
  978. PyObject *self,
  979. PyObject *module, PyObject *globals,
  980. PyObject* code);
  981. static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
  982. size_t size,
  983. int pyobjects);
  984. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
  985. PyObject *tuple);
  986. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
  987. PyObject *dict);
  988. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
  989. PyObject *dict);
  990. static int __pyx_CyFunction_init(void);
  991. /* CodeObjectCache.proto */
  992. typedef struct {
  993. PyCodeObject* code_object;
  994. int code_line;
  995. } __Pyx_CodeObjectCacheEntry;
  996. struct __Pyx_CodeObjectCache {
  997. int count;
  998. int max_count;
  999. __Pyx_CodeObjectCacheEntry* entries;
  1000. };
  1001. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  1002. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  1003. static PyCodeObject *__pyx_find_code_object(int code_line);
  1004. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  1005. /* AddTraceback.proto */
  1006. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  1007. int py_line, const char *filename);
  1008. /* CIntToPy.proto */
  1009. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  1010. /* CIntToPy.proto */
  1011. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
  1012. /* CIntFromPy.proto */
  1013. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  1014. /* CIntFromPy.proto */
  1015. static CYTHON_INLINE unsigned short __Pyx_PyInt_As_unsigned_short(PyObject *);
  1016. /* CIntFromPy.proto */
  1017. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  1018. /* CheckBinaryVersion.proto */
  1019. static int __Pyx_check_binary_version(void);
  1020. /* InitStrings.proto */
  1021. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  1022. static PyObject *__pyx_f_6gevent_4ares_7channel__sock_state_callback(struct PyGeventAresChannelObject *__pyx_v_self, int __pyx_v_socket, int __pyx_v_read, int __pyx_v_write); /* proto*/
  1023. static PyObject *__pyx_f_6gevent_4ares_7channel__getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags, int __pyx_skip_dispatch); /* proto*/
  1024. /* Module declarations from 'gevent.cares' */
  1025. /* Module declarations from 'gevent.python' */
  1026. /* Module declarations from 'gevent.ares' */
  1027. static PyTypeObject *__pyx_ptype_6gevent_4ares_result = 0;
  1028. static PyTypeObject *__pyx_ptype_6gevent_4ares_channel = 0;
  1029. static PyObject *__pyx_v_6gevent_4ares_string_types = 0;
  1030. static PyObject *__pyx_v_6gevent_4ares_text_type = 0;
  1031. static PyObject *__pyx_f_6gevent_4ares__prepare_cares_flag_map(void); /*proto*/
  1032. static PyObject *__pyx_f_6gevent_4ares__convert_cares_flags(int, int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_4ares__convert_cares_flags *__pyx_optional_args); /*proto*/
  1033. static PyObject *__pyx_f_6gevent_4ares_strerror(PyObject *, int __pyx_skip_dispatch); /*proto*/
  1034. static void __pyx_f_6gevent_4ares_gevent_sock_state_callback(void *, int, int, int); /*proto*/
  1035. static void __pyx_f_6gevent_4ares_gevent_ares_host_callback(void *, int, int, struct hostent *); /*proto*/
  1036. static void __pyx_f_6gevent_4ares_gevent_ares_nameinfo_callback(void *, int, int, char *, char *); /*proto*/
  1037. #define __Pyx_MODULE_NAME "gevent.ares"
  1038. int __pyx_module_is_main_gevent__ares = 0;
  1039. /* Implementation of 'gevent.ares' */
  1040. static PyObject *__pyx_builtin_ValueError;
  1041. static PyObject *__pyx_builtin_id;
  1042. static PyObject *__pyx_builtin_MemoryError;
  1043. static PyObject *__pyx_builtin_TypeError;
  1044. static const char __pyx_k__2[] = ",";
  1045. static const char __pyx_k_fd[] = "fd";
  1046. static const char __pyx_k_id[] = "id";
  1047. static const char __pyx_k_io[] = "io";
  1048. static const char __pyx_k_all[] = "__all__";
  1049. static const char __pyx_k_cls[] = "cls";
  1050. static const char __pyx_k_doc[] = "__doc__";
  1051. static const char __pyx_k_get[] = "get";
  1052. static const char __pyx_k_new[] = "__new__";
  1053. static const char __pyx_k_pop[] = "pop";
  1054. static const char __pyx_k_s_r[] = "%s(%r)";
  1055. static const char __pyx_k_s_s[] = "%s: %s";
  1056. static const char __pyx_k_sys[] = "sys";
  1057. static const char __pyx_k_addr[] = "addr";
  1058. static const char __pyx_k_loop[] = "loop";
  1059. static const char __pyx_k_main[] = "__main__";
  1060. static const char __pyx_k_name[] = "__name__";
  1061. static const char __pyx_k_self[] = "self";
  1062. static const char __pyx_k_stop[] = "stop";
  1063. static const char __pyx_k_test[] = "__test__";
  1064. static const char __pyx_k_again[] = "again";
  1065. static const char __pyx_k_ascii[] = "ascii";
  1066. static const char __pyx_k_class[] = "__class__";
  1067. static const char __pyx_k_flags[] = "flags";
  1068. static const char __pyx_k_ndots[] = "ndots";
  1069. static const char __pyx_k_split[] = "split";
  1070. static const char __pyx_k_start[] = "start";
  1071. static const char __pyx_k_timer[] = "timer";
  1072. static const char __pyx_k_tries[] = "tries";
  1073. static const char __pyx_k_value[] = "value";
  1074. static const char __pyx_k_encode[] = "encode";
  1075. static const char __pyx_k_events[] = "events";
  1076. static const char __pyx_k_family[] = "family";
  1077. static const char __pyx_k_import[] = "__import__";
  1078. static const char __pyx_k_module[] = "__module__";
  1079. static const char __pyx_k_name_2[] = "name";
  1080. static const char __pyx_k_socket[] = "_socket";
  1081. static const char __pyx_k_TIMEOUT[] = "TIMEOUT";
  1082. static const char __pyx_k_channel[] = "channel";
  1083. static const char __pyx_k_default[] = "default";
  1084. static const char __pyx_k_destroy[] = "destroy";
  1085. static const char __pyx_k_prepare[] = "__prepare__";
  1086. static const char __pyx_k_servers[] = "servers";
  1087. static const char __pyx_k_timeout[] = "timeout";
  1088. static const char __pyx_k_unicode[] = "unicode";
  1089. static const char __pyx_k_watcher[] = "watcher";
  1090. static const char __pyx_k_ARES_EOF[] = "ARES_EOF";
  1091. static const char __pyx_k_NI_DGRAM[] = "NI_DGRAM";
  1092. static const char __pyx_k_builtins[] = "__builtins__";
  1093. static const char __pyx_k_callback[] = "callback";
  1094. static const char __pyx_k_exc_info[] = "exc_info";
  1095. static const char __pyx_k_gaierror[] = "gaierror";
  1096. static const char __pyx_k_iterable[] = "iterable";
  1097. static const char __pyx_k_on_timer[] = "_on_timer";
  1098. static const char __pyx_k_qualname[] = "__qualname__";
  1099. static const char __pyx_k_sockaddr[] = "sockaddr";
  1100. static const char __pyx_k_tcp_port[] = "tcp_port";
  1101. static const char __pyx_k_udp_port[] = "udp_port";
  1102. static const char __pyx_k_InvalidIP[] = "InvalidIP";
  1103. static const char __pyx_k_NI_NOFQDN[] = "NI_NOFQDN";
  1104. static const char __pyx_k_TypeError[] = "TypeError";
  1105. static const char __pyx_k_exception[] = "exception";
  1106. static const char __pyx_k_metaclass[] = "__metaclass__";
  1107. static const char __pyx_k_ARES_EFILE[] = "ARES_EFILE";
  1108. static const char __pyx_k_ValueError[] = "ValueError";
  1109. static const char __pyx_k_basestring[] = "basestring";
  1110. static const char __pyx_k_getnewargs[] = "__getnewargs__";
  1111. static const char __pyx_k_process_fd[] = "_process_fd";
  1112. static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
  1113. static const char __pyx_k_ARES_ENOMEM[] = "ARES_ENOMEM";
  1114. static const char __pyx_k_MemoryError[] = "MemoryError";
  1115. static const char __pyx_k_NI_NAMEREQD[] = "NI_NAMEREQD";
  1116. static const char __pyx_k_ares_errors[] = "_ares_errors";
  1117. static const char __pyx_k_getnameinfo[] = "_getnameinfo";
  1118. static const char __pyx_k_gevent_ares[] = "gevent.ares";
  1119. static const char __pyx_k_pass_events[] = "pass_events";
  1120. static const char __pyx_k_set_servers[] = "set_servers";
  1121. static const char __pyx_k_ARES_EBADSTR[] = "ARES_EBADSTR";
  1122. static const char __pyx_k_ARES_ENODATA[] = "ARES_ENODATA";
  1123. static const char __pyx_k_ARES_ENONAME[] = "ARES_ENONAME";
  1124. static const char __pyx_k_ARES_ENOTIMP[] = "ARES_ENOTIMP";
  1125. static const char __pyx_k_ARES_SUCCESS[] = "ARES_SUCCESS";
  1126. static const char __pyx_k_handle_error[] = "handle_error";
  1127. static const char __pyx_k_version_info[] = "version_info";
  1128. static const char __pyx_k_ARES_EBADNAME[] = "ARES_EBADNAME";
  1129. static const char __pyx_k_ARES_EBADRESP[] = "ARES_EBADRESP";
  1130. static const char __pyx_k_ARES_EFORMERR[] = "ARES_EFORMERR";
  1131. static const char __pyx_k_ARES_EREFUSED[] = "ARES_EREFUSED";
  1132. static const char __pyx_k_ARES_ETIMEOUT[] = "ARES_ETIMEOUT";
  1133. static const char __pyx_k_s_exception_r[] = "%s(exception=%r)";
  1134. static const char __pyx_k_ARES_EBADFLAGS[] = "ARES_EBADFLAGS";
  1135. static const char __pyx_k_ARES_EBADHINTS[] = "ARES_EBADHINTS";
  1136. static const char __pyx_k_ARES_EBADQUERY[] = "ARES_EBADQUERY";
  1137. static const char __pyx_k_ARES_ENOTFOUND[] = "ARES_ENOTFOUND";
  1138. static const char __pyx_k_ARES_ESERVFAIL[] = "ARES_ESERVFAIL";
  1139. static const char __pyx_k_NI_NUMERICHOST[] = "NI_NUMERICHOST";
  1140. static const char __pyx_k_NI_NUMERICSERV[] = "NI_NUMERICSERV";
  1141. static const char __pyx_k_cares_flag_map[] = "_cares_flag_map";
  1142. static const char __pyx_k_ARES_EBADFAMILY[] = "ARES_EBADFAMILY";
  1143. static const char __pyx_k_ARES_ECANCELLED[] = "ARES_ECANCELLED";
  1144. static const char __pyx_k_ARES_FLAG_IGNTC[] = "ARES_FLAG_IGNTC";
  1145. static const char __pyx_k_ARES_FLAG_USEVC[] = "ARES_FLAG_USEVC";
  1146. static const char __pyx_k_ares_host_result[] = "ares_host_result";
  1147. static const char __pyx_k_ARES_ECONNREFUSED[] = "ARES_ECONNREFUSED";
  1148. static const char __pyx_k_ARES_EDESTRUCTION[] = "ARES_EDESTRUCTION";
  1149. static const char __pyx_k_ARES_FLAG_PRIMARY[] = "ARES_FLAG_PRIMARY";
  1150. static const char __pyx_k_ARES_ELOADIPHLPAPI[] = "ARES_ELOADIPHLPAPI";
  1151. static const char __pyx_k_ARES_FLAG_NOSEARCH[] = "ARES_FLAG_NOSEARCH";
  1152. static const char __pyx_k_ARES_FLAG_STAYOPEN[] = "ARES_FLAG_STAYOPEN";
  1153. static const char __pyx_k_ARES_FLAG_NOALIASES[] = "ARES_FLAG_NOALIASES";
  1154. static const char __pyx_k_ARES_FLAG_NORECURSE[] = "ARES_FLAG_NORECURSE";
  1155. static const char __pyx_k_ARES_ENOTINITIALIZED[] = "ARES_ENOTINITIALIZED";
  1156. static const char __pyx_k_ARES_FLAG_NOCHECKRESP[] = "ARES_FLAG_NOCHECKRESP";
  1157. static const char __pyx_k_s_value_r_exception_r[] = "%s(value=%r, exception=%r)";
  1158. static const char __pyx_k_ares_host_result___new[] = "ares_host_result.__new__";
  1159. static const char __pyx_k_expected_a_tuple_got_r[] = "expected a tuple, got %r";
  1160. static const char __pyx_k_Invalid_value_for_port_r[] = "Invalid value for port: %r";
  1161. static const char __pyx_k_ARES_EADDRGETNETWORKPARAMS[] = "ARES_EADDRGETNETWORKPARAMS";
  1162. static const char __pyx_k_Bad_value_for_ai_flags_0x_x[] = "Bad value for ai_flags: 0x%x";
  1163. static const char __pyx_k_ares_host_result___getnewargs[] = "ares_host_result.__getnewargs__";
  1164. static const char __pyx_k_s_at_0x_x__timer_r__watchers_s[] = "<%s at 0x%x _timer=%r _watchers[%s]>";
  1165. static const char __pyx_k_C_projects_gevent_src_gevent_are[] = "C:\\projects\\gevent\\src\\gevent\\ares.pyx";
  1166. static const char __pyx_k_this_ares_channel_has_been_destr[] = "this ares channel has been destroyed";
  1167. static PyObject *__pyx_n_s_ARES_EADDRGETNETWORKPARAMS;
  1168. static PyObject *__pyx_n_s_ARES_EBADFAMILY;
  1169. static PyObject *__pyx_n_s_ARES_EBADFLAGS;
  1170. static PyObject *__pyx_n_s_ARES_EBADHINTS;
  1171. static PyObject *__pyx_n_s_ARES_EBADNAME;
  1172. static PyObject *__pyx_n_s_ARES_EBADQUERY;
  1173. static PyObject *__pyx_n_s_ARES_EBADRESP;
  1174. static PyObject *__pyx_n_s_ARES_EBADSTR;
  1175. static PyObject *__pyx_n_s_ARES_ECANCELLED;
  1176. static PyObject *__pyx_n_s_ARES_ECONNREFUSED;
  1177. static PyObject *__pyx_n_s_ARES_EDESTRUCTION;
  1178. static PyObject *__pyx_n_s_ARES_EFILE;
  1179. static PyObject *__pyx_n_s_ARES_EFORMERR;
  1180. static PyObject *__pyx_n_s_ARES_ELOADIPHLPAPI;
  1181. static PyObject *__pyx_n_s_ARES_ENODATA;
  1182. static PyObject *__pyx_n_s_ARES_ENOMEM;
  1183. static PyObject *__pyx_n_s_ARES_ENONAME;
  1184. static PyObject *__pyx_n_s_ARES_ENOTFOUND;
  1185. static PyObject *__pyx_n_s_ARES_ENOTIMP;
  1186. static PyObject *__pyx_n_s_ARES_ENOTINITIALIZED;
  1187. static PyObject *__pyx_n_s_ARES_EOF;
  1188. static PyObject *__pyx_n_s_ARES_EREFUSED;
  1189. static PyObject *__pyx_n_s_ARES_ESERVFAIL;
  1190. static PyObject *__pyx_n_s_ARES_ETIMEOUT;
  1191. static PyObject *__pyx_n_s_ARES_FLAG_IGNTC;
  1192. static PyObject *__pyx_n_s_ARES_FLAG_NOALIASES;
  1193. static PyObject *__pyx_n_s_ARES_FLAG_NOCHECKRESP;
  1194. static PyObject *__pyx_n_s_ARES_FLAG_NORECURSE;
  1195. static PyObject *__pyx_n_s_ARES_FLAG_NOSEARCH;
  1196. static PyObject *__pyx_n_s_ARES_FLAG_PRIMARY;
  1197. static PyObject *__pyx_n_s_ARES_FLAG_STAYOPEN;
  1198. static PyObject *__pyx_n_s_ARES_FLAG_USEVC;
  1199. static PyObject *__pyx_n_s_ARES_SUCCESS;
  1200. static PyObject *__pyx_kp_s_Bad_value_for_ai_flags_0x_x;
  1201. static PyObject *__pyx_kp_s_C_projects_gevent_src_gevent_are;
  1202. static PyObject *__pyx_n_s_InvalidIP;
  1203. static PyObject *__pyx_kp_s_Invalid_value_for_port_r;
  1204. static PyObject *__pyx_n_s_MemoryError;
  1205. static PyObject *__pyx_n_s_NI_DGRAM;
  1206. static PyObject *__pyx_n_s_NI_NAMEREQD;
  1207. static PyObject *__pyx_n_s_NI_NOFQDN;
  1208. static PyObject *__pyx_n_s_NI_NUMERICHOST;
  1209. static PyObject *__pyx_n_s_NI_NUMERICSERV;
  1210. static PyObject *__pyx_n_s_TIMEOUT;
  1211. static PyObject *__pyx_n_s_TypeError;
  1212. static PyObject *__pyx_n_s_ValueError;
  1213. static PyObject *__pyx_kp_s__2;
  1214. static PyObject *__pyx_n_s_addr;
  1215. static PyObject *__pyx_n_s_again;
  1216. static PyObject *__pyx_n_s_all;
  1217. static PyObject *__pyx_n_s_ares_errors;
  1218. static PyObject *__pyx_n_s_ares_host_result;
  1219. static PyObject *__pyx_n_s_ares_host_result___getnewargs;
  1220. static PyObject *__pyx_n_s_ares_host_result___new;
  1221. static PyObject *__pyx_n_s_ascii;
  1222. static PyObject *__pyx_n_s_basestring;
  1223. static PyObject *__pyx_n_s_builtins;
  1224. static PyObject *__pyx_n_s_callback;
  1225. static PyObject *__pyx_n_s_cares_flag_map;
  1226. static PyObject *__pyx_n_s_channel;
  1227. static PyObject *__pyx_n_s_class;
  1228. static PyObject *__pyx_n_s_cls;
  1229. static PyObject *__pyx_n_s_default;
  1230. static PyObject *__pyx_n_s_destroy;
  1231. static PyObject *__pyx_n_s_doc;
  1232. static PyObject *__pyx_n_s_encode;
  1233. static PyObject *__pyx_n_s_events;
  1234. static PyObject *__pyx_n_s_exc_info;
  1235. static PyObject *__pyx_n_s_exception;
  1236. static PyObject *__pyx_kp_s_expected_a_tuple_got_r;
  1237. static PyObject *__pyx_n_s_family;
  1238. static PyObject *__pyx_n_s_fd;
  1239. static PyObject *__pyx_n_s_flags;
  1240. static PyObject *__pyx_n_s_gaierror;
  1241. static PyObject *__pyx_n_s_get;
  1242. static PyObject *__pyx_n_s_getnameinfo;
  1243. static PyObject *__pyx_n_s_getnewargs;
  1244. static PyObject *__pyx_n_s_gevent_ares;
  1245. static PyObject *__pyx_n_s_handle_error;
  1246. static PyObject *__pyx_n_s_id;
  1247. static PyObject *__pyx_n_s_import;
  1248. static PyObject *__pyx_n_s_io;
  1249. static PyObject *__pyx_n_s_iterable;
  1250. static PyObject *__pyx_n_s_loop;
  1251. static PyObject *__pyx_n_s_main;
  1252. static PyObject *__pyx_n_s_metaclass;
  1253. static PyObject *__pyx_n_s_module;
  1254. static PyObject *__pyx_n_s_name;
  1255. static PyObject *__pyx_n_s_name_2;
  1256. static PyObject *__pyx_n_s_ndots;
  1257. static PyObject *__pyx_n_s_new;
  1258. static PyObject *__pyx_n_s_on_timer;
  1259. static PyObject *__pyx_n_s_pass_events;
  1260. static PyObject *__pyx_n_s_pop;
  1261. static PyObject *__pyx_n_s_prepare;
  1262. static PyObject *__pyx_n_s_process_fd;
  1263. static PyObject *__pyx_n_s_pyx_vtable;
  1264. static PyObject *__pyx_n_s_qualname;
  1265. static PyObject *__pyx_kp_s_s_at_0x_x__timer_r__watchers_s;
  1266. static PyObject *__pyx_kp_s_s_exception_r;
  1267. static PyObject *__pyx_kp_s_s_r;
  1268. static PyObject *__pyx_kp_s_s_s;
  1269. static PyObject *__pyx_kp_s_s_value_r_exception_r;
  1270. static PyObject *__pyx_n_s_self;
  1271. static PyObject *__pyx_n_s_servers;
  1272. static PyObject *__pyx_n_s_set_servers;
  1273. static PyObject *__pyx_n_s_sockaddr;
  1274. static PyObject *__pyx_n_s_socket;
  1275. static PyObject *__pyx_n_s_split;
  1276. static PyObject *__pyx_n_s_start;
  1277. static PyObject *__pyx_n_s_stop;
  1278. static PyObject *__pyx_n_s_sys;
  1279. static PyObject *__pyx_n_s_tcp_port;
  1280. static PyObject *__pyx_n_s_test;
  1281. static PyObject *__pyx_kp_s_this_ares_channel_has_been_destr;
  1282. static PyObject *__pyx_n_s_timeout;
  1283. static PyObject *__pyx_n_s_timer;
  1284. static PyObject *__pyx_n_s_tries;
  1285. static PyObject *__pyx_n_s_udp_port;
  1286. static PyObject *__pyx_n_s_unicode;
  1287. static PyObject *__pyx_n_s_value;
  1288. static PyObject *__pyx_n_s_version_info;
  1289. static PyObject *__pyx_n_s_watcher;
  1290. static PyObject *__pyx_pf_6gevent_4ares__convert_cares_flags(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_flags, int __pyx_v_default); /* proto */
  1291. static PyObject *__pyx_pf_6gevent_4ares_2strerror(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code); /* proto */
  1292. static int __pyx_pf_6gevent_4ares_6result___init__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value, PyObject *__pyx_v_exception); /* proto */
  1293. static PyObject *__pyx_pf_6gevent_4ares_6result_2__repr__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */
  1294. static PyObject *__pyx_pf_6gevent_4ares_6result_4successful(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */
  1295. static PyObject *__pyx_pf_6gevent_4ares_6result_6get(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */
  1296. static PyObject *__pyx_pf_6gevent_4ares_6result_5value___get__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */
  1297. static int __pyx_pf_6gevent_4ares_6result_5value_2__set__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
  1298. static int __pyx_pf_6gevent_4ares_6result_5value_4__del__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */
  1299. static PyObject *__pyx_pf_6gevent_4ares_6result_9exception___get__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */
  1300. static int __pyx_pf_6gevent_4ares_6result_9exception_2__set__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
  1301. static int __pyx_pf_6gevent_4ares_6result_9exception_4__del__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self); /* proto */
  1302. static PyObject *__pyx_pf_6gevent_4ares_16ares_host_result___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_family, PyObject *__pyx_v_iterable); /* proto */
  1303. static PyObject *__pyx_pf_6gevent_4ares_16ares_host_result_2__getnewargs__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
  1304. static int __pyx_pf_6gevent_4ares_7channel___init__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_loop, PyObject *__pyx_v_flags, PyObject *__pyx_v_timeout, PyObject *__pyx_v_tries, PyObject *__pyx_v_ndots, PyObject *__pyx_v_udp_port, PyObject *__pyx_v_tcp_port, PyObject *__pyx_v_servers); /* proto */
  1305. static PyObject *__pyx_pf_6gevent_4ares_7channel_2__repr__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */
  1306. static PyObject *__pyx_pf_6gevent_4ares_7channel_4destroy(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */
  1307. static void __pyx_pf_6gevent_4ares_7channel_6__dealloc__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */
  1308. static PyObject *__pyx_pf_6gevent_4ares_7channel_8set_servers(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_servers); /* proto */
  1309. static PyObject *__pyx_pf_6gevent_4ares_7channel_10_on_timer(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */
  1310. static PyObject *__pyx_pf_6gevent_4ares_7channel_12_process_fd(struct PyGeventAresChannelObject *__pyx_v_self, int __pyx_v_events, PyObject *__pyx_v_watcher); /* proto */
  1311. static PyObject *__pyx_pf_6gevent_4ares_7channel_14gethostbyname(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_name, int __pyx_v_family); /* proto */
  1312. static PyObject *__pyx_pf_6gevent_4ares_7channel_16gethostbyaddr(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_addr); /* proto */
  1313. static PyObject *__pyx_pf_6gevent_4ares_7channel_18_getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags); /* proto */
  1314. static PyObject *__pyx_pf_6gevent_4ares_7channel_20getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags); /* proto */
  1315. static PyObject *__pyx_pf_6gevent_4ares_7channel_4loop___get__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */
  1316. static int __pyx_pf_6gevent_4ares_7channel_4loop_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
  1317. static int __pyx_pf_6gevent_4ares_7channel_4loop_4__del__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */
  1318. static PyObject *__pyx_pf_6gevent_4ares_7channel_9_watchers___get__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */
  1319. static int __pyx_pf_6gevent_4ares_7channel_9_watchers_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
  1320. static int __pyx_pf_6gevent_4ares_7channel_9_watchers_4__del__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */
  1321. static PyObject *__pyx_pf_6gevent_4ares_7channel_6_timer___get__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */
  1322. static int __pyx_pf_6gevent_4ares_7channel_6_timer_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
  1323. static int __pyx_pf_6gevent_4ares_7channel_6_timer_4__del__(struct PyGeventAresChannelObject *__pyx_v_self); /* proto */
  1324. static PyObject *__pyx_tp_new_6gevent_4ares_result(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1325. static PyObject *__pyx_tp_new_6gevent_4ares_channel(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  1326. static PyObject *__pyx_int_1;
  1327. static PyObject *__pyx_int_2;
  1328. static PyObject *__pyx_int_3;
  1329. static PyObject *__pyx_int_4;
  1330. static PyObject *__pyx_int_8;
  1331. static PyObject *__pyx_int_16;
  1332. static PyObject *__pyx_int_neg_1;
  1333. static PyObject *__pyx_int_neg_8;
  1334. static int __pyx_k_;
  1335. static int __pyx_k__5;
  1336. static PyObject *__pyx_tuple__3;
  1337. static PyObject *__pyx_tuple__4;
  1338. static PyObject *__pyx_tuple__6;
  1339. static PyObject *__pyx_tuple__8;
  1340. static PyObject *__pyx_codeobj__7;
  1341. static PyObject *__pyx_codeobj__9;
  1342. /* "gevent/ares.pyx":126
  1343. *
  1344. *
  1345. * cdef _prepare_cares_flag_map(): # <<<<<<<<<<<<<<
  1346. * global _cares_flag_map
  1347. * import _socket
  1348. */
  1349. static PyObject *__pyx_f_6gevent_4ares__prepare_cares_flag_map(void) {
  1350. PyObject *__pyx_v__socket = NULL;
  1351. PyObject *__pyx_r = NULL;
  1352. __Pyx_RefNannyDeclarations
  1353. PyObject *__pyx_t_1 = NULL;
  1354. PyObject *__pyx_t_2 = NULL;
  1355. PyObject *__pyx_t_3 = NULL;
  1356. PyObject *__pyx_t_4 = NULL;
  1357. PyObject *__pyx_t_5 = NULL;
  1358. PyObject *__pyx_t_6 = NULL;
  1359. PyObject *__pyx_t_7 = NULL;
  1360. __Pyx_RefNannySetupContext("_prepare_cares_flag_map", 0);
  1361. /* "gevent/ares.pyx":128
  1362. * cdef _prepare_cares_flag_map():
  1363. * global _cares_flag_map
  1364. * import _socket # <<<<<<<<<<<<<<
  1365. * _cares_flag_map = [
  1366. * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST),
  1367. */
  1368. __pyx_t_1 = __Pyx_Import(__pyx_n_s_socket, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)
  1369. __Pyx_GOTREF(__pyx_t_1);
  1370. __pyx_v__socket = __pyx_t_1;
  1371. __pyx_t_1 = 0;
  1372. /* "gevent/ares.pyx":130
  1373. * import _socket
  1374. * _cares_flag_map = [
  1375. * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST), # <<<<<<<<<<<<<<
  1376. * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV),
  1377. * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN),
  1378. */
  1379. __pyx_t_1 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NUMERICHOST, __pyx_int_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
  1380. __Pyx_GOTREF(__pyx_t_1);
  1381. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_NI_NUMERICHOST); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error)
  1382. __Pyx_GOTREF(__pyx_t_2);
  1383. __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 130, __pyx_L1_error)
  1384. __Pyx_GOTREF(__pyx_t_3);
  1385. __Pyx_GIVEREF(__pyx_t_1);
  1386. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  1387. __Pyx_GIVEREF(__pyx_t_2);
  1388. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  1389. __pyx_t_1 = 0;
  1390. __pyx_t_2 = 0;
  1391. /* "gevent/ares.pyx":131
  1392. * _cares_flag_map = [
  1393. * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST),
  1394. * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV), # <<<<<<<<<<<<<<
  1395. * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN),
  1396. * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD),
  1397. */
  1398. __pyx_t_2 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NUMERICSERV, __pyx_int_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
  1399. __Pyx_GOTREF(__pyx_t_2);
  1400. __pyx_t_1 = __Pyx_PyInt_From_int(ARES_NI_NUMERICSERV); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error)
  1401. __Pyx_GOTREF(__pyx_t_1);
  1402. __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 131, __pyx_L1_error)
  1403. __Pyx_GOTREF(__pyx_t_4);
  1404. __Pyx_GIVEREF(__pyx_t_2);
  1405. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  1406. __Pyx_GIVEREF(__pyx_t_1);
  1407. PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  1408. __pyx_t_2 = 0;
  1409. __pyx_t_1 = 0;
  1410. /* "gevent/ares.pyx":132
  1411. * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST),
  1412. * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV),
  1413. * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN), # <<<<<<<<<<<<<<
  1414. * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD),
  1415. * (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)]
  1416. */
  1417. __pyx_t_1 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NOFQDN, __pyx_int_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error)
  1418. __Pyx_GOTREF(__pyx_t_1);
  1419. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_NI_NOFQDN); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error)
  1420. __Pyx_GOTREF(__pyx_t_2);
  1421. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 132, __pyx_L1_error)
  1422. __Pyx_GOTREF(__pyx_t_5);
  1423. __Pyx_GIVEREF(__pyx_t_1);
  1424. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  1425. __Pyx_GIVEREF(__pyx_t_2);
  1426. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
  1427. __pyx_t_1 = 0;
  1428. __pyx_t_2 = 0;
  1429. /* "gevent/ares.pyx":133
  1430. * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV),
  1431. * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN),
  1432. * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD), # <<<<<<<<<<<<<<
  1433. * (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)]
  1434. *
  1435. */
  1436. __pyx_t_2 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_NAMEREQD, __pyx_int_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
  1437. __Pyx_GOTREF(__pyx_t_2);
  1438. __pyx_t_1 = __Pyx_PyInt_From_int(ARES_NI_NAMEREQD); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
  1439. __Pyx_GOTREF(__pyx_t_1);
  1440. __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 133, __pyx_L1_error)
  1441. __Pyx_GOTREF(__pyx_t_6);
  1442. __Pyx_GIVEREF(__pyx_t_2);
  1443. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  1444. __Pyx_GIVEREF(__pyx_t_1);
  1445. PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  1446. __pyx_t_2 = 0;
  1447. __pyx_t_1 = 0;
  1448. /* "gevent/ares.pyx":134
  1449. * (getattr(_socket, 'NI_NOFQDN', 4), cares.ARES_NI_NOFQDN),
  1450. * (getattr(_socket, 'NI_NAMEREQD', 8), cares.ARES_NI_NAMEREQD),
  1451. * (getattr(_socket, 'NI_DGRAM', 16), cares.ARES_NI_DGRAM)] # <<<<<<<<<<<<<<
  1452. *
  1453. *
  1454. */
  1455. __pyx_t_1 = __Pyx_GetAttr3(__pyx_v__socket, __pyx_n_s_NI_DGRAM, __pyx_int_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error)
  1456. __Pyx_GOTREF(__pyx_t_1);
  1457. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_NI_DGRAM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error)
  1458. __Pyx_GOTREF(__pyx_t_2);
  1459. __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 134, __pyx_L1_error)
  1460. __Pyx_GOTREF(__pyx_t_7);
  1461. __Pyx_GIVEREF(__pyx_t_1);
  1462. PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
  1463. __Pyx_GIVEREF(__pyx_t_2);
  1464. PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
  1465. __pyx_t_1 = 0;
  1466. __pyx_t_2 = 0;
  1467. /* "gevent/ares.pyx":129
  1468. * global _cares_flag_map
  1469. * import _socket
  1470. * _cares_flag_map = [ # <<<<<<<<<<<<<<
  1471. * (getattr(_socket, 'NI_NUMERICHOST', 1), cares.ARES_NI_NUMERICHOST),
  1472. * (getattr(_socket, 'NI_NUMERICSERV', 2), cares.ARES_NI_NUMERICSERV),
  1473. */
  1474. __pyx_t_2 = PyList_New(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
  1475. __Pyx_GOTREF(__pyx_t_2);
  1476. __Pyx_GIVEREF(__pyx_t_3);
  1477. PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  1478. __Pyx_GIVEREF(__pyx_t_4);
  1479. PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
  1480. __Pyx_GIVEREF(__pyx_t_5);
  1481. PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
  1482. __Pyx_GIVEREF(__pyx_t_6);
  1483. PyList_SET_ITEM(__pyx_t_2, 3, __pyx_t_6);
  1484. __Pyx_GIVEREF(__pyx_t_7);
  1485. PyList_SET_ITEM(__pyx_t_2, 4, __pyx_t_7);
  1486. __pyx_t_3 = 0;
  1487. __pyx_t_4 = 0;
  1488. __pyx_t_5 = 0;
  1489. __pyx_t_6 = 0;
  1490. __pyx_t_7 = 0;
  1491. if (PyDict_SetItem(__pyx_d, __pyx_n_s_cares_flag_map, __pyx_t_2) < 0) __PYX_ERR(0, 129, __pyx_L1_error)
  1492. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1493. /* "gevent/ares.pyx":126
  1494. *
  1495. *
  1496. * cdef _prepare_cares_flag_map(): # <<<<<<<<<<<<<<
  1497. * global _cares_flag_map
  1498. * import _socket
  1499. */
  1500. /* function exit code */
  1501. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  1502. goto __pyx_L0;
  1503. __pyx_L1_error:;
  1504. __Pyx_XDECREF(__pyx_t_1);
  1505. __Pyx_XDECREF(__pyx_t_2);
  1506. __Pyx_XDECREF(__pyx_t_3);
  1507. __Pyx_XDECREF(__pyx_t_4);
  1508. __Pyx_XDECREF(__pyx_t_5);
  1509. __Pyx_XDECREF(__pyx_t_6);
  1510. __Pyx_XDECREF(__pyx_t_7);
  1511. __Pyx_AddTraceback("gevent.ares._prepare_cares_flag_map", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1512. __pyx_r = 0;
  1513. __pyx_L0:;
  1514. __Pyx_XDECREF(__pyx_v__socket);
  1515. __Pyx_XGIVEREF(__pyx_r);
  1516. __Pyx_RefNannyFinishContext();
  1517. return __pyx_r;
  1518. }
  1519. /* "gevent/ares.pyx":137
  1520. *
  1521. *
  1522. * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<<
  1523. * if _cares_flag_map is None:
  1524. * _prepare_cares_flag_map()
  1525. */
  1526. static PyObject *__pyx_pw_6gevent_4ares_1_convert_cares_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1527. static PyObject *__pyx_f_6gevent_4ares__convert_cares_flags(int __pyx_v_flags, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6gevent_4ares__convert_cares_flags *__pyx_optional_args) {
  1528. int __pyx_v_default = __pyx_k_;
  1529. PyObject *__pyx_v_socket_flag = NULL;
  1530. PyObject *__pyx_v_cares_flag = NULL;
  1531. PyObject *__pyx_r = NULL;
  1532. __Pyx_RefNannyDeclarations
  1533. PyObject *__pyx_t_1 = NULL;
  1534. int __pyx_t_2;
  1535. int __pyx_t_3;
  1536. PyObject *__pyx_t_4 = NULL;
  1537. Py_ssize_t __pyx_t_5;
  1538. PyObject *(*__pyx_t_6)(PyObject *);
  1539. PyObject *__pyx_t_7 = NULL;
  1540. PyObject *__pyx_t_8 = NULL;
  1541. PyObject *__pyx_t_9 = NULL;
  1542. PyObject *(*__pyx_t_10)(PyObject *);
  1543. int __pyx_t_11;
  1544. __Pyx_RefNannySetupContext("_convert_cares_flags", 0);
  1545. if (__pyx_optional_args) {
  1546. if (__pyx_optional_args->__pyx_n > 0) {
  1547. __pyx_v_default = __pyx_optional_args->__pyx_default;
  1548. }
  1549. }
  1550. /* "gevent/ares.pyx":138
  1551. *
  1552. * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE):
  1553. * if _cares_flag_map is None: # <<<<<<<<<<<<<<
  1554. * _prepare_cares_flag_map()
  1555. * for socket_flag, cares_flag in _cares_flag_map:
  1556. */
  1557. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cares_flag_map); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error)
  1558. __Pyx_GOTREF(__pyx_t_1);
  1559. __pyx_t_2 = (__pyx_t_1 == Py_None);
  1560. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1561. __pyx_t_3 = (__pyx_t_2 != 0);
  1562. if (__pyx_t_3) {
  1563. /* "gevent/ares.pyx":139
  1564. * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE):
  1565. * if _cares_flag_map is None:
  1566. * _prepare_cares_flag_map() # <<<<<<<<<<<<<<
  1567. * for socket_flag, cares_flag in _cares_flag_map:
  1568. * if socket_flag & flags:
  1569. */
  1570. __pyx_t_1 = __pyx_f_6gevent_4ares__prepare_cares_flag_map(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error)
  1571. __Pyx_GOTREF(__pyx_t_1);
  1572. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1573. /* "gevent/ares.pyx":138
  1574. *
  1575. * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE):
  1576. * if _cares_flag_map is None: # <<<<<<<<<<<<<<
  1577. * _prepare_cares_flag_map()
  1578. * for socket_flag, cares_flag in _cares_flag_map:
  1579. */
  1580. }
  1581. /* "gevent/ares.pyx":140
  1582. * if _cares_flag_map is None:
  1583. * _prepare_cares_flag_map()
  1584. * for socket_flag, cares_flag in _cares_flag_map: # <<<<<<<<<<<<<<
  1585. * if socket_flag & flags:
  1586. * default |= cares_flag
  1587. */
  1588. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_cares_flag_map); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
  1589. __Pyx_GOTREF(__pyx_t_1);
  1590. if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
  1591. __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
  1592. __pyx_t_6 = NULL;
  1593. } else {
  1594. __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error)
  1595. __Pyx_GOTREF(__pyx_t_4);
  1596. __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 140, __pyx_L1_error)
  1597. }
  1598. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1599. for (;;) {
  1600. if (likely(!__pyx_t_6)) {
  1601. if (likely(PyList_CheckExact(__pyx_t_4))) {
  1602. if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
  1603. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  1604. __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 140, __pyx_L1_error)
  1605. #else
  1606. __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
  1607. __Pyx_GOTREF(__pyx_t_1);
  1608. #endif
  1609. } else {
  1610. if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
  1611. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  1612. __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 140, __pyx_L1_error)
  1613. #else
  1614. __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
  1615. __Pyx_GOTREF(__pyx_t_1);
  1616. #endif
  1617. }
  1618. } else {
  1619. __pyx_t_1 = __pyx_t_6(__pyx_t_4);
  1620. if (unlikely(!__pyx_t_1)) {
  1621. PyObject* exc_type = PyErr_Occurred();
  1622. if (exc_type) {
  1623. if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  1624. else __PYX_ERR(0, 140, __pyx_L1_error)
  1625. }
  1626. break;
  1627. }
  1628. __Pyx_GOTREF(__pyx_t_1);
  1629. }
  1630. if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
  1631. PyObject* sequence = __pyx_t_1;
  1632. #if !CYTHON_COMPILING_IN_PYPY
  1633. Py_ssize_t size = Py_SIZE(sequence);
  1634. #else
  1635. Py_ssize_t size = PySequence_Size(sequence);
  1636. #endif
  1637. if (unlikely(size != 2)) {
  1638. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  1639. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  1640. __PYX_ERR(0, 140, __pyx_L1_error)
  1641. }
  1642. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  1643. if (likely(PyTuple_CheckExact(sequence))) {
  1644. __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0);
  1645. __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1);
  1646. } else {
  1647. __pyx_t_7 = PyList_GET_ITEM(sequence, 0);
  1648. __pyx_t_8 = PyList_GET_ITEM(sequence, 1);
  1649. }
  1650. __Pyx_INCREF(__pyx_t_7);
  1651. __Pyx_INCREF(__pyx_t_8);
  1652. #else
  1653. __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 140, __pyx_L1_error)
  1654. __Pyx_GOTREF(__pyx_t_7);
  1655. __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 140, __pyx_L1_error)
  1656. __Pyx_GOTREF(__pyx_t_8);
  1657. #endif
  1658. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1659. } else {
  1660. Py_ssize_t index = -1;
  1661. __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 140, __pyx_L1_error)
  1662. __Pyx_GOTREF(__pyx_t_9);
  1663. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1664. __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
  1665. index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
  1666. __Pyx_GOTREF(__pyx_t_7);
  1667. index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L6_unpacking_failed;
  1668. __Pyx_GOTREF(__pyx_t_8);
  1669. if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 140, __pyx_L1_error)
  1670. __pyx_t_10 = NULL;
  1671. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  1672. goto __pyx_L7_unpacking_done;
  1673. __pyx_L6_unpacking_failed:;
  1674. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  1675. __pyx_t_10 = NULL;
  1676. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  1677. __PYX_ERR(0, 140, __pyx_L1_error)
  1678. __pyx_L7_unpacking_done:;
  1679. }
  1680. __Pyx_XDECREF_SET(__pyx_v_socket_flag, __pyx_t_7);
  1681. __pyx_t_7 = 0;
  1682. __Pyx_XDECREF_SET(__pyx_v_cares_flag, __pyx_t_8);
  1683. __pyx_t_8 = 0;
  1684. /* "gevent/ares.pyx":141
  1685. * _prepare_cares_flag_map()
  1686. * for socket_flag, cares_flag in _cares_flag_map:
  1687. * if socket_flag & flags: # <<<<<<<<<<<<<<
  1688. * default |= cares_flag
  1689. * flags &= ~socket_flag
  1690. */
  1691. __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)
  1692. __Pyx_GOTREF(__pyx_t_1);
  1693. __pyx_t_8 = PyNumber_And(__pyx_v_socket_flag, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 141, __pyx_L1_error)
  1694. __Pyx_GOTREF(__pyx_t_8);
  1695. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1696. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 141, __pyx_L1_error)
  1697. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1698. if (__pyx_t_3) {
  1699. /* "gevent/ares.pyx":142
  1700. * for socket_flag, cares_flag in _cares_flag_map:
  1701. * if socket_flag & flags:
  1702. * default |= cares_flag # <<<<<<<<<<<<<<
  1703. * flags &= ~socket_flag
  1704. * if not flags:
  1705. */
  1706. __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_default); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 142, __pyx_L1_error)
  1707. __Pyx_GOTREF(__pyx_t_8);
  1708. __pyx_t_1 = PyNumber_InPlaceOr(__pyx_t_8, __pyx_v_cares_flag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error)
  1709. __Pyx_GOTREF(__pyx_t_1);
  1710. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1711. __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error)
  1712. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1713. __pyx_v_default = __pyx_t_11;
  1714. /* "gevent/ares.pyx":143
  1715. * if socket_flag & flags:
  1716. * default |= cares_flag
  1717. * flags &= ~socket_flag # <<<<<<<<<<<<<<
  1718. * if not flags:
  1719. * return default
  1720. */
  1721. __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
  1722. __Pyx_GOTREF(__pyx_t_1);
  1723. __pyx_t_8 = PyNumber_Invert(__pyx_v_socket_flag); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 143, __pyx_L1_error)
  1724. __Pyx_GOTREF(__pyx_t_8);
  1725. __pyx_t_7 = PyNumber_InPlaceAnd(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 143, __pyx_L1_error)
  1726. __Pyx_GOTREF(__pyx_t_7);
  1727. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1728. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1729. __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
  1730. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1731. __pyx_v_flags = __pyx_t_11;
  1732. /* "gevent/ares.pyx":141
  1733. * _prepare_cares_flag_map()
  1734. * for socket_flag, cares_flag in _cares_flag_map:
  1735. * if socket_flag & flags: # <<<<<<<<<<<<<<
  1736. * default |= cares_flag
  1737. * flags &= ~socket_flag
  1738. */
  1739. }
  1740. /* "gevent/ares.pyx":144
  1741. * default |= cares_flag
  1742. * flags &= ~socket_flag
  1743. * if not flags: # <<<<<<<<<<<<<<
  1744. * return default
  1745. * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags)
  1746. */
  1747. __pyx_t_3 = ((!(__pyx_v_flags != 0)) != 0);
  1748. if (__pyx_t_3) {
  1749. /* "gevent/ares.pyx":145
  1750. * flags &= ~socket_flag
  1751. * if not flags:
  1752. * return default # <<<<<<<<<<<<<<
  1753. * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags)
  1754. *
  1755. */
  1756. __Pyx_XDECREF(__pyx_r);
  1757. __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_default); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 145, __pyx_L1_error)
  1758. __Pyx_GOTREF(__pyx_t_7);
  1759. __pyx_r = __pyx_t_7;
  1760. __pyx_t_7 = 0;
  1761. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1762. goto __pyx_L0;
  1763. /* "gevent/ares.pyx":144
  1764. * default |= cares_flag
  1765. * flags &= ~socket_flag
  1766. * if not flags: # <<<<<<<<<<<<<<
  1767. * return default
  1768. * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags)
  1769. */
  1770. }
  1771. /* "gevent/ares.pyx":140
  1772. * if _cares_flag_map is None:
  1773. * _prepare_cares_flag_map()
  1774. * for socket_flag, cares_flag in _cares_flag_map: # <<<<<<<<<<<<<<
  1775. * if socket_flag & flags:
  1776. * default |= cares_flag
  1777. */
  1778. }
  1779. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1780. /* "gevent/ares.pyx":146
  1781. * if not flags:
  1782. * return default
  1783. * raise gaierror(-1, "Bad value for ai_flags: 0x%x" % flags) # <<<<<<<<<<<<<<
  1784. *
  1785. *
  1786. */
  1787. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 146, __pyx_L1_error)
  1788. __Pyx_GOTREF(__pyx_t_7);
  1789. __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 146, __pyx_L1_error)
  1790. __Pyx_GOTREF(__pyx_t_8);
  1791. __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Bad_value_for_ai_flags_0x_x, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
  1792. __Pyx_GOTREF(__pyx_t_1);
  1793. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1794. __pyx_t_8 = NULL;
  1795. __pyx_t_11 = 0;
  1796. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
  1797. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
  1798. if (likely(__pyx_t_8)) {
  1799. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  1800. __Pyx_INCREF(__pyx_t_8);
  1801. __Pyx_INCREF(function);
  1802. __Pyx_DECREF_SET(__pyx_t_7, function);
  1803. __pyx_t_11 = 1;
  1804. }
  1805. }
  1806. #if CYTHON_FAST_PYCALL
  1807. if (PyFunction_Check(__pyx_t_7)) {
  1808. PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_int_neg_1, __pyx_t_1};
  1809. __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error)
  1810. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  1811. __Pyx_GOTREF(__pyx_t_4);
  1812. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1813. } else
  1814. #endif
  1815. #if CYTHON_FAST_PYCCALL
  1816. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  1817. PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_int_neg_1, __pyx_t_1};
  1818. __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error)
  1819. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  1820. __Pyx_GOTREF(__pyx_t_4);
  1821. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1822. } else
  1823. #endif
  1824. {
  1825. __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 146, __pyx_L1_error)
  1826. __Pyx_GOTREF(__pyx_t_9);
  1827. if (__pyx_t_8) {
  1828. __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
  1829. }
  1830. __Pyx_INCREF(__pyx_int_neg_1);
  1831. __Pyx_GIVEREF(__pyx_int_neg_1);
  1832. PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, __pyx_int_neg_1);
  1833. __Pyx_GIVEREF(__pyx_t_1);
  1834. PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, __pyx_t_1);
  1835. __pyx_t_1 = 0;
  1836. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error)
  1837. __Pyx_GOTREF(__pyx_t_4);
  1838. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  1839. }
  1840. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1841. __Pyx_Raise(__pyx_t_4, 0, 0, 0);
  1842. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1843. __PYX_ERR(0, 146, __pyx_L1_error)
  1844. /* "gevent/ares.pyx":137
  1845. *
  1846. *
  1847. * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<<
  1848. * if _cares_flag_map is None:
  1849. * _prepare_cares_flag_map()
  1850. */
  1851. /* function exit code */
  1852. __pyx_L1_error:;
  1853. __Pyx_XDECREF(__pyx_t_1);
  1854. __Pyx_XDECREF(__pyx_t_4);
  1855. __Pyx_XDECREF(__pyx_t_7);
  1856. __Pyx_XDECREF(__pyx_t_8);
  1857. __Pyx_XDECREF(__pyx_t_9);
  1858. __Pyx_AddTraceback("gevent.ares._convert_cares_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1859. __pyx_r = 0;
  1860. __pyx_L0:;
  1861. __Pyx_XDECREF(__pyx_v_socket_flag);
  1862. __Pyx_XDECREF(__pyx_v_cares_flag);
  1863. __Pyx_XGIVEREF(__pyx_r);
  1864. __Pyx_RefNannyFinishContext();
  1865. return __pyx_r;
  1866. }
  1867. /* Python wrapper */
  1868. static PyObject *__pyx_pw_6gevent_4ares_1_convert_cares_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1869. static PyObject *__pyx_pw_6gevent_4ares_1_convert_cares_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1870. int __pyx_v_flags;
  1871. int __pyx_v_default;
  1872. PyObject *__pyx_r = 0;
  1873. __Pyx_RefNannyDeclarations
  1874. __Pyx_RefNannySetupContext("_convert_cares_flags (wrapper)", 0);
  1875. {
  1876. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_flags,&__pyx_n_s_default,0};
  1877. PyObject* values[2] = {0,0};
  1878. if (unlikely(__pyx_kwds)) {
  1879. Py_ssize_t kw_args;
  1880. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1881. switch (pos_args) {
  1882. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1883. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1884. case 0: break;
  1885. default: goto __pyx_L5_argtuple_error;
  1886. }
  1887. kw_args = PyDict_Size(__pyx_kwds);
  1888. switch (pos_args) {
  1889. case 0:
  1890. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
  1891. else goto __pyx_L5_argtuple_error;
  1892. case 1:
  1893. if (kw_args > 0) {
  1894. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_default);
  1895. if (value) { values[1] = value; kw_args--; }
  1896. }
  1897. }
  1898. if (unlikely(kw_args > 0)) {
  1899. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_convert_cares_flags") < 0)) __PYX_ERR(0, 137, __pyx_L3_error)
  1900. }
  1901. } else {
  1902. switch (PyTuple_GET_SIZE(__pyx_args)) {
  1903. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1904. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1905. break;
  1906. default: goto __pyx_L5_argtuple_error;
  1907. }
  1908. }
  1909. __pyx_v_flags = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L3_error)
  1910. if (values[1]) {
  1911. __pyx_v_default = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_default == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L3_error)
  1912. } else {
  1913. __pyx_v_default = __pyx_k_;
  1914. }
  1915. }
  1916. goto __pyx_L4_argument_unpacking_done;
  1917. __pyx_L5_argtuple_error:;
  1918. __Pyx_RaiseArgtupleInvalid("_convert_cares_flags", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 137, __pyx_L3_error)
  1919. __pyx_L3_error:;
  1920. __Pyx_AddTraceback("gevent.ares._convert_cares_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1921. __Pyx_RefNannyFinishContext();
  1922. return NULL;
  1923. __pyx_L4_argument_unpacking_done:;
  1924. __pyx_r = __pyx_pf_6gevent_4ares__convert_cares_flags(__pyx_self, __pyx_v_flags, __pyx_v_default);
  1925. /* function exit code */
  1926. __Pyx_RefNannyFinishContext();
  1927. return __pyx_r;
  1928. }
  1929. static PyObject *__pyx_pf_6gevent_4ares__convert_cares_flags(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_flags, int __pyx_v_default) {
  1930. PyObject *__pyx_r = NULL;
  1931. __Pyx_RefNannyDeclarations
  1932. PyObject *__pyx_t_1 = NULL;
  1933. struct __pyx_opt_args_6gevent_4ares__convert_cares_flags __pyx_t_2;
  1934. __Pyx_RefNannySetupContext("_convert_cares_flags", 0);
  1935. __Pyx_XDECREF(__pyx_r);
  1936. __pyx_t_2.__pyx_n = 1;
  1937. __pyx_t_2.__pyx_default = __pyx_v_default;
  1938. __pyx_t_1 = __pyx_f_6gevent_4ares__convert_cares_flags(__pyx_v_flags, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error)
  1939. __Pyx_GOTREF(__pyx_t_1);
  1940. __pyx_r = __pyx_t_1;
  1941. __pyx_t_1 = 0;
  1942. goto __pyx_L0;
  1943. /* function exit code */
  1944. __pyx_L1_error:;
  1945. __Pyx_XDECREF(__pyx_t_1);
  1946. __Pyx_AddTraceback("gevent.ares._convert_cares_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1947. __pyx_r = NULL;
  1948. __pyx_L0:;
  1949. __Pyx_XGIVEREF(__pyx_r);
  1950. __Pyx_RefNannyFinishContext();
  1951. return __pyx_r;
  1952. }
  1953. /* "gevent/ares.pyx":149
  1954. *
  1955. *
  1956. * cpdef strerror(code): # <<<<<<<<<<<<<<
  1957. * return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code))
  1958. *
  1959. */
  1960. static PyObject *__pyx_pw_6gevent_4ares_3strerror(PyObject *__pyx_self, PyObject *__pyx_v_code); /*proto*/
  1961. static PyObject *__pyx_f_6gevent_4ares_strerror(PyObject *__pyx_v_code, CYTHON_UNUSED int __pyx_skip_dispatch) {
  1962. PyObject *__pyx_r = NULL;
  1963. __Pyx_RefNannyDeclarations
  1964. PyObject *__pyx_t_1 = NULL;
  1965. PyObject *__pyx_t_2 = NULL;
  1966. PyObject *__pyx_t_3 = NULL;
  1967. PyObject *__pyx_t_4 = NULL;
  1968. PyObject *__pyx_t_5 = NULL;
  1969. int __pyx_t_6;
  1970. int __pyx_t_7;
  1971. __Pyx_RefNannySetupContext("strerror", 0);
  1972. /* "gevent/ares.pyx":150
  1973. *
  1974. * cpdef strerror(code):
  1975. * return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code)) # <<<<<<<<<<<<<<
  1976. *
  1977. *
  1978. */
  1979. __Pyx_XDECREF(__pyx_r);
  1980. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_ares_errors); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 150, __pyx_L1_error)
  1981. __Pyx_GOTREF(__pyx_t_3);
  1982. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
  1983. __Pyx_GOTREF(__pyx_t_4);
  1984. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  1985. __pyx_t_3 = NULL;
  1986. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  1987. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
  1988. if (likely(__pyx_t_3)) {
  1989. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  1990. __Pyx_INCREF(__pyx_t_3);
  1991. __Pyx_INCREF(function);
  1992. __Pyx_DECREF_SET(__pyx_t_4, function);
  1993. }
  1994. }
  1995. if (!__pyx_t_3) {
  1996. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_code); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error)
  1997. __Pyx_GOTREF(__pyx_t_2);
  1998. } else {
  1999. #if CYTHON_FAST_PYCALL
  2000. if (PyFunction_Check(__pyx_t_4)) {
  2001. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_code};
  2002. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error)
  2003. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2004. __Pyx_GOTREF(__pyx_t_2);
  2005. } else
  2006. #endif
  2007. #if CYTHON_FAST_PYCCALL
  2008. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  2009. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_code};
  2010. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error)
  2011. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2012. __Pyx_GOTREF(__pyx_t_2);
  2013. } else
  2014. #endif
  2015. {
  2016. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 150, __pyx_L1_error)
  2017. __Pyx_GOTREF(__pyx_t_5);
  2018. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  2019. __Pyx_INCREF(__pyx_v_code);
  2020. __Pyx_GIVEREF(__pyx_v_code);
  2021. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_code);
  2022. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error)
  2023. __Pyx_GOTREF(__pyx_t_2);
  2024. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2025. }
  2026. }
  2027. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2028. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 150, __pyx_L1_error)
  2029. if (!__pyx_t_6) {
  2030. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2031. } else {
  2032. __Pyx_INCREF(__pyx_t_2);
  2033. __pyx_t_1 = __pyx_t_2;
  2034. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2035. goto __pyx_L3_bool_binop_done;
  2036. }
  2037. __Pyx_INCREF(__pyx_v_code);
  2038. __pyx_t_1 = __pyx_v_code;
  2039. __pyx_L3_bool_binop_done:;
  2040. __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_code); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 150, __pyx_L1_error)
  2041. __pyx_t_2 = __Pyx_PyBytes_FromString(ares_strerror(__pyx_t_7)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error)
  2042. __Pyx_GOTREF(__pyx_t_2);
  2043. __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
  2044. __Pyx_GOTREF(__pyx_t_4);
  2045. __Pyx_GIVEREF(__pyx_t_1);
  2046. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  2047. __Pyx_GIVEREF(__pyx_t_2);
  2048. PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  2049. __pyx_t_1 = 0;
  2050. __pyx_t_2 = 0;
  2051. __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error)
  2052. __Pyx_GOTREF(__pyx_t_2);
  2053. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2054. __pyx_r = __pyx_t_2;
  2055. __pyx_t_2 = 0;
  2056. goto __pyx_L0;
  2057. /* "gevent/ares.pyx":149
  2058. *
  2059. *
  2060. * cpdef strerror(code): # <<<<<<<<<<<<<<
  2061. * return '%s: %s' % (_ares_errors.get(code) or code, cares.ares_strerror(code))
  2062. *
  2063. */
  2064. /* function exit code */
  2065. __pyx_L1_error:;
  2066. __Pyx_XDECREF(__pyx_t_1);
  2067. __Pyx_XDECREF(__pyx_t_2);
  2068. __Pyx_XDECREF(__pyx_t_3);
  2069. __Pyx_XDECREF(__pyx_t_4);
  2070. __Pyx_XDECREF(__pyx_t_5);
  2071. __Pyx_AddTraceback("gevent.ares.strerror", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2072. __pyx_r = 0;
  2073. __pyx_L0:;
  2074. __Pyx_XGIVEREF(__pyx_r);
  2075. __Pyx_RefNannyFinishContext();
  2076. return __pyx_r;
  2077. }
  2078. /* Python wrapper */
  2079. static PyObject *__pyx_pw_6gevent_4ares_3strerror(PyObject *__pyx_self, PyObject *__pyx_v_code); /*proto*/
  2080. static PyObject *__pyx_pw_6gevent_4ares_3strerror(PyObject *__pyx_self, PyObject *__pyx_v_code) {
  2081. PyObject *__pyx_r = 0;
  2082. __Pyx_RefNannyDeclarations
  2083. __Pyx_RefNannySetupContext("strerror (wrapper)", 0);
  2084. __pyx_r = __pyx_pf_6gevent_4ares_2strerror(__pyx_self, ((PyObject *)__pyx_v_code));
  2085. /* function exit code */
  2086. __Pyx_RefNannyFinishContext();
  2087. return __pyx_r;
  2088. }
  2089. static PyObject *__pyx_pf_6gevent_4ares_2strerror(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_code) {
  2090. PyObject *__pyx_r = NULL;
  2091. __Pyx_RefNannyDeclarations
  2092. PyObject *__pyx_t_1 = NULL;
  2093. __Pyx_RefNannySetupContext("strerror", 0);
  2094. __Pyx_XDECREF(__pyx_r);
  2095. __pyx_t_1 = __pyx_f_6gevent_4ares_strerror(__pyx_v_code, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
  2096. __Pyx_GOTREF(__pyx_t_1);
  2097. __pyx_r = __pyx_t_1;
  2098. __pyx_t_1 = 0;
  2099. goto __pyx_L0;
  2100. /* function exit code */
  2101. __pyx_L1_error:;
  2102. __Pyx_XDECREF(__pyx_t_1);
  2103. __Pyx_AddTraceback("gevent.ares.strerror", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2104. __pyx_r = NULL;
  2105. __pyx_L0:;
  2106. __Pyx_XGIVEREF(__pyx_r);
  2107. __Pyx_RefNannyFinishContext();
  2108. return __pyx_r;
  2109. }
  2110. /* "gevent/ares.pyx":157
  2111. *
  2112. *
  2113. * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): # <<<<<<<<<<<<<<
  2114. * if not data:
  2115. * return
  2116. */
  2117. static void __pyx_f_6gevent_4ares_gevent_sock_state_callback(void *__pyx_v_data, int __pyx_v_s, int __pyx_v_read, int __pyx_v_write) {
  2118. struct PyGeventAresChannelObject *__pyx_v_ch = 0;
  2119. __Pyx_RefNannyDeclarations
  2120. int __pyx_t_1;
  2121. PyObject *__pyx_t_2 = NULL;
  2122. __Pyx_RefNannySetupContext("gevent_sock_state_callback", 0);
  2123. /* "gevent/ares.pyx":158
  2124. *
  2125. * cdef void gevent_sock_state_callback(void *data, int s, int read, int write):
  2126. * if not data: # <<<<<<<<<<<<<<
  2127. * return
  2128. * cdef channel ch = <channel>data
  2129. */
  2130. __pyx_t_1 = ((!(__pyx_v_data != 0)) != 0);
  2131. if (__pyx_t_1) {
  2132. /* "gevent/ares.pyx":159
  2133. * cdef void gevent_sock_state_callback(void *data, int s, int read, int write):
  2134. * if not data:
  2135. * return # <<<<<<<<<<<<<<
  2136. * cdef channel ch = <channel>data
  2137. * ch._sock_state_callback(s, read, write)
  2138. */
  2139. goto __pyx_L0;
  2140. /* "gevent/ares.pyx":158
  2141. *
  2142. * cdef void gevent_sock_state_callback(void *data, int s, int read, int write):
  2143. * if not data: # <<<<<<<<<<<<<<
  2144. * return
  2145. * cdef channel ch = <channel>data
  2146. */
  2147. }
  2148. /* "gevent/ares.pyx":160
  2149. * if not data:
  2150. * return
  2151. * cdef channel ch = <channel>data # <<<<<<<<<<<<<<
  2152. * ch._sock_state_callback(s, read, write)
  2153. *
  2154. */
  2155. __pyx_t_2 = ((PyObject *)__pyx_v_data);
  2156. __Pyx_INCREF(__pyx_t_2);
  2157. __pyx_v_ch = ((struct PyGeventAresChannelObject *)__pyx_t_2);
  2158. __pyx_t_2 = 0;
  2159. /* "gevent/ares.pyx":161
  2160. * return
  2161. * cdef channel ch = <channel>data
  2162. * ch._sock_state_callback(s, read, write) # <<<<<<<<<<<<<<
  2163. *
  2164. *
  2165. */
  2166. __pyx_t_2 = ((struct __pyx_vtabstruct_6gevent_4ares_channel *)__pyx_v_ch->__pyx_vtab)->_sock_state_callback(__pyx_v_ch, __pyx_v_s, __pyx_v_read, __pyx_v_write); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error)
  2167. __Pyx_GOTREF(__pyx_t_2);
  2168. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2169. /* "gevent/ares.pyx":157
  2170. *
  2171. *
  2172. * cdef void gevent_sock_state_callback(void *data, int s, int read, int write): # <<<<<<<<<<<<<<
  2173. * if not data:
  2174. * return
  2175. */
  2176. /* function exit code */
  2177. goto __pyx_L0;
  2178. __pyx_L1_error:;
  2179. __Pyx_XDECREF(__pyx_t_2);
  2180. __Pyx_WriteUnraisable("gevent.ares.gevent_sock_state_callback", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  2181. __pyx_L0:;
  2182. __Pyx_XDECREF((PyObject *)__pyx_v_ch);
  2183. __Pyx_RefNannyFinishContext();
  2184. }
  2185. /* "gevent/ares.pyx":168
  2186. * cdef public object exception
  2187. *
  2188. * def __init__(self, object value=None, object exception=None): # <<<<<<<<<<<<<<
  2189. * self.value = value
  2190. * self.exception = exception
  2191. */
  2192. /* Python wrapper */
  2193. static int __pyx_pw_6gevent_4ares_6result_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2194. static int __pyx_pw_6gevent_4ares_6result_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2195. PyObject *__pyx_v_value = 0;
  2196. PyObject *__pyx_v_exception = 0;
  2197. int __pyx_r;
  2198. __Pyx_RefNannyDeclarations
  2199. __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  2200. {
  2201. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,&__pyx_n_s_exception,0};
  2202. PyObject* values[2] = {0,0};
  2203. values[0] = ((PyObject *)Py_None);
  2204. values[1] = ((PyObject *)Py_None);
  2205. if (unlikely(__pyx_kwds)) {
  2206. Py_ssize_t kw_args;
  2207. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  2208. switch (pos_args) {
  2209. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2210. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2211. case 0: break;
  2212. default: goto __pyx_L5_argtuple_error;
  2213. }
  2214. kw_args = PyDict_Size(__pyx_kwds);
  2215. switch (pos_args) {
  2216. case 0:
  2217. if (kw_args > 0) {
  2218. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value);
  2219. if (value) { values[0] = value; kw_args--; }
  2220. }
  2221. case 1:
  2222. if (kw_args > 0) {
  2223. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_exception);
  2224. if (value) { values[1] = value; kw_args--; }
  2225. }
  2226. }
  2227. if (unlikely(kw_args > 0)) {
  2228. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 168, __pyx_L3_error)
  2229. }
  2230. } else {
  2231. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2232. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2233. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2234. case 0: break;
  2235. default: goto __pyx_L5_argtuple_error;
  2236. }
  2237. }
  2238. __pyx_v_value = values[0];
  2239. __pyx_v_exception = values[1];
  2240. }
  2241. goto __pyx_L4_argument_unpacking_done;
  2242. __pyx_L5_argtuple_error:;
  2243. __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 168, __pyx_L3_error)
  2244. __pyx_L3_error:;
  2245. __Pyx_AddTraceback("gevent.ares.result.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2246. __Pyx_RefNannyFinishContext();
  2247. return -1;
  2248. __pyx_L4_argument_unpacking_done:;
  2249. __pyx_r = __pyx_pf_6gevent_4ares_6result___init__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self), __pyx_v_value, __pyx_v_exception);
  2250. /* function exit code */
  2251. __Pyx_RefNannyFinishContext();
  2252. return __pyx_r;
  2253. }
  2254. static int __pyx_pf_6gevent_4ares_6result___init__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value, PyObject *__pyx_v_exception) {
  2255. int __pyx_r;
  2256. __Pyx_RefNannyDeclarations
  2257. __Pyx_RefNannySetupContext("__init__", 0);
  2258. /* "gevent/ares.pyx":169
  2259. *
  2260. * def __init__(self, object value=None, object exception=None):
  2261. * self.value = value # <<<<<<<<<<<<<<
  2262. * self.exception = exception
  2263. *
  2264. */
  2265. __Pyx_INCREF(__pyx_v_value);
  2266. __Pyx_GIVEREF(__pyx_v_value);
  2267. __Pyx_GOTREF(__pyx_v_self->value);
  2268. __Pyx_DECREF(__pyx_v_self->value);
  2269. __pyx_v_self->value = __pyx_v_value;
  2270. /* "gevent/ares.pyx":170
  2271. * def __init__(self, object value=None, object exception=None):
  2272. * self.value = value
  2273. * self.exception = exception # <<<<<<<<<<<<<<
  2274. *
  2275. * def __repr__(self):
  2276. */
  2277. __Pyx_INCREF(__pyx_v_exception);
  2278. __Pyx_GIVEREF(__pyx_v_exception);
  2279. __Pyx_GOTREF(__pyx_v_self->exception);
  2280. __Pyx_DECREF(__pyx_v_self->exception);
  2281. __pyx_v_self->exception = __pyx_v_exception;
  2282. /* "gevent/ares.pyx":168
  2283. * cdef public object exception
  2284. *
  2285. * def __init__(self, object value=None, object exception=None): # <<<<<<<<<<<<<<
  2286. * self.value = value
  2287. * self.exception = exception
  2288. */
  2289. /* function exit code */
  2290. __pyx_r = 0;
  2291. __Pyx_RefNannyFinishContext();
  2292. return __pyx_r;
  2293. }
  2294. /* "gevent/ares.pyx":172
  2295. * self.exception = exception
  2296. *
  2297. * def __repr__(self): # <<<<<<<<<<<<<<
  2298. * if self.exception is None:
  2299. * return '%s(%r)' % (self.__class__.__name__, self.value)
  2300. */
  2301. /* Python wrapper */
  2302. static PyObject *__pyx_pw_6gevent_4ares_6result_3__repr__(PyObject *__pyx_v_self); /*proto*/
  2303. static PyObject *__pyx_pw_6gevent_4ares_6result_3__repr__(PyObject *__pyx_v_self) {
  2304. PyObject *__pyx_r = 0;
  2305. __Pyx_RefNannyDeclarations
  2306. __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  2307. __pyx_r = __pyx_pf_6gevent_4ares_6result_2__repr__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self));
  2308. /* function exit code */
  2309. __Pyx_RefNannyFinishContext();
  2310. return __pyx_r;
  2311. }
  2312. static PyObject *__pyx_pf_6gevent_4ares_6result_2__repr__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) {
  2313. PyObject *__pyx_r = NULL;
  2314. __Pyx_RefNannyDeclarations
  2315. int __pyx_t_1;
  2316. int __pyx_t_2;
  2317. PyObject *__pyx_t_3 = NULL;
  2318. PyObject *__pyx_t_4 = NULL;
  2319. __Pyx_RefNannySetupContext("__repr__", 0);
  2320. /* "gevent/ares.pyx":173
  2321. *
  2322. * def __repr__(self):
  2323. * if self.exception is None: # <<<<<<<<<<<<<<
  2324. * return '%s(%r)' % (self.__class__.__name__, self.value)
  2325. * elif self.value is None:
  2326. */
  2327. __pyx_t_1 = (__pyx_v_self->exception == Py_None);
  2328. __pyx_t_2 = (__pyx_t_1 != 0);
  2329. if (__pyx_t_2) {
  2330. /* "gevent/ares.pyx":174
  2331. * def __repr__(self):
  2332. * if self.exception is None:
  2333. * return '%s(%r)' % (self.__class__.__name__, self.value) # <<<<<<<<<<<<<<
  2334. * elif self.value is None:
  2335. * return '%s(exception=%r)' % (self.__class__.__name__, self.exception)
  2336. */
  2337. __Pyx_XDECREF(__pyx_r);
  2338. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error)
  2339. __Pyx_GOTREF(__pyx_t_3);
  2340. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error)
  2341. __Pyx_GOTREF(__pyx_t_4);
  2342. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2343. __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error)
  2344. __Pyx_GOTREF(__pyx_t_3);
  2345. __Pyx_GIVEREF(__pyx_t_4);
  2346. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  2347. __Pyx_INCREF(__pyx_v_self->value);
  2348. __Pyx_GIVEREF(__pyx_v_self->value);
  2349. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->value);
  2350. __pyx_t_4 = 0;
  2351. __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L1_error)
  2352. __Pyx_GOTREF(__pyx_t_4);
  2353. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2354. __pyx_r = __pyx_t_4;
  2355. __pyx_t_4 = 0;
  2356. goto __pyx_L0;
  2357. /* "gevent/ares.pyx":173
  2358. *
  2359. * def __repr__(self):
  2360. * if self.exception is None: # <<<<<<<<<<<<<<
  2361. * return '%s(%r)' % (self.__class__.__name__, self.value)
  2362. * elif self.value is None:
  2363. */
  2364. }
  2365. /* "gevent/ares.pyx":175
  2366. * if self.exception is None:
  2367. * return '%s(%r)' % (self.__class__.__name__, self.value)
  2368. * elif self.value is None: # <<<<<<<<<<<<<<
  2369. * return '%s(exception=%r)' % (self.__class__.__name__, self.exception)
  2370. * else:
  2371. */
  2372. __pyx_t_2 = (__pyx_v_self->value == Py_None);
  2373. __pyx_t_1 = (__pyx_t_2 != 0);
  2374. if (__pyx_t_1) {
  2375. /* "gevent/ares.pyx":176
  2376. * return '%s(%r)' % (self.__class__.__name__, self.value)
  2377. * elif self.value is None:
  2378. * return '%s(exception=%r)' % (self.__class__.__name__, self.exception) # <<<<<<<<<<<<<<
  2379. * else:
  2380. * return '%s(value=%r, exception=%r)' % (self.__class__.__name__, self.value, self.exception)
  2381. */
  2382. __Pyx_XDECREF(__pyx_r);
  2383. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L1_error)
  2384. __Pyx_GOTREF(__pyx_t_4);
  2385. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error)
  2386. __Pyx_GOTREF(__pyx_t_3);
  2387. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2388. __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L1_error)
  2389. __Pyx_GOTREF(__pyx_t_4);
  2390. __Pyx_GIVEREF(__pyx_t_3);
  2391. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  2392. __Pyx_INCREF(__pyx_v_self->exception);
  2393. __Pyx_GIVEREF(__pyx_v_self->exception);
  2394. PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->exception);
  2395. __pyx_t_3 = 0;
  2396. __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s_exception_r, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error)
  2397. __Pyx_GOTREF(__pyx_t_3);
  2398. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2399. __pyx_r = __pyx_t_3;
  2400. __pyx_t_3 = 0;
  2401. goto __pyx_L0;
  2402. /* "gevent/ares.pyx":175
  2403. * if self.exception is None:
  2404. * return '%s(%r)' % (self.__class__.__name__, self.value)
  2405. * elif self.value is None: # <<<<<<<<<<<<<<
  2406. * return '%s(exception=%r)' % (self.__class__.__name__, self.exception)
  2407. * else:
  2408. */
  2409. }
  2410. /* "gevent/ares.pyx":178
  2411. * return '%s(exception=%r)' % (self.__class__.__name__, self.exception)
  2412. * else:
  2413. * return '%s(value=%r, exception=%r)' % (self.__class__.__name__, self.value, self.exception) # <<<<<<<<<<<<<<
  2414. * # add repr_recursive precaution
  2415. *
  2416. */
  2417. /*else*/ {
  2418. __Pyx_XDECREF(__pyx_r);
  2419. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error)
  2420. __Pyx_GOTREF(__pyx_t_3);
  2421. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error)
  2422. __Pyx_GOTREF(__pyx_t_4);
  2423. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2424. __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error)
  2425. __Pyx_GOTREF(__pyx_t_3);
  2426. __Pyx_GIVEREF(__pyx_t_4);
  2427. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  2428. __Pyx_INCREF(__pyx_v_self->value);
  2429. __Pyx_GIVEREF(__pyx_v_self->value);
  2430. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->value);
  2431. __Pyx_INCREF(__pyx_v_self->exception);
  2432. __Pyx_GIVEREF(__pyx_v_self->exception);
  2433. PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_self->exception);
  2434. __pyx_t_4 = 0;
  2435. __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_value_r_exception_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error)
  2436. __Pyx_GOTREF(__pyx_t_4);
  2437. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2438. __pyx_r = __pyx_t_4;
  2439. __pyx_t_4 = 0;
  2440. goto __pyx_L0;
  2441. }
  2442. /* "gevent/ares.pyx":172
  2443. * self.exception = exception
  2444. *
  2445. * def __repr__(self): # <<<<<<<<<<<<<<
  2446. * if self.exception is None:
  2447. * return '%s(%r)' % (self.__class__.__name__, self.value)
  2448. */
  2449. /* function exit code */
  2450. __pyx_L1_error:;
  2451. __Pyx_XDECREF(__pyx_t_3);
  2452. __Pyx_XDECREF(__pyx_t_4);
  2453. __Pyx_AddTraceback("gevent.ares.result.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2454. __pyx_r = NULL;
  2455. __pyx_L0:;
  2456. __Pyx_XGIVEREF(__pyx_r);
  2457. __Pyx_RefNannyFinishContext();
  2458. return __pyx_r;
  2459. }
  2460. /* "gevent/ares.pyx":181
  2461. * # add repr_recursive precaution
  2462. *
  2463. * def successful(self): # <<<<<<<<<<<<<<
  2464. * return self.exception is None
  2465. *
  2466. */
  2467. /* Python wrapper */
  2468. static PyObject *__pyx_pw_6gevent_4ares_6result_5successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  2469. static PyObject *__pyx_pw_6gevent_4ares_6result_5successful(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  2470. PyObject *__pyx_r = 0;
  2471. __Pyx_RefNannyDeclarations
  2472. __Pyx_RefNannySetupContext("successful (wrapper)", 0);
  2473. __pyx_r = __pyx_pf_6gevent_4ares_6result_4successful(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self));
  2474. /* function exit code */
  2475. __Pyx_RefNannyFinishContext();
  2476. return __pyx_r;
  2477. }
  2478. static PyObject *__pyx_pf_6gevent_4ares_6result_4successful(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) {
  2479. PyObject *__pyx_r = NULL;
  2480. __Pyx_RefNannyDeclarations
  2481. int __pyx_t_1;
  2482. PyObject *__pyx_t_2 = NULL;
  2483. __Pyx_RefNannySetupContext("successful", 0);
  2484. /* "gevent/ares.pyx":182
  2485. *
  2486. * def successful(self):
  2487. * return self.exception is None # <<<<<<<<<<<<<<
  2488. *
  2489. * def get(self):
  2490. */
  2491. __Pyx_XDECREF(__pyx_r);
  2492. __pyx_t_1 = (__pyx_v_self->exception == Py_None);
  2493. __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 182, __pyx_L1_error)
  2494. __Pyx_GOTREF(__pyx_t_2);
  2495. __pyx_r = __pyx_t_2;
  2496. __pyx_t_2 = 0;
  2497. goto __pyx_L0;
  2498. /* "gevent/ares.pyx":181
  2499. * # add repr_recursive precaution
  2500. *
  2501. * def successful(self): # <<<<<<<<<<<<<<
  2502. * return self.exception is None
  2503. *
  2504. */
  2505. /* function exit code */
  2506. __pyx_L1_error:;
  2507. __Pyx_XDECREF(__pyx_t_2);
  2508. __Pyx_AddTraceback("gevent.ares.result.successful", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2509. __pyx_r = NULL;
  2510. __pyx_L0:;
  2511. __Pyx_XGIVEREF(__pyx_r);
  2512. __Pyx_RefNannyFinishContext();
  2513. return __pyx_r;
  2514. }
  2515. /* "gevent/ares.pyx":184
  2516. * return self.exception is None
  2517. *
  2518. * def get(self): # <<<<<<<<<<<<<<
  2519. * if self.exception is not None:
  2520. * raise self.exception
  2521. */
  2522. /* Python wrapper */
  2523. static PyObject *__pyx_pw_6gevent_4ares_6result_7get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  2524. static PyObject *__pyx_pw_6gevent_4ares_6result_7get(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  2525. PyObject *__pyx_r = 0;
  2526. __Pyx_RefNannyDeclarations
  2527. __Pyx_RefNannySetupContext("get (wrapper)", 0);
  2528. __pyx_r = __pyx_pf_6gevent_4ares_6result_6get(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self));
  2529. /* function exit code */
  2530. __Pyx_RefNannyFinishContext();
  2531. return __pyx_r;
  2532. }
  2533. static PyObject *__pyx_pf_6gevent_4ares_6result_6get(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) {
  2534. PyObject *__pyx_r = NULL;
  2535. __Pyx_RefNannyDeclarations
  2536. int __pyx_t_1;
  2537. int __pyx_t_2;
  2538. __Pyx_RefNannySetupContext("get", 0);
  2539. /* "gevent/ares.pyx":185
  2540. *
  2541. * def get(self):
  2542. * if self.exception is not None: # <<<<<<<<<<<<<<
  2543. * raise self.exception
  2544. * return self.value
  2545. */
  2546. __pyx_t_1 = (__pyx_v_self->exception != Py_None);
  2547. __pyx_t_2 = (__pyx_t_1 != 0);
  2548. if (__pyx_t_2) {
  2549. /* "gevent/ares.pyx":186
  2550. * def get(self):
  2551. * if self.exception is not None:
  2552. * raise self.exception # <<<<<<<<<<<<<<
  2553. * return self.value
  2554. *
  2555. */
  2556. __Pyx_Raise(__pyx_v_self->exception, 0, 0, 0);
  2557. __PYX_ERR(0, 186, __pyx_L1_error)
  2558. /* "gevent/ares.pyx":185
  2559. *
  2560. * def get(self):
  2561. * if self.exception is not None: # <<<<<<<<<<<<<<
  2562. * raise self.exception
  2563. * return self.value
  2564. */
  2565. }
  2566. /* "gevent/ares.pyx":187
  2567. * if self.exception is not None:
  2568. * raise self.exception
  2569. * return self.value # <<<<<<<<<<<<<<
  2570. *
  2571. *
  2572. */
  2573. __Pyx_XDECREF(__pyx_r);
  2574. __Pyx_INCREF(__pyx_v_self->value);
  2575. __pyx_r = __pyx_v_self->value;
  2576. goto __pyx_L0;
  2577. /* "gevent/ares.pyx":184
  2578. * return self.exception is None
  2579. *
  2580. * def get(self): # <<<<<<<<<<<<<<
  2581. * if self.exception is not None:
  2582. * raise self.exception
  2583. */
  2584. /* function exit code */
  2585. __pyx_L1_error:;
  2586. __Pyx_AddTraceback("gevent.ares.result.get", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2587. __pyx_r = NULL;
  2588. __pyx_L0:;
  2589. __Pyx_XGIVEREF(__pyx_r);
  2590. __Pyx_RefNannyFinishContext();
  2591. return __pyx_r;
  2592. }
  2593. /* "gevent/ares.pyx":165
  2594. *
  2595. * cdef class result:
  2596. * cdef public object value # <<<<<<<<<<<<<<
  2597. * cdef public object exception
  2598. *
  2599. */
  2600. /* Python wrapper */
  2601. static PyObject *__pyx_pw_6gevent_4ares_6result_5value_1__get__(PyObject *__pyx_v_self); /*proto*/
  2602. static PyObject *__pyx_pw_6gevent_4ares_6result_5value_1__get__(PyObject *__pyx_v_self) {
  2603. PyObject *__pyx_r = 0;
  2604. __Pyx_RefNannyDeclarations
  2605. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  2606. __pyx_r = __pyx_pf_6gevent_4ares_6result_5value___get__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self));
  2607. /* function exit code */
  2608. __Pyx_RefNannyFinishContext();
  2609. return __pyx_r;
  2610. }
  2611. static PyObject *__pyx_pf_6gevent_4ares_6result_5value___get__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) {
  2612. PyObject *__pyx_r = NULL;
  2613. __Pyx_RefNannyDeclarations
  2614. __Pyx_RefNannySetupContext("__get__", 0);
  2615. __Pyx_XDECREF(__pyx_r);
  2616. __Pyx_INCREF(__pyx_v_self->value);
  2617. __pyx_r = __pyx_v_self->value;
  2618. goto __pyx_L0;
  2619. /* function exit code */
  2620. __pyx_L0:;
  2621. __Pyx_XGIVEREF(__pyx_r);
  2622. __Pyx_RefNannyFinishContext();
  2623. return __pyx_r;
  2624. }
  2625. /* Python wrapper */
  2626. static int __pyx_pw_6gevent_4ares_6result_5value_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
  2627. static int __pyx_pw_6gevent_4ares_6result_5value_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  2628. int __pyx_r;
  2629. __Pyx_RefNannyDeclarations
  2630. __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  2631. __pyx_r = __pyx_pf_6gevent_4ares_6result_5value_2__set__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self), ((PyObject *)__pyx_v_value));
  2632. /* function exit code */
  2633. __Pyx_RefNannyFinishContext();
  2634. return __pyx_r;
  2635. }
  2636. static int __pyx_pf_6gevent_4ares_6result_5value_2__set__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value) {
  2637. int __pyx_r;
  2638. __Pyx_RefNannyDeclarations
  2639. __Pyx_RefNannySetupContext("__set__", 0);
  2640. __Pyx_INCREF(__pyx_v_value);
  2641. __Pyx_GIVEREF(__pyx_v_value);
  2642. __Pyx_GOTREF(__pyx_v_self->value);
  2643. __Pyx_DECREF(__pyx_v_self->value);
  2644. __pyx_v_self->value = __pyx_v_value;
  2645. /* function exit code */
  2646. __pyx_r = 0;
  2647. __Pyx_RefNannyFinishContext();
  2648. return __pyx_r;
  2649. }
  2650. /* Python wrapper */
  2651. static int __pyx_pw_6gevent_4ares_6result_5value_5__del__(PyObject *__pyx_v_self); /*proto*/
  2652. static int __pyx_pw_6gevent_4ares_6result_5value_5__del__(PyObject *__pyx_v_self) {
  2653. int __pyx_r;
  2654. __Pyx_RefNannyDeclarations
  2655. __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  2656. __pyx_r = __pyx_pf_6gevent_4ares_6result_5value_4__del__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self));
  2657. /* function exit code */
  2658. __Pyx_RefNannyFinishContext();
  2659. return __pyx_r;
  2660. }
  2661. static int __pyx_pf_6gevent_4ares_6result_5value_4__del__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) {
  2662. int __pyx_r;
  2663. __Pyx_RefNannyDeclarations
  2664. __Pyx_RefNannySetupContext("__del__", 0);
  2665. __Pyx_INCREF(Py_None);
  2666. __Pyx_GIVEREF(Py_None);
  2667. __Pyx_GOTREF(__pyx_v_self->value);
  2668. __Pyx_DECREF(__pyx_v_self->value);
  2669. __pyx_v_self->value = Py_None;
  2670. /* function exit code */
  2671. __pyx_r = 0;
  2672. __Pyx_RefNannyFinishContext();
  2673. return __pyx_r;
  2674. }
  2675. /* "gevent/ares.pyx":166
  2676. * cdef class result:
  2677. * cdef public object value
  2678. * cdef public object exception # <<<<<<<<<<<<<<
  2679. *
  2680. * def __init__(self, object value=None, object exception=None):
  2681. */
  2682. /* Python wrapper */
  2683. static PyObject *__pyx_pw_6gevent_4ares_6result_9exception_1__get__(PyObject *__pyx_v_self); /*proto*/
  2684. static PyObject *__pyx_pw_6gevent_4ares_6result_9exception_1__get__(PyObject *__pyx_v_self) {
  2685. PyObject *__pyx_r = 0;
  2686. __Pyx_RefNannyDeclarations
  2687. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  2688. __pyx_r = __pyx_pf_6gevent_4ares_6result_9exception___get__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self));
  2689. /* function exit code */
  2690. __Pyx_RefNannyFinishContext();
  2691. return __pyx_r;
  2692. }
  2693. static PyObject *__pyx_pf_6gevent_4ares_6result_9exception___get__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) {
  2694. PyObject *__pyx_r = NULL;
  2695. __Pyx_RefNannyDeclarations
  2696. __Pyx_RefNannySetupContext("__get__", 0);
  2697. __Pyx_XDECREF(__pyx_r);
  2698. __Pyx_INCREF(__pyx_v_self->exception);
  2699. __pyx_r = __pyx_v_self->exception;
  2700. goto __pyx_L0;
  2701. /* function exit code */
  2702. __pyx_L0:;
  2703. __Pyx_XGIVEREF(__pyx_r);
  2704. __Pyx_RefNannyFinishContext();
  2705. return __pyx_r;
  2706. }
  2707. /* Python wrapper */
  2708. static int __pyx_pw_6gevent_4ares_6result_9exception_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
  2709. static int __pyx_pw_6gevent_4ares_6result_9exception_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  2710. int __pyx_r;
  2711. __Pyx_RefNannyDeclarations
  2712. __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  2713. __pyx_r = __pyx_pf_6gevent_4ares_6result_9exception_2__set__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self), ((PyObject *)__pyx_v_value));
  2714. /* function exit code */
  2715. __Pyx_RefNannyFinishContext();
  2716. return __pyx_r;
  2717. }
  2718. static int __pyx_pf_6gevent_4ares_6result_9exception_2__set__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self, PyObject *__pyx_v_value) {
  2719. int __pyx_r;
  2720. __Pyx_RefNannyDeclarations
  2721. __Pyx_RefNannySetupContext("__set__", 0);
  2722. __Pyx_INCREF(__pyx_v_value);
  2723. __Pyx_GIVEREF(__pyx_v_value);
  2724. __Pyx_GOTREF(__pyx_v_self->exception);
  2725. __Pyx_DECREF(__pyx_v_self->exception);
  2726. __pyx_v_self->exception = __pyx_v_value;
  2727. /* function exit code */
  2728. __pyx_r = 0;
  2729. __Pyx_RefNannyFinishContext();
  2730. return __pyx_r;
  2731. }
  2732. /* Python wrapper */
  2733. static int __pyx_pw_6gevent_4ares_6result_9exception_5__del__(PyObject *__pyx_v_self); /*proto*/
  2734. static int __pyx_pw_6gevent_4ares_6result_9exception_5__del__(PyObject *__pyx_v_self) {
  2735. int __pyx_r;
  2736. __Pyx_RefNannyDeclarations
  2737. __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  2738. __pyx_r = __pyx_pf_6gevent_4ares_6result_9exception_4__del__(((struct __pyx_obj_6gevent_4ares_result *)__pyx_v_self));
  2739. /* function exit code */
  2740. __Pyx_RefNannyFinishContext();
  2741. return __pyx_r;
  2742. }
  2743. static int __pyx_pf_6gevent_4ares_6result_9exception_4__del__(struct __pyx_obj_6gevent_4ares_result *__pyx_v_self) {
  2744. int __pyx_r;
  2745. __Pyx_RefNannyDeclarations
  2746. __Pyx_RefNannySetupContext("__del__", 0);
  2747. __Pyx_INCREF(Py_None);
  2748. __Pyx_GIVEREF(Py_None);
  2749. __Pyx_GOTREF(__pyx_v_self->exception);
  2750. __Pyx_DECREF(__pyx_v_self->exception);
  2751. __pyx_v_self->exception = Py_None;
  2752. /* function exit code */
  2753. __pyx_r = 0;
  2754. __Pyx_RefNannyFinishContext();
  2755. return __pyx_r;
  2756. }
  2757. /* "gevent/ares.pyx":192
  2758. * class ares_host_result(tuple):
  2759. *
  2760. * def __new__(cls, family, iterable): # <<<<<<<<<<<<<<
  2761. * cdef object self = tuple.__new__(cls, iterable)
  2762. * self.family = family
  2763. */
  2764. /* Python wrapper */
  2765. static PyObject *__pyx_pw_6gevent_4ares_16ares_host_result_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2766. static PyMethodDef __pyx_mdef_6gevent_4ares_16ares_host_result_1__new__ = {"__new__", (PyCFunction)__pyx_pw_6gevent_4ares_16ares_host_result_1__new__, METH_VARARGS|METH_KEYWORDS, 0};
  2767. static PyObject *__pyx_pw_6gevent_4ares_16ares_host_result_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2768. PyObject *__pyx_v_cls = 0;
  2769. PyObject *__pyx_v_family = 0;
  2770. PyObject *__pyx_v_iterable = 0;
  2771. PyObject *__pyx_r = 0;
  2772. __Pyx_RefNannyDeclarations
  2773. __Pyx_RefNannySetupContext("__new__ (wrapper)", 0);
  2774. {
  2775. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_family,&__pyx_n_s_iterable,0};
  2776. PyObject* values[3] = {0,0,0};
  2777. if (unlikely(__pyx_kwds)) {
  2778. Py_ssize_t kw_args;
  2779. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  2780. switch (pos_args) {
  2781. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  2782. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2783. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2784. case 0: break;
  2785. default: goto __pyx_L5_argtuple_error;
  2786. }
  2787. kw_args = PyDict_Size(__pyx_kwds);
  2788. switch (pos_args) {
  2789. case 0:
  2790. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
  2791. else goto __pyx_L5_argtuple_error;
  2792. case 1:
  2793. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_family)) != 0)) kw_args--;
  2794. else {
  2795. __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, 1); __PYX_ERR(0, 192, __pyx_L3_error)
  2796. }
  2797. case 2:
  2798. if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_iterable)) != 0)) kw_args--;
  2799. else {
  2800. __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, 2); __PYX_ERR(0, 192, __pyx_L3_error)
  2801. }
  2802. }
  2803. if (unlikely(kw_args > 0)) {
  2804. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__new__") < 0)) __PYX_ERR(0, 192, __pyx_L3_error)
  2805. }
  2806. } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
  2807. goto __pyx_L5_argtuple_error;
  2808. } else {
  2809. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2810. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2811. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  2812. }
  2813. __pyx_v_cls = values[0];
  2814. __pyx_v_family = values[1];
  2815. __pyx_v_iterable = values[2];
  2816. }
  2817. goto __pyx_L4_argument_unpacking_done;
  2818. __pyx_L5_argtuple_error:;
  2819. __Pyx_RaiseArgtupleInvalid("__new__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 192, __pyx_L3_error)
  2820. __pyx_L3_error:;
  2821. __Pyx_AddTraceback("gevent.ares.ares_host_result.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2822. __Pyx_RefNannyFinishContext();
  2823. return NULL;
  2824. __pyx_L4_argument_unpacking_done:;
  2825. __pyx_r = __pyx_pf_6gevent_4ares_16ares_host_result___new__(__pyx_self, __pyx_v_cls, __pyx_v_family, __pyx_v_iterable);
  2826. /* function exit code */
  2827. __Pyx_RefNannyFinishContext();
  2828. return __pyx_r;
  2829. }
  2830. static PyObject *__pyx_pf_6gevent_4ares_16ares_host_result___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_family, PyObject *__pyx_v_iterable) {
  2831. PyObject *__pyx_v_self = 0;
  2832. PyObject *__pyx_r = NULL;
  2833. __Pyx_RefNannyDeclarations
  2834. PyObject *__pyx_t_1 = NULL;
  2835. PyObject *__pyx_t_2 = NULL;
  2836. PyObject *__pyx_t_3 = NULL;
  2837. int __pyx_t_4;
  2838. PyObject *__pyx_t_5 = NULL;
  2839. __Pyx_RefNannySetupContext("__new__", 0);
  2840. /* "gevent/ares.pyx":193
  2841. *
  2842. * def __new__(cls, family, iterable):
  2843. * cdef object self = tuple.__new__(cls, iterable) # <<<<<<<<<<<<<<
  2844. * self.family = family
  2845. * return self
  2846. */
  2847. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
  2848. __Pyx_GOTREF(__pyx_t_2);
  2849. __pyx_t_3 = NULL;
  2850. __pyx_t_4 = 0;
  2851. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  2852. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  2853. if (likely(__pyx_t_3)) {
  2854. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  2855. __Pyx_INCREF(__pyx_t_3);
  2856. __Pyx_INCREF(function);
  2857. __Pyx_DECREF_SET(__pyx_t_2, function);
  2858. __pyx_t_4 = 1;
  2859. }
  2860. }
  2861. #if CYTHON_FAST_PYCALL
  2862. if (PyFunction_Check(__pyx_t_2)) {
  2863. PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_cls, __pyx_v_iterable};
  2864. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
  2865. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2866. __Pyx_GOTREF(__pyx_t_1);
  2867. } else
  2868. #endif
  2869. #if CYTHON_FAST_PYCCALL
  2870. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  2871. PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_cls, __pyx_v_iterable};
  2872. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
  2873. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2874. __Pyx_GOTREF(__pyx_t_1);
  2875. } else
  2876. #endif
  2877. {
  2878. __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 193, __pyx_L1_error)
  2879. __Pyx_GOTREF(__pyx_t_5);
  2880. if (__pyx_t_3) {
  2881. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
  2882. }
  2883. __Pyx_INCREF(__pyx_v_cls);
  2884. __Pyx_GIVEREF(__pyx_v_cls);
  2885. PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_cls);
  2886. __Pyx_INCREF(__pyx_v_iterable);
  2887. __Pyx_GIVEREF(__pyx_v_iterable);
  2888. PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_iterable);
  2889. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
  2890. __Pyx_GOTREF(__pyx_t_1);
  2891. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2892. }
  2893. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2894. __pyx_v_self = __pyx_t_1;
  2895. __pyx_t_1 = 0;
  2896. /* "gevent/ares.pyx":194
  2897. * def __new__(cls, family, iterable):
  2898. * cdef object self = tuple.__new__(cls, iterable)
  2899. * self.family = family # <<<<<<<<<<<<<<
  2900. * return self
  2901. *
  2902. */
  2903. if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_family, __pyx_v_family) < 0) __PYX_ERR(0, 194, __pyx_L1_error)
  2904. /* "gevent/ares.pyx":195
  2905. * cdef object self = tuple.__new__(cls, iterable)
  2906. * self.family = family
  2907. * return self # <<<<<<<<<<<<<<
  2908. *
  2909. * def __getnewargs__(self):
  2910. */
  2911. __Pyx_XDECREF(__pyx_r);
  2912. __Pyx_INCREF(__pyx_v_self);
  2913. __pyx_r = __pyx_v_self;
  2914. goto __pyx_L0;
  2915. /* "gevent/ares.pyx":192
  2916. * class ares_host_result(tuple):
  2917. *
  2918. * def __new__(cls, family, iterable): # <<<<<<<<<<<<<<
  2919. * cdef object self = tuple.__new__(cls, iterable)
  2920. * self.family = family
  2921. */
  2922. /* function exit code */
  2923. __pyx_L1_error:;
  2924. __Pyx_XDECREF(__pyx_t_1);
  2925. __Pyx_XDECREF(__pyx_t_2);
  2926. __Pyx_XDECREF(__pyx_t_3);
  2927. __Pyx_XDECREF(__pyx_t_5);
  2928. __Pyx_AddTraceback("gevent.ares.ares_host_result.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2929. __pyx_r = NULL;
  2930. __pyx_L0:;
  2931. __Pyx_XDECREF(__pyx_v_self);
  2932. __Pyx_XGIVEREF(__pyx_r);
  2933. __Pyx_RefNannyFinishContext();
  2934. return __pyx_r;
  2935. }
  2936. /* "gevent/ares.pyx":197
  2937. * return self
  2938. *
  2939. * def __getnewargs__(self): # <<<<<<<<<<<<<<
  2940. * return (self.family, tuple(self))
  2941. *
  2942. */
  2943. /* Python wrapper */
  2944. static PyObject *__pyx_pw_6gevent_4ares_16ares_host_result_3__getnewargs__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
  2945. static PyMethodDef __pyx_mdef_6gevent_4ares_16ares_host_result_3__getnewargs__ = {"__getnewargs__", (PyCFunction)__pyx_pw_6gevent_4ares_16ares_host_result_3__getnewargs__, METH_O, 0};
  2946. static PyObject *__pyx_pw_6gevent_4ares_16ares_host_result_3__getnewargs__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  2947. PyObject *__pyx_r = 0;
  2948. __Pyx_RefNannyDeclarations
  2949. __Pyx_RefNannySetupContext("__getnewargs__ (wrapper)", 0);
  2950. __pyx_r = __pyx_pf_6gevent_4ares_16ares_host_result_2__getnewargs__(__pyx_self, ((PyObject *)__pyx_v_self));
  2951. /* function exit code */
  2952. __Pyx_RefNannyFinishContext();
  2953. return __pyx_r;
  2954. }
  2955. static PyObject *__pyx_pf_6gevent_4ares_16ares_host_result_2__getnewargs__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  2956. PyObject *__pyx_r = NULL;
  2957. __Pyx_RefNannyDeclarations
  2958. PyObject *__pyx_t_1 = NULL;
  2959. PyObject *__pyx_t_2 = NULL;
  2960. PyObject *__pyx_t_3 = NULL;
  2961. __Pyx_RefNannySetupContext("__getnewargs__", 0);
  2962. /* "gevent/ares.pyx":198
  2963. *
  2964. * def __getnewargs__(self):
  2965. * return (self.family, tuple(self)) # <<<<<<<<<<<<<<
  2966. *
  2967. *
  2968. */
  2969. __Pyx_XDECREF(__pyx_r);
  2970. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_family); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
  2971. __Pyx_GOTREF(__pyx_t_1);
  2972. __pyx_t_2 = PySequence_Tuple(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 198, __pyx_L1_error)
  2973. __Pyx_GOTREF(__pyx_t_2);
  2974. __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
  2975. __Pyx_GOTREF(__pyx_t_3);
  2976. __Pyx_GIVEREF(__pyx_t_1);
  2977. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  2978. __Pyx_GIVEREF(__pyx_t_2);
  2979. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  2980. __pyx_t_1 = 0;
  2981. __pyx_t_2 = 0;
  2982. __pyx_r = __pyx_t_3;
  2983. __pyx_t_3 = 0;
  2984. goto __pyx_L0;
  2985. /* "gevent/ares.pyx":197
  2986. * return self
  2987. *
  2988. * def __getnewargs__(self): # <<<<<<<<<<<<<<
  2989. * return (self.family, tuple(self))
  2990. *
  2991. */
  2992. /* function exit code */
  2993. __pyx_L1_error:;
  2994. __Pyx_XDECREF(__pyx_t_1);
  2995. __Pyx_XDECREF(__pyx_t_2);
  2996. __Pyx_XDECREF(__pyx_t_3);
  2997. __Pyx_AddTraceback("gevent.ares.ares_host_result.__getnewargs__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2998. __pyx_r = NULL;
  2999. __pyx_L0:;
  3000. __Pyx_XGIVEREF(__pyx_r);
  3001. __Pyx_RefNannyFinishContext();
  3002. return __pyx_r;
  3003. }
  3004. /* "gevent/ares.pyx":201
  3005. *
  3006. *
  3007. * cdef void gevent_ares_host_callback(void *arg, int status, int timeouts, hostent* host): # <<<<<<<<<<<<<<
  3008. * cdef channel channel
  3009. * cdef object callback
  3010. */
  3011. static void __pyx_f_6gevent_4ares_gevent_ares_host_callback(void *__pyx_v_arg, int __pyx_v_status, CYTHON_UNUSED int __pyx_v_timeouts, struct hostent *__pyx_v_host) {
  3012. struct PyGeventAresChannelObject *__pyx_v_channel = 0;
  3013. PyObject *__pyx_v_callback = 0;
  3014. PyObject *__pyx_v_host_result = 0;
  3015. __Pyx_RefNannyDeclarations
  3016. PyObject *__pyx_t_1 = NULL;
  3017. PyObject *__pyx_t_2 = NULL;
  3018. PyObject *__pyx_t_3 = NULL;
  3019. PyObject *__pyx_t_4 = NULL;
  3020. PyObject *__pyx_t_5 = NULL;
  3021. PyObject *__pyx_t_6 = NULL;
  3022. int __pyx_t_7;
  3023. int __pyx_t_8;
  3024. PyObject *__pyx_t_9 = NULL;
  3025. PyObject *__pyx_t_10 = NULL;
  3026. PyObject *__pyx_t_11 = NULL;
  3027. int __pyx_t_12;
  3028. PyObject *__pyx_t_13 = NULL;
  3029. PyObject *__pyx_t_14 = NULL;
  3030. PyObject *__pyx_t_15 = NULL;
  3031. PyObject *__pyx_t_16 = NULL;
  3032. PyObject *__pyx_t_17 = NULL;
  3033. __Pyx_RefNannySetupContext("gevent_ares_host_callback", 0);
  3034. /* "gevent/ares.pyx":204
  3035. * cdef channel channel
  3036. * cdef object callback
  3037. * channel, callback = <tuple>arg # <<<<<<<<<<<<<<
  3038. * Py_DECREF(<PyObjectPtr>arg)
  3039. * cdef object host_result
  3040. */
  3041. __pyx_t_1 = ((PyObject *)__pyx_v_arg);
  3042. __Pyx_INCREF(__pyx_t_1);
  3043. if (likely(__pyx_t_1 != Py_None)) {
  3044. PyObject* sequence = __pyx_t_1;
  3045. #if !CYTHON_COMPILING_IN_PYPY
  3046. Py_ssize_t size = Py_SIZE(sequence);
  3047. #else
  3048. Py_ssize_t size = PySequence_Size(sequence);
  3049. #endif
  3050. if (unlikely(size != 2)) {
  3051. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  3052. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  3053. __PYX_ERR(0, 204, __pyx_L1_error)
  3054. }
  3055. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  3056. __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
  3057. __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
  3058. __Pyx_INCREF(__pyx_t_2);
  3059. __Pyx_INCREF(__pyx_t_3);
  3060. #else
  3061. __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error)
  3062. __Pyx_GOTREF(__pyx_t_2);
  3063. __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
  3064. __Pyx_GOTREF(__pyx_t_3);
  3065. #endif
  3066. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3067. } else {
  3068. __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 204, __pyx_L1_error)
  3069. }
  3070. if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6gevent_4ares_channel))))) __PYX_ERR(0, 204, __pyx_L1_error)
  3071. __pyx_v_channel = ((struct PyGeventAresChannelObject *)__pyx_t_2);
  3072. __pyx_t_2 = 0;
  3073. __pyx_v_callback = __pyx_t_3;
  3074. __pyx_t_3 = 0;
  3075. /* "gevent/ares.pyx":205
  3076. * cdef object callback
  3077. * channel, callback = <tuple>arg
  3078. * Py_DECREF(<PyObjectPtr>arg) # <<<<<<<<<<<<<<
  3079. * cdef object host_result
  3080. * try:
  3081. */
  3082. Py_DECREF(((PyObject*)__pyx_v_arg));
  3083. /* "gevent/ares.pyx":207
  3084. * Py_DECREF(<PyObjectPtr>arg)
  3085. * cdef object host_result
  3086. * try: # <<<<<<<<<<<<<<
  3087. * if status or not host:
  3088. * callback(result(None, gaierror(status, strerror(status))))
  3089. */
  3090. {
  3091. __Pyx_PyThreadState_declare
  3092. __Pyx_PyThreadState_assign
  3093. __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
  3094. __Pyx_XGOTREF(__pyx_t_4);
  3095. __Pyx_XGOTREF(__pyx_t_5);
  3096. __Pyx_XGOTREF(__pyx_t_6);
  3097. /*try:*/ {
  3098. /* "gevent/ares.pyx":208
  3099. * cdef object host_result
  3100. * try:
  3101. * if status or not host: # <<<<<<<<<<<<<<
  3102. * callback(result(None, gaierror(status, strerror(status))))
  3103. * else:
  3104. */
  3105. __pyx_t_8 = (__pyx_v_status != 0);
  3106. if (!__pyx_t_8) {
  3107. } else {
  3108. __pyx_t_7 = __pyx_t_8;
  3109. goto __pyx_L12_bool_binop_done;
  3110. }
  3111. __pyx_t_8 = ((!(__pyx_v_host != 0)) != 0);
  3112. __pyx_t_7 = __pyx_t_8;
  3113. __pyx_L12_bool_binop_done:;
  3114. if (__pyx_t_7) {
  3115. /* "gevent/ares.pyx":209
  3116. * try:
  3117. * if status or not host:
  3118. * callback(result(None, gaierror(status, strerror(status)))) # <<<<<<<<<<<<<<
  3119. * else:
  3120. * try:
  3121. */
  3122. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L3_error)
  3123. __Pyx_GOTREF(__pyx_t_2);
  3124. __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 209, __pyx_L3_error)
  3125. __Pyx_GOTREF(__pyx_t_9);
  3126. __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 209, __pyx_L3_error)
  3127. __Pyx_GOTREF(__pyx_t_10);
  3128. __pyx_t_11 = __pyx_f_6gevent_4ares_strerror(__pyx_t_10, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 209, __pyx_L3_error)
  3129. __Pyx_GOTREF(__pyx_t_11);
  3130. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3131. __pyx_t_10 = NULL;
  3132. __pyx_t_12 = 0;
  3133. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  3134. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
  3135. if (likely(__pyx_t_10)) {
  3136. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  3137. __Pyx_INCREF(__pyx_t_10);
  3138. __Pyx_INCREF(function);
  3139. __Pyx_DECREF_SET(__pyx_t_2, function);
  3140. __pyx_t_12 = 1;
  3141. }
  3142. }
  3143. #if CYTHON_FAST_PYCALL
  3144. if (PyFunction_Check(__pyx_t_2)) {
  3145. PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_9, __pyx_t_11};
  3146. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L3_error)
  3147. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  3148. __Pyx_GOTREF(__pyx_t_3);
  3149. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  3150. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  3151. } else
  3152. #endif
  3153. #if CYTHON_FAST_PYCCALL
  3154. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  3155. PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_9, __pyx_t_11};
  3156. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L3_error)
  3157. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  3158. __Pyx_GOTREF(__pyx_t_3);
  3159. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  3160. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  3161. } else
  3162. #endif
  3163. {
  3164. __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 209, __pyx_L3_error)
  3165. __Pyx_GOTREF(__pyx_t_13);
  3166. if (__pyx_t_10) {
  3167. __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10); __pyx_t_10 = NULL;
  3168. }
  3169. __Pyx_GIVEREF(__pyx_t_9);
  3170. PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_9);
  3171. __Pyx_GIVEREF(__pyx_t_11);
  3172. PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_11);
  3173. __pyx_t_9 = 0;
  3174. __pyx_t_11 = 0;
  3175. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L3_error)
  3176. __Pyx_GOTREF(__pyx_t_3);
  3177. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  3178. }
  3179. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3180. __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 209, __pyx_L3_error)
  3181. __Pyx_GOTREF(__pyx_t_2);
  3182. __Pyx_INCREF(Py_None);
  3183. __Pyx_GIVEREF(Py_None);
  3184. PyTuple_SET_ITEM(__pyx_t_2, 0, Py_None);
  3185. __Pyx_GIVEREF(__pyx_t_3);
  3186. PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
  3187. __pyx_t_3 = 0;
  3188. __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L3_error)
  3189. __Pyx_GOTREF(__pyx_t_3);
  3190. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3191. __Pyx_INCREF(__pyx_v_callback);
  3192. __pyx_t_2 = __pyx_v_callback; __pyx_t_13 = NULL;
  3193. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  3194. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
  3195. if (likely(__pyx_t_13)) {
  3196. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  3197. __Pyx_INCREF(__pyx_t_13);
  3198. __Pyx_INCREF(function);
  3199. __Pyx_DECREF_SET(__pyx_t_2, function);
  3200. }
  3201. }
  3202. if (!__pyx_t_13) {
  3203. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L3_error)
  3204. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3205. __Pyx_GOTREF(__pyx_t_1);
  3206. } else {
  3207. #if CYTHON_FAST_PYCALL
  3208. if (PyFunction_Check(__pyx_t_2)) {
  3209. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_3};
  3210. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L3_error)
  3211. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  3212. __Pyx_GOTREF(__pyx_t_1);
  3213. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3214. } else
  3215. #endif
  3216. #if CYTHON_FAST_PYCCALL
  3217. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  3218. PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_3};
  3219. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L3_error)
  3220. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  3221. __Pyx_GOTREF(__pyx_t_1);
  3222. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3223. } else
  3224. #endif
  3225. {
  3226. __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 209, __pyx_L3_error)
  3227. __Pyx_GOTREF(__pyx_t_11);
  3228. __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_13); __pyx_t_13 = NULL;
  3229. __Pyx_GIVEREF(__pyx_t_3);
  3230. PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_3);
  3231. __pyx_t_3 = 0;
  3232. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L3_error)
  3233. __Pyx_GOTREF(__pyx_t_1);
  3234. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  3235. }
  3236. }
  3237. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3238. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3239. /* "gevent/ares.pyx":208
  3240. * cdef object host_result
  3241. * try:
  3242. * if status or not host: # <<<<<<<<<<<<<<
  3243. * callback(result(None, gaierror(status, strerror(status))))
  3244. * else:
  3245. */
  3246. goto __pyx_L11;
  3247. }
  3248. /* "gevent/ares.pyx":211
  3249. * callback(result(None, gaierror(status, strerror(status))))
  3250. * else:
  3251. * try: # <<<<<<<<<<<<<<
  3252. * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host)))
  3253. * except:
  3254. */
  3255. /*else*/ {
  3256. {
  3257. __Pyx_PyThreadState_declare
  3258. __Pyx_PyThreadState_assign
  3259. __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
  3260. __Pyx_XGOTREF(__pyx_t_14);
  3261. __Pyx_XGOTREF(__pyx_t_15);
  3262. __Pyx_XGOTREF(__pyx_t_16);
  3263. /*try:*/ {
  3264. /* "gevent/ares.pyx":212
  3265. * else:
  3266. * try:
  3267. * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host))) # <<<<<<<<<<<<<<
  3268. * except:
  3269. * callback(result(None, sys.exc_info()[1]))
  3270. */
  3271. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ares_host_result); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L14_error)
  3272. __Pyx_GOTREF(__pyx_t_2);
  3273. __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_host->h_addrtype); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 212, __pyx_L14_error)
  3274. __Pyx_GOTREF(__pyx_t_11);
  3275. __pyx_t_3 = parse_h_name(__pyx_v_host); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 212, __pyx_L14_error)
  3276. __Pyx_GOTREF(__pyx_t_3);
  3277. __pyx_t_13 = parse_h_aliases(__pyx_v_host); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 212, __pyx_L14_error)
  3278. __Pyx_GOTREF(__pyx_t_13);
  3279. __pyx_t_9 = parse_h_addr_list(__pyx_v_host); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 212, __pyx_L14_error)
  3280. __Pyx_GOTREF(__pyx_t_9);
  3281. __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 212, __pyx_L14_error)
  3282. __Pyx_GOTREF(__pyx_t_10);
  3283. __Pyx_GIVEREF(__pyx_t_3);
  3284. PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3);
  3285. __Pyx_GIVEREF(__pyx_t_13);
  3286. PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_13);
  3287. __Pyx_GIVEREF(__pyx_t_9);
  3288. PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_9);
  3289. __pyx_t_3 = 0;
  3290. __pyx_t_13 = 0;
  3291. __pyx_t_9 = 0;
  3292. __pyx_t_9 = NULL;
  3293. __pyx_t_12 = 0;
  3294. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  3295. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
  3296. if (likely(__pyx_t_9)) {
  3297. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  3298. __Pyx_INCREF(__pyx_t_9);
  3299. __Pyx_INCREF(function);
  3300. __Pyx_DECREF_SET(__pyx_t_2, function);
  3301. __pyx_t_12 = 1;
  3302. }
  3303. }
  3304. #if CYTHON_FAST_PYCALL
  3305. if (PyFunction_Check(__pyx_t_2)) {
  3306. PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_11, __pyx_t_10};
  3307. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L14_error)
  3308. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  3309. __Pyx_GOTREF(__pyx_t_1);
  3310. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  3311. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3312. } else
  3313. #endif
  3314. #if CYTHON_FAST_PYCCALL
  3315. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  3316. PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_11, __pyx_t_10};
  3317. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L14_error)
  3318. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  3319. __Pyx_GOTREF(__pyx_t_1);
  3320. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  3321. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3322. } else
  3323. #endif
  3324. {
  3325. __pyx_t_13 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 212, __pyx_L14_error)
  3326. __Pyx_GOTREF(__pyx_t_13);
  3327. if (__pyx_t_9) {
  3328. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_9); __pyx_t_9 = NULL;
  3329. }
  3330. __Pyx_GIVEREF(__pyx_t_11);
  3331. PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_12, __pyx_t_11);
  3332. __Pyx_GIVEREF(__pyx_t_10);
  3333. PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_12, __pyx_t_10);
  3334. __pyx_t_11 = 0;
  3335. __pyx_t_10 = 0;
  3336. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L14_error)
  3337. __Pyx_GOTREF(__pyx_t_1);
  3338. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  3339. }
  3340. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3341. __pyx_v_host_result = __pyx_t_1;
  3342. __pyx_t_1 = 0;
  3343. /* "gevent/ares.pyx":211
  3344. * callback(result(None, gaierror(status, strerror(status))))
  3345. * else:
  3346. * try: # <<<<<<<<<<<<<<
  3347. * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host)))
  3348. * except:
  3349. */
  3350. }
  3351. /* "gevent/ares.pyx":216
  3352. * callback(result(None, sys.exc_info()[1]))
  3353. * else:
  3354. * callback(result(host_result)) # <<<<<<<<<<<<<<
  3355. * except:
  3356. * channel.loop.handle_error(callback, *sys.exc_info())
  3357. */
  3358. /*else:*/ {
  3359. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L16_except_error)
  3360. __Pyx_GOTREF(__pyx_t_2);
  3361. __Pyx_INCREF(__pyx_v_host_result);
  3362. __Pyx_GIVEREF(__pyx_v_host_result);
  3363. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_host_result);
  3364. __pyx_t_13 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_2, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 216, __pyx_L16_except_error)
  3365. __Pyx_GOTREF(__pyx_t_13);
  3366. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3367. __Pyx_INCREF(__pyx_v_callback);
  3368. __pyx_t_2 = __pyx_v_callback; __pyx_t_10 = NULL;
  3369. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  3370. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
  3371. if (likely(__pyx_t_10)) {
  3372. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  3373. __Pyx_INCREF(__pyx_t_10);
  3374. __Pyx_INCREF(function);
  3375. __Pyx_DECREF_SET(__pyx_t_2, function);
  3376. }
  3377. }
  3378. if (!__pyx_t_10) {
  3379. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L16_except_error)
  3380. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  3381. __Pyx_GOTREF(__pyx_t_1);
  3382. } else {
  3383. #if CYTHON_FAST_PYCALL
  3384. if (PyFunction_Check(__pyx_t_2)) {
  3385. PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_13};
  3386. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L16_except_error)
  3387. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  3388. __Pyx_GOTREF(__pyx_t_1);
  3389. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  3390. } else
  3391. #endif
  3392. #if CYTHON_FAST_PYCCALL
  3393. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  3394. PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_13};
  3395. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L16_except_error)
  3396. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  3397. __Pyx_GOTREF(__pyx_t_1);
  3398. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  3399. } else
  3400. #endif
  3401. {
  3402. __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 216, __pyx_L16_except_error)
  3403. __Pyx_GOTREF(__pyx_t_11);
  3404. __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
  3405. __Pyx_GIVEREF(__pyx_t_13);
  3406. PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_13);
  3407. __pyx_t_13 = 0;
  3408. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L16_except_error)
  3409. __Pyx_GOTREF(__pyx_t_1);
  3410. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  3411. }
  3412. }
  3413. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3414. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3415. }
  3416. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  3417. __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
  3418. __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
  3419. goto __pyx_L21_try_end;
  3420. __pyx_L14_error:;
  3421. __Pyx_PyThreadState_assign
  3422. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3423. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  3424. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  3425. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  3426. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  3427. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  3428. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3429. /* "gevent/ares.pyx":213
  3430. * try:
  3431. * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host)))
  3432. * except: # <<<<<<<<<<<<<<
  3433. * callback(result(None, sys.exc_info()[1]))
  3434. * else:
  3435. */
  3436. /*except:*/ {
  3437. __Pyx_AddTraceback("gevent.ares.gevent_ares_host_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3438. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_11) < 0) __PYX_ERR(0, 213, __pyx_L16_except_error)
  3439. __Pyx_GOTREF(__pyx_t_1);
  3440. __Pyx_GOTREF(__pyx_t_2);
  3441. __Pyx_GOTREF(__pyx_t_11);
  3442. /* "gevent/ares.pyx":214
  3443. * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host)))
  3444. * except:
  3445. * callback(result(None, sys.exc_info()[1])) # <<<<<<<<<<<<<<
  3446. * else:
  3447. * callback(result(host_result))
  3448. */
  3449. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 214, __pyx_L16_except_error)
  3450. __Pyx_GOTREF(__pyx_t_9);
  3451. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L16_except_error)
  3452. __Pyx_GOTREF(__pyx_t_3);
  3453. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  3454. __pyx_t_9 = NULL;
  3455. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  3456. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
  3457. if (likely(__pyx_t_9)) {
  3458. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  3459. __Pyx_INCREF(__pyx_t_9);
  3460. __Pyx_INCREF(function);
  3461. __Pyx_DECREF_SET(__pyx_t_3, function);
  3462. }
  3463. }
  3464. if (__pyx_t_9) {
  3465. __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 214, __pyx_L16_except_error)
  3466. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  3467. } else {
  3468. __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 214, __pyx_L16_except_error)
  3469. }
  3470. __Pyx_GOTREF(__pyx_t_10);
  3471. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3472. __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_10, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L16_except_error)
  3473. __Pyx_GOTREF(__pyx_t_3);
  3474. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3475. __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 214, __pyx_L16_except_error)
  3476. __Pyx_GOTREF(__pyx_t_10);
  3477. __Pyx_INCREF(Py_None);
  3478. __Pyx_GIVEREF(Py_None);
  3479. PyTuple_SET_ITEM(__pyx_t_10, 0, Py_None);
  3480. __Pyx_GIVEREF(__pyx_t_3);
  3481. PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3);
  3482. __pyx_t_3 = 0;
  3483. __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L16_except_error)
  3484. __Pyx_GOTREF(__pyx_t_3);
  3485. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3486. __Pyx_INCREF(__pyx_v_callback);
  3487. __pyx_t_10 = __pyx_v_callback; __pyx_t_9 = NULL;
  3488. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
  3489. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
  3490. if (likely(__pyx_t_9)) {
  3491. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  3492. __Pyx_INCREF(__pyx_t_9);
  3493. __Pyx_INCREF(function);
  3494. __Pyx_DECREF_SET(__pyx_t_10, function);
  3495. }
  3496. }
  3497. if (!__pyx_t_9) {
  3498. __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 214, __pyx_L16_except_error)
  3499. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3500. __Pyx_GOTREF(__pyx_t_13);
  3501. } else {
  3502. #if CYTHON_FAST_PYCALL
  3503. if (PyFunction_Check(__pyx_t_10)) {
  3504. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_3};
  3505. __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 214, __pyx_L16_except_error)
  3506. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  3507. __Pyx_GOTREF(__pyx_t_13);
  3508. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3509. } else
  3510. #endif
  3511. #if CYTHON_FAST_PYCCALL
  3512. if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
  3513. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_3};
  3514. __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 214, __pyx_L16_except_error)
  3515. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  3516. __Pyx_GOTREF(__pyx_t_13);
  3517. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3518. } else
  3519. #endif
  3520. {
  3521. __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 214, __pyx_L16_except_error)
  3522. __Pyx_GOTREF(__pyx_t_17);
  3523. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_9); __pyx_t_9 = NULL;
  3524. __Pyx_GIVEREF(__pyx_t_3);
  3525. PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_3);
  3526. __pyx_t_3 = 0;
  3527. __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_17, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 214, __pyx_L16_except_error)
  3528. __Pyx_GOTREF(__pyx_t_13);
  3529. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  3530. }
  3531. }
  3532. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3533. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  3534. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3535. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3536. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  3537. goto __pyx_L15_exception_handled;
  3538. }
  3539. __pyx_L16_except_error:;
  3540. /* "gevent/ares.pyx":211
  3541. * callback(result(None, gaierror(status, strerror(status))))
  3542. * else:
  3543. * try: # <<<<<<<<<<<<<<
  3544. * host_result = ares_host_result(host.h_addrtype, (parse_h_name(host), parse_h_aliases(host), parse_h_addr_list(host)))
  3545. * except:
  3546. */
  3547. __Pyx_PyThreadState_assign
  3548. __Pyx_XGIVEREF(__pyx_t_14);
  3549. __Pyx_XGIVEREF(__pyx_t_15);
  3550. __Pyx_XGIVEREF(__pyx_t_16);
  3551. __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
  3552. goto __pyx_L3_error;
  3553. __pyx_L15_exception_handled:;
  3554. __Pyx_PyThreadState_assign
  3555. __Pyx_XGIVEREF(__pyx_t_14);
  3556. __Pyx_XGIVEREF(__pyx_t_15);
  3557. __Pyx_XGIVEREF(__pyx_t_16);
  3558. __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
  3559. __pyx_L21_try_end:;
  3560. }
  3561. }
  3562. __pyx_L11:;
  3563. /* "gevent/ares.pyx":207
  3564. * Py_DECREF(<PyObjectPtr>arg)
  3565. * cdef object host_result
  3566. * try: # <<<<<<<<<<<<<<
  3567. * if status or not host:
  3568. * callback(result(None, gaierror(status, strerror(status))))
  3569. */
  3570. }
  3571. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  3572. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  3573. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  3574. goto __pyx_L10_try_end;
  3575. __pyx_L3_error:;
  3576. __Pyx_PyThreadState_assign
  3577. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  3578. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3579. __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
  3580. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  3581. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  3582. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  3583. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  3584. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  3585. /* "gevent/ares.pyx":217
  3586. * else:
  3587. * callback(result(host_result))
  3588. * except: # <<<<<<<<<<<<<<
  3589. * channel.loop.handle_error(callback, *sys.exc_info())
  3590. *
  3591. */
  3592. /*except:*/ {
  3593. __Pyx_AddTraceback("gevent.ares.gevent_ares_host_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3594. if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 217, __pyx_L5_except_error)
  3595. __Pyx_GOTREF(__pyx_t_11);
  3596. __Pyx_GOTREF(__pyx_t_2);
  3597. __Pyx_GOTREF(__pyx_t_1);
  3598. /* "gevent/ares.pyx":218
  3599. * callback(result(host_result))
  3600. * except:
  3601. * channel.loop.handle_error(callback, *sys.exc_info()) # <<<<<<<<<<<<<<
  3602. *
  3603. *
  3604. */
  3605. __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_channel->loop, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 218, __pyx_L5_except_error)
  3606. __Pyx_GOTREF(__pyx_t_13);
  3607. __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 218, __pyx_L5_except_error)
  3608. __Pyx_GOTREF(__pyx_t_10);
  3609. __Pyx_INCREF(__pyx_v_callback);
  3610. __Pyx_GIVEREF(__pyx_v_callback);
  3611. PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_callback);
  3612. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L5_except_error)
  3613. __Pyx_GOTREF(__pyx_t_3);
  3614. __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 218, __pyx_L5_except_error)
  3615. __Pyx_GOTREF(__pyx_t_9);
  3616. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3617. __pyx_t_3 = NULL;
  3618. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
  3619. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
  3620. if (likely(__pyx_t_3)) {
  3621. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
  3622. __Pyx_INCREF(__pyx_t_3);
  3623. __Pyx_INCREF(function);
  3624. __Pyx_DECREF_SET(__pyx_t_9, function);
  3625. }
  3626. }
  3627. if (__pyx_t_3) {
  3628. __pyx_t_17 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 218, __pyx_L5_except_error)
  3629. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3630. } else {
  3631. __pyx_t_17 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 218, __pyx_L5_except_error)
  3632. }
  3633. __Pyx_GOTREF(__pyx_t_17);
  3634. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  3635. __pyx_t_9 = PySequence_Tuple(__pyx_t_17); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 218, __pyx_L5_except_error)
  3636. __Pyx_GOTREF(__pyx_t_9);
  3637. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  3638. __pyx_t_17 = PyNumber_Add(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 218, __pyx_L5_except_error)
  3639. __Pyx_GOTREF(__pyx_t_17);
  3640. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3641. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  3642. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_17, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 218, __pyx_L5_except_error)
  3643. __Pyx_GOTREF(__pyx_t_9);
  3644. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  3645. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  3646. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  3647. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  3648. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3649. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3650. goto __pyx_L4_exception_handled;
  3651. }
  3652. __pyx_L5_except_error:;
  3653. /* "gevent/ares.pyx":207
  3654. * Py_DECREF(<PyObjectPtr>arg)
  3655. * cdef object host_result
  3656. * try: # <<<<<<<<<<<<<<
  3657. * if status or not host:
  3658. * callback(result(None, gaierror(status, strerror(status))))
  3659. */
  3660. __Pyx_PyThreadState_assign
  3661. __Pyx_XGIVEREF(__pyx_t_4);
  3662. __Pyx_XGIVEREF(__pyx_t_5);
  3663. __Pyx_XGIVEREF(__pyx_t_6);
  3664. __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
  3665. goto __pyx_L1_error;
  3666. __pyx_L4_exception_handled:;
  3667. __Pyx_PyThreadState_assign
  3668. __Pyx_XGIVEREF(__pyx_t_4);
  3669. __Pyx_XGIVEREF(__pyx_t_5);
  3670. __Pyx_XGIVEREF(__pyx_t_6);
  3671. __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
  3672. __pyx_L10_try_end:;
  3673. }
  3674. /* "gevent/ares.pyx":201
  3675. *
  3676. *
  3677. * cdef void gevent_ares_host_callback(void *arg, int status, int timeouts, hostent* host): # <<<<<<<<<<<<<<
  3678. * cdef channel channel
  3679. * cdef object callback
  3680. */
  3681. /* function exit code */
  3682. goto __pyx_L0;
  3683. __pyx_L1_error:;
  3684. __Pyx_XDECREF(__pyx_t_1);
  3685. __Pyx_XDECREF(__pyx_t_2);
  3686. __Pyx_XDECREF(__pyx_t_3);
  3687. __Pyx_XDECREF(__pyx_t_9);
  3688. __Pyx_XDECREF(__pyx_t_10);
  3689. __Pyx_XDECREF(__pyx_t_11);
  3690. __Pyx_XDECREF(__pyx_t_13);
  3691. __Pyx_XDECREF(__pyx_t_17);
  3692. __Pyx_WriteUnraisable("gevent.ares.gevent_ares_host_callback", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  3693. __pyx_L0:;
  3694. __Pyx_XDECREF((PyObject *)__pyx_v_channel);
  3695. __Pyx_XDECREF(__pyx_v_callback);
  3696. __Pyx_XDECREF(__pyx_v_host_result);
  3697. __Pyx_RefNannyFinishContext();
  3698. }
  3699. /* "gevent/ares.pyx":221
  3700. *
  3701. *
  3702. * cdef void gevent_ares_nameinfo_callback(void *arg, int status, int timeouts, char *c_node, char *c_service): # <<<<<<<<<<<<<<
  3703. * cdef channel channel
  3704. * cdef object callback
  3705. */
  3706. static void __pyx_f_6gevent_4ares_gevent_ares_nameinfo_callback(void *__pyx_v_arg, int __pyx_v_status, CYTHON_UNUSED int __pyx_v_timeouts, char *__pyx_v_c_node, char *__pyx_v_c_service) {
  3707. struct PyGeventAresChannelObject *__pyx_v_channel = 0;
  3708. PyObject *__pyx_v_callback = 0;
  3709. PyObject *__pyx_v_node = 0;
  3710. PyObject *__pyx_v_service = 0;
  3711. __Pyx_RefNannyDeclarations
  3712. PyObject *__pyx_t_1 = NULL;
  3713. PyObject *__pyx_t_2 = NULL;
  3714. PyObject *__pyx_t_3 = NULL;
  3715. PyObject *__pyx_t_4 = NULL;
  3716. PyObject *__pyx_t_5 = NULL;
  3717. PyObject *__pyx_t_6 = NULL;
  3718. int __pyx_t_7;
  3719. PyObject *__pyx_t_8 = NULL;
  3720. PyObject *__pyx_t_9 = NULL;
  3721. PyObject *__pyx_t_10 = NULL;
  3722. int __pyx_t_11;
  3723. PyObject *__pyx_t_12 = NULL;
  3724. PyObject *__pyx_t_13 = NULL;
  3725. __Pyx_RefNannySetupContext("gevent_ares_nameinfo_callback", 0);
  3726. /* "gevent/ares.pyx":224
  3727. * cdef channel channel
  3728. * cdef object callback
  3729. * channel, callback = <tuple>arg # <<<<<<<<<<<<<<
  3730. * Py_DECREF(<PyObjectPtr>arg)
  3731. * cdef object node
  3732. */
  3733. __pyx_t_1 = ((PyObject *)__pyx_v_arg);
  3734. __Pyx_INCREF(__pyx_t_1);
  3735. if (likely(__pyx_t_1 != Py_None)) {
  3736. PyObject* sequence = __pyx_t_1;
  3737. #if !CYTHON_COMPILING_IN_PYPY
  3738. Py_ssize_t size = Py_SIZE(sequence);
  3739. #else
  3740. Py_ssize_t size = PySequence_Size(sequence);
  3741. #endif
  3742. if (unlikely(size != 2)) {
  3743. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  3744. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  3745. __PYX_ERR(0, 224, __pyx_L1_error)
  3746. }
  3747. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  3748. __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
  3749. __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
  3750. __Pyx_INCREF(__pyx_t_2);
  3751. __Pyx_INCREF(__pyx_t_3);
  3752. #else
  3753. __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error)
  3754. __Pyx_GOTREF(__pyx_t_2);
  3755. __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 224, __pyx_L1_error)
  3756. __Pyx_GOTREF(__pyx_t_3);
  3757. #endif
  3758. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3759. } else {
  3760. __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 224, __pyx_L1_error)
  3761. }
  3762. if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_6gevent_4ares_channel))))) __PYX_ERR(0, 224, __pyx_L1_error)
  3763. __pyx_v_channel = ((struct PyGeventAresChannelObject *)__pyx_t_2);
  3764. __pyx_t_2 = 0;
  3765. __pyx_v_callback = __pyx_t_3;
  3766. __pyx_t_3 = 0;
  3767. /* "gevent/ares.pyx":225
  3768. * cdef object callback
  3769. * channel, callback = <tuple>arg
  3770. * Py_DECREF(<PyObjectPtr>arg) # <<<<<<<<<<<<<<
  3771. * cdef object node
  3772. * cdef object service
  3773. */
  3774. Py_DECREF(((PyObject*)__pyx_v_arg));
  3775. /* "gevent/ares.pyx":228
  3776. * cdef object node
  3777. * cdef object service
  3778. * try: # <<<<<<<<<<<<<<
  3779. * if status:
  3780. * callback(result(None, gaierror(status, strerror(status))))
  3781. */
  3782. {
  3783. __Pyx_PyThreadState_declare
  3784. __Pyx_PyThreadState_assign
  3785. __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
  3786. __Pyx_XGOTREF(__pyx_t_4);
  3787. __Pyx_XGOTREF(__pyx_t_5);
  3788. __Pyx_XGOTREF(__pyx_t_6);
  3789. /*try:*/ {
  3790. /* "gevent/ares.pyx":229
  3791. * cdef object service
  3792. * try:
  3793. * if status: # <<<<<<<<<<<<<<
  3794. * callback(result(None, gaierror(status, strerror(status))))
  3795. * else:
  3796. */
  3797. __pyx_t_7 = (__pyx_v_status != 0);
  3798. if (__pyx_t_7) {
  3799. /* "gevent/ares.pyx":230
  3800. * try:
  3801. * if status:
  3802. * callback(result(None, gaierror(status, strerror(status)))) # <<<<<<<<<<<<<<
  3803. * else:
  3804. * if c_node:
  3805. */
  3806. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 230, __pyx_L3_error)
  3807. __Pyx_GOTREF(__pyx_t_2);
  3808. __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 230, __pyx_L3_error)
  3809. __Pyx_GOTREF(__pyx_t_8);
  3810. __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_status); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 230, __pyx_L3_error)
  3811. __Pyx_GOTREF(__pyx_t_9);
  3812. __pyx_t_10 = __pyx_f_6gevent_4ares_strerror(__pyx_t_9, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 230, __pyx_L3_error)
  3813. __Pyx_GOTREF(__pyx_t_10);
  3814. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  3815. __pyx_t_9 = NULL;
  3816. __pyx_t_11 = 0;
  3817. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  3818. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
  3819. if (likely(__pyx_t_9)) {
  3820. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  3821. __Pyx_INCREF(__pyx_t_9);
  3822. __Pyx_INCREF(function);
  3823. __Pyx_DECREF_SET(__pyx_t_2, function);
  3824. __pyx_t_11 = 1;
  3825. }
  3826. }
  3827. #if CYTHON_FAST_PYCALL
  3828. if (PyFunction_Check(__pyx_t_2)) {
  3829. PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10};
  3830. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L3_error)
  3831. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  3832. __Pyx_GOTREF(__pyx_t_3);
  3833. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3834. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3835. } else
  3836. #endif
  3837. #if CYTHON_FAST_PYCCALL
  3838. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  3839. PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10};
  3840. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L3_error)
  3841. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  3842. __Pyx_GOTREF(__pyx_t_3);
  3843. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3844. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3845. } else
  3846. #endif
  3847. {
  3848. __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 230, __pyx_L3_error)
  3849. __Pyx_GOTREF(__pyx_t_12);
  3850. if (__pyx_t_9) {
  3851. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9); __pyx_t_9 = NULL;
  3852. }
  3853. __Pyx_GIVEREF(__pyx_t_8);
  3854. PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_8);
  3855. __Pyx_GIVEREF(__pyx_t_10);
  3856. PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_10);
  3857. __pyx_t_8 = 0;
  3858. __pyx_t_10 = 0;
  3859. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L3_error)
  3860. __Pyx_GOTREF(__pyx_t_3);
  3861. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  3862. }
  3863. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3864. __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 230, __pyx_L3_error)
  3865. __Pyx_GOTREF(__pyx_t_2);
  3866. __Pyx_INCREF(Py_None);
  3867. __Pyx_GIVEREF(Py_None);
  3868. PyTuple_SET_ITEM(__pyx_t_2, 0, Py_None);
  3869. __Pyx_GIVEREF(__pyx_t_3);
  3870. PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
  3871. __pyx_t_3 = 0;
  3872. __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L3_error)
  3873. __Pyx_GOTREF(__pyx_t_3);
  3874. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3875. __Pyx_INCREF(__pyx_v_callback);
  3876. __pyx_t_2 = __pyx_v_callback; __pyx_t_12 = NULL;
  3877. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  3878. __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2);
  3879. if (likely(__pyx_t_12)) {
  3880. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  3881. __Pyx_INCREF(__pyx_t_12);
  3882. __Pyx_INCREF(function);
  3883. __Pyx_DECREF_SET(__pyx_t_2, function);
  3884. }
  3885. }
  3886. if (!__pyx_t_12) {
  3887. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L3_error)
  3888. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3889. __Pyx_GOTREF(__pyx_t_1);
  3890. } else {
  3891. #if CYTHON_FAST_PYCALL
  3892. if (PyFunction_Check(__pyx_t_2)) {
  3893. PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_3};
  3894. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L3_error)
  3895. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  3896. __Pyx_GOTREF(__pyx_t_1);
  3897. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3898. } else
  3899. #endif
  3900. #if CYTHON_FAST_PYCCALL
  3901. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  3902. PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_3};
  3903. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L3_error)
  3904. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  3905. __Pyx_GOTREF(__pyx_t_1);
  3906. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3907. } else
  3908. #endif
  3909. {
  3910. __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 230, __pyx_L3_error)
  3911. __Pyx_GOTREF(__pyx_t_10);
  3912. __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12); __pyx_t_12 = NULL;
  3913. __Pyx_GIVEREF(__pyx_t_3);
  3914. PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_3);
  3915. __pyx_t_3 = 0;
  3916. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L3_error)
  3917. __Pyx_GOTREF(__pyx_t_1);
  3918. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3919. }
  3920. }
  3921. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3922. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3923. /* "gevent/ares.pyx":229
  3924. * cdef object service
  3925. * try:
  3926. * if status: # <<<<<<<<<<<<<<
  3927. * callback(result(None, gaierror(status, strerror(status))))
  3928. * else:
  3929. */
  3930. goto __pyx_L11;
  3931. }
  3932. /* "gevent/ares.pyx":232
  3933. * callback(result(None, gaierror(status, strerror(status))))
  3934. * else:
  3935. * if c_node: # <<<<<<<<<<<<<<
  3936. * node = PyUnicode_FromString(c_node)
  3937. * else:
  3938. */
  3939. /*else*/ {
  3940. __pyx_t_7 = (__pyx_v_c_node != 0);
  3941. if (__pyx_t_7) {
  3942. /* "gevent/ares.pyx":233
  3943. * else:
  3944. * if c_node:
  3945. * node = PyUnicode_FromString(c_node) # <<<<<<<<<<<<<<
  3946. * else:
  3947. * node = None
  3948. */
  3949. __pyx_t_1 = PyUnicode_FromString(__pyx_v_c_node); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L3_error)
  3950. __Pyx_GOTREF(__pyx_t_1);
  3951. __pyx_v_node = __pyx_t_1;
  3952. __pyx_t_1 = 0;
  3953. /* "gevent/ares.pyx":232
  3954. * callback(result(None, gaierror(status, strerror(status))))
  3955. * else:
  3956. * if c_node: # <<<<<<<<<<<<<<
  3957. * node = PyUnicode_FromString(c_node)
  3958. * else:
  3959. */
  3960. goto __pyx_L12;
  3961. }
  3962. /* "gevent/ares.pyx":235
  3963. * node = PyUnicode_FromString(c_node)
  3964. * else:
  3965. * node = None # <<<<<<<<<<<<<<
  3966. * if c_service:
  3967. * service = PyUnicode_FromString(c_service)
  3968. */
  3969. /*else*/ {
  3970. __Pyx_INCREF(Py_None);
  3971. __pyx_v_node = Py_None;
  3972. }
  3973. __pyx_L12:;
  3974. /* "gevent/ares.pyx":236
  3975. * else:
  3976. * node = None
  3977. * if c_service: # <<<<<<<<<<<<<<
  3978. * service = PyUnicode_FromString(c_service)
  3979. * else:
  3980. */
  3981. __pyx_t_7 = (__pyx_v_c_service != 0);
  3982. if (__pyx_t_7) {
  3983. /* "gevent/ares.pyx":237
  3984. * node = None
  3985. * if c_service:
  3986. * service = PyUnicode_FromString(c_service) # <<<<<<<<<<<<<<
  3987. * else:
  3988. * service = None
  3989. */
  3990. __pyx_t_1 = PyUnicode_FromString(__pyx_v_c_service); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L3_error)
  3991. __Pyx_GOTREF(__pyx_t_1);
  3992. __pyx_v_service = __pyx_t_1;
  3993. __pyx_t_1 = 0;
  3994. /* "gevent/ares.pyx":236
  3995. * else:
  3996. * node = None
  3997. * if c_service: # <<<<<<<<<<<<<<
  3998. * service = PyUnicode_FromString(c_service)
  3999. * else:
  4000. */
  4001. goto __pyx_L13;
  4002. }
  4003. /* "gevent/ares.pyx":239
  4004. * service = PyUnicode_FromString(c_service)
  4005. * else:
  4006. * service = None # <<<<<<<<<<<<<<
  4007. * callback(result((node, service)))
  4008. * except:
  4009. */
  4010. /*else*/ {
  4011. __Pyx_INCREF(Py_None);
  4012. __pyx_v_service = Py_None;
  4013. }
  4014. __pyx_L13:;
  4015. /* "gevent/ares.pyx":240
  4016. * else:
  4017. * service = None
  4018. * callback(result((node, service))) # <<<<<<<<<<<<<<
  4019. * except:
  4020. * channel.loop.handle_error(callback, *sys.exc_info())
  4021. */
  4022. __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __pyx_L3_error)
  4023. __Pyx_GOTREF(__pyx_t_2);
  4024. __Pyx_INCREF(__pyx_v_node);
  4025. __Pyx_GIVEREF(__pyx_v_node);
  4026. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_node);
  4027. __Pyx_INCREF(__pyx_v_service);
  4028. __Pyx_GIVEREF(__pyx_v_service);
  4029. PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_service);
  4030. __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 240, __pyx_L3_error)
  4031. __Pyx_GOTREF(__pyx_t_10);
  4032. __Pyx_GIVEREF(__pyx_t_2);
  4033. PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
  4034. __pyx_t_2 = 0;
  4035. __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_6gevent_4ares_result), __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __pyx_L3_error)
  4036. __Pyx_GOTREF(__pyx_t_2);
  4037. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  4038. __Pyx_INCREF(__pyx_v_callback);
  4039. __pyx_t_10 = __pyx_v_callback; __pyx_t_3 = NULL;
  4040. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
  4041. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
  4042. if (likely(__pyx_t_3)) {
  4043. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
  4044. __Pyx_INCREF(__pyx_t_3);
  4045. __Pyx_INCREF(function);
  4046. __Pyx_DECREF_SET(__pyx_t_10, function);
  4047. }
  4048. }
  4049. if (!__pyx_t_3) {
  4050. __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L3_error)
  4051. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4052. __Pyx_GOTREF(__pyx_t_1);
  4053. } else {
  4054. #if CYTHON_FAST_PYCALL
  4055. if (PyFunction_Check(__pyx_t_10)) {
  4056. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  4057. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L3_error)
  4058. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  4059. __Pyx_GOTREF(__pyx_t_1);
  4060. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4061. } else
  4062. #endif
  4063. #if CYTHON_FAST_PYCCALL
  4064. if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
  4065. PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_2};
  4066. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L3_error)
  4067. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  4068. __Pyx_GOTREF(__pyx_t_1);
  4069. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4070. } else
  4071. #endif
  4072. {
  4073. __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 240, __pyx_L3_error)
  4074. __Pyx_GOTREF(__pyx_t_12);
  4075. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); __pyx_t_3 = NULL;
  4076. __Pyx_GIVEREF(__pyx_t_2);
  4077. PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_2);
  4078. __pyx_t_2 = 0;
  4079. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L3_error)
  4080. __Pyx_GOTREF(__pyx_t_1);
  4081. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4082. }
  4083. }
  4084. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  4085. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4086. }
  4087. __pyx_L11:;
  4088. /* "gevent/ares.pyx":228
  4089. * cdef object node
  4090. * cdef object service
  4091. * try: # <<<<<<<<<<<<<<
  4092. * if status:
  4093. * callback(result(None, gaierror(status, strerror(status))))
  4094. */
  4095. }
  4096. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  4097. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4098. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  4099. goto __pyx_L10_try_end;
  4100. __pyx_L3_error:;
  4101. __Pyx_PyThreadState_assign
  4102. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  4103. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  4104. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  4105. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  4106. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  4107. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  4108. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4109. /* "gevent/ares.pyx":241
  4110. * service = None
  4111. * callback(result((node, service)))
  4112. * except: # <<<<<<<<<<<<<<
  4113. * channel.loop.handle_error(callback, *sys.exc_info())
  4114. *
  4115. */
  4116. /*except:*/ {
  4117. __Pyx_AddTraceback("gevent.ares.gevent_ares_nameinfo_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4118. if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_10, &__pyx_t_12) < 0) __PYX_ERR(0, 241, __pyx_L5_except_error)
  4119. __Pyx_GOTREF(__pyx_t_1);
  4120. __Pyx_GOTREF(__pyx_t_10);
  4121. __Pyx_GOTREF(__pyx_t_12);
  4122. /* "gevent/ares.pyx":242
  4123. * callback(result((node, service)))
  4124. * except:
  4125. * channel.loop.handle_error(callback, *sys.exc_info()) # <<<<<<<<<<<<<<
  4126. *
  4127. *
  4128. */
  4129. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_channel->loop, __pyx_n_s_handle_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L5_except_error)
  4130. __Pyx_GOTREF(__pyx_t_2);
  4131. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 242, __pyx_L5_except_error)
  4132. __Pyx_GOTREF(__pyx_t_3);
  4133. __Pyx_INCREF(__pyx_v_callback);
  4134. __Pyx_GIVEREF(__pyx_v_callback);
  4135. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_callback);
  4136. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 242, __pyx_L5_except_error)
  4137. __Pyx_GOTREF(__pyx_t_9);
  4138. __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_exc_info); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 242, __pyx_L5_except_error)
  4139. __Pyx_GOTREF(__pyx_t_13);
  4140. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4141. __pyx_t_9 = NULL;
  4142. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
  4143. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_13);
  4144. if (likely(__pyx_t_9)) {
  4145. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
  4146. __Pyx_INCREF(__pyx_t_9);
  4147. __Pyx_INCREF(function);
  4148. __Pyx_DECREF_SET(__pyx_t_13, function);
  4149. }
  4150. }
  4151. if (__pyx_t_9) {
  4152. __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 242, __pyx_L5_except_error)
  4153. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4154. } else {
  4155. __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 242, __pyx_L5_except_error)
  4156. }
  4157. __Pyx_GOTREF(__pyx_t_8);
  4158. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4159. __pyx_t_13 = PySequence_Tuple(__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 242, __pyx_L5_except_error)
  4160. __Pyx_GOTREF(__pyx_t_13);
  4161. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4162. __pyx_t_8 = PyNumber_Add(__pyx_t_3, __pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 242, __pyx_L5_except_error)
  4163. __Pyx_GOTREF(__pyx_t_8);
  4164. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4165. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4166. __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 242, __pyx_L5_except_error)
  4167. __Pyx_GOTREF(__pyx_t_13);
  4168. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4169. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4170. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  4171. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4172. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  4173. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4174. goto __pyx_L4_exception_handled;
  4175. }
  4176. __pyx_L5_except_error:;
  4177. /* "gevent/ares.pyx":228
  4178. * cdef object node
  4179. * cdef object service
  4180. * try: # <<<<<<<<<<<<<<
  4181. * if status:
  4182. * callback(result(None, gaierror(status, strerror(status))))
  4183. */
  4184. __Pyx_PyThreadState_assign
  4185. __Pyx_XGIVEREF(__pyx_t_4);
  4186. __Pyx_XGIVEREF(__pyx_t_5);
  4187. __Pyx_XGIVEREF(__pyx_t_6);
  4188. __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
  4189. goto __pyx_L1_error;
  4190. __pyx_L4_exception_handled:;
  4191. __Pyx_PyThreadState_assign
  4192. __Pyx_XGIVEREF(__pyx_t_4);
  4193. __Pyx_XGIVEREF(__pyx_t_5);
  4194. __Pyx_XGIVEREF(__pyx_t_6);
  4195. __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
  4196. __pyx_L10_try_end:;
  4197. }
  4198. /* "gevent/ares.pyx":221
  4199. *
  4200. *
  4201. * cdef void gevent_ares_nameinfo_callback(void *arg, int status, int timeouts, char *c_node, char *c_service): # <<<<<<<<<<<<<<
  4202. * cdef channel channel
  4203. * cdef object callback
  4204. */
  4205. /* function exit code */
  4206. goto __pyx_L0;
  4207. __pyx_L1_error:;
  4208. __Pyx_XDECREF(__pyx_t_1);
  4209. __Pyx_XDECREF(__pyx_t_2);
  4210. __Pyx_XDECREF(__pyx_t_3);
  4211. __Pyx_XDECREF(__pyx_t_8);
  4212. __Pyx_XDECREF(__pyx_t_9);
  4213. __Pyx_XDECREF(__pyx_t_10);
  4214. __Pyx_XDECREF(__pyx_t_12);
  4215. __Pyx_XDECREF(__pyx_t_13);
  4216. __Pyx_WriteUnraisable("gevent.ares.gevent_ares_nameinfo_callback", __pyx_clineno, __pyx_lineno, __pyx_filename, 0, 0);
  4217. __pyx_L0:;
  4218. __Pyx_XDECREF((PyObject *)__pyx_v_channel);
  4219. __Pyx_XDECREF(__pyx_v_callback);
  4220. __Pyx_XDECREF(__pyx_v_node);
  4221. __Pyx_XDECREF(__pyx_v_service);
  4222. __Pyx_RefNannyFinishContext();
  4223. }
  4224. /* "gevent/ares.pyx":252
  4225. * cdef public object _timer
  4226. *
  4227. * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, # <<<<<<<<<<<<<<
  4228. * udp_port=None, tcp_port=None, servers=None):
  4229. * cdef ares_channeldata* channel = NULL
  4230. */
  4231. /* Python wrapper */
  4232. static int __pyx_pw_6gevent_4ares_7channel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  4233. static int __pyx_pw_6gevent_4ares_7channel_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  4234. PyObject *__pyx_v_loop = 0;
  4235. PyObject *__pyx_v_flags = 0;
  4236. PyObject *__pyx_v_timeout = 0;
  4237. PyObject *__pyx_v_tries = 0;
  4238. PyObject *__pyx_v_ndots = 0;
  4239. PyObject *__pyx_v_udp_port = 0;
  4240. PyObject *__pyx_v_tcp_port = 0;
  4241. PyObject *__pyx_v_servers = 0;
  4242. int __pyx_r;
  4243. __Pyx_RefNannyDeclarations
  4244. __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  4245. {
  4246. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_loop,&__pyx_n_s_flags,&__pyx_n_s_timeout,&__pyx_n_s_tries,&__pyx_n_s_ndots,&__pyx_n_s_udp_port,&__pyx_n_s_tcp_port,&__pyx_n_s_servers,0};
  4247. PyObject* values[8] = {0,0,0,0,0,0,0,0};
  4248. values[1] = ((PyObject *)Py_None);
  4249. values[2] = ((PyObject *)Py_None);
  4250. values[3] = ((PyObject *)Py_None);
  4251. values[4] = ((PyObject *)Py_None);
  4252. /* "gevent/ares.pyx":253
  4253. *
  4254. * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None,
  4255. * udp_port=None, tcp_port=None, servers=None): # <<<<<<<<<<<<<<
  4256. * cdef ares_channeldata* channel = NULL
  4257. * cdef cares.ares_options options
  4258. */
  4259. values[5] = ((PyObject *)Py_None);
  4260. values[6] = ((PyObject *)Py_None);
  4261. values[7] = ((PyObject *)Py_None);
  4262. if (unlikely(__pyx_kwds)) {
  4263. Py_ssize_t kw_args;
  4264. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  4265. switch (pos_args) {
  4266. case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
  4267. case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
  4268. case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
  4269. case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
  4270. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  4271. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  4272. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4273. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4274. case 0: break;
  4275. default: goto __pyx_L5_argtuple_error;
  4276. }
  4277. kw_args = PyDict_Size(__pyx_kwds);
  4278. switch (pos_args) {
  4279. case 0:
  4280. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_loop)) != 0)) kw_args--;
  4281. else goto __pyx_L5_argtuple_error;
  4282. case 1:
  4283. if (kw_args > 0) {
  4284. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags);
  4285. if (value) { values[1] = value; kw_args--; }
  4286. }
  4287. case 2:
  4288. if (kw_args > 0) {
  4289. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout);
  4290. if (value) { values[2] = value; kw_args--; }
  4291. }
  4292. case 3:
  4293. if (kw_args > 0) {
  4294. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tries);
  4295. if (value) { values[3] = value; kw_args--; }
  4296. }
  4297. case 4:
  4298. if (kw_args > 0) {
  4299. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ndots);
  4300. if (value) { values[4] = value; kw_args--; }
  4301. }
  4302. case 5:
  4303. if (kw_args > 0) {
  4304. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_udp_port);
  4305. if (value) { values[5] = value; kw_args--; }
  4306. }
  4307. case 6:
  4308. if (kw_args > 0) {
  4309. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_tcp_port);
  4310. if (value) { values[6] = value; kw_args--; }
  4311. }
  4312. case 7:
  4313. if (kw_args > 0) {
  4314. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_servers);
  4315. if (value) { values[7] = value; kw_args--; }
  4316. }
  4317. }
  4318. if (unlikely(kw_args > 0)) {
  4319. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 252, __pyx_L3_error)
  4320. }
  4321. } else {
  4322. switch (PyTuple_GET_SIZE(__pyx_args)) {
  4323. case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
  4324. case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
  4325. case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
  4326. case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
  4327. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  4328. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  4329. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  4330. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  4331. break;
  4332. default: goto __pyx_L5_argtuple_error;
  4333. }
  4334. }
  4335. __pyx_v_loop = values[0];
  4336. __pyx_v_flags = values[1];
  4337. __pyx_v_timeout = values[2];
  4338. __pyx_v_tries = values[3];
  4339. __pyx_v_ndots = values[4];
  4340. __pyx_v_udp_port = values[5];
  4341. __pyx_v_tcp_port = values[6];
  4342. __pyx_v_servers = values[7];
  4343. }
  4344. goto __pyx_L4_argument_unpacking_done;
  4345. __pyx_L5_argtuple_error:;
  4346. __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 252, __pyx_L3_error)
  4347. __pyx_L3_error:;
  4348. __Pyx_AddTraceback("gevent.ares.channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4349. __Pyx_RefNannyFinishContext();
  4350. return -1;
  4351. __pyx_L4_argument_unpacking_done:;
  4352. __pyx_r = __pyx_pf_6gevent_4ares_7channel___init__(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_loop, __pyx_v_flags, __pyx_v_timeout, __pyx_v_tries, __pyx_v_ndots, __pyx_v_udp_port, __pyx_v_tcp_port, __pyx_v_servers);
  4353. /* "gevent/ares.pyx":252
  4354. * cdef public object _timer
  4355. *
  4356. * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, # <<<<<<<<<<<<<<
  4357. * udp_port=None, tcp_port=None, servers=None):
  4358. * cdef ares_channeldata* channel = NULL
  4359. */
  4360. /* function exit code */
  4361. __Pyx_RefNannyFinishContext();
  4362. return __pyx_r;
  4363. }
  4364. static int __pyx_pf_6gevent_4ares_7channel___init__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_loop, PyObject *__pyx_v_flags, PyObject *__pyx_v_timeout, PyObject *__pyx_v_tries, PyObject *__pyx_v_ndots, PyObject *__pyx_v_udp_port, PyObject *__pyx_v_tcp_port, PyObject *__pyx_v_servers) {
  4365. struct ares_channeldata *__pyx_v_channel;
  4366. struct ares_options __pyx_v_options;
  4367. int __pyx_v_optmask;
  4368. int __pyx_v_result;
  4369. int __pyx_r;
  4370. __Pyx_RefNannyDeclarations
  4371. int __pyx_t_1;
  4372. int __pyx_t_2;
  4373. PyObject *__pyx_t_3 = NULL;
  4374. int __pyx_t_4;
  4375. double __pyx_t_5;
  4376. unsigned short __pyx_t_6;
  4377. PyObject *__pyx_t_7 = NULL;
  4378. PyObject *__pyx_t_8 = NULL;
  4379. PyObject *__pyx_t_9 = NULL;
  4380. PyObject *__pyx_t_10 = NULL;
  4381. PyObject *__pyx_t_11 = NULL;
  4382. PyObject *__pyx_t_12 = NULL;
  4383. PyObject *__pyx_t_13 = NULL;
  4384. PyObject *__pyx_t_14 = NULL;
  4385. __Pyx_RefNannySetupContext("__init__", 0);
  4386. /* "gevent/ares.pyx":254
  4387. * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None,
  4388. * udp_port=None, tcp_port=None, servers=None):
  4389. * cdef ares_channeldata* channel = NULL # <<<<<<<<<<<<<<
  4390. * cdef cares.ares_options options
  4391. * memset(&options, 0, sizeof(cares.ares_options))
  4392. */
  4393. __pyx_v_channel = NULL;
  4394. /* "gevent/ares.pyx":256
  4395. * cdef ares_channeldata* channel = NULL
  4396. * cdef cares.ares_options options
  4397. * memset(&options, 0, sizeof(cares.ares_options)) # <<<<<<<<<<<<<<
  4398. * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB
  4399. * options.sock_state_cb = <void*>gevent_sock_state_callback
  4400. */
  4401. memset((&__pyx_v_options), 0, (sizeof(struct ares_options)));
  4402. /* "gevent/ares.pyx":257
  4403. * cdef cares.ares_options options
  4404. * memset(&options, 0, sizeof(cares.ares_options))
  4405. * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB # <<<<<<<<<<<<<<
  4406. * options.sock_state_cb = <void*>gevent_sock_state_callback
  4407. * options.sock_state_cb_data = <void*>self
  4408. */
  4409. __pyx_v_optmask = ARES_OPT_SOCK_STATE_CB;
  4410. /* "gevent/ares.pyx":258
  4411. * memset(&options, 0, sizeof(cares.ares_options))
  4412. * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB
  4413. * options.sock_state_cb = <void*>gevent_sock_state_callback # <<<<<<<<<<<<<<
  4414. * options.sock_state_cb_data = <void*>self
  4415. * if flags is not None:
  4416. */
  4417. __pyx_v_options.sock_state_cb = ((void *)__pyx_f_6gevent_4ares_gevent_sock_state_callback);
  4418. /* "gevent/ares.pyx":259
  4419. * cdef int optmask = cares.ARES_OPT_SOCK_STATE_CB
  4420. * options.sock_state_cb = <void*>gevent_sock_state_callback
  4421. * options.sock_state_cb_data = <void*>self # <<<<<<<<<<<<<<
  4422. * if flags is not None:
  4423. * options.flags = int(flags)
  4424. */
  4425. __pyx_v_options.sock_state_cb_data = ((void *)__pyx_v_self);
  4426. /* "gevent/ares.pyx":260
  4427. * options.sock_state_cb = <void*>gevent_sock_state_callback
  4428. * options.sock_state_cb_data = <void*>self
  4429. * if flags is not None: # <<<<<<<<<<<<<<
  4430. * options.flags = int(flags)
  4431. * optmask |= cares.ARES_OPT_FLAGS
  4432. */
  4433. __pyx_t_1 = (__pyx_v_flags != Py_None);
  4434. __pyx_t_2 = (__pyx_t_1 != 0);
  4435. if (__pyx_t_2) {
  4436. /* "gevent/ares.pyx":261
  4437. * options.sock_state_cb_data = <void*>self
  4438. * if flags is not None:
  4439. * options.flags = int(flags) # <<<<<<<<<<<<<<
  4440. * optmask |= cares.ARES_OPT_FLAGS
  4441. * if timeout is not None:
  4442. */
  4443. __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 261, __pyx_L1_error)
  4444. __Pyx_GOTREF(__pyx_t_3);
  4445. __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 261, __pyx_L1_error)
  4446. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4447. __pyx_v_options.flags = __pyx_t_4;
  4448. /* "gevent/ares.pyx":262
  4449. * if flags is not None:
  4450. * options.flags = int(flags)
  4451. * optmask |= cares.ARES_OPT_FLAGS # <<<<<<<<<<<<<<
  4452. * if timeout is not None:
  4453. * options.timeout = int(float(timeout) * 1000)
  4454. */
  4455. __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_FLAGS);
  4456. /* "gevent/ares.pyx":260
  4457. * options.sock_state_cb = <void*>gevent_sock_state_callback
  4458. * options.sock_state_cb_data = <void*>self
  4459. * if flags is not None: # <<<<<<<<<<<<<<
  4460. * options.flags = int(flags)
  4461. * optmask |= cares.ARES_OPT_FLAGS
  4462. */
  4463. }
  4464. /* "gevent/ares.pyx":263
  4465. * options.flags = int(flags)
  4466. * optmask |= cares.ARES_OPT_FLAGS
  4467. * if timeout is not None: # <<<<<<<<<<<<<<
  4468. * options.timeout = int(float(timeout) * 1000)
  4469. * optmask |= cares.ARES_OPT_TIMEOUTMS
  4470. */
  4471. __pyx_t_2 = (__pyx_v_timeout != Py_None);
  4472. __pyx_t_1 = (__pyx_t_2 != 0);
  4473. if (__pyx_t_1) {
  4474. /* "gevent/ares.pyx":264
  4475. * optmask |= cares.ARES_OPT_FLAGS
  4476. * if timeout is not None:
  4477. * options.timeout = int(float(timeout) * 1000) # <<<<<<<<<<<<<<
  4478. * optmask |= cares.ARES_OPT_TIMEOUTMS
  4479. * if tries is not None:
  4480. */
  4481. __pyx_t_5 = __Pyx_PyObject_AsDouble(__pyx_v_timeout); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 264, __pyx_L1_error)
  4482. __pyx_v_options.timeout = ((int)(__pyx_t_5 * 1000.0));
  4483. /* "gevent/ares.pyx":265
  4484. * if timeout is not None:
  4485. * options.timeout = int(float(timeout) * 1000)
  4486. * optmask |= cares.ARES_OPT_TIMEOUTMS # <<<<<<<<<<<<<<
  4487. * if tries is not None:
  4488. * options.tries = int(tries)
  4489. */
  4490. __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_TIMEOUTMS);
  4491. /* "gevent/ares.pyx":263
  4492. * options.flags = int(flags)
  4493. * optmask |= cares.ARES_OPT_FLAGS
  4494. * if timeout is not None: # <<<<<<<<<<<<<<
  4495. * options.timeout = int(float(timeout) * 1000)
  4496. * optmask |= cares.ARES_OPT_TIMEOUTMS
  4497. */
  4498. }
  4499. /* "gevent/ares.pyx":266
  4500. * options.timeout = int(float(timeout) * 1000)
  4501. * optmask |= cares.ARES_OPT_TIMEOUTMS
  4502. * if tries is not None: # <<<<<<<<<<<<<<
  4503. * options.tries = int(tries)
  4504. * optmask |= cares.ARES_OPT_TRIES
  4505. */
  4506. __pyx_t_1 = (__pyx_v_tries != Py_None);
  4507. __pyx_t_2 = (__pyx_t_1 != 0);
  4508. if (__pyx_t_2) {
  4509. /* "gevent/ares.pyx":267
  4510. * optmask |= cares.ARES_OPT_TIMEOUTMS
  4511. * if tries is not None:
  4512. * options.tries = int(tries) # <<<<<<<<<<<<<<
  4513. * optmask |= cares.ARES_OPT_TRIES
  4514. * if ndots is not None:
  4515. */
  4516. __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_tries); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error)
  4517. __Pyx_GOTREF(__pyx_t_3);
  4518. __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 267, __pyx_L1_error)
  4519. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4520. __pyx_v_options.tries = __pyx_t_4;
  4521. /* "gevent/ares.pyx":268
  4522. * if tries is not None:
  4523. * options.tries = int(tries)
  4524. * optmask |= cares.ARES_OPT_TRIES # <<<<<<<<<<<<<<
  4525. * if ndots is not None:
  4526. * options.ndots = int(ndots)
  4527. */
  4528. __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_TRIES);
  4529. /* "gevent/ares.pyx":266
  4530. * options.timeout = int(float(timeout) * 1000)
  4531. * optmask |= cares.ARES_OPT_TIMEOUTMS
  4532. * if tries is not None: # <<<<<<<<<<<<<<
  4533. * options.tries = int(tries)
  4534. * optmask |= cares.ARES_OPT_TRIES
  4535. */
  4536. }
  4537. /* "gevent/ares.pyx":269
  4538. * options.tries = int(tries)
  4539. * optmask |= cares.ARES_OPT_TRIES
  4540. * if ndots is not None: # <<<<<<<<<<<<<<
  4541. * options.ndots = int(ndots)
  4542. * optmask |= cares.ARES_OPT_NDOTS
  4543. */
  4544. __pyx_t_2 = (__pyx_v_ndots != Py_None);
  4545. __pyx_t_1 = (__pyx_t_2 != 0);
  4546. if (__pyx_t_1) {
  4547. /* "gevent/ares.pyx":270
  4548. * optmask |= cares.ARES_OPT_TRIES
  4549. * if ndots is not None:
  4550. * options.ndots = int(ndots) # <<<<<<<<<<<<<<
  4551. * optmask |= cares.ARES_OPT_NDOTS
  4552. * if udp_port is not None:
  4553. */
  4554. __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_ndots); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 270, __pyx_L1_error)
  4555. __Pyx_GOTREF(__pyx_t_3);
  4556. __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 270, __pyx_L1_error)
  4557. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4558. __pyx_v_options.ndots = __pyx_t_4;
  4559. /* "gevent/ares.pyx":271
  4560. * if ndots is not None:
  4561. * options.ndots = int(ndots)
  4562. * optmask |= cares.ARES_OPT_NDOTS # <<<<<<<<<<<<<<
  4563. * if udp_port is not None:
  4564. * options.udp_port = int(udp_port)
  4565. */
  4566. __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_NDOTS);
  4567. /* "gevent/ares.pyx":269
  4568. * options.tries = int(tries)
  4569. * optmask |= cares.ARES_OPT_TRIES
  4570. * if ndots is not None: # <<<<<<<<<<<<<<
  4571. * options.ndots = int(ndots)
  4572. * optmask |= cares.ARES_OPT_NDOTS
  4573. */
  4574. }
  4575. /* "gevent/ares.pyx":272
  4576. * options.ndots = int(ndots)
  4577. * optmask |= cares.ARES_OPT_NDOTS
  4578. * if udp_port is not None: # <<<<<<<<<<<<<<
  4579. * options.udp_port = int(udp_port)
  4580. * optmask |= cares.ARES_OPT_UDP_PORT
  4581. */
  4582. __pyx_t_1 = (__pyx_v_udp_port != Py_None);
  4583. __pyx_t_2 = (__pyx_t_1 != 0);
  4584. if (__pyx_t_2) {
  4585. /* "gevent/ares.pyx":273
  4586. * optmask |= cares.ARES_OPT_NDOTS
  4587. * if udp_port is not None:
  4588. * options.udp_port = int(udp_port) # <<<<<<<<<<<<<<
  4589. * optmask |= cares.ARES_OPT_UDP_PORT
  4590. * if tcp_port is not None:
  4591. */
  4592. __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_udp_port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L1_error)
  4593. __Pyx_GOTREF(__pyx_t_3);
  4594. __pyx_t_6 = __Pyx_PyInt_As_unsigned_short(__pyx_t_3); if (unlikely((__pyx_t_6 == (unsigned short)-1) && PyErr_Occurred())) __PYX_ERR(0, 273, __pyx_L1_error)
  4595. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4596. __pyx_v_options.udp_port = __pyx_t_6;
  4597. /* "gevent/ares.pyx":274
  4598. * if udp_port is not None:
  4599. * options.udp_port = int(udp_port)
  4600. * optmask |= cares.ARES_OPT_UDP_PORT # <<<<<<<<<<<<<<
  4601. * if tcp_port is not None:
  4602. * options.tcp_port = int(tcp_port)
  4603. */
  4604. __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_UDP_PORT);
  4605. /* "gevent/ares.pyx":272
  4606. * options.ndots = int(ndots)
  4607. * optmask |= cares.ARES_OPT_NDOTS
  4608. * if udp_port is not None: # <<<<<<<<<<<<<<
  4609. * options.udp_port = int(udp_port)
  4610. * optmask |= cares.ARES_OPT_UDP_PORT
  4611. */
  4612. }
  4613. /* "gevent/ares.pyx":275
  4614. * options.udp_port = int(udp_port)
  4615. * optmask |= cares.ARES_OPT_UDP_PORT
  4616. * if tcp_port is not None: # <<<<<<<<<<<<<<
  4617. * options.tcp_port = int(tcp_port)
  4618. * optmask |= cares.ARES_OPT_TCP_PORT
  4619. */
  4620. __pyx_t_2 = (__pyx_v_tcp_port != Py_None);
  4621. __pyx_t_1 = (__pyx_t_2 != 0);
  4622. if (__pyx_t_1) {
  4623. /* "gevent/ares.pyx":276
  4624. * optmask |= cares.ARES_OPT_UDP_PORT
  4625. * if tcp_port is not None:
  4626. * options.tcp_port = int(tcp_port) # <<<<<<<<<<<<<<
  4627. * optmask |= cares.ARES_OPT_TCP_PORT
  4628. * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK?
  4629. */
  4630. __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_tcp_port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
  4631. __Pyx_GOTREF(__pyx_t_3);
  4632. __pyx_t_6 = __Pyx_PyInt_As_unsigned_short(__pyx_t_3); if (unlikely((__pyx_t_6 == (unsigned short)-1) && PyErr_Occurred())) __PYX_ERR(0, 276, __pyx_L1_error)
  4633. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4634. __pyx_v_options.tcp_port = __pyx_t_6;
  4635. /* "gevent/ares.pyx":277
  4636. * if tcp_port is not None:
  4637. * options.tcp_port = int(tcp_port)
  4638. * optmask |= cares.ARES_OPT_TCP_PORT # <<<<<<<<<<<<<<
  4639. * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK?
  4640. * if result:
  4641. */
  4642. __pyx_v_optmask = (__pyx_v_optmask | ARES_OPT_TCP_PORT);
  4643. /* "gevent/ares.pyx":275
  4644. * options.udp_port = int(udp_port)
  4645. * optmask |= cares.ARES_OPT_UDP_PORT
  4646. * if tcp_port is not None: # <<<<<<<<<<<<<<
  4647. * options.tcp_port = int(tcp_port)
  4648. * optmask |= cares.ARES_OPT_TCP_PORT
  4649. */
  4650. }
  4651. /* "gevent/ares.pyx":278
  4652. * options.tcp_port = int(tcp_port)
  4653. * optmask |= cares.ARES_OPT_TCP_PORT
  4654. * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK? # <<<<<<<<<<<<<<
  4655. * if result:
  4656. * raise gaierror(result, strerror(result))
  4657. */
  4658. __pyx_v_result = ares_library_init(ARES_LIB_INIT_ALL);
  4659. /* "gevent/ares.pyx":279
  4660. * optmask |= cares.ARES_OPT_TCP_PORT
  4661. * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK?
  4662. * if result: # <<<<<<<<<<<<<<
  4663. * raise gaierror(result, strerror(result))
  4664. * result = cares.ares_init_options(&channel, &options, optmask)
  4665. */
  4666. __pyx_t_1 = (__pyx_v_result != 0);
  4667. if (__pyx_t_1) {
  4668. /* "gevent/ares.pyx":280
  4669. * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK?
  4670. * if result:
  4671. * raise gaierror(result, strerror(result)) # <<<<<<<<<<<<<<
  4672. * result = cares.ares_init_options(&channel, &options, optmask)
  4673. * if result:
  4674. */
  4675. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 280, __pyx_L1_error)
  4676. __Pyx_GOTREF(__pyx_t_7);
  4677. __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 280, __pyx_L1_error)
  4678. __Pyx_GOTREF(__pyx_t_8);
  4679. __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 280, __pyx_L1_error)
  4680. __Pyx_GOTREF(__pyx_t_9);
  4681. __pyx_t_10 = __pyx_f_6gevent_4ares_strerror(__pyx_t_9, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 280, __pyx_L1_error)
  4682. __Pyx_GOTREF(__pyx_t_10);
  4683. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4684. __pyx_t_9 = NULL;
  4685. __pyx_t_4 = 0;
  4686. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
  4687. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
  4688. if (likely(__pyx_t_9)) {
  4689. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  4690. __Pyx_INCREF(__pyx_t_9);
  4691. __Pyx_INCREF(function);
  4692. __Pyx_DECREF_SET(__pyx_t_7, function);
  4693. __pyx_t_4 = 1;
  4694. }
  4695. }
  4696. #if CYTHON_FAST_PYCALL
  4697. if (PyFunction_Check(__pyx_t_7)) {
  4698. PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10};
  4699. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error)
  4700. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  4701. __Pyx_GOTREF(__pyx_t_3);
  4702. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4703. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  4704. } else
  4705. #endif
  4706. #if CYTHON_FAST_PYCCALL
  4707. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  4708. PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_8, __pyx_t_10};
  4709. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error)
  4710. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  4711. __Pyx_GOTREF(__pyx_t_3);
  4712. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4713. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  4714. } else
  4715. #endif
  4716. {
  4717. __pyx_t_11 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 280, __pyx_L1_error)
  4718. __Pyx_GOTREF(__pyx_t_11);
  4719. if (__pyx_t_9) {
  4720. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
  4721. }
  4722. __Pyx_GIVEREF(__pyx_t_8);
  4723. PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_4, __pyx_t_8);
  4724. __Pyx_GIVEREF(__pyx_t_10);
  4725. PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_4, __pyx_t_10);
  4726. __pyx_t_8 = 0;
  4727. __pyx_t_10 = 0;
  4728. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error)
  4729. __Pyx_GOTREF(__pyx_t_3);
  4730. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  4731. }
  4732. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4733. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  4734. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4735. __PYX_ERR(0, 280, __pyx_L1_error)
  4736. /* "gevent/ares.pyx":279
  4737. * optmask |= cares.ARES_OPT_TCP_PORT
  4738. * cdef int result = cares.ares_library_init(cares.ARES_LIB_INIT_ALL) # ARES_LIB_INIT_WIN32 -DUSE_WINSOCK?
  4739. * if result: # <<<<<<<<<<<<<<
  4740. * raise gaierror(result, strerror(result))
  4741. * result = cares.ares_init_options(&channel, &options, optmask)
  4742. */
  4743. }
  4744. /* "gevent/ares.pyx":281
  4745. * if result:
  4746. * raise gaierror(result, strerror(result))
  4747. * result = cares.ares_init_options(&channel, &options, optmask) # <<<<<<<<<<<<<<
  4748. * if result:
  4749. * raise gaierror(result, strerror(result))
  4750. */
  4751. __pyx_v_result = ares_init_options((&__pyx_v_channel), (&__pyx_v_options), __pyx_v_optmask);
  4752. /* "gevent/ares.pyx":282
  4753. * raise gaierror(result, strerror(result))
  4754. * result = cares.ares_init_options(&channel, &options, optmask)
  4755. * if result: # <<<<<<<<<<<<<<
  4756. * raise gaierror(result, strerror(result))
  4757. * self._timer = loop.timer(TIMEOUT, TIMEOUT)
  4758. */
  4759. __pyx_t_1 = (__pyx_v_result != 0);
  4760. if (__pyx_t_1) {
  4761. /* "gevent/ares.pyx":283
  4762. * result = cares.ares_init_options(&channel, &options, optmask)
  4763. * if result:
  4764. * raise gaierror(result, strerror(result)) # <<<<<<<<<<<<<<
  4765. * self._timer = loop.timer(TIMEOUT, TIMEOUT)
  4766. * self._watchers = {}
  4767. */
  4768. __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 283, __pyx_L1_error)
  4769. __Pyx_GOTREF(__pyx_t_7);
  4770. __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 283, __pyx_L1_error)
  4771. __Pyx_GOTREF(__pyx_t_11);
  4772. __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_result); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 283, __pyx_L1_error)
  4773. __Pyx_GOTREF(__pyx_t_10);
  4774. __pyx_t_8 = __pyx_f_6gevent_4ares_strerror(__pyx_t_10, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 283, __pyx_L1_error)
  4775. __Pyx_GOTREF(__pyx_t_8);
  4776. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  4777. __pyx_t_10 = NULL;
  4778. __pyx_t_4 = 0;
  4779. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
  4780. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
  4781. if (likely(__pyx_t_10)) {
  4782. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  4783. __Pyx_INCREF(__pyx_t_10);
  4784. __Pyx_INCREF(function);
  4785. __Pyx_DECREF_SET(__pyx_t_7, function);
  4786. __pyx_t_4 = 1;
  4787. }
  4788. }
  4789. #if CYTHON_FAST_PYCALL
  4790. if (PyFunction_Check(__pyx_t_7)) {
  4791. PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_11, __pyx_t_8};
  4792. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
  4793. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  4794. __Pyx_GOTREF(__pyx_t_3);
  4795. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  4796. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4797. } else
  4798. #endif
  4799. #if CYTHON_FAST_PYCCALL
  4800. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  4801. PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_11, __pyx_t_8};
  4802. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
  4803. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  4804. __Pyx_GOTREF(__pyx_t_3);
  4805. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  4806. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4807. } else
  4808. #endif
  4809. {
  4810. __pyx_t_9 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 283, __pyx_L1_error)
  4811. __Pyx_GOTREF(__pyx_t_9);
  4812. if (__pyx_t_10) {
  4813. __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
  4814. }
  4815. __Pyx_GIVEREF(__pyx_t_11);
  4816. PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_4, __pyx_t_11);
  4817. __Pyx_GIVEREF(__pyx_t_8);
  4818. PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_4, __pyx_t_8);
  4819. __pyx_t_11 = 0;
  4820. __pyx_t_8 = 0;
  4821. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
  4822. __Pyx_GOTREF(__pyx_t_3);
  4823. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4824. }
  4825. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4826. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  4827. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4828. __PYX_ERR(0, 283, __pyx_L1_error)
  4829. /* "gevent/ares.pyx":282
  4830. * raise gaierror(result, strerror(result))
  4831. * result = cares.ares_init_options(&channel, &options, optmask)
  4832. * if result: # <<<<<<<<<<<<<<
  4833. * raise gaierror(result, strerror(result))
  4834. * self._timer = loop.timer(TIMEOUT, TIMEOUT)
  4835. */
  4836. }
  4837. /* "gevent/ares.pyx":284
  4838. * if result:
  4839. * raise gaierror(result, strerror(result))
  4840. * self._timer = loop.timer(TIMEOUT, TIMEOUT) # <<<<<<<<<<<<<<
  4841. * self._watchers = {}
  4842. * self.channel = channel
  4843. */
  4844. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_loop, __pyx_n_s_timer); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 284, __pyx_L1_error)
  4845. __Pyx_GOTREF(__pyx_t_7);
  4846. __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_TIMEOUT); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 284, __pyx_L1_error)
  4847. __Pyx_GOTREF(__pyx_t_9);
  4848. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_TIMEOUT); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 284, __pyx_L1_error)
  4849. __Pyx_GOTREF(__pyx_t_8);
  4850. __pyx_t_11 = NULL;
  4851. __pyx_t_4 = 0;
  4852. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
  4853. __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_7);
  4854. if (likely(__pyx_t_11)) {
  4855. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  4856. __Pyx_INCREF(__pyx_t_11);
  4857. __Pyx_INCREF(function);
  4858. __Pyx_DECREF_SET(__pyx_t_7, function);
  4859. __pyx_t_4 = 1;
  4860. }
  4861. }
  4862. #if CYTHON_FAST_PYCALL
  4863. if (PyFunction_Check(__pyx_t_7)) {
  4864. PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_8};
  4865. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error)
  4866. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  4867. __Pyx_GOTREF(__pyx_t_3);
  4868. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4869. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4870. } else
  4871. #endif
  4872. #if CYTHON_FAST_PYCCALL
  4873. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  4874. PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_9, __pyx_t_8};
  4875. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error)
  4876. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  4877. __Pyx_GOTREF(__pyx_t_3);
  4878. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4879. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4880. } else
  4881. #endif
  4882. {
  4883. __pyx_t_10 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 284, __pyx_L1_error)
  4884. __Pyx_GOTREF(__pyx_t_10);
  4885. if (__pyx_t_11) {
  4886. __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11); __pyx_t_11 = NULL;
  4887. }
  4888. __Pyx_GIVEREF(__pyx_t_9);
  4889. PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_4, __pyx_t_9);
  4890. __Pyx_GIVEREF(__pyx_t_8);
  4891. PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_4, __pyx_t_8);
  4892. __pyx_t_9 = 0;
  4893. __pyx_t_8 = 0;
  4894. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error)
  4895. __Pyx_GOTREF(__pyx_t_3);
  4896. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  4897. }
  4898. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4899. __Pyx_GIVEREF(__pyx_t_3);
  4900. __Pyx_GOTREF(__pyx_v_self->_timer);
  4901. __Pyx_DECREF(__pyx_v_self->_timer);
  4902. __pyx_v_self->_timer = __pyx_t_3;
  4903. __pyx_t_3 = 0;
  4904. /* "gevent/ares.pyx":285
  4905. * raise gaierror(result, strerror(result))
  4906. * self._timer = loop.timer(TIMEOUT, TIMEOUT)
  4907. * self._watchers = {} # <<<<<<<<<<<<<<
  4908. * self.channel = channel
  4909. * try:
  4910. */
  4911. __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L1_error)
  4912. __Pyx_GOTREF(__pyx_t_3);
  4913. __Pyx_GIVEREF(__pyx_t_3);
  4914. __Pyx_GOTREF(__pyx_v_self->_watchers);
  4915. __Pyx_DECREF(__pyx_v_self->_watchers);
  4916. __pyx_v_self->_watchers = ((PyObject*)__pyx_t_3);
  4917. __pyx_t_3 = 0;
  4918. /* "gevent/ares.pyx":286
  4919. * self._timer = loop.timer(TIMEOUT, TIMEOUT)
  4920. * self._watchers = {}
  4921. * self.channel = channel # <<<<<<<<<<<<<<
  4922. * try:
  4923. * if servers is not None:
  4924. */
  4925. __pyx_v_self->channel = __pyx_v_channel;
  4926. /* "gevent/ares.pyx":287
  4927. * self._watchers = {}
  4928. * self.channel = channel
  4929. * try: # <<<<<<<<<<<<<<
  4930. * if servers is not None:
  4931. * self.set_servers(servers)
  4932. */
  4933. {
  4934. __Pyx_PyThreadState_declare
  4935. __Pyx_PyThreadState_assign
  4936. __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
  4937. __Pyx_XGOTREF(__pyx_t_12);
  4938. __Pyx_XGOTREF(__pyx_t_13);
  4939. __Pyx_XGOTREF(__pyx_t_14);
  4940. /*try:*/ {
  4941. /* "gevent/ares.pyx":288
  4942. * self.channel = channel
  4943. * try:
  4944. * if servers is not None: # <<<<<<<<<<<<<<
  4945. * self.set_servers(servers)
  4946. * self.loop = loop
  4947. */
  4948. __pyx_t_1 = (__pyx_v_servers != Py_None);
  4949. __pyx_t_2 = (__pyx_t_1 != 0);
  4950. if (__pyx_t_2) {
  4951. /* "gevent/ares.pyx":289
  4952. * try:
  4953. * if servers is not None:
  4954. * self.set_servers(servers) # <<<<<<<<<<<<<<
  4955. * self.loop = loop
  4956. * except:
  4957. */
  4958. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_servers); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 289, __pyx_L11_error)
  4959. __Pyx_GOTREF(__pyx_t_7);
  4960. __pyx_t_10 = NULL;
  4961. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
  4962. __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
  4963. if (likely(__pyx_t_10)) {
  4964. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
  4965. __Pyx_INCREF(__pyx_t_10);
  4966. __Pyx_INCREF(function);
  4967. __Pyx_DECREF_SET(__pyx_t_7, function);
  4968. }
  4969. }
  4970. if (!__pyx_t_10) {
  4971. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_servers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L11_error)
  4972. __Pyx_GOTREF(__pyx_t_3);
  4973. } else {
  4974. #if CYTHON_FAST_PYCALL
  4975. if (PyFunction_Check(__pyx_t_7)) {
  4976. PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_servers};
  4977. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L11_error)
  4978. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  4979. __Pyx_GOTREF(__pyx_t_3);
  4980. } else
  4981. #endif
  4982. #if CYTHON_FAST_PYCCALL
  4983. if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
  4984. PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_servers};
  4985. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L11_error)
  4986. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  4987. __Pyx_GOTREF(__pyx_t_3);
  4988. } else
  4989. #endif
  4990. {
  4991. __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 289, __pyx_L11_error)
  4992. __Pyx_GOTREF(__pyx_t_8);
  4993. __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); __pyx_t_10 = NULL;
  4994. __Pyx_INCREF(__pyx_v_servers);
  4995. __Pyx_GIVEREF(__pyx_v_servers);
  4996. PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_servers);
  4997. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L11_error)
  4998. __Pyx_GOTREF(__pyx_t_3);
  4999. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5000. }
  5001. }
  5002. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5003. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5004. /* "gevent/ares.pyx":288
  5005. * self.channel = channel
  5006. * try:
  5007. * if servers is not None: # <<<<<<<<<<<<<<
  5008. * self.set_servers(servers)
  5009. * self.loop = loop
  5010. */
  5011. }
  5012. /* "gevent/ares.pyx":290
  5013. * if servers is not None:
  5014. * self.set_servers(servers)
  5015. * self.loop = loop # <<<<<<<<<<<<<<
  5016. * except:
  5017. * self.destroy()
  5018. */
  5019. __Pyx_INCREF(__pyx_v_loop);
  5020. __Pyx_GIVEREF(__pyx_v_loop);
  5021. __Pyx_GOTREF(__pyx_v_self->loop);
  5022. __Pyx_DECREF(__pyx_v_self->loop);
  5023. __pyx_v_self->loop = __pyx_v_loop;
  5024. /* "gevent/ares.pyx":287
  5025. * self._watchers = {}
  5026. * self.channel = channel
  5027. * try: # <<<<<<<<<<<<<<
  5028. * if servers is not None:
  5029. * self.set_servers(servers)
  5030. */
  5031. }
  5032. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  5033. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  5034. __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
  5035. goto __pyx_L18_try_end;
  5036. __pyx_L11_error:;
  5037. __Pyx_PyThreadState_assign
  5038. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  5039. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  5040. __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  5041. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  5042. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5043. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5044. /* "gevent/ares.pyx":291
  5045. * self.set_servers(servers)
  5046. * self.loop = loop
  5047. * except: # <<<<<<<<<<<<<<
  5048. * self.destroy()
  5049. * raise
  5050. */
  5051. /*except:*/ {
  5052. __Pyx_AddTraceback("gevent.ares.channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5053. if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_7, &__pyx_t_8) < 0) __PYX_ERR(0, 291, __pyx_L13_except_error)
  5054. __Pyx_GOTREF(__pyx_t_3);
  5055. __Pyx_GOTREF(__pyx_t_7);
  5056. __Pyx_GOTREF(__pyx_t_8);
  5057. /* "gevent/ares.pyx":292
  5058. * self.loop = loop
  5059. * except:
  5060. * self.destroy() # <<<<<<<<<<<<<<
  5061. * raise
  5062. *
  5063. */
  5064. __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_destroy); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 292, __pyx_L13_except_error)
  5065. __Pyx_GOTREF(__pyx_t_9);
  5066. __pyx_t_11 = NULL;
  5067. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
  5068. __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
  5069. if (likely(__pyx_t_11)) {
  5070. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
  5071. __Pyx_INCREF(__pyx_t_11);
  5072. __Pyx_INCREF(function);
  5073. __Pyx_DECREF_SET(__pyx_t_9, function);
  5074. }
  5075. }
  5076. if (__pyx_t_11) {
  5077. __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 292, __pyx_L13_except_error)
  5078. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5079. } else {
  5080. __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 292, __pyx_L13_except_error)
  5081. }
  5082. __Pyx_GOTREF(__pyx_t_10);
  5083. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  5084. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  5085. /* "gevent/ares.pyx":293
  5086. * except:
  5087. * self.destroy()
  5088. * raise # <<<<<<<<<<<<<<
  5089. *
  5090. * def __repr__(self):
  5091. */
  5092. __Pyx_GIVEREF(__pyx_t_3);
  5093. __Pyx_GIVEREF(__pyx_t_7);
  5094. __Pyx_XGIVEREF(__pyx_t_8);
  5095. __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_7, __pyx_t_8);
  5096. __pyx_t_3 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0;
  5097. __PYX_ERR(0, 293, __pyx_L13_except_error)
  5098. }
  5099. __pyx_L13_except_error:;
  5100. /* "gevent/ares.pyx":287
  5101. * self._watchers = {}
  5102. * self.channel = channel
  5103. * try: # <<<<<<<<<<<<<<
  5104. * if servers is not None:
  5105. * self.set_servers(servers)
  5106. */
  5107. __Pyx_PyThreadState_assign
  5108. __Pyx_XGIVEREF(__pyx_t_12);
  5109. __Pyx_XGIVEREF(__pyx_t_13);
  5110. __Pyx_XGIVEREF(__pyx_t_14);
  5111. __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
  5112. goto __pyx_L1_error;
  5113. __pyx_L18_try_end:;
  5114. }
  5115. /* "gevent/ares.pyx":252
  5116. * cdef public object _timer
  5117. *
  5118. * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None, # <<<<<<<<<<<<<<
  5119. * udp_port=None, tcp_port=None, servers=None):
  5120. * cdef ares_channeldata* channel = NULL
  5121. */
  5122. /* function exit code */
  5123. __pyx_r = 0;
  5124. goto __pyx_L0;
  5125. __pyx_L1_error:;
  5126. __Pyx_XDECREF(__pyx_t_3);
  5127. __Pyx_XDECREF(__pyx_t_7);
  5128. __Pyx_XDECREF(__pyx_t_8);
  5129. __Pyx_XDECREF(__pyx_t_9);
  5130. __Pyx_XDECREF(__pyx_t_10);
  5131. __Pyx_XDECREF(__pyx_t_11);
  5132. __Pyx_AddTraceback("gevent.ares.channel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5133. __pyx_r = -1;
  5134. __pyx_L0:;
  5135. __Pyx_RefNannyFinishContext();
  5136. return __pyx_r;
  5137. }
  5138. /* "gevent/ares.pyx":295
  5139. * raise
  5140. *
  5141. * def __repr__(self): # <<<<<<<<<<<<<<
  5142. * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers))
  5143. * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args
  5144. */
  5145. /* Python wrapper */
  5146. static PyObject *__pyx_pw_6gevent_4ares_7channel_3__repr__(PyObject *__pyx_v_self); /*proto*/
  5147. static PyObject *__pyx_pw_6gevent_4ares_7channel_3__repr__(PyObject *__pyx_v_self) {
  5148. PyObject *__pyx_r = 0;
  5149. __Pyx_RefNannyDeclarations
  5150. __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  5151. __pyx_r = __pyx_pf_6gevent_4ares_7channel_2__repr__(((struct PyGeventAresChannelObject *)__pyx_v_self));
  5152. /* function exit code */
  5153. __Pyx_RefNannyFinishContext();
  5154. return __pyx_r;
  5155. }
  5156. static PyObject *__pyx_pf_6gevent_4ares_7channel_2__repr__(struct PyGeventAresChannelObject *__pyx_v_self) {
  5157. PyObject *__pyx_v_args = NULL;
  5158. PyObject *__pyx_r = NULL;
  5159. __Pyx_RefNannyDeclarations
  5160. PyObject *__pyx_t_1 = NULL;
  5161. PyObject *__pyx_t_2 = NULL;
  5162. PyObject *__pyx_t_3 = NULL;
  5163. Py_ssize_t __pyx_t_4;
  5164. PyObject *__pyx_t_5 = NULL;
  5165. __Pyx_RefNannySetupContext("__repr__", 0);
  5166. /* "gevent/ares.pyx":296
  5167. *
  5168. * def __repr__(self):
  5169. * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers)) # <<<<<<<<<<<<<<
  5170. * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args
  5171. *
  5172. */
  5173. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
  5174. __Pyx_GOTREF(__pyx_t_1);
  5175. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error)
  5176. __Pyx_GOTREF(__pyx_t_2);
  5177. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5178. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
  5179. __Pyx_GOTREF(__pyx_t_1);
  5180. __Pyx_INCREF(((PyObject *)__pyx_v_self));
  5181. __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  5182. PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  5183. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_id, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error)
  5184. __Pyx_GOTREF(__pyx_t_3);
  5185. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5186. __pyx_t_1 = __pyx_v_self->_watchers;
  5187. __Pyx_INCREF(__pyx_t_1);
  5188. if (unlikely(__pyx_t_1 == Py_None)) {
  5189. PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
  5190. __PYX_ERR(0, 296, __pyx_L1_error)
  5191. }
  5192. __pyx_t_4 = PyDict_Size(__pyx_t_1); if (unlikely(__pyx_t_4 == -1)) __PYX_ERR(0, 296, __pyx_L1_error)
  5193. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5194. __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
  5195. __Pyx_GOTREF(__pyx_t_1);
  5196. __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 296, __pyx_L1_error)
  5197. __Pyx_GOTREF(__pyx_t_5);
  5198. __Pyx_GIVEREF(__pyx_t_2);
  5199. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  5200. __Pyx_GIVEREF(__pyx_t_3);
  5201. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  5202. __Pyx_INCREF(__pyx_v_self->_timer);
  5203. __Pyx_GIVEREF(__pyx_v_self->_timer);
  5204. PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_self->_timer);
  5205. __Pyx_GIVEREF(__pyx_t_1);
  5206. PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_1);
  5207. __pyx_t_2 = 0;
  5208. __pyx_t_3 = 0;
  5209. __pyx_t_1 = 0;
  5210. __pyx_v_args = ((PyObject*)__pyx_t_5);
  5211. __pyx_t_5 = 0;
  5212. /* "gevent/ares.pyx":297
  5213. * def __repr__(self):
  5214. * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers))
  5215. * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args # <<<<<<<<<<<<<<
  5216. *
  5217. * def destroy(self):
  5218. */
  5219. __Pyx_XDECREF(__pyx_r);
  5220. __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_s_at_0x_x__timer_r__watchers_s, __pyx_v_args); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 297, __pyx_L1_error)
  5221. __Pyx_GOTREF(__pyx_t_5);
  5222. __pyx_r = __pyx_t_5;
  5223. __pyx_t_5 = 0;
  5224. goto __pyx_L0;
  5225. /* "gevent/ares.pyx":295
  5226. * raise
  5227. *
  5228. * def __repr__(self): # <<<<<<<<<<<<<<
  5229. * args = (self.__class__.__name__, id(self), self._timer, len(self._watchers))
  5230. * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args
  5231. */
  5232. /* function exit code */
  5233. __pyx_L1_error:;
  5234. __Pyx_XDECREF(__pyx_t_1);
  5235. __Pyx_XDECREF(__pyx_t_2);
  5236. __Pyx_XDECREF(__pyx_t_3);
  5237. __Pyx_XDECREF(__pyx_t_5);
  5238. __Pyx_AddTraceback("gevent.ares.channel.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5239. __pyx_r = NULL;
  5240. __pyx_L0:;
  5241. __Pyx_XDECREF(__pyx_v_args);
  5242. __Pyx_XGIVEREF(__pyx_r);
  5243. __Pyx_RefNannyFinishContext();
  5244. return __pyx_r;
  5245. }
  5246. /* "gevent/ares.pyx":299
  5247. * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args
  5248. *
  5249. * def destroy(self): # <<<<<<<<<<<<<<
  5250. * if self.channel:
  5251. * # XXX ares_library_cleanup?
  5252. */
  5253. /* Python wrapper */
  5254. static PyObject *__pyx_pw_6gevent_4ares_7channel_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  5255. static PyObject *__pyx_pw_6gevent_4ares_7channel_5destroy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  5256. PyObject *__pyx_r = 0;
  5257. __Pyx_RefNannyDeclarations
  5258. __Pyx_RefNannySetupContext("destroy (wrapper)", 0);
  5259. __pyx_r = __pyx_pf_6gevent_4ares_7channel_4destroy(((struct PyGeventAresChannelObject *)__pyx_v_self));
  5260. /* function exit code */
  5261. __Pyx_RefNannyFinishContext();
  5262. return __pyx_r;
  5263. }
  5264. static PyObject *__pyx_pf_6gevent_4ares_7channel_4destroy(struct PyGeventAresChannelObject *__pyx_v_self) {
  5265. PyObject *__pyx_r = NULL;
  5266. __Pyx_RefNannyDeclarations
  5267. int __pyx_t_1;
  5268. int __pyx_t_2;
  5269. PyObject *__pyx_t_3 = NULL;
  5270. PyObject *__pyx_t_4 = NULL;
  5271. PyObject *__pyx_t_5 = NULL;
  5272. __Pyx_RefNannySetupContext("destroy", 0);
  5273. /* "gevent/ares.pyx":300
  5274. *
  5275. * def destroy(self):
  5276. * if self.channel: # <<<<<<<<<<<<<<
  5277. * # XXX ares_library_cleanup?
  5278. * cares.ares_destroy(self.channel)
  5279. */
  5280. __pyx_t_1 = (__pyx_v_self->channel != 0);
  5281. if (__pyx_t_1) {
  5282. /* "gevent/ares.pyx":302
  5283. * if self.channel:
  5284. * # XXX ares_library_cleanup?
  5285. * cares.ares_destroy(self.channel) # <<<<<<<<<<<<<<
  5286. * self.channel = NULL
  5287. * self._watchers.clear()
  5288. */
  5289. ares_destroy(__pyx_v_self->channel);
  5290. /* "gevent/ares.pyx":303
  5291. * # XXX ares_library_cleanup?
  5292. * cares.ares_destroy(self.channel)
  5293. * self.channel = NULL # <<<<<<<<<<<<<<
  5294. * self._watchers.clear()
  5295. * self._timer.stop()
  5296. */
  5297. __pyx_v_self->channel = NULL;
  5298. /* "gevent/ares.pyx":304
  5299. * cares.ares_destroy(self.channel)
  5300. * self.channel = NULL
  5301. * self._watchers.clear() # <<<<<<<<<<<<<<
  5302. * self._timer.stop()
  5303. * self.loop = None
  5304. */
  5305. if (unlikely(__pyx_v_self->_watchers == Py_None)) {
  5306. PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "clear");
  5307. __PYX_ERR(0, 304, __pyx_L1_error)
  5308. }
  5309. __pyx_t_2 = __Pyx_PyDict_Clear(__pyx_v_self->_watchers); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 304, __pyx_L1_error)
  5310. /* "gevent/ares.pyx":305
  5311. * self.channel = NULL
  5312. * self._watchers.clear()
  5313. * self._timer.stop() # <<<<<<<<<<<<<<
  5314. * self.loop = None
  5315. *
  5316. */
  5317. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_stop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 305, __pyx_L1_error)
  5318. __Pyx_GOTREF(__pyx_t_4);
  5319. __pyx_t_5 = NULL;
  5320. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
  5321. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  5322. if (likely(__pyx_t_5)) {
  5323. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  5324. __Pyx_INCREF(__pyx_t_5);
  5325. __Pyx_INCREF(function);
  5326. __Pyx_DECREF_SET(__pyx_t_4, function);
  5327. }
  5328. }
  5329. if (__pyx_t_5) {
  5330. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error)
  5331. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5332. } else {
  5333. __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error)
  5334. }
  5335. __Pyx_GOTREF(__pyx_t_3);
  5336. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5337. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5338. /* "gevent/ares.pyx":306
  5339. * self._watchers.clear()
  5340. * self._timer.stop()
  5341. * self.loop = None # <<<<<<<<<<<<<<
  5342. *
  5343. * def __dealloc__(self):
  5344. */
  5345. __Pyx_INCREF(Py_None);
  5346. __Pyx_GIVEREF(Py_None);
  5347. __Pyx_GOTREF(__pyx_v_self->loop);
  5348. __Pyx_DECREF(__pyx_v_self->loop);
  5349. __pyx_v_self->loop = Py_None;
  5350. /* "gevent/ares.pyx":300
  5351. *
  5352. * def destroy(self):
  5353. * if self.channel: # <<<<<<<<<<<<<<
  5354. * # XXX ares_library_cleanup?
  5355. * cares.ares_destroy(self.channel)
  5356. */
  5357. }
  5358. /* "gevent/ares.pyx":299
  5359. * return '<%s at 0x%x _timer=%r _watchers[%s]>' % args
  5360. *
  5361. * def destroy(self): # <<<<<<<<<<<<<<
  5362. * if self.channel:
  5363. * # XXX ares_library_cleanup?
  5364. */
  5365. /* function exit code */
  5366. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5367. goto __pyx_L0;
  5368. __pyx_L1_error:;
  5369. __Pyx_XDECREF(__pyx_t_3);
  5370. __Pyx_XDECREF(__pyx_t_4);
  5371. __Pyx_XDECREF(__pyx_t_5);
  5372. __Pyx_AddTraceback("gevent.ares.channel.destroy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5373. __pyx_r = NULL;
  5374. __pyx_L0:;
  5375. __Pyx_XGIVEREF(__pyx_r);
  5376. __Pyx_RefNannyFinishContext();
  5377. return __pyx_r;
  5378. }
  5379. /* "gevent/ares.pyx":308
  5380. * self.loop = None
  5381. *
  5382. * def __dealloc__(self): # <<<<<<<<<<<<<<
  5383. * if self.channel:
  5384. * # XXX ares_library_cleanup?
  5385. */
  5386. /* Python wrapper */
  5387. static void __pyx_pw_6gevent_4ares_7channel_7__dealloc__(PyObject *__pyx_v_self); /*proto*/
  5388. static void __pyx_pw_6gevent_4ares_7channel_7__dealloc__(PyObject *__pyx_v_self) {
  5389. __Pyx_RefNannyDeclarations
  5390. __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  5391. __pyx_pf_6gevent_4ares_7channel_6__dealloc__(((struct PyGeventAresChannelObject *)__pyx_v_self));
  5392. /* function exit code */
  5393. __Pyx_RefNannyFinishContext();
  5394. }
  5395. static void __pyx_pf_6gevent_4ares_7channel_6__dealloc__(struct PyGeventAresChannelObject *__pyx_v_self) {
  5396. __Pyx_RefNannyDeclarations
  5397. int __pyx_t_1;
  5398. __Pyx_RefNannySetupContext("__dealloc__", 0);
  5399. /* "gevent/ares.pyx":309
  5400. *
  5401. * def __dealloc__(self):
  5402. * if self.channel: # <<<<<<<<<<<<<<
  5403. * # XXX ares_library_cleanup?
  5404. * cares.ares_destroy(self.channel)
  5405. */
  5406. __pyx_t_1 = (__pyx_v_self->channel != 0);
  5407. if (__pyx_t_1) {
  5408. /* "gevent/ares.pyx":311
  5409. * if self.channel:
  5410. * # XXX ares_library_cleanup?
  5411. * cares.ares_destroy(self.channel) # <<<<<<<<<<<<<<
  5412. * self.channel = NULL
  5413. *
  5414. */
  5415. ares_destroy(__pyx_v_self->channel);
  5416. /* "gevent/ares.pyx":312
  5417. * # XXX ares_library_cleanup?
  5418. * cares.ares_destroy(self.channel)
  5419. * self.channel = NULL # <<<<<<<<<<<<<<
  5420. *
  5421. * def set_servers(self, servers=None):
  5422. */
  5423. __pyx_v_self->channel = NULL;
  5424. /* "gevent/ares.pyx":309
  5425. *
  5426. * def __dealloc__(self):
  5427. * if self.channel: # <<<<<<<<<<<<<<
  5428. * # XXX ares_library_cleanup?
  5429. * cares.ares_destroy(self.channel)
  5430. */
  5431. }
  5432. /* "gevent/ares.pyx":308
  5433. * self.loop = None
  5434. *
  5435. * def __dealloc__(self): # <<<<<<<<<<<<<<
  5436. * if self.channel:
  5437. * # XXX ares_library_cleanup?
  5438. */
  5439. /* function exit code */
  5440. __Pyx_RefNannyFinishContext();
  5441. }
  5442. /* "gevent/ares.pyx":314
  5443. * self.channel = NULL
  5444. *
  5445. * def set_servers(self, servers=None): # <<<<<<<<<<<<<<
  5446. * if not self.channel:
  5447. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  5448. */
  5449. /* Python wrapper */
  5450. static PyObject *__pyx_pw_6gevent_4ares_7channel_9set_servers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  5451. static PyObject *__pyx_pw_6gevent_4ares_7channel_9set_servers(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  5452. PyObject *__pyx_v_servers = 0;
  5453. PyObject *__pyx_r = 0;
  5454. __Pyx_RefNannyDeclarations
  5455. __Pyx_RefNannySetupContext("set_servers (wrapper)", 0);
  5456. {
  5457. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_servers,0};
  5458. PyObject* values[1] = {0};
  5459. values[0] = ((PyObject *)Py_None);
  5460. if (unlikely(__pyx_kwds)) {
  5461. Py_ssize_t kw_args;
  5462. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  5463. switch (pos_args) {
  5464. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5465. case 0: break;
  5466. default: goto __pyx_L5_argtuple_error;
  5467. }
  5468. kw_args = PyDict_Size(__pyx_kwds);
  5469. switch (pos_args) {
  5470. case 0:
  5471. if (kw_args > 0) {
  5472. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_servers);
  5473. if (value) { values[0] = value; kw_args--; }
  5474. }
  5475. }
  5476. if (unlikely(kw_args > 0)) {
  5477. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_servers") < 0)) __PYX_ERR(0, 314, __pyx_L3_error)
  5478. }
  5479. } else {
  5480. switch (PyTuple_GET_SIZE(__pyx_args)) {
  5481. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  5482. case 0: break;
  5483. default: goto __pyx_L5_argtuple_error;
  5484. }
  5485. }
  5486. __pyx_v_servers = values[0];
  5487. }
  5488. goto __pyx_L4_argument_unpacking_done;
  5489. __pyx_L5_argtuple_error:;
  5490. __Pyx_RaiseArgtupleInvalid("set_servers", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 314, __pyx_L3_error)
  5491. __pyx_L3_error:;
  5492. __Pyx_AddTraceback("gevent.ares.channel.set_servers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5493. __Pyx_RefNannyFinishContext();
  5494. return NULL;
  5495. __pyx_L4_argument_unpacking_done:;
  5496. __pyx_r = __pyx_pf_6gevent_4ares_7channel_8set_servers(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_servers);
  5497. /* function exit code */
  5498. __Pyx_RefNannyFinishContext();
  5499. return __pyx_r;
  5500. }
  5501. static PyObject *__pyx_pf_6gevent_4ares_7channel_8set_servers(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_servers) {
  5502. int __pyx_v_length;
  5503. CYTHON_UNUSED int __pyx_v_result;
  5504. int __pyx_v_index;
  5505. char *__pyx_v_string;
  5506. struct ares_addr_node *__pyx_v_c_servers;
  5507. PyObject *__pyx_v_server = NULL;
  5508. PyObject *__pyx_r = NULL;
  5509. __Pyx_RefNannyDeclarations
  5510. int __pyx_t_1;
  5511. PyObject *__pyx_t_2 = NULL;
  5512. PyObject *__pyx_t_3 = NULL;
  5513. PyObject *__pyx_t_4 = NULL;
  5514. PyObject *__pyx_t_5 = NULL;
  5515. int __pyx_t_6;
  5516. PyObject *__pyx_t_7 = NULL;
  5517. int __pyx_t_8;
  5518. Py_ssize_t __pyx_t_9;
  5519. PyObject *(*__pyx_t_10)(PyObject *);
  5520. char *__pyx_t_11;
  5521. PyObject *__pyx_t_12 = NULL;
  5522. int __pyx_t_13;
  5523. char const *__pyx_t_14;
  5524. PyObject *__pyx_t_15 = NULL;
  5525. PyObject *__pyx_t_16 = NULL;
  5526. PyObject *__pyx_t_17 = NULL;
  5527. PyObject *__pyx_t_18 = NULL;
  5528. PyObject *__pyx_t_19 = NULL;
  5529. PyObject *__pyx_t_20 = NULL;
  5530. __Pyx_RefNannySetupContext("set_servers", 0);
  5531. __Pyx_INCREF(__pyx_v_servers);
  5532. /* "gevent/ares.pyx":315
  5533. *
  5534. * def set_servers(self, servers=None):
  5535. * if not self.channel: # <<<<<<<<<<<<<<
  5536. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  5537. * if not servers:
  5538. */
  5539. __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0);
  5540. if (__pyx_t_1) {
  5541. /* "gevent/ares.pyx":316
  5542. * def set_servers(self, servers=None):
  5543. * if not self.channel:
  5544. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<<
  5545. * if not servers:
  5546. * servers = []
  5547. */
  5548. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 316, __pyx_L1_error)
  5549. __Pyx_GOTREF(__pyx_t_3);
  5550. __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 316, __pyx_L1_error)
  5551. __Pyx_GOTREF(__pyx_t_4);
  5552. __pyx_t_5 = NULL;
  5553. __pyx_t_6 = 0;
  5554. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  5555. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
  5556. if (likely(__pyx_t_5)) {
  5557. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  5558. __Pyx_INCREF(__pyx_t_5);
  5559. __Pyx_INCREF(function);
  5560. __Pyx_DECREF_SET(__pyx_t_3, function);
  5561. __pyx_t_6 = 1;
  5562. }
  5563. }
  5564. #if CYTHON_FAST_PYCALL
  5565. if (PyFunction_Check(__pyx_t_3)) {
  5566. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
  5567. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error)
  5568. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5569. __Pyx_GOTREF(__pyx_t_2);
  5570. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5571. } else
  5572. #endif
  5573. #if CYTHON_FAST_PYCCALL
  5574. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  5575. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
  5576. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error)
  5577. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  5578. __Pyx_GOTREF(__pyx_t_2);
  5579. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5580. } else
  5581. #endif
  5582. {
  5583. __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 316, __pyx_L1_error)
  5584. __Pyx_GOTREF(__pyx_t_7);
  5585. if (__pyx_t_5) {
  5586. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  5587. }
  5588. __Pyx_GIVEREF(__pyx_t_4);
  5589. PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4);
  5590. __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr);
  5591. __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr);
  5592. PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr);
  5593. __pyx_t_4 = 0;
  5594. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error)
  5595. __Pyx_GOTREF(__pyx_t_2);
  5596. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5597. }
  5598. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5599. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  5600. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5601. __PYX_ERR(0, 316, __pyx_L1_error)
  5602. /* "gevent/ares.pyx":315
  5603. *
  5604. * def set_servers(self, servers=None):
  5605. * if not self.channel: # <<<<<<<<<<<<<<
  5606. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  5607. * if not servers:
  5608. */
  5609. }
  5610. /* "gevent/ares.pyx":317
  5611. * if not self.channel:
  5612. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  5613. * if not servers: # <<<<<<<<<<<<<<
  5614. * servers = []
  5615. * if isinstance(servers, string_types):
  5616. */
  5617. __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_servers); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 317, __pyx_L1_error)
  5618. __pyx_t_8 = ((!__pyx_t_1) != 0);
  5619. if (__pyx_t_8) {
  5620. /* "gevent/ares.pyx":318
  5621. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  5622. * if not servers:
  5623. * servers = [] # <<<<<<<<<<<<<<
  5624. * if isinstance(servers, string_types):
  5625. * servers = servers.split(',')
  5626. */
  5627. __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 318, __pyx_L1_error)
  5628. __Pyx_GOTREF(__pyx_t_2);
  5629. __Pyx_DECREF_SET(__pyx_v_servers, __pyx_t_2);
  5630. __pyx_t_2 = 0;
  5631. /* "gevent/ares.pyx":317
  5632. * if not self.channel:
  5633. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  5634. * if not servers: # <<<<<<<<<<<<<<
  5635. * servers = []
  5636. * if isinstance(servers, string_types):
  5637. */
  5638. }
  5639. /* "gevent/ares.pyx":319
  5640. * if not servers:
  5641. * servers = []
  5642. * if isinstance(servers, string_types): # <<<<<<<<<<<<<<
  5643. * servers = servers.split(',')
  5644. * cdef int length = len(servers)
  5645. */
  5646. __pyx_t_2 = __pyx_v_6gevent_4ares_string_types;
  5647. __Pyx_INCREF(__pyx_t_2);
  5648. __pyx_t_8 = PyObject_IsInstance(__pyx_v_servers, __pyx_t_2); if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 319, __pyx_L1_error)
  5649. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5650. __pyx_t_1 = (__pyx_t_8 != 0);
  5651. if (__pyx_t_1) {
  5652. /* "gevent/ares.pyx":320
  5653. * servers = []
  5654. * if isinstance(servers, string_types):
  5655. * servers = servers.split(',') # <<<<<<<<<<<<<<
  5656. * cdef int length = len(servers)
  5657. * cdef int result, index
  5658. */
  5659. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_servers, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L1_error)
  5660. __Pyx_GOTREF(__pyx_t_2);
  5661. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L1_error)
  5662. __Pyx_GOTREF(__pyx_t_3);
  5663. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5664. __Pyx_DECREF_SET(__pyx_v_servers, __pyx_t_3);
  5665. __pyx_t_3 = 0;
  5666. /* "gevent/ares.pyx":319
  5667. * if not servers:
  5668. * servers = []
  5669. * if isinstance(servers, string_types): # <<<<<<<<<<<<<<
  5670. * servers = servers.split(',')
  5671. * cdef int length = len(servers)
  5672. */
  5673. }
  5674. /* "gevent/ares.pyx":321
  5675. * if isinstance(servers, string_types):
  5676. * servers = servers.split(',')
  5677. * cdef int length = len(servers) # <<<<<<<<<<<<<<
  5678. * cdef int result, index
  5679. * cdef char* string
  5680. */
  5681. __pyx_t_9 = PyObject_Length(__pyx_v_servers); if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 321, __pyx_L1_error)
  5682. __pyx_v_length = __pyx_t_9;
  5683. /* "gevent/ares.pyx":325
  5684. * cdef char* string
  5685. * cdef cares.ares_addr_node* c_servers
  5686. * if length <= 0: # <<<<<<<<<<<<<<
  5687. * result = cares.ares_set_servers(self.channel, NULL)
  5688. * else:
  5689. */
  5690. __pyx_t_1 = ((__pyx_v_length <= 0) != 0);
  5691. if (__pyx_t_1) {
  5692. /* "gevent/ares.pyx":326
  5693. * cdef cares.ares_addr_node* c_servers
  5694. * if length <= 0:
  5695. * result = cares.ares_set_servers(self.channel, NULL) # <<<<<<<<<<<<<<
  5696. * else:
  5697. * c_servers = <cares.ares_addr_node*>malloc(sizeof(cares.ares_addr_node) * length)
  5698. */
  5699. __pyx_v_result = ares_set_servers(__pyx_v_self->channel, NULL);
  5700. /* "gevent/ares.pyx":325
  5701. * cdef char* string
  5702. * cdef cares.ares_addr_node* c_servers
  5703. * if length <= 0: # <<<<<<<<<<<<<<
  5704. * result = cares.ares_set_servers(self.channel, NULL)
  5705. * else:
  5706. */
  5707. goto __pyx_L6;
  5708. }
  5709. /* "gevent/ares.pyx":328
  5710. * result = cares.ares_set_servers(self.channel, NULL)
  5711. * else:
  5712. * c_servers = <cares.ares_addr_node*>malloc(sizeof(cares.ares_addr_node) * length) # <<<<<<<<<<<<<<
  5713. * if not c_servers:
  5714. * raise MemoryError
  5715. */
  5716. /*else*/ {
  5717. __pyx_v_c_servers = ((struct ares_addr_node *)malloc(((sizeof(struct ares_addr_node)) * __pyx_v_length)));
  5718. /* "gevent/ares.pyx":329
  5719. * else:
  5720. * c_servers = <cares.ares_addr_node*>malloc(sizeof(cares.ares_addr_node) * length)
  5721. * if not c_servers: # <<<<<<<<<<<<<<
  5722. * raise MemoryError
  5723. * try:
  5724. */
  5725. __pyx_t_1 = ((!(__pyx_v_c_servers != 0)) != 0);
  5726. if (__pyx_t_1) {
  5727. /* "gevent/ares.pyx":330
  5728. * c_servers = <cares.ares_addr_node*>malloc(sizeof(cares.ares_addr_node) * length)
  5729. * if not c_servers:
  5730. * raise MemoryError # <<<<<<<<<<<<<<
  5731. * try:
  5732. * index = 0
  5733. */
  5734. PyErr_NoMemory(); __PYX_ERR(0, 330, __pyx_L1_error)
  5735. /* "gevent/ares.pyx":329
  5736. * else:
  5737. * c_servers = <cares.ares_addr_node*>malloc(sizeof(cares.ares_addr_node) * length)
  5738. * if not c_servers: # <<<<<<<<<<<<<<
  5739. * raise MemoryError
  5740. * try:
  5741. */
  5742. }
  5743. /* "gevent/ares.pyx":331
  5744. * if not c_servers:
  5745. * raise MemoryError
  5746. * try: # <<<<<<<<<<<<<<
  5747. * index = 0
  5748. * for server in servers:
  5749. */
  5750. /*try:*/ {
  5751. /* "gevent/ares.pyx":332
  5752. * raise MemoryError
  5753. * try:
  5754. * index = 0 # <<<<<<<<<<<<<<
  5755. * for server in servers:
  5756. * if isinstance(server, unicode):
  5757. */
  5758. __pyx_v_index = 0;
  5759. /* "gevent/ares.pyx":333
  5760. * try:
  5761. * index = 0
  5762. * for server in servers: # <<<<<<<<<<<<<<
  5763. * if isinstance(server, unicode):
  5764. * server = server.encode('ascii')
  5765. */
  5766. if (likely(PyList_CheckExact(__pyx_v_servers)) || PyTuple_CheckExact(__pyx_v_servers)) {
  5767. __pyx_t_3 = __pyx_v_servers; __Pyx_INCREF(__pyx_t_3); __pyx_t_9 = 0;
  5768. __pyx_t_10 = NULL;
  5769. } else {
  5770. __pyx_t_9 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_servers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 333, __pyx_L9_error)
  5771. __Pyx_GOTREF(__pyx_t_3);
  5772. __pyx_t_10 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 333, __pyx_L9_error)
  5773. }
  5774. for (;;) {
  5775. if (likely(!__pyx_t_10)) {
  5776. if (likely(PyList_CheckExact(__pyx_t_3))) {
  5777. if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_3)) break;
  5778. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5779. __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 333, __pyx_L9_error)
  5780. #else
  5781. __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L9_error)
  5782. __Pyx_GOTREF(__pyx_t_2);
  5783. #endif
  5784. } else {
  5785. if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
  5786. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5787. __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 333, __pyx_L9_error)
  5788. #else
  5789. __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 333, __pyx_L9_error)
  5790. __Pyx_GOTREF(__pyx_t_2);
  5791. #endif
  5792. }
  5793. } else {
  5794. __pyx_t_2 = __pyx_t_10(__pyx_t_3);
  5795. if (unlikely(!__pyx_t_2)) {
  5796. PyObject* exc_type = PyErr_Occurred();
  5797. if (exc_type) {
  5798. if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  5799. else __PYX_ERR(0, 333, __pyx_L9_error)
  5800. }
  5801. break;
  5802. }
  5803. __Pyx_GOTREF(__pyx_t_2);
  5804. }
  5805. __Pyx_XDECREF_SET(__pyx_v_server, __pyx_t_2);
  5806. __pyx_t_2 = 0;
  5807. /* "gevent/ares.pyx":334
  5808. * index = 0
  5809. * for server in servers:
  5810. * if isinstance(server, unicode): # <<<<<<<<<<<<<<
  5811. * server = server.encode('ascii')
  5812. * string = <char*?>server
  5813. */
  5814. __pyx_t_1 = PyUnicode_Check(__pyx_v_server);
  5815. __pyx_t_8 = (__pyx_t_1 != 0);
  5816. if (__pyx_t_8) {
  5817. /* "gevent/ares.pyx":335
  5818. * for server in servers:
  5819. * if isinstance(server, unicode):
  5820. * server = server.encode('ascii') # <<<<<<<<<<<<<<
  5821. * string = <char*?>server
  5822. * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0:
  5823. */
  5824. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_server, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 335, __pyx_L9_error)
  5825. __Pyx_GOTREF(__pyx_t_2);
  5826. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 335, __pyx_L9_error)
  5827. __Pyx_GOTREF(__pyx_t_7);
  5828. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5829. __Pyx_DECREF_SET(__pyx_v_server, __pyx_t_7);
  5830. __pyx_t_7 = 0;
  5831. /* "gevent/ares.pyx":334
  5832. * index = 0
  5833. * for server in servers:
  5834. * if isinstance(server, unicode): # <<<<<<<<<<<<<<
  5835. * server = server.encode('ascii')
  5836. * string = <char*?>server
  5837. */
  5838. }
  5839. /* "gevent/ares.pyx":336
  5840. * if isinstance(server, unicode):
  5841. * server = server.encode('ascii')
  5842. * string = <char*?>server # <<<<<<<<<<<<<<
  5843. * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0:
  5844. * c_servers[index].family = AF_INET
  5845. */
  5846. __pyx_t_11 = __Pyx_PyObject_AsString(__pyx_v_server); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) __PYX_ERR(0, 336, __pyx_L9_error)
  5847. __pyx_v_string = ((char *)__pyx_t_11);
  5848. /* "gevent/ares.pyx":337
  5849. * server = server.encode('ascii')
  5850. * string = <char*?>server
  5851. * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<<
  5852. * c_servers[index].family = AF_INET
  5853. * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0:
  5854. */
  5855. __pyx_t_8 = ((ares_inet_pton(AF_INET, __pyx_v_string, (&(__pyx_v_c_servers[__pyx_v_index]).addr)) > 0) != 0);
  5856. if (__pyx_t_8) {
  5857. /* "gevent/ares.pyx":338
  5858. * string = <char*?>server
  5859. * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0:
  5860. * c_servers[index].family = AF_INET # <<<<<<<<<<<<<<
  5861. * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0:
  5862. * c_servers[index].family = AF_INET6
  5863. */
  5864. (__pyx_v_c_servers[__pyx_v_index]).family = AF_INET;
  5865. /* "gevent/ares.pyx":337
  5866. * server = server.encode('ascii')
  5867. * string = <char*?>server
  5868. * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<<
  5869. * c_servers[index].family = AF_INET
  5870. * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0:
  5871. */
  5872. goto __pyx_L14;
  5873. }
  5874. /* "gevent/ares.pyx":339
  5875. * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0:
  5876. * c_servers[index].family = AF_INET
  5877. * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<<
  5878. * c_servers[index].family = AF_INET6
  5879. * else:
  5880. */
  5881. __pyx_t_8 = ((ares_inet_pton(AF_INET6, __pyx_v_string, (&(__pyx_v_c_servers[__pyx_v_index]).addr)) > 0) != 0);
  5882. if (__pyx_t_8) {
  5883. /* "gevent/ares.pyx":340
  5884. * c_servers[index].family = AF_INET
  5885. * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0:
  5886. * c_servers[index].family = AF_INET6 # <<<<<<<<<<<<<<
  5887. * else:
  5888. * raise InvalidIP(repr(string))
  5889. */
  5890. (__pyx_v_c_servers[__pyx_v_index]).family = AF_INET6;
  5891. /* "gevent/ares.pyx":339
  5892. * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0:
  5893. * c_servers[index].family = AF_INET
  5894. * elif cares.ares_inet_pton(AF_INET6, string, &c_servers[index].addr) > 0: # <<<<<<<<<<<<<<
  5895. * c_servers[index].family = AF_INET6
  5896. * else:
  5897. */
  5898. goto __pyx_L14;
  5899. }
  5900. /* "gevent/ares.pyx":342
  5901. * c_servers[index].family = AF_INET6
  5902. * else:
  5903. * raise InvalidIP(repr(string)) # <<<<<<<<<<<<<<
  5904. * c_servers[index].next = &c_servers[index] + 1
  5905. * index += 1
  5906. */
  5907. /*else*/ {
  5908. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidIP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L9_error)
  5909. __Pyx_GOTREF(__pyx_t_2);
  5910. __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_string); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 342, __pyx_L9_error)
  5911. __Pyx_GOTREF(__pyx_t_4);
  5912. __pyx_t_5 = PyObject_Repr(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 342, __pyx_L9_error)
  5913. __Pyx_GOTREF(__pyx_t_5);
  5914. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5915. __pyx_t_4 = NULL;
  5916. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  5917. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
  5918. if (likely(__pyx_t_4)) {
  5919. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  5920. __Pyx_INCREF(__pyx_t_4);
  5921. __Pyx_INCREF(function);
  5922. __Pyx_DECREF_SET(__pyx_t_2, function);
  5923. }
  5924. }
  5925. if (!__pyx_t_4) {
  5926. __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 342, __pyx_L9_error)
  5927. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5928. __Pyx_GOTREF(__pyx_t_7);
  5929. } else {
  5930. #if CYTHON_FAST_PYCALL
  5931. if (PyFunction_Check(__pyx_t_2)) {
  5932. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5};
  5933. __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 342, __pyx_L9_error)
  5934. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5935. __Pyx_GOTREF(__pyx_t_7);
  5936. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5937. } else
  5938. #endif
  5939. #if CYTHON_FAST_PYCCALL
  5940. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  5941. PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5};
  5942. __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 342, __pyx_L9_error)
  5943. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5944. __Pyx_GOTREF(__pyx_t_7);
  5945. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5946. } else
  5947. #endif
  5948. {
  5949. __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 342, __pyx_L9_error)
  5950. __Pyx_GOTREF(__pyx_t_12);
  5951. __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_4); __pyx_t_4 = NULL;
  5952. __Pyx_GIVEREF(__pyx_t_5);
  5953. PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_5);
  5954. __pyx_t_5 = 0;
  5955. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 342, __pyx_L9_error)
  5956. __Pyx_GOTREF(__pyx_t_7);
  5957. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  5958. }
  5959. }
  5960. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5961. __Pyx_Raise(__pyx_t_7, 0, 0, 0);
  5962. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5963. __PYX_ERR(0, 342, __pyx_L9_error)
  5964. }
  5965. __pyx_L14:;
  5966. /* "gevent/ares.pyx":343
  5967. * else:
  5968. * raise InvalidIP(repr(string))
  5969. * c_servers[index].next = &c_servers[index] + 1 # <<<<<<<<<<<<<<
  5970. * index += 1
  5971. * if index >= length:
  5972. */
  5973. (__pyx_v_c_servers[__pyx_v_index]).next = ((&(__pyx_v_c_servers[__pyx_v_index])) + 1);
  5974. /* "gevent/ares.pyx":344
  5975. * raise InvalidIP(repr(string))
  5976. * c_servers[index].next = &c_servers[index] + 1
  5977. * index += 1 # <<<<<<<<<<<<<<
  5978. * if index >= length:
  5979. * break
  5980. */
  5981. __pyx_v_index = (__pyx_v_index + 1);
  5982. /* "gevent/ares.pyx":345
  5983. * c_servers[index].next = &c_servers[index] + 1
  5984. * index += 1
  5985. * if index >= length: # <<<<<<<<<<<<<<
  5986. * break
  5987. * c_servers[length - 1].next = NULL
  5988. */
  5989. __pyx_t_8 = ((__pyx_v_index >= __pyx_v_length) != 0);
  5990. if (__pyx_t_8) {
  5991. /* "gevent/ares.pyx":346
  5992. * index += 1
  5993. * if index >= length:
  5994. * break # <<<<<<<<<<<<<<
  5995. * c_servers[length - 1].next = NULL
  5996. * index = cares.ares_set_servers(self.channel, c_servers)
  5997. */
  5998. goto __pyx_L12_break;
  5999. /* "gevent/ares.pyx":345
  6000. * c_servers[index].next = &c_servers[index] + 1
  6001. * index += 1
  6002. * if index >= length: # <<<<<<<<<<<<<<
  6003. * break
  6004. * c_servers[length - 1].next = NULL
  6005. */
  6006. }
  6007. /* "gevent/ares.pyx":333
  6008. * try:
  6009. * index = 0
  6010. * for server in servers: # <<<<<<<<<<<<<<
  6011. * if isinstance(server, unicode):
  6012. * server = server.encode('ascii')
  6013. */
  6014. }
  6015. __pyx_L12_break:;
  6016. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6017. /* "gevent/ares.pyx":347
  6018. * if index >= length:
  6019. * break
  6020. * c_servers[length - 1].next = NULL # <<<<<<<<<<<<<<
  6021. * index = cares.ares_set_servers(self.channel, c_servers)
  6022. * if index:
  6023. */
  6024. (__pyx_v_c_servers[(__pyx_v_length - 1)]).next = NULL;
  6025. /* "gevent/ares.pyx":348
  6026. * break
  6027. * c_servers[length - 1].next = NULL
  6028. * index = cares.ares_set_servers(self.channel, c_servers) # <<<<<<<<<<<<<<
  6029. * if index:
  6030. * raise ValueError(strerror(index))
  6031. */
  6032. __pyx_v_index = ares_set_servers(__pyx_v_self->channel, __pyx_v_c_servers);
  6033. /* "gevent/ares.pyx":349
  6034. * c_servers[length - 1].next = NULL
  6035. * index = cares.ares_set_servers(self.channel, c_servers)
  6036. * if index: # <<<<<<<<<<<<<<
  6037. * raise ValueError(strerror(index))
  6038. * finally:
  6039. */
  6040. __pyx_t_8 = (__pyx_v_index != 0);
  6041. if (__pyx_t_8) {
  6042. /* "gevent/ares.pyx":350
  6043. * index = cares.ares_set_servers(self.channel, c_servers)
  6044. * if index:
  6045. * raise ValueError(strerror(index)) # <<<<<<<<<<<<<<
  6046. * finally:
  6047. * free(c_servers)
  6048. */
  6049. __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 350, __pyx_L9_error)
  6050. __Pyx_GOTREF(__pyx_t_3);
  6051. __pyx_t_7 = __pyx_f_6gevent_4ares_strerror(__pyx_t_3, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 350, __pyx_L9_error)
  6052. __Pyx_GOTREF(__pyx_t_7);
  6053. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6054. __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 350, __pyx_L9_error)
  6055. __Pyx_GOTREF(__pyx_t_3);
  6056. __Pyx_GIVEREF(__pyx_t_7);
  6057. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7);
  6058. __pyx_t_7 = 0;
  6059. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 350, __pyx_L9_error)
  6060. __Pyx_GOTREF(__pyx_t_7);
  6061. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6062. __Pyx_Raise(__pyx_t_7, 0, 0, 0);
  6063. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6064. __PYX_ERR(0, 350, __pyx_L9_error)
  6065. /* "gevent/ares.pyx":349
  6066. * c_servers[length - 1].next = NULL
  6067. * index = cares.ares_set_servers(self.channel, c_servers)
  6068. * if index: # <<<<<<<<<<<<<<
  6069. * raise ValueError(strerror(index))
  6070. * finally:
  6071. */
  6072. }
  6073. }
  6074. /* "gevent/ares.pyx":352
  6075. * raise ValueError(strerror(index))
  6076. * finally:
  6077. * free(c_servers) # <<<<<<<<<<<<<<
  6078. *
  6079. * # this crashes c-ares
  6080. */
  6081. /*finally:*/ {
  6082. /*normal exit:*/{
  6083. free(__pyx_v_c_servers);
  6084. goto __pyx_L10;
  6085. }
  6086. /*exception exit:*/{
  6087. __Pyx_PyThreadState_declare
  6088. __pyx_L9_error:;
  6089. __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
  6090. __Pyx_PyThreadState_assign
  6091. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  6092. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  6093. __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  6094. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  6095. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  6096. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6097. if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
  6098. if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
  6099. __Pyx_XGOTREF(__pyx_t_15);
  6100. __Pyx_XGOTREF(__pyx_t_16);
  6101. __Pyx_XGOTREF(__pyx_t_17);
  6102. __Pyx_XGOTREF(__pyx_t_18);
  6103. __Pyx_XGOTREF(__pyx_t_19);
  6104. __Pyx_XGOTREF(__pyx_t_20);
  6105. __pyx_t_6 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename;
  6106. {
  6107. free(__pyx_v_c_servers);
  6108. }
  6109. __Pyx_PyThreadState_assign
  6110. if (PY_MAJOR_VERSION >= 3) {
  6111. __Pyx_XGIVEREF(__pyx_t_18);
  6112. __Pyx_XGIVEREF(__pyx_t_19);
  6113. __Pyx_XGIVEREF(__pyx_t_20);
  6114. __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
  6115. }
  6116. __Pyx_XGIVEREF(__pyx_t_15);
  6117. __Pyx_XGIVEREF(__pyx_t_16);
  6118. __Pyx_XGIVEREF(__pyx_t_17);
  6119. __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
  6120. __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
  6121. __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14;
  6122. goto __pyx_L1_error;
  6123. }
  6124. __pyx_L10:;
  6125. }
  6126. }
  6127. __pyx_L6:;
  6128. /* "gevent/ares.pyx":314
  6129. * self.channel = NULL
  6130. *
  6131. * def set_servers(self, servers=None): # <<<<<<<<<<<<<<
  6132. * if not self.channel:
  6133. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  6134. */
  6135. /* function exit code */
  6136. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6137. goto __pyx_L0;
  6138. __pyx_L1_error:;
  6139. __Pyx_XDECREF(__pyx_t_2);
  6140. __Pyx_XDECREF(__pyx_t_3);
  6141. __Pyx_XDECREF(__pyx_t_4);
  6142. __Pyx_XDECREF(__pyx_t_5);
  6143. __Pyx_XDECREF(__pyx_t_7);
  6144. __Pyx_XDECREF(__pyx_t_12);
  6145. __Pyx_AddTraceback("gevent.ares.channel.set_servers", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6146. __pyx_r = NULL;
  6147. __pyx_L0:;
  6148. __Pyx_XDECREF(__pyx_v_server);
  6149. __Pyx_XDECREF(__pyx_v_servers);
  6150. __Pyx_XGIVEREF(__pyx_r);
  6151. __Pyx_RefNannyFinishContext();
  6152. return __pyx_r;
  6153. }
  6154. /* "gevent/ares.pyx":358
  6155. * # cares.ares_cancel(self.channel)
  6156. *
  6157. * cdef _sock_state_callback(self, int socket, int read, int write): # <<<<<<<<<<<<<<
  6158. * if not self.channel:
  6159. * return
  6160. */
  6161. static PyObject *__pyx_f_6gevent_4ares_7channel__sock_state_callback(struct PyGeventAresChannelObject *__pyx_v_self, int __pyx_v_socket, int __pyx_v_read, int __pyx_v_write) {
  6162. PyObject *__pyx_v_watcher = 0;
  6163. int __pyx_v_events;
  6164. PyObject *__pyx_r = NULL;
  6165. __Pyx_RefNannyDeclarations
  6166. int __pyx_t_1;
  6167. PyObject *__pyx_t_2 = NULL;
  6168. PyObject *__pyx_t_3 = NULL;
  6169. int __pyx_t_4;
  6170. PyObject *__pyx_t_5 = NULL;
  6171. PyObject *__pyx_t_6 = NULL;
  6172. PyObject *__pyx_t_7 = NULL;
  6173. int __pyx_t_8;
  6174. PyObject *__pyx_t_9 = NULL;
  6175. __Pyx_RefNannySetupContext("_sock_state_callback", 0);
  6176. /* "gevent/ares.pyx":359
  6177. *
  6178. * cdef _sock_state_callback(self, int socket, int read, int write):
  6179. * if not self.channel: # <<<<<<<<<<<<<<
  6180. * return
  6181. * cdef object watcher = self._watchers.get(socket)
  6182. */
  6183. __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0);
  6184. if (__pyx_t_1) {
  6185. /* "gevent/ares.pyx":360
  6186. * cdef _sock_state_callback(self, int socket, int read, int write):
  6187. * if not self.channel:
  6188. * return # <<<<<<<<<<<<<<
  6189. * cdef object watcher = self._watchers.get(socket)
  6190. * cdef int events = 0
  6191. */
  6192. __Pyx_XDECREF(__pyx_r);
  6193. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6194. goto __pyx_L0;
  6195. /* "gevent/ares.pyx":359
  6196. *
  6197. * cdef _sock_state_callback(self, int socket, int read, int write):
  6198. * if not self.channel: # <<<<<<<<<<<<<<
  6199. * return
  6200. * cdef object watcher = self._watchers.get(socket)
  6201. */
  6202. }
  6203. /* "gevent/ares.pyx":361
  6204. * if not self.channel:
  6205. * return
  6206. * cdef object watcher = self._watchers.get(socket) # <<<<<<<<<<<<<<
  6207. * cdef int events = 0
  6208. * if read:
  6209. */
  6210. if (unlikely(__pyx_v_self->_watchers == Py_None)) {
  6211. PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "get");
  6212. __PYX_ERR(0, 361, __pyx_L1_error)
  6213. }
  6214. __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 361, __pyx_L1_error)
  6215. __Pyx_GOTREF(__pyx_t_2);
  6216. __pyx_t_3 = __Pyx_PyDict_GetItemDefault(__pyx_v_self->_watchers, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 361, __pyx_L1_error)
  6217. __Pyx_GOTREF(__pyx_t_3);
  6218. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6219. __pyx_v_watcher = __pyx_t_3;
  6220. __pyx_t_3 = 0;
  6221. /* "gevent/ares.pyx":362
  6222. * return
  6223. * cdef object watcher = self._watchers.get(socket)
  6224. * cdef int events = 0 # <<<<<<<<<<<<<<
  6225. * if read:
  6226. * events |= EV_READ
  6227. */
  6228. __pyx_v_events = 0;
  6229. /* "gevent/ares.pyx":363
  6230. * cdef object watcher = self._watchers.get(socket)
  6231. * cdef int events = 0
  6232. * if read: # <<<<<<<<<<<<<<
  6233. * events |= EV_READ
  6234. * if write:
  6235. */
  6236. __pyx_t_1 = (__pyx_v_read != 0);
  6237. if (__pyx_t_1) {
  6238. /* "gevent/ares.pyx":364
  6239. * cdef int events = 0
  6240. * if read:
  6241. * events |= EV_READ # <<<<<<<<<<<<<<
  6242. * if write:
  6243. * events |= EV_WRITE
  6244. */
  6245. __pyx_v_events = (__pyx_v_events | 1);
  6246. /* "gevent/ares.pyx":363
  6247. * cdef object watcher = self._watchers.get(socket)
  6248. * cdef int events = 0
  6249. * if read: # <<<<<<<<<<<<<<
  6250. * events |= EV_READ
  6251. * if write:
  6252. */
  6253. }
  6254. /* "gevent/ares.pyx":365
  6255. * if read:
  6256. * events |= EV_READ
  6257. * if write: # <<<<<<<<<<<<<<
  6258. * events |= EV_WRITE
  6259. * if watcher is None:
  6260. */
  6261. __pyx_t_1 = (__pyx_v_write != 0);
  6262. if (__pyx_t_1) {
  6263. /* "gevent/ares.pyx":366
  6264. * events |= EV_READ
  6265. * if write:
  6266. * events |= EV_WRITE # <<<<<<<<<<<<<<
  6267. * if watcher is None:
  6268. * if not events:
  6269. */
  6270. __pyx_v_events = (__pyx_v_events | 2);
  6271. /* "gevent/ares.pyx":365
  6272. * if read:
  6273. * events |= EV_READ
  6274. * if write: # <<<<<<<<<<<<<<
  6275. * events |= EV_WRITE
  6276. * if watcher is None:
  6277. */
  6278. }
  6279. /* "gevent/ares.pyx":367
  6280. * if write:
  6281. * events |= EV_WRITE
  6282. * if watcher is None: # <<<<<<<<<<<<<<
  6283. * if not events:
  6284. * return
  6285. */
  6286. __pyx_t_1 = (__pyx_v_watcher == Py_None);
  6287. __pyx_t_4 = (__pyx_t_1 != 0);
  6288. if (__pyx_t_4) {
  6289. /* "gevent/ares.pyx":368
  6290. * events |= EV_WRITE
  6291. * if watcher is None:
  6292. * if not events: # <<<<<<<<<<<<<<
  6293. * return
  6294. * watcher = self.loop.io(socket, events)
  6295. */
  6296. __pyx_t_4 = ((!(__pyx_v_events != 0)) != 0);
  6297. if (__pyx_t_4) {
  6298. /* "gevent/ares.pyx":369
  6299. * if watcher is None:
  6300. * if not events:
  6301. * return # <<<<<<<<<<<<<<
  6302. * watcher = self.loop.io(socket, events)
  6303. * self._watchers[socket] = watcher
  6304. */
  6305. __Pyx_XDECREF(__pyx_r);
  6306. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6307. goto __pyx_L0;
  6308. /* "gevent/ares.pyx":368
  6309. * events |= EV_WRITE
  6310. * if watcher is None:
  6311. * if not events: # <<<<<<<<<<<<<<
  6312. * return
  6313. * watcher = self.loop.io(socket, events)
  6314. */
  6315. }
  6316. /* "gevent/ares.pyx":370
  6317. * if not events:
  6318. * return
  6319. * watcher = self.loop.io(socket, events) # <<<<<<<<<<<<<<
  6320. * self._watchers[socket] = watcher
  6321. * elif events:
  6322. */
  6323. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->loop, __pyx_n_s_io); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error)
  6324. __Pyx_GOTREF(__pyx_t_2);
  6325. __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 370, __pyx_L1_error)
  6326. __Pyx_GOTREF(__pyx_t_5);
  6327. __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 370, __pyx_L1_error)
  6328. __Pyx_GOTREF(__pyx_t_6);
  6329. __pyx_t_7 = NULL;
  6330. __pyx_t_8 = 0;
  6331. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  6332. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
  6333. if (likely(__pyx_t_7)) {
  6334. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6335. __Pyx_INCREF(__pyx_t_7);
  6336. __Pyx_INCREF(function);
  6337. __Pyx_DECREF_SET(__pyx_t_2, function);
  6338. __pyx_t_8 = 1;
  6339. }
  6340. }
  6341. #if CYTHON_FAST_PYCALL
  6342. if (PyFunction_Check(__pyx_t_2)) {
  6343. PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6};
  6344. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L1_error)
  6345. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6346. __Pyx_GOTREF(__pyx_t_3);
  6347. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6348. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6349. } else
  6350. #endif
  6351. #if CYTHON_FAST_PYCCALL
  6352. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  6353. PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6};
  6354. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L1_error)
  6355. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6356. __Pyx_GOTREF(__pyx_t_3);
  6357. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6358. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6359. } else
  6360. #endif
  6361. {
  6362. __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 370, __pyx_L1_error)
  6363. __Pyx_GOTREF(__pyx_t_9);
  6364. if (__pyx_t_7) {
  6365. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
  6366. }
  6367. __Pyx_GIVEREF(__pyx_t_5);
  6368. PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_5);
  6369. __Pyx_GIVEREF(__pyx_t_6);
  6370. PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
  6371. __pyx_t_5 = 0;
  6372. __pyx_t_6 = 0;
  6373. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L1_error)
  6374. __Pyx_GOTREF(__pyx_t_3);
  6375. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6376. }
  6377. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6378. __Pyx_DECREF_SET(__pyx_v_watcher, __pyx_t_3);
  6379. __pyx_t_3 = 0;
  6380. /* "gevent/ares.pyx":371
  6381. * return
  6382. * watcher = self.loop.io(socket, events)
  6383. * self._watchers[socket] = watcher # <<<<<<<<<<<<<<
  6384. * elif events:
  6385. * if watcher.events == events:
  6386. */
  6387. if (unlikely(__pyx_v_self->_watchers == Py_None)) {
  6388. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
  6389. __PYX_ERR(0, 371, __pyx_L1_error)
  6390. }
  6391. __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 371, __pyx_L1_error)
  6392. __Pyx_GOTREF(__pyx_t_3);
  6393. if (unlikely(PyDict_SetItem(__pyx_v_self->_watchers, __pyx_t_3, __pyx_v_watcher) < 0)) __PYX_ERR(0, 371, __pyx_L1_error)
  6394. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6395. /* "gevent/ares.pyx":367
  6396. * if write:
  6397. * events |= EV_WRITE
  6398. * if watcher is None: # <<<<<<<<<<<<<<
  6399. * if not events:
  6400. * return
  6401. */
  6402. goto __pyx_L6;
  6403. }
  6404. /* "gevent/ares.pyx":372
  6405. * watcher = self.loop.io(socket, events)
  6406. * self._watchers[socket] = watcher
  6407. * elif events: # <<<<<<<<<<<<<<
  6408. * if watcher.events == events:
  6409. * return
  6410. */
  6411. __pyx_t_4 = (__pyx_v_events != 0);
  6412. if (__pyx_t_4) {
  6413. /* "gevent/ares.pyx":373
  6414. * self._watchers[socket] = watcher
  6415. * elif events:
  6416. * if watcher.events == events: # <<<<<<<<<<<<<<
  6417. * return
  6418. * watcher.stop()
  6419. */
  6420. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_events); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __pyx_L1_error)
  6421. __Pyx_GOTREF(__pyx_t_3);
  6422. __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 373, __pyx_L1_error)
  6423. __Pyx_GOTREF(__pyx_t_2);
  6424. __pyx_t_9 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 373, __pyx_L1_error)
  6425. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6426. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6427. __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 373, __pyx_L1_error)
  6428. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6429. if (__pyx_t_4) {
  6430. /* "gevent/ares.pyx":374
  6431. * elif events:
  6432. * if watcher.events == events:
  6433. * return # <<<<<<<<<<<<<<
  6434. * watcher.stop()
  6435. * watcher.events = events
  6436. */
  6437. __Pyx_XDECREF(__pyx_r);
  6438. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6439. goto __pyx_L0;
  6440. /* "gevent/ares.pyx":373
  6441. * self._watchers[socket] = watcher
  6442. * elif events:
  6443. * if watcher.events == events: # <<<<<<<<<<<<<<
  6444. * return
  6445. * watcher.stop()
  6446. */
  6447. }
  6448. /* "gevent/ares.pyx":375
  6449. * if watcher.events == events:
  6450. * return
  6451. * watcher.stop() # <<<<<<<<<<<<<<
  6452. * watcher.events = events
  6453. * else:
  6454. */
  6455. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 375, __pyx_L1_error)
  6456. __Pyx_GOTREF(__pyx_t_2);
  6457. __pyx_t_3 = NULL;
  6458. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  6459. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  6460. if (likely(__pyx_t_3)) {
  6461. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6462. __Pyx_INCREF(__pyx_t_3);
  6463. __Pyx_INCREF(function);
  6464. __Pyx_DECREF_SET(__pyx_t_2, function);
  6465. }
  6466. }
  6467. if (__pyx_t_3) {
  6468. __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 375, __pyx_L1_error)
  6469. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6470. } else {
  6471. __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 375, __pyx_L1_error)
  6472. }
  6473. __Pyx_GOTREF(__pyx_t_9);
  6474. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6475. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6476. /* "gevent/ares.pyx":376
  6477. * return
  6478. * watcher.stop()
  6479. * watcher.events = events # <<<<<<<<<<<<<<
  6480. * else:
  6481. * watcher.stop()
  6482. */
  6483. __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_events); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 376, __pyx_L1_error)
  6484. __Pyx_GOTREF(__pyx_t_9);
  6485. if (__Pyx_PyObject_SetAttrStr(__pyx_v_watcher, __pyx_n_s_events, __pyx_t_9) < 0) __PYX_ERR(0, 376, __pyx_L1_error)
  6486. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6487. /* "gevent/ares.pyx":372
  6488. * watcher = self.loop.io(socket, events)
  6489. * self._watchers[socket] = watcher
  6490. * elif events: # <<<<<<<<<<<<<<
  6491. * if watcher.events == events:
  6492. * return
  6493. */
  6494. goto __pyx_L6;
  6495. }
  6496. /* "gevent/ares.pyx":378
  6497. * watcher.events = events
  6498. * else:
  6499. * watcher.stop() # <<<<<<<<<<<<<<
  6500. * self._watchers.pop(socket, None)
  6501. * if not self._watchers:
  6502. */
  6503. /*else*/ {
  6504. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error)
  6505. __Pyx_GOTREF(__pyx_t_2);
  6506. __pyx_t_3 = NULL;
  6507. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  6508. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
  6509. if (likely(__pyx_t_3)) {
  6510. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6511. __Pyx_INCREF(__pyx_t_3);
  6512. __Pyx_INCREF(function);
  6513. __Pyx_DECREF_SET(__pyx_t_2, function);
  6514. }
  6515. }
  6516. if (__pyx_t_3) {
  6517. __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 378, __pyx_L1_error)
  6518. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6519. } else {
  6520. __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 378, __pyx_L1_error)
  6521. }
  6522. __Pyx_GOTREF(__pyx_t_9);
  6523. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6524. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6525. /* "gevent/ares.pyx":379
  6526. * else:
  6527. * watcher.stop()
  6528. * self._watchers.pop(socket, None) # <<<<<<<<<<<<<<
  6529. * if not self._watchers:
  6530. * self._timer.stop()
  6531. */
  6532. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_watchers, __pyx_n_s_pop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 379, __pyx_L1_error)
  6533. __Pyx_GOTREF(__pyx_t_2);
  6534. __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_socket); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 379, __pyx_L1_error)
  6535. __Pyx_GOTREF(__pyx_t_3);
  6536. __pyx_t_6 = NULL;
  6537. __pyx_t_8 = 0;
  6538. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  6539. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
  6540. if (likely(__pyx_t_6)) {
  6541. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6542. __Pyx_INCREF(__pyx_t_6);
  6543. __Pyx_INCREF(function);
  6544. __Pyx_DECREF_SET(__pyx_t_2, function);
  6545. __pyx_t_8 = 1;
  6546. }
  6547. }
  6548. #if CYTHON_FAST_PYCALL
  6549. if (PyFunction_Check(__pyx_t_2)) {
  6550. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, Py_None};
  6551. __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 379, __pyx_L1_error)
  6552. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  6553. __Pyx_GOTREF(__pyx_t_9);
  6554. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6555. } else
  6556. #endif
  6557. #if CYTHON_FAST_PYCCALL
  6558. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  6559. PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, Py_None};
  6560. __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 379, __pyx_L1_error)
  6561. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  6562. __Pyx_GOTREF(__pyx_t_9);
  6563. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6564. } else
  6565. #endif
  6566. {
  6567. __pyx_t_5 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 379, __pyx_L1_error)
  6568. __Pyx_GOTREF(__pyx_t_5);
  6569. if (__pyx_t_6) {
  6570. __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
  6571. }
  6572. __Pyx_GIVEREF(__pyx_t_3);
  6573. PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_t_3);
  6574. __Pyx_INCREF(Py_None);
  6575. __Pyx_GIVEREF(Py_None);
  6576. PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, Py_None);
  6577. __pyx_t_3 = 0;
  6578. __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 379, __pyx_L1_error)
  6579. __Pyx_GOTREF(__pyx_t_9);
  6580. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6581. }
  6582. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6583. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6584. /* "gevent/ares.pyx":380
  6585. * watcher.stop()
  6586. * self._watchers.pop(socket, None)
  6587. * if not self._watchers: # <<<<<<<<<<<<<<
  6588. * self._timer.stop()
  6589. * return
  6590. */
  6591. __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_self->_watchers); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 380, __pyx_L1_error)
  6592. __pyx_t_1 = ((!__pyx_t_4) != 0);
  6593. if (__pyx_t_1) {
  6594. /* "gevent/ares.pyx":381
  6595. * self._watchers.pop(socket, None)
  6596. * if not self._watchers:
  6597. * self._timer.stop() # <<<<<<<<<<<<<<
  6598. * return
  6599. * watcher.start(self._process_fd, watcher, pass_events=True)
  6600. */
  6601. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 381, __pyx_L1_error)
  6602. __Pyx_GOTREF(__pyx_t_2);
  6603. __pyx_t_5 = NULL;
  6604. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  6605. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
  6606. if (likely(__pyx_t_5)) {
  6607. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6608. __Pyx_INCREF(__pyx_t_5);
  6609. __Pyx_INCREF(function);
  6610. __Pyx_DECREF_SET(__pyx_t_2, function);
  6611. }
  6612. }
  6613. if (__pyx_t_5) {
  6614. __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 381, __pyx_L1_error)
  6615. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6616. } else {
  6617. __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 381, __pyx_L1_error)
  6618. }
  6619. __Pyx_GOTREF(__pyx_t_9);
  6620. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6621. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6622. /* "gevent/ares.pyx":380
  6623. * watcher.stop()
  6624. * self._watchers.pop(socket, None)
  6625. * if not self._watchers: # <<<<<<<<<<<<<<
  6626. * self._timer.stop()
  6627. * return
  6628. */
  6629. }
  6630. /* "gevent/ares.pyx":382
  6631. * if not self._watchers:
  6632. * self._timer.stop()
  6633. * return # <<<<<<<<<<<<<<
  6634. * watcher.start(self._process_fd, watcher, pass_events=True)
  6635. * self._timer.again(self._on_timer)
  6636. */
  6637. __Pyx_XDECREF(__pyx_r);
  6638. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6639. goto __pyx_L0;
  6640. }
  6641. __pyx_L6:;
  6642. /* "gevent/ares.pyx":383
  6643. * self._timer.stop()
  6644. * return
  6645. * watcher.start(self._process_fd, watcher, pass_events=True) # <<<<<<<<<<<<<<
  6646. * self._timer.again(self._on_timer)
  6647. *
  6648. */
  6649. __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 383, __pyx_L1_error)
  6650. __Pyx_GOTREF(__pyx_t_9);
  6651. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_process_fd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error)
  6652. __Pyx_GOTREF(__pyx_t_2);
  6653. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 383, __pyx_L1_error)
  6654. __Pyx_GOTREF(__pyx_t_5);
  6655. __Pyx_GIVEREF(__pyx_t_2);
  6656. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  6657. __Pyx_INCREF(__pyx_v_watcher);
  6658. __Pyx_GIVEREF(__pyx_v_watcher);
  6659. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_watcher);
  6660. __pyx_t_2 = 0;
  6661. __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 383, __pyx_L1_error)
  6662. __Pyx_GOTREF(__pyx_t_2);
  6663. if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_pass_events, Py_True) < 0) __PYX_ERR(0, 383, __pyx_L1_error)
  6664. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 383, __pyx_L1_error)
  6665. __Pyx_GOTREF(__pyx_t_3);
  6666. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6667. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6668. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6669. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6670. /* "gevent/ares.pyx":384
  6671. * return
  6672. * watcher.start(self._process_fd, watcher, pass_events=True)
  6673. * self._timer.again(self._on_timer) # <<<<<<<<<<<<<<
  6674. *
  6675. * def _on_timer(self):
  6676. */
  6677. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_timer, __pyx_n_s_again); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 384, __pyx_L1_error)
  6678. __Pyx_GOTREF(__pyx_t_2);
  6679. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_on_timer); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 384, __pyx_L1_error)
  6680. __Pyx_GOTREF(__pyx_t_5);
  6681. __pyx_t_9 = NULL;
  6682. if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
  6683. __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
  6684. if (likely(__pyx_t_9)) {
  6685. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  6686. __Pyx_INCREF(__pyx_t_9);
  6687. __Pyx_INCREF(function);
  6688. __Pyx_DECREF_SET(__pyx_t_2, function);
  6689. }
  6690. }
  6691. if (!__pyx_t_9) {
  6692. __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 384, __pyx_L1_error)
  6693. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6694. __Pyx_GOTREF(__pyx_t_3);
  6695. } else {
  6696. #if CYTHON_FAST_PYCALL
  6697. if (PyFunction_Check(__pyx_t_2)) {
  6698. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_5};
  6699. __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 384, __pyx_L1_error)
  6700. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  6701. __Pyx_GOTREF(__pyx_t_3);
  6702. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6703. } else
  6704. #endif
  6705. #if CYTHON_FAST_PYCCALL
  6706. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  6707. PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_5};
  6708. __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 384, __pyx_L1_error)
  6709. __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  6710. __Pyx_GOTREF(__pyx_t_3);
  6711. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6712. } else
  6713. #endif
  6714. {
  6715. __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 384, __pyx_L1_error)
  6716. __Pyx_GOTREF(__pyx_t_6);
  6717. __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL;
  6718. __Pyx_GIVEREF(__pyx_t_5);
  6719. PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5);
  6720. __pyx_t_5 = 0;
  6721. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 384, __pyx_L1_error)
  6722. __Pyx_GOTREF(__pyx_t_3);
  6723. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6724. }
  6725. }
  6726. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6727. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6728. /* "gevent/ares.pyx":358
  6729. * # cares.ares_cancel(self.channel)
  6730. *
  6731. * cdef _sock_state_callback(self, int socket, int read, int write): # <<<<<<<<<<<<<<
  6732. * if not self.channel:
  6733. * return
  6734. */
  6735. /* function exit code */
  6736. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6737. goto __pyx_L0;
  6738. __pyx_L1_error:;
  6739. __Pyx_XDECREF(__pyx_t_2);
  6740. __Pyx_XDECREF(__pyx_t_3);
  6741. __Pyx_XDECREF(__pyx_t_5);
  6742. __Pyx_XDECREF(__pyx_t_6);
  6743. __Pyx_XDECREF(__pyx_t_7);
  6744. __Pyx_XDECREF(__pyx_t_9);
  6745. __Pyx_AddTraceback("gevent.ares.channel._sock_state_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6746. __pyx_r = 0;
  6747. __pyx_L0:;
  6748. __Pyx_XDECREF(__pyx_v_watcher);
  6749. __Pyx_XGIVEREF(__pyx_r);
  6750. __Pyx_RefNannyFinishContext();
  6751. return __pyx_r;
  6752. }
  6753. /* "gevent/ares.pyx":386
  6754. * self._timer.again(self._on_timer)
  6755. *
  6756. * def _on_timer(self): # <<<<<<<<<<<<<<
  6757. * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD)
  6758. *
  6759. */
  6760. /* Python wrapper */
  6761. static PyObject *__pyx_pw_6gevent_4ares_7channel_11_on_timer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  6762. static PyObject *__pyx_pw_6gevent_4ares_7channel_11_on_timer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  6763. PyObject *__pyx_r = 0;
  6764. __Pyx_RefNannyDeclarations
  6765. __Pyx_RefNannySetupContext("_on_timer (wrapper)", 0);
  6766. __pyx_r = __pyx_pf_6gevent_4ares_7channel_10_on_timer(((struct PyGeventAresChannelObject *)__pyx_v_self));
  6767. /* function exit code */
  6768. __Pyx_RefNannyFinishContext();
  6769. return __pyx_r;
  6770. }
  6771. static PyObject *__pyx_pf_6gevent_4ares_7channel_10_on_timer(struct PyGeventAresChannelObject *__pyx_v_self) {
  6772. PyObject *__pyx_r = NULL;
  6773. __Pyx_RefNannyDeclarations
  6774. __Pyx_RefNannySetupContext("_on_timer", 0);
  6775. /* "gevent/ares.pyx":387
  6776. *
  6777. * def _on_timer(self):
  6778. * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD) # <<<<<<<<<<<<<<
  6779. *
  6780. * def _process_fd(self, int events, object watcher):
  6781. */
  6782. ares_process_fd(__pyx_v_self->channel, ARES_SOCKET_BAD, ARES_SOCKET_BAD);
  6783. /* "gevent/ares.pyx":386
  6784. * self._timer.again(self._on_timer)
  6785. *
  6786. * def _on_timer(self): # <<<<<<<<<<<<<<
  6787. * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD)
  6788. *
  6789. */
  6790. /* function exit code */
  6791. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6792. __Pyx_XGIVEREF(__pyx_r);
  6793. __Pyx_RefNannyFinishContext();
  6794. return __pyx_r;
  6795. }
  6796. /* "gevent/ares.pyx":389
  6797. * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD)
  6798. *
  6799. * def _process_fd(self, int events, object watcher): # <<<<<<<<<<<<<<
  6800. * if not self.channel:
  6801. * return
  6802. */
  6803. /* Python wrapper */
  6804. static PyObject *__pyx_pw_6gevent_4ares_7channel_13_process_fd(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  6805. static PyObject *__pyx_pw_6gevent_4ares_7channel_13_process_fd(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  6806. int __pyx_v_events;
  6807. PyObject *__pyx_v_watcher = 0;
  6808. PyObject *__pyx_r = 0;
  6809. __Pyx_RefNannyDeclarations
  6810. __Pyx_RefNannySetupContext("_process_fd (wrapper)", 0);
  6811. {
  6812. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_events,&__pyx_n_s_watcher,0};
  6813. PyObject* values[2] = {0,0};
  6814. if (unlikely(__pyx_kwds)) {
  6815. Py_ssize_t kw_args;
  6816. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  6817. switch (pos_args) {
  6818. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6819. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6820. case 0: break;
  6821. default: goto __pyx_L5_argtuple_error;
  6822. }
  6823. kw_args = PyDict_Size(__pyx_kwds);
  6824. switch (pos_args) {
  6825. case 0:
  6826. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_events)) != 0)) kw_args--;
  6827. else goto __pyx_L5_argtuple_error;
  6828. case 1:
  6829. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_watcher)) != 0)) kw_args--;
  6830. else {
  6831. __Pyx_RaiseArgtupleInvalid("_process_fd", 1, 2, 2, 1); __PYX_ERR(0, 389, __pyx_L3_error)
  6832. }
  6833. }
  6834. if (unlikely(kw_args > 0)) {
  6835. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_process_fd") < 0)) __PYX_ERR(0, 389, __pyx_L3_error)
  6836. }
  6837. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  6838. goto __pyx_L5_argtuple_error;
  6839. } else {
  6840. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  6841. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  6842. }
  6843. __pyx_v_events = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_events == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 389, __pyx_L3_error)
  6844. __pyx_v_watcher = values[1];
  6845. }
  6846. goto __pyx_L4_argument_unpacking_done;
  6847. __pyx_L5_argtuple_error:;
  6848. __Pyx_RaiseArgtupleInvalid("_process_fd", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 389, __pyx_L3_error)
  6849. __pyx_L3_error:;
  6850. __Pyx_AddTraceback("gevent.ares.channel._process_fd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6851. __Pyx_RefNannyFinishContext();
  6852. return NULL;
  6853. __pyx_L4_argument_unpacking_done:;
  6854. __pyx_r = __pyx_pf_6gevent_4ares_7channel_12_process_fd(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_events, __pyx_v_watcher);
  6855. /* function exit code */
  6856. __Pyx_RefNannyFinishContext();
  6857. return __pyx_r;
  6858. }
  6859. static PyObject *__pyx_pf_6gevent_4ares_7channel_12_process_fd(struct PyGeventAresChannelObject *__pyx_v_self, int __pyx_v_events, PyObject *__pyx_v_watcher) {
  6860. int __pyx_v_read_fd;
  6861. int __pyx_v_write_fd;
  6862. PyObject *__pyx_r = NULL;
  6863. __Pyx_RefNannyDeclarations
  6864. int __pyx_t_1;
  6865. PyObject *__pyx_t_2 = NULL;
  6866. int __pyx_t_3;
  6867. __Pyx_RefNannySetupContext("_process_fd", 0);
  6868. /* "gevent/ares.pyx":390
  6869. *
  6870. * def _process_fd(self, int events, object watcher):
  6871. * if not self.channel: # <<<<<<<<<<<<<<
  6872. * return
  6873. * cdef int read_fd = watcher.fd
  6874. */
  6875. __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0);
  6876. if (__pyx_t_1) {
  6877. /* "gevent/ares.pyx":391
  6878. * def _process_fd(self, int events, object watcher):
  6879. * if not self.channel:
  6880. * return # <<<<<<<<<<<<<<
  6881. * cdef int read_fd = watcher.fd
  6882. * cdef int write_fd = read_fd
  6883. */
  6884. __Pyx_XDECREF(__pyx_r);
  6885. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6886. goto __pyx_L0;
  6887. /* "gevent/ares.pyx":390
  6888. *
  6889. * def _process_fd(self, int events, object watcher):
  6890. * if not self.channel: # <<<<<<<<<<<<<<
  6891. * return
  6892. * cdef int read_fd = watcher.fd
  6893. */
  6894. }
  6895. /* "gevent/ares.pyx":392
  6896. * if not self.channel:
  6897. * return
  6898. * cdef int read_fd = watcher.fd # <<<<<<<<<<<<<<
  6899. * cdef int write_fd = read_fd
  6900. * if not (events & EV_READ):
  6901. */
  6902. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_watcher, __pyx_n_s_fd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 392, __pyx_L1_error)
  6903. __Pyx_GOTREF(__pyx_t_2);
  6904. __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 392, __pyx_L1_error)
  6905. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6906. __pyx_v_read_fd = __pyx_t_3;
  6907. /* "gevent/ares.pyx":393
  6908. * return
  6909. * cdef int read_fd = watcher.fd
  6910. * cdef int write_fd = read_fd # <<<<<<<<<<<<<<
  6911. * if not (events & EV_READ):
  6912. * read_fd = cares.ARES_SOCKET_BAD
  6913. */
  6914. __pyx_v_write_fd = __pyx_v_read_fd;
  6915. /* "gevent/ares.pyx":394
  6916. * cdef int read_fd = watcher.fd
  6917. * cdef int write_fd = read_fd
  6918. * if not (events & EV_READ): # <<<<<<<<<<<<<<
  6919. * read_fd = cares.ARES_SOCKET_BAD
  6920. * if not (events & EV_WRITE):
  6921. */
  6922. __pyx_t_1 = ((!((__pyx_v_events & 1) != 0)) != 0);
  6923. if (__pyx_t_1) {
  6924. /* "gevent/ares.pyx":395
  6925. * cdef int write_fd = read_fd
  6926. * if not (events & EV_READ):
  6927. * read_fd = cares.ARES_SOCKET_BAD # <<<<<<<<<<<<<<
  6928. * if not (events & EV_WRITE):
  6929. * write_fd = cares.ARES_SOCKET_BAD
  6930. */
  6931. __pyx_v_read_fd = ARES_SOCKET_BAD;
  6932. /* "gevent/ares.pyx":394
  6933. * cdef int read_fd = watcher.fd
  6934. * cdef int write_fd = read_fd
  6935. * if not (events & EV_READ): # <<<<<<<<<<<<<<
  6936. * read_fd = cares.ARES_SOCKET_BAD
  6937. * if not (events & EV_WRITE):
  6938. */
  6939. }
  6940. /* "gevent/ares.pyx":396
  6941. * if not (events & EV_READ):
  6942. * read_fd = cares.ARES_SOCKET_BAD
  6943. * if not (events & EV_WRITE): # <<<<<<<<<<<<<<
  6944. * write_fd = cares.ARES_SOCKET_BAD
  6945. * cares.ares_process_fd(self.channel, read_fd, write_fd)
  6946. */
  6947. __pyx_t_1 = ((!((__pyx_v_events & 2) != 0)) != 0);
  6948. if (__pyx_t_1) {
  6949. /* "gevent/ares.pyx":397
  6950. * read_fd = cares.ARES_SOCKET_BAD
  6951. * if not (events & EV_WRITE):
  6952. * write_fd = cares.ARES_SOCKET_BAD # <<<<<<<<<<<<<<
  6953. * cares.ares_process_fd(self.channel, read_fd, write_fd)
  6954. *
  6955. */
  6956. __pyx_v_write_fd = ARES_SOCKET_BAD;
  6957. /* "gevent/ares.pyx":396
  6958. * if not (events & EV_READ):
  6959. * read_fd = cares.ARES_SOCKET_BAD
  6960. * if not (events & EV_WRITE): # <<<<<<<<<<<<<<
  6961. * write_fd = cares.ARES_SOCKET_BAD
  6962. * cares.ares_process_fd(self.channel, read_fd, write_fd)
  6963. */
  6964. }
  6965. /* "gevent/ares.pyx":398
  6966. * if not (events & EV_WRITE):
  6967. * write_fd = cares.ARES_SOCKET_BAD
  6968. * cares.ares_process_fd(self.channel, read_fd, write_fd) # <<<<<<<<<<<<<<
  6969. *
  6970. * def gethostbyname(self, object callback, char* name, int family=AF_INET):
  6971. */
  6972. ares_process_fd(__pyx_v_self->channel, __pyx_v_read_fd, __pyx_v_write_fd);
  6973. /* "gevent/ares.pyx":389
  6974. * cares.ares_process_fd(self.channel, cares.ARES_SOCKET_BAD, cares.ARES_SOCKET_BAD)
  6975. *
  6976. * def _process_fd(self, int events, object watcher): # <<<<<<<<<<<<<<
  6977. * if not self.channel:
  6978. * return
  6979. */
  6980. /* function exit code */
  6981. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6982. goto __pyx_L0;
  6983. __pyx_L1_error:;
  6984. __Pyx_XDECREF(__pyx_t_2);
  6985. __Pyx_AddTraceback("gevent.ares.channel._process_fd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6986. __pyx_r = NULL;
  6987. __pyx_L0:;
  6988. __Pyx_XGIVEREF(__pyx_r);
  6989. __Pyx_RefNannyFinishContext();
  6990. return __pyx_r;
  6991. }
  6992. /* "gevent/ares.pyx":400
  6993. * cares.ares_process_fd(self.channel, read_fd, write_fd)
  6994. *
  6995. * def gethostbyname(self, object callback, char* name, int family=AF_INET): # <<<<<<<<<<<<<<
  6996. * if not self.channel:
  6997. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  6998. */
  6999. /* Python wrapper */
  7000. static PyObject *__pyx_pw_6gevent_4ares_7channel_15gethostbyname(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  7001. static PyObject *__pyx_pw_6gevent_4ares_7channel_15gethostbyname(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  7002. PyObject *__pyx_v_callback = 0;
  7003. char *__pyx_v_name;
  7004. int __pyx_v_family;
  7005. PyObject *__pyx_r = 0;
  7006. __Pyx_RefNannyDeclarations
  7007. __Pyx_RefNannySetupContext("gethostbyname (wrapper)", 0);
  7008. {
  7009. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_name_2,&__pyx_n_s_family,0};
  7010. PyObject* values[3] = {0,0,0};
  7011. if (unlikely(__pyx_kwds)) {
  7012. Py_ssize_t kw_args;
  7013. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  7014. switch (pos_args) {
  7015. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  7016. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7017. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7018. case 0: break;
  7019. default: goto __pyx_L5_argtuple_error;
  7020. }
  7021. kw_args = PyDict_Size(__pyx_kwds);
  7022. switch (pos_args) {
  7023. case 0:
  7024. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
  7025. else goto __pyx_L5_argtuple_error;
  7026. case 1:
  7027. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name_2)) != 0)) kw_args--;
  7028. else {
  7029. __Pyx_RaiseArgtupleInvalid("gethostbyname", 0, 2, 3, 1); __PYX_ERR(0, 400, __pyx_L3_error)
  7030. }
  7031. case 2:
  7032. if (kw_args > 0) {
  7033. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_family);
  7034. if (value) { values[2] = value; kw_args--; }
  7035. }
  7036. }
  7037. if (unlikely(kw_args > 0)) {
  7038. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "gethostbyname") < 0)) __PYX_ERR(0, 400, __pyx_L3_error)
  7039. }
  7040. } else {
  7041. switch (PyTuple_GET_SIZE(__pyx_args)) {
  7042. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  7043. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7044. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7045. break;
  7046. default: goto __pyx_L5_argtuple_error;
  7047. }
  7048. }
  7049. __pyx_v_callback = values[0];
  7050. __pyx_v_name = __Pyx_PyObject_AsString(values[1]); if (unlikely((!__pyx_v_name) && PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L3_error)
  7051. if (values[2]) {
  7052. __pyx_v_family = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_family == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 400, __pyx_L3_error)
  7053. } else {
  7054. __pyx_v_family = __pyx_k__5;
  7055. }
  7056. }
  7057. goto __pyx_L4_argument_unpacking_done;
  7058. __pyx_L5_argtuple_error:;
  7059. __Pyx_RaiseArgtupleInvalid("gethostbyname", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 400, __pyx_L3_error)
  7060. __pyx_L3_error:;
  7061. __Pyx_AddTraceback("gevent.ares.channel.gethostbyname", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7062. __Pyx_RefNannyFinishContext();
  7063. return NULL;
  7064. __pyx_L4_argument_unpacking_done:;
  7065. __pyx_r = __pyx_pf_6gevent_4ares_7channel_14gethostbyname(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_name, __pyx_v_family);
  7066. /* function exit code */
  7067. __Pyx_RefNannyFinishContext();
  7068. return __pyx_r;
  7069. }
  7070. static PyObject *__pyx_pf_6gevent_4ares_7channel_14gethostbyname(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_name, int __pyx_v_family) {
  7071. PyObject *__pyx_v_arg = 0;
  7072. PyObject *__pyx_r = NULL;
  7073. __Pyx_RefNannyDeclarations
  7074. int __pyx_t_1;
  7075. PyObject *__pyx_t_2 = NULL;
  7076. PyObject *__pyx_t_3 = NULL;
  7077. PyObject *__pyx_t_4 = NULL;
  7078. PyObject *__pyx_t_5 = NULL;
  7079. int __pyx_t_6;
  7080. PyObject *__pyx_t_7 = NULL;
  7081. __Pyx_RefNannySetupContext("gethostbyname", 0);
  7082. /* "gevent/ares.pyx":401
  7083. *
  7084. * def gethostbyname(self, object callback, char* name, int family=AF_INET):
  7085. * if not self.channel: # <<<<<<<<<<<<<<
  7086. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  7087. * # note that for file lookups still AF_INET can be returned for AF_INET6 request
  7088. */
  7089. __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0);
  7090. if (__pyx_t_1) {
  7091. /* "gevent/ares.pyx":402
  7092. * def gethostbyname(self, object callback, char* name, int family=AF_INET):
  7093. * if not self.channel:
  7094. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<<
  7095. * # note that for file lookups still AF_INET can be returned for AF_INET6 request
  7096. * cdef object arg = (self, callback)
  7097. */
  7098. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 402, __pyx_L1_error)
  7099. __Pyx_GOTREF(__pyx_t_3);
  7100. __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 402, __pyx_L1_error)
  7101. __Pyx_GOTREF(__pyx_t_4);
  7102. __pyx_t_5 = NULL;
  7103. __pyx_t_6 = 0;
  7104. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  7105. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
  7106. if (likely(__pyx_t_5)) {
  7107. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  7108. __Pyx_INCREF(__pyx_t_5);
  7109. __Pyx_INCREF(function);
  7110. __Pyx_DECREF_SET(__pyx_t_3, function);
  7111. __pyx_t_6 = 1;
  7112. }
  7113. }
  7114. #if CYTHON_FAST_PYCALL
  7115. if (PyFunction_Check(__pyx_t_3)) {
  7116. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
  7117. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error)
  7118. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7119. __Pyx_GOTREF(__pyx_t_2);
  7120. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7121. } else
  7122. #endif
  7123. #if CYTHON_FAST_PYCCALL
  7124. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  7125. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
  7126. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error)
  7127. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7128. __Pyx_GOTREF(__pyx_t_2);
  7129. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7130. } else
  7131. #endif
  7132. {
  7133. __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 402, __pyx_L1_error)
  7134. __Pyx_GOTREF(__pyx_t_7);
  7135. if (__pyx_t_5) {
  7136. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  7137. }
  7138. __Pyx_GIVEREF(__pyx_t_4);
  7139. PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4);
  7140. __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr);
  7141. __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr);
  7142. PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr);
  7143. __pyx_t_4 = 0;
  7144. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 402, __pyx_L1_error)
  7145. __Pyx_GOTREF(__pyx_t_2);
  7146. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7147. }
  7148. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7149. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  7150. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7151. __PYX_ERR(0, 402, __pyx_L1_error)
  7152. /* "gevent/ares.pyx":401
  7153. *
  7154. * def gethostbyname(self, object callback, char* name, int family=AF_INET):
  7155. * if not self.channel: # <<<<<<<<<<<<<<
  7156. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  7157. * # note that for file lookups still AF_INET can be returned for AF_INET6 request
  7158. */
  7159. }
  7160. /* "gevent/ares.pyx":404
  7161. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  7162. * # note that for file lookups still AF_INET can be returned for AF_INET6 request
  7163. * cdef object arg = (self, callback) # <<<<<<<<<<<<<<
  7164. * Py_INCREF(<PyObjectPtr>arg)
  7165. * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg)
  7166. */
  7167. __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 404, __pyx_L1_error)
  7168. __Pyx_GOTREF(__pyx_t_2);
  7169. __Pyx_INCREF(((PyObject *)__pyx_v_self));
  7170. __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  7171. PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  7172. __Pyx_INCREF(__pyx_v_callback);
  7173. __Pyx_GIVEREF(__pyx_v_callback);
  7174. PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_callback);
  7175. __pyx_v_arg = __pyx_t_2;
  7176. __pyx_t_2 = 0;
  7177. /* "gevent/ares.pyx":405
  7178. * # note that for file lookups still AF_INET can be returned for AF_INET6 request
  7179. * cdef object arg = (self, callback)
  7180. * Py_INCREF(<PyObjectPtr>arg) # <<<<<<<<<<<<<<
  7181. * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg)
  7182. *
  7183. */
  7184. Py_INCREF(((PyObject*)__pyx_v_arg));
  7185. /* "gevent/ares.pyx":406
  7186. * cdef object arg = (self, callback)
  7187. * Py_INCREF(<PyObjectPtr>arg)
  7188. * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg) # <<<<<<<<<<<<<<
  7189. *
  7190. * def gethostbyaddr(self, object callback, char* addr):
  7191. */
  7192. ares_gethostbyname(__pyx_v_self->channel, __pyx_v_name, __pyx_v_family, ((void *)__pyx_f_6gevent_4ares_gevent_ares_host_callback), ((void *)__pyx_v_arg));
  7193. /* "gevent/ares.pyx":400
  7194. * cares.ares_process_fd(self.channel, read_fd, write_fd)
  7195. *
  7196. * def gethostbyname(self, object callback, char* name, int family=AF_INET): # <<<<<<<<<<<<<<
  7197. * if not self.channel:
  7198. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  7199. */
  7200. /* function exit code */
  7201. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7202. goto __pyx_L0;
  7203. __pyx_L1_error:;
  7204. __Pyx_XDECREF(__pyx_t_2);
  7205. __Pyx_XDECREF(__pyx_t_3);
  7206. __Pyx_XDECREF(__pyx_t_4);
  7207. __Pyx_XDECREF(__pyx_t_5);
  7208. __Pyx_XDECREF(__pyx_t_7);
  7209. __Pyx_AddTraceback("gevent.ares.channel.gethostbyname", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7210. __pyx_r = NULL;
  7211. __pyx_L0:;
  7212. __Pyx_XDECREF(__pyx_v_arg);
  7213. __Pyx_XGIVEREF(__pyx_r);
  7214. __Pyx_RefNannyFinishContext();
  7215. return __pyx_r;
  7216. }
  7217. /* "gevent/ares.pyx":408
  7218. * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg)
  7219. *
  7220. * def gethostbyaddr(self, object callback, char* addr): # <<<<<<<<<<<<<<
  7221. * if not self.channel:
  7222. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  7223. */
  7224. /* Python wrapper */
  7225. static PyObject *__pyx_pw_6gevent_4ares_7channel_17gethostbyaddr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  7226. static PyObject *__pyx_pw_6gevent_4ares_7channel_17gethostbyaddr(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  7227. PyObject *__pyx_v_callback = 0;
  7228. char *__pyx_v_addr;
  7229. PyObject *__pyx_r = 0;
  7230. __Pyx_RefNannyDeclarations
  7231. __Pyx_RefNannySetupContext("gethostbyaddr (wrapper)", 0);
  7232. {
  7233. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_addr,0};
  7234. PyObject* values[2] = {0,0};
  7235. if (unlikely(__pyx_kwds)) {
  7236. Py_ssize_t kw_args;
  7237. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  7238. switch (pos_args) {
  7239. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7240. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7241. case 0: break;
  7242. default: goto __pyx_L5_argtuple_error;
  7243. }
  7244. kw_args = PyDict_Size(__pyx_kwds);
  7245. switch (pos_args) {
  7246. case 0:
  7247. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
  7248. else goto __pyx_L5_argtuple_error;
  7249. case 1:
  7250. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_addr)) != 0)) kw_args--;
  7251. else {
  7252. __Pyx_RaiseArgtupleInvalid("gethostbyaddr", 1, 2, 2, 1); __PYX_ERR(0, 408, __pyx_L3_error)
  7253. }
  7254. }
  7255. if (unlikely(kw_args > 0)) {
  7256. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "gethostbyaddr") < 0)) __PYX_ERR(0, 408, __pyx_L3_error)
  7257. }
  7258. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  7259. goto __pyx_L5_argtuple_error;
  7260. } else {
  7261. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  7262. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  7263. }
  7264. __pyx_v_callback = values[0];
  7265. __pyx_v_addr = __Pyx_PyObject_AsString(values[1]); if (unlikely((!__pyx_v_addr) && PyErr_Occurred())) __PYX_ERR(0, 408, __pyx_L3_error)
  7266. }
  7267. goto __pyx_L4_argument_unpacking_done;
  7268. __pyx_L5_argtuple_error:;
  7269. __Pyx_RaiseArgtupleInvalid("gethostbyaddr", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 408, __pyx_L3_error)
  7270. __pyx_L3_error:;
  7271. __Pyx_AddTraceback("gevent.ares.channel.gethostbyaddr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7272. __Pyx_RefNannyFinishContext();
  7273. return NULL;
  7274. __pyx_L4_argument_unpacking_done:;
  7275. __pyx_r = __pyx_pf_6gevent_4ares_7channel_16gethostbyaddr(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_addr);
  7276. /* function exit code */
  7277. __Pyx_RefNannyFinishContext();
  7278. return __pyx_r;
  7279. }
  7280. static PyObject *__pyx_pf_6gevent_4ares_7channel_16gethostbyaddr(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, char *__pyx_v_addr) {
  7281. char __pyx_v_addr_packed[16];
  7282. int __pyx_v_family;
  7283. int __pyx_v_length;
  7284. PyObject *__pyx_v_arg = 0;
  7285. PyObject *__pyx_r = NULL;
  7286. __Pyx_RefNannyDeclarations
  7287. int __pyx_t_1;
  7288. PyObject *__pyx_t_2 = NULL;
  7289. PyObject *__pyx_t_3 = NULL;
  7290. PyObject *__pyx_t_4 = NULL;
  7291. PyObject *__pyx_t_5 = NULL;
  7292. int __pyx_t_6;
  7293. PyObject *__pyx_t_7 = NULL;
  7294. __Pyx_RefNannySetupContext("gethostbyaddr", 0);
  7295. /* "gevent/ares.pyx":409
  7296. *
  7297. * def gethostbyaddr(self, object callback, char* addr):
  7298. * if not self.channel: # <<<<<<<<<<<<<<
  7299. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  7300. * # will guess the family
  7301. */
  7302. __pyx_t_1 = ((!(__pyx_v_self->channel != 0)) != 0);
  7303. if (__pyx_t_1) {
  7304. /* "gevent/ares.pyx":410
  7305. * def gethostbyaddr(self, object callback, char* addr):
  7306. * if not self.channel:
  7307. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<<
  7308. * # will guess the family
  7309. * cdef char addr_packed[16]
  7310. */
  7311. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 410, __pyx_L1_error)
  7312. __Pyx_GOTREF(__pyx_t_3);
  7313. __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 410, __pyx_L1_error)
  7314. __Pyx_GOTREF(__pyx_t_4);
  7315. __pyx_t_5 = NULL;
  7316. __pyx_t_6 = 0;
  7317. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  7318. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
  7319. if (likely(__pyx_t_5)) {
  7320. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  7321. __Pyx_INCREF(__pyx_t_5);
  7322. __Pyx_INCREF(function);
  7323. __Pyx_DECREF_SET(__pyx_t_3, function);
  7324. __pyx_t_6 = 1;
  7325. }
  7326. }
  7327. #if CYTHON_FAST_PYCALL
  7328. if (PyFunction_Check(__pyx_t_3)) {
  7329. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
  7330. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 410, __pyx_L1_error)
  7331. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7332. __Pyx_GOTREF(__pyx_t_2);
  7333. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7334. } else
  7335. #endif
  7336. #if CYTHON_FAST_PYCCALL
  7337. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  7338. PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
  7339. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 410, __pyx_L1_error)
  7340. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7341. __Pyx_GOTREF(__pyx_t_2);
  7342. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7343. } else
  7344. #endif
  7345. {
  7346. __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 410, __pyx_L1_error)
  7347. __Pyx_GOTREF(__pyx_t_7);
  7348. if (__pyx_t_5) {
  7349. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  7350. }
  7351. __Pyx_GIVEREF(__pyx_t_4);
  7352. PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_4);
  7353. __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr);
  7354. __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr);
  7355. PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr);
  7356. __pyx_t_4 = 0;
  7357. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 410, __pyx_L1_error)
  7358. __Pyx_GOTREF(__pyx_t_2);
  7359. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7360. }
  7361. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7362. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  7363. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7364. __PYX_ERR(0, 410, __pyx_L1_error)
  7365. /* "gevent/ares.pyx":409
  7366. *
  7367. * def gethostbyaddr(self, object callback, char* addr):
  7368. * if not self.channel: # <<<<<<<<<<<<<<
  7369. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  7370. * # will guess the family
  7371. */
  7372. }
  7373. /* "gevent/ares.pyx":415
  7374. * cdef int family
  7375. * cdef int length
  7376. * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: # <<<<<<<<<<<<<<
  7377. * family = AF_INET
  7378. * length = 4
  7379. */
  7380. __pyx_t_1 = ((ares_inet_pton(AF_INET, __pyx_v_addr, __pyx_v_addr_packed) > 0) != 0);
  7381. if (__pyx_t_1) {
  7382. /* "gevent/ares.pyx":416
  7383. * cdef int length
  7384. * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0:
  7385. * family = AF_INET # <<<<<<<<<<<<<<
  7386. * length = 4
  7387. * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0:
  7388. */
  7389. __pyx_v_family = AF_INET;
  7390. /* "gevent/ares.pyx":417
  7391. * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0:
  7392. * family = AF_INET
  7393. * length = 4 # <<<<<<<<<<<<<<
  7394. * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0:
  7395. * family = AF_INET6
  7396. */
  7397. __pyx_v_length = 4;
  7398. /* "gevent/ares.pyx":415
  7399. * cdef int family
  7400. * cdef int length
  7401. * if cares.ares_inet_pton(AF_INET, addr, addr_packed) > 0: # <<<<<<<<<<<<<<
  7402. * family = AF_INET
  7403. * length = 4
  7404. */
  7405. goto __pyx_L4;
  7406. }
  7407. /* "gevent/ares.pyx":418
  7408. * family = AF_INET
  7409. * length = 4
  7410. * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: # <<<<<<<<<<<<<<
  7411. * family = AF_INET6
  7412. * length = 16
  7413. */
  7414. __pyx_t_1 = ((ares_inet_pton(AF_INET6, __pyx_v_addr, __pyx_v_addr_packed) > 0) != 0);
  7415. if (__pyx_t_1) {
  7416. /* "gevent/ares.pyx":419
  7417. * length = 4
  7418. * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0:
  7419. * family = AF_INET6 # <<<<<<<<<<<<<<
  7420. * length = 16
  7421. * else:
  7422. */
  7423. __pyx_v_family = AF_INET6;
  7424. /* "gevent/ares.pyx":420
  7425. * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0:
  7426. * family = AF_INET6
  7427. * length = 16 # <<<<<<<<<<<<<<
  7428. * else:
  7429. * raise InvalidIP(repr(addr))
  7430. */
  7431. __pyx_v_length = 16;
  7432. /* "gevent/ares.pyx":418
  7433. * family = AF_INET
  7434. * length = 4
  7435. * elif cares.ares_inet_pton(AF_INET6, addr, addr_packed) > 0: # <<<<<<<<<<<<<<
  7436. * family = AF_INET6
  7437. * length = 16
  7438. */
  7439. goto __pyx_L4;
  7440. }
  7441. /* "gevent/ares.pyx":422
  7442. * length = 16
  7443. * else:
  7444. * raise InvalidIP(repr(addr)) # <<<<<<<<<<<<<<
  7445. * cdef object arg = (self, callback)
  7446. * Py_INCREF(<PyObjectPtr>arg)
  7447. */
  7448. /*else*/ {
  7449. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidIP); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __pyx_L1_error)
  7450. __Pyx_GOTREF(__pyx_t_3);
  7451. __pyx_t_7 = __Pyx_PyBytes_FromString(__pyx_v_addr); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 422, __pyx_L1_error)
  7452. __Pyx_GOTREF(__pyx_t_7);
  7453. __pyx_t_4 = PyObject_Repr(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 422, __pyx_L1_error)
  7454. __Pyx_GOTREF(__pyx_t_4);
  7455. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7456. __pyx_t_7 = NULL;
  7457. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
  7458. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
  7459. if (likely(__pyx_t_7)) {
  7460. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
  7461. __Pyx_INCREF(__pyx_t_7);
  7462. __Pyx_INCREF(function);
  7463. __Pyx_DECREF_SET(__pyx_t_3, function);
  7464. }
  7465. }
  7466. if (!__pyx_t_7) {
  7467. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error)
  7468. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7469. __Pyx_GOTREF(__pyx_t_2);
  7470. } else {
  7471. #if CYTHON_FAST_PYCALL
  7472. if (PyFunction_Check(__pyx_t_3)) {
  7473. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
  7474. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error)
  7475. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7476. __Pyx_GOTREF(__pyx_t_2);
  7477. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7478. } else
  7479. #endif
  7480. #if CYTHON_FAST_PYCCALL
  7481. if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
  7482. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
  7483. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error)
  7484. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7485. __Pyx_GOTREF(__pyx_t_2);
  7486. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7487. } else
  7488. #endif
  7489. {
  7490. __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 422, __pyx_L1_error)
  7491. __Pyx_GOTREF(__pyx_t_5);
  7492. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
  7493. __Pyx_GIVEREF(__pyx_t_4);
  7494. PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
  7495. __pyx_t_4 = 0;
  7496. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error)
  7497. __Pyx_GOTREF(__pyx_t_2);
  7498. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7499. }
  7500. }
  7501. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7502. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  7503. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7504. __PYX_ERR(0, 422, __pyx_L1_error)
  7505. }
  7506. __pyx_L4:;
  7507. /* "gevent/ares.pyx":423
  7508. * else:
  7509. * raise InvalidIP(repr(addr))
  7510. * cdef object arg = (self, callback) # <<<<<<<<<<<<<<
  7511. * Py_INCREF(<PyObjectPtr>arg)
  7512. * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg)
  7513. */
  7514. __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 423, __pyx_L1_error)
  7515. __Pyx_GOTREF(__pyx_t_2);
  7516. __Pyx_INCREF(((PyObject *)__pyx_v_self));
  7517. __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  7518. PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  7519. __Pyx_INCREF(__pyx_v_callback);
  7520. __Pyx_GIVEREF(__pyx_v_callback);
  7521. PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_callback);
  7522. __pyx_v_arg = __pyx_t_2;
  7523. __pyx_t_2 = 0;
  7524. /* "gevent/ares.pyx":424
  7525. * raise InvalidIP(repr(addr))
  7526. * cdef object arg = (self, callback)
  7527. * Py_INCREF(<PyObjectPtr>arg) # <<<<<<<<<<<<<<
  7528. * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg)
  7529. *
  7530. */
  7531. Py_INCREF(((PyObject*)__pyx_v_arg));
  7532. /* "gevent/ares.pyx":425
  7533. * cdef object arg = (self, callback)
  7534. * Py_INCREF(<PyObjectPtr>arg)
  7535. * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg) # <<<<<<<<<<<<<<
  7536. *
  7537. * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags):
  7538. */
  7539. ares_gethostbyaddr(__pyx_v_self->channel, __pyx_v_addr_packed, __pyx_v_length, __pyx_v_family, ((void *)__pyx_f_6gevent_4ares_gevent_ares_host_callback), ((void *)__pyx_v_arg));
  7540. /* "gevent/ares.pyx":408
  7541. * cares.ares_gethostbyname(self.channel, name, family, <void*>gevent_ares_host_callback, <void*>arg)
  7542. *
  7543. * def gethostbyaddr(self, object callback, char* addr): # <<<<<<<<<<<<<<
  7544. * if not self.channel:
  7545. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  7546. */
  7547. /* function exit code */
  7548. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7549. goto __pyx_L0;
  7550. __pyx_L1_error:;
  7551. __Pyx_XDECREF(__pyx_t_2);
  7552. __Pyx_XDECREF(__pyx_t_3);
  7553. __Pyx_XDECREF(__pyx_t_4);
  7554. __Pyx_XDECREF(__pyx_t_5);
  7555. __Pyx_XDECREF(__pyx_t_7);
  7556. __Pyx_AddTraceback("gevent.ares.channel.gethostbyaddr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7557. __pyx_r = NULL;
  7558. __pyx_L0:;
  7559. __Pyx_XDECREF(__pyx_v_arg);
  7560. __Pyx_XGIVEREF(__pyx_r);
  7561. __Pyx_RefNannyFinishContext();
  7562. return __pyx_r;
  7563. }
  7564. /* "gevent/ares.pyx":427
  7565. * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg)
  7566. *
  7567. * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<<
  7568. * if not self.channel:
  7569. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  7570. */
  7571. static PyObject *__pyx_pw_6gevent_4ares_7channel_19_getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  7572. static PyObject *__pyx_f_6gevent_4ares_7channel__getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags, int __pyx_skip_dispatch) {
  7573. char *__pyx_v_hostp;
  7574. int __pyx_v_port;
  7575. int __pyx_v_flowinfo;
  7576. int __pyx_v_scope_id;
  7577. struct sockaddr_in6 __pyx_v_sa6;
  7578. int __pyx_v_length;
  7579. PyObject *__pyx_v_arg = 0;
  7580. struct sockaddr *__pyx_v_x;
  7581. PyObject *__pyx_r = NULL;
  7582. __Pyx_RefNannyDeclarations
  7583. PyObject *__pyx_t_1 = NULL;
  7584. PyObject *__pyx_t_2 = NULL;
  7585. PyObject *__pyx_t_3 = NULL;
  7586. PyObject *__pyx_t_4 = NULL;
  7587. PyObject *__pyx_t_5 = NULL;
  7588. int __pyx_t_6;
  7589. PyObject *__pyx_t_7 = NULL;
  7590. int __pyx_t_8;
  7591. int __pyx_t_9;
  7592. __Pyx_RefNannySetupContext("_getnameinfo", 0);
  7593. /* Check if called by wrapper */
  7594. if (unlikely(__pyx_skip_dispatch)) ;
  7595. /* Check if overridden in Python */
  7596. else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
  7597. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_getnameinfo); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
  7598. __Pyx_GOTREF(__pyx_t_1);
  7599. if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_6gevent_4ares_7channel_19_getnameinfo)) {
  7600. __Pyx_XDECREF(__pyx_r);
  7601. __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 427, __pyx_L1_error)
  7602. __Pyx_GOTREF(__pyx_t_3);
  7603. __Pyx_INCREF(__pyx_t_1);
  7604. __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL;
  7605. __pyx_t_6 = 0;
  7606. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
  7607. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  7608. if (likely(__pyx_t_5)) {
  7609. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
  7610. __Pyx_INCREF(__pyx_t_5);
  7611. __Pyx_INCREF(function);
  7612. __Pyx_DECREF_SET(__pyx_t_4, function);
  7613. __pyx_t_6 = 1;
  7614. }
  7615. }
  7616. #if CYTHON_FAST_PYCALL
  7617. if (PyFunction_Check(__pyx_t_4)) {
  7618. PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_callback, __pyx_v_sockaddr, __pyx_t_3};
  7619. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 427, __pyx_L1_error)
  7620. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7621. __Pyx_GOTREF(__pyx_t_2);
  7622. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7623. } else
  7624. #endif
  7625. #if CYTHON_FAST_PYCCALL
  7626. if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
  7627. PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_v_callback, __pyx_v_sockaddr, __pyx_t_3};
  7628. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 427, __pyx_L1_error)
  7629. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7630. __Pyx_GOTREF(__pyx_t_2);
  7631. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7632. } else
  7633. #endif
  7634. {
  7635. __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 427, __pyx_L1_error)
  7636. __Pyx_GOTREF(__pyx_t_7);
  7637. if (__pyx_t_5) {
  7638. __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
  7639. }
  7640. __Pyx_INCREF(__pyx_v_callback);
  7641. __Pyx_GIVEREF(__pyx_v_callback);
  7642. PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_callback);
  7643. __Pyx_INCREF(__pyx_v_sockaddr);
  7644. __Pyx_GIVEREF(__pyx_v_sockaddr);
  7645. PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_sockaddr);
  7646. __Pyx_GIVEREF(__pyx_t_3);
  7647. PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_3);
  7648. __pyx_t_3 = 0;
  7649. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 427, __pyx_L1_error)
  7650. __Pyx_GOTREF(__pyx_t_2);
  7651. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7652. }
  7653. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7654. __pyx_r = __pyx_t_2;
  7655. __pyx_t_2 = 0;
  7656. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7657. goto __pyx_L0;
  7658. }
  7659. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7660. }
  7661. /* "gevent/ares.pyx":428
  7662. *
  7663. * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags):
  7664. * if not self.channel: # <<<<<<<<<<<<<<
  7665. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  7666. * cdef char* hostp = NULL
  7667. */
  7668. __pyx_t_8 = ((!(__pyx_v_self->channel != 0)) != 0);
  7669. if (__pyx_t_8) {
  7670. /* "gevent/ares.pyx":429
  7671. * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags):
  7672. * if not self.channel:
  7673. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed') # <<<<<<<<<<<<<<
  7674. * cdef char* hostp = NULL
  7675. * cdef int port = 0
  7676. */
  7677. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 429, __pyx_L1_error)
  7678. __Pyx_GOTREF(__pyx_t_2);
  7679. __pyx_t_4 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 429, __pyx_L1_error)
  7680. __Pyx_GOTREF(__pyx_t_4);
  7681. __pyx_t_7 = NULL;
  7682. __pyx_t_6 = 0;
  7683. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
  7684. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
  7685. if (likely(__pyx_t_7)) {
  7686. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
  7687. __Pyx_INCREF(__pyx_t_7);
  7688. __Pyx_INCREF(function);
  7689. __Pyx_DECREF_SET(__pyx_t_2, function);
  7690. __pyx_t_6 = 1;
  7691. }
  7692. }
  7693. #if CYTHON_FAST_PYCALL
  7694. if (PyFunction_Check(__pyx_t_2)) {
  7695. PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
  7696. __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __pyx_L1_error)
  7697. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7698. __Pyx_GOTREF(__pyx_t_1);
  7699. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7700. } else
  7701. #endif
  7702. #if CYTHON_FAST_PYCCALL
  7703. if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
  7704. PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_4, __pyx_kp_s_this_ares_channel_has_been_destr};
  7705. __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __pyx_L1_error)
  7706. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7707. __Pyx_GOTREF(__pyx_t_1);
  7708. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7709. } else
  7710. #endif
  7711. {
  7712. __pyx_t_3 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 429, __pyx_L1_error)
  7713. __Pyx_GOTREF(__pyx_t_3);
  7714. if (__pyx_t_7) {
  7715. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL;
  7716. }
  7717. __Pyx_GIVEREF(__pyx_t_4);
  7718. PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, __pyx_t_4);
  7719. __Pyx_INCREF(__pyx_kp_s_this_ares_channel_has_been_destr);
  7720. __Pyx_GIVEREF(__pyx_kp_s_this_ares_channel_has_been_destr);
  7721. PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, __pyx_kp_s_this_ares_channel_has_been_destr);
  7722. __pyx_t_4 = 0;
  7723. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __pyx_L1_error)
  7724. __Pyx_GOTREF(__pyx_t_1);
  7725. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7726. }
  7727. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7728. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  7729. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7730. __PYX_ERR(0, 429, __pyx_L1_error)
  7731. /* "gevent/ares.pyx":428
  7732. *
  7733. * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags):
  7734. * if not self.channel: # <<<<<<<<<<<<<<
  7735. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  7736. * cdef char* hostp = NULL
  7737. */
  7738. }
  7739. /* "gevent/ares.pyx":430
  7740. * if not self.channel:
  7741. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  7742. * cdef char* hostp = NULL # <<<<<<<<<<<<<<
  7743. * cdef int port = 0
  7744. * cdef int flowinfo = 0
  7745. */
  7746. __pyx_v_hostp = NULL;
  7747. /* "gevent/ares.pyx":431
  7748. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  7749. * cdef char* hostp = NULL
  7750. * cdef int port = 0 # <<<<<<<<<<<<<<
  7751. * cdef int flowinfo = 0
  7752. * cdef int scope_id = 0
  7753. */
  7754. __pyx_v_port = 0;
  7755. /* "gevent/ares.pyx":432
  7756. * cdef char* hostp = NULL
  7757. * cdef int port = 0
  7758. * cdef int flowinfo = 0 # <<<<<<<<<<<<<<
  7759. * cdef int scope_id = 0
  7760. * cdef sockaddr_in6 sa6
  7761. */
  7762. __pyx_v_flowinfo = 0;
  7763. /* "gevent/ares.pyx":433
  7764. * cdef int port = 0
  7765. * cdef int flowinfo = 0
  7766. * cdef int scope_id = 0 # <<<<<<<<<<<<<<
  7767. * cdef sockaddr_in6 sa6
  7768. * if not PyTuple_Check(sockaddr):
  7769. */
  7770. __pyx_v_scope_id = 0;
  7771. /* "gevent/ares.pyx":435
  7772. * cdef int scope_id = 0
  7773. * cdef sockaddr_in6 sa6
  7774. * if not PyTuple_Check(sockaddr): # <<<<<<<<<<<<<<
  7775. * raise TypeError('expected a tuple, got %r' % (sockaddr, ))
  7776. * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id)
  7777. */
  7778. __pyx_t_8 = ((!(PyTuple_Check(__pyx_v_sockaddr) != 0)) != 0);
  7779. if (__pyx_t_8) {
  7780. /* "gevent/ares.pyx":436
  7781. * cdef sockaddr_in6 sa6
  7782. * if not PyTuple_Check(sockaddr):
  7783. * raise TypeError('expected a tuple, got %r' % (sockaddr, )) # <<<<<<<<<<<<<<
  7784. * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id)
  7785. * if port < 0 or port > 65535:
  7786. */
  7787. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 436, __pyx_L1_error)
  7788. __Pyx_GOTREF(__pyx_t_1);
  7789. __Pyx_INCREF(__pyx_v_sockaddr);
  7790. __Pyx_GIVEREF(__pyx_v_sockaddr);
  7791. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sockaddr);
  7792. __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_expected_a_tuple_got_r, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 436, __pyx_L1_error)
  7793. __Pyx_GOTREF(__pyx_t_2);
  7794. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7795. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 436, __pyx_L1_error)
  7796. __Pyx_GOTREF(__pyx_t_1);
  7797. __Pyx_GIVEREF(__pyx_t_2);
  7798. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  7799. __pyx_t_2 = 0;
  7800. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 436, __pyx_L1_error)
  7801. __Pyx_GOTREF(__pyx_t_2);
  7802. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7803. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  7804. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7805. __PYX_ERR(0, 436, __pyx_L1_error)
  7806. /* "gevent/ares.pyx":435
  7807. * cdef int scope_id = 0
  7808. * cdef sockaddr_in6 sa6
  7809. * if not PyTuple_Check(sockaddr): # <<<<<<<<<<<<<<
  7810. * raise TypeError('expected a tuple, got %r' % (sockaddr, ))
  7811. * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id)
  7812. */
  7813. }
  7814. /* "gevent/ares.pyx":437
  7815. * if not PyTuple_Check(sockaddr):
  7816. * raise TypeError('expected a tuple, got %r' % (sockaddr, ))
  7817. * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id) # <<<<<<<<<<<<<<
  7818. * if port < 0 or port > 65535:
  7819. * raise gaierror(-8, 'Invalid value for port: %r' % port)
  7820. */
  7821. __pyx_t_6 = PyArg_ParseTuple(__pyx_v_sockaddr, ((char *)"si|ii"), (&__pyx_v_hostp), (&__pyx_v_port), (&__pyx_v_flowinfo), (&__pyx_v_scope_id)); if (unlikely(__pyx_t_6 == 0)) __PYX_ERR(0, 437, __pyx_L1_error)
  7822. /* "gevent/ares.pyx":438
  7823. * raise TypeError('expected a tuple, got %r' % (sockaddr, ))
  7824. * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id)
  7825. * if port < 0 or port > 65535: # <<<<<<<<<<<<<<
  7826. * raise gaierror(-8, 'Invalid value for port: %r' % port)
  7827. * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6)
  7828. */
  7829. __pyx_t_9 = ((__pyx_v_port < 0) != 0);
  7830. if (!__pyx_t_9) {
  7831. } else {
  7832. __pyx_t_8 = __pyx_t_9;
  7833. goto __pyx_L6_bool_binop_done;
  7834. }
  7835. __pyx_t_9 = ((__pyx_v_port > 0xFFFF) != 0);
  7836. __pyx_t_8 = __pyx_t_9;
  7837. __pyx_L6_bool_binop_done:;
  7838. if (__pyx_t_8) {
  7839. /* "gevent/ares.pyx":439
  7840. * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id)
  7841. * if port < 0 or port > 65535:
  7842. * raise gaierror(-8, 'Invalid value for port: %r' % port) # <<<<<<<<<<<<<<
  7843. * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6)
  7844. * if length <= 0:
  7845. */
  7846. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 439, __pyx_L1_error)
  7847. __Pyx_GOTREF(__pyx_t_1);
  7848. __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 439, __pyx_L1_error)
  7849. __Pyx_GOTREF(__pyx_t_3);
  7850. __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_value_for_port_r, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 439, __pyx_L1_error)
  7851. __Pyx_GOTREF(__pyx_t_4);
  7852. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7853. __pyx_t_3 = NULL;
  7854. __pyx_t_6 = 0;
  7855. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  7856. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
  7857. if (likely(__pyx_t_3)) {
  7858. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  7859. __Pyx_INCREF(__pyx_t_3);
  7860. __Pyx_INCREF(function);
  7861. __Pyx_DECREF_SET(__pyx_t_1, function);
  7862. __pyx_t_6 = 1;
  7863. }
  7864. }
  7865. #if CYTHON_FAST_PYCALL
  7866. if (PyFunction_Check(__pyx_t_1)) {
  7867. PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_int_neg_8, __pyx_t_4};
  7868. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 439, __pyx_L1_error)
  7869. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  7870. __Pyx_GOTREF(__pyx_t_2);
  7871. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7872. } else
  7873. #endif
  7874. #if CYTHON_FAST_PYCCALL
  7875. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  7876. PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_int_neg_8, __pyx_t_4};
  7877. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 439, __pyx_L1_error)
  7878. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  7879. __Pyx_GOTREF(__pyx_t_2);
  7880. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7881. } else
  7882. #endif
  7883. {
  7884. __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 439, __pyx_L1_error)
  7885. __Pyx_GOTREF(__pyx_t_7);
  7886. if (__pyx_t_3) {
  7887. __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
  7888. }
  7889. __Pyx_INCREF(__pyx_int_neg_8);
  7890. __Pyx_GIVEREF(__pyx_int_neg_8);
  7891. PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_int_neg_8);
  7892. __Pyx_GIVEREF(__pyx_t_4);
  7893. PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
  7894. __pyx_t_4 = 0;
  7895. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 439, __pyx_L1_error)
  7896. __Pyx_GOTREF(__pyx_t_2);
  7897. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7898. }
  7899. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7900. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  7901. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7902. __PYX_ERR(0, 439, __pyx_L1_error)
  7903. /* "gevent/ares.pyx":438
  7904. * raise TypeError('expected a tuple, got %r' % (sockaddr, ))
  7905. * PyArg_ParseTuple(sockaddr, "si|ii", &hostp, &port, &flowinfo, &scope_id)
  7906. * if port < 0 or port > 65535: # <<<<<<<<<<<<<<
  7907. * raise gaierror(-8, 'Invalid value for port: %r' % port)
  7908. * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6)
  7909. */
  7910. }
  7911. /* "gevent/ares.pyx":440
  7912. * if port < 0 or port > 65535:
  7913. * raise gaierror(-8, 'Invalid value for port: %r' % port)
  7914. * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6) # <<<<<<<<<<<<<<
  7915. * if length <= 0:
  7916. * raise InvalidIP(repr(hostp))
  7917. */
  7918. __pyx_v_length = gevent_make_sockaddr(__pyx_v_hostp, __pyx_v_port, __pyx_v_flowinfo, __pyx_v_scope_id, (&__pyx_v_sa6));
  7919. /* "gevent/ares.pyx":441
  7920. * raise gaierror(-8, 'Invalid value for port: %r' % port)
  7921. * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6)
  7922. * if length <= 0: # <<<<<<<<<<<<<<
  7923. * raise InvalidIP(repr(hostp))
  7924. * cdef object arg = (self, callback)
  7925. */
  7926. __pyx_t_8 = ((__pyx_v_length <= 0) != 0);
  7927. if (__pyx_t_8) {
  7928. /* "gevent/ares.pyx":442
  7929. * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6)
  7930. * if length <= 0:
  7931. * raise InvalidIP(repr(hostp)) # <<<<<<<<<<<<<<
  7932. * cdef object arg = (self, callback)
  7933. * Py_INCREF(<PyObjectPtr>arg)
  7934. */
  7935. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_InvalidIP); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 442, __pyx_L1_error)
  7936. __Pyx_GOTREF(__pyx_t_1);
  7937. __pyx_t_7 = __Pyx_PyBytes_FromString(__pyx_v_hostp); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 442, __pyx_L1_error)
  7938. __Pyx_GOTREF(__pyx_t_7);
  7939. __pyx_t_4 = PyObject_Repr(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 442, __pyx_L1_error)
  7940. __Pyx_GOTREF(__pyx_t_4);
  7941. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7942. __pyx_t_7 = NULL;
  7943. if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
  7944. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
  7945. if (likely(__pyx_t_7)) {
  7946. PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
  7947. __Pyx_INCREF(__pyx_t_7);
  7948. __Pyx_INCREF(function);
  7949. __Pyx_DECREF_SET(__pyx_t_1, function);
  7950. }
  7951. }
  7952. if (!__pyx_t_7) {
  7953. __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error)
  7954. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7955. __Pyx_GOTREF(__pyx_t_2);
  7956. } else {
  7957. #if CYTHON_FAST_PYCALL
  7958. if (PyFunction_Check(__pyx_t_1)) {
  7959. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
  7960. __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error)
  7961. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7962. __Pyx_GOTREF(__pyx_t_2);
  7963. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7964. } else
  7965. #endif
  7966. #if CYTHON_FAST_PYCCALL
  7967. if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
  7968. PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
  7969. __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error)
  7970. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7971. __Pyx_GOTREF(__pyx_t_2);
  7972. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7973. } else
  7974. #endif
  7975. {
  7976. __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 442, __pyx_L1_error)
  7977. __Pyx_GOTREF(__pyx_t_3);
  7978. __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL;
  7979. __Pyx_GIVEREF(__pyx_t_4);
  7980. PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_4);
  7981. __pyx_t_4 = 0;
  7982. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 442, __pyx_L1_error)
  7983. __Pyx_GOTREF(__pyx_t_2);
  7984. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7985. }
  7986. }
  7987. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7988. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  7989. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  7990. __PYX_ERR(0, 442, __pyx_L1_error)
  7991. /* "gevent/ares.pyx":441
  7992. * raise gaierror(-8, 'Invalid value for port: %r' % port)
  7993. * cdef int length = gevent_make_sockaddr(hostp, port, flowinfo, scope_id, &sa6)
  7994. * if length <= 0: # <<<<<<<<<<<<<<
  7995. * raise InvalidIP(repr(hostp))
  7996. * cdef object arg = (self, callback)
  7997. */
  7998. }
  7999. /* "gevent/ares.pyx":443
  8000. * if length <= 0:
  8001. * raise InvalidIP(repr(hostp))
  8002. * cdef object arg = (self, callback) # <<<<<<<<<<<<<<
  8003. * Py_INCREF(<PyObjectPtr>arg)
  8004. * cdef sockaddr_t* x = <sockaddr_t*>&sa6
  8005. */
  8006. __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 443, __pyx_L1_error)
  8007. __Pyx_GOTREF(__pyx_t_2);
  8008. __Pyx_INCREF(((PyObject *)__pyx_v_self));
  8009. __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  8010. PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  8011. __Pyx_INCREF(__pyx_v_callback);
  8012. __Pyx_GIVEREF(__pyx_v_callback);
  8013. PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_callback);
  8014. __pyx_v_arg = __pyx_t_2;
  8015. __pyx_t_2 = 0;
  8016. /* "gevent/ares.pyx":444
  8017. * raise InvalidIP(repr(hostp))
  8018. * cdef object arg = (self, callback)
  8019. * Py_INCREF(<PyObjectPtr>arg) # <<<<<<<<<<<<<<
  8020. * cdef sockaddr_t* x = <sockaddr_t*>&sa6
  8021. * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg)
  8022. */
  8023. Py_INCREF(((PyObject*)__pyx_v_arg));
  8024. /* "gevent/ares.pyx":445
  8025. * cdef object arg = (self, callback)
  8026. * Py_INCREF(<PyObjectPtr>arg)
  8027. * cdef sockaddr_t* x = <sockaddr_t*>&sa6 # <<<<<<<<<<<<<<
  8028. * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg)
  8029. *
  8030. */
  8031. __pyx_v_x = ((struct sockaddr *)(&__pyx_v_sa6));
  8032. /* "gevent/ares.pyx":446
  8033. * Py_INCREF(<PyObjectPtr>arg)
  8034. * cdef sockaddr_t* x = <sockaddr_t*>&sa6
  8035. * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg) # <<<<<<<<<<<<<<
  8036. *
  8037. * def getnameinfo(self, object callback, tuple sockaddr, int flags):
  8038. */
  8039. ares_getnameinfo(__pyx_v_self->channel, __pyx_v_x, __pyx_v_length, __pyx_v_flags, ((void *)__pyx_f_6gevent_4ares_gevent_ares_nameinfo_callback), ((void *)__pyx_v_arg));
  8040. /* "gevent/ares.pyx":427
  8041. * cares.ares_gethostbyaddr(self.channel, addr_packed, length, family, <void*>gevent_ares_host_callback, <void*>arg)
  8042. *
  8043. * cpdef _getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<<
  8044. * if not self.channel:
  8045. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  8046. */
  8047. /* function exit code */
  8048. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  8049. goto __pyx_L0;
  8050. __pyx_L1_error:;
  8051. __Pyx_XDECREF(__pyx_t_1);
  8052. __Pyx_XDECREF(__pyx_t_2);
  8053. __Pyx_XDECREF(__pyx_t_3);
  8054. __Pyx_XDECREF(__pyx_t_4);
  8055. __Pyx_XDECREF(__pyx_t_5);
  8056. __Pyx_XDECREF(__pyx_t_7);
  8057. __Pyx_AddTraceback("gevent.ares.channel._getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8058. __pyx_r = 0;
  8059. __pyx_L0:;
  8060. __Pyx_XDECREF(__pyx_v_arg);
  8061. __Pyx_XGIVEREF(__pyx_r);
  8062. __Pyx_RefNannyFinishContext();
  8063. return __pyx_r;
  8064. }
  8065. /* Python wrapper */
  8066. static PyObject *__pyx_pw_6gevent_4ares_7channel_19_getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  8067. static PyObject *__pyx_pw_6gevent_4ares_7channel_19_getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  8068. PyObject *__pyx_v_callback = 0;
  8069. PyObject *__pyx_v_sockaddr = 0;
  8070. int __pyx_v_flags;
  8071. PyObject *__pyx_r = 0;
  8072. __Pyx_RefNannyDeclarations
  8073. __Pyx_RefNannySetupContext("_getnameinfo (wrapper)", 0);
  8074. {
  8075. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_sockaddr,&__pyx_n_s_flags,0};
  8076. PyObject* values[3] = {0,0,0};
  8077. if (unlikely(__pyx_kwds)) {
  8078. Py_ssize_t kw_args;
  8079. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  8080. switch (pos_args) {
  8081. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  8082. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  8083. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  8084. case 0: break;
  8085. default: goto __pyx_L5_argtuple_error;
  8086. }
  8087. kw_args = PyDict_Size(__pyx_kwds);
  8088. switch (pos_args) {
  8089. case 0:
  8090. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
  8091. else goto __pyx_L5_argtuple_error;
  8092. case 1:
  8093. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sockaddr)) != 0)) kw_args--;
  8094. else {
  8095. __Pyx_RaiseArgtupleInvalid("_getnameinfo", 1, 3, 3, 1); __PYX_ERR(0, 427, __pyx_L3_error)
  8096. }
  8097. case 2:
  8098. if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
  8099. else {
  8100. __Pyx_RaiseArgtupleInvalid("_getnameinfo", 1, 3, 3, 2); __PYX_ERR(0, 427, __pyx_L3_error)
  8101. }
  8102. }
  8103. if (unlikely(kw_args > 0)) {
  8104. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_getnameinfo") < 0)) __PYX_ERR(0, 427, __pyx_L3_error)
  8105. }
  8106. } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
  8107. goto __pyx_L5_argtuple_error;
  8108. } else {
  8109. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  8110. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  8111. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  8112. }
  8113. __pyx_v_callback = values[0];
  8114. __pyx_v_sockaddr = ((PyObject*)values[1]);
  8115. __pyx_v_flags = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 427, __pyx_L3_error)
  8116. }
  8117. goto __pyx_L4_argument_unpacking_done;
  8118. __pyx_L5_argtuple_error:;
  8119. __Pyx_RaiseArgtupleInvalid("_getnameinfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 427, __pyx_L3_error)
  8120. __pyx_L3_error:;
  8121. __Pyx_AddTraceback("gevent.ares.channel._getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8122. __Pyx_RefNannyFinishContext();
  8123. return NULL;
  8124. __pyx_L4_argument_unpacking_done:;
  8125. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sockaddr), (&PyTuple_Type), 1, "sockaddr", 1))) __PYX_ERR(0, 427, __pyx_L1_error)
  8126. __pyx_r = __pyx_pf_6gevent_4ares_7channel_18_getnameinfo(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags);
  8127. /* function exit code */
  8128. goto __pyx_L0;
  8129. __pyx_L1_error:;
  8130. __pyx_r = NULL;
  8131. __pyx_L0:;
  8132. __Pyx_RefNannyFinishContext();
  8133. return __pyx_r;
  8134. }
  8135. static PyObject *__pyx_pf_6gevent_4ares_7channel_18_getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags) {
  8136. PyObject *__pyx_r = NULL;
  8137. __Pyx_RefNannyDeclarations
  8138. PyObject *__pyx_t_1 = NULL;
  8139. __Pyx_RefNannySetupContext("_getnameinfo", 0);
  8140. __Pyx_XDECREF(__pyx_r);
  8141. __pyx_t_1 = __pyx_f_6gevent_4ares_7channel__getnameinfo(__pyx_v_self, __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
  8142. __Pyx_GOTREF(__pyx_t_1);
  8143. __pyx_r = __pyx_t_1;
  8144. __pyx_t_1 = 0;
  8145. goto __pyx_L0;
  8146. /* function exit code */
  8147. __pyx_L1_error:;
  8148. __Pyx_XDECREF(__pyx_t_1);
  8149. __Pyx_AddTraceback("gevent.ares.channel._getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8150. __pyx_r = NULL;
  8151. __pyx_L0:;
  8152. __Pyx_XGIVEREF(__pyx_r);
  8153. __Pyx_RefNannyFinishContext();
  8154. return __pyx_r;
  8155. }
  8156. /* "gevent/ares.pyx":448
  8157. * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg)
  8158. *
  8159. * def getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<<
  8160. * try:
  8161. * flags = _convert_cares_flags(flags)
  8162. */
  8163. /* Python wrapper */
  8164. static PyObject *__pyx_pw_6gevent_4ares_7channel_21getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  8165. static PyObject *__pyx_pw_6gevent_4ares_7channel_21getnameinfo(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  8166. PyObject *__pyx_v_callback = 0;
  8167. PyObject *__pyx_v_sockaddr = 0;
  8168. int __pyx_v_flags;
  8169. PyObject *__pyx_r = 0;
  8170. __Pyx_RefNannyDeclarations
  8171. __Pyx_RefNannySetupContext("getnameinfo (wrapper)", 0);
  8172. {
  8173. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_callback,&__pyx_n_s_sockaddr,&__pyx_n_s_flags,0};
  8174. PyObject* values[3] = {0,0,0};
  8175. if (unlikely(__pyx_kwds)) {
  8176. Py_ssize_t kw_args;
  8177. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  8178. switch (pos_args) {
  8179. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  8180. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  8181. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  8182. case 0: break;
  8183. default: goto __pyx_L5_argtuple_error;
  8184. }
  8185. kw_args = PyDict_Size(__pyx_kwds);
  8186. switch (pos_args) {
  8187. case 0:
  8188. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_callback)) != 0)) kw_args--;
  8189. else goto __pyx_L5_argtuple_error;
  8190. case 1:
  8191. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sockaddr)) != 0)) kw_args--;
  8192. else {
  8193. __Pyx_RaiseArgtupleInvalid("getnameinfo", 1, 3, 3, 1); __PYX_ERR(0, 448, __pyx_L3_error)
  8194. }
  8195. case 2:
  8196. if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
  8197. else {
  8198. __Pyx_RaiseArgtupleInvalid("getnameinfo", 1, 3, 3, 2); __PYX_ERR(0, 448, __pyx_L3_error)
  8199. }
  8200. }
  8201. if (unlikely(kw_args > 0)) {
  8202. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "getnameinfo") < 0)) __PYX_ERR(0, 448, __pyx_L3_error)
  8203. }
  8204. } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
  8205. goto __pyx_L5_argtuple_error;
  8206. } else {
  8207. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  8208. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  8209. values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  8210. }
  8211. __pyx_v_callback = values[0];
  8212. __pyx_v_sockaddr = ((PyObject*)values[1]);
  8213. __pyx_v_flags = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 448, __pyx_L3_error)
  8214. }
  8215. goto __pyx_L4_argument_unpacking_done;
  8216. __pyx_L5_argtuple_error:;
  8217. __Pyx_RaiseArgtupleInvalid("getnameinfo", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 448, __pyx_L3_error)
  8218. __pyx_L3_error:;
  8219. __Pyx_AddTraceback("gevent.ares.channel.getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8220. __Pyx_RefNannyFinishContext();
  8221. return NULL;
  8222. __pyx_L4_argument_unpacking_done:;
  8223. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sockaddr), (&PyTuple_Type), 1, "sockaddr", 1))) __PYX_ERR(0, 448, __pyx_L1_error)
  8224. __pyx_r = __pyx_pf_6gevent_4ares_7channel_20getnameinfo(((struct PyGeventAresChannelObject *)__pyx_v_self), __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags);
  8225. /* function exit code */
  8226. goto __pyx_L0;
  8227. __pyx_L1_error:;
  8228. __pyx_r = NULL;
  8229. __pyx_L0:;
  8230. __Pyx_RefNannyFinishContext();
  8231. return __pyx_r;
  8232. }
  8233. static PyObject *__pyx_pf_6gevent_4ares_7channel_20getnameinfo(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_callback, PyObject *__pyx_v_sockaddr, int __pyx_v_flags) {
  8234. PyObject *__pyx_r = NULL;
  8235. __Pyx_RefNannyDeclarations
  8236. PyObject *__pyx_t_1 = NULL;
  8237. PyObject *__pyx_t_2 = NULL;
  8238. PyObject *__pyx_t_3 = NULL;
  8239. PyObject *__pyx_t_4 = NULL;
  8240. int __pyx_t_5;
  8241. PyObject *__pyx_t_6 = NULL;
  8242. PyObject *__pyx_t_7 = NULL;
  8243. __Pyx_RefNannySetupContext("getnameinfo", 0);
  8244. /* "gevent/ares.pyx":449
  8245. *
  8246. * def getnameinfo(self, object callback, tuple sockaddr, int flags):
  8247. * try: # <<<<<<<<<<<<<<
  8248. * flags = _convert_cares_flags(flags)
  8249. * except gaierror:
  8250. */
  8251. {
  8252. __Pyx_PyThreadState_declare
  8253. __Pyx_PyThreadState_assign
  8254. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  8255. __Pyx_XGOTREF(__pyx_t_1);
  8256. __Pyx_XGOTREF(__pyx_t_2);
  8257. __Pyx_XGOTREF(__pyx_t_3);
  8258. /*try:*/ {
  8259. /* "gevent/ares.pyx":450
  8260. * def getnameinfo(self, object callback, tuple sockaddr, int flags):
  8261. * try:
  8262. * flags = _convert_cares_flags(flags) # <<<<<<<<<<<<<<
  8263. * except gaierror:
  8264. * # The stdlib just ignores bad flags
  8265. */
  8266. __pyx_t_4 = __pyx_f_6gevent_4ares__convert_cares_flags(__pyx_v_flags, 0, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 450, __pyx_L3_error)
  8267. __Pyx_GOTREF(__pyx_t_4);
  8268. __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 450, __pyx_L3_error)
  8269. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8270. __pyx_v_flags = __pyx_t_5;
  8271. /* "gevent/ares.pyx":449
  8272. *
  8273. * def getnameinfo(self, object callback, tuple sockaddr, int flags):
  8274. * try: # <<<<<<<<<<<<<<
  8275. * flags = _convert_cares_flags(flags)
  8276. * except gaierror:
  8277. */
  8278. }
  8279. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  8280. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  8281. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  8282. goto __pyx_L10_try_end;
  8283. __pyx_L3_error:;
  8284. __Pyx_PyThreadState_assign
  8285. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  8286. /* "gevent/ares.pyx":451
  8287. * try:
  8288. * flags = _convert_cares_flags(flags)
  8289. * except gaierror: # <<<<<<<<<<<<<<
  8290. * # The stdlib just ignores bad flags
  8291. * flags = 0
  8292. */
  8293. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_gaierror); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 451, __pyx_L5_except_error)
  8294. __Pyx_GOTREF(__pyx_t_4);
  8295. __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_t_4);
  8296. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8297. if (__pyx_t_5) {
  8298. __Pyx_AddTraceback("gevent.ares.channel.getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8299. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 451, __pyx_L5_except_error)
  8300. __Pyx_GOTREF(__pyx_t_4);
  8301. __Pyx_GOTREF(__pyx_t_6);
  8302. __Pyx_GOTREF(__pyx_t_7);
  8303. /* "gevent/ares.pyx":453
  8304. * except gaierror:
  8305. * # The stdlib just ignores bad flags
  8306. * flags = 0 # <<<<<<<<<<<<<<
  8307. * return self._getnameinfo(callback, sockaddr, flags)
  8308. */
  8309. __pyx_v_flags = 0;
  8310. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8311. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8312. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8313. goto __pyx_L4_exception_handled;
  8314. }
  8315. goto __pyx_L5_except_error;
  8316. __pyx_L5_except_error:;
  8317. /* "gevent/ares.pyx":449
  8318. *
  8319. * def getnameinfo(self, object callback, tuple sockaddr, int flags):
  8320. * try: # <<<<<<<<<<<<<<
  8321. * flags = _convert_cares_flags(flags)
  8322. * except gaierror:
  8323. */
  8324. __Pyx_PyThreadState_assign
  8325. __Pyx_XGIVEREF(__pyx_t_1);
  8326. __Pyx_XGIVEREF(__pyx_t_2);
  8327. __Pyx_XGIVEREF(__pyx_t_3);
  8328. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8329. goto __pyx_L1_error;
  8330. __pyx_L4_exception_handled:;
  8331. __Pyx_PyThreadState_assign
  8332. __Pyx_XGIVEREF(__pyx_t_1);
  8333. __Pyx_XGIVEREF(__pyx_t_2);
  8334. __Pyx_XGIVEREF(__pyx_t_3);
  8335. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  8336. __pyx_L10_try_end:;
  8337. }
  8338. /* "gevent/ares.pyx":454
  8339. * # The stdlib just ignores bad flags
  8340. * flags = 0
  8341. * return self._getnameinfo(callback, sockaddr, flags) # <<<<<<<<<<<<<<
  8342. */
  8343. __Pyx_XDECREF(__pyx_r);
  8344. __pyx_t_7 = ((struct __pyx_vtabstruct_6gevent_4ares_channel *)__pyx_v_self->__pyx_vtab)->_getnameinfo(__pyx_v_self, __pyx_v_callback, __pyx_v_sockaddr, __pyx_v_flags, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 454, __pyx_L1_error)
  8345. __Pyx_GOTREF(__pyx_t_7);
  8346. __pyx_r = __pyx_t_7;
  8347. __pyx_t_7 = 0;
  8348. goto __pyx_L0;
  8349. /* "gevent/ares.pyx":448
  8350. * cares.ares_getnameinfo(self.channel, x, length, flags, <void*>gevent_ares_nameinfo_callback, <void*>arg)
  8351. *
  8352. * def getnameinfo(self, object callback, tuple sockaddr, int flags): # <<<<<<<<<<<<<<
  8353. * try:
  8354. * flags = _convert_cares_flags(flags)
  8355. */
  8356. /* function exit code */
  8357. __pyx_L1_error:;
  8358. __Pyx_XDECREF(__pyx_t_4);
  8359. __Pyx_XDECREF(__pyx_t_6);
  8360. __Pyx_XDECREF(__pyx_t_7);
  8361. __Pyx_AddTraceback("gevent.ares.channel.getnameinfo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8362. __pyx_r = NULL;
  8363. __pyx_L0:;
  8364. __Pyx_XGIVEREF(__pyx_r);
  8365. __Pyx_RefNannyFinishContext();
  8366. return __pyx_r;
  8367. }
  8368. /* "gevent/ares.pyx":247
  8369. * cdef public class channel [object PyGeventAresChannelObject, type PyGeventAresChannel_Type]:
  8370. *
  8371. * cdef public object loop # <<<<<<<<<<<<<<
  8372. * cdef ares_channeldata* channel
  8373. * cdef public dict _watchers
  8374. */
  8375. /* Python wrapper */
  8376. static PyObject *__pyx_pw_6gevent_4ares_7channel_4loop_1__get__(PyObject *__pyx_v_self); /*proto*/
  8377. static PyObject *__pyx_pw_6gevent_4ares_7channel_4loop_1__get__(PyObject *__pyx_v_self) {
  8378. PyObject *__pyx_r = 0;
  8379. __Pyx_RefNannyDeclarations
  8380. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  8381. __pyx_r = __pyx_pf_6gevent_4ares_7channel_4loop___get__(((struct PyGeventAresChannelObject *)__pyx_v_self));
  8382. /* function exit code */
  8383. __Pyx_RefNannyFinishContext();
  8384. return __pyx_r;
  8385. }
  8386. static PyObject *__pyx_pf_6gevent_4ares_7channel_4loop___get__(struct PyGeventAresChannelObject *__pyx_v_self) {
  8387. PyObject *__pyx_r = NULL;
  8388. __Pyx_RefNannyDeclarations
  8389. __Pyx_RefNannySetupContext("__get__", 0);
  8390. __Pyx_XDECREF(__pyx_r);
  8391. __Pyx_INCREF(__pyx_v_self->loop);
  8392. __pyx_r = __pyx_v_self->loop;
  8393. goto __pyx_L0;
  8394. /* function exit code */
  8395. __pyx_L0:;
  8396. __Pyx_XGIVEREF(__pyx_r);
  8397. __Pyx_RefNannyFinishContext();
  8398. return __pyx_r;
  8399. }
  8400. /* Python wrapper */
  8401. static int __pyx_pw_6gevent_4ares_7channel_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
  8402. static int __pyx_pw_6gevent_4ares_7channel_4loop_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  8403. int __pyx_r;
  8404. __Pyx_RefNannyDeclarations
  8405. __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  8406. __pyx_r = __pyx_pf_6gevent_4ares_7channel_4loop_2__set__(((struct PyGeventAresChannelObject *)__pyx_v_self), ((PyObject *)__pyx_v_value));
  8407. /* function exit code */
  8408. __Pyx_RefNannyFinishContext();
  8409. return __pyx_r;
  8410. }
  8411. static int __pyx_pf_6gevent_4ares_7channel_4loop_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value) {
  8412. int __pyx_r;
  8413. __Pyx_RefNannyDeclarations
  8414. __Pyx_RefNannySetupContext("__set__", 0);
  8415. __Pyx_INCREF(__pyx_v_value);
  8416. __Pyx_GIVEREF(__pyx_v_value);
  8417. __Pyx_GOTREF(__pyx_v_self->loop);
  8418. __Pyx_DECREF(__pyx_v_self->loop);
  8419. __pyx_v_self->loop = __pyx_v_value;
  8420. /* function exit code */
  8421. __pyx_r = 0;
  8422. __Pyx_RefNannyFinishContext();
  8423. return __pyx_r;
  8424. }
  8425. /* Python wrapper */
  8426. static int __pyx_pw_6gevent_4ares_7channel_4loop_5__del__(PyObject *__pyx_v_self); /*proto*/
  8427. static int __pyx_pw_6gevent_4ares_7channel_4loop_5__del__(PyObject *__pyx_v_self) {
  8428. int __pyx_r;
  8429. __Pyx_RefNannyDeclarations
  8430. __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  8431. __pyx_r = __pyx_pf_6gevent_4ares_7channel_4loop_4__del__(((struct PyGeventAresChannelObject *)__pyx_v_self));
  8432. /* function exit code */
  8433. __Pyx_RefNannyFinishContext();
  8434. return __pyx_r;
  8435. }
  8436. static int __pyx_pf_6gevent_4ares_7channel_4loop_4__del__(struct PyGeventAresChannelObject *__pyx_v_self) {
  8437. int __pyx_r;
  8438. __Pyx_RefNannyDeclarations
  8439. __Pyx_RefNannySetupContext("__del__", 0);
  8440. __Pyx_INCREF(Py_None);
  8441. __Pyx_GIVEREF(Py_None);
  8442. __Pyx_GOTREF(__pyx_v_self->loop);
  8443. __Pyx_DECREF(__pyx_v_self->loop);
  8444. __pyx_v_self->loop = Py_None;
  8445. /* function exit code */
  8446. __pyx_r = 0;
  8447. __Pyx_RefNannyFinishContext();
  8448. return __pyx_r;
  8449. }
  8450. /* "gevent/ares.pyx":249
  8451. * cdef public object loop
  8452. * cdef ares_channeldata* channel
  8453. * cdef public dict _watchers # <<<<<<<<<<<<<<
  8454. * cdef public object _timer
  8455. *
  8456. */
  8457. /* Python wrapper */
  8458. static PyObject *__pyx_pw_6gevent_4ares_7channel_9_watchers_1__get__(PyObject *__pyx_v_self); /*proto*/
  8459. static PyObject *__pyx_pw_6gevent_4ares_7channel_9_watchers_1__get__(PyObject *__pyx_v_self) {
  8460. PyObject *__pyx_r = 0;
  8461. __Pyx_RefNannyDeclarations
  8462. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  8463. __pyx_r = __pyx_pf_6gevent_4ares_7channel_9_watchers___get__(((struct PyGeventAresChannelObject *)__pyx_v_self));
  8464. /* function exit code */
  8465. __Pyx_RefNannyFinishContext();
  8466. return __pyx_r;
  8467. }
  8468. static PyObject *__pyx_pf_6gevent_4ares_7channel_9_watchers___get__(struct PyGeventAresChannelObject *__pyx_v_self) {
  8469. PyObject *__pyx_r = NULL;
  8470. __Pyx_RefNannyDeclarations
  8471. __Pyx_RefNannySetupContext("__get__", 0);
  8472. __Pyx_XDECREF(__pyx_r);
  8473. __Pyx_INCREF(__pyx_v_self->_watchers);
  8474. __pyx_r = __pyx_v_self->_watchers;
  8475. goto __pyx_L0;
  8476. /* function exit code */
  8477. __pyx_L0:;
  8478. __Pyx_XGIVEREF(__pyx_r);
  8479. __Pyx_RefNannyFinishContext();
  8480. return __pyx_r;
  8481. }
  8482. /* Python wrapper */
  8483. static int __pyx_pw_6gevent_4ares_7channel_9_watchers_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
  8484. static int __pyx_pw_6gevent_4ares_7channel_9_watchers_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  8485. int __pyx_r;
  8486. __Pyx_RefNannyDeclarations
  8487. __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  8488. __pyx_r = __pyx_pf_6gevent_4ares_7channel_9_watchers_2__set__(((struct PyGeventAresChannelObject *)__pyx_v_self), ((PyObject *)__pyx_v_value));
  8489. /* function exit code */
  8490. __Pyx_RefNannyFinishContext();
  8491. return __pyx_r;
  8492. }
  8493. static int __pyx_pf_6gevent_4ares_7channel_9_watchers_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value) {
  8494. int __pyx_r;
  8495. __Pyx_RefNannyDeclarations
  8496. PyObject *__pyx_t_1 = NULL;
  8497. __Pyx_RefNannySetupContext("__set__", 0);
  8498. if (!(likely(PyDict_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 249, __pyx_L1_error)
  8499. __pyx_t_1 = __pyx_v_value;
  8500. __Pyx_INCREF(__pyx_t_1);
  8501. __Pyx_GIVEREF(__pyx_t_1);
  8502. __Pyx_GOTREF(__pyx_v_self->_watchers);
  8503. __Pyx_DECREF(__pyx_v_self->_watchers);
  8504. __pyx_v_self->_watchers = ((PyObject*)__pyx_t_1);
  8505. __pyx_t_1 = 0;
  8506. /* function exit code */
  8507. __pyx_r = 0;
  8508. goto __pyx_L0;
  8509. __pyx_L1_error:;
  8510. __Pyx_XDECREF(__pyx_t_1);
  8511. __Pyx_AddTraceback("gevent.ares.channel._watchers.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8512. __pyx_r = -1;
  8513. __pyx_L0:;
  8514. __Pyx_RefNannyFinishContext();
  8515. return __pyx_r;
  8516. }
  8517. /* Python wrapper */
  8518. static int __pyx_pw_6gevent_4ares_7channel_9_watchers_5__del__(PyObject *__pyx_v_self); /*proto*/
  8519. static int __pyx_pw_6gevent_4ares_7channel_9_watchers_5__del__(PyObject *__pyx_v_self) {
  8520. int __pyx_r;
  8521. __Pyx_RefNannyDeclarations
  8522. __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  8523. __pyx_r = __pyx_pf_6gevent_4ares_7channel_9_watchers_4__del__(((struct PyGeventAresChannelObject *)__pyx_v_self));
  8524. /* function exit code */
  8525. __Pyx_RefNannyFinishContext();
  8526. return __pyx_r;
  8527. }
  8528. static int __pyx_pf_6gevent_4ares_7channel_9_watchers_4__del__(struct PyGeventAresChannelObject *__pyx_v_self) {
  8529. int __pyx_r;
  8530. __Pyx_RefNannyDeclarations
  8531. __Pyx_RefNannySetupContext("__del__", 0);
  8532. __Pyx_INCREF(Py_None);
  8533. __Pyx_GIVEREF(Py_None);
  8534. __Pyx_GOTREF(__pyx_v_self->_watchers);
  8535. __Pyx_DECREF(__pyx_v_self->_watchers);
  8536. __pyx_v_self->_watchers = ((PyObject*)Py_None);
  8537. /* function exit code */
  8538. __pyx_r = 0;
  8539. __Pyx_RefNannyFinishContext();
  8540. return __pyx_r;
  8541. }
  8542. /* "gevent/ares.pyx":250
  8543. * cdef ares_channeldata* channel
  8544. * cdef public dict _watchers
  8545. * cdef public object _timer # <<<<<<<<<<<<<<
  8546. *
  8547. * def __init__(self, object loop, flags=None, timeout=None, tries=None, ndots=None,
  8548. */
  8549. /* Python wrapper */
  8550. static PyObject *__pyx_pw_6gevent_4ares_7channel_6_timer_1__get__(PyObject *__pyx_v_self); /*proto*/
  8551. static PyObject *__pyx_pw_6gevent_4ares_7channel_6_timer_1__get__(PyObject *__pyx_v_self) {
  8552. PyObject *__pyx_r = 0;
  8553. __Pyx_RefNannyDeclarations
  8554. __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  8555. __pyx_r = __pyx_pf_6gevent_4ares_7channel_6_timer___get__(((struct PyGeventAresChannelObject *)__pyx_v_self));
  8556. /* function exit code */
  8557. __Pyx_RefNannyFinishContext();
  8558. return __pyx_r;
  8559. }
  8560. static PyObject *__pyx_pf_6gevent_4ares_7channel_6_timer___get__(struct PyGeventAresChannelObject *__pyx_v_self) {
  8561. PyObject *__pyx_r = NULL;
  8562. __Pyx_RefNannyDeclarations
  8563. __Pyx_RefNannySetupContext("__get__", 0);
  8564. __Pyx_XDECREF(__pyx_r);
  8565. __Pyx_INCREF(__pyx_v_self->_timer);
  8566. __pyx_r = __pyx_v_self->_timer;
  8567. goto __pyx_L0;
  8568. /* function exit code */
  8569. __pyx_L0:;
  8570. __Pyx_XGIVEREF(__pyx_r);
  8571. __Pyx_RefNannyFinishContext();
  8572. return __pyx_r;
  8573. }
  8574. /* Python wrapper */
  8575. static int __pyx_pw_6gevent_4ares_7channel_6_timer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
  8576. static int __pyx_pw_6gevent_4ares_7channel_6_timer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  8577. int __pyx_r;
  8578. __Pyx_RefNannyDeclarations
  8579. __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  8580. __pyx_r = __pyx_pf_6gevent_4ares_7channel_6_timer_2__set__(((struct PyGeventAresChannelObject *)__pyx_v_self), ((PyObject *)__pyx_v_value));
  8581. /* function exit code */
  8582. __Pyx_RefNannyFinishContext();
  8583. return __pyx_r;
  8584. }
  8585. static int __pyx_pf_6gevent_4ares_7channel_6_timer_2__set__(struct PyGeventAresChannelObject *__pyx_v_self, PyObject *__pyx_v_value) {
  8586. int __pyx_r;
  8587. __Pyx_RefNannyDeclarations
  8588. __Pyx_RefNannySetupContext("__set__", 0);
  8589. __Pyx_INCREF(__pyx_v_value);
  8590. __Pyx_GIVEREF(__pyx_v_value);
  8591. __Pyx_GOTREF(__pyx_v_self->_timer);
  8592. __Pyx_DECREF(__pyx_v_self->_timer);
  8593. __pyx_v_self->_timer = __pyx_v_value;
  8594. /* function exit code */
  8595. __pyx_r = 0;
  8596. __Pyx_RefNannyFinishContext();
  8597. return __pyx_r;
  8598. }
  8599. /* Python wrapper */
  8600. static int __pyx_pw_6gevent_4ares_7channel_6_timer_5__del__(PyObject *__pyx_v_self); /*proto*/
  8601. static int __pyx_pw_6gevent_4ares_7channel_6_timer_5__del__(PyObject *__pyx_v_self) {
  8602. int __pyx_r;
  8603. __Pyx_RefNannyDeclarations
  8604. __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  8605. __pyx_r = __pyx_pf_6gevent_4ares_7channel_6_timer_4__del__(((struct PyGeventAresChannelObject *)__pyx_v_self));
  8606. /* function exit code */
  8607. __Pyx_RefNannyFinishContext();
  8608. return __pyx_r;
  8609. }
  8610. static int __pyx_pf_6gevent_4ares_7channel_6_timer_4__del__(struct PyGeventAresChannelObject *__pyx_v_self) {
  8611. int __pyx_r;
  8612. __Pyx_RefNannyDeclarations
  8613. __Pyx_RefNannySetupContext("__del__", 0);
  8614. __Pyx_INCREF(Py_None);
  8615. __Pyx_GIVEREF(Py_None);
  8616. __Pyx_GOTREF(__pyx_v_self->_timer);
  8617. __Pyx_DECREF(__pyx_v_self->_timer);
  8618. __pyx_v_self->_timer = Py_None;
  8619. /* function exit code */
  8620. __pyx_r = 0;
  8621. __Pyx_RefNannyFinishContext();
  8622. return __pyx_r;
  8623. }
  8624. static PyObject *__pyx_tp_new_6gevent_4ares_result(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  8625. struct __pyx_obj_6gevent_4ares_result *p;
  8626. PyObject *o;
  8627. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  8628. o = (*t->tp_alloc)(t, 0);
  8629. } else {
  8630. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  8631. }
  8632. if (unlikely(!o)) return 0;
  8633. p = ((struct __pyx_obj_6gevent_4ares_result *)o);
  8634. p->value = Py_None; Py_INCREF(Py_None);
  8635. p->exception = Py_None; Py_INCREF(Py_None);
  8636. return o;
  8637. }
  8638. static void __pyx_tp_dealloc_6gevent_4ares_result(PyObject *o) {
  8639. struct __pyx_obj_6gevent_4ares_result *p = (struct __pyx_obj_6gevent_4ares_result *)o;
  8640. #if PY_VERSION_HEX >= 0x030400a1
  8641. if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
  8642. if (PyObject_CallFinalizerFromDealloc(o)) return;
  8643. }
  8644. #endif
  8645. PyObject_GC_UnTrack(o);
  8646. Py_CLEAR(p->value);
  8647. Py_CLEAR(p->exception);
  8648. (*Py_TYPE(o)->tp_free)(o);
  8649. }
  8650. static int __pyx_tp_traverse_6gevent_4ares_result(PyObject *o, visitproc v, void *a) {
  8651. int e;
  8652. struct __pyx_obj_6gevent_4ares_result *p = (struct __pyx_obj_6gevent_4ares_result *)o;
  8653. if (p->value) {
  8654. e = (*v)(p->value, a); if (e) return e;
  8655. }
  8656. if (p->exception) {
  8657. e = (*v)(p->exception, a); if (e) return e;
  8658. }
  8659. return 0;
  8660. }
  8661. static int __pyx_tp_clear_6gevent_4ares_result(PyObject *o) {
  8662. PyObject* tmp;
  8663. struct __pyx_obj_6gevent_4ares_result *p = (struct __pyx_obj_6gevent_4ares_result *)o;
  8664. tmp = ((PyObject*)p->value);
  8665. p->value = Py_None; Py_INCREF(Py_None);
  8666. Py_XDECREF(tmp);
  8667. tmp = ((PyObject*)p->exception);
  8668. p->exception = Py_None; Py_INCREF(Py_None);
  8669. Py_XDECREF(tmp);
  8670. return 0;
  8671. }
  8672. static PyObject *__pyx_getprop_6gevent_4ares_6result_value(PyObject *o, CYTHON_UNUSED void *x) {
  8673. return __pyx_pw_6gevent_4ares_6result_5value_1__get__(o);
  8674. }
  8675. static int __pyx_setprop_6gevent_4ares_6result_value(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  8676. if (v) {
  8677. return __pyx_pw_6gevent_4ares_6result_5value_3__set__(o, v);
  8678. }
  8679. else {
  8680. return __pyx_pw_6gevent_4ares_6result_5value_5__del__(o);
  8681. }
  8682. }
  8683. static PyObject *__pyx_getprop_6gevent_4ares_6result_exception(PyObject *o, CYTHON_UNUSED void *x) {
  8684. return __pyx_pw_6gevent_4ares_6result_9exception_1__get__(o);
  8685. }
  8686. static int __pyx_setprop_6gevent_4ares_6result_exception(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  8687. if (v) {
  8688. return __pyx_pw_6gevent_4ares_6result_9exception_3__set__(o, v);
  8689. }
  8690. else {
  8691. return __pyx_pw_6gevent_4ares_6result_9exception_5__del__(o);
  8692. }
  8693. }
  8694. static PyMethodDef __pyx_methods_6gevent_4ares_result[] = {
  8695. {"successful", (PyCFunction)__pyx_pw_6gevent_4ares_6result_5successful, METH_NOARGS, 0},
  8696. {"get", (PyCFunction)__pyx_pw_6gevent_4ares_6result_7get, METH_NOARGS, 0},
  8697. {0, 0, 0, 0}
  8698. };
  8699. static struct PyGetSetDef __pyx_getsets_6gevent_4ares_result[] = {
  8700. {(char *)"value", __pyx_getprop_6gevent_4ares_6result_value, __pyx_setprop_6gevent_4ares_6result_value, (char *)0, 0},
  8701. {(char *)"exception", __pyx_getprop_6gevent_4ares_6result_exception, __pyx_setprop_6gevent_4ares_6result_exception, (char *)0, 0},
  8702. {0, 0, 0, 0, 0}
  8703. };
  8704. static PyTypeObject __pyx_type_6gevent_4ares_result = {
  8705. PyVarObject_HEAD_INIT(0, 0)
  8706. "gevent.ares.result", /*tp_name*/
  8707. sizeof(struct __pyx_obj_6gevent_4ares_result), /*tp_basicsize*/
  8708. 0, /*tp_itemsize*/
  8709. __pyx_tp_dealloc_6gevent_4ares_result, /*tp_dealloc*/
  8710. 0, /*tp_print*/
  8711. 0, /*tp_getattr*/
  8712. 0, /*tp_setattr*/
  8713. #if PY_MAJOR_VERSION < 3
  8714. 0, /*tp_compare*/
  8715. #endif
  8716. #if PY_MAJOR_VERSION >= 3
  8717. 0, /*tp_as_async*/
  8718. #endif
  8719. __pyx_pw_6gevent_4ares_6result_3__repr__, /*tp_repr*/
  8720. 0, /*tp_as_number*/
  8721. 0, /*tp_as_sequence*/
  8722. 0, /*tp_as_mapping*/
  8723. 0, /*tp_hash*/
  8724. 0, /*tp_call*/
  8725. 0, /*tp_str*/
  8726. 0, /*tp_getattro*/
  8727. 0, /*tp_setattro*/
  8728. 0, /*tp_as_buffer*/
  8729. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  8730. 0, /*tp_doc*/
  8731. __pyx_tp_traverse_6gevent_4ares_result, /*tp_traverse*/
  8732. __pyx_tp_clear_6gevent_4ares_result, /*tp_clear*/
  8733. 0, /*tp_richcompare*/
  8734. 0, /*tp_weaklistoffset*/
  8735. 0, /*tp_iter*/
  8736. 0, /*tp_iternext*/
  8737. __pyx_methods_6gevent_4ares_result, /*tp_methods*/
  8738. 0, /*tp_members*/
  8739. __pyx_getsets_6gevent_4ares_result, /*tp_getset*/
  8740. 0, /*tp_base*/
  8741. 0, /*tp_dict*/
  8742. 0, /*tp_descr_get*/
  8743. 0, /*tp_descr_set*/
  8744. 0, /*tp_dictoffset*/
  8745. __pyx_pw_6gevent_4ares_6result_1__init__, /*tp_init*/
  8746. 0, /*tp_alloc*/
  8747. __pyx_tp_new_6gevent_4ares_result, /*tp_new*/
  8748. 0, /*tp_free*/
  8749. 0, /*tp_is_gc*/
  8750. 0, /*tp_bases*/
  8751. 0, /*tp_mro*/
  8752. 0, /*tp_cache*/
  8753. 0, /*tp_subclasses*/
  8754. 0, /*tp_weaklist*/
  8755. 0, /*tp_del*/
  8756. 0, /*tp_version_tag*/
  8757. #if PY_VERSION_HEX >= 0x030400a1
  8758. 0, /*tp_finalize*/
  8759. #endif
  8760. };
  8761. static struct __pyx_vtabstruct_6gevent_4ares_channel __pyx_vtable_6gevent_4ares_channel;
  8762. static PyObject *__pyx_tp_new_6gevent_4ares_channel(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  8763. struct PyGeventAresChannelObject *p;
  8764. PyObject *o;
  8765. if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
  8766. o = (*t->tp_alloc)(t, 0);
  8767. } else {
  8768. o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  8769. }
  8770. if (unlikely(!o)) return 0;
  8771. p = ((struct PyGeventAresChannelObject *)o);
  8772. p->__pyx_vtab = __pyx_vtabptr_6gevent_4ares_channel;
  8773. p->loop = Py_None; Py_INCREF(Py_None);
  8774. p->_watchers = ((PyObject*)Py_None); Py_INCREF(Py_None);
  8775. p->_timer = Py_None; Py_INCREF(Py_None);
  8776. return o;
  8777. }
  8778. static void __pyx_tp_dealloc_6gevent_4ares_channel(PyObject *o) {
  8779. struct PyGeventAresChannelObject *p = (struct PyGeventAresChannelObject *)o;
  8780. #if PY_VERSION_HEX >= 0x030400a1
  8781. if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
  8782. if (PyObject_CallFinalizerFromDealloc(o)) return;
  8783. }
  8784. #endif
  8785. PyObject_GC_UnTrack(o);
  8786. {
  8787. PyObject *etype, *eval, *etb;
  8788. PyErr_Fetch(&etype, &eval, &etb);
  8789. ++Py_REFCNT(o);
  8790. __pyx_pw_6gevent_4ares_7channel_7__dealloc__(o);
  8791. --Py_REFCNT(o);
  8792. PyErr_Restore(etype, eval, etb);
  8793. }
  8794. Py_CLEAR(p->loop);
  8795. Py_CLEAR(p->_watchers);
  8796. Py_CLEAR(p->_timer);
  8797. (*Py_TYPE(o)->tp_free)(o);
  8798. }
  8799. static int __pyx_tp_traverse_6gevent_4ares_channel(PyObject *o, visitproc v, void *a) {
  8800. int e;
  8801. struct PyGeventAresChannelObject *p = (struct PyGeventAresChannelObject *)o;
  8802. if (p->loop) {
  8803. e = (*v)(p->loop, a); if (e) return e;
  8804. }
  8805. if (p->_watchers) {
  8806. e = (*v)(p->_watchers, a); if (e) return e;
  8807. }
  8808. if (p->_timer) {
  8809. e = (*v)(p->_timer, a); if (e) return e;
  8810. }
  8811. return 0;
  8812. }
  8813. static int __pyx_tp_clear_6gevent_4ares_channel(PyObject *o) {
  8814. PyObject* tmp;
  8815. struct PyGeventAresChannelObject *p = (struct PyGeventAresChannelObject *)o;
  8816. tmp = ((PyObject*)p->loop);
  8817. p->loop = Py_None; Py_INCREF(Py_None);
  8818. Py_XDECREF(tmp);
  8819. tmp = ((PyObject*)p->_watchers);
  8820. p->_watchers = ((PyObject*)Py_None); Py_INCREF(Py_None);
  8821. Py_XDECREF(tmp);
  8822. tmp = ((PyObject*)p->_timer);
  8823. p->_timer = Py_None; Py_INCREF(Py_None);
  8824. Py_XDECREF(tmp);
  8825. return 0;
  8826. }
  8827. static PyObject *__pyx_getprop_6gevent_4ares_7channel_loop(PyObject *o, CYTHON_UNUSED void *x) {
  8828. return __pyx_pw_6gevent_4ares_7channel_4loop_1__get__(o);
  8829. }
  8830. static int __pyx_setprop_6gevent_4ares_7channel_loop(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  8831. if (v) {
  8832. return __pyx_pw_6gevent_4ares_7channel_4loop_3__set__(o, v);
  8833. }
  8834. else {
  8835. return __pyx_pw_6gevent_4ares_7channel_4loop_5__del__(o);
  8836. }
  8837. }
  8838. static PyObject *__pyx_getprop_6gevent_4ares_7channel__watchers(PyObject *o, CYTHON_UNUSED void *x) {
  8839. return __pyx_pw_6gevent_4ares_7channel_9_watchers_1__get__(o);
  8840. }
  8841. static int __pyx_setprop_6gevent_4ares_7channel__watchers(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  8842. if (v) {
  8843. return __pyx_pw_6gevent_4ares_7channel_9_watchers_3__set__(o, v);
  8844. }
  8845. else {
  8846. return __pyx_pw_6gevent_4ares_7channel_9_watchers_5__del__(o);
  8847. }
  8848. }
  8849. static PyObject *__pyx_getprop_6gevent_4ares_7channel__timer(PyObject *o, CYTHON_UNUSED void *x) {
  8850. return __pyx_pw_6gevent_4ares_7channel_6_timer_1__get__(o);
  8851. }
  8852. static int __pyx_setprop_6gevent_4ares_7channel__timer(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  8853. if (v) {
  8854. return __pyx_pw_6gevent_4ares_7channel_6_timer_3__set__(o, v);
  8855. }
  8856. else {
  8857. return __pyx_pw_6gevent_4ares_7channel_6_timer_5__del__(o);
  8858. }
  8859. }
  8860. static PyMethodDef __pyx_methods_6gevent_4ares_channel[] = {
  8861. {"destroy", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_5destroy, METH_NOARGS, 0},
  8862. {"set_servers", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_9set_servers, METH_VARARGS|METH_KEYWORDS, 0},
  8863. {"_on_timer", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_11_on_timer, METH_NOARGS, 0},
  8864. {"_process_fd", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_13_process_fd, METH_VARARGS|METH_KEYWORDS, 0},
  8865. {"gethostbyname", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_15gethostbyname, METH_VARARGS|METH_KEYWORDS, 0},
  8866. {"gethostbyaddr", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_17gethostbyaddr, METH_VARARGS|METH_KEYWORDS, 0},
  8867. {"_getnameinfo", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_19_getnameinfo, METH_VARARGS|METH_KEYWORDS, 0},
  8868. {"getnameinfo", (PyCFunction)__pyx_pw_6gevent_4ares_7channel_21getnameinfo, METH_VARARGS|METH_KEYWORDS, 0},
  8869. {0, 0, 0, 0}
  8870. };
  8871. static struct PyGetSetDef __pyx_getsets_6gevent_4ares_channel[] = {
  8872. {(char *)"loop", __pyx_getprop_6gevent_4ares_7channel_loop, __pyx_setprop_6gevent_4ares_7channel_loop, (char *)0, 0},
  8873. {(char *)"_watchers", __pyx_getprop_6gevent_4ares_7channel__watchers, __pyx_setprop_6gevent_4ares_7channel__watchers, (char *)0, 0},
  8874. {(char *)"_timer", __pyx_getprop_6gevent_4ares_7channel__timer, __pyx_setprop_6gevent_4ares_7channel__timer, (char *)0, 0},
  8875. {0, 0, 0, 0, 0}
  8876. };
  8877. DL_EXPORT(PyTypeObject) PyGeventAresChannel_Type = {
  8878. PyVarObject_HEAD_INIT(0, 0)
  8879. "gevent.ares.channel", /*tp_name*/
  8880. sizeof(struct PyGeventAresChannelObject), /*tp_basicsize*/
  8881. 0, /*tp_itemsize*/
  8882. __pyx_tp_dealloc_6gevent_4ares_channel, /*tp_dealloc*/
  8883. 0, /*tp_print*/
  8884. 0, /*tp_getattr*/
  8885. 0, /*tp_setattr*/
  8886. #if PY_MAJOR_VERSION < 3
  8887. 0, /*tp_compare*/
  8888. #endif
  8889. #if PY_MAJOR_VERSION >= 3
  8890. 0, /*tp_as_async*/
  8891. #endif
  8892. __pyx_pw_6gevent_4ares_7channel_3__repr__, /*tp_repr*/
  8893. 0, /*tp_as_number*/
  8894. 0, /*tp_as_sequence*/
  8895. 0, /*tp_as_mapping*/
  8896. 0, /*tp_hash*/
  8897. 0, /*tp_call*/
  8898. 0, /*tp_str*/
  8899. 0, /*tp_getattro*/
  8900. 0, /*tp_setattro*/
  8901. 0, /*tp_as_buffer*/
  8902. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  8903. 0, /*tp_doc*/
  8904. __pyx_tp_traverse_6gevent_4ares_channel, /*tp_traverse*/
  8905. __pyx_tp_clear_6gevent_4ares_channel, /*tp_clear*/
  8906. 0, /*tp_richcompare*/
  8907. 0, /*tp_weaklistoffset*/
  8908. 0, /*tp_iter*/
  8909. 0, /*tp_iternext*/
  8910. __pyx_methods_6gevent_4ares_channel, /*tp_methods*/
  8911. 0, /*tp_members*/
  8912. __pyx_getsets_6gevent_4ares_channel, /*tp_getset*/
  8913. 0, /*tp_base*/
  8914. 0, /*tp_dict*/
  8915. 0, /*tp_descr_get*/
  8916. 0, /*tp_descr_set*/
  8917. 0, /*tp_dictoffset*/
  8918. __pyx_pw_6gevent_4ares_7channel_1__init__, /*tp_init*/
  8919. 0, /*tp_alloc*/
  8920. __pyx_tp_new_6gevent_4ares_channel, /*tp_new*/
  8921. 0, /*tp_free*/
  8922. 0, /*tp_is_gc*/
  8923. 0, /*tp_bases*/
  8924. 0, /*tp_mro*/
  8925. 0, /*tp_cache*/
  8926. 0, /*tp_subclasses*/
  8927. 0, /*tp_weaklist*/
  8928. 0, /*tp_del*/
  8929. 0, /*tp_version_tag*/
  8930. #if PY_VERSION_HEX >= 0x030400a1
  8931. 0, /*tp_finalize*/
  8932. #endif
  8933. };
  8934. static PyMethodDef __pyx_methods[] = {
  8935. {"_convert_cares_flags", (PyCFunction)__pyx_pw_6gevent_4ares_1_convert_cares_flags, METH_VARARGS|METH_KEYWORDS, 0},
  8936. {"strerror", (PyCFunction)__pyx_pw_6gevent_4ares_3strerror, METH_O, 0},
  8937. {0, 0, 0, 0}
  8938. };
  8939. #if PY_MAJOR_VERSION >= 3
  8940. static struct PyModuleDef __pyx_moduledef = {
  8941. #if PY_VERSION_HEX < 0x03020000
  8942. { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  8943. #else
  8944. PyModuleDef_HEAD_INIT,
  8945. #endif
  8946. "ares",
  8947. 0, /* m_doc */
  8948. -1, /* m_size */
  8949. __pyx_methods /* m_methods */,
  8950. NULL, /* m_reload */
  8951. NULL, /* m_traverse */
  8952. NULL, /* m_clear */
  8953. NULL /* m_free */
  8954. };
  8955. #endif
  8956. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  8957. {&__pyx_n_s_ARES_EADDRGETNETWORKPARAMS, __pyx_k_ARES_EADDRGETNETWORKPARAMS, sizeof(__pyx_k_ARES_EADDRGETNETWORKPARAMS), 0, 0, 1, 1},
  8958. {&__pyx_n_s_ARES_EBADFAMILY, __pyx_k_ARES_EBADFAMILY, sizeof(__pyx_k_ARES_EBADFAMILY), 0, 0, 1, 1},
  8959. {&__pyx_n_s_ARES_EBADFLAGS, __pyx_k_ARES_EBADFLAGS, sizeof(__pyx_k_ARES_EBADFLAGS), 0, 0, 1, 1},
  8960. {&__pyx_n_s_ARES_EBADHINTS, __pyx_k_ARES_EBADHINTS, sizeof(__pyx_k_ARES_EBADHINTS), 0, 0, 1, 1},
  8961. {&__pyx_n_s_ARES_EBADNAME, __pyx_k_ARES_EBADNAME, sizeof(__pyx_k_ARES_EBADNAME), 0, 0, 1, 1},
  8962. {&__pyx_n_s_ARES_EBADQUERY, __pyx_k_ARES_EBADQUERY, sizeof(__pyx_k_ARES_EBADQUERY), 0, 0, 1, 1},
  8963. {&__pyx_n_s_ARES_EBADRESP, __pyx_k_ARES_EBADRESP, sizeof(__pyx_k_ARES_EBADRESP), 0, 0, 1, 1},
  8964. {&__pyx_n_s_ARES_EBADSTR, __pyx_k_ARES_EBADSTR, sizeof(__pyx_k_ARES_EBADSTR), 0, 0, 1, 1},
  8965. {&__pyx_n_s_ARES_ECANCELLED, __pyx_k_ARES_ECANCELLED, sizeof(__pyx_k_ARES_ECANCELLED), 0, 0, 1, 1},
  8966. {&__pyx_n_s_ARES_ECONNREFUSED, __pyx_k_ARES_ECONNREFUSED, sizeof(__pyx_k_ARES_ECONNREFUSED), 0, 0, 1, 1},
  8967. {&__pyx_n_s_ARES_EDESTRUCTION, __pyx_k_ARES_EDESTRUCTION, sizeof(__pyx_k_ARES_EDESTRUCTION), 0, 0, 1, 1},
  8968. {&__pyx_n_s_ARES_EFILE, __pyx_k_ARES_EFILE, sizeof(__pyx_k_ARES_EFILE), 0, 0, 1, 1},
  8969. {&__pyx_n_s_ARES_EFORMERR, __pyx_k_ARES_EFORMERR, sizeof(__pyx_k_ARES_EFORMERR), 0, 0, 1, 1},
  8970. {&__pyx_n_s_ARES_ELOADIPHLPAPI, __pyx_k_ARES_ELOADIPHLPAPI, sizeof(__pyx_k_ARES_ELOADIPHLPAPI), 0, 0, 1, 1},
  8971. {&__pyx_n_s_ARES_ENODATA, __pyx_k_ARES_ENODATA, sizeof(__pyx_k_ARES_ENODATA), 0, 0, 1, 1},
  8972. {&__pyx_n_s_ARES_ENOMEM, __pyx_k_ARES_ENOMEM, sizeof(__pyx_k_ARES_ENOMEM), 0, 0, 1, 1},
  8973. {&__pyx_n_s_ARES_ENONAME, __pyx_k_ARES_ENONAME, sizeof(__pyx_k_ARES_ENONAME), 0, 0, 1, 1},
  8974. {&__pyx_n_s_ARES_ENOTFOUND, __pyx_k_ARES_ENOTFOUND, sizeof(__pyx_k_ARES_ENOTFOUND), 0, 0, 1, 1},
  8975. {&__pyx_n_s_ARES_ENOTIMP, __pyx_k_ARES_ENOTIMP, sizeof(__pyx_k_ARES_ENOTIMP), 0, 0, 1, 1},
  8976. {&__pyx_n_s_ARES_ENOTINITIALIZED, __pyx_k_ARES_ENOTINITIALIZED, sizeof(__pyx_k_ARES_ENOTINITIALIZED), 0, 0, 1, 1},
  8977. {&__pyx_n_s_ARES_EOF, __pyx_k_ARES_EOF, sizeof(__pyx_k_ARES_EOF), 0, 0, 1, 1},
  8978. {&__pyx_n_s_ARES_EREFUSED, __pyx_k_ARES_EREFUSED, sizeof(__pyx_k_ARES_EREFUSED), 0, 0, 1, 1},
  8979. {&__pyx_n_s_ARES_ESERVFAIL, __pyx_k_ARES_ESERVFAIL, sizeof(__pyx_k_ARES_ESERVFAIL), 0, 0, 1, 1},
  8980. {&__pyx_n_s_ARES_ETIMEOUT, __pyx_k_ARES_ETIMEOUT, sizeof(__pyx_k_ARES_ETIMEOUT), 0, 0, 1, 1},
  8981. {&__pyx_n_s_ARES_FLAG_IGNTC, __pyx_k_ARES_FLAG_IGNTC, sizeof(__pyx_k_ARES_FLAG_IGNTC), 0, 0, 1, 1},
  8982. {&__pyx_n_s_ARES_FLAG_NOALIASES, __pyx_k_ARES_FLAG_NOALIASES, sizeof(__pyx_k_ARES_FLAG_NOALIASES), 0, 0, 1, 1},
  8983. {&__pyx_n_s_ARES_FLAG_NOCHECKRESP, __pyx_k_ARES_FLAG_NOCHECKRESP, sizeof(__pyx_k_ARES_FLAG_NOCHECKRESP), 0, 0, 1, 1},
  8984. {&__pyx_n_s_ARES_FLAG_NORECURSE, __pyx_k_ARES_FLAG_NORECURSE, sizeof(__pyx_k_ARES_FLAG_NORECURSE), 0, 0, 1, 1},
  8985. {&__pyx_n_s_ARES_FLAG_NOSEARCH, __pyx_k_ARES_FLAG_NOSEARCH, sizeof(__pyx_k_ARES_FLAG_NOSEARCH), 0, 0, 1, 1},
  8986. {&__pyx_n_s_ARES_FLAG_PRIMARY, __pyx_k_ARES_FLAG_PRIMARY, sizeof(__pyx_k_ARES_FLAG_PRIMARY), 0, 0, 1, 1},
  8987. {&__pyx_n_s_ARES_FLAG_STAYOPEN, __pyx_k_ARES_FLAG_STAYOPEN, sizeof(__pyx_k_ARES_FLAG_STAYOPEN), 0, 0, 1, 1},
  8988. {&__pyx_n_s_ARES_FLAG_USEVC, __pyx_k_ARES_FLAG_USEVC, sizeof(__pyx_k_ARES_FLAG_USEVC), 0, 0, 1, 1},
  8989. {&__pyx_n_s_ARES_SUCCESS, __pyx_k_ARES_SUCCESS, sizeof(__pyx_k_ARES_SUCCESS), 0, 0, 1, 1},
  8990. {&__pyx_kp_s_Bad_value_for_ai_flags_0x_x, __pyx_k_Bad_value_for_ai_flags_0x_x, sizeof(__pyx_k_Bad_value_for_ai_flags_0x_x), 0, 0, 1, 0},
  8991. {&__pyx_kp_s_C_projects_gevent_src_gevent_are, __pyx_k_C_projects_gevent_src_gevent_are, sizeof(__pyx_k_C_projects_gevent_src_gevent_are), 0, 0, 1, 0},
  8992. {&__pyx_n_s_InvalidIP, __pyx_k_InvalidIP, sizeof(__pyx_k_InvalidIP), 0, 0, 1, 1},
  8993. {&__pyx_kp_s_Invalid_value_for_port_r, __pyx_k_Invalid_value_for_port_r, sizeof(__pyx_k_Invalid_value_for_port_r), 0, 0, 1, 0},
  8994. {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
  8995. {&__pyx_n_s_NI_DGRAM, __pyx_k_NI_DGRAM, sizeof(__pyx_k_NI_DGRAM), 0, 0, 1, 1},
  8996. {&__pyx_n_s_NI_NAMEREQD, __pyx_k_NI_NAMEREQD, sizeof(__pyx_k_NI_NAMEREQD), 0, 0, 1, 1},
  8997. {&__pyx_n_s_NI_NOFQDN, __pyx_k_NI_NOFQDN, sizeof(__pyx_k_NI_NOFQDN), 0, 0, 1, 1},
  8998. {&__pyx_n_s_NI_NUMERICHOST, __pyx_k_NI_NUMERICHOST, sizeof(__pyx_k_NI_NUMERICHOST), 0, 0, 1, 1},
  8999. {&__pyx_n_s_NI_NUMERICSERV, __pyx_k_NI_NUMERICSERV, sizeof(__pyx_k_NI_NUMERICSERV), 0, 0, 1, 1},
  9000. {&__pyx_n_s_TIMEOUT, __pyx_k_TIMEOUT, sizeof(__pyx_k_TIMEOUT), 0, 0, 1, 1},
  9001. {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  9002. {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  9003. {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
  9004. {&__pyx_n_s_addr, __pyx_k_addr, sizeof(__pyx_k_addr), 0, 0, 1, 1},
  9005. {&__pyx_n_s_again, __pyx_k_again, sizeof(__pyx_k_again), 0, 0, 1, 1},
  9006. {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
  9007. {&__pyx_n_s_ares_errors, __pyx_k_ares_errors, sizeof(__pyx_k_ares_errors), 0, 0, 1, 1},
  9008. {&__pyx_n_s_ares_host_result, __pyx_k_ares_host_result, sizeof(__pyx_k_ares_host_result), 0, 0, 1, 1},
  9009. {&__pyx_n_s_ares_host_result___getnewargs, __pyx_k_ares_host_result___getnewargs, sizeof(__pyx_k_ares_host_result___getnewargs), 0, 0, 1, 1},
  9010. {&__pyx_n_s_ares_host_result___new, __pyx_k_ares_host_result___new, sizeof(__pyx_k_ares_host_result___new), 0, 0, 1, 1},
  9011. {&__pyx_n_s_ascii, __pyx_k_ascii, sizeof(__pyx_k_ascii), 0, 0, 1, 1},
  9012. {&__pyx_n_s_basestring, __pyx_k_basestring, sizeof(__pyx_k_basestring), 0, 0, 1, 1},
  9013. {&__pyx_n_s_builtins, __pyx_k_builtins, sizeof(__pyx_k_builtins), 0, 0, 1, 1},
  9014. {&__pyx_n_s_callback, __pyx_k_callback, sizeof(__pyx_k_callback), 0, 0, 1, 1},
  9015. {&__pyx_n_s_cares_flag_map, __pyx_k_cares_flag_map, sizeof(__pyx_k_cares_flag_map), 0, 0, 1, 1},
  9016. {&__pyx_n_s_channel, __pyx_k_channel, sizeof(__pyx_k_channel), 0, 0, 1, 1},
  9017. {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
  9018. {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1},
  9019. {&__pyx_n_s_default, __pyx_k_default, sizeof(__pyx_k_default), 0, 0, 1, 1},
  9020. {&__pyx_n_s_destroy, __pyx_k_destroy, sizeof(__pyx_k_destroy), 0, 0, 1, 1},
  9021. {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  9022. {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  9023. {&__pyx_n_s_events, __pyx_k_events, sizeof(__pyx_k_events), 0, 0, 1, 1},
  9024. {&__pyx_n_s_exc_info, __pyx_k_exc_info, sizeof(__pyx_k_exc_info), 0, 0, 1, 1},
  9025. {&__pyx_n_s_exception, __pyx_k_exception, sizeof(__pyx_k_exception), 0, 0, 1, 1},
  9026. {&__pyx_kp_s_expected_a_tuple_got_r, __pyx_k_expected_a_tuple_got_r, sizeof(__pyx_k_expected_a_tuple_got_r), 0, 0, 1, 0},
  9027. {&__pyx_n_s_family, __pyx_k_family, sizeof(__pyx_k_family), 0, 0, 1, 1},
  9028. {&__pyx_n_s_fd, __pyx_k_fd, sizeof(__pyx_k_fd), 0, 0, 1, 1},
  9029. {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
  9030. {&__pyx_n_s_gaierror, __pyx_k_gaierror, sizeof(__pyx_k_gaierror), 0, 0, 1, 1},
  9031. {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  9032. {&__pyx_n_s_getnameinfo, __pyx_k_getnameinfo, sizeof(__pyx_k_getnameinfo), 0, 0, 1, 1},
  9033. {&__pyx_n_s_getnewargs, __pyx_k_getnewargs, sizeof(__pyx_k_getnewargs), 0, 0, 1, 1},
  9034. {&__pyx_n_s_gevent_ares, __pyx_k_gevent_ares, sizeof(__pyx_k_gevent_ares), 0, 0, 1, 1},
  9035. {&__pyx_n_s_handle_error, __pyx_k_handle_error, sizeof(__pyx_k_handle_error), 0, 0, 1, 1},
  9036. {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
  9037. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  9038. {&__pyx_n_s_io, __pyx_k_io, sizeof(__pyx_k_io), 0, 0, 1, 1},
  9039. {&__pyx_n_s_iterable, __pyx_k_iterable, sizeof(__pyx_k_iterable), 0, 0, 1, 1},
  9040. {&__pyx_n_s_loop, __pyx_k_loop, sizeof(__pyx_k_loop), 0, 0, 1, 1},
  9041. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  9042. {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  9043. {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  9044. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  9045. {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
  9046. {&__pyx_n_s_ndots, __pyx_k_ndots, sizeof(__pyx_k_ndots), 0, 0, 1, 1},
  9047. {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  9048. {&__pyx_n_s_on_timer, __pyx_k_on_timer, sizeof(__pyx_k_on_timer), 0, 0, 1, 1},
  9049. {&__pyx_n_s_pass_events, __pyx_k_pass_events, sizeof(__pyx_k_pass_events), 0, 0, 1, 1},
  9050. {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
  9051. {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  9052. {&__pyx_n_s_process_fd, __pyx_k_process_fd, sizeof(__pyx_k_process_fd), 0, 0, 1, 1},
  9053. {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  9054. {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  9055. {&__pyx_kp_s_s_at_0x_x__timer_r__watchers_s, __pyx_k_s_at_0x_x__timer_r__watchers_s, sizeof(__pyx_k_s_at_0x_x__timer_r__watchers_s), 0, 0, 1, 0},
  9056. {&__pyx_kp_s_s_exception_r, __pyx_k_s_exception_r, sizeof(__pyx_k_s_exception_r), 0, 0, 1, 0},
  9057. {&__pyx_kp_s_s_r, __pyx_k_s_r, sizeof(__pyx_k_s_r), 0, 0, 1, 0},
  9058. {&__pyx_kp_s_s_s, __pyx_k_s_s, sizeof(__pyx_k_s_s), 0, 0, 1, 0},
  9059. {&__pyx_kp_s_s_value_r_exception_r, __pyx_k_s_value_r_exception_r, sizeof(__pyx_k_s_value_r_exception_r), 0, 0, 1, 0},
  9060. {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  9061. {&__pyx_n_s_servers, __pyx_k_servers, sizeof(__pyx_k_servers), 0, 0, 1, 1},
  9062. {&__pyx_n_s_set_servers, __pyx_k_set_servers, sizeof(__pyx_k_set_servers), 0, 0, 1, 1},
  9063. {&__pyx_n_s_sockaddr, __pyx_k_sockaddr, sizeof(__pyx_k_sockaddr), 0, 0, 1, 1},
  9064. {&__pyx_n_s_socket, __pyx_k_socket, sizeof(__pyx_k_socket), 0, 0, 1, 1},
  9065. {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  9066. {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  9067. {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
  9068. {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
  9069. {&__pyx_n_s_tcp_port, __pyx_k_tcp_port, sizeof(__pyx_k_tcp_port), 0, 0, 1, 1},
  9070. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  9071. {&__pyx_kp_s_this_ares_channel_has_been_destr, __pyx_k_this_ares_channel_has_been_destr, sizeof(__pyx_k_this_ares_channel_has_been_destr), 0, 0, 1, 0},
  9072. {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1},
  9073. {&__pyx_n_s_timer, __pyx_k_timer, sizeof(__pyx_k_timer), 0, 0, 1, 1},
  9074. {&__pyx_n_s_tries, __pyx_k_tries, sizeof(__pyx_k_tries), 0, 0, 1, 1},
  9075. {&__pyx_n_s_udp_port, __pyx_k_udp_port, sizeof(__pyx_k_udp_port), 0, 0, 1, 1},
  9076. {&__pyx_n_s_unicode, __pyx_k_unicode, sizeof(__pyx_k_unicode), 0, 0, 1, 1},
  9077. {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  9078. {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1},
  9079. {&__pyx_n_s_watcher, __pyx_k_watcher, sizeof(__pyx_k_watcher), 0, 0, 1, 1},
  9080. {0, 0, 0, 0, 0, 0, 0}
  9081. };
  9082. static int __Pyx_InitCachedBuiltins(void) {
  9083. __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 153, __pyx_L1_error)
  9084. __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(0, 296, __pyx_L1_error)
  9085. __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 330, __pyx_L1_error)
  9086. __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 436, __pyx_L1_error)
  9087. return 0;
  9088. __pyx_L1_error:;
  9089. return -1;
  9090. }
  9091. static int __Pyx_InitCachedConstants(void) {
  9092. __Pyx_RefNannyDeclarations
  9093. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  9094. /* "gevent/ares.pyx":320
  9095. * servers = []
  9096. * if isinstance(servers, string_types):
  9097. * servers = servers.split(',') # <<<<<<<<<<<<<<
  9098. * cdef int length = len(servers)
  9099. * cdef int result, index
  9100. */
  9101. __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s__2); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 320, __pyx_L1_error)
  9102. __Pyx_GOTREF(__pyx_tuple__3);
  9103. __Pyx_GIVEREF(__pyx_tuple__3);
  9104. /* "gevent/ares.pyx":335
  9105. * for server in servers:
  9106. * if isinstance(server, unicode):
  9107. * server = server.encode('ascii') # <<<<<<<<<<<<<<
  9108. * string = <char*?>server
  9109. * if cares.ares_inet_pton(AF_INET, string, &c_servers[index].addr) > 0:
  9110. */
  9111. __pyx_tuple__4 = PyTuple_Pack(1, __pyx_n_s_ascii); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 335, __pyx_L1_error)
  9112. __Pyx_GOTREF(__pyx_tuple__4);
  9113. __Pyx_GIVEREF(__pyx_tuple__4);
  9114. /* "gevent/ares.pyx":192
  9115. * class ares_host_result(tuple):
  9116. *
  9117. * def __new__(cls, family, iterable): # <<<<<<<<<<<<<<
  9118. * cdef object self = tuple.__new__(cls, iterable)
  9119. * self.family = family
  9120. */
  9121. __pyx_tuple__6 = PyTuple_Pack(4, __pyx_n_s_cls, __pyx_n_s_family, __pyx_n_s_iterable, __pyx_n_s_self); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 192, __pyx_L1_error)
  9122. __Pyx_GOTREF(__pyx_tuple__6);
  9123. __Pyx_GIVEREF(__pyx_tuple__6);
  9124. __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent_are, __pyx_n_s_new, 192, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 192, __pyx_L1_error)
  9125. /* "gevent/ares.pyx":197
  9126. * return self
  9127. *
  9128. * def __getnewargs__(self): # <<<<<<<<<<<<<<
  9129. * return (self.family, tuple(self))
  9130. *
  9131. */
  9132. __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 197, __pyx_L1_error)
  9133. __Pyx_GOTREF(__pyx_tuple__8);
  9134. __Pyx_GIVEREF(__pyx_tuple__8);
  9135. __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_C_projects_gevent_src_gevent_are, __pyx_n_s_getnewargs, 197, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 197, __pyx_L1_error)
  9136. __Pyx_RefNannyFinishContext();
  9137. return 0;
  9138. __pyx_L1_error:;
  9139. __Pyx_RefNannyFinishContext();
  9140. return -1;
  9141. }
  9142. static int __Pyx_InitGlobals(void) {
  9143. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  9144. __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  9145. __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  9146. __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
  9147. __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  9148. __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) __PYX_ERR(0, 1, __pyx_L1_error)
  9149. __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) __PYX_ERR(0, 1, __pyx_L1_error)
  9150. __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  9151. __pyx_int_neg_8 = PyInt_FromLong(-8); if (unlikely(!__pyx_int_neg_8)) __PYX_ERR(0, 1, __pyx_L1_error)
  9152. return 0;
  9153. __pyx_L1_error:;
  9154. return -1;
  9155. }
  9156. #if PY_MAJOR_VERSION < 3
  9157. PyMODINIT_FUNC initares(void); /*proto*/
  9158. PyMODINIT_FUNC initares(void)
  9159. #else
  9160. PyMODINIT_FUNC PyInit_ares(void); /*proto*/
  9161. PyMODINIT_FUNC PyInit_ares(void)
  9162. #endif
  9163. {
  9164. PyObject *__pyx_t_1 = NULL;
  9165. PyObject *__pyx_t_2 = NULL;
  9166. int __pyx_t_3;
  9167. PyObject *__pyx_t_4 = NULL;
  9168. PyObject *__pyx_t_5 = NULL;
  9169. PyObject *__pyx_t_6 = NULL;
  9170. PyObject *__pyx_t_7 = NULL;
  9171. PyObject *__pyx_t_8 = NULL;
  9172. PyObject *__pyx_t_9 = NULL;
  9173. PyObject *__pyx_t_10 = NULL;
  9174. PyObject *__pyx_t_11 = NULL;
  9175. PyObject *__pyx_t_12 = NULL;
  9176. PyObject *__pyx_t_13 = NULL;
  9177. PyObject *__pyx_t_14 = NULL;
  9178. PyObject *__pyx_t_15 = NULL;
  9179. PyObject *__pyx_t_16 = NULL;
  9180. PyObject *__pyx_t_17 = NULL;
  9181. PyObject *__pyx_t_18 = NULL;
  9182. PyObject *__pyx_t_19 = NULL;
  9183. PyObject *__pyx_t_20 = NULL;
  9184. PyObject *__pyx_t_21 = NULL;
  9185. PyObject *__pyx_t_22 = NULL;
  9186. PyObject *__pyx_t_23 = NULL;
  9187. PyObject *__pyx_t_24 = NULL;
  9188. PyObject *__pyx_t_25 = NULL;
  9189. PyObject *__pyx_t_26 = NULL;
  9190. PyObject *__pyx_t_27 = NULL;
  9191. __Pyx_RefNannyDeclarations
  9192. #if CYTHON_REFNANNY
  9193. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  9194. if (!__Pyx_RefNanny) {
  9195. PyErr_Clear();
  9196. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  9197. if (!__Pyx_RefNanny)
  9198. Py_FatalError("failed to import 'refnanny' module");
  9199. }
  9200. #endif
  9201. __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_ares(void)", 0);
  9202. if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  9203. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  9204. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  9205. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  9206. #ifdef __Pyx_CyFunction_USED
  9207. if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  9208. #endif
  9209. #ifdef __Pyx_FusedFunction_USED
  9210. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  9211. #endif
  9212. #ifdef __Pyx_Coroutine_USED
  9213. if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  9214. #endif
  9215. #ifdef __Pyx_Generator_USED
  9216. if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  9217. #endif
  9218. #ifdef __Pyx_StopAsyncIteration_USED
  9219. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  9220. #endif
  9221. /*--- Library function declarations ---*/
  9222. /*--- Threads initialization code ---*/
  9223. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  9224. #ifdef WITH_THREAD /* Python build with threading support? */
  9225. PyEval_InitThreads();
  9226. #endif
  9227. #endif
  9228. /*--- Module creation code ---*/
  9229. #if PY_MAJOR_VERSION < 3
  9230. __pyx_m = Py_InitModule4("ares", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  9231. #else
  9232. __pyx_m = PyModule_Create(&__pyx_moduledef);
  9233. #endif
  9234. if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  9235. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  9236. Py_INCREF(__pyx_d);
  9237. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  9238. #if CYTHON_COMPILING_IN_PYPY
  9239. Py_INCREF(__pyx_b);
  9240. #endif
  9241. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  9242. /*--- Initialize various global constants etc. ---*/
  9243. if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  9244. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  9245. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  9246. #endif
  9247. if (__pyx_module_is_main_gevent__ares) {
  9248. if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  9249. }
  9250. #if PY_MAJOR_VERSION >= 3
  9251. {
  9252. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  9253. if (!PyDict_GetItemString(modules, "gevent.ares")) {
  9254. if (unlikely(PyDict_SetItemString(modules, "gevent.ares", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  9255. }
  9256. }
  9257. #endif
  9258. /*--- Builtin init code ---*/
  9259. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  9260. /*--- Constants init code ---*/
  9261. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  9262. /*--- Global init code ---*/
  9263. __pyx_v_6gevent_4ares_string_types = Py_None; Py_INCREF(Py_None);
  9264. __pyx_v_6gevent_4ares_text_type = Py_None; Py_INCREF(Py_None);
  9265. /*--- Variable export code ---*/
  9266. /*--- Function export code ---*/
  9267. /*--- Type init code ---*/
  9268. if (PyType_Ready(&__pyx_type_6gevent_4ares_result) < 0) __PYX_ERR(0, 164, __pyx_L1_error)
  9269. __pyx_type_6gevent_4ares_result.tp_print = 0;
  9270. if (PyObject_SetAttrString(__pyx_m, "result", (PyObject *)&__pyx_type_6gevent_4ares_result) < 0) __PYX_ERR(0, 164, __pyx_L1_error)
  9271. __pyx_ptype_6gevent_4ares_result = &__pyx_type_6gevent_4ares_result;
  9272. __pyx_vtabptr_6gevent_4ares_channel = &__pyx_vtable_6gevent_4ares_channel;
  9273. __pyx_vtable_6gevent_4ares_channel._sock_state_callback = (PyObject *(*)(struct PyGeventAresChannelObject *, int, int, int))__pyx_f_6gevent_4ares_7channel__sock_state_callback;
  9274. __pyx_vtable_6gevent_4ares_channel._getnameinfo = (PyObject *(*)(struct PyGeventAresChannelObject *, PyObject *, PyObject *, int, int __pyx_skip_dispatch))__pyx_f_6gevent_4ares_7channel__getnameinfo;
  9275. if (PyType_Ready(&PyGeventAresChannel_Type) < 0) __PYX_ERR(0, 245, __pyx_L1_error)
  9276. PyGeventAresChannel_Type.tp_print = 0;
  9277. if (__Pyx_SetVtable(PyGeventAresChannel_Type.tp_dict, __pyx_vtabptr_6gevent_4ares_channel) < 0) __PYX_ERR(0, 245, __pyx_L1_error)
  9278. if (PyObject_SetAttrString(__pyx_m, "channel", (PyObject *)&PyGeventAresChannel_Type) < 0) __PYX_ERR(0, 245, __pyx_L1_error)
  9279. __pyx_ptype_6gevent_4ares_channel = &PyGeventAresChannel_Type;
  9280. /*--- Type import code ---*/
  9281. /*--- Variable import code ---*/
  9282. /*--- Function import code ---*/
  9283. /*--- Execution code ---*/
  9284. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  9285. if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  9286. #endif
  9287. /* "gevent/ares.pyx":3
  9288. * # Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details.
  9289. * cimport cares
  9290. * import sys # <<<<<<<<<<<<<<
  9291. * from python cimport *
  9292. * from _socket import gaierror
  9293. */
  9294. __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
  9295. __Pyx_GOTREF(__pyx_t_1);
  9296. if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
  9297. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9298. /* "gevent/ares.pyx":5
  9299. * import sys
  9300. * from python cimport *
  9301. * from _socket import gaierror # <<<<<<<<<<<<<<
  9302. *
  9303. *
  9304. */
  9305. __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
  9306. __Pyx_GOTREF(__pyx_t_1);
  9307. __Pyx_INCREF(__pyx_n_s_gaierror);
  9308. __Pyx_GIVEREF(__pyx_n_s_gaierror);
  9309. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_gaierror);
  9310. __pyx_t_2 = __Pyx_Import(__pyx_n_s_socket, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error)
  9311. __Pyx_GOTREF(__pyx_t_2);
  9312. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9313. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_gaierror); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
  9314. __Pyx_GOTREF(__pyx_t_1);
  9315. if (PyDict_SetItem(__pyx_d, __pyx_n_s_gaierror, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
  9316. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9317. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9318. /* "gevent/ares.pyx":8
  9319. *
  9320. *
  9321. * __all__ = ['channel'] # <<<<<<<<<<<<<<
  9322. *
  9323. * cdef object string_types
  9324. */
  9325. __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
  9326. __Pyx_GOTREF(__pyx_t_2);
  9327. __Pyx_INCREF(__pyx_n_s_channel);
  9328. __Pyx_GIVEREF(__pyx_n_s_channel);
  9329. PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_channel);
  9330. if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
  9331. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9332. /* "gevent/ares.pyx":13
  9333. * cdef object text_type
  9334. *
  9335. * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<<
  9336. * string_types = str,
  9337. * text_type = str
  9338. */
  9339. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
  9340. __Pyx_GOTREF(__pyx_t_2);
  9341. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_version_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
  9342. __Pyx_GOTREF(__pyx_t_1);
  9343. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9344. __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
  9345. __Pyx_GOTREF(__pyx_t_2);
  9346. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9347. __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
  9348. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9349. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 13, __pyx_L1_error)
  9350. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9351. if (__pyx_t_3) {
  9352. /* "gevent/ares.pyx":14
  9353. *
  9354. * if sys.version_info[0] >= 3:
  9355. * string_types = str, # <<<<<<<<<<<<<<
  9356. * text_type = str
  9357. * else:
  9358. */
  9359. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
  9360. __Pyx_GOTREF(__pyx_t_1);
  9361. __Pyx_INCREF(((PyObject *)(&PyString_Type)));
  9362. __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
  9363. PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)(&PyString_Type)));
  9364. __Pyx_XGOTREF(__pyx_v_6gevent_4ares_string_types);
  9365. __Pyx_DECREF_SET(__pyx_v_6gevent_4ares_string_types, __pyx_t_1);
  9366. __Pyx_GIVEREF(__pyx_t_1);
  9367. __pyx_t_1 = 0;
  9368. /* "gevent/ares.pyx":15
  9369. * if sys.version_info[0] >= 3:
  9370. * string_types = str,
  9371. * text_type = str # <<<<<<<<<<<<<<
  9372. * else:
  9373. * string_types = __builtins__.basestring,
  9374. */
  9375. __Pyx_INCREF(((PyObject *)(&PyString_Type)));
  9376. __Pyx_XGOTREF(__pyx_v_6gevent_4ares_text_type);
  9377. __Pyx_DECREF_SET(__pyx_v_6gevent_4ares_text_type, ((PyObject *)(&PyString_Type)));
  9378. __Pyx_GIVEREF(((PyObject *)(&PyString_Type)));
  9379. /* "gevent/ares.pyx":13
  9380. * cdef object text_type
  9381. *
  9382. * if sys.version_info[0] >= 3: # <<<<<<<<<<<<<<
  9383. * string_types = str,
  9384. * text_type = str
  9385. */
  9386. goto __pyx_L2;
  9387. }
  9388. /* "gevent/ares.pyx":17
  9389. * text_type = str
  9390. * else:
  9391. * string_types = __builtins__.basestring, # <<<<<<<<<<<<<<
  9392. * text_type = __builtins__.unicode
  9393. *
  9394. */
  9395. /*else*/ {
  9396. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_builtins); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  9397. __Pyx_GOTREF(__pyx_t_1);
  9398. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_basestring); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error)
  9399. __Pyx_GOTREF(__pyx_t_2);
  9400. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9401. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  9402. __Pyx_GOTREF(__pyx_t_1);
  9403. __Pyx_GIVEREF(__pyx_t_2);
  9404. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  9405. __pyx_t_2 = 0;
  9406. __Pyx_XGOTREF(__pyx_v_6gevent_4ares_string_types);
  9407. __Pyx_DECREF_SET(__pyx_v_6gevent_4ares_string_types, __pyx_t_1);
  9408. __Pyx_GIVEREF(__pyx_t_1);
  9409. __pyx_t_1 = 0;
  9410. /* "gevent/ares.pyx":18
  9411. * else:
  9412. * string_types = __builtins__.basestring,
  9413. * text_type = __builtins__.unicode # <<<<<<<<<<<<<<
  9414. *
  9415. * TIMEOUT = 1
  9416. */
  9417. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_builtins); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
  9418. __Pyx_GOTREF(__pyx_t_1);
  9419. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
  9420. __Pyx_GOTREF(__pyx_t_2);
  9421. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  9422. __Pyx_XGOTREF(__pyx_v_6gevent_4ares_text_type);
  9423. __Pyx_DECREF_SET(__pyx_v_6gevent_4ares_text_type, __pyx_t_2);
  9424. __Pyx_GIVEREF(__pyx_t_2);
  9425. __pyx_t_2 = 0;
  9426. }
  9427. __pyx_L2:;
  9428. /* "gevent/ares.pyx":20
  9429. * text_type = __builtins__.unicode
  9430. *
  9431. * TIMEOUT = 1 # <<<<<<<<<<<<<<
  9432. *
  9433. * DEF EV_READ = 1
  9434. */
  9435. if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIMEOUT, __pyx_int_1) < 0) __PYX_ERR(0, 20, __pyx_L1_error)
  9436. /* "gevent/ares.pyx":58
  9437. *
  9438. *
  9439. * ARES_SUCCESS = cares.ARES_SUCCESS # <<<<<<<<<<<<<<
  9440. * ARES_ENODATA = cares.ARES_ENODATA
  9441. * ARES_EFORMERR = cares.ARES_EFORMERR
  9442. */
  9443. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_SUCCESS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error)
  9444. __Pyx_GOTREF(__pyx_t_2);
  9445. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_SUCCESS, __pyx_t_2) < 0) __PYX_ERR(0, 58, __pyx_L1_error)
  9446. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9447. /* "gevent/ares.pyx":59
  9448. *
  9449. * ARES_SUCCESS = cares.ARES_SUCCESS
  9450. * ARES_ENODATA = cares.ARES_ENODATA # <<<<<<<<<<<<<<
  9451. * ARES_EFORMERR = cares.ARES_EFORMERR
  9452. * ARES_ESERVFAIL = cares.ARES_ESERVFAIL
  9453. */
  9454. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENODATA); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error)
  9455. __Pyx_GOTREF(__pyx_t_2);
  9456. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENODATA, __pyx_t_2) < 0) __PYX_ERR(0, 59, __pyx_L1_error)
  9457. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9458. /* "gevent/ares.pyx":60
  9459. * ARES_SUCCESS = cares.ARES_SUCCESS
  9460. * ARES_ENODATA = cares.ARES_ENODATA
  9461. * ARES_EFORMERR = cares.ARES_EFORMERR # <<<<<<<<<<<<<<
  9462. * ARES_ESERVFAIL = cares.ARES_ESERVFAIL
  9463. * ARES_ENOTFOUND = cares.ARES_ENOTFOUND
  9464. */
  9465. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFORMERR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error)
  9466. __Pyx_GOTREF(__pyx_t_2);
  9467. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EFORMERR, __pyx_t_2) < 0) __PYX_ERR(0, 60, __pyx_L1_error)
  9468. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9469. /* "gevent/ares.pyx":61
  9470. * ARES_ENODATA = cares.ARES_ENODATA
  9471. * ARES_EFORMERR = cares.ARES_EFORMERR
  9472. * ARES_ESERVFAIL = cares.ARES_ESERVFAIL # <<<<<<<<<<<<<<
  9473. * ARES_ENOTFOUND = cares.ARES_ENOTFOUND
  9474. * ARES_ENOTIMP = cares.ARES_ENOTIMP
  9475. */
  9476. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ESERVFAIL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error)
  9477. __Pyx_GOTREF(__pyx_t_2);
  9478. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ESERVFAIL, __pyx_t_2) < 0) __PYX_ERR(0, 61, __pyx_L1_error)
  9479. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9480. /* "gevent/ares.pyx":62
  9481. * ARES_EFORMERR = cares.ARES_EFORMERR
  9482. * ARES_ESERVFAIL = cares.ARES_ESERVFAIL
  9483. * ARES_ENOTFOUND = cares.ARES_ENOTFOUND # <<<<<<<<<<<<<<
  9484. * ARES_ENOTIMP = cares.ARES_ENOTIMP
  9485. * ARES_EREFUSED = cares.ARES_EREFUSED
  9486. */
  9487. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTFOUND); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error)
  9488. __Pyx_GOTREF(__pyx_t_2);
  9489. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOTFOUND, __pyx_t_2) < 0) __PYX_ERR(0, 62, __pyx_L1_error)
  9490. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9491. /* "gevent/ares.pyx":63
  9492. * ARES_ESERVFAIL = cares.ARES_ESERVFAIL
  9493. * ARES_ENOTFOUND = cares.ARES_ENOTFOUND
  9494. * ARES_ENOTIMP = cares.ARES_ENOTIMP # <<<<<<<<<<<<<<
  9495. * ARES_EREFUSED = cares.ARES_EREFUSED
  9496. * ARES_EBADQUERY = cares.ARES_EBADQUERY
  9497. */
  9498. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTIMP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
  9499. __Pyx_GOTREF(__pyx_t_2);
  9500. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOTIMP, __pyx_t_2) < 0) __PYX_ERR(0, 63, __pyx_L1_error)
  9501. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9502. /* "gevent/ares.pyx":64
  9503. * ARES_ENOTFOUND = cares.ARES_ENOTFOUND
  9504. * ARES_ENOTIMP = cares.ARES_ENOTIMP
  9505. * ARES_EREFUSED = cares.ARES_EREFUSED # <<<<<<<<<<<<<<
  9506. * ARES_EBADQUERY = cares.ARES_EBADQUERY
  9507. * ARES_EBADNAME = cares.ARES_EBADNAME
  9508. */
  9509. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EREFUSED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error)
  9510. __Pyx_GOTREF(__pyx_t_2);
  9511. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EREFUSED, __pyx_t_2) < 0) __PYX_ERR(0, 64, __pyx_L1_error)
  9512. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9513. /* "gevent/ares.pyx":65
  9514. * ARES_ENOTIMP = cares.ARES_ENOTIMP
  9515. * ARES_EREFUSED = cares.ARES_EREFUSED
  9516. * ARES_EBADQUERY = cares.ARES_EBADQUERY # <<<<<<<<<<<<<<
  9517. * ARES_EBADNAME = cares.ARES_EBADNAME
  9518. * ARES_EBADFAMILY = cares.ARES_EBADFAMILY
  9519. */
  9520. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADQUERY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
  9521. __Pyx_GOTREF(__pyx_t_2);
  9522. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADQUERY, __pyx_t_2) < 0) __PYX_ERR(0, 65, __pyx_L1_error)
  9523. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9524. /* "gevent/ares.pyx":66
  9525. * ARES_EREFUSED = cares.ARES_EREFUSED
  9526. * ARES_EBADQUERY = cares.ARES_EBADQUERY
  9527. * ARES_EBADNAME = cares.ARES_EBADNAME # <<<<<<<<<<<<<<
  9528. * ARES_EBADFAMILY = cares.ARES_EBADFAMILY
  9529. * ARES_EBADRESP = cares.ARES_EBADRESP
  9530. */
  9531. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADNAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
  9532. __Pyx_GOTREF(__pyx_t_2);
  9533. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADNAME, __pyx_t_2) < 0) __PYX_ERR(0, 66, __pyx_L1_error)
  9534. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9535. /* "gevent/ares.pyx":67
  9536. * ARES_EBADQUERY = cares.ARES_EBADQUERY
  9537. * ARES_EBADNAME = cares.ARES_EBADNAME
  9538. * ARES_EBADFAMILY = cares.ARES_EBADFAMILY # <<<<<<<<<<<<<<
  9539. * ARES_EBADRESP = cares.ARES_EBADRESP
  9540. * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED
  9541. */
  9542. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFAMILY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error)
  9543. __Pyx_GOTREF(__pyx_t_2);
  9544. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADFAMILY, __pyx_t_2) < 0) __PYX_ERR(0, 67, __pyx_L1_error)
  9545. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9546. /* "gevent/ares.pyx":68
  9547. * ARES_EBADNAME = cares.ARES_EBADNAME
  9548. * ARES_EBADFAMILY = cares.ARES_EBADFAMILY
  9549. * ARES_EBADRESP = cares.ARES_EBADRESP # <<<<<<<<<<<<<<
  9550. * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED
  9551. * ARES_ETIMEOUT = cares.ARES_ETIMEOUT
  9552. */
  9553. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADRESP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error)
  9554. __Pyx_GOTREF(__pyx_t_2);
  9555. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADRESP, __pyx_t_2) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
  9556. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9557. /* "gevent/ares.pyx":69
  9558. * ARES_EBADFAMILY = cares.ARES_EBADFAMILY
  9559. * ARES_EBADRESP = cares.ARES_EBADRESP
  9560. * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED # <<<<<<<<<<<<<<
  9561. * ARES_ETIMEOUT = cares.ARES_ETIMEOUT
  9562. * ARES_EOF = cares.ARES_EOF
  9563. */
  9564. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECONNREFUSED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
  9565. __Pyx_GOTREF(__pyx_t_2);
  9566. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ECONNREFUSED, __pyx_t_2) < 0) __PYX_ERR(0, 69, __pyx_L1_error)
  9567. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9568. /* "gevent/ares.pyx":70
  9569. * ARES_EBADRESP = cares.ARES_EBADRESP
  9570. * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED
  9571. * ARES_ETIMEOUT = cares.ARES_ETIMEOUT # <<<<<<<<<<<<<<
  9572. * ARES_EOF = cares.ARES_EOF
  9573. * ARES_EFILE = cares.ARES_EFILE
  9574. */
  9575. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ETIMEOUT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
  9576. __Pyx_GOTREF(__pyx_t_2);
  9577. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ETIMEOUT, __pyx_t_2) < 0) __PYX_ERR(0, 70, __pyx_L1_error)
  9578. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9579. /* "gevent/ares.pyx":71
  9580. * ARES_ECONNREFUSED = cares.ARES_ECONNREFUSED
  9581. * ARES_ETIMEOUT = cares.ARES_ETIMEOUT
  9582. * ARES_EOF = cares.ARES_EOF # <<<<<<<<<<<<<<
  9583. * ARES_EFILE = cares.ARES_EFILE
  9584. * ARES_ENOMEM = cares.ARES_ENOMEM
  9585. */
  9586. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EOF); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
  9587. __Pyx_GOTREF(__pyx_t_2);
  9588. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EOF, __pyx_t_2) < 0) __PYX_ERR(0, 71, __pyx_L1_error)
  9589. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9590. /* "gevent/ares.pyx":72
  9591. * ARES_ETIMEOUT = cares.ARES_ETIMEOUT
  9592. * ARES_EOF = cares.ARES_EOF
  9593. * ARES_EFILE = cares.ARES_EFILE # <<<<<<<<<<<<<<
  9594. * ARES_ENOMEM = cares.ARES_ENOMEM
  9595. * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION
  9596. */
  9597. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFILE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
  9598. __Pyx_GOTREF(__pyx_t_2);
  9599. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EFILE, __pyx_t_2) < 0) __PYX_ERR(0, 72, __pyx_L1_error)
  9600. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9601. /* "gevent/ares.pyx":73
  9602. * ARES_EOF = cares.ARES_EOF
  9603. * ARES_EFILE = cares.ARES_EFILE
  9604. * ARES_ENOMEM = cares.ARES_ENOMEM # <<<<<<<<<<<<<<
  9605. * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION
  9606. * ARES_EBADSTR = cares.ARES_EBADSTR
  9607. */
  9608. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOMEM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
  9609. __Pyx_GOTREF(__pyx_t_2);
  9610. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOMEM, __pyx_t_2) < 0) __PYX_ERR(0, 73, __pyx_L1_error)
  9611. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9612. /* "gevent/ares.pyx":74
  9613. * ARES_EFILE = cares.ARES_EFILE
  9614. * ARES_ENOMEM = cares.ARES_ENOMEM
  9615. * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION # <<<<<<<<<<<<<<
  9616. * ARES_EBADSTR = cares.ARES_EBADSTR
  9617. * ARES_EBADFLAGS = cares.ARES_EBADFLAGS
  9618. */
  9619. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
  9620. __Pyx_GOTREF(__pyx_t_2);
  9621. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EDESTRUCTION, __pyx_t_2) < 0) __PYX_ERR(0, 74, __pyx_L1_error)
  9622. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9623. /* "gevent/ares.pyx":75
  9624. * ARES_ENOMEM = cares.ARES_ENOMEM
  9625. * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION
  9626. * ARES_EBADSTR = cares.ARES_EBADSTR # <<<<<<<<<<<<<<
  9627. * ARES_EBADFLAGS = cares.ARES_EBADFLAGS
  9628. * ARES_ENONAME = cares.ARES_ENONAME
  9629. */
  9630. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADSTR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error)
  9631. __Pyx_GOTREF(__pyx_t_2);
  9632. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADSTR, __pyx_t_2) < 0) __PYX_ERR(0, 75, __pyx_L1_error)
  9633. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9634. /* "gevent/ares.pyx":76
  9635. * ARES_EDESTRUCTION = cares.ARES_EDESTRUCTION
  9636. * ARES_EBADSTR = cares.ARES_EBADSTR
  9637. * ARES_EBADFLAGS = cares.ARES_EBADFLAGS # <<<<<<<<<<<<<<
  9638. * ARES_ENONAME = cares.ARES_ENONAME
  9639. * ARES_EBADHINTS = cares.ARES_EBADHINTS
  9640. */
  9641. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFLAGS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error)
  9642. __Pyx_GOTREF(__pyx_t_2);
  9643. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADFLAGS, __pyx_t_2) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
  9644. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9645. /* "gevent/ares.pyx":77
  9646. * ARES_EBADSTR = cares.ARES_EBADSTR
  9647. * ARES_EBADFLAGS = cares.ARES_EBADFLAGS
  9648. * ARES_ENONAME = cares.ARES_ENONAME # <<<<<<<<<<<<<<
  9649. * ARES_EBADHINTS = cares.ARES_EBADHINTS
  9650. * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED
  9651. */
  9652. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENONAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
  9653. __Pyx_GOTREF(__pyx_t_2);
  9654. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENONAME, __pyx_t_2) < 0) __PYX_ERR(0, 77, __pyx_L1_error)
  9655. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9656. /* "gevent/ares.pyx":78
  9657. * ARES_EBADFLAGS = cares.ARES_EBADFLAGS
  9658. * ARES_ENONAME = cares.ARES_ENONAME
  9659. * ARES_EBADHINTS = cares.ARES_EBADHINTS # <<<<<<<<<<<<<<
  9660. * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED
  9661. * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI
  9662. */
  9663. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADHINTS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error)
  9664. __Pyx_GOTREF(__pyx_t_2);
  9665. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EBADHINTS, __pyx_t_2) < 0) __PYX_ERR(0, 78, __pyx_L1_error)
  9666. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9667. /* "gevent/ares.pyx":79
  9668. * ARES_ENONAME = cares.ARES_ENONAME
  9669. * ARES_EBADHINTS = cares.ARES_EBADHINTS
  9670. * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED # <<<<<<<<<<<<<<
  9671. * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI
  9672. * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS
  9673. */
  9674. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTINITIALIZED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error)
  9675. __Pyx_GOTREF(__pyx_t_2);
  9676. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ENOTINITIALIZED, __pyx_t_2) < 0) __PYX_ERR(0, 79, __pyx_L1_error)
  9677. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9678. /* "gevent/ares.pyx":80
  9679. * ARES_EBADHINTS = cares.ARES_EBADHINTS
  9680. * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED
  9681. * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI # <<<<<<<<<<<<<<
  9682. * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS
  9683. * ARES_ECANCELLED = cares.ARES_ECANCELLED
  9684. */
  9685. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ELOADIPHLPAPI); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L1_error)
  9686. __Pyx_GOTREF(__pyx_t_2);
  9687. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ELOADIPHLPAPI, __pyx_t_2) < 0) __PYX_ERR(0, 80, __pyx_L1_error)
  9688. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9689. /* "gevent/ares.pyx":81
  9690. * ARES_ENOTINITIALIZED = cares.ARES_ENOTINITIALIZED
  9691. * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI
  9692. * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS # <<<<<<<<<<<<<<
  9693. * ARES_ECANCELLED = cares.ARES_ECANCELLED
  9694. *
  9695. */
  9696. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EADDRGETNETWORKPARAMS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)
  9697. __Pyx_GOTREF(__pyx_t_2);
  9698. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_EADDRGETNETWORKPARAMS, __pyx_t_2) < 0) __PYX_ERR(0, 81, __pyx_L1_error)
  9699. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9700. /* "gevent/ares.pyx":82
  9701. * ARES_ELOADIPHLPAPI = cares.ARES_ELOADIPHLPAPI
  9702. * ARES_EADDRGETNETWORKPARAMS = cares.ARES_EADDRGETNETWORKPARAMS
  9703. * ARES_ECANCELLED = cares.ARES_ECANCELLED # <<<<<<<<<<<<<<
  9704. *
  9705. * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC
  9706. */
  9707. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECANCELLED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
  9708. __Pyx_GOTREF(__pyx_t_2);
  9709. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_ECANCELLED, __pyx_t_2) < 0) __PYX_ERR(0, 82, __pyx_L1_error)
  9710. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9711. /* "gevent/ares.pyx":84
  9712. * ARES_ECANCELLED = cares.ARES_ECANCELLED
  9713. *
  9714. * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC # <<<<<<<<<<<<<<
  9715. * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY
  9716. * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC
  9717. */
  9718. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_USEVC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
  9719. __Pyx_GOTREF(__pyx_t_2);
  9720. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_USEVC, __pyx_t_2) < 0) __PYX_ERR(0, 84, __pyx_L1_error)
  9721. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9722. /* "gevent/ares.pyx":85
  9723. *
  9724. * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC
  9725. * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY # <<<<<<<<<<<<<<
  9726. * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC
  9727. * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE
  9728. */
  9729. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_PRIMARY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error)
  9730. __Pyx_GOTREF(__pyx_t_2);
  9731. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_PRIMARY, __pyx_t_2) < 0) __PYX_ERR(0, 85, __pyx_L1_error)
  9732. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9733. /* "gevent/ares.pyx":86
  9734. * ARES_FLAG_USEVC = cares.ARES_FLAG_USEVC
  9735. * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY
  9736. * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC # <<<<<<<<<<<<<<
  9737. * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE
  9738. * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN
  9739. */
  9740. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_IGNTC); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error)
  9741. __Pyx_GOTREF(__pyx_t_2);
  9742. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_IGNTC, __pyx_t_2) < 0) __PYX_ERR(0, 86, __pyx_L1_error)
  9743. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9744. /* "gevent/ares.pyx":87
  9745. * ARES_FLAG_PRIMARY = cares.ARES_FLAG_PRIMARY
  9746. * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC
  9747. * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE # <<<<<<<<<<<<<<
  9748. * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN
  9749. * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH
  9750. */
  9751. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NORECURSE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error)
  9752. __Pyx_GOTREF(__pyx_t_2);
  9753. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NORECURSE, __pyx_t_2) < 0) __PYX_ERR(0, 87, __pyx_L1_error)
  9754. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9755. /* "gevent/ares.pyx":88
  9756. * ARES_FLAG_IGNTC = cares.ARES_FLAG_IGNTC
  9757. * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE
  9758. * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN # <<<<<<<<<<<<<<
  9759. * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH
  9760. * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES
  9761. */
  9762. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_STAYOPEN); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
  9763. __Pyx_GOTREF(__pyx_t_2);
  9764. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_STAYOPEN, __pyx_t_2) < 0) __PYX_ERR(0, 88, __pyx_L1_error)
  9765. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9766. /* "gevent/ares.pyx":89
  9767. * ARES_FLAG_NORECURSE = cares.ARES_FLAG_NORECURSE
  9768. * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN
  9769. * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH # <<<<<<<<<<<<<<
  9770. * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES
  9771. * ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP
  9772. */
  9773. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NOSEARCH); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
  9774. __Pyx_GOTREF(__pyx_t_2);
  9775. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NOSEARCH, __pyx_t_2) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
  9776. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9777. /* "gevent/ares.pyx":90
  9778. * ARES_FLAG_STAYOPEN = cares.ARES_FLAG_STAYOPEN
  9779. * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH
  9780. * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES # <<<<<<<<<<<<<<
  9781. * ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP
  9782. *
  9783. */
  9784. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NOALIASES); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
  9785. __Pyx_GOTREF(__pyx_t_2);
  9786. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NOALIASES, __pyx_t_2) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
  9787. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9788. /* "gevent/ares.pyx":91
  9789. * ARES_FLAG_NOSEARCH = cares.ARES_FLAG_NOSEARCH
  9790. * ARES_FLAG_NOALIASES = cares.ARES_FLAG_NOALIASES
  9791. * ARES_FLAG_NOCHECKRESP = cares.ARES_FLAG_NOCHECKRESP # <<<<<<<<<<<<<<
  9792. *
  9793. *
  9794. */
  9795. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_FLAG_NOCHECKRESP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
  9796. __Pyx_GOTREF(__pyx_t_2);
  9797. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARES_FLAG_NOCHECKRESP, __pyx_t_2) < 0) __PYX_ERR(0, 91, __pyx_L1_error)
  9798. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  9799. /* "gevent/ares.pyx":95
  9800. *
  9801. * _ares_errors = dict([
  9802. * (cares.ARES_SUCCESS, 'ARES_SUCCESS'), # <<<<<<<<<<<<<<
  9803. * (cares.ARES_ENODATA, 'ARES_ENODATA'),
  9804. * (cares.ARES_EFORMERR, 'ARES_EFORMERR'),
  9805. */
  9806. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_SUCCESS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error)
  9807. __Pyx_GOTREF(__pyx_t_2);
  9808. __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error)
  9809. __Pyx_GOTREF(__pyx_t_1);
  9810. __Pyx_GIVEREF(__pyx_t_2);
  9811. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  9812. __Pyx_INCREF(__pyx_n_s_ARES_SUCCESS);
  9813. __Pyx_GIVEREF(__pyx_n_s_ARES_SUCCESS);
  9814. PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_ARES_SUCCESS);
  9815. __pyx_t_2 = 0;
  9816. /* "gevent/ares.pyx":96
  9817. * _ares_errors = dict([
  9818. * (cares.ARES_SUCCESS, 'ARES_SUCCESS'),
  9819. * (cares.ARES_ENODATA, 'ARES_ENODATA'), # <<<<<<<<<<<<<<
  9820. * (cares.ARES_EFORMERR, 'ARES_EFORMERR'),
  9821. * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'),
  9822. */
  9823. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENODATA); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error)
  9824. __Pyx_GOTREF(__pyx_t_2);
  9825. __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error)
  9826. __Pyx_GOTREF(__pyx_t_4);
  9827. __Pyx_GIVEREF(__pyx_t_2);
  9828. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  9829. __Pyx_INCREF(__pyx_n_s_ARES_ENODATA);
  9830. __Pyx_GIVEREF(__pyx_n_s_ARES_ENODATA);
  9831. PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_ARES_ENODATA);
  9832. __pyx_t_2 = 0;
  9833. /* "gevent/ares.pyx":97
  9834. * (cares.ARES_SUCCESS, 'ARES_SUCCESS'),
  9835. * (cares.ARES_ENODATA, 'ARES_ENODATA'),
  9836. * (cares.ARES_EFORMERR, 'ARES_EFORMERR'), # <<<<<<<<<<<<<<
  9837. * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'),
  9838. * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'),
  9839. */
  9840. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFORMERR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
  9841. __Pyx_GOTREF(__pyx_t_2);
  9842. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error)
  9843. __Pyx_GOTREF(__pyx_t_5);
  9844. __Pyx_GIVEREF(__pyx_t_2);
  9845. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  9846. __Pyx_INCREF(__pyx_n_s_ARES_EFORMERR);
  9847. __Pyx_GIVEREF(__pyx_n_s_ARES_EFORMERR);
  9848. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_ARES_EFORMERR);
  9849. __pyx_t_2 = 0;
  9850. /* "gevent/ares.pyx":98
  9851. * (cares.ARES_ENODATA, 'ARES_ENODATA'),
  9852. * (cares.ARES_EFORMERR, 'ARES_EFORMERR'),
  9853. * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'), # <<<<<<<<<<<<<<
  9854. * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'),
  9855. * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'),
  9856. */
  9857. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ESERVFAIL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
  9858. __Pyx_GOTREF(__pyx_t_2);
  9859. __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 98, __pyx_L1_error)
  9860. __Pyx_GOTREF(__pyx_t_6);
  9861. __Pyx_GIVEREF(__pyx_t_2);
  9862. PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  9863. __Pyx_INCREF(__pyx_n_s_ARES_ESERVFAIL);
  9864. __Pyx_GIVEREF(__pyx_n_s_ARES_ESERVFAIL);
  9865. PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_s_ARES_ESERVFAIL);
  9866. __pyx_t_2 = 0;
  9867. /* "gevent/ares.pyx":99
  9868. * (cares.ARES_EFORMERR, 'ARES_EFORMERR'),
  9869. * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'),
  9870. * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'), # <<<<<<<<<<<<<<
  9871. * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'),
  9872. * (cares.ARES_EREFUSED, 'ARES_EREFUSED'),
  9873. */
  9874. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTFOUND); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error)
  9875. __Pyx_GOTREF(__pyx_t_2);
  9876. __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 99, __pyx_L1_error)
  9877. __Pyx_GOTREF(__pyx_t_7);
  9878. __Pyx_GIVEREF(__pyx_t_2);
  9879. PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
  9880. __Pyx_INCREF(__pyx_n_s_ARES_ENOTFOUND);
  9881. __Pyx_GIVEREF(__pyx_n_s_ARES_ENOTFOUND);
  9882. PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_ARES_ENOTFOUND);
  9883. __pyx_t_2 = 0;
  9884. /* "gevent/ares.pyx":100
  9885. * (cares.ARES_ESERVFAIL, 'ARES_ESERVFAIL'),
  9886. * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'),
  9887. * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'), # <<<<<<<<<<<<<<
  9888. * (cares.ARES_EREFUSED, 'ARES_EREFUSED'),
  9889. * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'),
  9890. */
  9891. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTIMP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
  9892. __Pyx_GOTREF(__pyx_t_2);
  9893. __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 100, __pyx_L1_error)
  9894. __Pyx_GOTREF(__pyx_t_8);
  9895. __Pyx_GIVEREF(__pyx_t_2);
  9896. PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
  9897. __Pyx_INCREF(__pyx_n_s_ARES_ENOTIMP);
  9898. __Pyx_GIVEREF(__pyx_n_s_ARES_ENOTIMP);
  9899. PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_n_s_ARES_ENOTIMP);
  9900. __pyx_t_2 = 0;
  9901. /* "gevent/ares.pyx":101
  9902. * (cares.ARES_ENOTFOUND, 'ARES_ENOTFOUND'),
  9903. * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'),
  9904. * (cares.ARES_EREFUSED, 'ARES_EREFUSED'), # <<<<<<<<<<<<<<
  9905. * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'),
  9906. * (cares.ARES_EBADNAME, 'ARES_EBADNAME'),
  9907. */
  9908. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EREFUSED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error)
  9909. __Pyx_GOTREF(__pyx_t_2);
  9910. __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 101, __pyx_L1_error)
  9911. __Pyx_GOTREF(__pyx_t_9);
  9912. __Pyx_GIVEREF(__pyx_t_2);
  9913. PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
  9914. __Pyx_INCREF(__pyx_n_s_ARES_EREFUSED);
  9915. __Pyx_GIVEREF(__pyx_n_s_ARES_EREFUSED);
  9916. PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_n_s_ARES_EREFUSED);
  9917. __pyx_t_2 = 0;
  9918. /* "gevent/ares.pyx":102
  9919. * (cares.ARES_ENOTIMP, 'ARES_ENOTIMP'),
  9920. * (cares.ARES_EREFUSED, 'ARES_EREFUSED'),
  9921. * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'), # <<<<<<<<<<<<<<
  9922. * (cares.ARES_EBADNAME, 'ARES_EBADNAME'),
  9923. * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'),
  9924. */
  9925. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADQUERY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error)
  9926. __Pyx_GOTREF(__pyx_t_2);
  9927. __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 102, __pyx_L1_error)
  9928. __Pyx_GOTREF(__pyx_t_10);
  9929. __Pyx_GIVEREF(__pyx_t_2);
  9930. PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
  9931. __Pyx_INCREF(__pyx_n_s_ARES_EBADQUERY);
  9932. __Pyx_GIVEREF(__pyx_n_s_ARES_EBADQUERY);
  9933. PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_n_s_ARES_EBADQUERY);
  9934. __pyx_t_2 = 0;
  9935. /* "gevent/ares.pyx":103
  9936. * (cares.ARES_EREFUSED, 'ARES_EREFUSED'),
  9937. * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'),
  9938. * (cares.ARES_EBADNAME, 'ARES_EBADNAME'), # <<<<<<<<<<<<<<
  9939. * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'),
  9940. * (cares.ARES_EBADRESP, 'ARES_EBADRESP'),
  9941. */
  9942. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADNAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error)
  9943. __Pyx_GOTREF(__pyx_t_2);
  9944. __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 103, __pyx_L1_error)
  9945. __Pyx_GOTREF(__pyx_t_11);
  9946. __Pyx_GIVEREF(__pyx_t_2);
  9947. PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_2);
  9948. __Pyx_INCREF(__pyx_n_s_ARES_EBADNAME);
  9949. __Pyx_GIVEREF(__pyx_n_s_ARES_EBADNAME);
  9950. PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_n_s_ARES_EBADNAME);
  9951. __pyx_t_2 = 0;
  9952. /* "gevent/ares.pyx":104
  9953. * (cares.ARES_EBADQUERY, 'ARES_EBADQUERY'),
  9954. * (cares.ARES_EBADNAME, 'ARES_EBADNAME'),
  9955. * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'), # <<<<<<<<<<<<<<
  9956. * (cares.ARES_EBADRESP, 'ARES_EBADRESP'),
  9957. * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'),
  9958. */
  9959. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFAMILY); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
  9960. __Pyx_GOTREF(__pyx_t_2);
  9961. __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 104, __pyx_L1_error)
  9962. __Pyx_GOTREF(__pyx_t_12);
  9963. __Pyx_GIVEREF(__pyx_t_2);
  9964. PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2);
  9965. __Pyx_INCREF(__pyx_n_s_ARES_EBADFAMILY);
  9966. __Pyx_GIVEREF(__pyx_n_s_ARES_EBADFAMILY);
  9967. PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_n_s_ARES_EBADFAMILY);
  9968. __pyx_t_2 = 0;
  9969. /* "gevent/ares.pyx":105
  9970. * (cares.ARES_EBADNAME, 'ARES_EBADNAME'),
  9971. * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'),
  9972. * (cares.ARES_EBADRESP, 'ARES_EBADRESP'), # <<<<<<<<<<<<<<
  9973. * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'),
  9974. * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'),
  9975. */
  9976. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADRESP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 105, __pyx_L1_error)
  9977. __Pyx_GOTREF(__pyx_t_2);
  9978. __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 105, __pyx_L1_error)
  9979. __Pyx_GOTREF(__pyx_t_13);
  9980. __Pyx_GIVEREF(__pyx_t_2);
  9981. PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_2);
  9982. __Pyx_INCREF(__pyx_n_s_ARES_EBADRESP);
  9983. __Pyx_GIVEREF(__pyx_n_s_ARES_EBADRESP);
  9984. PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_n_s_ARES_EBADRESP);
  9985. __pyx_t_2 = 0;
  9986. /* "gevent/ares.pyx":106
  9987. * (cares.ARES_EBADFAMILY, 'ARES_EBADFAMILY'),
  9988. * (cares.ARES_EBADRESP, 'ARES_EBADRESP'),
  9989. * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'), # <<<<<<<<<<<<<<
  9990. * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'),
  9991. * (cares.ARES_EOF, 'ARES_EOF'),
  9992. */
  9993. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECONNREFUSED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error)
  9994. __Pyx_GOTREF(__pyx_t_2);
  9995. __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 106, __pyx_L1_error)
  9996. __Pyx_GOTREF(__pyx_t_14);
  9997. __Pyx_GIVEREF(__pyx_t_2);
  9998. PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_2);
  9999. __Pyx_INCREF(__pyx_n_s_ARES_ECONNREFUSED);
  10000. __Pyx_GIVEREF(__pyx_n_s_ARES_ECONNREFUSED);
  10001. PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_n_s_ARES_ECONNREFUSED);
  10002. __pyx_t_2 = 0;
  10003. /* "gevent/ares.pyx":107
  10004. * (cares.ARES_EBADRESP, 'ARES_EBADRESP'),
  10005. * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'),
  10006. * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'), # <<<<<<<<<<<<<<
  10007. * (cares.ARES_EOF, 'ARES_EOF'),
  10008. * (cares.ARES_EFILE, 'ARES_EFILE'),
  10009. */
  10010. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ETIMEOUT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error)
  10011. __Pyx_GOTREF(__pyx_t_2);
  10012. __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 107, __pyx_L1_error)
  10013. __Pyx_GOTREF(__pyx_t_15);
  10014. __Pyx_GIVEREF(__pyx_t_2);
  10015. PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_2);
  10016. __Pyx_INCREF(__pyx_n_s_ARES_ETIMEOUT);
  10017. __Pyx_GIVEREF(__pyx_n_s_ARES_ETIMEOUT);
  10018. PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_n_s_ARES_ETIMEOUT);
  10019. __pyx_t_2 = 0;
  10020. /* "gevent/ares.pyx":108
  10021. * (cares.ARES_ECONNREFUSED, 'ARES_ECONNREFUSED'),
  10022. * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'),
  10023. * (cares.ARES_EOF, 'ARES_EOF'), # <<<<<<<<<<<<<<
  10024. * (cares.ARES_EFILE, 'ARES_EFILE'),
  10025. * (cares.ARES_ENOMEM, 'ARES_ENOMEM'),
  10026. */
  10027. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EOF); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error)
  10028. __Pyx_GOTREF(__pyx_t_2);
  10029. __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 108, __pyx_L1_error)
  10030. __Pyx_GOTREF(__pyx_t_16);
  10031. __Pyx_GIVEREF(__pyx_t_2);
  10032. PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_2);
  10033. __Pyx_INCREF(__pyx_n_s_ARES_EOF);
  10034. __Pyx_GIVEREF(__pyx_n_s_ARES_EOF);
  10035. PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_n_s_ARES_EOF);
  10036. __pyx_t_2 = 0;
  10037. /* "gevent/ares.pyx":109
  10038. * (cares.ARES_ETIMEOUT, 'ARES_ETIMEOUT'),
  10039. * (cares.ARES_EOF, 'ARES_EOF'),
  10040. * (cares.ARES_EFILE, 'ARES_EFILE'), # <<<<<<<<<<<<<<
  10041. * (cares.ARES_ENOMEM, 'ARES_ENOMEM'),
  10042. * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'),
  10043. */
  10044. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EFILE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error)
  10045. __Pyx_GOTREF(__pyx_t_2);
  10046. __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 109, __pyx_L1_error)
  10047. __Pyx_GOTREF(__pyx_t_17);
  10048. __Pyx_GIVEREF(__pyx_t_2);
  10049. PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_2);
  10050. __Pyx_INCREF(__pyx_n_s_ARES_EFILE);
  10051. __Pyx_GIVEREF(__pyx_n_s_ARES_EFILE);
  10052. PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_n_s_ARES_EFILE);
  10053. __pyx_t_2 = 0;
  10054. /* "gevent/ares.pyx":110
  10055. * (cares.ARES_EOF, 'ARES_EOF'),
  10056. * (cares.ARES_EFILE, 'ARES_EFILE'),
  10057. * (cares.ARES_ENOMEM, 'ARES_ENOMEM'), # <<<<<<<<<<<<<<
  10058. * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'),
  10059. * (cares.ARES_EBADSTR, 'ARES_EBADSTR'),
  10060. */
  10061. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOMEM); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
  10062. __Pyx_GOTREF(__pyx_t_2);
  10063. __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 110, __pyx_L1_error)
  10064. __Pyx_GOTREF(__pyx_t_18);
  10065. __Pyx_GIVEREF(__pyx_t_2);
  10066. PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_2);
  10067. __Pyx_INCREF(__pyx_n_s_ARES_ENOMEM);
  10068. __Pyx_GIVEREF(__pyx_n_s_ARES_ENOMEM);
  10069. PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_n_s_ARES_ENOMEM);
  10070. __pyx_t_2 = 0;
  10071. /* "gevent/ares.pyx":111
  10072. * (cares.ARES_EFILE, 'ARES_EFILE'),
  10073. * (cares.ARES_ENOMEM, 'ARES_ENOMEM'),
  10074. * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'), # <<<<<<<<<<<<<<
  10075. * (cares.ARES_EBADSTR, 'ARES_EBADSTR'),
  10076. * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'),
  10077. */
  10078. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EDESTRUCTION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error)
  10079. __Pyx_GOTREF(__pyx_t_2);
  10080. __pyx_t_19 = PyTuple_New(2); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 111, __pyx_L1_error)
  10081. __Pyx_GOTREF(__pyx_t_19);
  10082. __Pyx_GIVEREF(__pyx_t_2);
  10083. PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_2);
  10084. __Pyx_INCREF(__pyx_n_s_ARES_EDESTRUCTION);
  10085. __Pyx_GIVEREF(__pyx_n_s_ARES_EDESTRUCTION);
  10086. PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_n_s_ARES_EDESTRUCTION);
  10087. __pyx_t_2 = 0;
  10088. /* "gevent/ares.pyx":112
  10089. * (cares.ARES_ENOMEM, 'ARES_ENOMEM'),
  10090. * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'),
  10091. * (cares.ARES_EBADSTR, 'ARES_EBADSTR'), # <<<<<<<<<<<<<<
  10092. * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'),
  10093. * (cares.ARES_ENONAME, 'ARES_ENONAME'),
  10094. */
  10095. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADSTR); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error)
  10096. __Pyx_GOTREF(__pyx_t_2);
  10097. __pyx_t_20 = PyTuple_New(2); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 112, __pyx_L1_error)
  10098. __Pyx_GOTREF(__pyx_t_20);
  10099. __Pyx_GIVEREF(__pyx_t_2);
  10100. PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_2);
  10101. __Pyx_INCREF(__pyx_n_s_ARES_EBADSTR);
  10102. __Pyx_GIVEREF(__pyx_n_s_ARES_EBADSTR);
  10103. PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_n_s_ARES_EBADSTR);
  10104. __pyx_t_2 = 0;
  10105. /* "gevent/ares.pyx":113
  10106. * (cares.ARES_EDESTRUCTION, 'ARES_EDESTRUCTION'),
  10107. * (cares.ARES_EBADSTR, 'ARES_EBADSTR'),
  10108. * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'), # <<<<<<<<<<<<<<
  10109. * (cares.ARES_ENONAME, 'ARES_ENONAME'),
  10110. * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'),
  10111. */
  10112. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADFLAGS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
  10113. __Pyx_GOTREF(__pyx_t_2);
  10114. __pyx_t_21 = PyTuple_New(2); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 113, __pyx_L1_error)
  10115. __Pyx_GOTREF(__pyx_t_21);
  10116. __Pyx_GIVEREF(__pyx_t_2);
  10117. PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_2);
  10118. __Pyx_INCREF(__pyx_n_s_ARES_EBADFLAGS);
  10119. __Pyx_GIVEREF(__pyx_n_s_ARES_EBADFLAGS);
  10120. PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_n_s_ARES_EBADFLAGS);
  10121. __pyx_t_2 = 0;
  10122. /* "gevent/ares.pyx":114
  10123. * (cares.ARES_EBADSTR, 'ARES_EBADSTR'),
  10124. * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'),
  10125. * (cares.ARES_ENONAME, 'ARES_ENONAME'), # <<<<<<<<<<<<<<
  10126. * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'),
  10127. * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'),
  10128. */
  10129. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENONAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error)
  10130. __Pyx_GOTREF(__pyx_t_2);
  10131. __pyx_t_22 = PyTuple_New(2); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 114, __pyx_L1_error)
  10132. __Pyx_GOTREF(__pyx_t_22);
  10133. __Pyx_GIVEREF(__pyx_t_2);
  10134. PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_2);
  10135. __Pyx_INCREF(__pyx_n_s_ARES_ENONAME);
  10136. __Pyx_GIVEREF(__pyx_n_s_ARES_ENONAME);
  10137. PyTuple_SET_ITEM(__pyx_t_22, 1, __pyx_n_s_ARES_ENONAME);
  10138. __pyx_t_2 = 0;
  10139. /* "gevent/ares.pyx":115
  10140. * (cares.ARES_EBADFLAGS, 'ARES_EBADFLAGS'),
  10141. * (cares.ARES_ENONAME, 'ARES_ENONAME'),
  10142. * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'), # <<<<<<<<<<<<<<
  10143. * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'),
  10144. * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'),
  10145. */
  10146. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EBADHINTS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error)
  10147. __Pyx_GOTREF(__pyx_t_2);
  10148. __pyx_t_23 = PyTuple_New(2); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 115, __pyx_L1_error)
  10149. __Pyx_GOTREF(__pyx_t_23);
  10150. __Pyx_GIVEREF(__pyx_t_2);
  10151. PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_2);
  10152. __Pyx_INCREF(__pyx_n_s_ARES_EBADHINTS);
  10153. __Pyx_GIVEREF(__pyx_n_s_ARES_EBADHINTS);
  10154. PyTuple_SET_ITEM(__pyx_t_23, 1, __pyx_n_s_ARES_EBADHINTS);
  10155. __pyx_t_2 = 0;
  10156. /* "gevent/ares.pyx":116
  10157. * (cares.ARES_ENONAME, 'ARES_ENONAME'),
  10158. * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'),
  10159. * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'), # <<<<<<<<<<<<<<
  10160. * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'),
  10161. * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'),
  10162. */
  10163. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ENOTINITIALIZED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error)
  10164. __Pyx_GOTREF(__pyx_t_2);
  10165. __pyx_t_24 = PyTuple_New(2); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 116, __pyx_L1_error)
  10166. __Pyx_GOTREF(__pyx_t_24);
  10167. __Pyx_GIVEREF(__pyx_t_2);
  10168. PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_2);
  10169. __Pyx_INCREF(__pyx_n_s_ARES_ENOTINITIALIZED);
  10170. __Pyx_GIVEREF(__pyx_n_s_ARES_ENOTINITIALIZED);
  10171. PyTuple_SET_ITEM(__pyx_t_24, 1, __pyx_n_s_ARES_ENOTINITIALIZED);
  10172. __pyx_t_2 = 0;
  10173. /* "gevent/ares.pyx":117
  10174. * (cares.ARES_EBADHINTS, 'ARES_EBADHINTS'),
  10175. * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'),
  10176. * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'), # <<<<<<<<<<<<<<
  10177. * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'),
  10178. * (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')])
  10179. */
  10180. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ELOADIPHLPAPI); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error)
  10181. __Pyx_GOTREF(__pyx_t_2);
  10182. __pyx_t_25 = PyTuple_New(2); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 117, __pyx_L1_error)
  10183. __Pyx_GOTREF(__pyx_t_25);
  10184. __Pyx_GIVEREF(__pyx_t_2);
  10185. PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_t_2);
  10186. __Pyx_INCREF(__pyx_n_s_ARES_ELOADIPHLPAPI);
  10187. __Pyx_GIVEREF(__pyx_n_s_ARES_ELOADIPHLPAPI);
  10188. PyTuple_SET_ITEM(__pyx_t_25, 1, __pyx_n_s_ARES_ELOADIPHLPAPI);
  10189. __pyx_t_2 = 0;
  10190. /* "gevent/ares.pyx":118
  10191. * (cares.ARES_ENOTINITIALIZED, 'ARES_ENOTINITIALIZED'),
  10192. * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'),
  10193. * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'), # <<<<<<<<<<<<<<
  10194. * (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')])
  10195. *
  10196. */
  10197. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_EADDRGETNETWORKPARAMS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error)
  10198. __Pyx_GOTREF(__pyx_t_2);
  10199. __pyx_t_26 = PyTuple_New(2); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 118, __pyx_L1_error)
  10200. __Pyx_GOTREF(__pyx_t_26);
  10201. __Pyx_GIVEREF(__pyx_t_2);
  10202. PyTuple_SET_ITEM(__pyx_t_26, 0, __pyx_t_2);
  10203. __Pyx_INCREF(__pyx_n_s_ARES_EADDRGETNETWORKPARAMS);
  10204. __Pyx_GIVEREF(__pyx_n_s_ARES_EADDRGETNETWORKPARAMS);
  10205. PyTuple_SET_ITEM(__pyx_t_26, 1, __pyx_n_s_ARES_EADDRGETNETWORKPARAMS);
  10206. __pyx_t_2 = 0;
  10207. /* "gevent/ares.pyx":119
  10208. * (cares.ARES_ELOADIPHLPAPI, 'ARES_ELOADIPHLPAPI'),
  10209. * (cares.ARES_EADDRGETNETWORKPARAMS, 'ARES_EADDRGETNETWORKPARAMS'),
  10210. * (cares.ARES_ECANCELLED, 'ARES_ECANCELLED')]) # <<<<<<<<<<<<<<
  10211. *
  10212. *
  10213. */
  10214. __pyx_t_2 = __Pyx_PyInt_From_int(ARES_ECANCELLED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error)
  10215. __Pyx_GOTREF(__pyx_t_2);
  10216. __pyx_t_27 = PyTuple_New(2); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 119, __pyx_L1_error)
  10217. __Pyx_GOTREF(__pyx_t_27);
  10218. __Pyx_GIVEREF(__pyx_t_2);
  10219. PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_t_2);
  10220. __Pyx_INCREF(__pyx_n_s_ARES_ECANCELLED);
  10221. __Pyx_GIVEREF(__pyx_n_s_ARES_ECANCELLED);
  10222. PyTuple_SET_ITEM(__pyx_t_27, 1, __pyx_n_s_ARES_ECANCELLED);
  10223. __pyx_t_2 = 0;
  10224. /* "gevent/ares.pyx":94
  10225. *
  10226. *
  10227. * _ares_errors = dict([ # <<<<<<<<<<<<<<
  10228. * (cares.ARES_SUCCESS, 'ARES_SUCCESS'),
  10229. * (cares.ARES_ENODATA, 'ARES_ENODATA'),
  10230. */
  10231. __pyx_t_2 = PyList_New(25); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
  10232. __Pyx_GOTREF(__pyx_t_2);
  10233. __Pyx_GIVEREF(__pyx_t_1);
  10234. PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  10235. __Pyx_GIVEREF(__pyx_t_4);
  10236. PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
  10237. __Pyx_GIVEREF(__pyx_t_5);
  10238. PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
  10239. __Pyx_GIVEREF(__pyx_t_6);
  10240. PyList_SET_ITEM(__pyx_t_2, 3, __pyx_t_6);
  10241. __Pyx_GIVEREF(__pyx_t_7);
  10242. PyList_SET_ITEM(__pyx_t_2, 4, __pyx_t_7);
  10243. __Pyx_GIVEREF(__pyx_t_8);
  10244. PyList_SET_ITEM(__pyx_t_2, 5, __pyx_t_8);
  10245. __Pyx_GIVEREF(__pyx_t_9);
  10246. PyList_SET_ITEM(__pyx_t_2, 6, __pyx_t_9);
  10247. __Pyx_GIVEREF(__pyx_t_10);
  10248. PyList_SET_ITEM(__pyx_t_2, 7, __pyx_t_10);
  10249. __Pyx_GIVEREF(__pyx_t_11);
  10250. PyList_SET_ITEM(__pyx_t_2, 8, __pyx_t_11);
  10251. __Pyx_GIVEREF(__pyx_t_12);
  10252. PyList_SET_ITEM(__pyx_t_2, 9, __pyx_t_12);
  10253. __Pyx_GIVEREF(__pyx_t_13);
  10254. PyList_SET_ITEM(__pyx_t_2, 10, __pyx_t_13);
  10255. __Pyx_GIVEREF(__pyx_t_14);
  10256. PyList_SET_ITEM(__pyx_t_2, 11, __pyx_t_14);
  10257. __Pyx_GIVEREF(__pyx_t_15);
  10258. PyList_SET_ITEM(__pyx_t_2, 12, __pyx_t_15);
  10259. __Pyx_GIVEREF(__pyx_t_16);
  10260. PyList_SET_ITEM(__pyx_t_2, 13, __pyx_t_16);
  10261. __Pyx_GIVEREF(__pyx_t_17);
  10262. PyList_SET_ITEM(__pyx_t_2, 14, __pyx_t_17);
  10263. __Pyx_GIVEREF(__pyx_t_18);
  10264. PyList_SET_ITEM(__pyx_t_2, 15, __pyx_t_18);
  10265. __Pyx_GIVEREF(__pyx_t_19);
  10266. PyList_SET_ITEM(__pyx_t_2, 16, __pyx_t_19);
  10267. __Pyx_GIVEREF(__pyx_t_20);
  10268. PyList_SET_ITEM(__pyx_t_2, 17, __pyx_t_20);
  10269. __Pyx_GIVEREF(__pyx_t_21);
  10270. PyList_SET_ITEM(__pyx_t_2, 18, __pyx_t_21);
  10271. __Pyx_GIVEREF(__pyx_t_22);
  10272. PyList_SET_ITEM(__pyx_t_2, 19, __pyx_t_22);
  10273. __Pyx_GIVEREF(__pyx_t_23);
  10274. PyList_SET_ITEM(__pyx_t_2, 20, __pyx_t_23);
  10275. __Pyx_GIVEREF(__pyx_t_24);
  10276. PyList_SET_ITEM(__pyx_t_2, 21, __pyx_t_24);
  10277. __Pyx_GIVEREF(__pyx_t_25);
  10278. PyList_SET_ITEM(__pyx_t_2, 22, __pyx_t_25);
  10279. __Pyx_GIVEREF(__pyx_t_26);
  10280. PyList_SET_ITEM(__pyx_t_2, 23, __pyx_t_26);
  10281. __Pyx_GIVEREF(__pyx_t_27);
  10282. PyList_SET_ITEM(__pyx_t_2, 24, __pyx_t_27);
  10283. __pyx_t_1 = 0;
  10284. __pyx_t_4 = 0;
  10285. __pyx_t_5 = 0;
  10286. __pyx_t_6 = 0;
  10287. __pyx_t_7 = 0;
  10288. __pyx_t_8 = 0;
  10289. __pyx_t_9 = 0;
  10290. __pyx_t_10 = 0;
  10291. __pyx_t_11 = 0;
  10292. __pyx_t_12 = 0;
  10293. __pyx_t_13 = 0;
  10294. __pyx_t_14 = 0;
  10295. __pyx_t_15 = 0;
  10296. __pyx_t_16 = 0;
  10297. __pyx_t_17 = 0;
  10298. __pyx_t_18 = 0;
  10299. __pyx_t_19 = 0;
  10300. __pyx_t_20 = 0;
  10301. __pyx_t_21 = 0;
  10302. __pyx_t_22 = 0;
  10303. __pyx_t_23 = 0;
  10304. __pyx_t_24 = 0;
  10305. __pyx_t_25 = 0;
  10306. __pyx_t_26 = 0;
  10307. __pyx_t_27 = 0;
  10308. __pyx_t_27 = PyTuple_New(1); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 94, __pyx_L1_error)
  10309. __Pyx_GOTREF(__pyx_t_27);
  10310. __Pyx_GIVEREF(__pyx_t_2);
  10311. PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_t_2);
  10312. __pyx_t_2 = 0;
  10313. __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyDict_Type)), __pyx_t_27, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error)
  10314. __Pyx_GOTREF(__pyx_t_2);
  10315. __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
  10316. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ares_errors, __pyx_t_2) < 0) __PYX_ERR(0, 94, __pyx_L1_error)
  10317. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  10318. /* "gevent/ares.pyx":123
  10319. *
  10320. * # maps c-ares flag to _socket module flag
  10321. * _cares_flag_map = None # <<<<<<<<<<<<<<
  10322. *
  10323. *
  10324. */
  10325. if (PyDict_SetItem(__pyx_d, __pyx_n_s_cares_flag_map, Py_None) < 0) __PYX_ERR(0, 123, __pyx_L1_error)
  10326. /* "gevent/ares.pyx":137
  10327. *
  10328. *
  10329. * cpdef _convert_cares_flags(int flags, int default=cares.ARES_NI_LOOKUPHOST|cares.ARES_NI_LOOKUPSERVICE): # <<<<<<<<<<<<<<
  10330. * if _cares_flag_map is None:
  10331. * _prepare_cares_flag_map()
  10332. */
  10333. __pyx_k_ = (ARES_NI_LOOKUPHOST | ARES_NI_LOOKUPSERVICE);
  10334. __pyx_k_ = (ARES_NI_LOOKUPHOST | ARES_NI_LOOKUPSERVICE);
  10335. /* "gevent/ares.pyx":153
  10336. *
  10337. *
  10338. * class InvalidIP(ValueError): # <<<<<<<<<<<<<<
  10339. * pass
  10340. *
  10341. */
  10342. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error)
  10343. __Pyx_GOTREF(__pyx_t_2);
  10344. __Pyx_INCREF(__pyx_builtin_ValueError);
  10345. __Pyx_GIVEREF(__pyx_builtin_ValueError);
  10346. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_ValueError);
  10347. __pyx_t_27 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 153, __pyx_L1_error)
  10348. __Pyx_GOTREF(__pyx_t_27);
  10349. __pyx_t_26 = __Pyx_Py3MetaclassPrepare(__pyx_t_27, __pyx_t_2, __pyx_n_s_InvalidIP, __pyx_n_s_InvalidIP, (PyObject *) NULL, __pyx_n_s_gevent_ares, (PyObject *) NULL); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 153, __pyx_L1_error)
  10350. __Pyx_GOTREF(__pyx_t_26);
  10351. __pyx_t_25 = __Pyx_Py3ClassCreate(__pyx_t_27, __pyx_n_s_InvalidIP, __pyx_t_2, __pyx_t_26, NULL, 0, 1); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 153, __pyx_L1_error)
  10352. __Pyx_GOTREF(__pyx_t_25);
  10353. if (PyDict_SetItem(__pyx_d, __pyx_n_s_InvalidIP, __pyx_t_25) < 0) __PYX_ERR(0, 153, __pyx_L1_error)
  10354. __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
  10355. __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
  10356. __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
  10357. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  10358. /* "gevent/ares.pyx":190
  10359. *
  10360. *
  10361. * class ares_host_result(tuple): # <<<<<<<<<<<<<<
  10362. *
  10363. * def __new__(cls, family, iterable):
  10364. */
  10365. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error)
  10366. __Pyx_GOTREF(__pyx_t_2);
  10367. __Pyx_INCREF(((PyObject *)(&PyTuple_Type)));
  10368. __Pyx_GIVEREF(((PyObject *)(&PyTuple_Type)));
  10369. PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)(&PyTuple_Type)));
  10370. __pyx_t_27 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 190, __pyx_L1_error)
  10371. __Pyx_GOTREF(__pyx_t_27);
  10372. __pyx_t_26 = __Pyx_Py3MetaclassPrepare(__pyx_t_27, __pyx_t_2, __pyx_n_s_ares_host_result, __pyx_n_s_ares_host_result, (PyObject *) NULL, __pyx_n_s_gevent_ares, (PyObject *) NULL); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 190, __pyx_L1_error)
  10373. __Pyx_GOTREF(__pyx_t_26);
  10374. /* "gevent/ares.pyx":192
  10375. * class ares_host_result(tuple):
  10376. *
  10377. * def __new__(cls, family, iterable): # <<<<<<<<<<<<<<
  10378. * cdef object self = tuple.__new__(cls, iterable)
  10379. * self.family = family
  10380. */
  10381. __pyx_t_25 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_4ares_16ares_host_result_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_ares_host_result___new, NULL, __pyx_n_s_gevent_ares, __pyx_d, ((PyObject *)__pyx_codeobj__7)); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 192, __pyx_L1_error)
  10382. __Pyx_GOTREF(__pyx_t_25);
  10383. if (PyObject_SetItem(__pyx_t_26, __pyx_n_s_new, __pyx_t_25) < 0) __PYX_ERR(0, 192, __pyx_L1_error)
  10384. __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
  10385. /* "gevent/ares.pyx":197
  10386. * return self
  10387. *
  10388. * def __getnewargs__(self): # <<<<<<<<<<<<<<
  10389. * return (self.family, tuple(self))
  10390. *
  10391. */
  10392. __pyx_t_25 = __Pyx_CyFunction_NewEx(&__pyx_mdef_6gevent_4ares_16ares_host_result_3__getnewargs__, 0, __pyx_n_s_ares_host_result___getnewargs, NULL, __pyx_n_s_gevent_ares, __pyx_d, ((PyObject *)__pyx_codeobj__9)); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 197, __pyx_L1_error)
  10393. __Pyx_GOTREF(__pyx_t_25);
  10394. if (PyObject_SetItem(__pyx_t_26, __pyx_n_s_getnewargs, __pyx_t_25) < 0) __PYX_ERR(0, 197, __pyx_L1_error)
  10395. __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
  10396. /* "gevent/ares.pyx":190
  10397. *
  10398. *
  10399. * class ares_host_result(tuple): # <<<<<<<<<<<<<<
  10400. *
  10401. * def __new__(cls, family, iterable):
  10402. */
  10403. __pyx_t_25 = __Pyx_Py3ClassCreate(__pyx_t_27, __pyx_n_s_ares_host_result, __pyx_t_2, __pyx_t_26, NULL, 0, 1); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 190, __pyx_L1_error)
  10404. __Pyx_GOTREF(__pyx_t_25);
  10405. if (PyDict_SetItem(__pyx_d, __pyx_n_s_ares_host_result, __pyx_t_25) < 0) __PYX_ERR(0, 190, __pyx_L1_error)
  10406. __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
  10407. __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
  10408. __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
  10409. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  10410. /* "gevent/ares.pyx":400
  10411. * cares.ares_process_fd(self.channel, read_fd, write_fd)
  10412. *
  10413. * def gethostbyname(self, object callback, char* name, int family=AF_INET): # <<<<<<<<<<<<<<
  10414. * if not self.channel:
  10415. * raise gaierror(cares.ARES_EDESTRUCTION, 'this ares channel has been destroyed')
  10416. */
  10417. __pyx_k__5 = AF_INET;
  10418. /* "gevent/ares.pyx":1
  10419. * # Copyright (c) 2011-2012 Denis Bilenko. See LICENSE for details. # <<<<<<<<<<<<<<
  10420. * cimport cares
  10421. * import sys
  10422. */
  10423. __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  10424. __Pyx_GOTREF(__pyx_t_2);
  10425. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  10426. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  10427. /*--- Wrapped vars code ---*/
  10428. goto __pyx_L0;
  10429. __pyx_L1_error:;
  10430. __Pyx_XDECREF(__pyx_t_1);
  10431. __Pyx_XDECREF(__pyx_t_2);
  10432. __Pyx_XDECREF(__pyx_t_4);
  10433. __Pyx_XDECREF(__pyx_t_5);
  10434. __Pyx_XDECREF(__pyx_t_6);
  10435. __Pyx_XDECREF(__pyx_t_7);
  10436. __Pyx_XDECREF(__pyx_t_8);
  10437. __Pyx_XDECREF(__pyx_t_9);
  10438. __Pyx_XDECREF(__pyx_t_10);
  10439. __Pyx_XDECREF(__pyx_t_11);
  10440. __Pyx_XDECREF(__pyx_t_12);
  10441. __Pyx_XDECREF(__pyx_t_13);
  10442. __Pyx_XDECREF(__pyx_t_14);
  10443. __Pyx_XDECREF(__pyx_t_15);
  10444. __Pyx_XDECREF(__pyx_t_16);
  10445. __Pyx_XDECREF(__pyx_t_17);
  10446. __Pyx_XDECREF(__pyx_t_18);
  10447. __Pyx_XDECREF(__pyx_t_19);
  10448. __Pyx_XDECREF(__pyx_t_20);
  10449. __Pyx_XDECREF(__pyx_t_21);
  10450. __Pyx_XDECREF(__pyx_t_22);
  10451. __Pyx_XDECREF(__pyx_t_23);
  10452. __Pyx_XDECREF(__pyx_t_24);
  10453. __Pyx_XDECREF(__pyx_t_25);
  10454. __Pyx_XDECREF(__pyx_t_26);
  10455. __Pyx_XDECREF(__pyx_t_27);
  10456. if (__pyx_m) {
  10457. if (__pyx_d) {
  10458. __Pyx_AddTraceback("init gevent.ares", __pyx_clineno, __pyx_lineno, __pyx_filename);
  10459. }
  10460. Py_DECREF(__pyx_m); __pyx_m = 0;
  10461. } else if (!PyErr_Occurred()) {
  10462. PyErr_SetString(PyExc_ImportError, "init gevent.ares");
  10463. }
  10464. __pyx_L0:;
  10465. __Pyx_RefNannyFinishContext();
  10466. #if PY_MAJOR_VERSION < 3
  10467. return;
  10468. #else
  10469. return __pyx_m;
  10470. #endif
  10471. }
  10472. /* --- Runtime support code --- */
  10473. /* Refnanny */
  10474. #if CYTHON_REFNANNY
  10475. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  10476. PyObject *m = NULL, *p = NULL;
  10477. void *r = NULL;
  10478. m = PyImport_ImportModule((char *)modname);
  10479. if (!m) goto end;
  10480. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  10481. if (!p) goto end;
  10482. r = PyLong_AsVoidPtr(p);
  10483. end:
  10484. Py_XDECREF(p);
  10485. Py_XDECREF(m);
  10486. return (__Pyx_RefNannyAPIStruct *)r;
  10487. }
  10488. #endif
  10489. /* GetBuiltinName */
  10490. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  10491. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  10492. if (unlikely(!result)) {
  10493. PyErr_Format(PyExc_NameError,
  10494. #if PY_MAJOR_VERSION >= 3
  10495. "name '%U' is not defined", name);
  10496. #else
  10497. "name '%.200s' is not defined", PyString_AS_STRING(name));
  10498. #endif
  10499. }
  10500. return result;
  10501. }
  10502. /* Import */
  10503. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  10504. PyObject *empty_list = 0;
  10505. PyObject *module = 0;
  10506. PyObject *global_dict = 0;
  10507. PyObject *empty_dict = 0;
  10508. PyObject *list;
  10509. #if PY_VERSION_HEX < 0x03030000
  10510. PyObject *py_import;
  10511. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  10512. if (!py_import)
  10513. goto bad;
  10514. #endif
  10515. if (from_list)
  10516. list = from_list;
  10517. else {
  10518. empty_list = PyList_New(0);
  10519. if (!empty_list)
  10520. goto bad;
  10521. list = empty_list;
  10522. }
  10523. global_dict = PyModule_GetDict(__pyx_m);
  10524. if (!global_dict)
  10525. goto bad;
  10526. empty_dict = PyDict_New();
  10527. if (!empty_dict)
  10528. goto bad;
  10529. {
  10530. #if PY_MAJOR_VERSION >= 3
  10531. if (level == -1) {
  10532. if (strchr(__Pyx_MODULE_NAME, '.')) {
  10533. #if PY_VERSION_HEX < 0x03030000
  10534. PyObject *py_level = PyInt_FromLong(1);
  10535. if (!py_level)
  10536. goto bad;
  10537. module = PyObject_CallFunctionObjArgs(py_import,
  10538. name, global_dict, empty_dict, list, py_level, NULL);
  10539. Py_DECREF(py_level);
  10540. #else
  10541. module = PyImport_ImportModuleLevelObject(
  10542. name, global_dict, empty_dict, list, 1);
  10543. #endif
  10544. if (!module) {
  10545. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  10546. goto bad;
  10547. PyErr_Clear();
  10548. }
  10549. }
  10550. level = 0;
  10551. }
  10552. #endif
  10553. if (!module) {
  10554. #if PY_VERSION_HEX < 0x03030000
  10555. PyObject *py_level = PyInt_FromLong(level);
  10556. if (!py_level)
  10557. goto bad;
  10558. module = PyObject_CallFunctionObjArgs(py_import,
  10559. name, global_dict, empty_dict, list, py_level, NULL);
  10560. Py_DECREF(py_level);
  10561. #else
  10562. module = PyImport_ImportModuleLevelObject(
  10563. name, global_dict, empty_dict, list, level);
  10564. #endif
  10565. }
  10566. }
  10567. bad:
  10568. #if PY_VERSION_HEX < 0x03030000
  10569. Py_XDECREF(py_import);
  10570. #endif
  10571. Py_XDECREF(empty_list);
  10572. Py_XDECREF(empty_dict);
  10573. return module;
  10574. }
  10575. /* GetAttr */
  10576. static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
  10577. #if CYTHON_COMPILING_IN_CPYTHON
  10578. #if PY_MAJOR_VERSION >= 3
  10579. if (likely(PyUnicode_Check(n)))
  10580. #else
  10581. if (likely(PyString_Check(n)))
  10582. #endif
  10583. return __Pyx_PyObject_GetAttrStr(o, n);
  10584. #endif
  10585. return PyObject_GetAttr(o, n);
  10586. }
  10587. /* GetAttr3 */
  10588. static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
  10589. PyObject *r = __Pyx_GetAttr(o, n);
  10590. if (unlikely(!r)) {
  10591. if (!PyErr_ExceptionMatches(PyExc_AttributeError))
  10592. goto bad;
  10593. PyErr_Clear();
  10594. r = d;
  10595. Py_INCREF(d);
  10596. }
  10597. return r;
  10598. bad:
  10599. return NULL;
  10600. }
  10601. /* GetModuleGlobalName */
  10602. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
  10603. PyObject *result;
  10604. #if !CYTHON_AVOID_BORROWED_REFS
  10605. result = PyDict_GetItem(__pyx_d, name);
  10606. if (likely(result)) {
  10607. Py_INCREF(result);
  10608. } else {
  10609. #else
  10610. result = PyObject_GetItem(__pyx_d, name);
  10611. if (!result) {
  10612. PyErr_Clear();
  10613. #endif
  10614. result = __Pyx_GetBuiltinName(name);
  10615. }
  10616. return result;
  10617. }
  10618. /* RaiseTooManyValuesToUnpack */
  10619. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
  10620. PyErr_Format(PyExc_ValueError,
  10621. "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
  10622. }
  10623. /* RaiseNeedMoreValuesToUnpack */
  10624. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
  10625. PyErr_Format(PyExc_ValueError,
  10626. "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
  10627. index, (index == 1) ? "" : "s");
  10628. }
  10629. /* IterFinish */
  10630. static CYTHON_INLINE int __Pyx_IterFinish(void) {
  10631. #if CYTHON_FAST_THREAD_STATE
  10632. PyThreadState *tstate = PyThreadState_GET();
  10633. PyObject* exc_type = tstate->curexc_type;
  10634. if (unlikely(exc_type)) {
  10635. if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
  10636. PyObject *exc_value, *exc_tb;
  10637. exc_value = tstate->curexc_value;
  10638. exc_tb = tstate->curexc_traceback;
  10639. tstate->curexc_type = 0;
  10640. tstate->curexc_value = 0;
  10641. tstate->curexc_traceback = 0;
  10642. Py_DECREF(exc_type);
  10643. Py_XDECREF(exc_value);
  10644. Py_XDECREF(exc_tb);
  10645. return 0;
  10646. } else {
  10647. return -1;
  10648. }
  10649. }
  10650. return 0;
  10651. #else
  10652. if (unlikely(PyErr_Occurred())) {
  10653. if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
  10654. PyErr_Clear();
  10655. return 0;
  10656. } else {
  10657. return -1;
  10658. }
  10659. }
  10660. return 0;
  10661. #endif
  10662. }
  10663. /* UnpackItemEndCheck */
  10664. static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
  10665. if (unlikely(retval)) {
  10666. Py_DECREF(retval);
  10667. __Pyx_RaiseTooManyValuesError(expected);
  10668. return -1;
  10669. } else {
  10670. return __Pyx_IterFinish();
  10671. }
  10672. return 0;
  10673. }
  10674. /* PyFunctionFastCall */
  10675. #if CYTHON_FAST_PYCALL
  10676. #include "frameobject.h"
  10677. static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
  10678. PyObject *globals) {
  10679. PyFrameObject *f;
  10680. PyThreadState *tstate = PyThreadState_GET();
  10681. PyObject **fastlocals;
  10682. Py_ssize_t i;
  10683. PyObject *result;
  10684. assert(globals != NULL);
  10685. /* XXX Perhaps we should create a specialized
  10686. PyFrame_New() that doesn't take locals, but does
  10687. take builtins without sanity checking them.
  10688. */
  10689. assert(tstate != NULL);
  10690. f = PyFrame_New(tstate, co, globals, NULL);
  10691. if (f == NULL) {
  10692. return NULL;
  10693. }
  10694. fastlocals = f->f_localsplus;
  10695. for (i = 0; i < na; i++) {
  10696. Py_INCREF(*args);
  10697. fastlocals[i] = *args++;
  10698. }
  10699. result = PyEval_EvalFrameEx(f,0);
  10700. ++tstate->recursion_depth;
  10701. Py_DECREF(f);
  10702. --tstate->recursion_depth;
  10703. return result;
  10704. }
  10705. #if 1 || PY_VERSION_HEX < 0x030600B1
  10706. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) {
  10707. PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
  10708. PyObject *globals = PyFunction_GET_GLOBALS(func);
  10709. PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
  10710. PyObject *closure;
  10711. #if PY_MAJOR_VERSION >= 3
  10712. PyObject *kwdefs;
  10713. #endif
  10714. PyObject *kwtuple, **k;
  10715. PyObject **d;
  10716. Py_ssize_t nd;
  10717. Py_ssize_t nk;
  10718. PyObject *result;
  10719. assert(kwargs == NULL || PyDict_Check(kwargs));
  10720. nk = kwargs ? PyDict_Size(kwargs) : 0;
  10721. if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
  10722. return NULL;
  10723. }
  10724. if (
  10725. #if PY_MAJOR_VERSION >= 3
  10726. co->co_kwonlyargcount == 0 &&
  10727. #endif
  10728. likely(kwargs == NULL || nk == 0) &&
  10729. co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
  10730. if (argdefs == NULL && co->co_argcount == nargs) {
  10731. result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
  10732. goto done;
  10733. }
  10734. else if (nargs == 0 && argdefs != NULL
  10735. && co->co_argcount == Py_SIZE(argdefs)) {
  10736. /* function called with no arguments, but all parameters have
  10737. a default value: use default values as arguments .*/
  10738. args = &PyTuple_GET_ITEM(argdefs, 0);
  10739. result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
  10740. goto done;
  10741. }
  10742. }
  10743. if (kwargs != NULL) {
  10744. Py_ssize_t pos, i;
  10745. kwtuple = PyTuple_New(2 * nk);
  10746. if (kwtuple == NULL) {
  10747. result = NULL;
  10748. goto done;
  10749. }
  10750. k = &PyTuple_GET_ITEM(kwtuple, 0);
  10751. pos = i = 0;
  10752. while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
  10753. Py_INCREF(k[i]);
  10754. Py_INCREF(k[i+1]);
  10755. i += 2;
  10756. }
  10757. nk = i / 2;
  10758. }
  10759. else {
  10760. kwtuple = NULL;
  10761. k = NULL;
  10762. }
  10763. closure = PyFunction_GET_CLOSURE(func);
  10764. #if PY_MAJOR_VERSION >= 3
  10765. kwdefs = PyFunction_GET_KW_DEFAULTS(func);
  10766. #endif
  10767. if (argdefs != NULL) {
  10768. d = &PyTuple_GET_ITEM(argdefs, 0);
  10769. nd = Py_SIZE(argdefs);
  10770. }
  10771. else {
  10772. d = NULL;
  10773. nd = 0;
  10774. }
  10775. #if PY_MAJOR_VERSION >= 3
  10776. result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
  10777. args, nargs,
  10778. k, (int)nk,
  10779. d, (int)nd, kwdefs, closure);
  10780. #else
  10781. result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
  10782. args, nargs,
  10783. k, (int)nk,
  10784. d, (int)nd, closure);
  10785. #endif
  10786. Py_XDECREF(kwtuple);
  10787. done:
  10788. Py_LeaveRecursiveCall();
  10789. return result;
  10790. }
  10791. #endif // CPython < 3.6
  10792. #endif // CYTHON_FAST_PYCALL
  10793. /* PyCFunctionFastCall */
  10794. #if CYTHON_FAST_PYCCALL
  10795. static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
  10796. PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
  10797. PyCFunction meth = PyCFunction_GET_FUNCTION(func);
  10798. PyObject *self = PyCFunction_GET_SELF(func);
  10799. assert(PyCFunction_Check(func));
  10800. assert(METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)));
  10801. assert(nargs >= 0);
  10802. assert(nargs == 0 || args != NULL);
  10803. /* _PyCFunction_FastCallDict() must not be called with an exception set,
  10804. because it may clear it (directly or indirectly) and so the
  10805. caller loses its exception */
  10806. assert(!PyErr_Occurred());
  10807. return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
  10808. }
  10809. #endif // CYTHON_FAST_PYCCALL
  10810. /* PyObjectCall */
  10811. #if CYTHON_COMPILING_IN_CPYTHON
  10812. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  10813. PyObject *result;
  10814. ternaryfunc call = func->ob_type->tp_call;
  10815. if (unlikely(!call))
  10816. return PyObject_Call(func, arg, kw);
  10817. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  10818. return NULL;
  10819. result = (*call)(func, arg, kw);
  10820. Py_LeaveRecursiveCall();
  10821. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  10822. PyErr_SetString(
  10823. PyExc_SystemError,
  10824. "NULL result without error in PyObject_Call");
  10825. }
  10826. return result;
  10827. }
  10828. #endif
  10829. /* PyErrFetchRestore */
  10830. #if CYTHON_FAST_THREAD_STATE
  10831. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  10832. PyObject *tmp_type, *tmp_value, *tmp_tb;
  10833. tmp_type = tstate->curexc_type;
  10834. tmp_value = tstate->curexc_value;
  10835. tmp_tb = tstate->curexc_traceback;
  10836. tstate->curexc_type = type;
  10837. tstate->curexc_value = value;
  10838. tstate->curexc_traceback = tb;
  10839. Py_XDECREF(tmp_type);
  10840. Py_XDECREF(tmp_value);
  10841. Py_XDECREF(tmp_tb);
  10842. }
  10843. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  10844. *type = tstate->curexc_type;
  10845. *value = tstate->curexc_value;
  10846. *tb = tstate->curexc_traceback;
  10847. tstate->curexc_type = 0;
  10848. tstate->curexc_value = 0;
  10849. tstate->curexc_traceback = 0;
  10850. }
  10851. #endif
  10852. /* RaiseException */
  10853. #if PY_MAJOR_VERSION < 3
  10854. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
  10855. CYTHON_UNUSED PyObject *cause) {
  10856. __Pyx_PyThreadState_declare
  10857. Py_XINCREF(type);
  10858. if (!value || value == Py_None)
  10859. value = NULL;
  10860. else
  10861. Py_INCREF(value);
  10862. if (!tb || tb == Py_None)
  10863. tb = NULL;
  10864. else {
  10865. Py_INCREF(tb);
  10866. if (!PyTraceBack_Check(tb)) {
  10867. PyErr_SetString(PyExc_TypeError,
  10868. "raise: arg 3 must be a traceback or None");
  10869. goto raise_error;
  10870. }
  10871. }
  10872. if (PyType_Check(type)) {
  10873. #if CYTHON_COMPILING_IN_PYPY
  10874. if (!value) {
  10875. Py_INCREF(Py_None);
  10876. value = Py_None;
  10877. }
  10878. #endif
  10879. PyErr_NormalizeException(&type, &value, &tb);
  10880. } else {
  10881. if (value) {
  10882. PyErr_SetString(PyExc_TypeError,
  10883. "instance exception may not have a separate value");
  10884. goto raise_error;
  10885. }
  10886. value = type;
  10887. type = (PyObject*) Py_TYPE(type);
  10888. Py_INCREF(type);
  10889. if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
  10890. PyErr_SetString(PyExc_TypeError,
  10891. "raise: exception class must be a subclass of BaseException");
  10892. goto raise_error;
  10893. }
  10894. }
  10895. __Pyx_PyThreadState_assign
  10896. __Pyx_ErrRestore(type, value, tb);
  10897. return;
  10898. raise_error:
  10899. Py_XDECREF(value);
  10900. Py_XDECREF(type);
  10901. Py_XDECREF(tb);
  10902. return;
  10903. }
  10904. #else
  10905. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  10906. PyObject* owned_instance = NULL;
  10907. if (tb == Py_None) {
  10908. tb = 0;
  10909. } else if (tb && !PyTraceBack_Check(tb)) {
  10910. PyErr_SetString(PyExc_TypeError,
  10911. "raise: arg 3 must be a traceback or None");
  10912. goto bad;
  10913. }
  10914. if (value == Py_None)
  10915. value = 0;
  10916. if (PyExceptionInstance_Check(type)) {
  10917. if (value) {
  10918. PyErr_SetString(PyExc_TypeError,
  10919. "instance exception may not have a separate value");
  10920. goto bad;
  10921. }
  10922. value = type;
  10923. type = (PyObject*) Py_TYPE(value);
  10924. } else if (PyExceptionClass_Check(type)) {
  10925. PyObject *instance_class = NULL;
  10926. if (value && PyExceptionInstance_Check(value)) {
  10927. instance_class = (PyObject*) Py_TYPE(value);
  10928. if (instance_class != type) {
  10929. int is_subclass = PyObject_IsSubclass(instance_class, type);
  10930. if (!is_subclass) {
  10931. instance_class = NULL;
  10932. } else if (unlikely(is_subclass == -1)) {
  10933. goto bad;
  10934. } else {
  10935. type = instance_class;
  10936. }
  10937. }
  10938. }
  10939. if (!instance_class) {
  10940. PyObject *args;
  10941. if (!value)
  10942. args = PyTuple_New(0);
  10943. else if (PyTuple_Check(value)) {
  10944. Py_INCREF(value);
  10945. args = value;
  10946. } else
  10947. args = PyTuple_Pack(1, value);
  10948. if (!args)
  10949. goto bad;
  10950. owned_instance = PyObject_Call(type, args, NULL);
  10951. Py_DECREF(args);
  10952. if (!owned_instance)
  10953. goto bad;
  10954. value = owned_instance;
  10955. if (!PyExceptionInstance_Check(value)) {
  10956. PyErr_Format(PyExc_TypeError,
  10957. "calling %R should have returned an instance of "
  10958. "BaseException, not %R",
  10959. type, Py_TYPE(value));
  10960. goto bad;
  10961. }
  10962. }
  10963. } else {
  10964. PyErr_SetString(PyExc_TypeError,
  10965. "raise: exception class must be a subclass of BaseException");
  10966. goto bad;
  10967. }
  10968. #if PY_VERSION_HEX >= 0x03030000
  10969. if (cause) {
  10970. #else
  10971. if (cause && cause != Py_None) {
  10972. #endif
  10973. PyObject *fixed_cause;
  10974. if (cause == Py_None) {
  10975. fixed_cause = NULL;
  10976. } else if (PyExceptionClass_Check(cause)) {
  10977. fixed_cause = PyObject_CallObject(cause, NULL);
  10978. if (fixed_cause == NULL)
  10979. goto bad;
  10980. } else if (PyExceptionInstance_Check(cause)) {
  10981. fixed_cause = cause;
  10982. Py_INCREF(fixed_cause);
  10983. } else {
  10984. PyErr_SetString(PyExc_TypeError,
  10985. "exception causes must derive from "
  10986. "BaseException");
  10987. goto bad;
  10988. }
  10989. PyException_SetCause(value, fixed_cause);
  10990. }
  10991. PyErr_SetObject(type, value);
  10992. if (tb) {
  10993. #if CYTHON_COMPILING_IN_PYPY
  10994. PyObject *tmp_type, *tmp_value, *tmp_tb;
  10995. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  10996. Py_INCREF(tb);
  10997. PyErr_Restore(tmp_type, tmp_value, tb);
  10998. Py_XDECREF(tmp_tb);
  10999. #else
  11000. PyThreadState *tstate = PyThreadState_GET();
  11001. PyObject* tmp_tb = tstate->curexc_traceback;
  11002. if (tb != tmp_tb) {
  11003. Py_INCREF(tb);
  11004. tstate->curexc_traceback = tb;
  11005. Py_XDECREF(tmp_tb);
  11006. }
  11007. #endif
  11008. }
  11009. bad:
  11010. Py_XDECREF(owned_instance);
  11011. return;
  11012. }
  11013. #endif
  11014. /* RaiseDoubleKeywords */
  11015. static void __Pyx_RaiseDoubleKeywordsError(
  11016. const char* func_name,
  11017. PyObject* kw_name)
  11018. {
  11019. PyErr_Format(PyExc_TypeError,
  11020. #if PY_MAJOR_VERSION >= 3
  11021. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  11022. #else
  11023. "%s() got multiple values for keyword argument '%s'", func_name,
  11024. PyString_AsString(kw_name));
  11025. #endif
  11026. }
  11027. /* ParseKeywords */
  11028. static int __Pyx_ParseOptionalKeywords(
  11029. PyObject *kwds,
  11030. PyObject **argnames[],
  11031. PyObject *kwds2,
  11032. PyObject *values[],
  11033. Py_ssize_t num_pos_args,
  11034. const char* function_name)
  11035. {
  11036. PyObject *key = 0, *value = 0;
  11037. Py_ssize_t pos = 0;
  11038. PyObject*** name;
  11039. PyObject*** first_kw_arg = argnames + num_pos_args;
  11040. while (PyDict_Next(kwds, &pos, &key, &value)) {
  11041. name = first_kw_arg;
  11042. while (*name && (**name != key)) name++;
  11043. if (*name) {
  11044. values[name-argnames] = value;
  11045. continue;
  11046. }
  11047. name = first_kw_arg;
  11048. #if PY_MAJOR_VERSION < 3
  11049. if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
  11050. while (*name) {
  11051. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  11052. && _PyString_Eq(**name, key)) {
  11053. values[name-argnames] = value;
  11054. break;
  11055. }
  11056. name++;
  11057. }
  11058. if (*name) continue;
  11059. else {
  11060. PyObject*** argname = argnames;
  11061. while (argname != first_kw_arg) {
  11062. if ((**argname == key) || (
  11063. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  11064. && _PyString_Eq(**argname, key))) {
  11065. goto arg_passed_twice;
  11066. }
  11067. argname++;
  11068. }
  11069. }
  11070. } else
  11071. #endif
  11072. if (likely(PyUnicode_Check(key))) {
  11073. while (*name) {
  11074. int cmp = (**name == key) ? 0 :
  11075. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  11076. (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
  11077. #endif
  11078. PyUnicode_Compare(**name, key);
  11079. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  11080. if (cmp == 0) {
  11081. values[name-argnames] = value;
  11082. break;
  11083. }
  11084. name++;
  11085. }
  11086. if (*name) continue;
  11087. else {
  11088. PyObject*** argname = argnames;
  11089. while (argname != first_kw_arg) {
  11090. int cmp = (**argname == key) ? 0 :
  11091. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  11092. (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
  11093. #endif
  11094. PyUnicode_Compare(**argname, key);
  11095. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  11096. if (cmp == 0) goto arg_passed_twice;
  11097. argname++;
  11098. }
  11099. }
  11100. } else
  11101. goto invalid_keyword_type;
  11102. if (kwds2) {
  11103. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  11104. } else {
  11105. goto invalid_keyword;
  11106. }
  11107. }
  11108. return 0;
  11109. arg_passed_twice:
  11110. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  11111. goto bad;
  11112. invalid_keyword_type:
  11113. PyErr_Format(PyExc_TypeError,
  11114. "%.200s() keywords must be strings", function_name);
  11115. goto bad;
  11116. invalid_keyword:
  11117. PyErr_Format(PyExc_TypeError,
  11118. #if PY_MAJOR_VERSION < 3
  11119. "%.200s() got an unexpected keyword argument '%.200s'",
  11120. function_name, PyString_AsString(key));
  11121. #else
  11122. "%s() got an unexpected keyword argument '%U'",
  11123. function_name, key);
  11124. #endif
  11125. bad:
  11126. return -1;
  11127. }
  11128. /* RaiseArgTupleInvalid */
  11129. static void __Pyx_RaiseArgtupleInvalid(
  11130. const char* func_name,
  11131. int exact,
  11132. Py_ssize_t num_min,
  11133. Py_ssize_t num_max,
  11134. Py_ssize_t num_found)
  11135. {
  11136. Py_ssize_t num_expected;
  11137. const char *more_or_less;
  11138. if (num_found < num_min) {
  11139. num_expected = num_min;
  11140. more_or_less = "at least";
  11141. } else {
  11142. num_expected = num_max;
  11143. more_or_less = "at most";
  11144. }
  11145. if (exact) {
  11146. more_or_less = "exactly";
  11147. }
  11148. PyErr_Format(PyExc_TypeError,
  11149. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  11150. func_name, more_or_less, num_expected,
  11151. (num_expected == 1) ? "" : "s", num_found);
  11152. }
  11153. /* PyObjectCallMethO */
  11154. #if CYTHON_COMPILING_IN_CPYTHON
  11155. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  11156. PyObject *self, *result;
  11157. PyCFunction cfunc;
  11158. cfunc = PyCFunction_GET_FUNCTION(func);
  11159. self = PyCFunction_GET_SELF(func);
  11160. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  11161. return NULL;
  11162. result = cfunc(self, arg);
  11163. Py_LeaveRecursiveCall();
  11164. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  11165. PyErr_SetString(
  11166. PyExc_SystemError,
  11167. "NULL result without error in PyObject_Call");
  11168. }
  11169. return result;
  11170. }
  11171. #endif
  11172. /* PyObjectCallOneArg */
  11173. #if CYTHON_COMPILING_IN_CPYTHON
  11174. static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  11175. PyObject *result;
  11176. PyObject *args = PyTuple_New(1);
  11177. if (unlikely(!args)) return NULL;
  11178. Py_INCREF(arg);
  11179. PyTuple_SET_ITEM(args, 0, arg);
  11180. result = __Pyx_PyObject_Call(func, args, NULL);
  11181. Py_DECREF(args);
  11182. return result;
  11183. }
  11184. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  11185. #if CYTHON_FAST_PYCALL
  11186. if (PyFunction_Check(func)) {
  11187. return __Pyx_PyFunction_FastCall(func, &arg, 1);
  11188. }
  11189. #endif
  11190. #ifdef __Pyx_CyFunction_USED
  11191. if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
  11192. #else
  11193. if (likely(PyCFunction_Check(func))) {
  11194. #endif
  11195. if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
  11196. return __Pyx_PyObject_CallMethO(func, arg);
  11197. #if CYTHON_FAST_PYCCALL
  11198. } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
  11199. return __Pyx_PyCFunction_FastCall(func, &arg, 1);
  11200. #endif
  11201. }
  11202. }
  11203. return __Pyx__PyObject_CallOneArg(func, arg);
  11204. }
  11205. #else
  11206. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  11207. PyObject *result;
  11208. PyObject *args = PyTuple_Pack(1, arg);
  11209. if (unlikely(!args)) return NULL;
  11210. result = __Pyx_PyObject_Call(func, args, NULL);
  11211. Py_DECREF(args);
  11212. return result;
  11213. }
  11214. #endif
  11215. /* WriteUnraisableException */
  11216. static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
  11217. CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
  11218. int full_traceback, CYTHON_UNUSED int nogil) {
  11219. PyObject *old_exc, *old_val, *old_tb;
  11220. PyObject *ctx;
  11221. __Pyx_PyThreadState_declare
  11222. #ifdef WITH_THREAD
  11223. PyGILState_STATE state;
  11224. if (nogil)
  11225. state = PyGILState_Ensure();
  11226. #ifdef _MSC_VER
  11227. else state = (PyGILState_STATE)-1;
  11228. #endif
  11229. #endif
  11230. __Pyx_PyThreadState_assign
  11231. __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
  11232. if (full_traceback) {
  11233. Py_XINCREF(old_exc);
  11234. Py_XINCREF(old_val);
  11235. Py_XINCREF(old_tb);
  11236. __Pyx_ErrRestore(old_exc, old_val, old_tb);
  11237. PyErr_PrintEx(1);
  11238. }
  11239. #if PY_MAJOR_VERSION < 3
  11240. ctx = PyString_FromString(name);
  11241. #else
  11242. ctx = PyUnicode_FromString(name);
  11243. #endif
  11244. __Pyx_ErrRestore(old_exc, old_val, old_tb);
  11245. if (!ctx) {
  11246. PyErr_WriteUnraisable(Py_None);
  11247. } else {
  11248. PyErr_WriteUnraisable(ctx);
  11249. Py_DECREF(ctx);
  11250. }
  11251. #ifdef WITH_THREAD
  11252. if (nogil)
  11253. PyGILState_Release(state);
  11254. #endif
  11255. }
  11256. /* RaiseNoneIterError */
  11257. static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
  11258. PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
  11259. }
  11260. /* ExtTypeTest */
  11261. static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
  11262. if (unlikely(!type)) {
  11263. PyErr_SetString(PyExc_SystemError, "Missing type object");
  11264. return 0;
  11265. }
  11266. if (likely(PyObject_TypeCheck(obj, type)))
  11267. return 1;
  11268. PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
  11269. Py_TYPE(obj)->tp_name, type->tp_name);
  11270. return 0;
  11271. }
  11272. /* SaveResetException */
  11273. #if CYTHON_FAST_THREAD_STATE
  11274. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  11275. *type = tstate->exc_type;
  11276. *value = tstate->exc_value;
  11277. *tb = tstate->exc_traceback;
  11278. Py_XINCREF(*type);
  11279. Py_XINCREF(*value);
  11280. Py_XINCREF(*tb);
  11281. }
  11282. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  11283. PyObject *tmp_type, *tmp_value, *tmp_tb;
  11284. tmp_type = tstate->exc_type;
  11285. tmp_value = tstate->exc_value;
  11286. tmp_tb = tstate->exc_traceback;
  11287. tstate->exc_type = type;
  11288. tstate->exc_value = value;
  11289. tstate->exc_traceback = tb;
  11290. Py_XDECREF(tmp_type);
  11291. Py_XDECREF(tmp_value);
  11292. Py_XDECREF(tmp_tb);
  11293. }
  11294. #endif
  11295. /* GetException */
  11296. #if CYTHON_FAST_THREAD_STATE
  11297. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  11298. #else
  11299. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
  11300. #endif
  11301. PyObject *local_type, *local_value, *local_tb;
  11302. #if CYTHON_FAST_THREAD_STATE
  11303. PyObject *tmp_type, *tmp_value, *tmp_tb;
  11304. local_type = tstate->curexc_type;
  11305. local_value = tstate->curexc_value;
  11306. local_tb = tstate->curexc_traceback;
  11307. tstate->curexc_type = 0;
  11308. tstate->curexc_value = 0;
  11309. tstate->curexc_traceback = 0;
  11310. #else
  11311. PyErr_Fetch(&local_type, &local_value, &local_tb);
  11312. #endif
  11313. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  11314. #if CYTHON_FAST_THREAD_STATE
  11315. if (unlikely(tstate->curexc_type))
  11316. #else
  11317. if (unlikely(PyErr_Occurred()))
  11318. #endif
  11319. goto bad;
  11320. #if PY_MAJOR_VERSION >= 3
  11321. if (local_tb) {
  11322. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  11323. goto bad;
  11324. }
  11325. #endif
  11326. Py_XINCREF(local_tb);
  11327. Py_XINCREF(local_type);
  11328. Py_XINCREF(local_value);
  11329. *type = local_type;
  11330. *value = local_value;
  11331. *tb = local_tb;
  11332. #if CYTHON_FAST_THREAD_STATE
  11333. tmp_type = tstate->exc_type;
  11334. tmp_value = tstate->exc_value;
  11335. tmp_tb = tstate->exc_traceback;
  11336. tstate->exc_type = local_type;
  11337. tstate->exc_value = local_value;
  11338. tstate->exc_traceback = local_tb;
  11339. Py_XDECREF(tmp_type);
  11340. Py_XDECREF(tmp_value);
  11341. Py_XDECREF(tmp_tb);
  11342. #else
  11343. PyErr_SetExcInfo(local_type, local_value, local_tb);
  11344. #endif
  11345. return 0;
  11346. bad:
  11347. *type = 0;
  11348. *value = 0;
  11349. *tb = 0;
  11350. Py_XDECREF(local_type);
  11351. Py_XDECREF(local_value);
  11352. Py_XDECREF(local_tb);
  11353. return -1;
  11354. }
  11355. /* PyObjectCallNoArg */
  11356. #if CYTHON_COMPILING_IN_CPYTHON
  11357. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
  11358. #if CYTHON_FAST_PYCALL
  11359. if (PyFunction_Check(func)) {
  11360. return __Pyx_PyFunction_FastCall(func, NULL, 0);
  11361. }
  11362. #endif
  11363. #ifdef __Pyx_CyFunction_USED
  11364. if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
  11365. #else
  11366. if (likely(PyCFunction_Check(func))) {
  11367. #endif
  11368. if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
  11369. return __Pyx_PyObject_CallMethO(func, NULL);
  11370. }
  11371. }
  11372. return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
  11373. }
  11374. #endif
  11375. /* GetItemInt */
  11376. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
  11377. PyObject *r;
  11378. if (!j) return NULL;
  11379. r = PyObject_GetItem(o, j);
  11380. Py_DECREF(j);
  11381. return r;
  11382. }
  11383. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  11384. CYTHON_NCP_UNUSED int wraparound,
  11385. CYTHON_NCP_UNUSED int boundscheck) {
  11386. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  11387. if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
  11388. if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
  11389. PyObject *r = PyList_GET_ITEM(o, i);
  11390. Py_INCREF(r);
  11391. return r;
  11392. }
  11393. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  11394. #else
  11395. return PySequence_GetItem(o, i);
  11396. #endif
  11397. }
  11398. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  11399. CYTHON_NCP_UNUSED int wraparound,
  11400. CYTHON_NCP_UNUSED int boundscheck) {
  11401. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  11402. if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
  11403. if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
  11404. PyObject *r = PyTuple_GET_ITEM(o, i);
  11405. Py_INCREF(r);
  11406. return r;
  11407. }
  11408. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  11409. #else
  11410. return PySequence_GetItem(o, i);
  11411. #endif
  11412. }
  11413. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
  11414. CYTHON_NCP_UNUSED int wraparound,
  11415. CYTHON_NCP_UNUSED int boundscheck) {
  11416. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
  11417. if (is_list || PyList_CheckExact(o)) {
  11418. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
  11419. if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
  11420. PyObject *r = PyList_GET_ITEM(o, n);
  11421. Py_INCREF(r);
  11422. return r;
  11423. }
  11424. }
  11425. else if (PyTuple_CheckExact(o)) {
  11426. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
  11427. if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
  11428. PyObject *r = PyTuple_GET_ITEM(o, n);
  11429. Py_INCREF(r);
  11430. return r;
  11431. }
  11432. } else {
  11433. PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
  11434. if (likely(m && m->sq_item)) {
  11435. if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
  11436. Py_ssize_t l = m->sq_length(o);
  11437. if (likely(l >= 0)) {
  11438. i += l;
  11439. } else {
  11440. if (!PyErr_ExceptionMatches(PyExc_OverflowError))
  11441. return NULL;
  11442. PyErr_Clear();
  11443. }
  11444. }
  11445. return m->sq_item(o, i);
  11446. }
  11447. }
  11448. #else
  11449. if (is_list || PySequence_Check(o)) {
  11450. return PySequence_GetItem(o, i);
  11451. }
  11452. #endif
  11453. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  11454. }
  11455. /* pyobject_as_double */
  11456. static double __Pyx__PyObject_AsDouble(PyObject* obj) {
  11457. PyObject* float_value;
  11458. #if !CYTHON_USE_TYPE_SLOTS
  11459. float_value = PyNumber_Float(obj); if (0) goto bad;
  11460. #else
  11461. PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number;
  11462. if (likely(nb) && likely(nb->nb_float)) {
  11463. float_value = nb->nb_float(obj);
  11464. if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) {
  11465. PyErr_Format(PyExc_TypeError,
  11466. "__float__ returned non-float (type %.200s)",
  11467. Py_TYPE(float_value)->tp_name);
  11468. Py_DECREF(float_value);
  11469. goto bad;
  11470. }
  11471. } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
  11472. #if PY_MAJOR_VERSION >= 3
  11473. float_value = PyFloat_FromString(obj);
  11474. #else
  11475. float_value = PyFloat_FromString(obj, 0);
  11476. #endif
  11477. } else {
  11478. PyObject* args = PyTuple_New(1);
  11479. if (unlikely(!args)) goto bad;
  11480. PyTuple_SET_ITEM(args, 0, obj);
  11481. float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
  11482. PyTuple_SET_ITEM(args, 0, 0);
  11483. Py_DECREF(args);
  11484. }
  11485. #endif
  11486. if (likely(float_value)) {
  11487. double value = PyFloat_AS_DOUBLE(float_value);
  11488. Py_DECREF(float_value);
  11489. return value;
  11490. }
  11491. bad:
  11492. return (double)-1;
  11493. }
  11494. /* SwapException */
  11495. #if CYTHON_FAST_THREAD_STATE
  11496. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  11497. PyObject *tmp_type, *tmp_value, *tmp_tb;
  11498. tmp_type = tstate->exc_type;
  11499. tmp_value = tstate->exc_value;
  11500. tmp_tb = tstate->exc_traceback;
  11501. tstate->exc_type = *type;
  11502. tstate->exc_value = *value;
  11503. tstate->exc_traceback = *tb;
  11504. *type = tmp_type;
  11505. *value = tmp_value;
  11506. *tb = tmp_tb;
  11507. }
  11508. #else
  11509. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
  11510. PyObject *tmp_type, *tmp_value, *tmp_tb;
  11511. PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
  11512. PyErr_SetExcInfo(*type, *value, *tb);
  11513. *type = tmp_type;
  11514. *value = tmp_value;
  11515. *tb = tmp_tb;
  11516. }
  11517. #endif
  11518. /* dict_getitem_default */
  11519. static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
  11520. PyObject* value;
  11521. #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
  11522. value = PyDict_GetItemWithError(d, key);
  11523. if (unlikely(!value)) {
  11524. if (unlikely(PyErr_Occurred()))
  11525. return NULL;
  11526. value = default_value;
  11527. }
  11528. Py_INCREF(value);
  11529. #else
  11530. if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
  11531. value = PyDict_GetItem(d, key);
  11532. if (unlikely(!value)) {
  11533. value = default_value;
  11534. }
  11535. Py_INCREF(value);
  11536. } else {
  11537. if (default_value == Py_None)
  11538. default_value = NULL;
  11539. value = PyObject_CallMethodObjArgs(
  11540. d, __pyx_n_s_get, key, default_value, NULL);
  11541. }
  11542. #endif
  11543. return value;
  11544. }
  11545. /* ArgTypeTest */
  11546. static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
  11547. PyErr_Format(PyExc_TypeError,
  11548. "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
  11549. name, type->tp_name, Py_TYPE(obj)->tp_name);
  11550. }
  11551. static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
  11552. const char *name, int exact)
  11553. {
  11554. if (unlikely(!type)) {
  11555. PyErr_SetString(PyExc_SystemError, "Missing type object");
  11556. return 0;
  11557. }
  11558. if (none_allowed && obj == Py_None) return 1;
  11559. else if (exact) {
  11560. if (likely(Py_TYPE(obj) == type)) return 1;
  11561. #if PY_MAJOR_VERSION == 2
  11562. else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
  11563. #endif
  11564. }
  11565. else {
  11566. if (likely(PyObject_TypeCheck(obj, type))) return 1;
  11567. }
  11568. __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
  11569. return 0;
  11570. }
  11571. /* PyErrExceptionMatches */
  11572. #if CYTHON_FAST_THREAD_STATE
  11573. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
  11574. PyObject *exc_type = tstate->curexc_type;
  11575. if (exc_type == err) return 1;
  11576. if (unlikely(!exc_type)) return 0;
  11577. return PyErr_GivenExceptionMatches(exc_type, err);
  11578. }
  11579. #endif
  11580. /* SetVTable */
  11581. static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
  11582. #if PY_VERSION_HEX >= 0x02070000
  11583. PyObject *ob = PyCapsule_New(vtable, 0, 0);
  11584. #else
  11585. PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
  11586. #endif
  11587. if (!ob)
  11588. goto bad;
  11589. if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
  11590. goto bad;
  11591. Py_DECREF(ob);
  11592. return 0;
  11593. bad:
  11594. Py_XDECREF(ob);
  11595. return -1;
  11596. }
  11597. /* ImportFrom */
  11598. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  11599. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  11600. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  11601. PyErr_Format(PyExc_ImportError,
  11602. #if PY_MAJOR_VERSION < 3
  11603. "cannot import name %.230s", PyString_AS_STRING(name));
  11604. #else
  11605. "cannot import name %S", name);
  11606. #endif
  11607. }
  11608. return value;
  11609. }
  11610. /* CalculateMetaclass */
  11611. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
  11612. Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
  11613. for (i=0; i < nbases; i++) {
  11614. PyTypeObject *tmptype;
  11615. PyObject *tmp = PyTuple_GET_ITEM(bases, i);
  11616. tmptype = Py_TYPE(tmp);
  11617. #if PY_MAJOR_VERSION < 3
  11618. if (tmptype == &PyClass_Type)
  11619. continue;
  11620. #endif
  11621. if (!metaclass) {
  11622. metaclass = tmptype;
  11623. continue;
  11624. }
  11625. if (PyType_IsSubtype(metaclass, tmptype))
  11626. continue;
  11627. if (PyType_IsSubtype(tmptype, metaclass)) {
  11628. metaclass = tmptype;
  11629. continue;
  11630. }
  11631. PyErr_SetString(PyExc_TypeError,
  11632. "metaclass conflict: "
  11633. "the metaclass of a derived class "
  11634. "must be a (non-strict) subclass "
  11635. "of the metaclasses of all its bases");
  11636. return NULL;
  11637. }
  11638. if (!metaclass) {
  11639. #if PY_MAJOR_VERSION < 3
  11640. metaclass = &PyClass_Type;
  11641. #else
  11642. metaclass = &PyType_Type;
  11643. #endif
  11644. }
  11645. Py_INCREF((PyObject*) metaclass);
  11646. return (PyObject*) metaclass;
  11647. }
  11648. /* Py3ClassCreate */
  11649. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
  11650. PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
  11651. PyObject *ns;
  11652. if (metaclass) {
  11653. PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
  11654. if (prep) {
  11655. PyObject *pargs = PyTuple_Pack(2, name, bases);
  11656. if (unlikely(!pargs)) {
  11657. Py_DECREF(prep);
  11658. return NULL;
  11659. }
  11660. ns = PyObject_Call(prep, pargs, mkw);
  11661. Py_DECREF(prep);
  11662. Py_DECREF(pargs);
  11663. } else {
  11664. if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
  11665. return NULL;
  11666. PyErr_Clear();
  11667. ns = PyDict_New();
  11668. }
  11669. } else {
  11670. ns = PyDict_New();
  11671. }
  11672. if (unlikely(!ns))
  11673. return NULL;
  11674. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
  11675. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
  11676. if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
  11677. return ns;
  11678. bad:
  11679. Py_DECREF(ns);
  11680. return NULL;
  11681. }
  11682. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
  11683. PyObject *dict, PyObject *mkw,
  11684. int calculate_metaclass, int allow_py2_metaclass) {
  11685. PyObject *result, *margs;
  11686. PyObject *owned_metaclass = NULL;
  11687. if (allow_py2_metaclass) {
  11688. owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
  11689. if (owned_metaclass) {
  11690. metaclass = owned_metaclass;
  11691. } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
  11692. PyErr_Clear();
  11693. } else {
  11694. return NULL;
  11695. }
  11696. }
  11697. if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
  11698. metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
  11699. Py_XDECREF(owned_metaclass);
  11700. if (unlikely(!metaclass))
  11701. return NULL;
  11702. owned_metaclass = metaclass;
  11703. }
  11704. margs = PyTuple_Pack(3, name, bases, dict);
  11705. if (unlikely(!margs)) {
  11706. result = NULL;
  11707. } else {
  11708. result = PyObject_Call(metaclass, margs, mkw);
  11709. Py_DECREF(margs);
  11710. }
  11711. Py_XDECREF(owned_metaclass);
  11712. return result;
  11713. }
  11714. /* FetchCommonType */
  11715. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
  11716. PyObject* fake_module;
  11717. PyTypeObject* cached_type = NULL;
  11718. fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
  11719. if (!fake_module) return NULL;
  11720. Py_INCREF(fake_module);
  11721. cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
  11722. if (cached_type) {
  11723. if (!PyType_Check((PyObject*)cached_type)) {
  11724. PyErr_Format(PyExc_TypeError,
  11725. "Shared Cython type %.200s is not a type object",
  11726. type->tp_name);
  11727. goto bad;
  11728. }
  11729. if (cached_type->tp_basicsize != type->tp_basicsize) {
  11730. PyErr_Format(PyExc_TypeError,
  11731. "Shared Cython type %.200s has the wrong size, try recompiling",
  11732. type->tp_name);
  11733. goto bad;
  11734. }
  11735. } else {
  11736. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
  11737. PyErr_Clear();
  11738. if (PyType_Ready(type) < 0) goto bad;
  11739. if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
  11740. goto bad;
  11741. Py_INCREF(type);
  11742. cached_type = type;
  11743. }
  11744. done:
  11745. Py_DECREF(fake_module);
  11746. return cached_type;
  11747. bad:
  11748. Py_XDECREF(cached_type);
  11749. cached_type = NULL;
  11750. goto done;
  11751. }
  11752. /* CythonFunction */
  11753. static PyObject *
  11754. __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
  11755. {
  11756. if (unlikely(op->func_doc == NULL)) {
  11757. if (op->func.m_ml->ml_doc) {
  11758. #if PY_MAJOR_VERSION >= 3
  11759. op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
  11760. #else
  11761. op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
  11762. #endif
  11763. if (unlikely(op->func_doc == NULL))
  11764. return NULL;
  11765. } else {
  11766. Py_INCREF(Py_None);
  11767. return Py_None;
  11768. }
  11769. }
  11770. Py_INCREF(op->func_doc);
  11771. return op->func_doc;
  11772. }
  11773. static int
  11774. __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
  11775. {
  11776. PyObject *tmp = op->func_doc;
  11777. if (value == NULL) {
  11778. value = Py_None;
  11779. }
  11780. Py_INCREF(value);
  11781. op->func_doc = value;
  11782. Py_XDECREF(tmp);
  11783. return 0;
  11784. }
  11785. static PyObject *
  11786. __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
  11787. {
  11788. if (unlikely(op->func_name == NULL)) {
  11789. #if PY_MAJOR_VERSION >= 3
  11790. op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
  11791. #else
  11792. op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
  11793. #endif
  11794. if (unlikely(op->func_name == NULL))
  11795. return NULL;
  11796. }
  11797. Py_INCREF(op->func_name);
  11798. return op->func_name;
  11799. }
  11800. static int
  11801. __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
  11802. {
  11803. PyObject *tmp;
  11804. #if PY_MAJOR_VERSION >= 3
  11805. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  11806. #else
  11807. if (unlikely(value == NULL || !PyString_Check(value))) {
  11808. #endif
  11809. PyErr_SetString(PyExc_TypeError,
  11810. "__name__ must be set to a string object");
  11811. return -1;
  11812. }
  11813. tmp = op->func_name;
  11814. Py_INCREF(value);
  11815. op->func_name = value;
  11816. Py_XDECREF(tmp);
  11817. return 0;
  11818. }
  11819. static PyObject *
  11820. __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
  11821. {
  11822. Py_INCREF(op->func_qualname);
  11823. return op->func_qualname;
  11824. }
  11825. static int
  11826. __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
  11827. {
  11828. PyObject *tmp;
  11829. #if PY_MAJOR_VERSION >= 3
  11830. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  11831. #else
  11832. if (unlikely(value == NULL || !PyString_Check(value))) {
  11833. #endif
  11834. PyErr_SetString(PyExc_TypeError,
  11835. "__qualname__ must be set to a string object");
  11836. return -1;
  11837. }
  11838. tmp = op->func_qualname;
  11839. Py_INCREF(value);
  11840. op->func_qualname = value;
  11841. Py_XDECREF(tmp);
  11842. return 0;
  11843. }
  11844. static PyObject *
  11845. __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
  11846. {
  11847. PyObject *self;
  11848. self = m->func_closure;
  11849. if (self == NULL)
  11850. self = Py_None;
  11851. Py_INCREF(self);
  11852. return self;
  11853. }
  11854. static PyObject *
  11855. __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
  11856. {
  11857. if (unlikely(op->func_dict == NULL)) {
  11858. op->func_dict = PyDict_New();
  11859. if (unlikely(op->func_dict == NULL))
  11860. return NULL;
  11861. }
  11862. Py_INCREF(op->func_dict);
  11863. return op->func_dict;
  11864. }
  11865. static int
  11866. __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
  11867. {
  11868. PyObject *tmp;
  11869. if (unlikely(value == NULL)) {
  11870. PyErr_SetString(PyExc_TypeError,
  11871. "function's dictionary may not be deleted");
  11872. return -1;
  11873. }
  11874. if (unlikely(!PyDict_Check(value))) {
  11875. PyErr_SetString(PyExc_TypeError,
  11876. "setting function's dictionary to a non-dict");
  11877. return -1;
  11878. }
  11879. tmp = op->func_dict;
  11880. Py_INCREF(value);
  11881. op->func_dict = value;
  11882. Py_XDECREF(tmp);
  11883. return 0;
  11884. }
  11885. static PyObject *
  11886. __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
  11887. {
  11888. Py_INCREF(op->func_globals);
  11889. return op->func_globals;
  11890. }
  11891. static PyObject *
  11892. __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
  11893. {
  11894. Py_INCREF(Py_None);
  11895. return Py_None;
  11896. }
  11897. static PyObject *
  11898. __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
  11899. {
  11900. PyObject* result = (op->func_code) ? op->func_code : Py_None;
  11901. Py_INCREF(result);
  11902. return result;
  11903. }
  11904. static int
  11905. __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
  11906. int result = 0;
  11907. PyObject *res = op->defaults_getter((PyObject *) op);
  11908. if (unlikely(!res))
  11909. return -1;
  11910. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  11911. op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
  11912. Py_INCREF(op->defaults_tuple);
  11913. op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
  11914. Py_INCREF(op->defaults_kwdict);
  11915. #else
  11916. op->defaults_tuple = PySequence_ITEM(res, 0);
  11917. if (unlikely(!op->defaults_tuple)) result = -1;
  11918. else {
  11919. op->defaults_kwdict = PySequence_ITEM(res, 1);
  11920. if (unlikely(!op->defaults_kwdict)) result = -1;
  11921. }
  11922. #endif
  11923. Py_DECREF(res);
  11924. return result;
  11925. }
  11926. static int
  11927. __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
  11928. PyObject* tmp;
  11929. if (!value) {
  11930. value = Py_None;
  11931. } else if (value != Py_None && !PyTuple_Check(value)) {
  11932. PyErr_SetString(PyExc_TypeError,
  11933. "__defaults__ must be set to a tuple object");
  11934. return -1;
  11935. }
  11936. Py_INCREF(value);
  11937. tmp = op->defaults_tuple;
  11938. op->defaults_tuple = value;
  11939. Py_XDECREF(tmp);
  11940. return 0;
  11941. }
  11942. static PyObject *
  11943. __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
  11944. PyObject* result = op->defaults_tuple;
  11945. if (unlikely(!result)) {
  11946. if (op->defaults_getter) {
  11947. if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
  11948. result = op->defaults_tuple;
  11949. } else {
  11950. result = Py_None;
  11951. }
  11952. }
  11953. Py_INCREF(result);
  11954. return result;
  11955. }
  11956. static int
  11957. __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
  11958. PyObject* tmp;
  11959. if (!value) {
  11960. value = Py_None;
  11961. } else if (value != Py_None && !PyDict_Check(value)) {
  11962. PyErr_SetString(PyExc_TypeError,
  11963. "__kwdefaults__ must be set to a dict object");
  11964. return -1;
  11965. }
  11966. Py_INCREF(value);
  11967. tmp = op->defaults_kwdict;
  11968. op->defaults_kwdict = value;
  11969. Py_XDECREF(tmp);
  11970. return 0;
  11971. }
  11972. static PyObject *
  11973. __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
  11974. PyObject* result = op->defaults_kwdict;
  11975. if (unlikely(!result)) {
  11976. if (op->defaults_getter) {
  11977. if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
  11978. result = op->defaults_kwdict;
  11979. } else {
  11980. result = Py_None;
  11981. }
  11982. }
  11983. Py_INCREF(result);
  11984. return result;
  11985. }
  11986. static int
  11987. __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
  11988. PyObject* tmp;
  11989. if (!value || value == Py_None) {
  11990. value = NULL;
  11991. } else if (!PyDict_Check(value)) {
  11992. PyErr_SetString(PyExc_TypeError,
  11993. "__annotations__ must be set to a dict object");
  11994. return -1;
  11995. }
  11996. Py_XINCREF(value);
  11997. tmp = op->func_annotations;
  11998. op->func_annotations = value;
  11999. Py_XDECREF(tmp);
  12000. return 0;
  12001. }
  12002. static PyObject *
  12003. __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
  12004. PyObject* result = op->func_annotations;
  12005. if (unlikely(!result)) {
  12006. result = PyDict_New();
  12007. if (unlikely(!result)) return NULL;
  12008. op->func_annotations = result;
  12009. }
  12010. Py_INCREF(result);
  12011. return result;
  12012. }
  12013. static PyGetSetDef __pyx_CyFunction_getsets[] = {
  12014. {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  12015. {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  12016. {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  12017. {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  12018. {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
  12019. {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
  12020. {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
  12021. {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
  12022. {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  12023. {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  12024. {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  12025. {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  12026. {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  12027. {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  12028. {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  12029. {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  12030. {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
  12031. {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
  12032. {0, 0, 0, 0, 0}
  12033. };
  12034. static PyMemberDef __pyx_CyFunction_members[] = {
  12035. {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
  12036. {0, 0, 0, 0, 0}
  12037. };
  12038. static PyObject *
  12039. __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
  12040. {
  12041. #if PY_MAJOR_VERSION >= 3
  12042. return PyUnicode_FromString(m->func.m_ml->ml_name);
  12043. #else
  12044. return PyString_FromString(m->func.m_ml->ml_name);
  12045. #endif
  12046. }
  12047. static PyMethodDef __pyx_CyFunction_methods[] = {
  12048. {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
  12049. {0, 0, 0, 0}
  12050. };
  12051. #if PY_VERSION_HEX < 0x030500A0
  12052. #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
  12053. #else
  12054. #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
  12055. #endif
  12056. static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
  12057. PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  12058. __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
  12059. if (op == NULL)
  12060. return NULL;
  12061. op->flags = flags;
  12062. __Pyx_CyFunction_weakreflist(op) = NULL;
  12063. op->func.m_ml = ml;
  12064. op->func.m_self = (PyObject *) op;
  12065. Py_XINCREF(closure);
  12066. op->func_closure = closure;
  12067. Py_XINCREF(module);
  12068. op->func.m_module = module;
  12069. op->func_dict = NULL;
  12070. op->func_name = NULL;
  12071. Py_INCREF(qualname);
  12072. op->func_qualname = qualname;
  12073. op->func_doc = NULL;
  12074. op->func_classobj = NULL;
  12075. op->func_globals = globals;
  12076. Py_INCREF(op->func_globals);
  12077. Py_XINCREF(code);
  12078. op->func_code = code;
  12079. op->defaults_pyobjects = 0;
  12080. op->defaults = NULL;
  12081. op->defaults_tuple = NULL;
  12082. op->defaults_kwdict = NULL;
  12083. op->defaults_getter = NULL;
  12084. op->func_annotations = NULL;
  12085. PyObject_GC_Track(op);
  12086. return (PyObject *) op;
  12087. }
  12088. static int
  12089. __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
  12090. {
  12091. Py_CLEAR(m->func_closure);
  12092. Py_CLEAR(m->func.m_module);
  12093. Py_CLEAR(m->func_dict);
  12094. Py_CLEAR(m->func_name);
  12095. Py_CLEAR(m->func_qualname);
  12096. Py_CLEAR(m->func_doc);
  12097. Py_CLEAR(m->func_globals);
  12098. Py_CLEAR(m->func_code);
  12099. Py_CLEAR(m->func_classobj);
  12100. Py_CLEAR(m->defaults_tuple);
  12101. Py_CLEAR(m->defaults_kwdict);
  12102. Py_CLEAR(m->func_annotations);
  12103. if (m->defaults) {
  12104. PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
  12105. int i;
  12106. for (i = 0; i < m->defaults_pyobjects; i++)
  12107. Py_XDECREF(pydefaults[i]);
  12108. PyObject_Free(m->defaults);
  12109. m->defaults = NULL;
  12110. }
  12111. return 0;
  12112. }
  12113. static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
  12114. {
  12115. PyObject_GC_UnTrack(m);
  12116. if (__Pyx_CyFunction_weakreflist(m) != NULL)
  12117. PyObject_ClearWeakRefs((PyObject *) m);
  12118. __Pyx_CyFunction_clear(m);
  12119. PyObject_GC_Del(m);
  12120. }
  12121. static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
  12122. {
  12123. Py_VISIT(m->func_closure);
  12124. Py_VISIT(m->func.m_module);
  12125. Py_VISIT(m->func_dict);
  12126. Py_VISIT(m->func_name);
  12127. Py_VISIT(m->func_qualname);
  12128. Py_VISIT(m->func_doc);
  12129. Py_VISIT(m->func_globals);
  12130. Py_VISIT(m->func_code);
  12131. Py_VISIT(m->func_classobj);
  12132. Py_VISIT(m->defaults_tuple);
  12133. Py_VISIT(m->defaults_kwdict);
  12134. if (m->defaults) {
  12135. PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
  12136. int i;
  12137. for (i = 0; i < m->defaults_pyobjects; i++)
  12138. Py_VISIT(pydefaults[i]);
  12139. }
  12140. return 0;
  12141. }
  12142. static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
  12143. {
  12144. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12145. if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
  12146. Py_INCREF(func);
  12147. return func;
  12148. }
  12149. if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
  12150. if (type == NULL)
  12151. type = (PyObject *)(Py_TYPE(obj));
  12152. return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
  12153. }
  12154. if (obj == Py_None)
  12155. obj = NULL;
  12156. return __Pyx_PyMethod_New(func, obj, type);
  12157. }
  12158. static PyObject*
  12159. __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
  12160. {
  12161. #if PY_MAJOR_VERSION >= 3
  12162. return PyUnicode_FromFormat("<cyfunction %U at %p>",
  12163. op->func_qualname, (void *)op);
  12164. #else
  12165. return PyString_FromFormat("<cyfunction %s at %p>",
  12166. PyString_AsString(op->func_qualname), (void *)op);
  12167. #endif
  12168. }
  12169. static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
  12170. PyCFunctionObject* f = (PyCFunctionObject*)func;
  12171. PyCFunction meth = f->m_ml->ml_meth;
  12172. Py_ssize_t size;
  12173. switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
  12174. case METH_VARARGS:
  12175. if (likely(kw == NULL || PyDict_Size(kw) == 0))
  12176. return (*meth)(self, arg);
  12177. break;
  12178. case METH_VARARGS | METH_KEYWORDS:
  12179. return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
  12180. case METH_NOARGS:
  12181. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  12182. size = PyTuple_GET_SIZE(arg);
  12183. if (likely(size == 0))
  12184. return (*meth)(self, NULL);
  12185. PyErr_Format(PyExc_TypeError,
  12186. "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
  12187. f->m_ml->ml_name, size);
  12188. return NULL;
  12189. }
  12190. break;
  12191. case METH_O:
  12192. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  12193. size = PyTuple_GET_SIZE(arg);
  12194. if (likely(size == 1)) {
  12195. PyObject *result, *arg0 = PySequence_ITEM(arg, 0);
  12196. if (unlikely(!arg0)) return NULL;
  12197. result = (*meth)(self, arg0);
  12198. Py_DECREF(arg0);
  12199. return result;
  12200. }
  12201. PyErr_Format(PyExc_TypeError,
  12202. "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
  12203. f->m_ml->ml_name, size);
  12204. return NULL;
  12205. }
  12206. break;
  12207. default:
  12208. PyErr_SetString(PyExc_SystemError, "Bad call flags in "
  12209. "__Pyx_CyFunction_Call. METH_OLDARGS is no "
  12210. "longer supported!");
  12211. return NULL;
  12212. }
  12213. PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
  12214. f->m_ml->ml_name);
  12215. return NULL;
  12216. }
  12217. static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  12218. return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
  12219. }
  12220. static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
  12221. PyObject *result;
  12222. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
  12223. if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
  12224. Py_ssize_t argc;
  12225. PyObject *new_args;
  12226. PyObject *self;
  12227. argc = PyTuple_GET_SIZE(args);
  12228. new_args = PyTuple_GetSlice(args, 1, argc);
  12229. if (unlikely(!new_args))
  12230. return NULL;
  12231. self = PyTuple_GetItem(args, 0);
  12232. if (unlikely(!self)) {
  12233. Py_DECREF(new_args);
  12234. return NULL;
  12235. }
  12236. result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
  12237. Py_DECREF(new_args);
  12238. } else {
  12239. result = __Pyx_CyFunction_Call(func, args, kw);
  12240. }
  12241. return result;
  12242. }
  12243. static PyTypeObject __pyx_CyFunctionType_type = {
  12244. PyVarObject_HEAD_INIT(0, 0)
  12245. "cython_function_or_method",
  12246. sizeof(__pyx_CyFunctionObject),
  12247. 0,
  12248. (destructor) __Pyx_CyFunction_dealloc,
  12249. 0,
  12250. 0,
  12251. 0,
  12252. #if PY_MAJOR_VERSION < 3
  12253. 0,
  12254. #else
  12255. 0,
  12256. #endif
  12257. (reprfunc) __Pyx_CyFunction_repr,
  12258. 0,
  12259. 0,
  12260. 0,
  12261. 0,
  12262. __Pyx_CyFunction_CallAsMethod,
  12263. 0,
  12264. 0,
  12265. 0,
  12266. 0,
  12267. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
  12268. 0,
  12269. (traverseproc) __Pyx_CyFunction_traverse,
  12270. (inquiry) __Pyx_CyFunction_clear,
  12271. 0,
  12272. #if PY_VERSION_HEX < 0x030500A0
  12273. offsetof(__pyx_CyFunctionObject, func_weakreflist),
  12274. #else
  12275. offsetof(PyCFunctionObject, m_weakreflist),
  12276. #endif
  12277. 0,
  12278. 0,
  12279. __pyx_CyFunction_methods,
  12280. __pyx_CyFunction_members,
  12281. __pyx_CyFunction_getsets,
  12282. 0,
  12283. 0,
  12284. __Pyx_CyFunction_descr_get,
  12285. 0,
  12286. offsetof(__pyx_CyFunctionObject, func_dict),
  12287. 0,
  12288. 0,
  12289. 0,
  12290. 0,
  12291. 0,
  12292. 0,
  12293. 0,
  12294. 0,
  12295. 0,
  12296. 0,
  12297. 0,
  12298. 0,
  12299. #if PY_VERSION_HEX >= 0x030400a1
  12300. 0,
  12301. #endif
  12302. };
  12303. static int __pyx_CyFunction_init(void) {
  12304. __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
  12305. if (__pyx_CyFunctionType == NULL) {
  12306. return -1;
  12307. }
  12308. return 0;
  12309. }
  12310. static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
  12311. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12312. m->defaults = PyObject_Malloc(size);
  12313. if (!m->defaults)
  12314. return PyErr_NoMemory();
  12315. memset(m->defaults, 0, size);
  12316. m->defaults_pyobjects = pyobjects;
  12317. return m->defaults;
  12318. }
  12319. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
  12320. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12321. m->defaults_tuple = tuple;
  12322. Py_INCREF(tuple);
  12323. }
  12324. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
  12325. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12326. m->defaults_kwdict = dict;
  12327. Py_INCREF(dict);
  12328. }
  12329. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
  12330. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12331. m->func_annotations = dict;
  12332. Py_INCREF(dict);
  12333. }
  12334. /* CodeObjectCache */
  12335. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  12336. int start = 0, mid = 0, end = count - 1;
  12337. if (end >= 0 && code_line > entries[end].code_line) {
  12338. return count;
  12339. }
  12340. while (start < end) {
  12341. mid = start + (end - start) / 2;
  12342. if (code_line < entries[mid].code_line) {
  12343. end = mid;
  12344. } else if (code_line > entries[mid].code_line) {
  12345. start = mid + 1;
  12346. } else {
  12347. return mid;
  12348. }
  12349. }
  12350. if (code_line <= entries[mid].code_line) {
  12351. return mid;
  12352. } else {
  12353. return mid + 1;
  12354. }
  12355. }
  12356. static PyCodeObject *__pyx_find_code_object(int code_line) {
  12357. PyCodeObject* code_object;
  12358. int pos;
  12359. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  12360. return NULL;
  12361. }
  12362. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  12363. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  12364. return NULL;
  12365. }
  12366. code_object = __pyx_code_cache.entries[pos].code_object;
  12367. Py_INCREF(code_object);
  12368. return code_object;
  12369. }
  12370. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  12371. int pos, i;
  12372. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  12373. if (unlikely(!code_line)) {
  12374. return;
  12375. }
  12376. if (unlikely(!entries)) {
  12377. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  12378. if (likely(entries)) {
  12379. __pyx_code_cache.entries = entries;
  12380. __pyx_code_cache.max_count = 64;
  12381. __pyx_code_cache.count = 1;
  12382. entries[0].code_line = code_line;
  12383. entries[0].code_object = code_object;
  12384. Py_INCREF(code_object);
  12385. }
  12386. return;
  12387. }
  12388. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  12389. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  12390. PyCodeObject* tmp = entries[pos].code_object;
  12391. entries[pos].code_object = code_object;
  12392. Py_DECREF(tmp);
  12393. return;
  12394. }
  12395. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  12396. int new_max = __pyx_code_cache.max_count + 64;
  12397. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  12398. __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  12399. if (unlikely(!entries)) {
  12400. return;
  12401. }
  12402. __pyx_code_cache.entries = entries;
  12403. __pyx_code_cache.max_count = new_max;
  12404. }
  12405. for (i=__pyx_code_cache.count; i>pos; i--) {
  12406. entries[i] = entries[i-1];
  12407. }
  12408. entries[pos].code_line = code_line;
  12409. entries[pos].code_object = code_object;
  12410. __pyx_code_cache.count++;
  12411. Py_INCREF(code_object);
  12412. }
  12413. /* AddTraceback */
  12414. #include "compile.h"
  12415. #include "frameobject.h"
  12416. #include "traceback.h"
  12417. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  12418. const char *funcname, int c_line,
  12419. int py_line, const char *filename) {
  12420. PyCodeObject *py_code = 0;
  12421. PyObject *py_srcfile = 0;
  12422. PyObject *py_funcname = 0;
  12423. #if PY_MAJOR_VERSION < 3
  12424. py_srcfile = PyString_FromString(filename);
  12425. #else
  12426. py_srcfile = PyUnicode_FromString(filename);
  12427. #endif
  12428. if (!py_srcfile) goto bad;
  12429. if (c_line) {
  12430. #if PY_MAJOR_VERSION < 3
  12431. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  12432. #else
  12433. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  12434. #endif
  12435. }
  12436. else {
  12437. #if PY_MAJOR_VERSION < 3
  12438. py_funcname = PyString_FromString(funcname);
  12439. #else
  12440. py_funcname = PyUnicode_FromString(funcname);
  12441. #endif
  12442. }
  12443. if (!py_funcname) goto bad;
  12444. py_code = __Pyx_PyCode_New(
  12445. 0,
  12446. 0,
  12447. 0,
  12448. 0,
  12449. 0,
  12450. __pyx_empty_bytes, /*PyObject *code,*/
  12451. __pyx_empty_tuple, /*PyObject *consts,*/
  12452. __pyx_empty_tuple, /*PyObject *names,*/
  12453. __pyx_empty_tuple, /*PyObject *varnames,*/
  12454. __pyx_empty_tuple, /*PyObject *freevars,*/
  12455. __pyx_empty_tuple, /*PyObject *cellvars,*/
  12456. py_srcfile, /*PyObject *filename,*/
  12457. py_funcname, /*PyObject *name,*/
  12458. py_line,
  12459. __pyx_empty_bytes /*PyObject *lnotab*/
  12460. );
  12461. Py_DECREF(py_srcfile);
  12462. Py_DECREF(py_funcname);
  12463. return py_code;
  12464. bad:
  12465. Py_XDECREF(py_srcfile);
  12466. Py_XDECREF(py_funcname);
  12467. return NULL;
  12468. }
  12469. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  12470. int py_line, const char *filename) {
  12471. PyCodeObject *py_code = 0;
  12472. PyFrameObject *py_frame = 0;
  12473. py_code = __pyx_find_code_object(c_line ? c_line : py_line);
  12474. if (!py_code) {
  12475. py_code = __Pyx_CreateCodeObjectForTraceback(
  12476. funcname, c_line, py_line, filename);
  12477. if (!py_code) goto bad;
  12478. __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
  12479. }
  12480. py_frame = PyFrame_New(
  12481. PyThreadState_GET(), /*PyThreadState *tstate,*/
  12482. py_code, /*PyCodeObject *code,*/
  12483. __pyx_d, /*PyObject *globals,*/
  12484. 0 /*PyObject *locals*/
  12485. );
  12486. if (!py_frame) goto bad;
  12487. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  12488. PyTraceBack_Here(py_frame);
  12489. bad:
  12490. Py_XDECREF(py_code);
  12491. Py_XDECREF(py_frame);
  12492. }
  12493. /* CIntToPy */
  12494. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  12495. const long neg_one = (long) -1, const_zero = (long) 0;
  12496. const int is_unsigned = neg_one > const_zero;
  12497. if (is_unsigned) {
  12498. if (sizeof(long) < sizeof(long)) {
  12499. return PyInt_FromLong((long) value);
  12500. } else if (sizeof(long) <= sizeof(unsigned long)) {
  12501. return PyLong_FromUnsignedLong((unsigned long) value);
  12502. #ifdef HAVE_LONG_LONG
  12503. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  12504. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  12505. #endif
  12506. }
  12507. } else {
  12508. if (sizeof(long) <= sizeof(long)) {
  12509. return PyInt_FromLong((long) value);
  12510. #ifdef HAVE_LONG_LONG
  12511. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  12512. return PyLong_FromLongLong((PY_LONG_LONG) value);
  12513. #endif
  12514. }
  12515. }
  12516. {
  12517. int one = 1; int little = (int)*(unsigned char *)&one;
  12518. unsigned char *bytes = (unsigned char *)&value;
  12519. return _PyLong_FromByteArray(bytes, sizeof(long),
  12520. little, !is_unsigned);
  12521. }
  12522. }
  12523. /* CIntToPy */
  12524. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
  12525. const int neg_one = (int) -1, const_zero = (int) 0;
  12526. const int is_unsigned = neg_one > const_zero;
  12527. if (is_unsigned) {
  12528. if (sizeof(int) < sizeof(long)) {
  12529. return PyInt_FromLong((long) value);
  12530. } else if (sizeof(int) <= sizeof(unsigned long)) {
  12531. return PyLong_FromUnsignedLong((unsigned long) value);
  12532. #ifdef HAVE_LONG_LONG
  12533. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  12534. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  12535. #endif
  12536. }
  12537. } else {
  12538. if (sizeof(int) <= sizeof(long)) {
  12539. return PyInt_FromLong((long) value);
  12540. #ifdef HAVE_LONG_LONG
  12541. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  12542. return PyLong_FromLongLong((PY_LONG_LONG) value);
  12543. #endif
  12544. }
  12545. }
  12546. {
  12547. int one = 1; int little = (int)*(unsigned char *)&one;
  12548. unsigned char *bytes = (unsigned char *)&value;
  12549. return _PyLong_FromByteArray(bytes, sizeof(int),
  12550. little, !is_unsigned);
  12551. }
  12552. }
  12553. /* CIntFromPyVerify */
  12554. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  12555. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  12556. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  12557. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  12558. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  12559. {\
  12560. func_type value = func_value;\
  12561. if (sizeof(target_type) < sizeof(func_type)) {\
  12562. if (unlikely(value != (func_type) (target_type) value)) {\
  12563. func_type zero = 0;\
  12564. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  12565. return (target_type) -1;\
  12566. if (is_unsigned && unlikely(value < zero))\
  12567. goto raise_neg_overflow;\
  12568. else\
  12569. goto raise_overflow;\
  12570. }\
  12571. }\
  12572. return (target_type) value;\
  12573. }
  12574. /* CIntFromPy */
  12575. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  12576. const int neg_one = (int) -1, const_zero = (int) 0;
  12577. const int is_unsigned = neg_one > const_zero;
  12578. #if PY_MAJOR_VERSION < 3
  12579. if (likely(PyInt_Check(x))) {
  12580. if (sizeof(int) < sizeof(long)) {
  12581. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  12582. } else {
  12583. long val = PyInt_AS_LONG(x);
  12584. if (is_unsigned && unlikely(val < 0)) {
  12585. goto raise_neg_overflow;
  12586. }
  12587. return (int) val;
  12588. }
  12589. } else
  12590. #endif
  12591. if (likely(PyLong_Check(x))) {
  12592. if (is_unsigned) {
  12593. #if CYTHON_USE_PYLONG_INTERNALS
  12594. const digit* digits = ((PyLongObject*)x)->ob_digit;
  12595. switch (Py_SIZE(x)) {
  12596. case 0: return (int) 0;
  12597. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  12598. case 2:
  12599. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  12600. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  12601. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12602. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  12603. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  12604. }
  12605. }
  12606. break;
  12607. case 3:
  12608. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  12609. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  12610. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12611. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  12612. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  12613. }
  12614. }
  12615. break;
  12616. case 4:
  12617. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  12618. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  12619. __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])))
  12620. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  12621. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  12622. }
  12623. }
  12624. break;
  12625. }
  12626. #endif
  12627. #if CYTHON_COMPILING_IN_CPYTHON
  12628. if (unlikely(Py_SIZE(x) < 0)) {
  12629. goto raise_neg_overflow;
  12630. }
  12631. #else
  12632. {
  12633. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  12634. if (unlikely(result < 0))
  12635. return (int) -1;
  12636. if (unlikely(result == 1))
  12637. goto raise_neg_overflow;
  12638. }
  12639. #endif
  12640. if (sizeof(int) <= sizeof(unsigned long)) {
  12641. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  12642. #ifdef HAVE_LONG_LONG
  12643. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  12644. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  12645. #endif
  12646. }
  12647. } else {
  12648. #if CYTHON_USE_PYLONG_INTERNALS
  12649. const digit* digits = ((PyLongObject*)x)->ob_digit;
  12650. switch (Py_SIZE(x)) {
  12651. case 0: return (int) 0;
  12652. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  12653. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  12654. case -2:
  12655. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  12656. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  12657. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12658. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  12659. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12660. }
  12661. }
  12662. break;
  12663. case 2:
  12664. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  12665. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  12666. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12667. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  12668. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12669. }
  12670. }
  12671. break;
  12672. case -3:
  12673. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  12674. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  12675. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12676. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  12677. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12678. }
  12679. }
  12680. break;
  12681. case 3:
  12682. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  12683. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  12684. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12685. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  12686. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12687. }
  12688. }
  12689. break;
  12690. case -4:
  12691. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  12692. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  12693. __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])))
  12694. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  12695. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12696. }
  12697. }
  12698. break;
  12699. case 4:
  12700. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  12701. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  12702. __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])))
  12703. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  12704. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12705. }
  12706. }
  12707. break;
  12708. }
  12709. #endif
  12710. if (sizeof(int) <= sizeof(long)) {
  12711. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  12712. #ifdef HAVE_LONG_LONG
  12713. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  12714. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  12715. #endif
  12716. }
  12717. }
  12718. {
  12719. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  12720. PyErr_SetString(PyExc_RuntimeError,
  12721. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  12722. #else
  12723. int val;
  12724. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  12725. #if PY_MAJOR_VERSION < 3
  12726. if (likely(v) && !PyLong_Check(v)) {
  12727. PyObject *tmp = v;
  12728. v = PyNumber_Long(tmp);
  12729. Py_DECREF(tmp);
  12730. }
  12731. #endif
  12732. if (likely(v)) {
  12733. int one = 1; int is_little = (int)*(unsigned char *)&one;
  12734. unsigned char *bytes = (unsigned char *)&val;
  12735. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  12736. bytes, sizeof(val),
  12737. is_little, !is_unsigned);
  12738. Py_DECREF(v);
  12739. if (likely(!ret))
  12740. return val;
  12741. }
  12742. #endif
  12743. return (int) -1;
  12744. }
  12745. } else {
  12746. int val;
  12747. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  12748. if (!tmp) return (int) -1;
  12749. val = __Pyx_PyInt_As_int(tmp);
  12750. Py_DECREF(tmp);
  12751. return val;
  12752. }
  12753. raise_overflow:
  12754. PyErr_SetString(PyExc_OverflowError,
  12755. "value too large to convert to int");
  12756. return (int) -1;
  12757. raise_neg_overflow:
  12758. PyErr_SetString(PyExc_OverflowError,
  12759. "can't convert negative value to int");
  12760. return (int) -1;
  12761. }
  12762. /* CIntFromPy */
  12763. static CYTHON_INLINE unsigned short __Pyx_PyInt_As_unsigned_short(PyObject *x) {
  12764. const unsigned short neg_one = (unsigned short) -1, const_zero = (unsigned short) 0;
  12765. const int is_unsigned = neg_one > const_zero;
  12766. #if PY_MAJOR_VERSION < 3
  12767. if (likely(PyInt_Check(x))) {
  12768. if (sizeof(unsigned short) < sizeof(long)) {
  12769. __PYX_VERIFY_RETURN_INT(unsigned short, long, PyInt_AS_LONG(x))
  12770. } else {
  12771. long val = PyInt_AS_LONG(x);
  12772. if (is_unsigned && unlikely(val < 0)) {
  12773. goto raise_neg_overflow;
  12774. }
  12775. return (unsigned short) val;
  12776. }
  12777. } else
  12778. #endif
  12779. if (likely(PyLong_Check(x))) {
  12780. if (is_unsigned) {
  12781. #if CYTHON_USE_PYLONG_INTERNALS
  12782. const digit* digits = ((PyLongObject*)x)->ob_digit;
  12783. switch (Py_SIZE(x)) {
  12784. case 0: return (unsigned short) 0;
  12785. case 1: __PYX_VERIFY_RETURN_INT(unsigned short, digit, digits[0])
  12786. case 2:
  12787. if (8 * sizeof(unsigned short) > 1 * PyLong_SHIFT) {
  12788. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  12789. __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12790. } else if (8 * sizeof(unsigned short) >= 2 * PyLong_SHIFT) {
  12791. return (unsigned short) (((((unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]));
  12792. }
  12793. }
  12794. break;
  12795. case 3:
  12796. if (8 * sizeof(unsigned short) > 2 * PyLong_SHIFT) {
  12797. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  12798. __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12799. } else if (8 * sizeof(unsigned short) >= 3 * PyLong_SHIFT) {
  12800. return (unsigned short) (((((((unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]));
  12801. }
  12802. }
  12803. break;
  12804. case 4:
  12805. if (8 * sizeof(unsigned short) > 3 * PyLong_SHIFT) {
  12806. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  12807. __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12808. } else if (8 * sizeof(unsigned short) >= 4 * PyLong_SHIFT) {
  12809. return (unsigned short) (((((((((unsigned short)digits[3]) << PyLong_SHIFT) | (unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0]));
  12810. }
  12811. }
  12812. break;
  12813. }
  12814. #endif
  12815. #if CYTHON_COMPILING_IN_CPYTHON
  12816. if (unlikely(Py_SIZE(x) < 0)) {
  12817. goto raise_neg_overflow;
  12818. }
  12819. #else
  12820. {
  12821. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  12822. if (unlikely(result < 0))
  12823. return (unsigned short) -1;
  12824. if (unlikely(result == 1))
  12825. goto raise_neg_overflow;
  12826. }
  12827. #endif
  12828. if (sizeof(unsigned short) <= sizeof(unsigned long)) {
  12829. __PYX_VERIFY_RETURN_INT_EXC(unsigned short, unsigned long, PyLong_AsUnsignedLong(x))
  12830. #ifdef HAVE_LONG_LONG
  12831. } else if (sizeof(unsigned short) <= sizeof(unsigned PY_LONG_LONG)) {
  12832. __PYX_VERIFY_RETURN_INT_EXC(unsigned short, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  12833. #endif
  12834. }
  12835. } else {
  12836. #if CYTHON_USE_PYLONG_INTERNALS
  12837. const digit* digits = ((PyLongObject*)x)->ob_digit;
  12838. switch (Py_SIZE(x)) {
  12839. case 0: return (unsigned short) 0;
  12840. case -1: __PYX_VERIFY_RETURN_INT(unsigned short, sdigit, (sdigit) (-(sdigit)digits[0]))
  12841. case 1: __PYX_VERIFY_RETURN_INT(unsigned short, digit, +digits[0])
  12842. case -2:
  12843. if (8 * sizeof(unsigned short) - 1 > 1 * PyLong_SHIFT) {
  12844. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  12845. __PYX_VERIFY_RETURN_INT(unsigned short, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12846. } else if (8 * sizeof(unsigned short) - 1 > 2 * PyLong_SHIFT) {
  12847. return (unsigned short) (((unsigned short)-1)*(((((unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])));
  12848. }
  12849. }
  12850. break;
  12851. case 2:
  12852. if (8 * sizeof(unsigned short) > 1 * PyLong_SHIFT) {
  12853. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  12854. __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12855. } else if (8 * sizeof(unsigned short) - 1 > 2 * PyLong_SHIFT) {
  12856. return (unsigned short) ((((((unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])));
  12857. }
  12858. }
  12859. break;
  12860. case -3:
  12861. if (8 * sizeof(unsigned short) - 1 > 2 * PyLong_SHIFT) {
  12862. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  12863. __PYX_VERIFY_RETURN_INT(unsigned short, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12864. } else if (8 * sizeof(unsigned short) - 1 > 3 * PyLong_SHIFT) {
  12865. return (unsigned short) (((unsigned short)-1)*(((((((unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])));
  12866. }
  12867. }
  12868. break;
  12869. case 3:
  12870. if (8 * sizeof(unsigned short) > 2 * PyLong_SHIFT) {
  12871. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  12872. __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12873. } else if (8 * sizeof(unsigned short) - 1 > 3 * PyLong_SHIFT) {
  12874. return (unsigned short) ((((((((unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])));
  12875. }
  12876. }
  12877. break;
  12878. case -4:
  12879. if (8 * sizeof(unsigned short) - 1 > 3 * PyLong_SHIFT) {
  12880. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  12881. __PYX_VERIFY_RETURN_INT(unsigned short, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12882. } else if (8 * sizeof(unsigned short) - 1 > 4 * PyLong_SHIFT) {
  12883. return (unsigned short) (((unsigned short)-1)*(((((((((unsigned short)digits[3]) << PyLong_SHIFT) | (unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])));
  12884. }
  12885. }
  12886. break;
  12887. case 4:
  12888. if (8 * sizeof(unsigned short) > 3 * PyLong_SHIFT) {
  12889. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  12890. __PYX_VERIFY_RETURN_INT(unsigned short, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12891. } else if (8 * sizeof(unsigned short) - 1 > 4 * PyLong_SHIFT) {
  12892. return (unsigned short) ((((((((((unsigned short)digits[3]) << PyLong_SHIFT) | (unsigned short)digits[2]) << PyLong_SHIFT) | (unsigned short)digits[1]) << PyLong_SHIFT) | (unsigned short)digits[0])));
  12893. }
  12894. }
  12895. break;
  12896. }
  12897. #endif
  12898. if (sizeof(unsigned short) <= sizeof(long)) {
  12899. __PYX_VERIFY_RETURN_INT_EXC(unsigned short, long, PyLong_AsLong(x))
  12900. #ifdef HAVE_LONG_LONG
  12901. } else if (sizeof(unsigned short) <= sizeof(PY_LONG_LONG)) {
  12902. __PYX_VERIFY_RETURN_INT_EXC(unsigned short, PY_LONG_LONG, PyLong_AsLongLong(x))
  12903. #endif
  12904. }
  12905. }
  12906. {
  12907. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  12908. PyErr_SetString(PyExc_RuntimeError,
  12909. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  12910. #else
  12911. unsigned short val;
  12912. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  12913. #if PY_MAJOR_VERSION < 3
  12914. if (likely(v) && !PyLong_Check(v)) {
  12915. PyObject *tmp = v;
  12916. v = PyNumber_Long(tmp);
  12917. Py_DECREF(tmp);
  12918. }
  12919. #endif
  12920. if (likely(v)) {
  12921. int one = 1; int is_little = (int)*(unsigned char *)&one;
  12922. unsigned char *bytes = (unsigned char *)&val;
  12923. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  12924. bytes, sizeof(val),
  12925. is_little, !is_unsigned);
  12926. Py_DECREF(v);
  12927. if (likely(!ret))
  12928. return val;
  12929. }
  12930. #endif
  12931. return (unsigned short) -1;
  12932. }
  12933. } else {
  12934. unsigned short val;
  12935. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  12936. if (!tmp) return (unsigned short) -1;
  12937. val = __Pyx_PyInt_As_unsigned_short(tmp);
  12938. Py_DECREF(tmp);
  12939. return val;
  12940. }
  12941. raise_overflow:
  12942. PyErr_SetString(PyExc_OverflowError,
  12943. "value too large to convert to unsigned short");
  12944. return (unsigned short) -1;
  12945. raise_neg_overflow:
  12946. PyErr_SetString(PyExc_OverflowError,
  12947. "can't convert negative value to unsigned short");
  12948. return (unsigned short) -1;
  12949. }
  12950. /* CIntFromPy */
  12951. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  12952. const long neg_one = (long) -1, const_zero = (long) 0;
  12953. const int is_unsigned = neg_one > const_zero;
  12954. #if PY_MAJOR_VERSION < 3
  12955. if (likely(PyInt_Check(x))) {
  12956. if (sizeof(long) < sizeof(long)) {
  12957. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  12958. } else {
  12959. long val = PyInt_AS_LONG(x);
  12960. if (is_unsigned && unlikely(val < 0)) {
  12961. goto raise_neg_overflow;
  12962. }
  12963. return (long) val;
  12964. }
  12965. } else
  12966. #endif
  12967. if (likely(PyLong_Check(x))) {
  12968. if (is_unsigned) {
  12969. #if CYTHON_USE_PYLONG_INTERNALS
  12970. const digit* digits = ((PyLongObject*)x)->ob_digit;
  12971. switch (Py_SIZE(x)) {
  12972. case 0: return (long) 0;
  12973. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  12974. case 2:
  12975. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  12976. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  12977. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12978. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  12979. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  12980. }
  12981. }
  12982. break;
  12983. case 3:
  12984. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  12985. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  12986. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12987. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  12988. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  12989. }
  12990. }
  12991. break;
  12992. case 4:
  12993. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  12994. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  12995. __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])))
  12996. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  12997. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  12998. }
  12999. }
  13000. break;
  13001. }
  13002. #endif
  13003. #if CYTHON_COMPILING_IN_CPYTHON
  13004. if (unlikely(Py_SIZE(x) < 0)) {
  13005. goto raise_neg_overflow;
  13006. }
  13007. #else
  13008. {
  13009. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  13010. if (unlikely(result < 0))
  13011. return (long) -1;
  13012. if (unlikely(result == 1))
  13013. goto raise_neg_overflow;
  13014. }
  13015. #endif
  13016. if (sizeof(long) <= sizeof(unsigned long)) {
  13017. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  13018. #ifdef HAVE_LONG_LONG
  13019. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  13020. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  13021. #endif
  13022. }
  13023. } else {
  13024. #if CYTHON_USE_PYLONG_INTERNALS
  13025. const digit* digits = ((PyLongObject*)x)->ob_digit;
  13026. switch (Py_SIZE(x)) {
  13027. case 0: return (long) 0;
  13028. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  13029. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  13030. case -2:
  13031. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  13032. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  13033. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13034. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  13035. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13036. }
  13037. }
  13038. break;
  13039. case 2:
  13040. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  13041. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  13042. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13043. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  13044. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13045. }
  13046. }
  13047. break;
  13048. case -3:
  13049. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  13050. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  13051. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13052. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  13053. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13054. }
  13055. }
  13056. break;
  13057. case 3:
  13058. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  13059. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  13060. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13061. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  13062. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13063. }
  13064. }
  13065. break;
  13066. case -4:
  13067. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  13068. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  13069. __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])))
  13070. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  13071. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13072. }
  13073. }
  13074. break;
  13075. case 4:
  13076. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  13077. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  13078. __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])))
  13079. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  13080. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13081. }
  13082. }
  13083. break;
  13084. }
  13085. #endif
  13086. if (sizeof(long) <= sizeof(long)) {
  13087. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  13088. #ifdef HAVE_LONG_LONG
  13089. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  13090. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  13091. #endif
  13092. }
  13093. }
  13094. {
  13095. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  13096. PyErr_SetString(PyExc_RuntimeError,
  13097. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  13098. #else
  13099. long val;
  13100. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  13101. #if PY_MAJOR_VERSION < 3
  13102. if (likely(v) && !PyLong_Check(v)) {
  13103. PyObject *tmp = v;
  13104. v = PyNumber_Long(tmp);
  13105. Py_DECREF(tmp);
  13106. }
  13107. #endif
  13108. if (likely(v)) {
  13109. int one = 1; int is_little = (int)*(unsigned char *)&one;
  13110. unsigned char *bytes = (unsigned char *)&val;
  13111. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  13112. bytes, sizeof(val),
  13113. is_little, !is_unsigned);
  13114. Py_DECREF(v);
  13115. if (likely(!ret))
  13116. return val;
  13117. }
  13118. #endif
  13119. return (long) -1;
  13120. }
  13121. } else {
  13122. long val;
  13123. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  13124. if (!tmp) return (long) -1;
  13125. val = __Pyx_PyInt_As_long(tmp);
  13126. Py_DECREF(tmp);
  13127. return val;
  13128. }
  13129. raise_overflow:
  13130. PyErr_SetString(PyExc_OverflowError,
  13131. "value too large to convert to long");
  13132. return (long) -1;
  13133. raise_neg_overflow:
  13134. PyErr_SetString(PyExc_OverflowError,
  13135. "can't convert negative value to long");
  13136. return (long) -1;
  13137. }
  13138. /* CheckBinaryVersion */
  13139. static int __Pyx_check_binary_version(void) {
  13140. char ctversion[4], rtversion[4];
  13141. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  13142. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  13143. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  13144. char message[200];
  13145. PyOS_snprintf(message, sizeof(message),
  13146. "compiletime version %s of module '%.100s' "
  13147. "does not match runtime version %s",
  13148. ctversion, __Pyx_MODULE_NAME, rtversion);
  13149. return PyErr_WarnEx(NULL, message, 1);
  13150. }
  13151. return 0;
  13152. }
  13153. /* InitStrings */
  13154. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  13155. while (t->p) {
  13156. #if PY_MAJOR_VERSION < 3
  13157. if (t->is_unicode) {
  13158. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  13159. } else if (t->intern) {
  13160. *t->p = PyString_InternFromString(t->s);
  13161. } else {
  13162. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  13163. }
  13164. #else
  13165. if (t->is_unicode | t->is_str) {
  13166. if (t->intern) {
  13167. *t->p = PyUnicode_InternFromString(t->s);
  13168. } else if (t->encoding) {
  13169. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  13170. } else {
  13171. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  13172. }
  13173. } else {
  13174. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  13175. }
  13176. #endif
  13177. if (!*t->p)
  13178. return -1;
  13179. ++t;
  13180. }
  13181. return 0;
  13182. }
  13183. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  13184. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  13185. }
  13186. static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
  13187. Py_ssize_t ignore;
  13188. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  13189. }
  13190. static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  13191. #if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  13192. if (
  13193. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  13194. __Pyx_sys_getdefaultencoding_not_ascii &&
  13195. #endif
  13196. PyUnicode_Check(o)) {
  13197. #if PY_VERSION_HEX < 0x03030000
  13198. char* defenc_c;
  13199. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  13200. if (!defenc) return NULL;
  13201. defenc_c = PyBytes_AS_STRING(defenc);
  13202. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  13203. {
  13204. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  13205. char* c;
  13206. for (c = defenc_c; c < end; c++) {
  13207. if ((unsigned char) (*c) >= 128) {
  13208. PyUnicode_AsASCIIString(o);
  13209. return NULL;
  13210. }
  13211. }
  13212. }
  13213. #endif
  13214. *length = PyBytes_GET_SIZE(defenc);
  13215. return defenc_c;
  13216. #else
  13217. if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
  13218. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  13219. if (PyUnicode_IS_ASCII(o)) {
  13220. *length = PyUnicode_GET_LENGTH(o);
  13221. return PyUnicode_AsUTF8(o);
  13222. } else {
  13223. PyUnicode_AsASCIIString(o);
  13224. return NULL;
  13225. }
  13226. #else
  13227. return PyUnicode_AsUTF8AndSize(o, length);
  13228. #endif
  13229. #endif
  13230. } else
  13231. #endif
  13232. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  13233. if (PyByteArray_Check(o)) {
  13234. *length = PyByteArray_GET_SIZE(o);
  13235. return PyByteArray_AS_STRING(o);
  13236. } else
  13237. #endif
  13238. {
  13239. char* result;
  13240. int r = PyBytes_AsStringAndSize(o, &result, length);
  13241. if (unlikely(r < 0)) {
  13242. return NULL;
  13243. } else {
  13244. return result;
  13245. }
  13246. }
  13247. }
  13248. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  13249. int is_true = x == Py_True;
  13250. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  13251. else return PyObject_IsTrue(x);
  13252. }
  13253. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  13254. #if CYTHON_USE_TYPE_SLOTS
  13255. PyNumberMethods *m;
  13256. #endif
  13257. const char *name = NULL;
  13258. PyObject *res = NULL;
  13259. #if PY_MAJOR_VERSION < 3
  13260. if (PyInt_Check(x) || PyLong_Check(x))
  13261. #else
  13262. if (PyLong_Check(x))
  13263. #endif
  13264. return __Pyx_NewRef(x);
  13265. #if CYTHON_USE_TYPE_SLOTS
  13266. m = Py_TYPE(x)->tp_as_number;
  13267. #if PY_MAJOR_VERSION < 3
  13268. if (m && m->nb_int) {
  13269. name = "int";
  13270. res = PyNumber_Int(x);
  13271. }
  13272. else if (m && m->nb_long) {
  13273. name = "long";
  13274. res = PyNumber_Long(x);
  13275. }
  13276. #else
  13277. if (m && m->nb_int) {
  13278. name = "int";
  13279. res = PyNumber_Long(x);
  13280. }
  13281. #endif
  13282. #else
  13283. res = PyNumber_Int(x);
  13284. #endif
  13285. if (res) {
  13286. #if PY_MAJOR_VERSION < 3
  13287. if (!PyInt_Check(res) && !PyLong_Check(res)) {
  13288. #else
  13289. if (!PyLong_Check(res)) {
  13290. #endif
  13291. PyErr_Format(PyExc_TypeError,
  13292. "__%.4s__ returned non-%.4s (type %.200s)",
  13293. name, name, Py_TYPE(res)->tp_name);
  13294. Py_DECREF(res);
  13295. return NULL;
  13296. }
  13297. }
  13298. else if (!PyErr_Occurred()) {
  13299. PyErr_SetString(PyExc_TypeError,
  13300. "an integer is required");
  13301. }
  13302. return res;
  13303. }
  13304. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  13305. Py_ssize_t ival;
  13306. PyObject *x;
  13307. #if PY_MAJOR_VERSION < 3
  13308. if (likely(PyInt_CheckExact(b))) {
  13309. if (sizeof(Py_ssize_t) >= sizeof(long))
  13310. return PyInt_AS_LONG(b);
  13311. else
  13312. return PyInt_AsSsize_t(x);
  13313. }
  13314. #endif
  13315. if (likely(PyLong_CheckExact(b))) {
  13316. #if CYTHON_USE_PYLONG_INTERNALS
  13317. const digit* digits = ((PyLongObject*)b)->ob_digit;
  13318. const Py_ssize_t size = Py_SIZE(b);
  13319. if (likely(__Pyx_sst_abs(size) <= 1)) {
  13320. ival = likely(size) ? digits[0] : 0;
  13321. if (size == -1) ival = -ival;
  13322. return ival;
  13323. } else {
  13324. switch (size) {
  13325. case 2:
  13326. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  13327. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  13328. }
  13329. break;
  13330. case -2:
  13331. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  13332. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  13333. }
  13334. break;
  13335. case 3:
  13336. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  13337. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  13338. }
  13339. break;
  13340. case -3:
  13341. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  13342. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  13343. }
  13344. break;
  13345. case 4:
  13346. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  13347. 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]));
  13348. }
  13349. break;
  13350. case -4:
  13351. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  13352. 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]));
  13353. }
  13354. break;
  13355. }
  13356. }
  13357. #endif
  13358. return PyLong_AsSsize_t(b);
  13359. }
  13360. x = PyNumber_Index(b);
  13361. if (!x) return -1;
  13362. ival = PyInt_AsSsize_t(x);
  13363. Py_DECREF(x);
  13364. return ival;
  13365. }
  13366. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  13367. return PyInt_FromSize_t(ival);
  13368. }
  13369. #endif /* Py_PYTHON_H */