# HG changeset patch # User Paul Boddie # Date 1256599408 -3600 # Node ID 837ba944f563fe45776d0b52458cb9584a0168e9 # Parent ed407c965ea509dd8f12d01cb38623b3f9d482be Added tests for attribute deletion, currently disallowed. Added notes about attribute usage optimisation effects. diff -r ed407c965ea5 -r 837ba944f563 docs/optimisations.txt --- a/docs/optimisations.txt Mon Oct 26 01:03:38 2009 +0100 +++ b/docs/optimisations.txt Tue Oct 27 00:23:28 2009 +0100 @@ -224,7 +224,16 @@ the earliest opportunity and then specialise the attribute accesses, perhaps also invocations, in the generated code. AttributeError occurrences would need to be considered, however, potentially disqualifying certain attributes from -any optimisations, and control flow would also need to be considered. +any optimisations, and control flow would also need to be considered. The +result would resemble the following: + + def f(x, y): + if not isinstance(x, C): + raise TypeError + x.method(y) + if x.something: + ... + return x.attr Implemented Optimisation Types ============================== diff -r ed407c965ea5 -r 837ba944f563 micropython/ast.py --- a/micropython/ast.py Mon Oct 26 01:03:38 2009 +0100 +++ b/micropython/ast.py Tue Oct 27 00:23:28 2009 +0100 @@ -501,6 +501,9 @@ "Assign the assignment expression to the recipient 'node'." + if node.flags == "OP_DELETE": + raise TranslationNotImplementedError(self.module.full_name(), node, "AssName(OP_DELETE)") + self._visitName(node, self.name_store_instructions) self.set_source() diff -r ed407c965ea5 -r 837ba944f563 micropython/inspect.py --- a/micropython/inspect.py Mon Oct 26 01:03:38 2009 +0100 +++ b/micropython/inspect.py Tue Oct 27 00:23:28 2009 +0100 @@ -455,6 +455,9 @@ return None def visitAssName(self, node): + if node.flags == "OP_DELETE": + raise InspectError(self.full_name(), node, "Deletion of attribute %r is not supported." % node.name) + self.store(node.name, self.expr) self.use_name(node.name) return None diff -r ed407c965ea5 -r 837ba944f563 tests/failure/delete_name.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/failure/delete_name.py Tue Oct 27 00:23:28 2009 +0100 @@ -0,0 +1,6 @@ +#!/usr/bin/env python + +a = 123 +del a + +# vim: tabstop=4 expandtab shiftwidth=4