# HG changeset patch # User Paul Boddie # Date 1276371216 -7200 # Node ID b8c6ae7387238c96eb1dc2921a8a60287255a42d # Parent 475fd98986d900d668fbff6a5d35660c7000a941 Simplified exception raising so that the current node and unit name are added to raised exceptions automatically. Improved line number reporting in exceptions. Removed the previous _scope annotations on AST nodes, handling scope conflicts in the inspection process. Added the note_scope and used_in_scope methods and the scope_usage attribute to namespaces in order to track any external scope usage recorded for names. Changed various tests to not employ name shadowing. Added various tests which should exhibit failure due to name shadowing. Fixed the xrange test which previously used name shadowing. diff -r 475fd98986d9 -r b8c6ae738723 micropython/ast.py --- a/micropython/ast.py Sat Jun 12 03:04:08 2010 +0200 +++ b/micropython/ast.py Sat Jun 12 21:33:36 2010 +0200 @@ -25,7 +25,6 @@ from micropython.rsvp import * from micropython.trans import Helper import compiler.ast -from compiler.visitor import ASTVisitor # Program visitors. @@ -191,7 +190,7 @@ # Visitor methods. def default(self, node, *args): - raise TranslateError(self.module.full_name(), node, "Node class %r is not supported." % node.__class__) + raise TranslateError("Node class %r is not supported." % node.__class__) # Concrete visitor methods. @@ -368,7 +367,7 @@ # Expressions. - def visitBackquote(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Backquote") + def visitBackquote(self, node): raise TranslationNotImplementedError("Backquote") def visitCallFunc(self, node): @@ -389,21 +388,21 @@ const = self.importer.get_constant(node.value) self.new_op(LoadConst(const)) - def visitDict(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Dict") + def visitDict(self, node): raise TranslationNotImplementedError("Dict") - def visitEllipsis(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Ellipsis") + def visitEllipsis(self, node): raise TranslationNotImplementedError("Ellipsis") - def visitExec(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Exec") + def visitExec(self, node): raise TranslationNotImplementedError("Exec") - def visitExpression(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Expression") + def visitExpression(self, node): raise TranslationNotImplementedError("Expression") - def visitGenExpr(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "GenExpr") + def visitGenExpr(self, node): raise TranslationNotImplementedError("GenExpr") - def visitGenExprFor(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "GenExprFor") + def visitGenExprFor(self, node): raise TranslationNotImplementedError("GenExprFor") - def visitGenExprIf(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "GenExprIf") + def visitGenExprIf(self, node): raise TranslationNotImplementedError("GenExprIf") - def visitGenExprInner(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "GenExprInner") + def visitGenExprInner(self, node): raise TranslationNotImplementedError("GenExprInner") def visitGetattr(self, node): self._visitAttr(node, self.attribute_load_instructions) @@ -411,11 +410,11 @@ def visitList(self, node): self._generateList(node) - def visitListComp(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "ListComp") + def visitListComp(self, node): raise TranslationNotImplementedError("ListComp") - def visitListCompFor(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "ListCompFor") + def visitListCompFor(self, node): raise TranslationNotImplementedError("ListCompFor") - def visitListCompIf(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "ListCompIf") + def visitListCompIf(self, node): raise TranslationNotImplementedError("ListCompIf") def visitName(self, node): @@ -430,7 +429,7 @@ else: self._visitName(node, self.name_load_instructions) - def visitSlice(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Slice") + def visitSlice(self, node): raise TranslationNotImplementedError("Slice") def visitSubscript(self, node): self.dispatch(node.expr) @@ -499,7 +498,7 @@ "Assign the assignment expression to the recipient 'node'." if hasattr(node, "flags") and node.flags == "OP_DELETE": - raise TranslationNotImplementedError(self.module.full_name(), node, "AssName(OP_DELETE)") + raise TranslationNotImplementedError("AssName(OP_DELETE)") self._visitName(node, self.name_store_instructions) self.set_source() @@ -547,7 +546,7 @@ elif isinstance(node.node, compiler.ast.Getattr): self.visitAssAttr(node.node) else: - raise TranslationNotImplementedError(self.module.full_name(), node, "AugAssign(Slice or Subscript)") + raise TranslationNotImplementedError("AugAssign(Slice or Subscript)") self.discard_value() @@ -575,7 +574,7 @@ self.dispatch(node.code) self.unit = unit - def visitDecorators(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Decorators") + def visitDecorators(self, node): raise TranslationNotImplementedError("Decorators") def visitFrom(self, node): pass @@ -664,7 +663,7 @@ self.optimiser.reset() - def visitAssert(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Assert") + def visitAssert(self, node): raise TranslationNotImplementedError("Assert") def visitBreak(self, node): next_block, exit_block = self.get_loop_blocks() @@ -819,9 +818,9 @@ def visitPass(self, node): pass - def visitPrint(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Print") + def visitPrint(self, node): raise TranslationNotImplementedError("Print") - def visitPrintnl(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Printnl") + def visitPrintnl(self, node): raise TranslationNotImplementedError("Printnl") def visitRaise(self, node): # NOTE: expr1 only => instance provided @@ -940,7 +939,7 @@ adding instructions which raise active exceptions. """ - raise TranslationNotImplementedError(self.module.full_name(), node, "TryFinally") + raise TranslationNotImplementedError("TryFinally") def visitWhile(self, node): exit_block = self.new_block() @@ -972,8 +971,8 @@ self.drop_loop_blocks() - def visitWith(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "With") + def visitWith(self, node): raise TranslationNotImplementedError("With") - def visitYield(self, node): raise TranslationNotImplementedError(self.module.full_name(), node, "Yield") + def visitYield(self, node): raise TranslationNotImplementedError("Yield") # vim: tabstop=4 expandtab shiftwidth=4 diff -r 475fd98986d9 -r b8c6ae738723 micropython/common.py --- a/micropython/common.py Sat Jun 12 03:04:08 2010 +0200 +++ b/micropython/common.py Sat Jun 12 21:33:36 2010 +0200 @@ -19,11 +19,27 @@ this program. If not, see . """ +import compiler.visitor + try: set except NameError: from sets import Set as set +# Visitors. + +class ASTVisitor(compiler.visitor.ASTVisitor): + + "A base class for visitors." + + def dispatch(self, node, *args): + try: + return compiler.visitor.ASTVisitor.dispatch(self, node, *args) + except NodeProcessingError, exc: + exc.astnode = node + exc.unit_name = self.full_name() + raise + # Errors. class ProcessingError(Exception): @@ -48,13 +64,24 @@ "A processing error associated with a particular program node." - def __init__(self, unit_name, node, message): - self.unit_name = unit_name - self.astnode = node + def __init__(self, message): self.message = message + self.unit_name = None + self.astnode = None + + def get_lineno(self, node): + lineno = node.lineno + if lineno is not None: + return lineno + else: + for child in node.getChildNodes(): + lineno = self.get_lineno(child) + if lineno is not None: + return lineno + return None def __repr__(self): - return "Error in %r at line %r: %s" % (self.unit_name, self.astnode.lineno, self.message) + return "Error in %r at line %r: %s" % (self.unit_name, self.get_lineno(self.astnode), self.message) def __str__(self): return repr(self) diff -r 475fd98986d9 -r b8c6ae738723 micropython/data.py --- a/micropython/data.py Sat Jun 12 03:04:08 2010 +0200 +++ b/micropython/data.py Sat Jun 12 21:33:36 2010 +0200 @@ -124,6 +124,7 @@ def __init__(self, module=None): self.namespace = {} self.globals = set() + self.scope_usage = {} self.module = module self.finalised = 0 @@ -271,6 +272,27 @@ else: return 0 + def note_scope(self, name, scope): + + "Note usage of 'name' from the given 'scope' in the current namespace." + + if not self.scope_usage.has_key(name): + self.scope_usage[name] = scope + return 1 + elif self.scope_usage[name] == scope: + return 1 + else: + return 0 + + def used_in_scope(self, name, scope): + + """ + Return whether 'name' is used from the given 'scope' in the current + namespace. + """ + + return self.scope_usage.get(name) == scope + # Attribute positioning. def attributes_as_list(self): @@ -1244,6 +1266,9 @@ # Namespace-related methods. def make_global(self, name): + + "Declare 'name' as a global in the current namespace." + if name not in self.argnames and not self.has_key(name): self.globals.add(name) return 1 diff -r 475fd98986d9 -r b8c6ae738723 micropython/inspect.py --- a/micropython/inspect.py Sat Jun 12 03:04:08 2010 +0200 +++ b/micropython/inspect.py Sat Jun 12 21:33:36 2010 +0200 @@ -75,7 +75,6 @@ from micropython.common import * from micropython.data import * import compiler.ast -from compiler.visitor import ASTVisitor # Program visitors. @@ -271,8 +270,20 @@ "Record attribute or local 'name', storing 'obj'." + # Store in the module. + if not self.namespaces: - self.set(name, obj, not self.in_loop) + if self.used_in_scope(name, "builtins"): + raise InspectError("Name %r already used as a built-in." % name) + else: + self.set(name, obj, not self.in_loop) + + # Or store locally. + + elif self.namespaces[-1].used_in_scope(name, "global"): + raise InspectError("Name %r already used as global." % name) + elif self.namespaces[-1].used_in_scope(name, "builtins"): + raise InspectError("Name %r already used as a built-in." % name) else: self.namespaces[-1].set(name, obj, not self.in_loop) @@ -390,7 +401,7 @@ # Visitor methods. def default(self, node, *args): - raise InspectError(self.full_name(), node, "Node class %r is not supported." % node.__class__) + raise InspectError("Node class %r is not supported." % node.__class__) def NOP(self, node): for n in node.getChildNodes(): @@ -549,7 +560,7 @@ def visitAssName(self, node): if hasattr(node, "flags") and node.flags == "OP_DELETE": print "Warning: deletion of attribute %r in %r is not supported." % (node.name, self.full_name()) - #raise InspectError(self.full_name(), node, "Deletion of attribute %r is not supported." % node.name) + #raise InspectError("Deletion of attribute %r is not supported." % node.name) self.store(node.name, self.expr) self.define_attribute_user(node) @@ -582,7 +593,7 @@ elif isinstance(node.node, compiler.ast.Getattr): self.visitAssAttr(node.node) else: - raise InspectError(self.full_name(), node, "AugAssign(Slice or Subscript)") + raise InspectError("AugAssign(Slice or Subscript)") return None @@ -621,13 +632,11 @@ expr = self.dispatch(base) if isinstance(expr, Attr): if expr.assignments != 1: - raise InspectError(self.full_name(), node, - "Base class %r for %r is not constant." % (base, cls.full_name())) + raise InspectError("Base class %r for %r is not constant." % (base, cls.full_name())) else: cls.add_base(expr.get_value()) else: # if expr is None: - raise InspectError(self.full_name(), node, - "Base class %r for %r is not found: it may be hidden in some way." % (base, cls.full_name())) + raise InspectError("Base class %r for %r is not found: it may be hidden in some way." % (base, cls.full_name())) # NOTE: Potentially dubious measure to permit __init__ availability. # If no bases exist, adopt the 'object' class. @@ -819,7 +828,7 @@ for name in node.names: ns = self.namespaces[-1] if not ns.make_global(name): - raise InspectError(ns.full_name(), node, "Name %r is global and local in %r" % (name, ns.full_name())) + raise InspectError("Name %r is global and local in %r" % (name, ns.full_name())) # The name is recorded in an earlier process. @@ -899,7 +908,6 @@ if self.importer.predefined_constants.has_key(name): attr = self.importer.get_predefined_constant(name) - node._scope = "constant" # Locals. @@ -909,7 +917,6 @@ # Note usage of the local (potentially a class attribute). self.use_specific_attribute(None, name) - node._scope = "local" # Globals. @@ -919,21 +926,33 @@ # Note usage of the module attribute. self.use_specific_attribute(self.full_name(), name) - node._scope = "global" + + # Note global usage in any local namespace. + + if self.namespaces: + if not self.namespaces[-1].note_scope(name, "global"): + raise InspectError("Name %r cannot be used as global." % name) # Builtins. elif self.builtins is not None and self.builtins.has_key(name): attr = self.builtins[name] self.use_specific_attribute(self.builtins.full_name(), name) - node._scope = "builtins" + + # Note builtins usage in any local namespace. + + if self.namespaces: + if not self.namespaces[-1].note_scope(name, "builtins"): + raise InspectError("Name %r cannot be used as a built-in." % name) + else: + if not self.note_scope(name, "builtins"): + raise InspectError("Name %r cannot be used as a built-in." % name) # Unknown. else: attr = None self.use_name(name) - node._scope = "unknown" return attr diff -r 475fd98986d9 -r b8c6ae738723 micropython/trans.py --- a/micropython/trans.py Sat Jun 12 03:04:08 2010 +0200 +++ b/micropython/trans.py Sat Jun 12 21:33:36 2010 +0200 @@ -59,7 +59,7 @@ "Return the scope for the given 'name'." - if self.unit.has_key(name): + if self.unit is not self.module and self.unit.has_key(name): return "local" elif self.module.has_key(name): return "global" @@ -89,9 +89,9 @@ try: return self.builtins[name] except KeyError: - raise TranslateError(self.module.full_name(), node, "No __builtins__ definition is available for name %r." % name) + raise TranslateError("No __builtins__ definition is available for name %r." % name) else: - raise TranslateError(self.module.full_name(), node, "No __builtins__ module is available for name %r." % name) + raise TranslateError("No __builtins__ module is available for name %r." % name) # Code feature methods. @@ -425,15 +425,14 @@ try: attr = self.objtable.access(target_name, attrname) except TableError, exc: - raise TranslateError(self.module.full_name(), node, exc.args[0]) + raise TranslateError(exc.args[0]) # Produce a suitable instruction. if AddressInstruction is not None: self.replace_active_value(AddressInstruction(attr)) else: - raise TranslateError(self.module.full_name(), node, - "Storing of class or module attribute %r via an object is not permitted." % attrname) + raise TranslateError("Storing of class or module attribute %r via an object is not permitted." % attrname) return @@ -472,8 +471,7 @@ if AddressContextInstruction is not None: self.new_op(AddressContextInstruction(attr)) else: - raise TranslateError(self.module.full_name(), node, - "Storing of class attribute %r via self not permitted." % attrname) + raise TranslateError("Storing of class attribute %r via self not permitted." % attrname) # Preserve the context if the class attribute comes from an # incompatible class. @@ -485,8 +483,7 @@ if AddressInstruction is not None: self.new_op(AddressInstruction(attr)) else: - raise TranslateError(self.module.full_name(), node, - "Storing of class attribute %r via self not permitted." % attrname) + raise TranslateError("Storing of class attribute %r via self not permitted." % attrname) # Otherwise, test for a suitable context at run-time. @@ -497,8 +494,7 @@ if AddressContextCondInstruction is not None: self.new_op(AddressContextCondInstruction(attr)) else: - raise TranslateError(self.module.full_name(), node, - "Storing of class attribute %r via self not permitted." % attrname) + raise TranslateError("Storing of class attribute %r via self not permitted." % attrname) return @@ -540,8 +536,7 @@ elif AttrInstruction is not None and not attr.is_static_attribute(): self.new_op(AttrInstruction(attr)) else: - raise TranslateError(self.module.full_name(), node, - "Storing of class or module attribute %r via an object is not permitted." % attrname) + raise TranslateError("Storing of class or module attribute %r via an object is not permitted." % attrname) return @@ -555,8 +550,7 @@ # If this error arises on generated code, check the names_used # attribute on the Importer. - raise TranslateError(self.module.full_name(), node, - "No attribute entry exists for name %r." % attrname) + raise TranslateError("No attribute entry exists for name %r." % attrname) # NOTE: Test for class vs. instance attributes, generating # NOTE: context-related instructions. @@ -785,8 +779,7 @@ # Test for illegal conditions. if pos in employed_positions: - raise TranslateError(self.module.full_name(), node, - "Keyword argument %r overwrites parameter %r." % (arg.name, pos)) + raise TranslateError("Keyword argument %r overwrites parameter %r." % (arg.name, pos)) employed_positions.add(pos) @@ -857,7 +850,7 @@ for i in range(ncontext, nargs_min): if i not in employed_positions: - raise TranslateError(self.module.full_name(), node, + raise TranslateError( "Argument %r not supplied for %r: need at least %d argument(s)." % (i+1, target.name, nargs_min)) nargs = frame_pos @@ -878,7 +871,7 @@ # allowed. elif nargs > nargs_max: - raise TranslateError(self.module.full_name(), node, + raise TranslateError( "Too many arguments for %r: need at most %d argument(s)." % (target.name, nargs_max)) else: @@ -1165,14 +1158,11 @@ name = node.name - # Transfer scope information if this was set during inspection. + # Get the expected scope of the name. - if hasattr(node, "_scope"): - scope = node._scope - else: - scope = self.get_scope(name) + scope = self.get_scope(name) - #print self.module.name, node.lineno, name, scope + #print self.module.name, node.lineno, name, predicted_scope self._generateName(name, scope, classes, node) def _generateName(self, name, scope, classes, node): @@ -1197,20 +1187,20 @@ elif isinstance(unit, Module): self.new_op(AddressInstruction(unit.module_attributes()[name])) else: - raise TranslateError(self.module.full_name(), node, "Program unit %r has no local %r." % (unit, name)) + raise TranslateError("Program unit has no local %r." % name) elif scope == "global": globals = self.module.module_attributes() if globals.has_key(name): self.new_op(AddressInstruction(globals[name])) else: - raise TranslateError(self.module.full_name(), node, "Module %r has no attribute %r." % (self.module, name)) + raise TranslateError("Module has no attribute %r." % name) elif scope == "builtins": self.new_op(AddressInstruction(self.get_builtin(name, node))) else: - raise TranslateError(self.module.full_name(), node, "Program unit %r uses unknown name %r." % (self.unit, name)) + raise TranslateError("Program unit uses unknown name %r." % name) def _visitUnary(self, node): diff -r 475fd98986d9 -r b8c6ae738723 tests/attributes_class_bind_function.py --- a/tests/attributes_class_bind_function.py Sat Jun 12 03:04:08 2010 +0200 +++ b/tests/attributes_class_bind_function.py Sat Jun 12 21:33:36 2010 +0200 @@ -1,10 +1,10 @@ #!/usr/bin/env python -def e(self, x): +def f(self, x): return x class C: - e = e + e = f c = C() p = c.e # bound C.e diff -r 475fd98986d9 -r b8c6ae738723 tests/attributes_class_bind_function_inherited.py --- a/tests/attributes_class_bind_function_inherited.py Sat Jun 12 03:04:08 2010 +0200 +++ b/tests/attributes_class_bind_function_inherited.py Sat Jun 12 21:33:36 2010 +0200 @@ -1,10 +1,10 @@ #!/usr/bin/env python -def e(self, x): +def f(self, x): return x class C: - e = e + e = f class E(C): # e = C.e (via inheritance) diff -r 475fd98986d9 -r b8c6ae738723 tests/attributes_class_bind_function_inherited_internal.py --- a/tests/attributes_class_bind_function_inherited_internal.py Sat Jun 12 03:04:08 2010 +0200 +++ b/tests/attributes_class_bind_function_inherited_internal.py Sat Jun 12 21:33:36 2010 +0200 @@ -1,10 +1,10 @@ #!/usr/bin/env python -def e(self, x): +def f(self, x): return x class C: - e = e + e = f class E(C): # e = C.e (via inheritance) diff -r 475fd98986d9 -r b8c6ae738723 tests/attributes_class_bind_function_inherited_via_self.py --- a/tests/attributes_class_bind_function_inherited_via_self.py Sat Jun 12 03:04:08 2010 +0200 +++ b/tests/attributes_class_bind_function_inherited_via_self.py Sat Jun 12 21:33:36 2010 +0200 @@ -1,10 +1,10 @@ #!/usr/bin/env python -def e(self, x): +def f(self, x): return x class C: - e = e + e = f class E(C): # e = C.e (via inheritance) diff -r 475fd98986d9 -r b8c6ae738723 tests/attributes_class_bind_function_internal.py --- a/tests/attributes_class_bind_function_internal.py Sat Jun 12 03:04:08 2010 +0200 +++ b/tests/attributes_class_bind_function_internal.py Sat Jun 12 21:33:36 2010 +0200 @@ -1,10 +1,10 @@ #!/usr/bin/env python -def e(self, x): +def f(self, x): return x class C: - e = e + e = f def test(self, x): return self.e(x) diff -r 475fd98986d9 -r b8c6ae738723 tests/attributes_class_bind_function_unbound.py --- a/tests/attributes_class_bind_function_unbound.py Sat Jun 12 03:04:08 2010 +0200 +++ b/tests/attributes_class_bind_function_unbound.py Sat Jun 12 21:33:36 2010 +0200 @@ -1,10 +1,10 @@ #!/usr/bin/env python -def e(self, x): +def f(self, x): return x class C: - e = e + e = f class D: e = C.e diff -r 475fd98986d9 -r b8c6ae738723 tests/attributes_class_bind_function_unbound_fake_self.py --- a/tests/attributes_class_bind_function_unbound_fake_self.py Sat Jun 12 03:04:08 2010 +0200 +++ b/tests/attributes_class_bind_function_unbound_fake_self.py Sat Jun 12 21:33:36 2010 +0200 @@ -1,10 +1,10 @@ #!/usr/bin/env python -def e(self, x): +def f(self, x): return x class C: - e = e + e = f class D: e = C.e diff -r 475fd98986d9 -r b8c6ae738723 tests/attributes_class_bind_function_via_self.py --- a/tests/attributes_class_bind_function_via_self.py Sat Jun 12 03:04:08 2010 +0200 +++ b/tests/attributes_class_bind_function_via_self.py Sat Jun 12 21:33:36 2010 +0200 @@ -1,10 +1,10 @@ #!/usr/bin/env python -def e(self, x): +def g(self, x): return x class C: - e = e + e = g def f(self): return self.e diff -r 475fd98986d9 -r b8c6ae738723 tests/attributes_class_bind_function_via_self_uncertain.py --- a/tests/attributes_class_bind_function_via_self_uncertain.py Sat Jun 12 03:04:08 2010 +0200 +++ b/tests/attributes_class_bind_function_via_self_uncertain.py Sat Jun 12 21:33:36 2010 +0200 @@ -1,10 +1,10 @@ #!/usr/bin/env python -def e(self, x): +def g(self, x): return x class C: - e = e + e = g def f(self): self.m = self.e diff -r 475fd98986d9 -r b8c6ae738723 tests/failure/shadow_class_global.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/failure/shadow_class_global.py Sat Jun 12 21:33:36 2010 +0200 @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +def e(self, x): + return x + +class C: + e = e + +c = C() + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 475fd98986d9 -r b8c6ae738723 tests/failure/shadow_class_global_reassign.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/failure/shadow_class_global_reassign.py Sat Jun 12 21:33:36 2010 +0200 @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +def f(self, x): + return x + +class C: + e = f + + def f(self, x): + return x + +c = C() +c.f(1) + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 475fd98986d9 -r b8c6ae738723 tests/failure/shadow_globals_builtins.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/failure/shadow_globals_builtins.py Sat Jun 12 21:33:36 2010 +0200 @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +c = max(4, 5) + +def max(a, b): + return a + +result_2 = max(2, 3) + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 475fd98986d9 -r b8c6ae738723 tests/failure/shadow_locals_globals.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/failure/shadow_locals_globals.py Sat Jun 12 21:33:36 2010 +0200 @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +a = 1 + +def before(): + b = a + a = 2 + return b + +result1_1 = before() + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 475fd98986d9 -r b8c6ae738723 tests/failure/shadow_locals_globals_reassign.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/failure/shadow_locals_globals_reassign.py Sat Jun 12 21:33:36 2010 +0200 @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +a = 1 + +def before(): + b = a + a = 2 + return b + +def reassign(): + a = a + return a + +result1_1 = before() +result2_1 = reassign() + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 475fd98986d9 -r b8c6ae738723 tests/shadow_globals_builtins.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/shadow_globals_builtins.py Sat Jun 12 21:33:36 2010 +0200 @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +def max(a, b): + return a + +result_2 = max(2, 3) + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 475fd98986d9 -r b8c6ae738723 tests/shadow_locals_globals.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/shadow_locals_globals.py Sat Jun 12 21:33:36 2010 +0200 @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +a = 1 + +def after(): + a = 2 + b = a + return b + +result_2 = after() + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 475fd98986d9 -r b8c6ae738723 tests/xrange.py --- a/tests/xrange.py Sat Jun 12 03:04:08 2010 +0200 +++ b/tests/xrange.py Sat Jun 12 21:33:36 2010 +0200 @@ -4,7 +4,7 @@ result_0 = xr.start result_10 = xr.end result_1 = xr.step -iter = iter(xr) -result1_0 = iter.next() +it = iter(xr) +result1_0 = it.next() # vim: tabstop=4 expandtab shiftwidth=4