summaryrefslogtreecommitdiffstats
path: root/Python/marshal.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2011-10-09 08:38:36 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2011-10-09 08:38:36 (GMT)
commitafe55bba33a20f87a58f940186359237064b428f (patch)
tree66d64a1518d79c3d0e90c0a1d0080cd88e887d99 /Python/marshal.c
parent67df285a3389c7fdb8c7bd301314ac45e17f8074 (diff)
downloadcpython-afe55bba33a20f87a58f940186359237064b428f.zip
cpython-afe55bba33a20f87a58f940186359237064b428f.tar.gz
cpython-afe55bba33a20f87a58f940186359237064b428f.tar.bz2
Add API for static strings, primarily good for identifiers.
Thanks to Konrad Schöbel and Jasper Schulz for helping with the mass-editing.
Diffstat (limited to 'Python/marshal.c')
-rw-r--r--Python/marshal.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Python/marshal.c b/Python/marshal.c
index 31fe66b..b8288d0 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -480,7 +480,9 @@ r_string(char *s, int n, RFILE *p)
}
}
else {
- PyObject *data = PyObject_CallMethod(p->readable, "read", "i", n);
+ _Py_identifier(read);
+
+ PyObject *data = _PyObject_CallMethodId(p->readable, &PyId_read, "i", n);
read = 0;
if (data != NULL) {
if (!PyBytes_Check(data)) {
@@ -1290,12 +1292,14 @@ marshal_dump(PyObject *self, PyObject *args)
int version = Py_MARSHAL_VERSION;
PyObject *s;
PyObject *res;
+ _Py_identifier(write);
+
if (!PyArg_ParseTuple(args, "OO|i:dump", &x, &f, &version))
return NULL;
s = PyMarshal_WriteObjectToString(x, version);
if (s == NULL)
return NULL;
- res = PyObject_CallMethod(f, "write", "O", s);
+ res = _PyObject_CallMethodId(f, &PyId_write, "O", s);
Py_DECREF(s);
return res;
}
@@ -1317,6 +1321,7 @@ static PyObject *
marshal_load(PyObject *self, PyObject *f)
{
PyObject *data, *result;
+ _Py_identifier(read);
RFILE rf;
/*
@@ -1324,7 +1329,7 @@ marshal_load(PyObject *self, PyObject *f)
* This is to ensure that the object passed in at least
* has a read method which returns bytes.
*/
- data = PyObject_CallMethod(f, "read", "i", 0);
+ data = _PyObject_CallMethodId(f, &PyId_read, "i", 0);
if (data == NULL)
return NULL;
if (!PyBytes_Check(data)) {