Commit Graph

8632 Commits

Author SHA1 Message Date
Victor Stinner f70e1ca0fc Issue #23485: select.select() is now retried automatically with the recomputed
timeout when interrupted by a signal, except if the signal handler raises an
exception. This change is part of the PEP 475.

The asyncore and selectors module doesn't catch the InterruptedError exception
anymore when calling select.select(), since this function should not raise
InterruptedError anymore.
2015-03-30 21:16:11 +02:00
Victor Stinner e134a7fe36 Issue #23752: _Py_fstat() is now responsible to raise the Python exception
Add _Py_fstat_noraise() function when a Python exception is not welcome.
2015-03-30 10:09:31 +02:00
Serhiy Storchaka 2e1c4e5db2 Issue #23785: Fixed memory leak in TextIOWrapper.tell() in rare circumstances. 2015-03-30 10:00:40 +03:00
Serhiy Storchaka 04d09ebd39 Issue #23785: Fixed memory leak in TextIOWrapper.tell() in rare circumstances. 2015-03-30 09:58:41 +03:00
Serhiy Storchaka 7901b48a1f Issue #23171: csv.Writer.writerow() now supports arbitrary iterables. 2015-03-30 09:09:54 +03:00
Victor Stinner a695f83f0d Issue #22117: Remove _PyTime_ROUND_DOWN and _PyTime_ROUND_UP rounding methods
Use _PyTime_ROUND_FLOOR and _PyTime_ROUND_CEILING instead.
2015-03-30 03:57:14 +02:00
Victor Stinner 869e1778c0 Issue #22117: Replace usage of _PyTime_ROUND_UP with _PyTime_ROUND_CEILING
All these functions only accept positive timeouts, so this change has no effect
in practice.
2015-03-30 03:49:14 +02:00
Victor Stinner bcdd777d3c Issue #22117: Add _PyTime_ROUND_CEILING rounding method for timestamps
Add also more tests for ROUNd_FLOOR.
2015-03-30 03:52:49 +02:00
Victor Stinner 520bddf79a Issue #23752: When built from an existing file descriptor, io.FileIO() now only
calls fstat() once. Before fstat() was called twice, which was not necessary.
2015-03-30 03:21:06 +02:00
Victor Stinner ea9c0dd2c2 Issue #22117: Fix usage of _PyTime_AsTimeval()
Add _PyTime_AsTimeval_noraise() function. Call it when it's not possible (or
not useful) to raise a Python exception on overflow.
2015-03-30 02:51:13 +02:00
Victor Stinner 160e819a1d Issue #23694: Fix usage of _Py_open() in the _posixsubprocess module
Don't call _Py_open() from _close_open_fds_safe() because it is call just after
fork(). It's not good to play with locks (the GIL) between fork() and exec().

Use instead _Py_open_noraise() which doesn't touch to the GIL.
2015-03-30 02:18:31 +02:00
Victor Stinner e4a994d617 Issue #22117: Fix rounding of fromtimestamp() methods of datetime.datetime and
datetime.time: round towards minus infinity ("floor") instead of rounding
towards zero ("down").
2015-03-30 01:10:14 +02:00
Victor Stinner dca028b86a Issue #22117: Fix os.utime(), it now rounds the timestamp towards minus
infinity (-inf) instead of rounding towards zero.

Replace _PyTime_ROUND_DOWN with _PyTime_ROUND_FLOOR.
2015-03-30 01:02:57 +02:00
Victor Stinner 09e5cf28ae Issue #22117: Use the _PyTime_t API in _datetime.datetime() constructor
* Remove _PyTime_gettimeofday()
* Add _PyTime_GetSystemClock()
2015-03-30 00:09:18 +02:00
Serhiy Storchaka 07360df481 Issue #14260: The groupindex attribute of regular expression pattern object
now is non-modifiable mapping.
2015-03-30 01:01:48 +03:00
Serhiy Storchaka bfbfc8deb2 Removed unintentional trailing spaces in text files. 2015-03-29 19:12:58 +03:00
Victor Stinner 02937aab13 Issue #22117: Add the new _PyTime_ROUND_FLOOR rounding method for the datetime
module. time.clock_settime() now uses this rounding method instead of
_PyTime_ROUND_DOWN to handle correctly dates before 1970.
2015-03-28 05:02:39 +01:00
Victor Stinner b3b4544070 Issue #22117: Use the _PyTime_t API for time.clock_settime()
Remove also the now unused _PyTime_AddDouble() function.
2015-03-28 04:09:41 +01:00
Victor Stinner c337838af7 Issue #22117: Use the new _PyTime_t API in the select module 2015-03-28 05:07:51 +01:00
Victor Stinner f5faad2bf0 Issue #22117: The thread module uses the new _PyTime_t timestamp API
Add also a new _PyTime_AsMicroseconds() function.

threading.TIMEOUT_MAX is now be smaller: only 292 years instead of 292,271
years on 64-bit system for example. Sorry, your threads will hang a *little
bit* shorter. Call me if you want to ensure that your locks wait longer, I can
share some tricks with you.
2015-03-28 03:52:05 +01:00
Victor Stinner e245231fab Issue #22117: Fix ssl to use _PyTime_t API on sock_timeout
I didn't notice that the ssl module uses private attributes of socket objects.
2015-03-28 03:00:46 +01:00
Victor Stinner 71694d5c8c Issue #22117: The socket module uses _PyTime_t timestamp for timeouts 2015-03-28 01:18:54 +01:00
Victor Stinner 95e9cef6f0 Issue #22117: Write unit tests for _PyTime_AsTimeval()
* _PyTime_AsTimeval() now ensures that tv_usec is always positive
* _PyTime_AsTimespec() now ensures that tv_nsec is always positive
* _PyTime_AsTimeval() now returns an integer on overflow instead of raising an
  exception
2015-03-28 01:26:47 +01:00
Victor Stinner b7df3144ef Issue #23618, #22117: refactor socketmodule.c
Move Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS inside internal_select_ex() to
prepare a switch to the _PyTime_t type and retry syscall on EINTR.
2015-03-27 22:59:32 +01:00
Victor Stinner 34dc0f46ae Issue #22117: The signal modules uses the new _PyTime_t API
* Add _PyTime_AsTimespec()
* Add unit tests for _PyTime_AsTimespec()
2015-03-27 18:19:03 +01:00
Victor Stinner 7181dec3f1 Issue #22117: The gc module now uses _PyTime_t timestamp 2015-03-27 17:47:53 +01:00
Victor Stinner a47b881d86 Issue #22117: time.time() now uses the new _PyTime_t API
* Add _PyTime_GetSystemClockWithInfo()
2015-03-27 18:16:17 +01:00
Victor Stinner 4bfb460d88 Issue #22117: time.monotonic() now uses the new _PyTime_t API
* Add _PyTime_FromNanoseconds()
* Add _PyTime_AsSecondsDouble()
* Add unit tests for _PyTime_AsSecondsDouble()
2015-03-27 22:27:24 +01:00
Victor Stinner 992c43fec9 Issue #22117: Fix rounding in _PyTime_FromSecondsObject()
* Rename _PyTime_FromObject() to _PyTime_FromSecondsObject()
* Add _PyTime_AsNanosecondsObject() and _testcapi.pytime_fromsecondsobject()
* Add unit tests
2015-03-27 17:12:45 +01:00
Victor Stinner cb29f0177c Issue #22117: Add a new Python timestamp format _PyTime_t to pytime.h
In practice, _PyTime_t is a number of nanoseconds. Its C type is a 64-bit
signed number. It's integer value is in the range [-2^63; 2^63-1]. In seconds,
the range is around [-292 years; +292 years]. In term of Epoch timestamp
(1970-01-01), it can store a date between 1677-09-21 and 2262-04-11.

The API has a resolution of 1 nanosecond and use integer number. With a
resolution on 1 nanosecond, 64-bit IEEE 754 floating point numbers loose
precision after 194 days. It's not the case with this API. The drawback is
overflow for values outside [-2^63; 2^63-1], but these values are unlikely for
most Python modules, except of the datetime module.

New functions:

- _PyTime_GetMonotonicClock()
- _PyTime_FromObject()
- _PyTime_AsMilliseconds()
- _PyTime_AsTimeval()

This change uses these new functions in time.sleep() to avoid rounding issues.

The new API will be extended step by step, and the old API will be removed step
by step. Currently, some code is duplicated just to be able to move
incrementally, instead of pushing a large change at once.
2015-03-27 13:31:18 +01:00
Serhiy Storchaka 632a77e6a3 Issue #22364: Improved some re error messages using regex for hints. 2015-03-25 21:03:47 +02:00
Serhiy Storchaka 7665be6087 Issue #21802: The reader in BufferedRWPair now is closed even when closing
writer failed in BufferedRWPair.close().
2015-03-24 23:21:57 +02:00
Victor Stinner 19276f184f Issue #23654: Fix faulthandler._stack_overflow() for the Intel C Compiler (ICC)
Issue #23654: Turn off ICC's tail call optimization for the stack_overflow
generator. ICC turns the recursive tail call into a loop.

Patch written by Matt Frank.
2015-03-23 21:20:27 +01:00
Steve Dower 2ea51c98db Closes #9445: Removes detection of GetFinalPathNameByHandle 2015-03-20 21:49:12 -07:00
Steve Dower ef42dae7fa Issue #23765: Remove IsBadStringPtr calls in ctypes
Also renames a local to avoid warnings about shadowing
2015-03-24 23:28:54 -07:00
Raymond Hettinger fef9c1b368 Fix typo 2015-03-24 21:12:57 -07:00
Raymond Hettinger 8dbbae2e52 Minor code and comment cleanups. 2015-03-24 21:01:50 -07:00
Serhiy Storchaka 8be6be427d Issue #21802: The reader in BufferedRWPair now is closed even when closing
writer failed in BufferedRWPair.close().
2015-03-24 23:23:28 +02:00
Victor Stinner 91afbb6088 Issue #23753: Move _Py_wstat() from Python/fileutils.c to Modules/getpath.c
I expected more users of _Py_wstat(), but in practice it's only used by
Modules/getpath.c. Move the function because it's not needed on Windows.
Windows uses PC/getpathp.c which uses the Win32 API (ex: GetFileAttributesW())
not the POSIX API.
2015-03-24 12:16:28 +01:00
Victor Stinner f329878e74 Issue #23753: Python doesn't support anymore platforms without stat() or
fstat(), these functions are always required.

Remove HAVE_STAT and HAVE_FSTAT defines, and stop supporting DONT_HAVE_STAT and
DONT_HAVE_FSTAT.
2015-03-24 10:27:50 +01:00
Raymond Hettinger 551350a79f Improve and fix-up comments. 2015-03-24 00:19:53 -07:00
Raymond Hettinger 0f1451c8c0 Issue 23744: Minor speed-up for deque.__bool__(). 2015-03-23 23:23:55 -07:00
Victor Stinner d1f3a002c3 Merge 3.4 (faulthandler ICC) 2015-03-23 21:21:00 +01:00
Serhiy Storchaka f07a4b663d Issue #21526: Tkinter now supports new boolean type in Tcl 8.5. 2015-03-23 00:47:45 +02:00
Victor Stinner efde146b0c Issue #23571: _Py_CheckFunctionResult() now gives the name of the function
which returned an invalid result (result+error or no result without error) in
the exception message.

Add also unit test to check that the exception contains the name of the
function.

Special case: the final _PyEval_EvalFrameEx() check doesn't mention the
function since it didn't execute a single function but a whole frame.
2015-03-21 15:04:43 +01:00
Raymond Hettinger 6921c13bbb Minor nit. Make the rotate() success/fail tests consistent. 2015-03-21 02:03:40 -07:00
Raymond Hettinger ac13ad6a32 For safety, wait to decref deleted values until the deque state has been restored. 2015-03-21 01:53:16 -07:00
Raymond Hettinger 0f6f94778a Fix minor formatting nits and remove unnecessary comment. 2015-03-21 01:42:10 -07:00
Raymond Hettinger 32ea16577d Issue 23704: Add index(), copy(), and insert() to deques. Register deques as a MutableSequence. 2015-03-21 01:37:37 -07:00
Raymond Hettinger 39dadf7abf Issue 23705: Improve the performance of __contains__ checks for deques. 2015-03-20 16:38:56 -07:00