Commit 2bae36f6 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Tests for tp_dictoffset

parent 338af286
#include <Python.h>
#include <stddef.h> /* For offsetof */
typedef struct {
PyObject_HEAD
PyObject_HEAD;
PyObject* dict;
int n;
} slots_tester_object;
......@@ -252,7 +255,7 @@ static PyTypeObject slots_tester_map= {
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
offsetof(slots_tester_object, dict), /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
slots_tester_new, /* tp_new */
......
......@@ -88,3 +88,27 @@ try:
pass
except TypeError, e:
print e
try:
slots_test.SlotsTesterSeq(5).foo = 1
except AttributeError, e:
print e
try:
print slots_test.SlotsTesterSeq(5).__dict__
except AttributeError, e:
print e
c = C3(5)
c.foo = 1
print c.foo
print c.__dict__
s = slots_test.SlotsTesterMap(6)
s.bar = 2
print s.bar
print hasattr(s, "bar"), hasattr(s, "foo")
try:
print s.__dict__
except AttributeError, e:
print e
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment