summaryrefslogtreecommitdiffstats
path: root/Modules/timemodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-08-24 03:51:52 (GMT)
committerGuido van Rossum <guido@python.org>2007-08-24 03:51:52 (GMT)
commiteda12ecc5fc9521ae022d1874e0d58db3a2bd465 (patch)
tree01b83947a4c0e5d5aaae15cb3e3186cc1c8ffa7d /Modules/timemodule.c
parent28bbe4252eeccd3e7df351ce7beff5774de0b702 (diff)
downloadcpython-eda12ecc5fc9521ae022d1874e0d58db3a2bd465.zip
cpython-eda12ecc5fc9521ae022d1874e0d58db3a2bd465.tar.gz
cpython-eda12ecc5fc9521ae022d1874e0d58db3a2bd465.tar.bz2
Patch by Ero Carrera to get rid of PyString in timemodule.c.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r--Modules/timemodule.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 45002a1..8ce6667 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -377,13 +377,17 @@ time_strftime(PyObject *self, PyObject *args)
PyObject *tup = NULL;
struct tm buf;
const char *fmt;
+ PyObject *format;
size_t fmtlen, buflen;
char *outbuf = 0;
size_t i;
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;
if (tup == NULL) {
@@ -458,6 +462,9 @@ time_strftime(PyObject *self, PyObject *args)
return NULL;
}
+ /* Convert the unicode string to an ascii one */
+ fmt = PyUnicode_AsString(format);
+
fmtlen = strlen(fmt);
/* 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);
if (p[24] == '\n')
p[24] = '\0';
- return PyString_FromString(p);
+ return PyUnicode_FromString(p);
}
PyDoc_STRVAR(asctime_doc,
@@ -571,7 +578,7 @@ time_ctime(PyObject *self, PyObject *args)
}
if (p[24] == '\n')
p[24] = '\0';
- return PyString_FromString(p);
+ return PyUnicode_FromString(p);
}
PyDoc_STRVAR(ctime_doc,