Skip to content

Commit 5358251

Browse files
committed
consistency & warnings patches
1 parent 441a0be commit 5358251

File tree

3 files changed

+32
-33
lines changed

3 files changed

+32
-33
lines changed

Modules/_ctypes/_ctypes.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ _DictRemover_clear(PyObject *myself)
168168
}
169169

170170
static void
171-
_DictRemover_dealloc(PyObject *self)
171+
_DictRemover_dealloc(PyObject *myself)
172172
{
173-
PyTypeObject *tp = Py_TYPE(self);
174-
PyObject_GC_UnTrack(self);
175-
(void)_DictRemover_clear(self);
176-
tp->tp_free(self);
173+
PyTypeObject *tp = Py_TYPE(myself);
174+
PyObject_GC_UnTrack(myself);
175+
(void)_DictRemover_clear(myself);
176+
tp->tp_free(myself);
177177
Py_DECREF(tp);
178178
}
179179

@@ -423,13 +423,13 @@ StructParam_clear(PyObject *myself)
423423
}
424424

425425
static void
426-
StructParam_dealloc(PyObject *self)
426+
StructParam_dealloc(PyObject *myself)
427427
{
428-
PyTypeObject *tp = Py_TYPE(self);
429-
PyObject_GC_UnTrack(self);
430-
(void)StructParam_clear(self);
431-
PyMem_Free(_StructParamObject_CAST(self)->ptr);
432-
tp->tp_free(self);
428+
PyTypeObject *tp = Py_TYPE(myself);
429+
PyObject_GC_UnTrack(myself);
430+
(void)StructParam_clear(myself);
431+
PyMem_Free(_StructParamObject_CAST(myself)->ptr);
432+
tp->tp_free(myself);
433433
Py_DECREF(tp);
434434
}
435435

@@ -4411,7 +4411,7 @@ _build_result(PyObject *result, PyObject *callargs,
44114411
}
44124412

44134413
static PyObject *
4414-
PyCFuncPtr_call(PyObject *myself, PyObject *inargs, PyObject *kwds)
4414+
PyCFuncPtr_call(PyObject *op, PyObject *inargs, PyObject *kwds)
44154415
{
44164416
PyObject *restype;
44174417
PyObject *converters;
@@ -4424,15 +4424,15 @@ PyCFuncPtr_call(PyObject *myself, PyObject *inargs, PyObject *kwds)
44244424
IUnknown *piunk = NULL;
44254425
#endif
44264426
void *pProc = NULL;
4427-
PyCFuncPtrObject *self = _PyCFuncPtrObject_CAST(myself);
4427+
PyCFuncPtrObject *self = _PyCFuncPtrObject_CAST(op);
44284428

44294429
int inoutmask;
44304430
int outmask;
44314431
unsigned int numretvals;
44324432

44334433
ctypes_state *st = get_module_state_by_def(Py_TYPE(Py_TYPE(self)));
44344434
StgInfo *info;
4435-
if (PyStgInfo_FromObject(st, myself, &info) < 0) {
4435+
if (PyStgInfo_FromObject(st, op, &info) < 0) {
44364436
return NULL;
44374437
}
44384438
assert(info); /* Cannot be NULL for PyCFuncPtrObject instances */
@@ -4819,8 +4819,8 @@ Array_init(PyObject *self, PyObject *args, PyObject *kw)
48194819
static PyObject *
48204820
Array_item(PyObject *myself, Py_ssize_t index)
48214821
{
4822-
Py_ssize_t offset, size;
48234822
CDataObject *self = _CDataObject_CAST(myself);
4823+
Py_ssize_t offset, size;
48244824

48254825
if (index < 0 || index >= self->b_length) {
48264826
PyErr_SetString(PyExc_IndexError,
@@ -5179,10 +5179,10 @@ class _ctypes.Simple "PyObject *" "clinic_state()->Simple_Type"
51795179
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=016c476c7aa8b8a8]*/
51805180

51815181
static int
5182-
Simple_set_value(PyObject *myself, PyObject *value, void *Py_UNUSED(ignored))
5182+
Simple_set_value(PyObject *op, PyObject *value, void *Py_UNUSED(ignored))
51835183
{
51845184
PyObject *result;
5185-
CDataObject *self = _CDataObject_CAST(myself);
5185+
CDataObject *self = _CDataObject_CAST(op);
51865186

51875187
if (value == NULL) {
51885188
PyErr_SetString(PyExc_TypeError,
@@ -5192,7 +5192,7 @@ Simple_set_value(PyObject *myself, PyObject *value, void *Py_UNUSED(ignored))
51925192

51935193
ctypes_state *st = get_module_state_by_def(Py_TYPE(Py_TYPE(self)));
51945194
StgInfo *info;
5195-
if (PyStgInfo_FromObject(st, myself, &info) < 0) {
5195+
if (PyStgInfo_FromObject(st, op, &info) < 0) {
51965196
return -1;
51975197
}
51985198
assert(info); /* Cannot be NULL for CDataObject instances */
@@ -5220,12 +5220,12 @@ Simple_init(PyObject *self, PyObject *args, PyObject *kw)
52205220
}
52215221

52225222
static PyObject *
5223-
Simple_get_value(PyObject *myself, void *Py_UNUSED(ignored))
5223+
Simple_get_value(PyObject *op, void *Py_UNUSED(ignored))
52245224
{
5225-
CDataObject *self = _CDataObject_CAST(myself);
5225+
CDataObject *self = _CDataObject_CAST(op);
52265226
ctypes_state *st = get_module_state_by_def(Py_TYPE(Py_TYPE(self)));
52275227
StgInfo *info;
5228-
if (PyStgInfo_FromObject(st, myself, &info) < 0) {
5228+
if (PyStgInfo_FromObject(st, op, &info) < 0) {
52295229
return NULL;
52305230
}
52315231
assert(info); /* Cannot be NULL for CDataObject instances */
@@ -5268,10 +5268,11 @@ static PyMethodDef Simple_methods[] = {
52685268
{ NULL, NULL },
52695269
};
52705270

5271-
static int Simple_bool(PyObject *myself)
5271+
static int
5272+
Simple_bool(PyObject *op)
52725273
{
52735274
int cmp;
5274-
CDataObject *self = _CDataObject_CAST(myself);
5275+
CDataObject *self = _CDataObject_CAST(op);
52755276
LOCK_PTR(self);
52765277
cmp = memcmp(self->b_ptr, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", self->b_size);
52775278
UNLOCK_PTR(self);
@@ -5429,11 +5430,11 @@ Pointer_get_contents(PyObject *self, void *closure)
54295430
}
54305431

54315432
static int
5432-
Pointer_set_contents(PyObject *myself, PyObject *value, void *closure)
5433+
Pointer_set_contents(PyObject *op, PyObject *value, void *closure)
54335434
{
54345435
CDataObject *dst;
54355436
PyObject *keep;
5436-
CDataObject *self = _CDataObject_CAST(myself);
5437+
CDataObject *self = _CDataObject_CAST(op);
54375438

54385439
if (value == NULL) {
54395440
PyErr_SetString(PyExc_TypeError,
@@ -5442,7 +5443,7 @@ Pointer_set_contents(PyObject *myself, PyObject *value, void *closure)
54425443
}
54435444
ctypes_state *st = get_module_state_by_def(Py_TYPE(Py_TYPE(self)));
54445445
StgInfo *stginfo;
5445-
if (PyStgInfo_FromObject(st, myself, &stginfo) < 0) {
5446+
if (PyStgInfo_FromObject(st, op, &stginfo) < 0) {
54465447
return -1;
54475448
}
54485449
assert(stginfo); /* Cannot be NULL for pointer instances */
@@ -5664,14 +5665,13 @@ Pointer_subscript(PyObject *myself, PyObject *item)
56645665
}
56655666

56665667
static int
5667-
Pointer_bool(PyObject *myself)
5668+
Pointer_bool(PyObject *self)
56685669
{
5669-
CDataObject *self = _CDataObject_CAST(myself);
5670-
return locked_deref(self) != NULL;
5670+
return locked_deref(_CDataObject_CAST(self)) != NULL;
56715671
}
56725672

56735673
static PyType_Slot pycpointer_slots[] = {
5674-
{Py_tp_doc, PyDoc_STR("XXX to be provided")},
5674+
{Py_tp_doc, (void *)PyDoc_STR("XXX to be provided")},
56755675
{Py_tp_getset, Pointer_getsets},
56765676
{Py_tp_init, Pointer_init},
56775677
{Py_tp_new, Pointer_new},

Modules/_ctypes/callbacks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ CThunkObject_dealloc(PyObject *myself)
6363
}
6464

6565
static PyType_Slot cthunk_slots[] = {
66-
{Py_tp_doc, PyDoc_STR("CThunkObject")},
66+
{Py_tp_doc, (void *)PyDoc_STR("CThunkObject")},
6767
{Py_tp_dealloc, CThunkObject_dealloc},
6868
{Py_tp_traverse, CThunkObject_traverse},
6969
{Py_tp_clear, CThunkObject_clear},

Modules/_ctypes/cfield.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ static void pymem_destructor(PyObject *ptr)
4141
/*
4242
PyCField_Type
4343
*/
44-
4544
/*[clinic input]
4645
class _ctypes.CField "PyObject *" "PyObject"
4746
[clinic start generated code]*/
@@ -308,7 +307,7 @@ static PyType_Slot cfield_slots[] = {
308307
{Py_tp_new, PyCField_new},
309308
{Py_tp_dealloc, PyCField_dealloc},
310309
{Py_tp_repr, PyCField_repr},
311-
{Py_tp_doc, PyDoc_STR("Structure/Union member")},
310+
{Py_tp_doc, (void *)PyDoc_STR("Structure/Union member")},
312311
{Py_tp_traverse, PyCField_traverse},
313312
{Py_tp_clear, PyCField_clear},
314313
{Py_tp_getset, PyCField_getset},

0 commit comments

Comments
 (0)