[pypy-svn] r66406 - pypy/branch/parser-compiler/pypy/interpreter/astcompiler

benjamin at codespeak.net benjamin at codespeak.net
Sun Jul 19 00:27:11 CEST 2009


Author: benjamin
Date: Sun Jul 19 00:27:10 2009
New Revision: 66406

Modified:
   pypy/branch/parser-compiler/pypy/interpreter/astcompiler/symtable.py
Log:
do string formatting on constants

Modified: pypy/branch/parser-compiler/pypy/interpreter/astcompiler/symtable.py
==============================================================================
--- pypy/branch/parser-compiler/pypy/interpreter/astcompiler/symtable.py	(original)
+++ pypy/branch/parser-compiler/pypy/interpreter/astcompiler/symtable.py	Sun Jul 19 00:27:10 2009
@@ -243,25 +243,26 @@
     def _check_optimization(self):
         if (self.has_free or self.child_has_free) and not self.optimized:
             err = None
+            if self.child_has_free:
+                trailer = "contains a nested function with free variables"
+            else:
+                trailer = "is a nested function"
+            name = self.name
             if self.import_star:
                 node = self.import_star
                 if self.bare_exec:
                     err = "function %r uses import * and bare exec, " \
-                        "which are illegal because it %s"
+                        "which are illegal because it %s" % (name, trailer)
                 else:
-                    err = "import * is not allowed in function %r because it %s"
+                    err = "import * is not allowed in function %r because " \
+                        "it %s" % (name, trailer)
             elif self.bare_exec:
                 node = self.bare_exec
                 err = "unqualified exec is not allowed in function %r " \
-                    "because it %s"
+                    "because it %s" % (name, trailer)
             else:
                 raise AssertionError("unkown reason for unoptimization")
-            if self.child_has_free:
-                trailer = "contains a nested function with free variables"
-            else:
-                trailer = "is a nested function"
-            raise SyntaxError(err % (self.name, trailer), node.lineno,
-                              node.col_offset)
+            raise SyntaxError(err, node.lineno, node.col_offset)
         self.locals_fully_known = self.optimized and not self.has_exec
 
 
@@ -385,9 +386,11 @@
             old_role = self.scope.lookup_role(name)
             if old_role & (SYM_USED | SYM_ASSIGNED):
                 if old_role & SYM_ASSIGNED:
-                    msg = "name '%s' is assigned to before global declaration"
+                    msg = "name '%s' is assigned to before global declaration" \
+                        % (name,)
                 else:
-                    msg = "name '%s' is used prior to global declaration"
+                    msg = "name '%s' is used prior to global declaration" % \
+                        (name,)
                 misc.syntax_warning(self.space, msg, self.compile_info.filename,
                                     glob.lineno, glob.col_offset)
             self.note_symbol(name, SYM_GLOBAL)



More information about the Pypy-commit mailing list