mirror of
https://github.com/python/cpython.git
synced 2025-09-28 03:13:48 +00:00
Patch by Ero Carrera to get rid of PyString in timemodule.c.
This commit is contained in:
parent
28bbe4252e
commit
eda12ecc5f
1 changed files with 10 additions and 3 deletions
|
@ -377,13 +377,17 @@ time_strftime(PyObject *self, PyObject *args)
|
||||||
PyObject *tup = NULL;
|
PyObject *tup = NULL;
|
||||||
struct tm buf;
|
struct tm buf;
|
||||||
const char *fmt;
|
const char *fmt;
|
||||||
|
PyObject *format;
|
||||||
size_t fmtlen, buflen;
|
size_t fmtlen, buflen;
|
||||||
char *outbuf = 0;
|
char *outbuf = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
memset((void *) &buf, '\0', sizeof(buf));
|
memset((void *) &buf, '\0', sizeof(buf));
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s|O:strftime", &fmt, &tup))
|
/* Will always expect a unicode string to be passed as format.
|
||||||
|
Given that there's no str type anymore in py3k this seems safe.
|
||||||
|
*/
|
||||||
|
if (!PyArg_ParseTuple(args, "U|O:strftime", &format, &tup))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (tup == NULL) {
|
if (tup == NULL) {
|
||||||
|
@ -458,6 +462,9 @@ time_strftime(PyObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Convert the unicode string to an ascii one */
|
||||||
|
fmt = PyUnicode_AsString(format);
|
||||||
|
|
||||||
fmtlen = strlen(fmt);
|
fmtlen = strlen(fmt);
|
||||||
|
|
||||||
/* I hate these functions that presume you know how big the output
|
/* I hate these functions that presume you know how big the output
|
||||||
|
@ -535,7 +542,7 @@ time_asctime(PyObject *self, PyObject *args)
|
||||||
p = asctime(&buf);
|
p = asctime(&buf);
|
||||||
if (p[24] == '\n')
|
if (p[24] == '\n')
|
||||||
p[24] = '\0';
|
p[24] = '\0';
|
||||||
return PyString_FromString(p);
|
return PyUnicode_FromString(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(asctime_doc,
|
PyDoc_STRVAR(asctime_doc,
|
||||||
|
@ -571,7 +578,7 @@ time_ctime(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
if (p[24] == '\n')
|
if (p[24] == '\n')
|
||||||
p[24] = '\0';
|
p[24] = '\0';
|
||||||
return PyString_FromString(p);
|
return PyUnicode_FromString(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(ctime_doc,
|
PyDoc_STRVAR(ctime_doc,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue