diff options
author | Guido van Rossum <guido@python.org> | 2002-07-19 17:06:47 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-07-19 17:06:47 (GMT) |
commit | d3c46d54632703be3d3767e5f785ee83695c6f53 (patch) | |
tree | b7b3dde6eb3bdb087eba189ab818c6923e0c7d73 /Modules | |
parent | 00efe7e7989b1a28e09ca2158f214494d2064c19 (diff) | |
download | cpython-d3c46d54632703be3d3767e5f785ee83695c6f53.zip cpython-d3c46d54632703be3d3767e5f785ee83695c6f53.tar.gz cpython-d3c46d54632703be3d3767e5f785ee83695c6f53.tar.bz2 |
Patch to call the Pure python strptime implementation if there's no
C implementation. See SF patch 474274, by Brett Cannon.
(As an experiment, I'm adding a line that #undefs HAVE_STRPTIME,
so that you'll always get the Python version. This is so that it
gets some good exercise. We should eventually delete that line.)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/timemodule.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index dbb4456..eb48c2b 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -412,6 +412,7 @@ See the library reference manual for formatting codes. When the time tuple\n\ is not present, current time as returned by localtime() is used."); #endif /* HAVE_STRFTIME */ +#undef HAVE_STRPTIME #ifdef HAVE_STRPTIME #if 0 @@ -445,12 +446,28 @@ time_strptime(PyObject *self, PyObject *args) return tmtotuple(&tm); } +#endif /* HAVE_STRPTIME */ + +#ifndef HAVE_STRPTIME + +static PyObject * +time_strptime(PyObject *self, PyObject *args) +{ + PyObject *strptime_module = PyImport_ImportModule("_strptime"); + + if (!strptime_module) + return NULL; + return PyObject_CallMethod(strptime_module, "strptime", "O", args); +} + +#endif /* !HAVE_STRPTIME */ + PyDoc_STRVAR(strptime_doc, "strptime(string, format) -> tuple\n\ \n\ Parse a string to a time tuple according to a format specification.\n\ See the library reference manual for formatting codes (same as strftime())."); -#endif /* HAVE_STRPTIME */ + static PyObject * time_asctime(PyObject *self, PyObject *args) @@ -553,9 +570,7 @@ static PyMethodDef time_methods[] = { #ifdef HAVE_STRFTIME {"strftime", time_strftime, METH_VARARGS, strftime_doc}, #endif -#ifdef HAVE_STRPTIME {"strptime", time_strptime, METH_VARARGS, strptime_doc}, -#endif {NULL, NULL} /* sentinel */ }; |