Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
resolve conflict
  • Loading branch information
shihai1991 committed Dec 18, 2022
commit b1709fdf190bc53f177235eec68b32f026e92e60
12 changes: 6 additions & 6 deletions Lib/test/test_ctypes/test_struct_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ class Y(X):

def test_5(self):
class X(Structure):
<<<<<<< HEAD:Lib/ctypes/test/test_struct_fields.py
_fields_ = [("x", c_int)]
CField = type(X.x)
self.assertRaises(TypeError, CField)
=======
_fields_ = (("char", c_char * 5),)

x = X(b'#' * 5)
x.char = b'a\0b\0'
self.assertEqual(bytes(x), b'a\x00###')
>>>>>>> origin/main:Lib/test/test_ctypes/test_struct_fields.py

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):
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the ``PyCField_new`` which user cannot call it directly.
Comment thread
shihai1991 marked this conversation as resolved.
Outdated
4 changes: 0 additions & 4 deletions Modules/_ctypes/cfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ PyCField_FromDesc(PyObject *desc, Py_ssize_t index,
#define CONT_BITFIELD 2
#define EXPAND_BITFIELD 3

<<<<<<< HEAD
self = (CFieldObject *)PyCField_Type.tp_alloc((PyTypeObject *)&PyCField_Type, 0);
=======
self = (CFieldObject *)_PyObject_CallNoArgs((PyObject *)&PyCField_Type);
>>>>>>> origin/main
if (self == NULL)
return NULL;
dict = PyType_stgdict(desc);
Expand Down
4 changes: 0 additions & 4 deletions Modules/_ctypes/stgdict.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,7 @@ MakeFields(PyObject *type, CFieldObject *descr,
}
continue;
}
<<<<<<< HEAD
new_descr = (CFieldObject *)PyCField_Type.tp_alloc((PyTypeObject *)&PyCField_Type, 0);
=======
new_descr = (CFieldObject *)_PyObject_CallNoArgs((PyObject *)&PyCField_Type);
>>>>>>> origin/main
if (new_descr == NULL) {
Py_DECREF(fdescr);
Py_DECREF(fieldlist);
Expand Down