mò %U²Ic@s6 dklZlZlZdkZeiddedƒdGHd„ZedƒZedƒZ eedƒd jƒee d ƒd jƒd GHd „Z e dƒZe dƒZ eedƒd jƒee d ƒd jƒdGHd„Z e dƒZe dƒZ eedƒd jƒee d ƒd jƒdGHd„Z dZ e ƒZeedƒd jƒdZ eed ƒd jƒdGHd„ZedƒZedƒZ eedƒd jƒee d ƒd jƒdGHd„ZedƒZedƒZ eedƒdjƒee d ƒd jƒdGHd„ZedƒZeedƒdjƒdGHd„Zd„Zedd d ƒZed d!d"ƒZeeƒd#jƒd$GHd%„ZeƒZeeiƒd&jƒeeiƒd'jƒeeiƒd(jƒd&Zd)fd*„ƒYZeƒZeeiƒd&jƒeeiƒd'jƒeeiƒd(jƒd+GHd,„Zeed"ƒd-jƒd.GHed/ƒed0ƒed1ƒed2ƒed3ƒed4ƒd5dUd6GHd7„ZedƒZedƒZ eedƒd jƒee dƒd8jƒd9„ZedƒZedƒZ eedƒd jƒee dƒd8jƒd:„ZdZ edƒZeed ƒd jƒd;„Zedd d ƒZed d!d"ƒZeeƒd<jƒd=GHd>„Z d?„Z!y e ƒWne"j onXe‚y e!ƒWne#j onXe‚d@GHdA„Z$ee$dd d ƒƒdojƒdB„Z%ee%dCdƒƒdCdjƒdD„Z&ee&dpƒdqƒdrjƒdIGHdJa'dK„ZeeƒdJjƒet'dJjƒdJa'dL„Zeeƒd jƒet'dJjƒdJa'dM„Zeeƒd jƒet'd jƒdJa'dN„Zeeƒd jƒet'd jƒdOGHdPfdQ„ƒYZ(dR„Zxe)dEƒD] Z*eƒq´Wee(i+djƒdSGHdT„Zda'eed"ƒd ƒd jƒdUa'eed ƒd ƒdjƒdVGHdW„Zed ƒd!ƒZ,ee,i-dXƒƒe,dX=ee,hdYd <dZdJ<d[d"s1. simple nestingcs‡d†}|S(Ncsˆ|S(N(txty(R(R(t,/data/zmath/lib/python2.4/test/test_scope.pytadder s(R(RR((RRt make_adders ii iiþÿÿÿis2. extra nestingcs‡d†}|ƒS(Ncs‡d†}|S(Ncsˆ|S(N(RR(R(R(RRs(R(R(R(Rtextras (R(RR((RRt make_adder2s s3. simple nesting + rebindingcs‡d†}ˆd‰|S(Ncsˆ|S(N(RR(R(R(RR%si(RR(RR((RRt make_adder3$s  ii s"4. nesting with global but no freecCsd„}|ƒS(NcCsd„}|ƒS(NcCs d„}|S(NcCst|S(N(tglobal_xR(R((RR5s(R(R((Rtnest4s (R (R ((RR 3s (R (R ((Rt make_adder42s s5. nesting through classcsdf‡d†ƒY}|ƒS(NtAddercstZ‡d†ZRS(Ncsˆ|S(N(RR(tselfR(R(Rt__call__Fs(t__name__t __module__R((R(RR Es(R (RR ((RRt make_adder5Dss"6. nesting plus free ref to globalcCsd„}|a|S(NcCst|S(N(t global_nest_xR(R((RRTs(RRR(RR((Rt make_adder6Rs i s7. nearest enclosing scopecCsd„}|dƒS(Ncsd‰‡d†}|S(Ni*csˆ|S(N(Rtz(R(R(Rthds(RR(RRR((RRtgbs i(R(RR((Rtfas ii/s8. mixed freevars and cellvarscCs|S(N(R(R((Rtidentitynscs‡‡d†}|S(Ncs*|ˆ}‡‡‡d†}|ˆ‰|S(NcstˆˆˆƒS(N(RRtbR((RRR(RRts(taRRtcRR(RRRRR(RR(RRRRrs  (R(RRRR((RRRRqsiiii's9. free variable in methodcs#d‰df‡d†ƒY}|ƒS(NtvartTestcs/tZd„Z‡d†Zd„Zd„ZRS(NcCsdS(Ntmethod((R ((Rtmethod_and_var…scsˆS(N(R(R (R(Rttest‡scCs tdƒS(Ntglobal(tstr(R ((Rt actual_global‰scCs t|ƒS(N(R"R (R ((RR"‹s(RRRR R#R"((R(RR„s   (RR(RR((RRR ‚s RRR!RcBs,tZd„Zd„Zd„Zd„ZRS(NcCsdS(NR((R ((RR—scCstS(N(R(R ((RR ™scCs tdƒS(NR!(R"(R ((RR#›scCs t|ƒS(N(R"R (R ((RR"s(RRRR R#R"(((RR•s   s 10. recursioncs4‡d†‰|djoˆ|ƒSn td‚dS(Ncs+|djodSn|ˆ|dƒSdS(Nii(tntfact(R$(R%(RR%¨s isx must be >= 0(R%Rt ValueError(RR%((R%RR§s  iÐs11. unoptimized namespacessŠdef unoptimized_clash1(strip): def f(s): from string import * return strip(s) # ambiguity: free or local return f sƒdef unoptimized_clash2(): from string import * def f(s): return strip(s) # ambiguity: global or local return f sœdef unoptimized_clash2(): from string import * def g(): def f(s): return strip(s) # ambiguity: global or local return f sOdef error(y): exec "a = 1" def f(x): return x + y return f sCdef f(x): def g(): return x del x # can't del name s]def f(): def g(): from string import * return strip # global or local? sç def noproblem1(): from string import * f = lambda x:x def noproblem2(): from string import * def f(x): return x + 1 def noproblem3(): from string import * def f(x): global y y = x s 12. lambdascs ‡d†S(Ncsˆ|S(N(RR(R(R(Rtüs((R((RRR'üsics ‡d†ƒS(Ncs ‡d†S(Ncsˆ|S(N(RR(R(R(RR's(((R(RR's((R((RRR'scCsd„S(NcCst|S(N(R R(R((RR's((R((RR'scs ‡‡d†S(Ncs‡‡‡d†S(Ncs ˆˆˆS(N(RRR((RRR(RR' s((RRR(RR(RRR' s((RRR((RRRR' sis13. UnboundLocalcsˆGH‡d†}d‰dS(NcsˆS(N(R((R(Rtinnersi(RR((RR(((RRt errorInOuters cs‡d†}|ƒd‰dS(NcsˆS(N(R((R(RR(si(R(R(RR(((RRt errorInInners s14. complex definitionscs‡d†}|S(NcsˆS(N(tlst((R+(Rtreturner1s(R,(R+R,((R+Rt makeReturner0s c s‡d†}|S(NcsˆS(N(tkwargs((R.(RR,8s(R,(R.R,((R.Rt makeReturner27s Rcs|\‰‰‡‡d†}|S(Ncs|\}}ˆ|ˆ|fS(N(RtdRR(t.0RR0(RR(RtaddPair?s (RRR2(R1RRR2((RRRt makeAddPair>s idiÈieiÊs15. scope of global statementsicCsd}d„}|ƒS(NicCsd„}|ƒS(NcCsd„}|ƒS(NcCstS(N(R(((RROs(R(R((RtiNs (R4(R4((RRLs (RR(RR((RRJs cCsd}d„}|ƒS(Nicsd‰‡d†}|ƒS(Nics‡d†}|ƒS(NcsˆS(N(R((R(RR^s(R(R(R(RR4]s (RR4(R4R((RRR[s (RR(RR((RRYs cCsd}d„}|ƒS(NicCsdad„}|ƒS(NicCsd„}|ƒS(NcCstS(N(R(((RRns(R(R((RR4ms (RR4(R4((RRjs (RR(RR((RRhs cCsd}d„}|ƒS(NicCsdad„}|ƒS(NicCsd„}|ƒS(NcCstS(N(R(((RR~s(R(R((RR4}s (RR4(R4((RRzs (RR(RR((RRxs s16. check leakstFoocBs tZdZd„Zd„ZRS(NicCstid7_dS(Ni(R5tcount(R ((Rt__init__‹scCstid8_dS(Ni(R5R6(R ((Rt__del__Žs(RRR6R7R8(((RR5ˆs cs tƒ‰‡d†}|ƒdS(NcsˆS(N(R((R(Rtf2“s(R5RR9(RR9((RRtf1‘s  s17. class and globalcsdf‡d†ƒY}|ƒS(NR5cstZ‡d†ZRS(Ncsˆ|S(N(RR(R R(R(RR¡s(RRR((R(RR5Ÿs(R5(RR5((RRR žsiÿÿÿÿs18. verify that locals() workscs‡d†}|S(Ncs'‡d†}ˆˆ}ˆd7‰tƒS(Ncsˆ|S(N(RR(R(R(RR®si(RRRtwtlocals(RRR;(R(RRR­s   (R(RR((RRR¬s RRRR;s"19. var is bound and free in classcsdf‡d†ƒY}|S(NtCcstZ‡d†ZˆZRS(NcsˆS(N(R(R (R(Rtm¾s(RRR>RR((R(RR=½s (R=(RR=((RRR¼ss#20. interaction with trace functioncCstS(N(ttracer(RRR((RR?ÉscsO|\}‰|djo2ˆdjod|i|f‰n‡d†SndS(Nits_%s__%scs t|ˆƒS(N(tgetattrtobjtdes(RB(RC(RR'Ñs(tgettertkindRCtklassRtname(RGRFRDRERC((RCRt adaptgetterÌs    t TestClasscBstZRS(N(RR(((RRIÓstfooR@s&sys.settrace() did not raise TypeErrors%20. eval and exec with free variablescs ‡d†S(NcsˆdS(Ni(R((R(RR'ás((R((RRRàss;eval() should have failed, because code contained free varss9exec should have failed, because code contained free varss+21. list comprehension with local variablessbad should not be definedcCs6g}dD] }|iƒD] }||qq ~dS(Nsa b(t_[1]tstsplittbad(RKRLRN((RRûss22. eval with free variablescs‡d†}|S(NcsˆtdƒdS(Nsx + 1(Rteval((R(RRs(R(RR((RRRs (iii(ii(idiÈ(ieiÊ(iR@(:ttest.test_supporttverifyt TestFailedt check_syntaxtwarningstfilterwarningst SyntaxWarningRtinctplus10RRR R RRRRt test_funcRRRR ttRR#RR:R9tf3tNonetf8R)R*tUnboundLocalErrort NameErrorR-R/R3RR5trangeR4R6R0thas_keytinstRR>tsysR?RHRItsettracet TypeErrorROt func_codeRN((R:R9R[RR]RRSR5RWRYRQRbRHRR RRR-RTRIRR RRRR RRcRXR3R0RRR4RR*R/RZR)R?R((Rt?s€                                                        +