# HG changeset patch # User Paul Boddie # Date 1256599408 -3600 # Node ID a1e36f5cc00112c51eb70c90b8c66788f0b903ec # Parent c5669a4003d9738910dfe65f00009255bad8fe69 Added tests for attribute deletion, currently disallowed. Added notes about attribute usage optimisation effects. diff -r c5669a4003d9 -r a1e36f5cc001 docs/optimisations.txt --- a/docs/optimisations.txt Sat Oct 31 23:00:22 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 c5669a4003d9 -r a1e36f5cc001 micropython/ast.py --- a/micropython/ast.py Sat Oct 31 23:00:22 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 c5669a4003d9 -r a1e36f5cc001 micropython/inspect.py --- a/micropython/inspect.py Sat Oct 31 23:00:22 2009 +0100 +++ b/micropython/inspect.py Tue Oct 27 00:23:28 2009 +0100 @@ -467,6 +467,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.reset_attributes(node.name) self.use_name(node.name) diff -r c5669a4003d9 -r a1e36f5cc001 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