[pypy-commit] pypy mappingproxy: Add failing cpyext test clarifying the expected behaviour of type->tp_dict
rlamy
pypy.commits at gmail.com
Thu Aug 4 13:29:22 EDT 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: mappingproxy
Changeset: r86019:332fe6be115d
Date: 2016-08-04 18:28 +0100
http://bitbucket.org/pypy/pypy/changeset/332fe6be115d/
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
@@ -277,9 +277,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")
More information about the pypy-commit
mailing list