diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2011-05-02 17:14:24 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2011-05-02 17:14:24 (GMT) |
commit | 89da349b7be56000e4b0efbe11ec4958af691b42 (patch) | |
tree | 0f6a529fb790429d25c0eb73c7c66c8836642dc3 /Modules | |
parent | 9d8c3b7cef1f235e92b018924ca21e0d1a49efd7 (diff) | |
download | cpython-89da349b7be56000e4b0efbe11ec4958af691b42.zip cpython-89da349b7be56000e4b0efbe11ec4958af691b42.tar.gz cpython-89da349b7be56000e4b0efbe11ec4958af691b42.tar.bz2 |
Issue #11930: Remove year >= 1000 limitation from datetime.strftime.
Patch by Victor Stinner.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_datetimemodule.c | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index a19c0c3..747be45 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -1166,31 +1166,6 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple, if (!pin) return NULL; - /* Give up if the year is before 1000. - * Python strftime() plays games with the year, and different - * games depending on whether envar PYTHON2K is set. This makes - * years before 1000 a nightmare, even if the platform strftime - * supports them (and not all do). - * We could get a lot farther here by avoiding Python's strftime - * wrapper and calling the C strftime() directly, but that isn't - * an option in the Python implementation of this module. - */ - { - long year; - PyObject *pyyear = PySequence_GetItem(timetuple, 0); - if (pyyear == NULL) return NULL; - assert(PyLong_Check(pyyear)); - year = PyLong_AsLong(pyyear); - Py_DECREF(pyyear); - if (year < 1000) { - PyErr_Format(PyExc_ValueError, "year=%ld is before " - "1000; the datetime strftime() " - "methods require year >= 1000", - year); - return NULL; - } - } - /* Scan the input format, looking for %z/%Z/%f escapes, building * a new format. Since computing the replacements for those codes * is expensive, don't unless they're actually used. |