summaryrefslogtreecommitdiffstats
path: root/Modules/datetimemodule.c
Commit message (Collapse)AuthorAgeFilesLines
* [2.7] bpo-35021: Fix assertion failures in _datetimemodule.c. (GH-10039) ↵Serhiy Storchaka2018-11-201-46/+50
| | | | | | | | | | | | | (GH-10617) Fixes assertion failures in _datetimemodule.c introduced in the previous fix (see bpo-31752). Rather of trying to handle an int subclass as exact int, let it to use overridden special methods, but check the result of divmod(). (cherry picked from commit 3ec0f495163da3b7a15deb2805cec48aed432f58) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [2.7] bpo-34234: Use _PyAnyInt_Check() and _PyAnyInt_CheckExact(). (GH-8479)Serhiy Storchaka2018-07-311-10/+10
|
* [2.7] bpo-31752: Fix possible crash in timedelta constructor called with ↵Serhiy Storchaka2017-10-231-2/+7
| | | | | | custom integers. (GH-3947) (#4088) Bad remainder in divmod() in intermediate calculations caused an assertion failure.. (cherry picked from commit 4ffd4653a7ec9c97775472276cf5e159e2366bb2)
* consistently use Py_TYPE, Py_REFCNT, and correct initializer macros (#3563)Benjamin Peterson2017-09-141-6/+3
| | | This no-op change makes 2.7 more consistent with 3.x to ease comparison and backports.
* Issue #22463: Backport compiler warning fixes and workaroundsMartin Panter2016-06-211-2/+2
| | | | | | | | | | | | | | * Set but unused variable in Parser/pgen.c in non-debug builds. Patch by Christian Heimes. * Unused static function in Modules/readline.c. Patch by Georg Brandl. * main_window unused in Modules/tkappinit.c. Patch by Gregory P. Smith. * Dead assignment in Modules/_ctypes/cfield.c. Extracted from patch by Brett Cannon. * Expression result unused in PyObject_INIT macro expansions. Based on patches by Christian Heimes. * Load expat_config.h and therefore pyconfig.h before C stdlib headers are loaded. This silences pre-processor warnings including '_POSIX_C_SOURCE redefined'. Extracted from patch by Christian Heimes.
* Issue #27076: Doc, comment and test function name spelling fixesMartin Panter2016-05-261-1/+1
| | | | Most fixes to Doc/ and Lib/ directories by Ville Skyttä.
* Issue #11576: Fixed timedelta subtraction glitch on big timedelta valuesAlexander Belopolsky2011-04-061-7/+8
|
* Revert r81681 (issue 8810).Alexander Belopolsky2010-07-031-2/+1
|
* Issue8810: Clearing up docstring for tzinfo.utcoffset.Sean Reifscheider2010-06-041-1/+2
|
* Issue #7150: Raise OverflowError if the result of adding or subtractingAlexander Belopolsky2010-05-271-13/+16
| | | | timedelta from date or datetime falls outside of the MINYEAR:MAXYEAR range.
* Untabify C files. Will watch buildbots.Antoine Pitrou2010-05-091-3361/+3361
|
* Issue #8644: Improve accuracy of timedelta.total_seconds method.Mark Dickinson2010-05-091-3/+19
| | | | (Backport of r80979 to py3k.) Thanks Alexander Belopolsky.
* Prevent a possible NULL de-reference and an unneeded variable assignment.Brett Cannon2010-05-041-2/+2
| | | | Found using Clang's static analyzer.
* Fix a gcc warning introduced by r79397.Victor Stinner2010-03-251-1/+1
|
* Backported PyCapsule from 3.1, and converted most uses ofLarry Hastings2010-03-251-5/+4
| | | | CObject to PyCapsule.
* #7413: Passing '\0' as the separator to datetime.datetime.isoformat()Amaury Forgeot d'Arc2009-12-291-9/+14
| | | | used to drop the time part of the result.
* Issue #5788: `datetime.timedelta` objects get a new `total_seconds()` method ↵Antoine Pitrou2009-11-251-1/+12
| | | | | | returning the total number of seconds in the duration. Patch by Brian Quinlan.
* Merge in release25-maint r60793:Gregory P. Smith2008-06-111-0/+7
| | | | | | Added checks for integer overflows, contributed by Google. Some are only available if asserts are left in the code, in cases where they can't be triggered from Python code.
* More reverting of r63675 per the mailing list discussions. This restoresGregory P. Smith2008-06-101-2/+2
| | | | | occurances of PyBytes_ in the code to their original PyString_ names. The bytesobject.c file will be renamed back to stringobject.c in a future checkin.
* This reverts r63675 based on the discussion in this thread:Gregory P. Smith2008-06-091-56/+56
| | | | | | | http://mail.python.org/pipermail/python-dev/2008-June/079988.html Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names in the spirit of 3.0 are available via a #define only. See the email thread.
* Fix issue 2782: be less strict about the format string type in strftime.Gregory P. Smith2008-06-021-21/+25
| | | | | Accept unicode and anything else ParseTuple "s#" can deal with. This matches the time.strftime behavior.
* Renamed PyString to PyBytesChristian Heimes2008-05-261-63/+63
|
* Use a buffer large enough to ensure we don't overrun, even if the valueNeal Norwitz2008-03-171-1/+1
| | | | is outside the range we expect.
* add %f format to datetime - issue 1158Skip Montanaro2008-03-151-24/+78
|
* Backport of PEP 3101, Advanced String Formatting, from py3k.Eric Smith2008-02-171-0/+32
| | | | | | | | | | | | | | | Highlights: - Adding PyObject_Format. - Adding string.Format class. - Adding __format__ for str, unicode, int, long, float, datetime. - Adding builtin format. - Adding ''.format and u''.format. - str/unicode fixups for formatters. The files in Objects/stringlib that implement PEP 3101 (stringdefs.h, unicodedefs.h, formatter.h, string_format.h) are identical in trunk and py3k. Any changes from here on should be made to trunk, and changes will propogate to py3k).
* Modified PyImport_Import and PyImport_ImportModule to always use absolute ↵Christian Heimes2008-01-031-4/+4
| | | | | | imports by calling __import__ with an explicit level of 0 Added a new API function PyImport_ImportModuleNoBlock. It solves the problem with dead locks when mixing threads and imports
* #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and ↵Christian Heimes2007-12-191-22/+22
| | | | Py_REFCNT. Macros for b/w compatibility are available.
* PEP 3123: Provide forward compatibility with Python 3.0, while keepingMartin v. Löwis2007-07-211-26/+24
| | | | | backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
* Stop using METH_OLDARGS implicitlyNeal Norwitz2007-05-221-9/+9
|
* Complete revamp of PCBuild8 directory. Use subdirectories for each project ↵Kristján Valur Jónsson2007-04-301-0/+2
| | | | under the main pcbuild solution. Now make extensive use of property sheets to simplify project configuration. x64 build fully supported, and the process for building PGO version (Profiler Guided Optimization) simplified. All projects are now present, except _ssl, which needs to be reimplemented. Also, some of the projects that require external libraries need extra work to fully compile on x64.
* Patch #1646728: datetime.fromtimestamp fails with negativeGuido van Rossum2007-03-061-0/+6
| | | | | | fractional times. With unittest. Somebody please backport to 2.5.
* Bug #1653736: Complain about keyword arguments to time.isoformat.Martin v. Löwis2007-02-081-2/+2
| | | | Will backport to 2.5.
* Bug #1556784: allow format strings longer than 127 characters inGeorg Brandl2006-09-301-2/+2
| | | | datetime's strftime function.
* Bug #1478429: make datetime.datetime.fromtimestamp accept every float,Georg Brandl2006-04-281-0/+7
| | | | possibly "rounding up" to the next whole second.
* C++ compiler cleanup: "typename" is a C++ keywordSkip Montanaro2006-04-181-11/+11
|
* Coverity-found bug: datetime_strptime() failed to check for NULL return fromThomas Wouters2006-04-141-0/+4
| | | | | | PySequence_GetItem of the time.strptime() result. Not a high probability bug, but not inconceivable either, considering people can provide their own 'time' module.
* Fix problem spotted by Coverity that occurs if tzinfo.tzname().replace()Neal Norwitz2006-03-201-4/+9
| | | | | | returns a non-string when converting %Z. Will backport.
* More unconsting.Martin v. Löwis2006-02-271-11/+11
|
* Remove two instances of trailing commas. Resolves patch #1209781.Georg Brandl2006-02-191-1/+1
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-2/+2
|
* Check return result from Py_InitModule*(). This API can fail.Neal Norwitz2006-01-191-0/+2
| | | | Probably should be backported.
* Add const to several API functions that take char *.Jeremy Hylton2005-12-101-16/+16
| | | | | | | | | | | | | | | | | | | In C++, it's an error to pass a string literal to a char* function without a const_cast(). Rather than require every C++ extension module to put a cast around string literals, fix the API to state the const-ness. I focused on parts of the API where people usually pass literals: PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type slots, etc. Predictably, there were a large set of functions that needed to be fixed as a result of these changes. The most pervasive change was to make the keyword args list passed to PyArg_ParseTupleAndKewords() to be a const char *kwlist[]. One cast was required as a result of the changes: A type object mallocs the memory for its tp_doc slot and later frees it. PyTypeObject says that tp_doc is const char *; but if the type was created by type_new(), we know it is safe to cast to char *.
* similar to SF bug 847019: a quick check in the time() constructor, whichArmin Rigo2005-11-071-1/+2
| | | | | | accepts strings only for unpickling reasons. This check prevents the honest mistake of passing a string like '2:59.0' to time() and getting an insane object.
* Add strptime() constructor to datetime class. Thanks to Josh Spoerri forSkip Montanaro2005-01-131-0/+45
| | | | the changes.
* Bug #1087216: datetime module documentation missing critical detailRaymond Hettinger2004-12-191-3/+9
|
* SF bug #1028306: date-datetime comparisonTim Peters2004-09-161-1/+11
| | | | Treat comparing a date to a datetime like a mixed-type comparison.
* SF patch 876130: add C API to datetime module, from Anthony Tuininga.Tim Peters2004-06-201-0/+30
| | | | | | The LaTeX is untested (well, so is the new API, for that matter). Note that I also changed NULL to get spelled consistently in concrete.tex. If that was a wrong thing to do, Fred should yell at me.
* Bug 975996: Add _PyTime_DoubleToTimet to C APITim Peters2004-06-201-5/+15
| | | | | | | | | | | New include file timefuncs.h exports private API function _PyTime_DoubleToTimet() from timemodule.c. timemodule should export some other functions too (look for painful bits in datetimemodule.c). Added insane-argument checking to datetime's assorted fromtimestamp() and utcfromtimestamp() methods. Added insane-argument tests of these to test_datetime, and insane-argument tests for ctime(), localtime() and gmtime() to test_time.
* SF 952807: Unpickling pickled instances of subclasses of datetime.date,Tim Peters2004-06-071-6/+3
| | | | | | | datetime.datetime and datetime.time could yield insane objects. Thanks to Jiwon Seo for the fix. Bugfix candidate. I'll backport it to 2.3.
* SF bug 847019 datetime.datetime initialization needs more strict checkingTim Peters2004-03-211-2/+10
| | | | | | | | | It's possible to create insane datetime objects by using the constructor "backdoor" inserted for fast unpickling. Doing extensive range checking would eliminate the backdoor's purpose (speed), but at least a little checking can stop honest mistakes. Bugfix candidate.