mò
­fIc           @   s6	  d  k  l Z l Z l Z d k Z e i d d e d ƒ d GHd „  Z e d ƒ Z e d ƒ Z	 e e d ƒ d	 j ƒ e e	 d
 ƒ d j ƒ d GHd „  Z
 e
 d ƒ Z e
 d ƒ Z	 e e d ƒ d	 j ƒ e e	 d
 ƒ d j ƒ d GHd „  Z e d ƒ Z e d ƒ Z	 e e d ƒ d	 j ƒ e e	 d
 ƒ d j ƒ d GHd „  Z d Z e ƒ  Z e e d ƒ d	 j ƒ d Z e e d
 ƒ d j ƒ d GHd „  Z e d ƒ Z e d ƒ Z	 e e d ƒ d	 j ƒ e e	 d
 ƒ d j ƒ d GHd „  Z e d ƒ Z e d ƒ Z	 e e d ƒ d j ƒ e e	 d
 ƒ d j ƒ d GHd „  Z e d ƒ Z e e d ƒ d j ƒ d GHd „  Z d „  Z e d d	 d  ƒ Z e d	 d! d" ƒ Z e e ƒ  d# j ƒ d$ GHd% „  Z e ƒ  Z e e i ƒ  d& j ƒ e e i ƒ  d' j ƒ e e i ƒ  d( j ƒ d& Z d) f  d* „  ƒ  YZ e ƒ  Z e e i ƒ  d& j ƒ e e i ƒ  d' j ƒ e e i ƒ  d( j ƒ d+ GHd, „  Z e e d" ƒ d- j ƒ d. GHe d/ ƒ e d0 ƒ e d1 ƒ e d2 ƒ e d3 ƒ e d4 ƒ d5 d Ud6 GHd7 „  Z e d ƒ Z e d ƒ Z	 e e d ƒ d	 j ƒ e e	 d ƒ d8 j ƒ d9 „  Z e d ƒ Z e d ƒ Z	 e e d ƒ d	 j ƒ e e	 d ƒ d8 j ƒ d: „  Z d Z e d ƒ Z e e d	 ƒ d  j ƒ d; „  Z e d d	 d  ƒ Z e d	 d! d" ƒ Z e e ƒ  d< j ƒ d= GHd> „  Z  d? „  Z! y e  ƒ  Wn e" j
 o n Xe ‚ y e! ƒ  Wn e# j
 o n Xe ‚ d@ GHdA „  Z$ e e$ d d	 d  ƒ ƒ  do j ƒ dB „  Z% e e% dC d ƒ ƒ  dC d j ƒ dD „  Z& e e& dp ƒ dq ƒ dr j ƒ dI GHdJ a' dK „  Z e e ƒ  dJ j ƒ e t' dJ j ƒ dJ a' dL „  Z e e ƒ  d	 j ƒ e t' dJ j ƒ dJ a' dM „  Z e e ƒ  d	 j ƒ e t' d	 j ƒ dJ a' dN „  Z e e ƒ  d	 j ƒ e t' d	 j ƒ dO GHdP f  dQ „  ƒ  YZ( dR „  Z x e) dE ƒ D] Z* e ƒ  q´We e( i+ d j ƒ dS GHdT „  Z d a' e e d" ƒ d	 ƒ d j ƒ dU a' e e d  ƒ d	 ƒ d j ƒ dV GHdW „  Z e d	 ƒ d! ƒ Z, e e, i- dX ƒ ƒ e, dX =e e, h  dY d	 <dZ dJ <d[ d" <j ƒ d\ GHd] „  Z e d  ƒ ƒ  Z. e e. i/ e. i0 ƒ  j ƒ d^ GHd k1 Z1 d_ „  Z2 d` „  Z3 da f  db „  ƒ  YZ4 e1 i5 e2 ƒ e3 dc e4 ds ƒ e1 i5 d ƒ y e1 i5 ƒ  Wn e6 j
 o n Xe de ‚ df GHdg „  Z e d  ƒ Z y e7 e i8 ƒ Wn e6 j
 o n Xdh GHy e i8 d UWn e6 j
 o n Xdi GHdj GHy	 e9 GHWn e# j
 o n Xdk GHdl „  a' t' ƒ  y	 e9 GHWn e# j
 o n Xdm GHdn „  Z e d! ƒ ƒ  d S(t   (   s   verifys
   TestFaileds   check_syntaxNt   ignores	   import \*s   <string>s   1. simple nestingc            s   ‡  d †  } | S(   Nc            s   ˆ  |  S(   N(   t   xt   y(   R   (   R   (    t,   /mit/python/lib/python2.4/test/test_scope.pyt   adder	   s    (   R   (   R   R   (    (   R   R   t
   make_adder   s    i   i
   i   iþÿÿÿi   s   2. extra nestingc            s   ‡  d †  } | ƒ  S(   Nc             s   ‡  d †  }  |  S(   Nc            s   ˆ  |  S(   N(   R   R   (   R   (   R   (    R   R      s    (   R   (   R   (   R   (    R   t   extra   s    (   R   (   R   R   (    (   R   R   t   make_adder2   s    s   3. simple nesting + rebindingc            s   ‡  d †  } ˆ  d ‰  | S(   Nc            s   ˆ  |  S(   N(   R   R   (   R   (   R   (    R   R   %   s    i   (   R   R   (   R   R   (    (   R   R   t   make_adder3$   s    
i    i	   s"   4. nesting with global but no freec          C   s   d „  }  |  ƒ  S(   Nc          C   s   d „  }  |  ƒ  S(   Nc          C   s   d „  }  |  S(   Nc         C   s   t  |  S(   N(   t   global_xR   (   R   (    (    R   R   5   s    (   R   (   R   (    (    R   t   nest4   s    	(   R
   (   R
   (    (    R   R
   3   s    	(   R
   (   R
   (    (    R   t   make_adder42   s    	s   5. nesting through classc            s   d f  ‡  d †  ƒ  Y} | ƒ  S(   Nt   Adderc              s   t  Z ‡  d †  Z RS(   Nc            s   ˆ  | S(   N(   R   R   (   t   selfR   (   R   (    R   t   __call__F   s    (   t   __name__t
   __module__R   (    (   R   (    R   R   E   s   (   R   (   R   R   (    (   R   R   t   make_adder5D   s    s"   6. nesting plus free ref to globalc         C   s   d „  } |  a | S(   Nc         C   s   t  |  S(   N(   t   global_nest_xR   (   R   (    (    R   R   T   s    (   R   R   R   (   R   R   (    (    R   t   make_adder6R   s     	i   s   7. nearest enclosing scopec         C   s   d „  } | d ƒ S(   Nc            s   d ‰  ‡  d †  } | S(   Ni*   c            s   ˆ  |  S(   N(   R   t   z(   R   (   R   (    R   t   hd   s    (   R   R   (   R   R   R   (    (   R   R   t   gb   s    i   (   R   (   R   R   (    (    R   t   fa   s    	i   i/   s   8. mixed freevars and cellvarsc         C   s   |  S(   N(   R   (   R   (    (    R   t   identityn   s    c            s   ‡  ‡ d †  } | S(   Nc            s*   |  ˆ }  ‡ ‡ ‡  d †  } | ˆ ‰ | S(   Nc              s   t  ˆ ˆ ˆ  ƒ S(   N(   R   R   t   bR   (    (   R   R   R   (    R   R   t   s    (   t   aR   R   t   cR   R   (   R   R   R   R   R   (   R   R   (   R   R   R   R   r   s    

(   R   (   R   R   R   R   (    (   R   R   R   R   q   s    i   i   i   i'   s   9. free variable in methodc             s#   d ‰  d f  ‡  d †  ƒ  Y}  |  ƒ  S(   Nt   vart   Testc              s/   t  Z d „  Z ‡  d †  Z d „  Z d „  Z RS(   Nc         C   s   d S(   Nt   method(    (   R   (    (    R   t   method_and_var…   s    c            s   ˆ  S(   N(   R   (   R   (   R   (    R   t   test‡   s    c         C   s
   t  d ƒ S(   Nt   global(   t   str(   R   (    (    R   t   actual_global‰   s    c         C   s
   t  |  ƒ S(   N(   R"   R   (   R   (    (    R   R"   ‹   s    (   R   R   R   R    R#   R"   (    (   R   (    R   R   „   s   		(   R   R   (   R   R   (    (   R   R   R    ‚   s    	R   R   R!   R   c           B   s,   t  Z d „  Z d „  Z d „  Z d „  Z RS(   Nc         C   s   d S(   NR   (    (   R   (    (    R   R   —   s    c         C   s   t  S(   N(   R   (   R   (    (    R   R    ™   s    c         C   s
   t  d ƒ S(   NR!   (   R"   (   R   (    (    R   R#   ›   s    c         C   s
   t  |  ƒ S(   N(   R"   R   (   R   (    (    R   R"      s    (   R   R   R   R    R#   R"   (    (    (    R   R   •   s   			s   10. recursionc            s4   ‡  d †  ‰  |  d j o ˆ  |  ƒ Sn
 t d ‚ d  S(   Nc            s+   |  d j o d Sn |  ˆ  |  d ƒ Sd  S(   Ni    i   (   t   nt   fact(   R$   (   R%   (    R   R%   ¨   s    i    s   x must be >= 0(   R%   R   t
   ValueError(   R   R%   (    (   R%   R   R   §   s    iÐ  s   11. 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
sO   def error(y):
    exec "a = 1"
    def f(x):
        return x + y
    return f
sC   def 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. lambdasc            s
   ‡  d †  S(   Nc            s   ˆ  |  S(   N(   R   R   (   R   (   R   (    R   t   <lambda>ü   s    (    (   R   (    (   R   R   R'   ü   s    i   c            s   ‡  d †  ƒ  S(   Nc              s
   ‡  d †  S(   Nc            s   ˆ  |  S(   N(   R   R   (   R   (   R   (    R   R'     s    (    (    (   R   (    R   R'     s    (    (   R   (    (   R   R   R'     s    c         C   s   d „  S(   Nc         C   s   t  |  S(   N(   R	   R   (   R   (    (    R   R'     s    (    (   R   (    (    R   R'     s    c            s   ‡  ‡ d †  S(   Nc            s   ‡ ‡ ‡  d †  S(   Nc              s   ˆ ˆ ˆ  S(   N(   R   R   R   (    (   R   R   R   (    R   R'     s    (    (   R   R   R   (   R   R   (   R   R   R'     s    (    (   R   R   R   (    (   R   R   R   R'     s    i   s   13. UnboundLocalc             s   ˆ  GH‡  d †  } d ‰  d  S(   Nc              s   ˆ  S(   N(   R   (    (   R   (    R   t   inner  s    i   (   R   R(   (   R   R(   (    (   R   R   t   errorInOuter  s    c             s   ‡  d †  } | ƒ  d ‰  d  S(   Nc              s   ˆ  S(   N(   R   (    (   R   (    R   R(     s    i   (   R(   R   (   R   R(   (    (   R   R   t   errorInInner  s    s   14. complex definitionsc             s   ‡  d †  } | S(   Nc              s   ˆ  S(   N(   t   lst(    (   R+   (    R   t   returner1  s    (   R,   (   R+   R,   (    (   R+   R   t   makeReturner0  s    c             s   ‡  d †  } | S(   Nc              s   ˆ  S(   N(   t   kwargs(    (   R.   (    R   R,   8  s    (   R,   (   R.   R,   (    (   R.   R   t   makeReturner27  s    R   c            s   |  \ ‰  ‰ ‡  ‡ d †  } | S(   Nc            s   |  \ } } ˆ  | ˆ | f S(   N(   R   t   dR   R   (   t   .0R   R0   (   R   R   (    R   t   addPair?  s   (   R   R   R2   (   R1   R   R   R2   (    (   R   R   R   t   makeAddPair>  s   id   iÈ   ie   iÊ   s   15. scope of global statementsi   c          C   s   d }  d „  } | ƒ  S(   Ni   c          C   s   d „  }  |  ƒ  S(   Nc          C   s   d „  }  |  ƒ  S(   Nc           C   s   t  S(   N(   R   (    (    (    R   R   O  s    (   R   (   R   (    (    R   t   iN  s    	(   R4   (   R4   (    (    R   R   L  s     	(   R   R   (   R   R   (    (    R   R   J  s    	c          C   s   d }  d „  } | ƒ  S(   Ni   c             s   d ‰  ‡  d †  }  |  ƒ  S(   Ni   c             s   ‡  d †  }  |  ƒ  S(   Nc              s   ˆ  S(   N(   R   (    (   R   (    R   R   ^  s    (   R   (   R   (   R   (    R   R4   ]  s    (   R   R4   (   R4   R   (    (   R   R   R   [  s    (   R   R   (   R   R   (    (    R   R   Y  s    	c          C   s   d }  d „  } | ƒ  S(   Ni   c          C   s   d a  d „  }  |  ƒ  S(   Ni   c          C   s   d „  }  |  ƒ  S(   Nc           C   s   t  S(   N(   R   (    (    (    R   R   n  s    (   R   (   R   (    (    R   R4   m  s    	(   R   R4   (   R4   (    (    R   R   j  s     	(   R   R   (   R   R   (    (    R   R   h  s    	c          C   s   d }  d „  } | ƒ  S(   Ni   c          C   s   d a  d „  }  |  ƒ  S(   Ni   c          C   s   d „  }  |  ƒ  S(   Nc           C   s   t  S(   N(   R   (    (    (    R   R   ~  s    (   R   (   R   (    (    R   R4   }  s    	(   R   R4   (   R4   (    (    R   R   z  s     	(   R   R   (   R   R   (    (    R   R   x  s    	s   16. check leakst   Fooc           B   s    t  Z d Z d „  Z d „  Z RS(   Ni    c         C   s   t  i d 7_ d  S(   Ni   (   R5   t   count(   R   (    (    R   t   __init__‹  s    c         C   s   t  i d 8_ d  S(   Ni   (   R5   R6   (   R   (    (    R   t   __del__Ž  s    (   R   R   R6   R7   R8   (    (    (    R   R5   ˆ  s   	c             s    t  ƒ  ‰  ‡  d †  } | ƒ  d  S(   Nc              s   ˆ  S(   N(   R   (    (   R   (    R   t   f2“  s    (   R5   R   R9   (   R   R9   (    (   R   R   t   f1‘  s    	s   17. class and globalc            s   d f  ‡  d †  ƒ  Y} | ƒ  S(   NR5   c              s   t  Z ‡  d †  Z RS(   Nc            s   ˆ  | S(   N(   R   R   (   R   R   (   R   (    R   R   ¡  s    (   R   R   R   (    (   R   (    R   R5   Ÿ  s    (   R5   (   R   R5   (    (   R   R   R    ž  s    iÿÿÿÿs   18. verify that locals() worksc            s   ‡  d †  } | S(   Nc            s'   ‡  d †  } ˆ ˆ  } ˆ  d 7‰  t ƒ  S(   Nc            s   ˆ  |  S(   N(   R   R   (   R   (   R   (    R   R   ®  s    i   (   R   R   R   t   wt   locals(   R   R   R;   (   R   (   R   R   R   ­  s    

(   R   (   R   R   (    (   R   R   R   ¬  s    R   R   R   R;   s"   19. var is bound and free in classc            s   d f  ‡  d †  ƒ  Y} | S(   Nt   Cc              s   t  Z ‡  d †  Z ˆ  Z RS(   Nc            s   ˆ  S(   N(   R   (   R   (   R   (    R   t   m¾  s    (   R   R   R>   R   R   (    (   R   (    R   R=   ½  s   (   R=   (   R   R=   (    (   R   R   R   ¼  s    s#   20. interaction with trace functionc         C   s   t  S(   N(   t   tracer(   R   R   R   (    (    R   R?   É  s    c            sO   | \ } ‰  | d j o2 ˆ  d j o d | i |  f ‰  n ‡  d †  Sn d  S(   Ni   t    s   _%s__%sc            s   t  |  ˆ  ƒ S(   N(   t   getattrt   objt   des(   RB   (   RC   (    R   R'   Ñ  s    (   t   gettert   kindRC   t   klassR   t   name(   RG   RF   RD   RE   RC   (    (   RC   R   t   adaptgetterÌ  s
    t	   TestClassc           B   s   t  Z RS(   N(   R   R   (    (    (    R   RI   Ó  s   t   fooR@   s&   sys.settrace() did not raise TypeErrors%   20. eval and exec with free variablesc            s
   ‡  d †  S(   Nc              s   ˆ  d S(   Ni   (   R   (    (   R   (    R   R'   á  s    (    (   R   (    (   R   R   R   à  s    s;   eval() should have failed, because code contained free varss9   exec should have failed, because code contained free varss+   21. list comprehension with local variabless   bad should not be definedc          C   s6   g  }  d D]  } | i ƒ  D] } |  | q q ~  d  S(   Ns   a b(   t   _[1]t   st   splitt   bad(   RK   RL   RN   (    (    R   R   û  s    s   22. eval with free variablesc            s   ‡  d †  } | S(   Nc              s   ˆ  t d ƒ d  S(   Ns   x + 1(   R   t   eval(    (   R   (    R   R     s    (   R   (   R   R   (    (   R   R   R     s    (   i   i   i   (   i   i   (   id   iÈ   (   ie   iÊ   (   i   R@   (:   t   test.test_supportt   verifyt
   TestFailedt   check_syntaxt   warningst   filterwarningst   SyntaxWarningR   t   inct   plus10R   R   R   R	   R   R   R   R   t	   test_funcR   R   R   R    t   tR   R#   R   R:   R9   t   f3t   Nonet   f8R)   R*   t   UnboundLocalErrort	   NameErrorR-   R/   R3   R   R5   t   rangeR4   R6   R0   t   has_keyt   instR   R>   t   sysR?   RH   RI   t   settracet	   TypeErrorRO   t	   func_codeRN   ((   R:   R9   R[   R   R]   R   RS   R5   RW   RY   RQ   Rb   RH   R   R    RR   R-   RT   RI   R   R   R   R   R   R	   R   Rc   RX   R3   R0   R   R   R4   R   R*   R/   RZ   R)   R?   R   (    (    R   t   ?   s€  																






									 		
	
				 			+				  						