summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_bisectmodule.c8
-rw-r--r--Modules/_collectionsmodule.c4
-rw-r--r--Modules/_ctypes/_ctypes.c4
-rw-r--r--Modules/_ctypes/callproc.c6
-rw-r--r--Modules/_cursesmodule.c7
-rw-r--r--Modules/_datetimemodule.c77
-rw-r--r--Modules/_elementtree.c33
-rw-r--r--Modules/_io/_iomodule.c7
-rw-r--r--Modules/_io/bufferedio.c47
-rw-r--r--Modules/_io/fileio.c5
-rw-r--r--Modules/_io/iobase.c27
-rw-r--r--Modules/_io/textio.c103
-rw-r--r--Modules/_pickle.c14
-rw-r--r--Modules/_posixsubprocess.c11
-rw-r--r--Modules/_sqlite/connection.c15
-rw-r--r--Modules/_sqlite/cursor.c3
-rw-r--r--Modules/_sqlite/microprotocols.c8
-rw-r--r--Modules/_sqlite/module.c3
-rw-r--r--Modules/arraymodule.c7
-rw-r--r--Modules/cjkcodecs/multibytecodec.c7
-rw-r--r--Modules/faulthandler.c9
-rw-r--r--Modules/gcmodule.c4
-rw-r--r--Modules/itertoolsmodule.c4
-rw-r--r--Modules/mmapmodule.c4
-rw-r--r--Modules/ossaudiodev.c4
-rw-r--r--Modules/socketmodule.c4
-rw-r--r--Modules/timemodule.c5
27 files changed, 282 insertions, 148 deletions
diff --git a/Modules/_bisectmodule.c b/Modules/_bisectmodule.c
index 7fecfc6..9da255e 100644
--- a/Modules/_bisectmodule.c
+++ b/Modules/_bisectmodule.c
@@ -86,7 +86,9 @@ insort_right(PyObject *self, PyObject *args, PyObject *kw)
if (PyList_Insert(list, index, item) < 0)
return NULL;
} else {
- result = PyObject_CallMethod(list, "insert", "nO", index, item);
+ _Py_identifier(insert);
+
+ result = _PyObject_CallMethodId(list, &PyId_insert, "nO", index, item);
if (result == NULL)
return NULL;
Py_DECREF(result);
@@ -186,7 +188,9 @@ insort_left(PyObject *self, PyObject *args, PyObject *kw)
if (PyList_Insert(list, index, item) < 0)
return NULL;
} else {
- result = PyObject_CallMethod(list, "insert", "iO", index, item);
+ _Py_identifier(insert);
+
+ result = _PyObject_CallMethodId(list, &PyId_insert, "iO", index, item);
if (result == NULL)
return NULL;
Py_DECREF(result);
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 156ad18..40e253d 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -1334,13 +1334,15 @@ defdict_reduce(defdictobject *dd)
PyObject *items;
PyObject *iter;
PyObject *result;
+ _Py_identifier(items);
+
if (dd->default_factory == NULL || dd->default_factory == Py_None)
args = PyTuple_New(0);
else
args = PyTuple_Pack(1, dd->default_factory);
if (args == NULL)
return NULL;
- items = PyObject_CallMethod((PyObject *)dd, "items", "()");
+ items = _PyObject_CallMethodId((PyObject *)dd, &PyId_items, "()");
if (items == NULL) {
Py_DECREF(args);
return NULL;
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index e2905bc..1d7cf94 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -3679,8 +3679,10 @@ _build_result(PyObject *result, PyObject *callargs,
PyTuple_SET_ITEM(tup, index, v);
index++;
} else if (bit & outmask) {
+ _Py_identifier(__ctypes_from_outparam__);
+
v = PyTuple_GET_ITEM(callargs, i);
- v = PyObject_CallMethod(v, "__ctypes_from_outparam__", NULL);
+ v = _PyObject_CallMethodId(v, &PyId___ctypes_from_outparam__, NULL);
if (v == NULL || numretvals == 1) {
Py_DECREF(callargs);
return v;
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 60d59c8..adc2870 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -1687,13 +1687,15 @@ unpickle(PyObject *self, PyObject *args)
PyObject *state;
PyObject *result;
PyObject *tmp;
+ _Py_identifier(__new__);
+ _Py_identifier(__setstate__);
if (!PyArg_ParseTuple(args, "OO", &typ, &state))
return NULL;
- result = PyObject_CallMethod(typ, "__new__", "O", typ);
+ result = _PyObject_CallMethodId(typ, &PyId___new__, "O", typ);
if (result == NULL)
return NULL;
- tmp = PyObject_CallMethod(result, "__setstate__", "O", state);
+ tmp = _PyObject_CallMethodId(result, &PyId___setstate__, "O", state);
if (tmp == NULL) {
Py_DECREF(result);
return NULL;
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 191d53f..ead38d3 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -1418,10 +1418,12 @@ PyCursesWindow_PutWin(PyCursesWindowObject *self, PyObject *stream)
while (1) {
char buf[BUFSIZ];
Py_ssize_t n = fread(buf, 1, BUFSIZ, fp);
+ _Py_identifier(write);
+
if (n <= 0)
break;
Py_DECREF(res);
- res = PyObject_CallMethod(stream, "write", "y#", buf, n);
+ res = _PyObject_CallMethodId(stream, &PyId_write, "y#", buf, n);
if (res == NULL)
break;
}
@@ -1911,6 +1913,7 @@ PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
WINDOW *win;
PyCursesInitialised;
+ _Py_identifier(read);
strcpy(fn, "/tmp/py.curses.getwin.XXXXXX");
fd = mkstemp(fn);
@@ -1922,7 +1925,7 @@ PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
remove(fn);
return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
}
- data = PyObject_CallMethod(stream, "read", "");
+ data = _PyObject_CallMethodId(stream, &PyId_read, "");
if (data == NULL) {
fclose(fp);
remove(fn);
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index a7156a4..eb6998f 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -946,6 +946,7 @@ static PyObject *
call_tzname(PyObject *tzinfo, PyObject *tzinfoarg)
{
PyObject *result;
+ _Py_identifier(tzname);
assert(tzinfo != NULL);
assert(check_tzinfo_subclass(tzinfo) >= 0);
@@ -954,7 +955,7 @@ call_tzname(PyObject *tzinfo, PyObject *tzinfoarg)
if (tzinfo == Py_None)
Py_RETURN_NONE;
- result = PyObject_CallMethod(tzinfo, "tzname", "O", tzinfoarg);
+ result = _PyObject_CallMethodId(tzinfo, &PyId_tzname, "O", tzinfoarg);
if (result == NULL || result == Py_None)
return result;
@@ -1078,6 +1079,8 @@ make_Zreplacement(PyObject *object, PyObject *tzinfoarg)
PyObject *temp;
PyObject *tzinfo = get_tzinfo_member(object);
PyObject *Zreplacement = PyUnicode_FromStringAndSize(NULL, 0);
+ _Py_identifier(replace);
+
if (Zreplacement == NULL)
return NULL;
if (tzinfo == Py_None || tzinfo == NULL)
@@ -1098,7 +1101,7 @@ make_Zreplacement(PyObject *object, PyObject *tzinfoarg)
* strftime doesn't treat them as format codes.
*/
Py_DECREF(Zreplacement);
- Zreplacement = PyObject_CallMethod(temp, "replace", "ss", "%", "%%");
+ Zreplacement = _PyObject_CallMethodId(temp, &PyId_replace, "ss", "%", "%%");
Py_DECREF(temp);
if (Zreplacement == NULL)
return NULL;
@@ -1281,12 +1284,15 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
{
PyObject *format;
PyObject *time = PyImport_ImportModuleNoBlock("time");
+
if (time == NULL)
goto Done;
format = PyUnicode_FromString(PyBytes_AS_STRING(newfmt));
if (format != NULL) {
- result = PyObject_CallMethod(time, "strftime", "OO",
- format, timetuple, NULL);
+ _Py_identifier(strftime);
+
+ result = _PyObject_CallMethodId(time, &PyId_strftime, "OO",
+ format, timetuple, NULL);
Py_DECREF(format);
}
Py_DECREF(time);
@@ -1312,7 +1318,9 @@ time_time(void)
PyObject *time = PyImport_ImportModuleNoBlock("time");
if (time != NULL) {
- result = PyObject_CallMethod(time, "time", "()");
+ _Py_identifier(time);
+
+ result = _PyObject_CallMethodId(time, &PyId_time, "()");
Py_DECREF(time);
}
return result;
@@ -1329,13 +1337,15 @@ build_struct_time(int y, int m, int d, int hh, int mm, int ss, int dstflag)
time = PyImport_ImportModuleNoBlock("time");
if (time != NULL) {
- result = PyObject_CallMethod(time, "struct_time",
- "((iiiiiiiii))",
- y, m, d,
- hh, mm, ss,
- weekday(y, m, d),
- days_before_month(y, m) + d,
- dstflag);
+ _Py_identifier(struct_time);
+
+ result = _PyObject_CallMethodId(time, &PyId_struct_time,
+ "((iiiiiiiii))",
+ y, m, d,
+ hh, mm, ss,
+ weekday(y, m, d),
+ days_before_month(y, m) + d,
+ dstflag);
Py_DECREF(time);
}
return result;
@@ -1568,11 +1578,12 @@ multiply_float_timedelta(PyObject *floatobj, PyDateTime_Delta *delta)
PyObject *result = NULL;
PyObject *pyus_in = NULL, *temp, *pyus_out;
PyObject *ratio = NULL;
+ _Py_identifier(as_integer_ratio);
pyus_in = delta_to_microseconds(delta);
if (pyus_in == NULL)
return NULL;
- ratio = PyObject_CallMethod(floatobj, "as_integer_ratio", NULL);
+ ratio = _PyObject_CallMethodId(floatobj, &PyId_as_integer_ratio, NULL);
if (ratio == NULL)
goto error;
temp = PyNumber_Multiply(pyus_in, PyTuple_GET_ITEM(ratio, 0));
@@ -1666,11 +1677,12 @@ truedivide_timedelta_float(PyDateTime_Delta *delta, PyObject *f)
PyObject *result = NULL;
PyObject *pyus_in = NULL, *temp, *pyus_out;
PyObject *ratio = NULL;
+ _Py_identifier(as_integer_ratio);
pyus_in = delta_to_microseconds(delta);
if (pyus_in == NULL)
return NULL;
- ratio = PyObject_CallMethod(f, "as_integer_ratio", NULL);
+ ratio = _PyObject_CallMethodId(f, &PyId_as_integer_ratio, NULL);
if (ratio == NULL)
goto error;
temp = PyNumber_Multiply(pyus_in, PyTuple_GET_ITEM(ratio, 1));
@@ -2461,6 +2473,7 @@ date_today(PyObject *cls, PyObject *dummy)
{
PyObject *time;
PyObject *result;
+ _Py_identifier(fromtimestamp);
time = time_time();
if (time == NULL)
@@ -2472,7 +2485,7 @@ date_today(PyObject *cls, PyObject *dummy)
* time.time() delivers; if someone were gonzo about optimization,
* date.today() could get away with plain C time().
*/
- result = PyObject_CallMethod(cls, "fromtimestamp", "O", time);
+ result = _PyObject_CallMethodId(cls, &PyId_fromtimestamp, "O", time);
Py_DECREF(time);
return result;
}
@@ -2613,7 +2626,9 @@ date_isoformat(PyDateTime_Date *self)
static PyObject *
date_str(PyDateTime_Date *self)
{
- return PyObject_CallMethod((PyObject *)self, "isoformat", "()");
+ _Py_identifier(isoformat);
+
+ return _PyObject_CallMethodId((PyObject *)self, &PyId_isoformat, "()");
}
@@ -2632,13 +2647,14 @@ date_strftime(PyDateTime_Date *self, PyObject *args, PyObject *kw)
PyObject *result;
PyObject *tuple;
PyObject *format;
+ _Py_identifier(timetuple);
static char *keywords[] = {"format", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kw, "U:strftime", keywords,
&format))
return NULL;
- tuple = PyObject_CallMethod((PyObject *)self, "timetuple", "()");
+ tuple = _PyObject_CallMethodId((PyObject *)self, &PyId_timetuple, "()");
if (tuple == NULL)
return NULL;
result = wrap_strftime((PyObject *)self, format, tuple,
@@ -2651,6 +2667,7 @@ static PyObject *
date_format(PyDateTime_Date *self, PyObject *args)
{
PyObject *format;
+ _Py_identifier(strftime);
if (!PyArg_ParseTuple(args, "U:__format__", &format))
return NULL;
@@ -2659,7 +2676,7 @@ date_format(PyDateTime_Date *self, PyObject *args)
if (PyUnicode_GetSize(format) == 0)
return PyObject_Str((PyObject *)self);
- return PyObject_CallMethod((PyObject *)self, "strftime", "O", format);
+ return _PyObject_CallMethodId((PyObject *)self, &PyId_strftime, "O", format);
}
/* ISO methods. */
@@ -3573,7 +3590,9 @@ time_repr(PyDateTime_Time *self)
static PyObject *
time_str(PyDateTime_Time *self)
{
- return PyObject_CallMethod((PyObject *)self, "isoformat", "()");
+ _Py_identifier(isoformat);
+
+ return _PyObject_CallMethodId((PyObject *)self, &PyId_isoformat, "()");
}
static PyObject *
@@ -4152,7 +4171,9 @@ datetime_now(PyObject *cls, PyObject *args, PyObject *kw)
if (self != NULL && tzinfo != Py_None) {
/* Convert UTC to tzinfo's zone. */
PyObject *temp = self;
- self = PyObject_CallMethod(tzinfo, "fromutc", "O", self);
+ _Py_identifier(fromutc);
+
+ self = _PyObject_CallMethodId(tzinfo, &PyId_fromutc, "O", self);
Py_DECREF(temp);
}
return self;
@@ -4189,7 +4210,9 @@ datetime_fromtimestamp(PyObject *cls, PyObject *args, PyObject *kw)
if (self != NULL && tzinfo != Py_None) {
/* Convert UTC to tzinfo's zone. */
PyObject *temp = self;
- self = PyObject_CallMethod(tzinfo, "fromutc", "O", self);
+ _Py_identifier(fromutc);
+
+ self = _PyObject_CallMethodId(tzinfo, &PyId_fromutc, "O", self);
Py_DECREF(temp);
}
return self;
@@ -4214,6 +4237,7 @@ datetime_strptime(PyObject *cls, PyObject *args)
{
static PyObject *module = NULL;
PyObject *string, *format;
+ _Py_identifier(_strptime_datetime);
if (!PyArg_ParseTuple(args, "UU:strptime", &string, &format))
return NULL;
@@ -4223,8 +4247,8 @@ datetime_strptime(PyObject *cls, PyObject *args)
if (module == NULL)
return NULL;
}
- return PyObject_CallMethod(module, "_strptime_datetime", "OOO",
- cls, string, format);
+ return _PyObject_CallMethodId(module, &PyId__strptime_datetime, "OOO",
+ cls, string, format);
}
/* Return new datetime from date/datetime and time arguments. */
@@ -4469,7 +4493,9 @@ datetime_repr(PyDateTime_DateTime *self)
static PyObject *
datetime_str(PyDateTime_DateTime *self)
{
- return PyObject_CallMethod((PyObject *)self, "isoformat", "(s)", " ");
+ _Py_identifier(isoformat);
+
+ return _PyObject_CallMethodId((PyObject *)self, &PyId_isoformat, "(s)", " ");
}
static PyObject *
@@ -4676,6 +4702,7 @@ datetime_astimezone(PyDateTime_DateTime *self, PyObject *args, PyObject *kw)
PyObject *offset;
PyObject *temp;
PyObject *tzinfo;
+ _Py_identifier(fromutc);
static char *keywords[] = {"tz", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kw, "O!:astimezone", keywords,
@@ -4717,7 +4744,7 @@ datetime_astimezone(PyDateTime_DateTime *self, PyObject *args, PyObject *kw)
Py_DECREF(temp);
temp = result;
- result = PyObject_CallMethod(tzinfo, "fromutc", "O", temp);
+ result = _PyObject_CallMethodId(tzinfo, &PyId_fromutc, "O", temp);
Py_DECREF(temp);
return result;
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 0c64dd5..fcd1271 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -790,16 +790,18 @@ static PyObject*
element_find(ElementObject* self, PyObject* args)
{
int i;
-
PyObject* tag;
PyObject* namespaces = Py_None;
+
if (!PyArg_ParseTuple(args, "O|O:find", &tag, &namespaces))
return NULL;
- if (checkpath(tag) || namespaces != Py_None)
- return PyObject_CallMethod(
- elementpath_obj, "find", "OOO", self, tag, namespaces
+ if (checkpath(tag) || namespaces != Py_None) {
+ _Py_identifier(find);
+ return _PyObject_CallMethodId(
+ elementpath_obj, &PyId_find, "OOO", self, tag, namespaces
);
+ }
if (!self->extra)
Py_RETURN_NONE;
@@ -820,16 +822,17 @@ static PyObject*
element_findtext(ElementObject* self, PyObject* args)
{
int i;
-
PyObject* tag;
PyObject* default_value = Py_None;
PyObject* namespaces = Py_None;
+ _Py_identifier(findtext);
+
if (!PyArg_ParseTuple(args, "O|OO:findtext", &tag, &default_value, &namespaces))
return NULL;
if (checkpath(tag) || namespaces != Py_None)
- return PyObject_CallMethod(
- elementpath_obj, "findtext", "OOOO", self, tag, default_value, namespaces
+ return _PyObject_CallMethodId(
+ elementpath_obj, &PyId_findtext, "OOOO", self, tag, default_value, namespaces
);
if (!self->extra) {
@@ -858,16 +861,18 @@ element_findall(ElementObject* self, PyObject* args)
{
int i;
PyObject* out;
-
PyObject* tag;
PyObject* namespaces = Py_None;
+
if (!PyArg_ParseTuple(args, "O|O:findall", &tag, &namespaces))
return NULL;
- if (checkpath(tag) || namespaces != Py_None)
- return PyObject_CallMethod(
- elementpath_obj, "findall", "OOO", self, tag, namespaces
+ if (checkpath(tag) || namespaces != Py_None) {
+ _Py_identifier(findall);
+ return _PyObject_CallMethodId(
+ elementpath_obj, &PyId_findall, "OOO", self, tag, namespaces
);
+ }
out = PyList_New(0);
if (!out)
@@ -895,11 +900,13 @@ element_iterfind(ElementObject* self, PyObject* args)
{
PyObject* tag;
PyObject* namespaces = Py_None;
+ _Py_identifier(iterfind);
+
if (!PyArg_ParseTuple(args, "O|O:iterfind", &tag, &namespaces))
return NULL;
- return PyObject_CallMethod(
- elementpath_obj, "iterfind", "OOO", self, tag, namespaces
+ return _PyObject_CallMethodId(
+ elementpath_obj, &PyId_iterfind, "OOO", self, tag, namespaces
);
}
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index 6f5bd48..f264756 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -308,6 +308,9 @@ io_open(PyObject *self, PyObject *args, PyObject *kwds)
PyObject *raw, *modeobj = NULL, *buffer = NULL, *wrapper = NULL;
+ _Py_identifier(isatty);
+ _Py_identifier(fileno);
+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|sizzzi:open", kwlist,
&file, &mode, &buffering,
&encoding, &errors, &newline,
@@ -421,7 +424,7 @@ io_open(PyObject *self, PyObject *args, PyObject *kwds)
/* buffering */
{
- PyObject *res = PyObject_CallMethod(raw, "isatty", NULL);
+ PyObject *res = _PyObject_CallMethodId(raw, &PyId_isatty, NULL);
if (res == NULL)
goto error;
isatty = PyLong_AsLong(res);
@@ -443,7 +446,7 @@ io_open(PyObject *self, PyObject *args, PyObject *kwds)
{
struct stat st;
long fileno;
- PyObject *res = PyObject_CallMethod(raw, "fileno", NULL);
+ PyObject *res = _PyObject_CallMethodId(raw, &PyId_fileno, NULL);
if (res == NULL)
goto error;
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 86f7412..6ef2c20 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -13,6 +13,18 @@
#include "pythread.h"
#include "_iomodule.h"
+_Py_identifier(close);
+_Py_identifier(_dealloc_warn);
+_Py_identifier(flush);
+_Py_identifier(isatty);
+_Py_identifier(peek);
+_Py_identifier(read);
+_Py_identifier(read1);
+_Py_identifier(readable);
+_Py_identifier(readinto);
+_Py_identifier(writable);
+_Py_identifier(write);
+
/*
* BufferedIOBase class, inherits from IOBase.
*/
@@ -38,12 +50,13 @@ bufferediobase_readinto(PyObject *self, PyObject *args)
Py_buffer buf;
Py_ssize_t len;
PyObject *data;
+ _Py_identifier(read);
if (!PyArg_ParseTuple(args, "w*:readinto", &buf)) {
return NULL;
}
- data = PyObject_CallMethod(self, "read", "n", buf.len);
+ data = _PyObject_CallMethodId(self, &PyId_read, "n", buf.len);
if (data == NULL)
goto error;
@@ -410,7 +423,7 @@ buffered_dealloc_warn(buffered *self, PyObject *source)
{
if (self->ok && self->raw) {
PyObject *r;
- r = PyObject_CallMethod(self->raw, "_dealloc_warn", "O", source);
+ r = _PyObject_CallMethodId(self->raw, &PyId__dealloc_warn, "O", source);
if (r)
Py_DECREF(r);
else
@@ -2216,13 +2229,13 @@ bufferedrwpair_dealloc(rwpair *self)
}
static PyObject *
-_forward_call(buffered *self, const char *name, PyObject *args)
+_forward_call(buffered *self, _Py_Identifier *name, PyObject *args)
{
- PyObject *func = PyObject_GetAttrString((PyObject *)self, name);
+ PyObject *func = _PyObject_GetAttrId((PyObject *)self, name);
PyObject *ret;
if (func == NULL) {
- PyErr_SetString(PyExc_AttributeError, name);
+ PyErr_SetString(PyExc_AttributeError, name->string);
return NULL;
}
@@ -2234,66 +2247,66 @@ _forward_call(buffered *self, const char *name, PyObject *args)
static PyObject *
bufferedrwpair_read(rwpair *self, PyObject *args)
{
- return _forward_call(self->reader, "read", args);
+ return _forward_call(self->reader, &PyId_read, args);
}
static PyObject *
bufferedrwpair_peek(rwpair *self, PyObject *args)
{
- return _forward_call(self->reader, "peek", args);
+ return _forward_call(self->reader, &PyId_peek, args);
}
static PyObject *
bufferedrwpair_read1(rwpair *self, PyObject *args)
{
- return _forward_call(self->reader, "read1", args);
+ return _forward_call(self->reader, &PyId_read1, args);
}
static PyObject *
bufferedrwpair_readinto(rwpair *self, PyObject *args)
{
- return _forward_call(self->reader, "readinto", args);
+ return _forward_call(self->reader, &PyId_readinto, args);
}
static PyObject *
bufferedrwpair_write(rwpair *self, PyObject *args)
{
- return _forward_call(self->writer, "write", args);
+ return _forward_call(self->writer, &PyId_write, args);
}
static PyObject *
bufferedrwpair_flush(rwpair *self, PyObject *args)
{
- return _forward_call(self->writer, "flush", args);
+ return _forward_call(self->writer, &PyId_flush, args);
}
static PyObject *
bufferedrwpair_readable(rwpair *self, PyObject *args)
{
- return _forward_call(self->reader, "readable", args);
+ return _forward_call(self->reader, &PyId_readable, args);
}
static PyObject *
bufferedrwpair_writable(rwpair *self, PyObject *args)
{
- return _forward_call(self->writer, "writable", args);
+ return _forward_call(self->writer, &PyId_writable, args);
}
static PyObject *
bufferedrwpair_close(rwpair *self, PyObject *args)
{
- PyObject *ret = _forward_call(self->writer, "close", args);
+ PyObject *ret = _forward_call(self->writer, &PyId_close, args);
if (ret == NULL)
return NULL;
Py_DECREF(ret);
- return _forward_call(self->reader, "close", args);
+ return _forward_call(self->reader, &PyId_close, args);
}
static PyObject *
bufferedrwpair_isatty(rwpair *self, PyObject *args)
{
- PyObject *ret = _forward_call(self->writer, "isatty", args);
+ PyObject *ret = _forward_call(self->writer, &PyId_isatty, args);
if (ret != Py_False) {
/* either True or exception */
@@ -2301,7 +2314,7 @@ bufferedrwpair_isatty(rwpair *self, PyObject *args)
}
Py_DECREF(ret);
- return _forward_call(self->reader, "isatty", args);
+ return _forward_call(self->reader, &PyId_isatty, args);
}
static PyObject *
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 2bf8933..a16d13c 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -128,6 +128,7 @@ internal_close(fileio *self)
static PyObject *
fileio_close(fileio *self)
{
+ _Py_identifier(close);
if (!self->closefd) {
self->fd = -1;
Py_RETURN_NONE;
@@ -143,8 +144,8 @@ fileio_close(fileio *self)
if (errno < 0)
return NULL;
- return PyObject_CallMethod((PyObject*)&PyRawIOBase_Type,
- "close", "O", self);
+ return _PyObject_CallMethodId((PyObject*)&PyRawIOBase_Type,
+ &PyId_close, "O", self);
}
static PyObject *
diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c
index 35c7cdd..6a94a04 100644
--- a/Modules/_io/iobase.c
+++ b/Modules/_io/iobase.c
@@ -97,7 +97,9 @@ PyDoc_STRVAR(iobase_tell_doc,
static PyObject *
iobase_tell(PyObject *self, PyObject *args)
{
- return PyObject_CallMethod(self, "seek", "ii", 0, 1);
+ _Py_identifier(seek);
+
+ return _PyObject_CallMethodId(self, &PyId_seek, "ii", 0, 1);
}
PyDoc_STRVAR(iobase_truncate_doc,
@@ -464,6 +466,7 @@ iobase_readline(PyObject *self, PyObject *args)
int has_peek = 0;
PyObject *buffer, *result;
Py_ssize_t old_size = -1;
+ _Py_identifier(read);
if (!PyArg_ParseTuple(args, "|O&:readline", &_PyIO_ConvertSsize_t, &limit)) {
return NULL;
@@ -481,7 +484,9 @@ iobase_readline(PyObject *self, PyObject *args)
PyObject *b;
if (has_peek) {
- PyObject *readahead = PyObject_CallMethod(self, "peek", "i", 1);
+ _Py_identifier(peek);
+ PyObject *readahead = _PyObject_CallMethodId(self, &PyId_peek, "i", 1);
+
if (readahead == NULL)
goto fail;
if (!PyBytes_Check(readahead)) {
@@ -515,7 +520,7 @@ iobase_readline(PyObject *self, PyObject *args)
Py_DECREF(readahead);
}
- b = PyObject_CallMethod(self, "read", "n", nreadahead);
+ b = _PyObject_CallMethodId(self, &PyId_read, "n", nreadahead);
if (b == NULL)
goto fail;
if (!PyBytes_Check(b)) {
@@ -601,7 +606,9 @@ iobase_readlines(PyObject *self, PyObject *args)
/* XXX special-casing this made sense in the Python version in order
to remove the bytecode interpretation overhead, but it could
probably be removed here. */
- PyObject *ret = PyObject_CallMethod(result, "extend", "O", self);
+ _Py_identifier(extend);
+ PyObject *ret = _PyObject_CallMethodId(result, &PyId_extend, "O", self);
+
if (ret == NULL) {
Py_DECREF(result);
return NULL;
@@ -781,8 +788,11 @@ rawiobase_read(PyObject *self, PyObject *args)
return NULL;
}
- if (n < 0)
- return PyObject_CallMethod(self, "readall", NULL);
+ if (n < 0) {
+ _Py_identifier(readall);
+
+ return _PyObject_CallMethodId(self, &PyId_readall, NULL);
+ }
/* TODO: allocate a bytes object directly instead and manually construct
a writable memoryview pointing to it. */
@@ -823,8 +833,9 @@ rawiobase_readall(PyObject *self, PyObject *args)
return NULL;
while (1) {
- PyObject *data = PyObject_CallMethod(self, "read",
- "i", DEFAULT_BUFFER_SIZE);
+ _Py_identifier(read);
+ PyObject *data = _PyObject_CallMethodId(self, &PyId_read,
+ "i", DEFAULT_BUFFER_SIZE);
if (!data) {
Py_DECREF(chunks);
return NULL;
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index aa29ffb..2ded719 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -11,6 +11,24 @@
#include "structmember.h"
#include "_iomodule.h"
+_Py_identifier(close);
+_Py_identifier(_dealloc_warn);
+_Py_identifier(decode);
+_Py_identifier(device_encoding);
+_Py_identifier(fileno);
+_Py_identifier(flush);
+_Py_identifier(getpreferredencoding);
+_Py_identifier(isatty);
+_Py_identifier(read);
+_Py_identifier(readable);
+_Py_identifier(replace);
+_Py_identifier(reset);
+_Py_identifier(seek);
+_Py_identifier(seekable);
+_Py_identifier(setstate);
+_Py_identifier(tell);
+_Py_identifier(writable);
+
/* TextIOBase */
PyDoc_STRVAR(textiobase_doc,
@@ -501,8 +519,8 @@ incrementalnewlinedecoder_setstate(nldecoder_object *self, PyObject *state)
flag >>= 1;
if (self->decoder != Py_None)
- return PyObject_CallMethod(self->decoder,
- "setstate", "((OK))", buffer, flag);
+ return _PyObject_CallMethodId(self->decoder,
+ &PyId_setstate, "((OK))", buffer, flag);
else
Py_RETURN_NONE;
}
@@ -842,7 +860,7 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
if (encoding == NULL) {
/* Try os.device_encoding(fileno) */
PyObject *fileno;
- fileno = PyObject_CallMethod(buffer, "fileno", NULL);
+ fileno = _PyObject_CallMethodId(buffer, &PyId_fileno, NULL);
/* Ignore only AttributeError and UnsupportedOperation */
if (fileno == NULL) {
if (PyErr_ExceptionMatches(PyExc_AttributeError) ||
@@ -854,9 +872,9 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
}
}
else {
- self->encoding = PyObject_CallMethod(state->os_module,
- "device_encoding",
- "N", fileno);
+ self->encoding = _PyObject_CallMethodId(state->os_module,
+ &PyId_device_encoding,
+ "N", fileno);
if (self->encoding == NULL)
goto error;
else if (!PyUnicode_Check(self->encoding))
@@ -873,8 +891,8 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
}
else {
use_locale:
- self->encoding = PyObject_CallMethod(
- state->locale_module, "getpreferredencoding", NULL);
+ self->encoding = _PyObject_CallMethodId(
+ state->locale_module, &PyId_getpreferredencoding, NULL);
if (self->encoding == NULL) {
catch_ImportError:
/*
@@ -939,7 +957,7 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
#endif
/* Build the decoder object */
- res = PyObject_CallMethod(buffer, "readable", NULL);
+ res = _PyObject_CallMethodId(buffer, &PyId_readable, NULL);
if (res == NULL)
goto error;
r = PyObject_IsTrue(res);
@@ -964,7 +982,7 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
}
/* Build the encoder object */
- res = PyObject_CallMethod(buffer, "writable", NULL);
+ res = _PyObject_CallMethodId(buffer, &PyId_writable, NULL);
if (res == NULL)
goto error;
r = PyObject_IsTrue(res);
@@ -1022,7 +1040,7 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
Py_DECREF(raw);
}
- res = PyObject_CallMethod(buffer, "seekable", NULL);
+ res = _PyObject_CallMethodId(buffer, &PyId_seekable, NULL);
if (res == NULL)
goto error;
self->seekable = self->telling = PyObject_IsTrue(res);
@@ -1255,8 +1273,8 @@ textiowrapper_write(textio *self, PyObject *args)
haslf = 1;
if (haslf && self->writetranslate && self->writenl != NULL) {
- PyObject *newtext = PyObject_CallMethod(
- text, "replace", "ss", "\n", self->writenl);
+ PyObject *newtext = _PyObject_CallMethodId(
+ text, &PyId_replace, "ss", "\n", self->writenl);
Py_DECREF(text);
if (newtext == NULL)
return NULL;
@@ -1311,7 +1329,7 @@ textiowrapper_write(textio *self, PyObject *args)
Py_CLEAR(self->snapshot);
if (self->decoder) {
- ret = PyObject_CallMethod(self->decoder, "reset", NULL);
+ ret = _PyObject_CallMethodId(self->decoder, &PyId_reset, NULL);
if (ret == NULL)
return NULL;
Py_DECREF(ret);
@@ -1490,7 +1508,7 @@ textiowrapper_read(textio *self, PyObject *args)
if (n < 0) {
/* Read everything */
- PyObject *bytes = PyObject_CallMethod(self->buffer, "read", NULL);
+ PyObject *bytes = _PyObject_CallMethodId(self->buffer, &PyId_read, NULL);
PyObject *decoded;
if (bytes == NULL)
goto fail;
@@ -1940,8 +1958,8 @@ _textiowrapper_decoder_setstate(textio *self, cookie_type *cookie)
if (cookie->start_pos == 0 && cookie->dec_flags == 0)
res = PyObject_CallMethodObjArgs(self->decoder, _PyIO_str_reset, NULL);
else
- res = PyObject_CallMethod(self->decoder, "setstate",
- "((yi))", "", cookie->dec_flags);
+ res = _PyObject_CallMethodId(self->decoder, &PyId_setstate,
+ "((yi))", "", cookie->dec_flags);
if (res == NULL)
return -1;
Py_DECREF(res);
@@ -2005,13 +2023,12 @@ textiowrapper_seek(textio *self, PyObject *args)
* sync the underlying buffer with the current position.
*/
Py_DECREF(cookieObj);
- cookieObj = PyObject_CallMethod((PyObject *)self, "tell", NULL);
+ cookieObj = _PyObject_CallMethodId((PyObject *)self, &PyId_tell, NULL);
if (cookieObj == NULL)
goto fail;
}
else if (whence == 2) {
/* seek relative to end of file */
-
cmp = PyObject_RichCompareBool(cookieObj, _PyIO_zero, Py_EQ);
if (cmp < 0)
goto fail;
@@ -2021,7 +2038,7 @@ textiowrapper_seek(textio *self, PyObject *args)
goto fail;
}
- res = PyObject_CallMethod((PyObject *)self, "flush", NULL);
+ res = _PyObject_CallMethodId((PyObject *)self, &PyId_flush, NULL);
if (res == NULL)
goto fail;
Py_DECREF(res);
@@ -2029,13 +2046,13 @@ textiowrapper_seek(textio *self, PyObject *args)
textiowrapper_set_decoded_chars(self, NULL);
Py_CLEAR(self->snapshot);
if (self->decoder) {
- res = PyObject_CallMethod(self->decoder, "reset", NULL);
+ res = _PyObject_CallMethodId(self->decoder, &PyId_reset, NULL);
if (res == NULL)
goto fail;
Py_DECREF(res);
}
- res = PyObject_CallMethod(self->buffer, "seek", "ii", 0, 2);
+ res = _PyObject_CallMethodId(self->buffer, &PyId_seek, "ii", 0, 2);
Py_XDECREF(cookieObj);
return res;
}
@@ -2088,8 +2105,8 @@ textiowrapper_seek(textio *self, PyObject *args)
if (cookie.chars_to_skip) {
/* Just like _read_chunk, feed the decoder and save a snapshot. */
- PyObject *input_chunk = PyObject_CallMethod(
- self->buffer, "read", "i", cookie.bytes_to_feed);
+ PyObject *input_chunk = _PyObject_CallMethodId(
+ self->buffer, &PyId_read, "i", cookie.bytes_to_feed);
PyObject *decoded;
if (input_chunk == NULL)
@@ -2103,8 +2120,8 @@ textiowrapper_seek(textio *self, PyObject *args)
goto fail;
}
- decoded = PyObject_CallMethod(self->decoder, "decode",
- "Oi", input_chunk, (int)cookie.need_eof);
+ decoded = _PyObject_CallMethodId(self->decoder, &PyId_decode,
+ "Oi", input_chunk, (int)cookie.need_eof);
if (decoded == NULL)
goto fail;
@@ -2170,12 +2187,12 @@ textiowrapper_tell(textio *self, PyObject *args)
if (_textiowrapper_writeflush(self) < 0)
return NULL;
- res = PyObject_CallMethod((PyObject *)self, "flush", NULL);
+ res = _PyObject_CallMethodId((PyObject *)self, &PyId_flush, NULL);
if (res == NULL)
goto fail;
Py_DECREF(res);
- posobj = PyObject_CallMethod(self->buffer, "tell", NULL);
+ posobj = _PyObject_CallMethodId(self->buffer, &PyId_tell, NULL);
if (posobj == NULL)
goto fail;
@@ -2229,8 +2246,8 @@ textiowrapper_tell(textio *self, PyObject *args)
/* TODO: replace assert with exception */
#define DECODER_DECODE(start, len, res) do { \
- PyObject *_decoded = PyObject_CallMethod( \
- self->decoder, "decode", "y#", start, len); \
+ PyObject *_decoded = _PyObject_CallMethodId( \
+ self->decoder, &PyId_decode, "y#", start, len); \
if (_decoded == NULL) \
goto fail; \
assert (PyUnicode_Check(_decoded)); \
@@ -2312,8 +2329,8 @@ textiowrapper_tell(textio *self, PyObject *args)
}
if (input == input_end) {
/* We didn't get enough decoded data; signal EOF to get more. */
- PyObject *decoded = PyObject_CallMethod(
- self->decoder, "decode", "yi", "", /* final = */ 1);
+ PyObject *decoded = _PyObject_CallMethodId(
+ self->decoder, &PyId_decode, "yi", "", /* final = */ 1);
if (decoded == NULL)
goto fail;
assert (PyUnicode_Check(decoded));
@@ -2329,7 +2346,7 @@ textiowrapper_tell(textio *self, PyObject *args)
}
finally:
- res = PyObject_CallMethod(self->decoder, "setstate", "(O)", saved_state);
+ res = _PyObject_CallMethodId(self->decoder, &PyId_setstate, "(O)", saved_state);
Py_DECREF(saved_state);
if (res == NULL)
return NULL;
@@ -2344,7 +2361,7 @@ fail:
PyObject *type, *value, *traceback;
PyErr_Fetch(&type, &value, &traceback);
- res = PyObject_CallMethod(self->decoder, "setstate", "(O)", saved_state);
+ res = _PyObject_CallMethodId(self->decoder, &PyId_setstate, "(O)", saved_state);
Py_DECREF(saved_state);
if (res == NULL)
return NULL;
@@ -2432,35 +2449,35 @@ static PyObject *
textiowrapper_fileno(textio *self, PyObject *args)
{
CHECK_INITIALIZED(self);
- return PyObject_CallMethod(self->buffer, "fileno", NULL);
+ return _PyObject_CallMethodId(self->buffer, &PyId_fileno, NULL);
}
static PyObject *
textiowrapper_seekable(textio *self, PyObject *args)
{
CHECK_INITIALIZED(self);
- return PyObject_CallMethod(self->buffer, "seekable", NULL);
+ return _PyObject_CallMethodId(self->buffer, &PyId_seekable, NULL);
}
static PyObject *
textiowrapper_readable(textio *self, PyObject *args)
{
CHECK_INITIALIZED(self);
- return PyObject_CallMethod(self->buffer, "readable", NULL);
+ return _PyObject_CallMethodId(self->buffer, &PyId_readable, NULL);
}
static PyObject *
textiowrapper_writable(textio *self, PyObject *args)
{
CHECK_INITIALIZED(self);
- return PyObject_CallMethod(self->buffer, "writable", NULL);
+ return _PyObject_CallMethodId(self->buffer, &PyId_writable, NULL);
}
static PyObject *
textiowrapper_isatty(textio *self, PyObject *args)
{
CHECK_INITIALIZED(self);
- return PyObject_CallMethod(self->buffer, "isatty", NULL);
+ return _PyObject_CallMethodId(self->buffer, &PyId_isatty, NULL);
}
static PyObject *
@@ -2479,7 +2496,7 @@ textiowrapper_flush(textio *self, PyObject *args)
self->telling = self->seekable;
if (_textiowrapper_writeflush(self) < 0)
return NULL;
- return PyObject_CallMethod(self->buffer, "flush", NULL);
+ return _PyObject_CallMethodId(self->buffer, &PyId_flush, NULL);
}
static PyObject *
@@ -2502,20 +2519,20 @@ textiowrapper_close(textio *self, PyObject *args)
}
else {
if (self->deallocating) {
- res = PyObject_CallMethod(self->buffer, "_dealloc_warn", "O", self);
+ res = _PyObject_CallMethodId(self->buffer, &PyId__dealloc_warn, "O", self);
if (res)
Py_DECREF(res);
else
PyErr_Clear();
}
- res = PyObject_CallMethod((PyObject *)self, "flush", NULL);
+ res = _PyObject_CallMethodId((PyObject *)self, &PyId_flush, NULL);
if (res == NULL) {
return NULL;
}
else
Py_DECREF(res);
- return PyObject_CallMethod(self->buffer, "close", NULL);
+ return _PyObject_CallMethodId(self->buffer, &PyId_close, NULL);
}
}
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 0b10009..e53abc88 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -2488,7 +2488,9 @@ save_dict(PicklerObject *self, PyObject *obj)
status = batch_dict_exact(self, obj);
Py_LeaveRecursiveCall();
} else {
- items = PyObject_CallMethod(obj, "items", "()");
+ _Py_identifier(items);
+
+ items = _PyObject_CallMethodId(obj, &PyId_items, "()");
if (items == NULL)
goto error;
iter = PyObject_GetIter(items);
@@ -3774,8 +3776,10 @@ static PyTypeObject Pickler_Type = {
static PyObject *
find_class(UnpicklerObject *self, PyObject *module_name, PyObject *global_name)
{
- return PyObject_CallMethod((PyObject *)self, "find_class", "OO",
- module_name, global_name);
+ _Py_identifier(find_class);
+
+ return _PyObject_CallMethodId((PyObject *)self, &PyId_find_class, "OO",
+ module_name, global_name);
}
static Py_ssize_t
@@ -4388,7 +4392,9 @@ instantiate(PyObject *cls, PyObject *args)
result = PyObject_CallObject(cls, args);
}
else {
- result = PyObject_CallMethod(cls, "__new__", "O", cls);
+ _Py_identifier(__new__);
+
+ result = _PyObject_CallMethodId(cls, &PyId___new__, "O", cls);
}
return result;
}
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
index bc2f72c..e6a9283 100644
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -18,7 +18,9 @@ static long max_fd;
static int _enable_gc(PyObject *gc_module)
{
PyObject *result;
- result = PyObject_CallMethod(gc_module, "enable", NULL);
+ _Py_identifier(enable);
+
+ result = _PyObject_CallMethodId(gc_module, &PyId_enable, NULL);
if (result == NULL)
return 1;
Py_DECREF(result);
@@ -249,10 +251,13 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
/* We need to call gc.disable() when we'll be calling preexec_fn */
if (preexec_fn != Py_None) {
PyObject *result;
+ _Py_identifier(isenabled);
+ _Py_identifier(disable);
+
gc_module = PyImport_ImportModule("gc");
if (gc_module == NULL)
return NULL;
- result = PyObject_CallMethod(gc_module, "isenabled", NULL);
+ result = _PyObject_CallMethodId(gc_module, &PyId_isenabled, NULL);
if (result == NULL) {
Py_DECREF(gc_module);
return NULL;
@@ -263,7 +268,7 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
Py_DECREF(gc_module);
return NULL;
}
- result = PyObject_CallMethod(gc_module, "disable", NULL);
+ result = _PyObject_CallMethodId(gc_module, &PyId_disable, NULL);
if (result == NULL) {
Py_DECREF(gc_module);
return NULL;
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 310a27c..c2f218f 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -675,6 +675,7 @@ void _pysqlite_final_callback(sqlite3_context* context)
{
PyObject* function_result = NULL;
PyObject** aggregate_instance;
+ _Py_identifier(finalize);
#ifdef WITH_THREAD
PyGILState_STATE threadstate;
@@ -690,7 +691,7 @@ void _pysqlite_final_callback(sqlite3_context* context)
goto error;
}
- function_result = PyObject_CallMethod(*aggregate_instance, "finalize", "");
+ function_result = _PyObject_CallMethodId(*aggregate_instance, &PyId_finalize, "");
if (!function_result) {
if (_enable_callback_tracebacks) {
PyErr_Print();
@@ -1230,8 +1231,9 @@ PyObject* pysqlite_connection_execute(pysqlite_Connection* self, PyObject* args,
PyObject* cursor = 0;
PyObject* result = 0;
PyObject* method = 0;
+ _Py_identifier(cursor);
- cursor = PyObject_CallMethod((PyObject*)self, "cursor", "");
+ cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, "");
if (!cursor) {
goto error;
}
@@ -1259,8 +1261,9 @@ PyObject* pysqlite_connection_executemany(pysqlite_Connection* self, PyObject* a
PyObject* cursor = 0;
PyObject* result = 0;
PyObject* method = 0;
+ _Py_identifier(cursor);
- cursor = PyObject_CallMethod((PyObject*)self, "cursor", "");
+ cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, "");
if (!cursor) {
goto error;
}
@@ -1288,8 +1291,9 @@ PyObject* pysqlite_connection_executescript(pysqlite_Connection* self, PyObject*
PyObject* cursor = 0;
PyObject* result = 0;
PyObject* method = 0;
+ _Py_identifier(cursor);
- cursor = PyObject_CallMethod((PyObject*)self, "cursor", "");
+ cursor = _PyObject_CallMethodId((PyObject*)self, &PyId_cursor, "");
if (!cursor) {
goto error;
}
@@ -1437,6 +1441,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
PyObject* name;
PyObject* retval;
Py_ssize_t i, len;
+ _Py_identifier(upper);
char *uppercase_name_str;
int rc;
unsigned int kind;
@@ -1450,7 +1455,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
goto finally;
}
- uppercase_name = PyObject_CallMethod(name, "upper", "");
+ uppercase_name = _PyObject_CallMethodId(name, &PyId_upper, "");
if (!uppercase_name) {
goto finally;
}
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 264ae45..b47fed4 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -150,8 +150,9 @@ PyObject* _pysqlite_get_converter(PyObject* key)
{
PyObject* upcase_key;
PyObject* retval;
+ _Py_identifier(upper);
- upcase_key = PyObject_CallMethod(key, "upper", "");
+ upcase_key = _PyObject_CallMethodId(key, &PyId_upper, "");
if (!upcase_key) {
return NULL;
}
diff --git a/Modules/_sqlite/microprotocols.c b/Modules/_sqlite/microprotocols.c
index c730afa..c0f5e22 100644
--- a/Modules/_sqlite/microprotocols.c
+++ b/Modules/_sqlite/microprotocols.c
@@ -95,7 +95,9 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
/* try to have the protocol adapt this object*/
if (PyObject_HasAttrString(proto, "__adapt__")) {
- PyObject *adapted = PyObject_CallMethod(proto, "__adapt__", "O", obj);
+ _Py_identifier(__adapt__);
+ PyObject *adapted = _PyObject_CallMethodId(proto, &PyId___adapt__, "O", obj);
+
if (adapted) {
if (adapted != Py_None) {
return adapted;
@@ -110,7 +112,9 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
/* and finally try to have the object adapt itself */
if (PyObject_HasAttrString(obj, "__conform__")) {
- PyObject *adapted = PyObject_CallMethod(obj, "__conform__","O", proto);
+ _Py_identifier(__conform__);
+ PyObject *adapted = _PyObject_CallMethodId(obj, &PyId___conform__,"O", proto);
+
if (adapted) {
if (adapted != Py_None) {
return adapted;
diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c
index cbc3b8e..20e1ec7 100644
--- a/Modules/_sqlite/module.c
+++ b/Modules/_sqlite/module.c
@@ -179,13 +179,14 @@ static PyObject* module_register_converter(PyObject* self, PyObject* args)
PyObject* name = NULL;
PyObject* callable;
PyObject* retval = NULL;
+ _Py_identifier(upper);
if (!PyArg_ParseTuple(args, "UO", &orig_name, &callable)) {
return NULL;
}
/* convert the name to upper case */
- name = PyObject_CallMethod(orig_name, "upper", "");
+ name = _PyObject_CallMethodId(orig_name, &PyId_upper, "");
if (!name) {
goto error;
}
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 0032594..6cedee4 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -1253,6 +1253,7 @@ array_fromfile(arrayobject *self, PyObject *args)
PyObject *f, *b, *res;
Py_ssize_t itemsize = self->ob_descr->itemsize;
Py_ssize_t n, nbytes;
+ _Py_identifier(read);
int not_enough_bytes;
if (!PyArg_ParseTuple(args, "On:fromfile", &f, &n))
@@ -1264,7 +1265,7 @@ array_fromfile(arrayobject *self, PyObject *args)
return NULL;
}
- b = PyObject_CallMethod(f, "read", "n", nbytes);
+ b = _PyObject_CallMethodId(f, &PyId_read, "n", nbytes);
if (b == NULL)
return NULL;
@@ -1321,12 +1322,14 @@ array_tofile(arrayobject *self, PyObject *f)
char* ptr = self->ob_item + i*BLOCKSIZE;
Py_ssize_t size = BLOCKSIZE;
PyObject *bytes, *res;
+ _Py_identifier(write);
+
if (i*BLOCKSIZE + size > nbytes)
size = nbytes - i*BLOCKSIZE;
bytes = PyBytes_FromStringAndSize(ptr, size);
if (bytes == NULL)
return NULL;
- res = PyObject_CallMethod(f, "write", "O", bytes);
+ res = _PyObject_CallMethodId(f, &PyId_write, "O", bytes);
Py_DECREF(bytes);
if (res == NULL)
return NULL;
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index 1b37845..8635a56 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -1579,12 +1579,13 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self,
PyObject *unistr)
{
PyObject *str, *wr;
+ _Py_identifier(write);
str = encoder_encode_stateful(STATEFUL_ECTX(self), unistr, 0);
if (str == NULL)
return -1;
- wr = PyObject_CallMethod(self->stream, "write", "O", str);
+ wr = _PyObject_CallMethodId(self->stream, &PyId_write, "O", str);
Py_DECREF(str);
if (wr == NULL)
return -1;
@@ -1650,7 +1651,9 @@ mbstreamwriter_reset(MultibyteStreamWriterObject *self)
assert(PyBytes_Check(pwrt));
if (PyBytes_Size(pwrt) > 0) {
PyObject *wr;
- wr = PyObject_CallMethod(self->stream, "write", "O", pwrt);
+ _Py_identifier(write);
+
+ wr = _PyObject_CallMethodId(self->stream, &PyId_write, "O", pwrt);
if (wr == NULL) {
Py_DECREF(pwrt);
return NULL;
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index 06f7f2e..11d5340 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -146,6 +146,8 @@ static PyObject*
faulthandler_get_fileno(PyObject *file, int *p_fd)
{
PyObject *result;
+ _Py_identifier(fileno);
+ _Py_identifier(flush);
long fd_long;
int fd;
@@ -157,7 +159,7 @@ faulthandler_get_fileno(PyObject *file, int *p_fd)
}
}
- result = PyObject_CallMethod(file, "fileno", "");
+ result = _PyObject_CallMethodId(file, &PyId_fileno, "");
if (result == NULL)
return NULL;
@@ -175,7 +177,7 @@ faulthandler_get_fileno(PyObject *file, int *p_fd)
return NULL;
}
- result = PyObject_CallMethod(file, "flush", "");
+ result = _PyObject_CallMethodId(file, &PyId_flush, "");
if (result != NULL)
Py_DECREF(result);
else {
@@ -1197,6 +1199,7 @@ static int
faulthandler_env_options(void)
{
PyObject *xoptions, *key, *module, *res;
+ _Py_identifier(enable);
if (!Py_GETENV("PYTHONFAULTHANDLER")) {
int has_key;
@@ -1219,7 +1222,7 @@ faulthandler_env_options(void)
if (module == NULL) {
return -1;
}
- res = PyObject_CallMethod(module, "enable", "");
+ res = _PyObject_CallMethodId(module, &PyId_enable, "");
Py_DECREF(module);
if (res == NULL)
return -1;
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index b05675c..2533de6 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -769,7 +769,9 @@ get_time(void)
{
double result = 0;
if (tmod != NULL) {
- PyObject *f = PyObject_CallMethod(tmod, "time", NULL);
+ _Py_identifier(time);
+
+ PyObject *f = _PyObject_CallMethodId(tmod, &PyId_time, NULL);
if (f == NULL) {
PyErr_Clear();
}
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index d0897c3..4f81fe2 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -654,7 +654,9 @@ tee(PyObject *self, PyObject *args)
copyable = it;
PyTuple_SET_ITEM(result, 0, copyable);
for (i=1 ; i<n ; i++) {
- copyable = PyObject_CallMethod(copyable, "__copy__", NULL);
+ _Py_identifier(__copy__);
+
+ copyable = _PyObject_CallMethodId(copyable, &PyId___copy__, NULL);
if (copyable == NULL) {
Py_DECREF(result);
return NULL;
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 5d086a7..f4a80c2 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -702,7 +702,9 @@ mmap__enter__method(mmap_object *self, PyObject *args)
static PyObject *
mmap__exit__method(PyObject *self, PyObject *args)
{
- return PyObject_CallMethod(self, "close", NULL);
+ _Py_identifier(close);
+
+ return _PyObject_CallMethodId(self, &PyId_close, NULL);
}
static struct PyMethodDef mmap_object_methods[] = {
diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c
index f0fe8c2..7512c1d 100644
--- a/Modules/ossaudiodev.c
+++ b/Modules/ossaudiodev.c
@@ -534,7 +534,9 @@ oss_self(PyObject *self, PyObject *unused)
static PyObject *
oss_exit(PyObject *self, PyObject *unused)
{
- PyObject *ret = PyObject_CallMethod(self, "close", NULL);
+ _Py_identifier(close);
+
+ PyObject *ret = _PyObject_CallMethodId(self, &PyId_close, NULL);
if (!ret)
return NULL;
Py_DECREF(ret);
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index e64c960..6d0a44c 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -4821,7 +4821,9 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
if (hobj == Py_None) {
hptr = NULL;
} else if (PyUnicode_Check(hobj)) {
- idna = PyObject_CallMethod(hobj, "encode", "s", "idna");
+ _Py_identifier(encode);
+
+ idna = _PyObject_CallMethodId(hobj, &PyId_encode, "s", "idna");
if (!idna)
return NULL;
assert(PyBytes_Check(idna));
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 4dc82a0..2ea0247 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -535,11 +535,12 @@ time_strptime(PyObject *self, PyObject *args)
{
PyObject *strptime_module = PyImport_ImportModuleNoBlock("_strptime");
PyObject *strptime_result;
+ _Py_identifier(_strptime_time);
if (!strptime_module)
return NULL;
- strptime_result = PyObject_CallMethod(strptime_module,
- "_strptime_time", "O", args);
+ strptime_result = _PyObject_CallMethodId(strptime_module,
+ &PyId__strptime_time, "O", args);
Py_DECREF(strptime_module);
return strptime_result;
}