1.1 --- a/micropython/ast.py Sat Jun 12 03:04:08 2010 +0200 1.2 +++ b/micropython/ast.py Sat Jun 12 21:33:36 2010 +0200 1.3 @@ -25,7 +25,6 @@ 1.4 from micropython.rsvp import * 1.5 from micropython.trans import Helper 1.6 import compiler.ast 1.7 -from compiler.visitor import ASTVisitor 1.8 1.9 # Program visitors. 1.10 1.11 @@ -191,7 +190,7 @@ 1.12 # Visitor methods. 1.13 1.14 def default(self, node, *args): 1.15 - raise TranslateError(self.module.full_name(), node, "Node class %r is not supported." % node.__class__) 1.16 + raise TranslateError("Node class %r is not supported." % node.__class__) 1.17 1.18 # Concrete visitor methods. 1.19 1.20 @@ -368,7 +367,7 @@ 1.21 1.22 # Expressions. 1.23 1.24 - def visitBackquote(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Backquote") 1.25 + def visitBackquote(self, node): raise TranslationNotImplementedError("Backquote") 1.26 1.27 def visitCallFunc(self, node): 1.28 1.29 @@ -389,21 +388,21 @@ 1.30 const = self.importer.get_constant(node.value) 1.31 self.new_op(LoadConst(const)) 1.32 1.33 - def visitDict(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Dict") 1.34 + def visitDict(self, node): raise TranslationNotImplementedError("Dict") 1.35 1.36 - def visitEllipsis(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Ellipsis") 1.37 + def visitEllipsis(self, node): raise TranslationNotImplementedError("Ellipsis") 1.38 1.39 - def visitExec(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Exec") 1.40 + def visitExec(self, node): raise TranslationNotImplementedError("Exec") 1.41 1.42 - def visitExpression(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Expression") 1.43 + def visitExpression(self, node): raise TranslationNotImplementedError("Expression") 1.44 1.45 - def visitGenExpr(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "GenExpr") 1.46 + def visitGenExpr(self, node): raise TranslationNotImplementedError("GenExpr") 1.47 1.48 - def visitGenExprFor(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "GenExprFor") 1.49 + def visitGenExprFor(self, node): raise TranslationNotImplementedError("GenExprFor") 1.50 1.51 - def visitGenExprIf(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "GenExprIf") 1.52 + def visitGenExprIf(self, node): raise TranslationNotImplementedError("GenExprIf") 1.53 1.54 - def visitGenExprInner(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "GenExprInner") 1.55 + def visitGenExprInner(self, node): raise TranslationNotImplementedError("GenExprInner") 1.56 1.57 def visitGetattr(self, node): 1.58 self._visitAttr(node, self.attribute_load_instructions) 1.59 @@ -411,11 +410,11 @@ 1.60 def visitList(self, node): 1.61 self._generateList(node) 1.62 1.63 - def visitListComp(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "ListComp") 1.64 + def visitListComp(self, node): raise TranslationNotImplementedError("ListComp") 1.65 1.66 - def visitListCompFor(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "ListCompFor") 1.67 + def visitListCompFor(self, node): raise TranslationNotImplementedError("ListCompFor") 1.68 1.69 - def visitListCompIf(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "ListCompIf") 1.70 + def visitListCompIf(self, node): raise TranslationNotImplementedError("ListCompIf") 1.71 1.72 def visitName(self, node): 1.73 1.74 @@ -430,7 +429,7 @@ 1.75 else: 1.76 self._visitName(node, self.name_load_instructions) 1.77 1.78 - def visitSlice(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Slice") 1.79 + def visitSlice(self, node): raise TranslationNotImplementedError("Slice") 1.80 1.81 def visitSubscript(self, node): 1.82 self.dispatch(node.expr) 1.83 @@ -499,7 +498,7 @@ 1.84 "Assign the assignment expression to the recipient 'node'." 1.85 1.86 if hasattr(node, "flags") and node.flags == "OP_DELETE": 1.87 - raise TranslationNotImplementedError(self.module.full_name(), node, "AssName(OP_DELETE)") 1.88 + raise TranslationNotImplementedError("AssName(OP_DELETE)") 1.89 1.90 self._visitName(node, self.name_store_instructions) 1.91 self.set_source() 1.92 @@ -547,7 +546,7 @@ 1.93 elif isinstance(node.node, compiler.ast.Getattr): 1.94 self.visitAssAttr(node.node) 1.95 else: 1.96 - raise TranslationNotImplementedError(self.module.full_name(), node, "AugAssign(Slice or Subscript)") 1.97 + raise TranslationNotImplementedError("AugAssign(Slice or Subscript)") 1.98 1.99 self.discard_value() 1.100 1.101 @@ -575,7 +574,7 @@ 1.102 self.dispatch(node.code) 1.103 self.unit = unit 1.104 1.105 - def visitDecorators(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Decorators") 1.106 + def visitDecorators(self, node): raise TranslationNotImplementedError("Decorators") 1.107 1.108 def visitFrom(self, node): pass 1.109 1.110 @@ -664,7 +663,7 @@ 1.111 1.112 self.optimiser.reset() 1.113 1.114 - def visitAssert(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Assert") 1.115 + def visitAssert(self, node): raise TranslationNotImplementedError("Assert") 1.116 1.117 def visitBreak(self, node): 1.118 next_block, exit_block = self.get_loop_blocks() 1.119 @@ -819,9 +818,9 @@ 1.120 1.121 def visitPass(self, node): pass 1.122 1.123 - def visitPrint(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Print") 1.124 + def visitPrint(self, node): raise TranslationNotImplementedError("Print") 1.125 1.126 - def visitPrintnl(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Printnl") 1.127 + def visitPrintnl(self, node): raise TranslationNotImplementedError("Printnl") 1.128 1.129 def visitRaise(self, node): 1.130 # NOTE: expr1 only => instance provided 1.131 @@ -940,7 +939,7 @@ 1.132 adding instructions which raise active exceptions. 1.133 """ 1.134 1.135 - raise TranslationNotImplementedError(self.module.full_name(), node, "TryFinally") 1.136 + raise TranslationNotImplementedError("TryFinally") 1.137 1.138 def visitWhile(self, node): 1.139 exit_block = self.new_block() 1.140 @@ -972,8 +971,8 @@ 1.141 1.142 self.drop_loop_blocks() 1.143 1.144 - def visitWith(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "With") 1.145 + def visitWith(self, node): raise TranslationNotImplementedError("With") 1.146 1.147 - def visitYield(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Yield") 1.148 + def visitYield(self, node): raise TranslationNotImplementedError("Yield") 1.149 1.150 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/micropython/common.py Sat Jun 12 03:04:08 2010 +0200 2.2 +++ b/micropython/common.py Sat Jun 12 21:33:36 2010 +0200 2.3 @@ -19,11 +19,27 @@ 2.4 this program. If not, see <http://www.gnu.org/licenses/>. 2.5 """ 2.6 2.7 +import compiler.visitor 2.8 + 2.9 try: 2.10 set 2.11 except NameError: 2.12 from sets import Set as set 2.13 2.14 +# Visitors. 2.15 + 2.16 +class ASTVisitor(compiler.visitor.ASTVisitor): 2.17 + 2.18 + "A base class for visitors." 2.19 + 2.20 + def dispatch(self, node, *args): 2.21 + try: 2.22 + return compiler.visitor.ASTVisitor.dispatch(self, node, *args) 2.23 + except NodeProcessingError, exc: 2.24 + exc.astnode = node 2.25 + exc.unit_name = self.full_name() 2.26 + raise 2.27 + 2.28 # Errors. 2.29 2.30 class ProcessingError(Exception): 2.31 @@ -48,13 +64,24 @@ 2.32 2.33 "A processing error associated with a particular program node." 2.34 2.35 - def __init__(self, unit_name, node, message): 2.36 - self.unit_name = unit_name 2.37 - self.astnode = node 2.38 + def __init__(self, message): 2.39 self.message = message 2.40 + self.unit_name = None 2.41 + self.astnode = None 2.42 + 2.43 + def get_lineno(self, node): 2.44 + lineno = node.lineno 2.45 + if lineno is not None: 2.46 + return lineno 2.47 + else: 2.48 + for child in node.getChildNodes(): 2.49 + lineno = self.get_lineno(child) 2.50 + if lineno is not None: 2.51 + return lineno 2.52 + return None 2.53 2.54 def __repr__(self): 2.55 - return "Error in %r at line %r: %s" % (self.unit_name, self.astnode.lineno, self.message) 2.56 + return "Error in %r at line %r: %s" % (self.unit_name, self.get_lineno(self.astnode), self.message) 2.57 2.58 def __str__(self): 2.59 return repr(self)
3.1 --- a/micropython/data.py Sat Jun 12 03:04:08 2010 +0200 3.2 +++ b/micropython/data.py Sat Jun 12 21:33:36 2010 +0200 3.3 @@ -124,6 +124,7 @@ 3.4 def __init__(self, module=None): 3.5 self.namespace = {} 3.6 self.globals = set() 3.7 + self.scope_usage = {} 3.8 self.module = module 3.9 self.finalised = 0 3.10 3.11 @@ -271,6 +272,27 @@ 3.12 else: 3.13 return 0 3.14 3.15 + def note_scope(self, name, scope): 3.16 + 3.17 + "Note usage of 'name' from the given 'scope' in the current namespace." 3.18 + 3.19 + if not self.scope_usage.has_key(name): 3.20 + self.scope_usage[name] = scope 3.21 + return 1 3.22 + elif self.scope_usage[name] == scope: 3.23 + return 1 3.24 + else: 3.25 + return 0 3.26 + 3.27 + def used_in_scope(self, name, scope): 3.28 + 3.29 + """ 3.30 + Return whether 'name' is used from the given 'scope' in the current 3.31 + namespace. 3.32 + """ 3.33 + 3.34 + return self.scope_usage.get(name) == scope 3.35 + 3.36 # Attribute positioning. 3.37 3.38 def attributes_as_list(self): 3.39 @@ -1244,6 +1266,9 @@ 3.40 # Namespace-related methods. 3.41 3.42 def make_global(self, name): 3.43 + 3.44 + "Declare 'name' as a global in the current namespace." 3.45 + 3.46 if name not in self.argnames and not self.has_key(name): 3.47 self.globals.add(name) 3.48 return 1
4.1 --- a/micropython/inspect.py Sat Jun 12 03:04:08 2010 +0200 4.2 +++ b/micropython/inspect.py Sat Jun 12 21:33:36 2010 +0200 4.3 @@ -75,7 +75,6 @@ 4.4 from micropython.common import * 4.5 from micropython.data import * 4.6 import compiler.ast 4.7 -from compiler.visitor import ASTVisitor 4.8 4.9 # Program visitors. 4.10 4.11 @@ -271,8 +270,20 @@ 4.12 4.13 "Record attribute or local 'name', storing 'obj'." 4.14 4.15 + # Store in the module. 4.16 + 4.17 if not self.namespaces: 4.18 - self.set(name, obj, not self.in_loop) 4.19 + if self.used_in_scope(name, "builtins"): 4.20 + raise InspectError("Name %r already used as a built-in." % name) 4.21 + else: 4.22 + self.set(name, obj, not self.in_loop) 4.23 + 4.24 + # Or store locally. 4.25 + 4.26 + elif self.namespaces[-1].used_in_scope(name, "global"): 4.27 + raise InspectError("Name %r already used as global." % name) 4.28 + elif self.namespaces[-1].used_in_scope(name, "builtins"): 4.29 + raise InspectError("Name %r already used as a built-in." % name) 4.30 else: 4.31 self.namespaces[-1].set(name, obj, not self.in_loop) 4.32 4.33 @@ -390,7 +401,7 @@ 4.34 # Visitor methods. 4.35 4.36 def default(self, node, *args): 4.37 - raise InspectError(self.full_name(), node, "Node class %r is not supported." % node.__class__) 4.38 + raise InspectError("Node class %r is not supported." % node.__class__) 4.39 4.40 def NOP(self, node): 4.41 for n in node.getChildNodes(): 4.42 @@ -549,7 +560,7 @@ 4.43 def visitAssName(self, node): 4.44 if hasattr(node, "flags") and node.flags == "OP_DELETE": 4.45 print "Warning: deletion of attribute %r in %r is not supported." % (node.name, self.full_name()) 4.46 - #raise InspectError(self.full_name(), node, "Deletion of attribute %r is not supported." % node.name) 4.47 + #raise InspectError("Deletion of attribute %r is not supported." % node.name) 4.48 4.49 self.store(node.name, self.expr) 4.50 self.define_attribute_user(node) 4.51 @@ -582,7 +593,7 @@ 4.52 elif isinstance(node.node, compiler.ast.Getattr): 4.53 self.visitAssAttr(node.node) 4.54 else: 4.55 - raise InspectError(self.full_name(), node, "AugAssign(Slice or Subscript)") 4.56 + raise InspectError("AugAssign(Slice or Subscript)") 4.57 4.58 return None 4.59 4.60 @@ -621,13 +632,11 @@ 4.61 expr = self.dispatch(base) 4.62 if isinstance(expr, Attr): 4.63 if expr.assignments != 1: 4.64 - raise InspectError(self.full_name(), node, 4.65 - "Base class %r for %r is not constant." % (base, cls.full_name())) 4.66 + raise InspectError("Base class %r for %r is not constant." % (base, cls.full_name())) 4.67 else: 4.68 cls.add_base(expr.get_value()) 4.69 else: # if expr is None: 4.70 - raise InspectError(self.full_name(), node, 4.71 - "Base class %r for %r is not found: it may be hidden in some way." % (base, cls.full_name())) 4.72 + raise InspectError("Base class %r for %r is not found: it may be hidden in some way." % (base, cls.full_name())) 4.73 4.74 # NOTE: Potentially dubious measure to permit __init__ availability. 4.75 # If no bases exist, adopt the 'object' class. 4.76 @@ -819,7 +828,7 @@ 4.77 for name in node.names: 4.78 ns = self.namespaces[-1] 4.79 if not ns.make_global(name): 4.80 - raise InspectError(ns.full_name(), node, "Name %r is global and local in %r" % (name, ns.full_name())) 4.81 + raise InspectError("Name %r is global and local in %r" % (name, ns.full_name())) 4.82 4.83 # The name is recorded in an earlier process. 4.84 4.85 @@ -899,7 +908,6 @@ 4.86 4.87 if self.importer.predefined_constants.has_key(name): 4.88 attr = self.importer.get_predefined_constant(name) 4.89 - node._scope = "constant" 4.90 4.91 # Locals. 4.92 4.93 @@ -909,7 +917,6 @@ 4.94 # Note usage of the local (potentially a class attribute). 4.95 4.96 self.use_specific_attribute(None, name) 4.97 - node._scope = "local" 4.98 4.99 # Globals. 4.100 4.101 @@ -919,21 +926,33 @@ 4.102 # Note usage of the module attribute. 4.103 4.104 self.use_specific_attribute(self.full_name(), name) 4.105 - node._scope = "global" 4.106 + 4.107 + # Note global usage in any local namespace. 4.108 + 4.109 + if self.namespaces: 4.110 + if not self.namespaces[-1].note_scope(name, "global"): 4.111 + raise InspectError("Name %r cannot be used as global." % name) 4.112 4.113 # Builtins. 4.114 4.115 elif self.builtins is not None and self.builtins.has_key(name): 4.116 attr = self.builtins[name] 4.117 self.use_specific_attribute(self.builtins.full_name(), name) 4.118 - node._scope = "builtins" 4.119 + 4.120 + # Note builtins usage in any local namespace. 4.121 + 4.122 + if self.namespaces: 4.123 + if not self.namespaces[-1].note_scope(name, "builtins"): 4.124 + raise InspectError("Name %r cannot be used as a built-in." % name) 4.125 + else: 4.126 + if not self.note_scope(name, "builtins"): 4.127 + raise InspectError("Name %r cannot be used as a built-in." % name) 4.128 4.129 # Unknown. 4.130 4.131 else: 4.132 attr = None 4.133 self.use_name(name) 4.134 - node._scope = "unknown" 4.135 4.136 return attr 4.137
5.1 --- a/micropython/trans.py Sat Jun 12 03:04:08 2010 +0200 5.2 +++ b/micropython/trans.py Sat Jun 12 21:33:36 2010 +0200 5.3 @@ -59,7 +59,7 @@ 5.4 5.5 "Return the scope for the given 'name'." 5.6 5.7 - if self.unit.has_key(name): 5.8 + if self.unit is not self.module and self.unit.has_key(name): 5.9 return "local" 5.10 elif self.module.has_key(name): 5.11 return "global" 5.12 @@ -89,9 +89,9 @@ 5.13 try: 5.14 return self.builtins[name] 5.15 except KeyError: 5.16 - raise TranslateError(self.module.full_name(), node, "No __builtins__ definition is available for name %r." % name) 5.17 + raise TranslateError("No __builtins__ definition is available for name %r." % name) 5.18 else: 5.19 - raise TranslateError(self.module.full_name(), node, "No __builtins__ module is available for name %r." % name) 5.20 + raise TranslateError("No __builtins__ module is available for name %r." % name) 5.21 5.22 # Code feature methods. 5.23 5.24 @@ -425,15 +425,14 @@ 5.25 try: 5.26 attr = self.objtable.access(target_name, attrname) 5.27 except TableError, exc: 5.28 - raise TranslateError(self.module.full_name(), node, exc.args[0]) 5.29 + raise TranslateError(exc.args[0]) 5.30 5.31 # Produce a suitable instruction. 5.32 5.33 if AddressInstruction is not None: 5.34 self.replace_active_value(AddressInstruction(attr)) 5.35 else: 5.36 - raise TranslateError(self.module.full_name(), node, 5.37 - "Storing of class or module attribute %r via an object is not permitted." % attrname) 5.38 + raise TranslateError("Storing of class or module attribute %r via an object is not permitted." % attrname) 5.39 5.40 return 5.41 5.42 @@ -472,8 +471,7 @@ 5.43 if AddressContextInstruction is not None: 5.44 self.new_op(AddressContextInstruction(attr)) 5.45 else: 5.46 - raise TranslateError(self.module.full_name(), node, 5.47 - "Storing of class attribute %r via self not permitted." % attrname) 5.48 + raise TranslateError("Storing of class attribute %r via self not permitted." % attrname) 5.49 5.50 # Preserve the context if the class attribute comes from an 5.51 # incompatible class. 5.52 @@ -485,8 +483,7 @@ 5.53 if AddressInstruction is not None: 5.54 self.new_op(AddressInstruction(attr)) 5.55 else: 5.56 - raise TranslateError(self.module.full_name(), node, 5.57 - "Storing of class attribute %r via self not permitted." % attrname) 5.58 + raise TranslateError("Storing of class attribute %r via self not permitted." % attrname) 5.59 5.60 # Otherwise, test for a suitable context at run-time. 5.61 5.62 @@ -497,8 +494,7 @@ 5.63 if AddressContextCondInstruction is not None: 5.64 self.new_op(AddressContextCondInstruction(attr)) 5.65 else: 5.66 - raise TranslateError(self.module.full_name(), node, 5.67 - "Storing of class attribute %r via self not permitted." % attrname) 5.68 + raise TranslateError("Storing of class attribute %r via self not permitted." % attrname) 5.69 5.70 return 5.71 5.72 @@ -540,8 +536,7 @@ 5.73 elif AttrInstruction is not None and not attr.is_static_attribute(): 5.74 self.new_op(AttrInstruction(attr)) 5.75 else: 5.76 - raise TranslateError(self.module.full_name(), node, 5.77 - "Storing of class or module attribute %r via an object is not permitted." % attrname) 5.78 + raise TranslateError("Storing of class or module attribute %r via an object is not permitted." % attrname) 5.79 5.80 return 5.81 5.82 @@ -555,8 +550,7 @@ 5.83 # If this error arises on generated code, check the names_used 5.84 # attribute on the Importer. 5.85 5.86 - raise TranslateError(self.module.full_name(), node, 5.87 - "No attribute entry exists for name %r." % attrname) 5.88 + raise TranslateError("No attribute entry exists for name %r." % attrname) 5.89 5.90 # NOTE: Test for class vs. instance attributes, generating 5.91 # NOTE: context-related instructions. 5.92 @@ -785,8 +779,7 @@ 5.93 # Test for illegal conditions. 5.94 5.95 if pos in employed_positions: 5.96 - raise TranslateError(self.module.full_name(), node, 5.97 - "Keyword argument %r overwrites parameter %r." % (arg.name, pos)) 5.98 + raise TranslateError("Keyword argument %r overwrites parameter %r." % (arg.name, pos)) 5.99 5.100 employed_positions.add(pos) 5.101 5.102 @@ -857,7 +850,7 @@ 5.103 5.104 for i in range(ncontext, nargs_min): 5.105 if i not in employed_positions: 5.106 - raise TranslateError(self.module.full_name(), node, 5.107 + raise TranslateError( 5.108 "Argument %r not supplied for %r: need at least %d argument(s)." % (i+1, target.name, nargs_min)) 5.109 5.110 nargs = frame_pos 5.111 @@ -878,7 +871,7 @@ 5.112 # allowed. 5.113 5.114 elif nargs > nargs_max: 5.115 - raise TranslateError(self.module.full_name(), node, 5.116 + raise TranslateError( 5.117 "Too many arguments for %r: need at most %d argument(s)." % (target.name, nargs_max)) 5.118 5.119 else: 5.120 @@ -1165,14 +1158,11 @@ 5.121 5.122 name = node.name 5.123 5.124 - # Transfer scope information if this was set during inspection. 5.125 + # Get the expected scope of the name. 5.126 5.127 - if hasattr(node, "_scope"): 5.128 - scope = node._scope 5.129 - else: 5.130 - scope = self.get_scope(name) 5.131 + scope = self.get_scope(name) 5.132 5.133 - #print self.module.name, node.lineno, name, scope 5.134 + #print self.module.name, node.lineno, name, predicted_scope 5.135 self._generateName(name, scope, classes, node) 5.136 5.137 def _generateName(self, name, scope, classes, node): 5.138 @@ -1197,20 +1187,20 @@ 5.139 elif isinstance(unit, Module): 5.140 self.new_op(AddressInstruction(unit.module_attributes()[name])) 5.141 else: 5.142 - raise TranslateError(self.module.full_name(), node, "Program unit %r has no local %r." % (unit, name)) 5.143 + raise TranslateError("Program unit has no local %r." % name) 5.144 5.145 elif scope == "global": 5.146 globals = self.module.module_attributes() 5.147 if globals.has_key(name): 5.148 self.new_op(AddressInstruction(globals[name])) 5.149 else: 5.150 - raise TranslateError(self.module.full_name(), node, "Module %r has no attribute %r." % (self.module, name)) 5.151 + raise TranslateError("Module has no attribute %r." % name) 5.152 5.153 elif scope == "builtins": 5.154 self.new_op(AddressInstruction(self.get_builtin(name, node))) 5.155 5.156 else: 5.157 - raise TranslateError(self.module.full_name(), node, "Program unit %r uses unknown name %r." % (self.unit, name)) 5.158 + raise TranslateError("Program unit uses unknown name %r." % name) 5.159 5.160 def _visitUnary(self, node): 5.161
6.1 --- a/tests/attributes_class_bind_function.py Sat Jun 12 03:04:08 2010 +0200 6.2 +++ b/tests/attributes_class_bind_function.py Sat Jun 12 21:33:36 2010 +0200 6.3 @@ -1,10 +1,10 @@ 6.4 #!/usr/bin/env python 6.5 6.6 -def e(self, x): 6.7 +def f(self, x): 6.8 return x 6.9 6.10 class C: 6.11 - e = e 6.12 + e = f 6.13 6.14 c = C() 6.15 p = c.e # bound C.e
7.1 --- a/tests/attributes_class_bind_function_inherited.py Sat Jun 12 03:04:08 2010 +0200 7.2 +++ b/tests/attributes_class_bind_function_inherited.py Sat Jun 12 21:33:36 2010 +0200 7.3 @@ -1,10 +1,10 @@ 7.4 #!/usr/bin/env python 7.5 7.6 -def e(self, x): 7.7 +def f(self, x): 7.8 return x 7.9 7.10 class C: 7.11 - e = e 7.12 + e = f 7.13 7.14 class E(C): 7.15 # e = C.e (via inheritance)
8.1 --- a/tests/attributes_class_bind_function_inherited_internal.py Sat Jun 12 03:04:08 2010 +0200 8.2 +++ b/tests/attributes_class_bind_function_inherited_internal.py Sat Jun 12 21:33:36 2010 +0200 8.3 @@ -1,10 +1,10 @@ 8.4 #!/usr/bin/env python 8.5 8.6 -def e(self, x): 8.7 +def f(self, x): 8.8 return x 8.9 8.10 class C: 8.11 - e = e 8.12 + e = f 8.13 8.14 class E(C): 8.15 # e = C.e (via inheritance)
9.1 --- a/tests/attributes_class_bind_function_inherited_via_self.py Sat Jun 12 03:04:08 2010 +0200 9.2 +++ b/tests/attributes_class_bind_function_inherited_via_self.py Sat Jun 12 21:33:36 2010 +0200 9.3 @@ -1,10 +1,10 @@ 9.4 #!/usr/bin/env python 9.5 9.6 -def e(self, x): 9.7 +def f(self, x): 9.8 return x 9.9 9.10 class C: 9.11 - e = e 9.12 + e = f 9.13 9.14 class E(C): 9.15 # e = C.e (via inheritance)
10.1 --- a/tests/attributes_class_bind_function_internal.py Sat Jun 12 03:04:08 2010 +0200 10.2 +++ b/tests/attributes_class_bind_function_internal.py Sat Jun 12 21:33:36 2010 +0200 10.3 @@ -1,10 +1,10 @@ 10.4 #!/usr/bin/env python 10.5 10.6 -def e(self, x): 10.7 +def f(self, x): 10.8 return x 10.9 10.10 class C: 10.11 - e = e 10.12 + e = f 10.13 10.14 def test(self, x): 10.15 return self.e(x)
11.1 --- a/tests/attributes_class_bind_function_unbound.py Sat Jun 12 03:04:08 2010 +0200 11.2 +++ b/tests/attributes_class_bind_function_unbound.py Sat Jun 12 21:33:36 2010 +0200 11.3 @@ -1,10 +1,10 @@ 11.4 #!/usr/bin/env python 11.5 11.6 -def e(self, x): 11.7 +def f(self, x): 11.8 return x 11.9 11.10 class C: 11.11 - e = e 11.12 + e = f 11.13 11.14 class D: 11.15 e = C.e
12.1 --- a/tests/attributes_class_bind_function_unbound_fake_self.py Sat Jun 12 03:04:08 2010 +0200 12.2 +++ b/tests/attributes_class_bind_function_unbound_fake_self.py Sat Jun 12 21:33:36 2010 +0200 12.3 @@ -1,10 +1,10 @@ 12.4 #!/usr/bin/env python 12.5 12.6 -def e(self, x): 12.7 +def f(self, x): 12.8 return x 12.9 12.10 class C: 12.11 - e = e 12.12 + e = f 12.13 12.14 class D: 12.15 e = C.e
13.1 --- a/tests/attributes_class_bind_function_via_self.py Sat Jun 12 03:04:08 2010 +0200 13.2 +++ b/tests/attributes_class_bind_function_via_self.py Sat Jun 12 21:33:36 2010 +0200 13.3 @@ -1,10 +1,10 @@ 13.4 #!/usr/bin/env python 13.5 13.6 -def e(self, x): 13.7 +def g(self, x): 13.8 return x 13.9 13.10 class C: 13.11 - e = e 13.12 + e = g 13.13 13.14 def f(self): 13.15 return self.e
14.1 --- a/tests/attributes_class_bind_function_via_self_uncertain.py Sat Jun 12 03:04:08 2010 +0200 14.2 +++ b/tests/attributes_class_bind_function_via_self_uncertain.py Sat Jun 12 21:33:36 2010 +0200 14.3 @@ -1,10 +1,10 @@ 14.4 #!/usr/bin/env python 14.5 14.6 -def e(self, x): 14.7 +def g(self, x): 14.8 return x 14.9 14.10 class C: 14.11 - e = e 14.12 + e = g 14.13 14.14 def f(self): 14.15 self.m = self.e
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/tests/failure/shadow_class_global.py Sat Jun 12 21:33:36 2010 +0200 15.3 @@ -0,0 +1,11 @@ 15.4 +#!/usr/bin/env python 15.5 + 15.6 +def e(self, x): 15.7 + return x 15.8 + 15.9 +class C: 15.10 + e = e 15.11 + 15.12 +c = C() 15.13 + 15.14 +# vim: tabstop=4 expandtab shiftwidth=4
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/tests/failure/shadow_class_global_reassign.py Sat Jun 12 21:33:36 2010 +0200 16.3 @@ -0,0 +1,15 @@ 16.4 +#!/usr/bin/env python 16.5 + 16.6 +def f(self, x): 16.7 + return x 16.8 + 16.9 +class C: 16.10 + e = f 16.11 + 16.12 + def f(self, x): 16.13 + return x 16.14 + 16.15 +c = C() 16.16 +c.f(1) 16.17 + 16.18 +# vim: tabstop=4 expandtab shiftwidth=4
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/tests/failure/shadow_globals_builtins.py Sat Jun 12 21:33:36 2010 +0200 17.3 @@ -0,0 +1,10 @@ 17.4 +#!/usr/bin/env python 17.5 + 17.6 +c = max(4, 5) 17.7 + 17.8 +def max(a, b): 17.9 + return a 17.10 + 17.11 +result_2 = max(2, 3) 17.12 + 17.13 +# vim: tabstop=4 expandtab shiftwidth=4
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/tests/failure/shadow_locals_globals.py Sat Jun 12 21:33:36 2010 +0200 18.3 @@ -0,0 +1,12 @@ 18.4 +#!/usr/bin/env python 18.5 + 18.6 +a = 1 18.7 + 18.8 +def before(): 18.9 + b = a 18.10 + a = 2 18.11 + return b 18.12 + 18.13 +result1_1 = before() 18.14 + 18.15 +# vim: tabstop=4 expandtab shiftwidth=4
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/tests/failure/shadow_locals_globals_reassign.py Sat Jun 12 21:33:36 2010 +0200 19.3 @@ -0,0 +1,17 @@ 19.4 +#!/usr/bin/env python 19.5 + 19.6 +a = 1 19.7 + 19.8 +def before(): 19.9 + b = a 19.10 + a = 2 19.11 + return b 19.12 + 19.13 +def reassign(): 19.14 + a = a 19.15 + return a 19.16 + 19.17 +result1_1 = before() 19.18 +result2_1 = reassign() 19.19 + 19.20 +# vim: tabstop=4 expandtab shiftwidth=4
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/tests/shadow_globals_builtins.py Sat Jun 12 21:33:36 2010 +0200 20.3 @@ -0,0 +1,8 @@ 20.4 +#!/usr/bin/env python 20.5 + 20.6 +def max(a, b): 20.7 + return a 20.8 + 20.9 +result_2 = max(2, 3) 20.10 + 20.11 +# vim: tabstop=4 expandtab shiftwidth=4
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/tests/shadow_locals_globals.py Sat Jun 12 21:33:36 2010 +0200 21.3 @@ -0,0 +1,12 @@ 21.4 +#!/usr/bin/env python 21.5 + 21.6 +a = 1 21.7 + 21.8 +def after(): 21.9 + a = 2 21.10 + b = a 21.11 + return b 21.12 + 21.13 +result_2 = after() 21.14 + 21.15 +# vim: tabstop=4 expandtab shiftwidth=4
22.1 --- a/tests/xrange.py Sat Jun 12 03:04:08 2010 +0200 22.2 +++ b/tests/xrange.py Sat Jun 12 21:33:36 2010 +0200 22.3 @@ -4,7 +4,7 @@ 22.4 result_0 = xr.start 22.5 result_10 = xr.end 22.6 result_1 = xr.step 22.7 -iter = iter(xr) 22.8 -result1_0 = iter.next() 22.9 +it = iter(xr) 22.10 +result1_0 = it.next() 22.11 22.12 # vim: tabstop=4 expandtab shiftwidth=4