Victor Stinner [Fri, 27 Mar 2015 12:31:18 +0000 (13:31 +0100)]
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.
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.
Victor Stinner [Wed, 25 Mar 2015 00:54:46 +0000 (01:54 +0100)]
Issue #23571: Fix reentrant call to Py_FatalError()
Flushing sys.stdout and sys.stderr in Py_FatalError() can call again
Py_FatalError(). Add a reentrant flag to detect this case and just abort at the
second call.
Serhiy Storchaka [Tue, 24 Mar 2015 20:28:43 +0000 (22:28 +0200)]
Issue #23671: string.Template now allows to specify the "self" parameter as
keyword argument. string.Formatter now allows to specify the "self" and
the "format_string" parameters as keyword arguments.
Victor Stinner [Tue, 24 Mar 2015 12:44:35 +0000 (13:44 +0100)]
Issue #23571: Py_FatalError() now tries to flush sys.stdout and sys.stderr
It should help to see exceptions when stderr if buffered: PyErr_Display() calls
sys.stderr.write(), it doesn't write into stderr file descriptor directly.
Victor Stinner [Tue, 24 Mar 2015 10:24:06 +0000 (11:24 +0100)]
Issue #23571: Enhance Py_FatalError()
* Display the current Python stack if an exception was raised but the exception
has no traceback
* Disable faulthandler if an exception was raised (before it was only disabled
if no exception was raised)
* To display the current Python stack, call PyGILState_GetThisThreadState()
which works even if the GIL was released
Serhiy Storchaka [Sun, 22 Mar 2015 07:46:36 +0000 (09:46 +0200)]
Issue #22079: Deprecation warning now is issued in PyType_Ready() instead of
raising TypeError when statically allocated type subclasses dynamically
allocated type
Serhiy Storchaka [Sat, 21 Mar 2015 07:40:26 +0000 (09:40 +0200)]
Issue #22351: The nntplib.NNTP constructor no longer leaves the connection
and socket open until the garbage collector cleans them up. Patch by
Martin Panter.
Victor Stinner [Wed, 25 Mar 2015 00:55:14 +0000 (01:55 +0100)]
(Merge 3.4) Issue #23571: Fix reentrant call to Py_FatalError()
Flushing sys.stdout and sys.stderr in Py_FatalError() can call again
Py_FatalError(). Add a reentrant flag to detect this case and just abort at the
second call.
Serhiy Storchaka [Tue, 24 Mar 2015 20:58:14 +0000 (22:58 +0200)]
Issue #23622: Unknown escapes in regular expressions that consist of ``'\'``
and ASCII letter now raise a deprecation warning and will be forbidden in
Python 3.6.
Serhiy Storchaka [Tue, 24 Mar 2015 20:30:46 +0000 (22:30 +0200)]
Issue #23671: string.Template now allows to specify the "self" parameter as
keyword argument. string.Formatter now allows to specify the "self" and
the "format_string" parameters as keyword arguments.
Serhiy Storchaka [Tue, 24 Mar 2015 19:55:47 +0000 (21:55 +0200)]
Issue #23573: Increased performance of string search operations (str.find,
str.index, str.count, the in operator, str.split, str.partition) with
arguments of different kinds (UCS1, UCS2, UCS4).
Serhiy Storchaka [Tue, 24 Mar 2015 16:06:42 +0000 (18:06 +0200)]
Issue #20289: The copy module now uses pickle protocol 4 (PEP 3154) and
supports copying of instances of classes whose __new__ method takes
keyword-only arguments.
Victor Stinner [Tue, 24 Mar 2015 15:28:52 +0000 (16:28 +0100)]
Issue #23571: Enhance _Py_CheckFunctionResult()
Too bad, sometimes Py_FatalError() is unable to write the exception into
sys.stderr (on "AMD64 OpenIndiana 3.x" buildbot, the buildbot was probably out
of memory).
Call Py_FatalError() with a different message for the two cases (result+error,
or no result and no error).
Victor Stinner [Tue, 24 Mar 2015 12:46:18 +0000 (13:46 +0100)]
(Merge 3.4) Issue #23571: Py_FatalError() now tries to flush sys.stdout and
sys.stderr
It should help to see exceptions when stderr if buffered: PyErr_Display() calls
sys.stderr.write(), it doesn't write into stderr file descriptor directly.
Victor Stinner [Tue, 24 Mar 2015 11:53:59 +0000 (12:53 +0100)]
Issue #23571: In debug mode, _Py_CheckFunctionResult() now calls
Py_FatalError() instead of using an assertion in debug mode. Py_FatalError()
displays the current exception and the traceback which contain more information
than just the assertion error.
Victor Stinner [Tue, 24 Mar 2015 11:41:23 +0000 (12:41 +0100)]
Issue #23571: PyErr_FormatV() and PyErr_SetObject() now always clear the
current exception because they can run arbitrary Python code and so no
exception must be set.
Victor Stinner [Tue, 24 Mar 2015 11:16:28 +0000 (12:16 +0100)]
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.
Victor Stinner [Tue, 24 Mar 2015 11:01:30 +0000 (12:01 +0100)]
(Merge 3.4) Issue #23571: Enhance Py_FatalError()
* Display the current Python stack if an exception was raised but the exception
has no traceback
* Disable faulthandler if an exception was raised (before it was only disabled
if no exception was raised)
* To display the current Python stack, call PyGILState_GetThisThreadState()
which works even if the GIL was released
Serhiy Storchaka [Mon, 23 Mar 2015 12:59:48 +0000 (14:59 +0200)]
Issue #23688: Added support of arbitrary bytes-like objects and avoided
unnecessary copying of memoryview in gzip.GzipFile.write().
Original patch by Wolfgang Maier.
Victor Stinner [Sat, 21 Mar 2015 14:04:43 +0000 (15:04 +0100)]
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.
Serhiy Storchaka [Sat, 21 Mar 2015 07:41:19 +0000 (09:41 +0200)]
Issue #22351: The nntplib.NNTP constructor no longer leaves the connection
and socket open until the garbage collector cleans them up. Patch by
Martin Panter.
Serhiy Storchaka [Fri, 20 Mar 2015 18:04:21 +0000 (20:04 +0200)]
Issue #22832: Tweaked parameter names for fcntl module to better match
official POSIX documentation. Updated the documenttion for Python 3.
Patch by Alex Shkop.
R David Murray [Fri, 20 Mar 2015 15:31:38 +0000 (11:31 -0400)]
#11726: Make linecache docs reflect that all files are treated the same.
Being able to read non-python text files is not a purpose of linecache, but it
does work and people use it. This changeset adjusts the language to make it
clear that Python files are not treated uniquely, but does not go so far as to
say reading non-python files is explicitly supported.