Author: Ronan Lamy <[email protected]>
Branch: py2-mappingproxy
Changeset: r86112:b2d8c440375b
Date: 2016-08-04 18:28 +0100
http://bitbucket.org/pypy/pypy/changeset/b2d8c440375b/
Log: Add failing cpyext test clarifying the expected behaviour of
type->tp_dict
diff --git a/pypy/module/cpyext/test/test_typeobject.py
b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -282,11 +282,23 @@
args->ob_type->tp_dict, "copy");
Py_INCREF(method);
return method;
+ '''),
+ ("get_type_dict", "METH_O",
'''
- )
+ PyObject* value = args->ob_type->tp_dict;
+ if (value == NULL) value = Py_None;
+ Py_INCREF(value);
+ return value;
+ '''),
])
obj = foo.new()
assert module.read_tp_dict(obj) == foo.fooType.copy
+ assert type(module.get_type_dict(obj)) is dict
+ d = module.get_type_dict(1)
+ assert type(d) is dict
+ d["_some_attribute"] = 1
+ assert int._some_attribute == 1
+ del d["_some_attribute"]
def test_custom_allocation(self):
foo = self.import_module("foo")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit