Commit graph

9443 commits

Author SHA1 Message Date
Raymond Hettinger
c22eee6b59 Precomputing the number iterations allows the inner-loop to be vectorizable. 2015-09-26 02:14:50 -07:00
Raymond Hettinger
7a84552c84 Hoist constant expression out of an inner loop. 2015-09-26 01:30:51 -07:00
Raymond Hettinger
e055b88937 merge 2015-09-26 00:15:46 -07:00
Raymond Hettinger
bf49fee125 Issue #25135: Avoid possible reentrancy issues in deque_clear. 2015-09-26 00:14:59 -07:00
Benjamin Peterson
5b8854eee0 merge 3.5 2015-09-26 00:09:39 -07:00
Benjamin Peterson
03c59b9bef merge 3.4 2015-09-26 00:09:32 -07:00
Benjamin Peterson
e48cf7e729 prevent overflow in _Unpickler_Read 2015-09-26 00:08:34 -07:00
Raymond Hettinger
2b0d646b75 Replace an unpredictable branch with a simple addition. 2015-09-23 19:15:44 -07:00
Raymond Hettinger
3a1a8d0424 Eliminate unnecessary variables 2015-09-23 02:42:02 -07:00
Steve Dower
8ef1db34bb Merge with 3.5 2015-09-22 17:01:17 -07:00
Steve Dower
57ab1cdb15 Issue #25092: Fix datetime.strftime() failure when errno was already set to EINVAL. 2015-09-22 14:51:42 -07:00
Raymond Hettinger
7a237230d1 Eliminate unnecessary variable 2015-09-22 01:20:36 -07:00
Raymond Hettinger
d3d2b2c50c Minor consistency improvements to negative value comparisons. 2015-09-21 23:41:56 -07:00
Victor Stinner
5ebae87628 Issue #25207, #14626: Fix my commit.
It doesn't work to use #define XXX defined(YYY)" and then "#ifdef XXX"
to check YYY.
2015-09-22 01:29:33 +02:00
Victor Stinner
4552ced916 Issue #25207, #14626: Fix ICC compiler warnings in posixmodule.c
Replace "#if XXX" with #ifdef XXX".
2015-09-21 22:37:15 +02:00
Raymond Hettinger
aed8830af3 Add a fast path (no iterator creation) for a common case for repeating deques of size 1 2015-09-19 09:05:42 -07:00
Raymond Hettinger
0e14e6610b Hoist constant expression out of an inner loop 2015-09-19 00:21:33 -06: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
Victor Stinner
024364a89a Merge 3.5 (os.waitpid) 2015-09-15 10:24:27 +02:00
Victor Stinner
d3ffd32767 Issue #25118: Fix a regression of Python 3.5.0 in os.waitpid() on Windows.
Add an unit test on os.waitpid()
2015-09-15 10:11:03 +02:00
Raymond Hettinger
ad26225e1a Tighten inner-loop for deque_inplace_repeat(). 2015-09-14 01:03:04 -04:00
Raymond Hettinger
e4f3467df1 Add an exact type match fast path for deque_copy(). 2015-09-13 19:27:01 -04:00
Raymond Hettinger
95e2cc5d12 Fix refcount. 2015-09-13 02:41:18 -04:00
Kristján Valur Jónsson
3d6e7b0e34 Merge 2015-09-12 16:41:22 +00:00
Kristján Valur Jónsson
a8a930f863 Issue #25021: Merge 3.5 to default 2015-09-12 16:36:15 +00:00
Kristján Valur Jónsson
d7f65e5763 Issue #25021: Merge 3.4 to 3.5 2015-09-12 16:34:33 +00:00
Kristján Valur Jónsson
95c3e6cb22 Issue #25021: Merge from 3.3 to 3.4 2015-09-12 15:30:23 +00:00
Kristján Valur Jónsson
102764a1f6 Issue #25021: Correctly make sure that product.__setstate__ does not access
invalid memory.
2015-09-12 15:20:54 +00:00
Raymond Hettinger
67c78b5421 In-line the append operations inside deque_inplace_repeat(). 2015-09-12 11:00:20 -04:00
Victor Stinner
e390410ca4 Merge 3.5 2015-09-11 12:38:27 +02:00
Victor Stinner
f9fdfa7c4e Merge 3.4 2015-09-11 12:38:17 +02:00
Victor Stinner
ec1a498a01 Issue #24684: socket.socket.getaddrinfo() now calls
PyUnicode_AsEncodedString() instead of calling the encode() method of the
host, to handle correctly custom string with an encode() method which doesn't
return a byte string. The encoder of the IDNA codec is now called directly
instead of calling the encode() method of the string.
2015-09-11 12:37:30 +02:00
Martin Panter
db4220ea09 Issue #25030: Do not document seek() as if it accepts keyword arguments
Patch from Shiyao Ma.
2015-09-11 03:58:30 +00:00
Victor Stinner
4237d3474c Fix test_time on platform with 32-bit time_t type
Filter values which would overflow when converted to a C time_t type.
2015-09-10 10:10:39 +02:00
Raymond Hettinger
f5d72f35e8 Simply deque repeat by reusing code in in-line repeat. Avoid unnecessary division. 2015-09-09 22:39:44 -04:00
Larry Hastings
334b4a3403 Merge from 3.5. 2015-09-09 07:00:54 -07:00
Larry Hastings
ded28e3863 Merge Python 3.5.0rc4 back to hg.python.org. 2015-09-09 06:52:38 -07:00
Martin Panter
3f560c16e5 Merge 3.5 into 3.6 2015-09-09 06:28:08 +00:00
Martin Panter
6088b7bd49 Merge 3.4 into 3.5 2015-09-09 06:27:43 +00:00
Martin Panter
9499413508 os.sendfile(headers=None, trailers=None) arguments are not actually accepted
Needs to be tested on a BSD.
2015-09-09 05:29:24 +00:00
Martin Panter
a122b5a1fd Issue #23738: Merge 3.5 into 3.6 2015-09-09 03:01:17 +00:00
Steve Dower
97cded934f Issue #25029: MemoryError in test_strptime 2015-09-08 19:12:51 -07:00
Martin Panter
0ff89099c7 Issue #23738: Merge 3.4 into 3.5 2015-09-09 01:56:53 +00:00
Martin Panter
bf19d16950 Issue #23738: Document and test actual keyword parameter names
Also fix signature because os.utime(..., ns=None) is not allowed.
2015-09-09 01:01:13 +00:00
Victor Stinner
7667f58151 Issue #23517: fromtimestamp() and utcfromtimestamp() methods of
datetime.datetime now round microseconds to nearest with ties going to nearest
even integer (ROUND_HALF_EVEN), as round(float), instead of rounding towards
-Infinity (ROUND_FLOOR).

pytime API: replace _PyTime_ROUND_HALF_UP with _PyTime_ROUND_HALF_EVEN. Fix
also _PyTime_Divide() for negative numbers.

_PyTime_AsTimeval_impl() now reuses _PyTime_Divide() instead of reimplementing
rounding modes.
2015-09-09 01:02:23 +02:00
Victor Stinner
69cc487df4 Revert change 0eb8c182131e:
"""Issue #23517: datetime.timedelta constructor now rounds microseconds to
nearest with ties going away from zero (ROUND_HALF_UP), as Python 2 and Python
older than 3.3, instead of rounding to nearest with ties going to nearest even
integer (ROUND_HALF_EVEN)."""

datetime.timedelta uses rounding mode ROUND_HALF_EVEN again.
2015-09-08 23:58:54 +02:00
Victor Stinner
90fd895197 Issue #22241: Fix a compiler waring 2015-09-08 00:12:49 +02:00