summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-10-23 17:20:21 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-10-23 17:20:21 (GMT)
commit09fcb72048be60435ae70ec2c3e23e2325edb421 (patch)
treeee7c279b7b77ff5d58f831b37fb517f28d65398a
parentd5d0bc35adc6c043d5985152451505e70d869341 (diff)
downloadcpython-09fcb72048be60435ae70ec2c3e23e2325edb421.zip
cpython-09fcb72048be60435ae70ec2c3e23e2325edb421.tar.gz
cpython-09fcb72048be60435ae70ec2c3e23e2325edb421.tar.bz2
Issue #19356: Avoid using a C variabled named "_self", it's a reserved word in some C compilers.
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/_ctypes/_ctypes.c80
-rw-r--r--Modules/_ctypes/callbacks.c12
-rw-r--r--Modules/_elementtree.c4
-rw-r--r--Modules/_io/textio.c4
5 files changed, 53 insertions, 50 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 0787328..d644718 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -568,6 +568,9 @@ Tools/Demos
Build
-----
+- Issue #19356: Avoid using a C variabled named "_self", it's a reserved
+ word in some C compilers.
+
- Issue #19130: Correct PCbuild/readme.txt, Python 3.3 and 3.4 require VS 2010.
- Issue #16067: Add description into MSI file to replace installer's temporary name.
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 9a37aac..7d0d258 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -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 */
@@ -2471,17 +2471,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 */
@@ -2516,36 +2516,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)
@@ -4183,9 +4183,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;
@@ -4209,9 +4209,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);
@@ -4220,7 +4220,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;
@@ -4297,7 +4297,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;
@@ -4311,9 +4311,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;
@@ -4340,9 +4340,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,
@@ -4357,7 +4357,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;
@@ -4382,7 +4382,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;
@@ -4397,9 +4397,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;
}
@@ -4685,9 +4685,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;
@@ -4716,9 +4716,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;
@@ -4848,14 +4848,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;
@@ -4968,7 +4968,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;
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 34c46ad..a3d2321 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -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);
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 57503d5..9bdc4c7 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -809,9 +809,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);
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 111cc7e..603ee60 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -282,12 +282,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,