Commit Graph

120 Commits

Author SHA1 Message Date
Serhiy Storchaka 314d6fca36 bpo-29953: Fix memory leaks in the replace() method of datetime and time (#927)
objects when pass out of bound fold argument.
2017-03-31 22:48:16 +03:00
Serhiy Storchaka ba85d69a3e bpo-29878: Add global instances of int for 0 and 1. (#852) 2017-03-30 09:09:41 +03:00
Victor Stinner 05e218c37d Merge 3.6 2017-02-10 10:34:37 +01:00
Victor Stinner b67f096738 Fix datetime.fromtimestamp(): check bounds
Issue #29100: Fix datetime.fromtimestamp() regression introduced in Python
3.6.0: check minimum and maximum years.
2017-02-10 10:34:02 +01:00
Victor Stinner 12bc0274a8 Merge 3.6 2017-01-03 23:47:39 +01:00
Victor Stinner 423c16b4c3 Issue #29140: Fix hash(datetime.time)
Fix time_hash() function: replace DATE_xxx() macros with TIME_xxx() macros.
Before, the hash function used a wrong value for microseconds if fold is set
(equal to 1).
2017-01-03 23:47:12 +01:00
Serhiy Storchaka 5ab81d787f Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of dict. 2016-12-16 16:18:57 +02:00
Victor Stinner 20401deae2 Use _PyObject_CallMethodIdObjArgs() in _datetime
Issue #28915: Replace _PyObject_CallMethodId() with
_PyObject_CallMethodIdObjArgs() when the format string was only made of "O"
formats, PyObject* arguments.

_PyObject_CallMethodIdObjArgs() avoids the creation of a temporary tuple and
doesn't have to parse a format string.
2016-12-09 15:24:31 +01:00
Victor Stinner ddc120f4cf Fix refleak introduced in change 032cbdb596fe
Issue #28915.
2016-12-09 15:35:40 +01:00
Victor Stinner 2b635971e7 build_struct_time() uses Py_BuildValue()
Issue #28915: Avoid calling _PyObject_CallMethodId() with "(...)" format to
avoid the creation of a temporary tuple: use Py_BuildValue() with
_PyObject_CallMethodIdObjArgs().
2016-12-09 00:38:16 +01:00
Victor Stinner 4c38154a43 Don't parenthesis in _PyObject_CallMethodId() format
Issue #28915: Without parenthesis, _PyObject_CallMethodId() avoids the creation
a temporary tuple, and so is more efficient.
2016-12-09 00:33:39 +01:00
Serhiy Storchaka e425bd95e9 Issue #28752: Restored the __reduce__() methods of datetime objects. 2016-11-22 00:30:32 +02:00
Serhiy Storchaka 546ce65968 Issue #28752: Restored the __reduce__() methods of datetime objects. 2016-11-22 00:29:42 +02:00
Serhiy Storchaka a98c4a984b Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize
with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
2016-11-20 09:13:40 +02:00
Serhiy Storchaka 06515833fe Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize
with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
2016-11-20 09:13:07 +02:00
Serhiy Storchaka f8d7d41507 Issue #28511: Use the "U" format instead of "O!" in PyArg_Parse*. 2016-10-23 15:12:25 +03:00
Alexander Belopolsky 3e7a3cb903 Issue #28148: Stop using localtime() and gmtime() in the time module.
Introduced platform independent _PyTime_localtime API that is similar
to POSIX localtime_r, but available on all platforms.  Patch by Ed
Schouten.
2016-09-28 17:31:35 -04:00
Benjamin Peterson ac965ca16c stop using Py_LL and Py_ULL 2016-09-18 18:12:21 -07:00
Alexander Belopolsky 130bbe5fd3 #28067: Fixed another typo. 2016-09-10 16:51:17 -04:00
Alexander Belopolsky abd143b23b #28067: Fixed a typo. 2016-09-10 16:08:26 -04:00
Alexander Belopolsky 6d88fa5c05 Closes #28067: Do not call localtime (gmtime) in datetime module. 2016-09-10 15:58:31 -04:00
Benjamin Peterson dec2df3df3 fix dummy macro 2016-09-09 17:46:24 -07:00
Benjamin Peterson af580dff4a replace PY_LONG_LONG with long long 2016-09-06 10:46:49 -07:00
Victor Stinner ad8c83ad6b Avoid inefficient way to call functions without argument
Don't pass "()" format to PyObject_CallXXX() to call a function without
argument: pass NULL as the format string instead. It avoids to have to parse a
string to produce 0 argument.
2016-09-05 17:53:15 -07:00
Victor Stinner d1584d3e7e Issue #27809: tzinfo_reduce() uses fast call 2016-08-23 00:11:04 +02:00
Alexander Belopolsky 47649ab1f1 Closes #27710: Disallow fold not in [0, 1] in time and datetime constructors. 2016-08-08 17:05:40 -04:00
Alexander Belopolsky 43746c3770 Closes #27661: Added tzinfo keyword argument to datetime.combine. 2016-08-02 17:49:30 -04:00
Alexander Belopolsky 8e1d3a2d41 Issue 24773: Added a time_t overflow check. 2016-07-25 13:54:51 -04:00
Alexander Belopolsky 5d0c598382 Closes issue #24773: Implement PEP 495 (Local Time Disambiguation). 2016-07-22 18:47:04 -04:00
Martin Panter 0b7d84de6b Issue #27171: Merge typo fixes from 3.5 2016-06-02 10:11:18 +00:00
Martin Panter e26da7c03a Issue #27171: Fix typos in documentation, comments, and test function names 2016-06-02 10:07:09 +00:00
Martin Panter 3e04d5b306 Issue #27076: Merge spelling from 3.5 2016-05-26 06:03:19 +00:00
Martin Panter 46f50726a0 Issue #27076: Doc, comment and tests spelling fixes
Most fixes to Doc/ and Lib/ directories by Ville Skyttä.
2016-05-26 05:35:26 +00:00
Serhiy Storchaka f01e408c16 Issue #26200: Added Py_SETREF and replaced Py_XSETREF with Py_SETREF
in places where Py_DECREF was used.
2016-04-10 18:12:01 +03:00
Serhiy Storchaka ec39756960 Issue #22570: Renamed Py_SETREF to Py_XSETREF. 2016-04-06 09:50:03 +03:00
Alexander Belopolsky 16b698b095 merge 2016-03-25 15:46:55 -04:00
Alexander Belopolsky 1dcf4f9ee5 Issue#26616:Fixed a bug in datetime.astimezone() method. 2016-03-25 15:42:59 -04:00
Alexander Belopolsky a2998a63c8 Closes #19475: Added timespec to the datetime.isoformat() method.
Added an optional argument timespec to the datetime isoformat() method
to choose the precision of the time component.

Original patch by Alessandro Cucci.
2016-03-06 14:58:43 -05:00
Serhiy Storchaka 576f132b98 Issue #20440: Cleaning up the code by using Py_SETREF. 2016-01-05 21:27:54 +02:00
Serhiy Storchaka ef1585eb9a Issue #25923: Added more const qualifiers to signatures of static and private functions. 2015-12-25 20:01:53 +02:00
Serhiy Storchaka 2d06e84455 Issue #25923: Added the const qualifier to static constant arrays. 2015-12-25 19:53:18 +02:00
Serhiy Storchaka fad85aadb0 Issue #25558: Use compile-time asserts. 2015-11-07 15:42:38 +02:00
Alexander Belopolsky 365ba8f6c1 Closes issue #23600: Wrong results from tzinfo.fromutc(). 2015-09-27 22:32:15 -04:00
Alexander Belopolsky d19b5042ff Closes issue #23600: Wrong results from tzinfo.fromutc(). 2015-09-27 21:56:53 -04:00
Alexander Belopolsky c58c2cb392 Closes issue #23600: Wrong results from tzinfo.fromutc(). 2015-09-27 21:56:09 -04:00
Alexander Belopolsky c79447b267 Closes issue #23600: Wrong results from tzinfo.fromutc(). 2015-09-27 21:41:55 -04:00
Victor Stinner 84ff4abd79 Merge 3.4 (datetime rounding) 2015-09-18 14:50:18 +02:00
Victor Stinner 511491ade0 Issue #23517: Fix rounding in fromtimestamp() and utcfromtimestamp() methods
of datetime.datetime: microseconds are now rounded to nearest with ties going
to nearest even integer (ROUND_HALF_EVEN), instead of being rounding towards
zero (ROUND_DOWN). It's important that these methods use the same rounding
mode than datetime.timedelta to keep the property:

   (datetime(1970,1,1) + timedelta(seconds=t)) == datetime.utcfromtimestamp(t)

It also the rounding mode used by round(float) for example.

Add more unit tests on the rounding mode in test_datetime.
2015-09-18 14:42:05 +02:00
Victor Stinner 9a8b177e60 Issue #25155: Add _PyTime_AsTimevalTime_t() function
On Windows, the tv_sec field of the timeval structure has the type C long,
whereas it has the type C time_t on all other platforms. A C long has a size of
32 bits (signed inter, 1 bit for the sign, 31 bits for the value) which is not
enough to store an Epoch timestamp after the year 2038.

Add the _PyTime_AsTimevalTime_t() function written for datetime.datetime.now():
convert a _PyTime_t timestamp to a (secs, us) tuple where secs type is time_t.
It allows to support dates after the year 2038 on Windows.

Enhance also _PyTime_AsTimeval_impl() to detect overflow on the number of
seconds when rounding the number of microseconds.
2015-09-18 13:36:17 +02:00
Victor Stinner 1e2b6882fc Issue #25155: Add _PyTime_AsTimevalTime_t() function
On Windows, the tv_sec field of the timeval structure has the type C long,
whereas it has the type C time_t on all other platforms. A C long has a size of
32 bits (signed inter, 1 bit for the sign, 31 bits for the value) which is not
enough to store an Epoch timestamp after the year 2038.

Add the _PyTime_AsTimevalTime_t() function written for datetime.datetime.now():
convert a _PyTime_t timestamp to a (secs, us) tuple where secs type is time_t.
It allows to support dates after the year 2038 on Windows.

Enhance also _PyTime_AsTimeval_impl() to detect overflow on the number of
seconds when rounding the number of microseconds.
2015-09-18 13:23:02 +02:00