[pypy-svn] r51312 - in pypy/dist/pypy/translator/cli: . test
antocuni at codespeak.net
antocuni at codespeak.net
Wed Feb 6 16:25:57 CET 2008
Author: antocuni
Date: Wed Feb 6 16:25:55 2008
New Revision: 51312
Modified:
pypy/dist/pypy/translator/cli/class_.py
pypy/dist/pypy/translator/cli/test/test_dotnet.py
Log:
we can't use null as default value for valuetypes
Modified: pypy/dist/pypy/translator/cli/class_.py
==============================================================================
--- pypy/dist/pypy/translator/cli/class_.py (original)
+++ pypy/dist/pypy/translator/cli/class_.py Wed Feb 6 16:25:55 2008
@@ -131,6 +131,8 @@
default_values = self.INSTANCE._fields.copy()
default_values.update(self.INSTANCE._overridden_defaults)
for f_name, (F_TYPE, f_default) in default_values.iteritems():
+ if getattr(F_TYPE, '_is_value_type', False):
+ continue # we can't set it to null
INSTANCE_DEF, _ = self.INSTANCE._lookup_field(f_name)
cts_type = self.cts.lltype_to_cts(F_TYPE)
f_name = self.cts.escape_name(f_name)
Modified: pypy/dist/pypy/translator/cli/test/test_dotnet.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/test_dotnet.py (original)
+++ pypy/dist/pypy/translator/cli/test/test_dotnet.py Wed Feb 6 16:25:55 2008
@@ -496,6 +496,16 @@
res = self.interpret(fn, [])
assert res == 42
+ def test_valuetype_field(self):
+ class Foo:
+ def __init__(self, x):
+ self.x = x
+
+ def fn():
+ f = Foo(OpCodes.Add)
+ return f
+ self.interpret(fn, [])
+
class TestPythonnet(TestDotnetRtyping):
# don't interpreter functions but execute them directly through pythonnet
More information about the Pypy-commit
mailing list