x.char = b'a\0b\0'
self.assertEqual(bytes(x), b'a\x00###')
+ def test_6(self):
+ class X(Structure):
+ _fields_ = [("x", c_int)]
+ CField = type(X.x)
+ self.assertRaises(TypeError, CField)
+
def test_gh99275(self):
class BrokenStructure(Structure):
def __init_subclass__(cls, **kwargs):
/*
PyCField_Type
*/
-static PyObject *
-PyCField_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- CFieldObject *obj;
- obj = (CFieldObject *)type->tp_alloc(type, 0);
- return (PyObject *)obj;
-}
/*
* Expects the size, index and offset for the current field in *psize and
#define CONT_BITFIELD 2
#define EXPAND_BITFIELD 3
- self = (CFieldObject *)_PyObject_CallNoArgs((PyObject *)&PyCField_Type);
+ self = (CFieldObject *)PyCField_Type.tp_alloc((PyTypeObject *)&PyCField_Type, 0);
if (self == NULL)
return NULL;
dict = PyType_stgdict(desc);
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- PyCField_new, /* tp_new */
+ 0, /* tp_new */
0, /* tp_free */
};