[pypy-svn] r66439 - in pypy/branch/parser-compiler/pypy/interpreter/astcompiler: . test
benjamin at codespeak.net
benjamin at codespeak.net
Mon Jul 20 16:38:29 CEST 2009
Author: benjamin
Date: Mon Jul 20 16:38:29 2009
New Revision: 66439
Modified:
pypy/branch/parser-compiler/pypy/interpreter/astcompiler/codegen.py
pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_compiler.py
Log:
implement attribute deletion
Modified: pypy/branch/parser-compiler/pypy/interpreter/astcompiler/codegen.py
==============================================================================
--- pypy/branch/parser-compiler/pypy/interpreter/astcompiler/codegen.py (original)
+++ pypy/branch/parser-compiler/pypy/interpreter/astcompiler/codegen.py Mon Jul 20 16:38:29 2009
@@ -1019,6 +1019,10 @@
self.emit_op_name(ops.STORE_ATTR, names, attr.attr)
elif attr.ctx == ast.Store:
self.emit_op_name(ops.STORE_ATTR, names, attr.attr)
+ elif attr.ctx == ast.Del:
+ self.emit_op_name(ops.DELETE_ATTR, names, attr.attr)
+ else:
+ raise AssertionError("unknown context")
def _simple_slice(self, slc, ctx):
slice_offset = 0
Modified: pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_compiler.py
==============================================================================
--- pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_compiler.py (original)
+++ pypy/branch/parser-compiler/pypy/interpreter/astcompiler/test/test_compiler.py Mon Jul 20 16:38:29 2009
@@ -715,6 +715,18 @@
def test_backquote_repr(self):
yield self.st, "x = None; y = `x`", "y", "None"
+ def test_deleting_attributes(self):
+ test = """class X():
+ x = 3
+del X.x
+try:
+ X.x
+except AttributeError:
+ pass
+else:
+ raise AssertionError("attribute not removed")"""
+ yield self.st, test, "X.__name__", "X"
+
class AppTestPrint:
More information about the Pypy-commit
mailing list