Issue #19356: Avoid using a C variabled named "_self", it's a reserved word in some C compilers.

This commit is contained in:
Antoine Pitrou 2013-10-23 19:21:55 +02:00
commit 4d397008cd
5 changed files with 56 additions and 51 deletions

View File

@ -52,6 +52,12 @@ Library
- Issue #17087: Improved the repr for regular expression match objects.
Build
-----
- Issue #19356: Avoid using a C variabled named "_self", it's a reserved
word in some C compilers.
What's New in Python 3.4.0 Alpha 4?
===================================
@ -655,7 +661,6 @@ Tools/Demos
- Issue #18922: Now The Lib/smtpd.py and Tools/i18n/msgfmt.py scripts write
their version strings to stdout, and not to sderr.
What's New in Python 3.4.0 Alpha 1?
===================================

View File

@ -143,18 +143,18 @@ typedef struct {
} DictRemoverObject;
static void
_DictRemover_dealloc(PyObject *_self)
_DictRemover_dealloc(PyObject *myself)
{
DictRemoverObject *self = (DictRemoverObject *)_self;
DictRemoverObject *self = (DictRemoverObject *)myself;
Py_XDECREF(self->key);
Py_XDECREF(self->dict);
Py_TYPE(self)->tp_free(_self);
Py_TYPE(self)->tp_free(myself);
}
static PyObject *
_DictRemover_call(PyObject *_self, PyObject *args, PyObject *kw)
_DictRemover_call(PyObject *myself, PyObject *args, PyObject *kw)
{
DictRemoverObject *self = (DictRemoverObject *)_self;
DictRemoverObject *self = (DictRemoverObject *)myself;
if (self->key && self->dict) {
if (-1 == PyDict_DelItem(self->dict, self->key))
/* XXX Error context */
@ -2451,17 +2451,17 @@ static PyMemberDef PyCData_members[] = {
{ NULL },
};
static int PyCData_NewGetBuffer(PyObject *_self, Py_buffer *view, int flags)
static int PyCData_NewGetBuffer(PyObject *myself, Py_buffer *view, int flags)
{
CDataObject *self = (CDataObject *)_self;
StgDictObject *dict = PyObject_stgdict(_self);
CDataObject *self = (CDataObject *)myself;
StgDictObject *dict = PyObject_stgdict(myself);
Py_ssize_t i;
if (view == NULL) return 0;
view->buf = self->b_ptr;
view->obj = _self;
Py_INCREF(_self);
view->obj = myself;
Py_INCREF(myself);
view->len = self->b_size;
view->readonly = 0;
/* use default format character if not set */
@ -2496,36 +2496,36 @@ PyCData_nohash(PyObject *self)
}
static PyObject *
PyCData_reduce(PyObject *_self, PyObject *args)
PyCData_reduce(PyObject *myself, PyObject *args)
{
CDataObject *self = (CDataObject *)_self;
CDataObject *self = (CDataObject *)myself;
if (PyObject_stgdict(_self)->flags & (TYPEFLAG_ISPOINTER|TYPEFLAG_HASPOINTER)) {
if (PyObject_stgdict(myself)->flags & (TYPEFLAG_ISPOINTER|TYPEFLAG_HASPOINTER)) {
PyErr_SetString(PyExc_ValueError,
"ctypes objects containing pointers cannot be pickled");
return NULL;
}
return Py_BuildValue("O(O(NN))",
_unpickle,
Py_TYPE(_self),
PyObject_GetAttrString(_self, "__dict__"),
Py_TYPE(myself),
PyObject_GetAttrString(myself, "__dict__"),
PyBytes_FromStringAndSize(self->b_ptr, self->b_size));
}
static PyObject *
PyCData_setstate(PyObject *_self, PyObject *args)
PyCData_setstate(PyObject *myself, PyObject *args)
{
void *data;
Py_ssize_t len;
int res;
PyObject *dict, *mydict;
CDataObject *self = (CDataObject *)_self;
CDataObject *self = (CDataObject *)myself;
if (!PyArg_ParseTuple(args, "Os#", &dict, &data, &len))
return NULL;
if (len > self->b_size)
len = self->b_size;
memmove(self->b_ptr, data, len);
mydict = PyObject_GetAttrString(_self, "__dict__");
mydict = PyObject_GetAttrString(myself, "__dict__");
res = PyDict_Update(mydict, dict);
Py_DECREF(mydict);
if (res == -1)
@ -4163,9 +4163,9 @@ Array_init(CDataObject *self, PyObject *args, PyObject *kw)
}
static PyObject *
Array_item(PyObject *_self, Py_ssize_t index)
Array_item(PyObject *myself, Py_ssize_t index)
{
CDataObject *self = (CDataObject *)_self;
CDataObject *self = (CDataObject *)myself;
Py_ssize_t offset, size;
StgDictObject *stgdict;
@ -4189,9 +4189,9 @@ Array_item(PyObject *_self, Py_ssize_t index)
}
static PyObject *
Array_subscript(PyObject *_self, PyObject *item)
Array_subscript(PyObject *myself, PyObject *item)
{
CDataObject *self = (CDataObject *)_self;
CDataObject *self = (CDataObject *)myself;
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
@ -4200,7 +4200,7 @@ Array_subscript(PyObject *_self, PyObject *item)
return NULL;
if (i < 0)
i += self->b_length;
return Array_item(_self, i);
return Array_item(myself, i);
}
else if (PySlice_Check(item)) {
StgDictObject *stgdict, *itemdict;
@ -4277,7 +4277,7 @@ Array_subscript(PyObject *_self, PyObject *item)
for (cur = start, i = 0; i < slicelen;
cur += step, i++) {
PyObject *v = Array_item(_self, cur);
PyObject *v = Array_item(myself, cur);
PyList_SET_ITEM(np, i, v);
}
return np;
@ -4291,9 +4291,9 @@ Array_subscript(PyObject *_self, PyObject *item)
}
static int
Array_ass_item(PyObject *_self, Py_ssize_t index, PyObject *value)
Array_ass_item(PyObject *myself, Py_ssize_t index, PyObject *value)
{
CDataObject *self = (CDataObject *)_self;
CDataObject *self = (CDataObject *)myself;
Py_ssize_t size, offset;
StgDictObject *stgdict;
char *ptr;
@ -4320,9 +4320,9 @@ Array_ass_item(PyObject *_self, Py_ssize_t index, PyObject *value)
}
static int
Array_ass_subscript(PyObject *_self, PyObject *item, PyObject *value)
Array_ass_subscript(PyObject *myself, PyObject *item, PyObject *value)
{
CDataObject *self = (CDataObject *)_self;
CDataObject *self = (CDataObject *)myself;
if (value == NULL) {
PyErr_SetString(PyExc_TypeError,
@ -4337,7 +4337,7 @@ Array_ass_subscript(PyObject *_self, PyObject *item, PyObject *value)
return -1;
if (i < 0)
i += self->b_length;
return Array_ass_item(_self, i, value);
return Array_ass_item(myself, i, value);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelen, otherlen, i, cur;
@ -4362,7 +4362,7 @@ Array_ass_subscript(PyObject *_self, PyObject *item, PyObject *value)
int result;
if (item == NULL)
return -1;
result = Array_ass_item(_self, cur, item);
result = Array_ass_item(myself, cur, item);
Py_DECREF(item);
if (result == -1)
return -1;
@ -4377,9 +4377,9 @@ Array_ass_subscript(PyObject *_self, PyObject *item, PyObject *value)
}
static Py_ssize_t
Array_length(PyObject *_self)
Array_length(PyObject *myself)
{
CDataObject *self = (CDataObject *)_self;
CDataObject *self = (CDataObject *)myself;
return self->b_length;
}
@ -4665,9 +4665,9 @@ static PyTypeObject Simple_Type = {
PyCPointer_Type
*/
static PyObject *
Pointer_item(PyObject *_self, Py_ssize_t index)
Pointer_item(PyObject *myself, Py_ssize_t index)
{
CDataObject *self = (CDataObject *)_self;
CDataObject *self = (CDataObject *)myself;
Py_ssize_t size;
Py_ssize_t offset;
StgDictObject *stgdict, *itemdict;
@ -4696,9 +4696,9 @@ Pointer_item(PyObject *_self, Py_ssize_t index)
}
static int
Pointer_ass_item(PyObject *_self, Py_ssize_t index, PyObject *value)
Pointer_ass_item(PyObject *myself, Py_ssize_t index, PyObject *value)
{
CDataObject *self = (CDataObject *)_self;
CDataObject *self = (CDataObject *)myself;
Py_ssize_t size;
Py_ssize_t offset;
StgDictObject *stgdict, *itemdict;
@ -4828,14 +4828,14 @@ Pointer_new(PyTypeObject *type, PyObject *args, PyObject *kw)
}
static PyObject *
Pointer_subscript(PyObject *_self, PyObject *item)
Pointer_subscript(PyObject *myself, PyObject *item)
{
CDataObject *self = (CDataObject *)_self;
CDataObject *self = (CDataObject *)myself;
if (PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
if (i == -1 && PyErr_Occurred())
return NULL;
return Pointer_item(_self, i);
return Pointer_item(myself, i);
}
else if (PySlice_Check(item)) {
PySliceObject *slice = (PySliceObject *)item;
@ -4948,7 +4948,7 @@ Pointer_subscript(PyObject *_self, PyObject *item)
return NULL;
for (cur = start, i = 0; i < len; cur += step, i++) {
PyObject *v = Pointer_item(_self, cur);
PyObject *v = Pointer_item(myself, cur);
PyList_SET_ITEM(np, i, v);
}
return np;

View File

@ -10,9 +10,9 @@
/**************************************************************/
static void
CThunkObject_dealloc(PyObject *_self)
CThunkObject_dealloc(PyObject *myself)
{
CThunkObject *self = (CThunkObject *)_self;
CThunkObject *self = (CThunkObject *)myself;
PyObject_GC_UnTrack(self);
Py_XDECREF(self->converters);
Py_XDECREF(self->callable);
@ -23,9 +23,9 @@ CThunkObject_dealloc(PyObject *_self)
}
static int
CThunkObject_traverse(PyObject *_self, visitproc visit, void *arg)
CThunkObject_traverse(PyObject *myself, visitproc visit, void *arg)
{
CThunkObject *self = (CThunkObject *)_self;
CThunkObject *self = (CThunkObject *)myself;
Py_VISIT(self->converters);
Py_VISIT(self->callable);
Py_VISIT(self->restype);
@ -33,9 +33,9 @@ CThunkObject_traverse(PyObject *_self, visitproc visit, void *arg)
}
static int
CThunkObject_clear(PyObject *_self)
CThunkObject_clear(PyObject *myself)
{
CThunkObject *self = (CThunkObject *)_self;
CThunkObject *self = (CThunkObject *)myself;
Py_CLEAR(self->converters);
Py_CLEAR(self->callable);
Py_CLEAR(self->restype);

View File

@ -816,9 +816,9 @@ element_deepcopy(ElementObject* self, PyObject* args)
}
static PyObject*
element_sizeof(PyObject* _self, PyObject* args)
element_sizeof(PyObject* myself, PyObject* args)
{
ElementObject *self = (ElementObject*)_self;
ElementObject *self = (ElementObject*)myself;
Py_ssize_t result = sizeof(ElementObject);
if (self->extra) {
result += sizeof(ElementObjectExtra);

View File

@ -293,12 +293,12 @@ check_decoded(PyObject *decoded)
#define SEEN_ALL (SEEN_CR | SEEN_LF | SEEN_CRLF)
PyObject *
_PyIncrementalNewlineDecoder_decode(PyObject *_self,
_PyIncrementalNewlineDecoder_decode(PyObject *myself,
PyObject *input, int final)
{
PyObject *output;
Py_ssize_t output_len;
nldecoder_object *self = (nldecoder_object *) _self;
nldecoder_object *self = (nldecoder_object *) myself;
if (self->decoder == NULL) {
PyErr_SetString(PyExc_ValueError,