ó
‹wÛjc           @   sj   d  d l  Z  d  d l m Z m Z m Z m Z d e  j f d „  ƒ  YZ d „  Z e	 d k rf e ƒ  n  d S(   iÿÿÿÿN(   t   check_syntax_errort   check_py3k_warningst   check_warningst   run_unittestt
   ScopeTestsc           B   s  e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sQ   d „  } | d ƒ } | d ƒ } |  j  | d ƒ d ƒ |  j  | d ƒ d ƒ d  S(   Nc            s   ‡  f d †  } | S(   Nc            s   ˆ  |  S(   N(    (   t   y(   t   x(    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   adder   s    (    (   R   R   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt
   make_adder
   s    i   i
   i   iþÿÿÿi   (   t   assertEqual(   t   selfR   t   inct   plus10(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testSimpleNesting   s
    	c         C   sQ   d „  } | d ƒ } | d ƒ } |  j  | d ƒ d ƒ |  j  | d ƒ d ƒ d  S(   Nc            s   ‡  f d †  } | ƒ  S(   Nc             s   ‡  f d †  }  |  S(   Nc            s   ˆ  |  S(   N(    (   R   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR      s    (    (   R   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   extra   s    (    (   R   R   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   make_adder2   s    i   i
   i   iþÿÿÿi   (   R	   (   R
   R   R   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testExtraNesting   s
    	c         C   sQ   d „  } | d ƒ } | d ƒ } |  j  | d ƒ d ƒ |  j  | d ƒ d ƒ d  S(   Nc            s   ‡  f d †  } ˆ  d ‰  | S(   Nc            s   ˆ  |  S(   N(    (   R   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR   '   s    i   (    (   R   R   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   make_adder3&   s    
i    i	   i   i   iþÿÿÿi   (   R	   (   R
   R   R   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testSimpleAndRebinding$   s
    	c            sT   ‡  f d †  } d ‰  | ƒ  } |  j  | d ƒ d ƒ d ‰  |  j  | d ƒ d ƒ d  S(   Nc             s   ‡  f d †  }  |  ƒ  S(   Nc             s   ‡  f d †  }  |  ƒ  S(   Nc             s   ‡  f d †  }  |  S(   Nc            s   ˆ  |  S(   N(    (   R   (   t   global_x(    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR   7   s    (    (   R   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   nest6   s    (    (   R   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR   5   s    (    (   R   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   make_adder44   s    i   i   i
   iþÿÿÿi   (   R	   (   R
   R   R   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testNestingGlobalNoFree2   s    		c         C   sQ   d „  } | d ƒ } | d ƒ } |  j  | d ƒ d ƒ |  j  | d ƒ d ƒ d  S(   Nc            s    d d ‡  f d †  ƒ  Y} | ƒ  S(   Nt   Adderc              s   e  Z ‡  f d  †  Z RS(   c            s   ˆ  | S(   N(    (   R
   R   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   __call__H   s    (   t   __name__t
   __module__R   (    (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR   G   s   (    (    (   R   R   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   make_adder5F   s    i   i
   i   iþÿÿÿi   (   R	   (   R
   R   R   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testNestingThroughClassD   s
    	c         C   sQ   d „  } | d ƒ } | d ƒ } |  j  | d ƒ d ƒ |  j  | d ƒ d ƒ d  S(   Nc         S   s   d „  } |  a  | S(   Nc         S   s   t  |  S(   N(   t   global_nest_x(   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR   V   s    (   R   (   R   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   make_adder6T   s    	i   i
   i   iþÿÿÿi   (   R	   (   R
   R   R   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testNestingPlusFreeRefToGlobalR   s
    	c         C   s/   d „  } | d ƒ } |  j  | d ƒ d ƒ d  S(   Nc         S   s   d „  } | d ƒ S(   Nc            s   d ‰  ‡  f d †  } | S(   Ni*   c            s   ˆ  |  S(   N(    (   t   z(   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   hf   s    (    (   R   R!   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   gd   s    i   (    (   R   R"   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   fc   s    	i
   i   i/   (   R	   (   R
   R#   t	   test_func(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testNearestEnclosingScopea   s    	c            sS   d „  ‰  ‡  f d †  } | d d d ƒ } | d d d ƒ } |  j  | ƒ  d ƒ d  S(	   Nc         S   s   |  S(   N(    (   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   identityp   s    c            s   ‡ ‡  ‡ f d †  } | S(   Nc            s0   |  ˆ }  ‡  ‡ ‡ ‡ f d †  } | ˆ ‰ | S(   Nc              s   ˆ ˆ ˆ  ˆ ƒ S(   N(    (    (   t   bR&   R   R    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR!   v   s    (    (   t   aR'   t   cR!   (   R&   R   R    (   R'   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR"   t   s    

(    (   R   R   R    R"   (   R&   (   R   R    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR#   s   s    i   i   i   i   i   i'   (   R	   (   R
   R#   R"   R!   (    (   R&   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testMixedFreevarsAndCellvarsn   s
    	c            sÂ   d „  } | ƒ  } |  j  | j ƒ  d ƒ |  j  | j ƒ  d ƒ |  j  | j ƒ  d ƒ d ‰  d d ‡  f d †  ƒ  Y} | ƒ  } |  j  | j ƒ  d ƒ |  j  | j ƒ  d ƒ |  j  | j ƒ  d ƒ d  S(   Nc             s&   d ‰  d d ‡  f d †  ƒ  Y}  |  ƒ  S(   Nt   vart   Testc              s2   e  Z d  „  Z ‡  f d †  Z d „  Z d „  Z RS(   c         S   s   d S(   Nt   method(    (   R
   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   method_and_var‡   s    c            s   ˆ  S(   N(    (   R
   (   R.   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   test‰   s    c         S   s
   t  d ƒ S(   Nt   global(   t   str(   R
   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   actual_global‹   s    c         S   s
   t  |  ƒ S(   N(   R1   (   R
   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR1   �   s    (   R   R   R.   R/   R2   R1   (    (   R.   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR,   †   s   		(    (    (   R,   (    (   R.   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR/   „   s    	R+   R-   R0   R,   c              s2   e  Z d  „  Z ‡  f d †  Z d „  Z d „  Z RS(   c         S   s   d S(   NR-   (    (   R
   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR.   ™   s    c            s   ˆ  S(   N(    (   R
   (   R.   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR/   ›   s    c         S   s
   t  d ƒ S(   NR0   (   R1   (   R
   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR2   �   s    c         S   s
   t  |  ƒ S(   N(   R1   (   R
   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR1   Ÿ   s    (   R   R   R.   R/   R2   R1   (    (   R.   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR,   —   s   		(    (   R	   R/   R.   R2   (   R
   R/   t   tR,   (    (   R.   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testFreeVarInMethod‚   s    			c         C   s#   d „  } |  j  | d ƒ d ƒ d  S(   Nc            s2   ‡  f d †  ‰  |  d k r% ˆ  |  ƒ St  d ‚ d  S(   Nc            s&   |  d k r d S|  ˆ  |  d ƒ Sd  S(   Ni    i   (    (   t   n(   t   fact(    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR6   ª   s    i    s   x must be >= 0(   t
   ValueError(   R   (    (   R6   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR#   ©   s    
i   iÐ  (   R	   (   R
   R#   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testRecursion§   s    	c         B   sZ   e  |  d ƒ e  |  d ƒ e  |  d ƒ e  |  d ƒ e  |  d ƒ e  |  d ƒ d d  Ud  S(   NsŠ   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
(   R    (   R
   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testUnoptimizedNamespaces·   s    c   	         s  d „  } | d ƒ } | d ƒ } |  j  | d ƒ d ƒ |  j  | d ƒ d ƒ d „  } | d ƒ } | d ƒ } |  j  | d ƒ d ƒ |  j  | d ƒ d ƒ ‡  f d †  } d ‰  | d  ƒ } |  j  | d ƒ d	 ƒ d
 „  } | d d d	 ƒ } | d d d ƒ } |  j  | ƒ  d ƒ d  S(   Nc            s   ‡  f d †  S(   Nc            s   ˆ  |  S(   N(    (   R   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   <lambda>þ   t    (    (   R   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR:   þ   R;   i   i
   i   i   i   c            s   ‡  f d †  ƒ  S(   Nc              s   ‡  f d †  S(   Nc            s   ˆ  |  S(   N(    (   R   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR:     R;   (    (    (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR:     R;   (    (   R   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR:     R;   c            s   ‡  f d †  S(   Nc            s   ˆ  |  S(   N(    (   R   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR:   
  R;   (    (   R   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR:   
  R;   i   c            s   ‡  ‡ f d †  S(   Nc            s   ‡  ‡ ‡ f d †  S(   Nc              s   ˆ ˆ  ˆ S(   N(    (    (   R'   R   R    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR:     R;   (    (   R(   R'   R)   (   R   R    (   R'   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR:     R;   (    (   R   R   R    (    (   R   R    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR:     R;   i   i   i   (   R	   t   None(	   R
   t   f1R   R   t   f2t   f3t   f8R"   R!   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testLambdasü   s$    			c         B   sH   d „  } d „  } |  j  e | ƒ |  j  e | ƒ d i |  j d 6Ud  S(   Nc             s   ˆ  GH‡  f d †  }  d ‰  d  S(   Nc              s   ˆ  S(   N(    (    (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   inner  s    i   (    (   RB   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   errorInOuter  s    c             s    ‡  f d †  }  |  ƒ  d ‰  d  S(   Nc              s   ˆ  S(   N(    (    (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyRB     s    i   (    (   RB   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   errorInInner  s    s–   
global_x = 1
def f():
    global_x += 1
try:
    f()
except UnboundLocalError:
    pass
else:
    fail('scope of global_x not correctly determined')
t   fail(   t   assertRaisest   UnboundLocalErrort	   NameErrorRE   (   R
   RC   RD   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testUnboundLocal  s
    		c         B   s•   d „  } |  j  | d d d ƒ ƒ  d ƒ d „  } |  j  | d d ƒ ƒ  d d ƒ e d e f ƒ � d	 e ƒ  UWd  QX|  j  e d ƒ d ƒ d ƒ d  S(   Nc             s   ‡  f d †  } | S(   Nc              s   ˆ  S(   N(    (    (   t   lst(    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   returner5  s    (    (   RJ   RK   (    (   RJ   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   makeReturner4  s    i   i   i   c             s   ‡  f d †  } | S(   Nc              s   ˆ  S(   N(    (    (   t   kwargs(    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyRK   <  s    (    (   RM   RK   (    (   RM   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   makeReturner2;  s    R(   i   s*   tuple parameter unpacking has been removedsc   def makeAddPair((a, b)):
    def addPair((c, d)):
        return (a + c, b + d)
    return addPair
id   iÈ   ie   iÊ   (   i   i   i   (   i   i   (   id   iÈ   (   ie   iÊ   (   R	   R   t   SyntaxWarningt   localst   makeAddPair(   R
   RL   RN   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testComplexDefinitions2  s    		 c         B   s   d d  Ud  S(   NsÉ  # I
x = 7
def f():
    x = 1
    def g():
        global x
        def i():
            def h():
                return x
            return h()
        return i()
    return g()
self.assertEqual(f(), 7)
self.assertEqual(x, 7)

# II
x = 7
def f():
    x = 1
    def g():
        x = 2
        def i():
            def h():
                return x
            return h()
        return i()
    return g()
self.assertEqual(f(), 2)
self.assertEqual(x, 7)

# III
x = 7
def f():
    x = 1
    def g():
        global x
        x = 2
        def i():
            def h():
                return x
            return h()
        return i()
    return g()
self.assertEqual(f(), 2)
self.assertEqual(x, 2)

# IV
x = 7
def f():
    x = 3
    def g():
        global x
        x = 2
        def i():
            def h():
                return x
            return h()
        return i()
    return g()
self.assertEqual(f(), 2)
self.assertEqual(x, 2)

# XXX what about global statements in class blocks?
# do they affect methods?

x = 12
class Global:
    global x
    x = 13
    def set(self, val):
        x = val
    def get(self):
        return x

g = Global()
self.assertEqual(g.get(), 13)
g.set(15)
self.assertEqual(g.get(), 13)
(    (   R
   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testScopeOfGlobalStmtL  s    Rc            s]   d d ‡  f d †  ƒ  Y‰  ‡  f d †  } x t  d ƒ D] } | ƒ  q5 W|  j ˆ  j d ƒ d  S(   Nt   Fooc              s,   e  Z d  Z ‡  f d †  Z ‡  f d †  Z RS(   i    c            s   ˆ  j  d 7_  d  S(   Ni   (   t   count(   R
   (   RT   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   __init__¥  s    c            s   ˆ  j  d 8_  d  S(   Ni   (   RU   (   R
   (   RT   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   __del__¨  s    (   R   R   RU   RV   RW   (    (   RT   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyRT   ¢  s   c             s#   ˆ ƒ  ‰  ‡  f d †  }  |  ƒ  d  S(   Nc              s   ˆ  S(   N(    (    (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR>   ­  s    (    (   R>   (   RT   (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR=   «  s    	id   i    (    (   t   rangeR	   RU   (   R
   R=   t   i(    (   RT   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt	   testLeaks   s
    	c         B   s   d d  Ud  S(   Ns¶  def test(x):
    class Foo:
        global x
        def __call__(self, y):
            return x + y
    return Foo()

x = 0
self.assertEqual(test(6)(2), 8)
x = -1
self.assertEqual(test(3)(2), 5)

looked_up_by_load_name = False
class X:
    # Implicit globals inside classes are be looked up by LOAD_NAME, not
    # LOAD_GLOBAL.
    locals()['looked_up_by_load_name'] = True
    passed = looked_up_by_load_name

self.assertTrue(X.passed)
(    (   R
   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testClassAndGlobal¶  s    c         C   s[   d „  } | d ƒ d ƒ } |  j  d | ƒ | d =|  j | i d d 6d d 6d d	 6ƒ d  S(
   Nc            s   ‡  f d †  } | S(   Nc            s*   ‡  f d †  } ˆ ˆ  } ˆ  d 7‰  t  ƒ  S(   Nc            s   ˆ  |  S(   N(    (   R    (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR!   Ó  s    i   (   RP   (   R   R!   t   w(   R   (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR"   Ò  s    

(    (   R   R"   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR#   Ñ  s    i   i   R!   R   i   R   i   R\   (   t   assertInR	   (   R
   R#   t   d(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testLocalsFunctionÏ  s
    		c         C   s^   d „  } |  j  | d ƒ j d ƒ d „  } | d ƒ j } |  j d | ƒ |  j d | ƒ d  S(   Nc            s   d d ‡  f d †  ƒ  Y} | S(   Nt   Cc              s$   e  Z d  Z ‡  f d †  Z e ƒ  RS(   i   c            s   ˆ  S(   N(    (   R
   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   mí  s    (   R   R   R   Ra   RP   (    (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR`   ë  s   (    (    (   R   R`   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR#   ê  s    i   i   c            s   d d ‡  f d †  ƒ  Y} | S(   NR`   c              s,   e  Z ˆ  Z ‡  f d  †  Z e e ƒ  ƒ Z RS(   c            s   ˆ  S(   N(    (   R
   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyRa   ÷  s    (   R   R   R   Ra   t   listRP   R    (    (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR`   õ  s   (    (    (   R   R`   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR#   ô  s    R   R   (   R	   R   R    t   assertNotInR]   (   R
   R#   t   varnames(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testLocalsClassß  s    		c            sd   d d  l  } | j d „  ƒ z3 d ‰  d d ‡  f d †  ƒ  Y} |  j ˆ  d ƒ Wd  | j d  ƒ Xd  S(   Niÿÿÿÿc         S   s   d  S(   N(   R<   (   R(   R'   R)   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR:     R;   i   R`   c              s   e  Z ‡  f d  †  Z RS(   c            s   ˆ  S(   N(    (   R
   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR#     s    (   R   R   R#   (    (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR`   
  s   (    (   t   syst   settraceR	   R<   (   R
   Rf   R`   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testLocalsClass_WithTrace   s    c         C   s5   d „  } | d ƒ ƒ  } |  j  | j | j ƒ  ƒ d  S(   Nc            s   d d ‡  f d †  ƒ  Y} | S(   NR`   c              s   e  Z ‡  f d  †  Z ˆ  Z RS(   c            s   ˆ  S(   N(    (   R
   (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyRa     s    (   R   R   Ra   R(   (    (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR`     s   (    (    (   R   R`   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR#     s    i   (   R	   R(   Ra   (   R
   R#   t   inst(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testBoundAndFree  s    	c            sx   d d  l  } ‡  f d †  ‰  d „  } d d	 d „  ƒ  Y} | j ˆ  ƒ | d | d
 ƒ | j d  ƒ |  j t | j ƒ d  S(   Niÿÿÿÿc            s   ˆ  S(   N(    (   R(   R'   R)   (   t   tracer(    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyRk   "  s    c            sK   | \ } ‰  | d k rG ˆ  d k r: d | j  |  f ‰  n  ‡  f d †  Sd  S(   Ni   R;   s   _%s__%sc            s   t  |  ˆ  ƒ S(   N(   t   getattr(   t   obj(   t   des(    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR:   *  R;   (   R   (   t   namet   klasst   gettert   kind(    (   Rn   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   adaptgetter%  s
    t	   TestClassc           B   s   e  Z RS(    (   R   R   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyRt   ,  s   t   fooi   R;   (    (   i   R;   (   Rf   Rg   R<   RF   t	   TypeError(   R
   Rf   Rs   Rt   (    (   Rk   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testInteractionWithTraceFunc  s    	c         B   s_   d „  } | d ƒ } |  j  e e | j ƒ y | j i  UWn e k
 rM n X|  j d ƒ d  S(   Nc            s   ‡  f d †  S(   Nc              s   ˆ  d S(   Ni   (    (    (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR:   8  R;   (    (   R   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR#   7  s    i   s9   exec should have failed, because code contained free vars(   RF   Rv   t   evalt	   func_codeRE   (   R
   R#   R"   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testEvalExecFreeVars5  s    	c         C   sS   y	 t  GHWn t k
 r n Xd GHd „  } | ƒ  y	 t  GHWn t k
 rN n Xd  S(   Ns   bad should not be definedc          S   s.   g  d D] }  |  j  ƒ  D] } | ^ q q d  S(   Ns   a b(   t   split(   t   st   bad(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR   M  s    (   R}   RH   (   R
   R   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testListCompLocalVarsD  s    			c         C   s   d „  } | d ƒ ƒ  d  S(   Nc            s   ‡  f d †  } | S(   Nc              s   ˆ  t  d ƒ d  S(   Ns   x + 1(   Rx   (    (   R   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR"   Y  s    (    (   R   R"   (    (   R   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR#   X  s    i   (    (   R
   R#   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testEvalFreeVarsV  s    	c            s-   d d d „  ƒ  Y‰  ‡  f d †  } | ƒ  d  S(   Nt   Specialc           B   s   e  Z d  „  Z RS(   c         S   s   t  ƒ  d  S(   N(   t   nestedcell_get(   R
   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyRW   d  s    (   R   R   RW   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR€   c  s   c              s%   ‡  f d †  a  ˆ ƒ  f ‰  d ‰  d  S(   Nc              s   ˆ  S(   N(    (    (   R)   (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR�   i  s    i   (   R�   (    (   R€   (   R)   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR#   g  s    (    (    (   R
   R#   (    (   R€   s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testFreeingCell`  s    c         B   sH   d } i  } i  } | | | U|  j  d | d ƒ |  j  d | d ƒ d  S(   Ns¢   def f():
    y = 1
    def g():
        global y
        return y
    def h():
        return y + 1
    return g, h

y = 9
g, h = f()
result9 = g()
result2 = h()
i   t   result2i	   t   result9(   R	   (   R
   t   CODEt   local_nst	   global_ns(    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt#   testGlobalInParallelNestedFunctionsq  s    
c         C   s   d „  } d „  } d  S(   Nc         S   s   d  S(   N(    (   R(   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   topŒ  s    c           S   s   d  S(   N(    (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR'   Ž  s    (    (   R
   R‰   R'   (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   testTopIsNotSignificantŠ  s    	(   R   R   R   R   R   R   R   R   R%   R*   R4   R8   R9   RA   RI   RR   RS   RZ   R[   R_   Re   Rh   Rj   Rw   Rz   R~   R   R‚   Rˆ   RŠ   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyR      s8   									%		E				T				!						
		c           C   s'   t  d t f ƒ � t t ƒ Wd  QXd  S(   Ns&   import \* only allowed at module level(   R   RO   R   R   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt	   test_main’  s    t   __main__(
   t   unittestt   test.test_supportR    R   R   R   t   TestCaseR   R‹   R   (    (    (    s…   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_scope.pyt   <module>   s   "ÿ ÿ Ž	