holger krekel committed d7cf399

make our applevel-loaded _stablecompiler issue
SyntaxWarnings/raise SyntaxErrors on too late
global statements. Makes
pass (but you need to erase lib/ i think
because using the app-level _sre really takes

added the possibility to specify the compiler
for running compliance tests.

Comments (0)

Files changed (2)


     """ Regression Test Declaration.""" 
     def __init__(self, basename, enabled=False, dumbtest=False,
                                  oldstyle=False, core=False, uselibfile=False,
+                                 compiler=None, 
                                  usemodules = ''): 
         self.basename = basename 
         self.enabled = enabled 
         self._oldstyle = oldstyle 
         self._uselibfile = uselibfile
         self._usemodules = usemodules.split()
+        self.compiler = compiler 
         self.core = core
     def oldstyle(self): 
     RegrTest('', enabled=False, dumbtest=1),
     RegrTest('', enabled=True, core=True),
-    RegrTest('', enabled=True, core=True),
+    RegrTest('', enabled=True, core=True, compiler='_stable'),
         # this fails because it relies on the warnings module 
         # turning a warning into an exception, but PyPy's
         # interplevel doesn't call into the app-level warnings
         if regrtest.uselibfile: 
+        if regrtest.compiler:
+            pypy_options.append('--compiler=%s' % regrtest.compiler)
             ['--usemodules=%s' % mod for mod in regrtest.usemodules])
         sopt = " ".join(pypy_options) 


                    SC_UNKNOWN, SC_DEFAULT
 from misc import mangle
 import types
+import warnings
 import sys
+def issue_warning(msg, filename, lineno): 
+    try:
+        warnings.warn_explicit(msg, SyntaxWarning, filename, lineno)
+    except SyntaxWarning:
+        err = SyntaxError(msg)
+        err.filename = filename
+        err.lineno = lineno
+        raise err 
 class Scope:
     localsfullyknown = True
     # XXX how much information do I need about each name?
     def visitGlobal(self, node, scope):
         for name in node.names:
+            namescope = scope.check_name(name)
+            if namescope == SC_LOCAL:
+                issue_warning("name '%s' is assigned to before "
+                              "global declaration" %(name,),
+                              node.filename, node.lineno) 
+            elif namescope != SC_GLOBAL and name in scope.uses:
+                issue_warning("name '%s' is used prior "
+                              "to global declaration" %(name,), 
+                              node.filename, node.lineno)
     def visitAssign(self, node, scope):