[pypy-svn] r36604 - in pypy/dist/pypy/translator/backendopt: . test
antocuni at codespeak.net
antocuni at codespeak.net
Fri Jan 12 18:38:38 CET 2007
Author: antocuni
Date: Fri Jan 12 18:38:29 2007
New Revision: 36604
Modified:
pypy/dist/pypy/translator/backendopt/malloc.py
pypy/dist/pypy/translator/backendopt/test/test_malloc.py
Log:
bugfix, and the corresponding test.
Modified: pypy/dist/pypy/translator/backendopt/malloc.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/malloc.py (original)
+++ pypy/dist/pypy/translator/backendopt/malloc.py Fri Jan 12 18:38:29 2007
@@ -550,8 +550,7 @@
def flatten(self, TYPE):
for name, (FIELDTYPE, default) in self._get_fields(TYPE).iteritems():
key = self.key_for_field_access(TYPE, name)
- example = FIELDTYPE._defl()
- constant = Constant(example)
+ constant = Constant(default)
constant.concretetype = FIELDTYPE
self.flatconstants[key] = constant
self.flatnames.append(key)
Modified: pypy/dist/pypy/translator/backendopt/test/test_malloc.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_malloc.py (original)
+++ pypy/dist/pypy/translator/backendopt/test/test_malloc.py Fri Jan 12 18:38:29 2007
@@ -341,3 +341,14 @@
s = ootype.new(FOO)
return bool(s)
self.check(fn, [], [], True)
+
+ def test_classattr_as_defaults(self):
+ class Bar:
+ foo = 41
+
+ def fn():
+ x = Bar()
+ x.foo += 1
+ return x.foo
+ self.check(fn, [], [], 42)
+
More information about the Pypy-commit
mailing list