Commit Graph

8810 Commits

Author SHA1 Message Date
Victor Stinner c7489a5595 Issue #23836: Fix the faulthandler module to handle reentrant calls
to its signal handlers.

Use also _Py_write_noraise() instead of write() to retry write() if it is
interrupted by a signal (fail with EINTR).

faulthandler.dump_traceback() also calls PyErr_CheckSignals() to call the
Python signal handler if a signal was received.
2015-04-01 18:48:58 +02:00
Victor Stinner 185fd33a17 Issue #23836: Use _Py_write_noraise() to retry on EINTR in child_exec() of
_posixsubprocess
2015-04-01 18:35:53 +02:00
Victor Stinner e72fe3995b Issue #23836: Use _Py_write_noraise() to retry on EINTR in trip_signal() of
signalmodule.c
2015-04-01 18:35:22 +02:00
Benjamin Peterson 81541f4480 merge 3.4 2015-04-01 12:37:34 -04:00
Victor Stinner 62d1c70eff Issue #22117, issue #23485: Fix _PyTime_AsMilliseconds() and
_PyTime_AsMicroseconds() rounding.

Add also unit tests.
2015-04-01 17:47:07 +02:00
Benjamin Peterson 4fd929b431 remove assignment in conditional 2015-04-01 11:16:40 -04:00
Victor Stinner a772662423 Issue #23618: Fix EINTR handling on Windows
Windows uses WSAEINTR error code, not EINTR, for socket functions.
2015-04-01 11:09:43 +02:00
Victor Stinner 70a46f635f Issue #23618: Enhance EINTR handling in socket.connect()
Call PyErr_CheckSignals() immediatly if connect() or select() fails with EINTR
in internal_connect().

Refactor also the code to limit indentaton and make it more readable.
2015-03-31 22:03:59 +02:00
Victor Stinner ee699e9d2b Issue #23618: Fix EINTR handling in socket.connect()
Call PyErr_CheckSignals() if connect(), select() or getsockopt() failed with
EINTR.
2015-03-31 21:28:42 +02:00
Victor Stinner c4e819a54f Issue #23618: Cleanup internal_connect() in socketmodule.c
On Windows, it looks like using the C type socklen_t for getsockopt() (instead
of int) is fine, it was already used in socket.getsockopt().
2015-03-31 21:23:10 +02:00
Raymond Hettinger 41290a68ba Issue 23793: Add deque support for __add__(), __mul__(), and __imul__(). 2015-03-31 08:12:23 -07:00
Victor Stinner b6c15bcad3 Issue #23618: Refactor internal_connect()
On Windows, internal_connect() now reuses internal_connect_select() and always
calls getsockopt().
2015-03-31 16:35:35 +02:00
Victor Stinner dd88d3db45 Issue #23618: Refactor internal_connect()
The function now returns the error code instead of using the global errno
(POSIX) or WSAGetLastError() (Windows).

internal_connect() now returns errno if getsockopt() fails.
2015-03-31 16:08:22 +02:00
Victor Stinner 1bb0aef4d1 Issue #22117: Fix integer overflow check in socket_parse_timeout() on Windows 2015-03-31 16:31:19 +02:00
Victor Stinner dd83bd2f9c Issue #23618: Fix internal_connect_select() 2015-03-31 14:24:47 +02:00
Victor Stinner 416f2e66ca Issue #23618: internal_connect_select() now waits also for error events 2015-03-31 13:56:29 +02:00
Victor Stinner e6951c6c8a Issue #23618: Refactor internal_select() to prepare socket.connect() for EINTR 2015-03-31 13:50:44 +02:00
Victor Stinner 391fa713f7 Issue #23618: Refactor the _socket module
* Inline internal_select() function
* Rename internal_select_ex() internal_select()
2015-03-31 13:15:31 +02:00
Serhiy Storchaka 58e4134a1c Issue #23611: Serializing more "lookupable" objects (such as unbound methods
or nested classes) now are supported with pickle protocols < 4.
2015-03-31 14:07:24 +03:00
Serhiy Storchaka 72e731cc03 Issue #13583: sqlite3.Row now supports slice indexing.
Tests by Jessica McKellar.
2015-03-31 13:33:11 +03:00
Serhiy Storchaka 80d84c89ee Merge heads 2015-03-31 13:18:35 +03:00
Serhiy Storchaka d5d818d40b Issue #18473: Fixed 2to3 and 3to2 compatible pickle mappings.
Fixed ambigious reverse mappings.  Added many new mappings.  Import mapping
is no longer applied to modules already mapped with full name mapping.

Added tests for compatible pickling and unpickling and for consistency of
_compat_pickle mappings.
2015-03-31 13:17:10 +03:00
Serhiy Storchaka bfe1824d08 Issue #18473: Fixed 2to3 and 3to2 compatible pickle mappings.
Fixed ambigious reverse mappings.  Added many new mappings.  Import mapping
is no longer applied to modules already mapped with full name mapping.

Added tests for compatible pickling and unpickling and for consistency of
_compat_pickle mappings.
2015-03-31 13:12:37 +03:00
Victor Stinner 45ca48b03d Issue #23485: select.devpoll.poll() is now retried when interrupted by a signal 2015-03-31 12:10:33 +02:00
Victor Stinner 4448c08451 Issue #23485: select.kqueue.control() is now retried when interrupted by a signal 2015-03-31 11:48:34 +02:00
Victor Stinner 41eba224de Issue #23485: select.epoll.poll() is now retried when interrupted by a signal 2015-03-30 21:59:21 +02:00
Victor Stinner 3c7d6e0693 Issue #23485: select.poll.poll() is now retried when interrupted by a signal 2015-03-30 21:38:00 +02:00
Victor Stinner 6aa446cf03 PEP 475: on EINTR, retry the function even if the timeout is equals to zero
Retry:

* signal.sigtimedwait()
* threading.Lock.acquire()
* threading.RLock.acquire()
* time.sleep()
2015-03-30 21:33:51 +02:00
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
Serhiy Storchaka 17d3a58e39 Issue #22832: Tweaked parameter names for fcntl module to better match
official POSIX documentation.  Updated the documenttion for Python 3.
Patch by Alex Shkop.
2015-03-20 20:04:21 +02:00
Victor Stinner a453cd8d85 Issue #23715: signal.sigwaitinfo() and signal.sigtimedwait() are now retried
when interrupted by a signal not in the *sigset* parameter, if the signal
handler does not raise an exception. signal.sigtimedwait() recomputes the
timeout with a monotonic clock when it is retried.

Remove test_signal.test_sigwaitinfo_interrupted() because sigwaitinfo() doesn't
raise InterruptedError anymore if it is interrupted by a signal not in its
sigset parameter.
2015-03-20 12:54:28 +01:00
Victor Stinner f50e187724 Fix compiler warnings: comparison between signed and unsigned numbers 2015-03-20 11:32:24 +01:00
Victor Stinner fbd6f9ed12 Issue #23696: Chain ZipImportError to the OSError 2015-03-20 10:52:25 +01:00
Victor Stinner 99953006df Issue #23709, #23001: ossaudiodev now uses Py_ssize_t for sizes instead of int
The module is now also "SSIZE_T clean" (for PyArg_Parse...() functions) since
it switched to Py_buffer ("y*" argument format).
2015-03-20 10:37:34 +01:00
Victor Stinner 716a74ea22 Issue #23001: Fix typo 2015-03-20 10:24:18 +01:00
Serhiy Storchaka 8490f5acfe Issue #23001: Few functions in modules mmap, ossaudiodev, socket, ssl, and
codecs, that accepted only read-only bytes-like object now accept writable
bytes-like object too.
2015-03-20 09:00:36 +02:00
Victor Stinner 0eac13052c Issue #23646: Fix test_threading on Windows 2015-03-20 03:06:12 +01:00
Victor Stinner 9a8089b32a Issue #23646: Enhance precision of time.sleep() and socket timeout when
interrupted by a signal

Add a new _PyTime_AddDouble() function and remove _PyTime_ADD_SECONDS() macro.
The _PyTime_ADD_SECONDS only supported an integer number of seconds, the
_PyTime_AddDouble() has subsecond resolution.
2015-03-20 01:42:20 +01:00
Victor Stinner 4fa99cdb4c Issue #23709: The ossaudiodev module now retries read/write when interrupted by
a signal (PEP 475).

Use he new _Py_read() and _Py_write() functions.
2015-03-20 00:27:28 +01:00
Victor Stinner 54799672da Issue #23708: select.devpoll now retries its internal write() when interrupted
by a signal (EINTR).

Modify devpoll_flush() to use _Py_write() instead of calling directly write().
2015-03-19 23:33:09 +01:00
Victor Stinner 66aab0c4b5 Issue #23708: Add _Py_read() and _Py_write() functions to factorize code handle
EINTR error and special cases for Windows.

These functions now truncate the length to PY_SSIZE_T_MAX to have a portable
and reliable behaviour. For example, read() result is undefined if counter is
greater than PY_SSIZE_T_MAX on Linux.
2015-03-19 22:53:20 +01:00
Victor Stinner 79d68f929d Issue #23646: If time.sleep() is interrupted by a signal, the sleep is now
retried with the recomputed delay, except if the signal handler raises an
exception (PEP 475).

Modify also test_signal to use a monotonic clock instead of the system clock.
2015-03-19 21:54:09 +01:00
Serhiy Storchaka 009b811d67 Removed unintentional trailing spaces in non-external and non-generated C files. 2015-03-18 21:53:15 +02:00
Victor Stinner cb7e5f6f08 Merge 3.4 (tracemalloc typo) 2015-03-18 16:05:32 +01:00
Victor Stinner 444f124fcf _tracemalloc.c: Fix typo 2015-03-18 16:05:18 +01:00
Victor Stinner e371b3d21a Fix compiler warning in mmapmodule.c (compare signed/unsigned integers) 2015-03-18 15:04:34 +01:00
Victor Stinner 5200f55024 Issue #19428: Handle PyMarshal_Read*() errors in run_pyc_file()
Detect also earlier PyMarshal_Read*() errors in zipimport.
2015-03-18 13:56:25 +01:00
Victor Stinner e42ccd2bfd Issue #23694: Enhance _Py_fopen(), it now raises an exception on error
* If fopen() fails, OSError is raised with the original filename object.
* The GIL is now released while calling fopen()
2015-03-18 01:39:23 +01:00
Victor Stinner a555cfcb73 Issue #23694: Enhance _Py_open(), it now raises exceptions
* _Py_open() now raises exceptions on error. If open() fails, it raises an
  OSError with the filename.
* _Py_open() now releases the GIL while calling open()
* Add _Py_open_noraise() when _Py_open() cannot be used because the GIL is not
  held
2015-03-18 00:22:14 +01:00
Victor Stinner f024d263b4 Issue #23685: Fix usage of PyMODINIT_FUNC in _json, _scproxy, nis, pyexpat
_codecs_cn, _codecs_hk, _codecs_iso2022, _codecs_jp, _codecs_kr and _codecs_tw
modules.

pyexpat.c doesn't need to redeclare PyMODINIT_FUNC, it's already declared in
Include/pyport.h.
2015-03-17 17:48:27 +01:00
Victor Stinner 0c2fd89777 Revert changeset d927047b1d8eb87738676980a24930d053ba2150
Sorry, it was a mistake, the patch is still under review: issue #23646.
2015-03-17 10:49:17 +01:00
Serhiy Storchaka a60c2fe480 Issue #23641: Cleaned out legacy dunder names from tests and docs.
Fixed 2 to 3 porting bug in pynche.ColorDB.
2015-03-12 21:56:08 +02:00
Victor Stinner 945c82eea3 test 2015-03-12 16:19:01 +01:00
Serhiy Storchaka c2ccce791c Issue #23641: Cleaned out legacy dunder names from tests and docs.
Fixed 2 to 3 porting bug in pynche.ColorDB.
Added few tests for __truediv__, __floordiv__ and __matmul__.
2015-03-12 22:01:30 +02:00
Victor Stinner 95bb714ff7 Issue #23566: enable(), register(), dump_traceback() and dump_traceback_later()
functions of faulthandler now accept file descriptors. Patch by Wei Wu.
2015-03-12 15:32:03 +01:00
Steve Dower 8acde7dcce Issue #23524: Change back to using Windows errors for _Py_fstat instead of the errno shim. 2015-03-07 18:14:07 -08:00
Victor Stinner 35a97c0bed Issue #22524: Fix os.scandir() for platforms which don't have a d_type field in
the dirent structure (ex: OpenIndiana).
2015-03-08 02:59:09 +01:00
Victor Stinner 6036e4431d Issue #22524: New os.scandir() function, part of the PEP 471: "os.scandir()
function -- a better and faster directory iterator". Patch written by Ben
Hoyt.
2015-03-08 01:58:04 +01:00
Victor Stinner 4a7cc88472 Issue #23571: PyObject_Call(), PyCFunction_Call() and call_function() now
raise a SystemError if a function returns a result and raises an exception.
The SystemError is chained to the previous exception.

Refactor also PyObject_Call() and PyCFunction_Call() to make them more readable.

Remove some checks which became useless (duplicate checks).

Change reviewed by Serhiy Storchaka.
2015-03-06 23:35:27 +01:00
Steve Dower d81431f587 Issue #23524: Replace _PyVerify_fd function with calling _set_thread_local_invalid_parameter_handler on every thread. 2015-03-06 14:47:02 -08:00
Ned Deily e37a1946c7 Fix regression introduced by changeset 7c6e3358221a that caused compile
errors of _testcapimodule.c with older versions of gcc.
2015-03-05 15:47:10 -08:00
Serhiy Storchaka caa01f861c Fixed GCC version testing. 2015-03-05 23:42:24 +02:00
Victor Stinner a4c727131e Fix "GCC diagnostic" in socketmodule.c
Fix regression of changeset 7c6e3358221a on GCC < 4.4. The _socket module
cannot be compiled on "x86 FreeBSD 7.2 3.x" buildbot anymore.
2015-03-05 14:04:03 +01:00
Benjamin Peterson de8eca4638 merge 3.4 2015-03-04 22:50:25 -05:00
Benjamin Peterson 990fcaac3c expose X509_V_FLAG_TRUSTED_FIRST 2015-03-04 22:49:41 -05:00
Benjamin Peterson b64ae7bf2d merge 3.4 (#23476) 2015-03-04 22:11:48 -05:00
Benjamin Peterson fdb1971587 enable X509_V_FLAG_TRUSTED_FIRST when possible (closes #23476) 2015-03-04 22:11:12 -05:00
Antoine Pitrou 0bfd0a4048 Issue #23576: Avoid stalling in SSL reads when EOF has been reached in the SSL layer but the underlying connection hasn't been closed. 2015-03-04 20:54:57 +01:00
Antoine Pitrou f7f3b0a14a Issue #23576: Avoid stalling in SSL reads when EOF has been reached in the SSL layer but the underlying connection hasn't been closed. 2015-03-04 20:51:55 +01:00
Victor Stinner 9672da7bb4 Issue #23285: Fix handling of EINTR in fileio.c
Fix handling of EINTR: don't return None if PyErr_CheckSignals() raised an
exception.

Initialize also the length outside the loop to only initialize it once.
2015-03-04 18:40:10 +01:00
Raymond Hettinger 87e691240b Minor neatening-up. Make assignments in same order a struct fields. Line-up comments. 2015-03-02 23:32:02 -08:00
Raymond Hettinger f9d9c79aa8 Switch the state variable to unsigned for defined wrap-around behavior. 2015-03-02 22:47:46 -08:00
Raymond Hettinger 30c9074b96 Minor beautification. Move struct definitions to the top. Fix-up a comment. 2015-03-02 22:31:35 -08:00
Raymond Hettinger f30f5b9ba6 Minor code beautification. Replace macro with in-lineable functions. 2015-03-02 22:23:37 -08:00
Raymond Hettinger 3c186ba441 Beautify and better document the use of the size_t cast for bounds checking. 2015-03-02 21:45:02 -08:00
Benjamin Peterson 83d8fc265a merge 3.4 (#23367) 2015-03-02 11:18:56 -05:00
Benjamin Peterson 5061e67f0f merge 3.3 (#23367) 2015-03-02 11:18:40 -05:00
Benjamin Peterson b779bfba45 fix possible overflow bugs in unicodedata (closes #23367) 2015-03-02 11:17:05 -05:00
Steve Dower 3e96f324dc Issue #23451: Update pyconfig.h for Windows to require Vista headers and remove unnecessary version checks. 2015-03-02 08:01:10 -08:00
Alexander Belopolsky e49af34151 Issue #7830: Flatten nested functools.partial. 2015-03-01 15:08:17 -05:00
Alexander Belopolsky e2e178e081 Closes issue #22791: Improved datetime from timestamp methods documentation.
Original patch by Akira Li.
2015-03-01 14:52:07 -05:00
Raymond Hettinger 7f9ea7543e Issue #23553: Use an unsigned cast to tighten-up the bounds checking logic. 2015-03-01 00:38:00 -08:00
Serhiy Storchaka 90295b450c Merge heads 2015-03-01 10:03:46 +02:00
Raymond Hettinger c20830804d Need a (size_t) cast instead of (unsigned) to be big enough for a Py_ssize_t. 2015-02-28 23:29:16 -08:00
Serhiy Storchaka 50adb9fc32 Issue #20204: Added the __module__ attribute to _tkinter classes. 2015-03-01 09:07:10 +02:00
Serhiy Storchaka efdc16f978 Issue #20204: Added the __module__ attribute to _tkinter classes. 2015-03-01 09:06:29 +02:00
Raymond Hettinger a473b9da15 Use unsigned division and modulo for item assignment as well. 2015-02-28 17:49:47 -08:00
Raymond Hettinger 63d1ff2a0b Convert one more division to unsigned arithmetic to speed-up deque_item(). 2015-02-28 07:41:30 -08:00
Raymond Hettinger 7e8c7956a7 Line missed in last checkin 2015-02-27 16:59:29 -08:00
Raymond Hettinger da2850f932 Since the index is always non-negative, use faster unsigned division and modulo. 2015-02-27 12:42:54 -08:00
Raymond Hettinger daf57f25e5 Bump the blocksize up from 62 to 64 to speed up the modulo calculation.
Remove the old comment suggesting that it was desireable to have
blocksize+2 as a multiple of the cache line length.  That would
have made sense only if the block structure start point was always
aligned to a cache line boundary.  However, the memory allocations
are 16 byte aligned, so we don't really have control over whether
the struct spills across cache line boundaries.
2015-02-26 23:21:29 -08:00
Serhiy Storchaka b48af340b9 Silenced minor GCC warnings. 2015-02-26 15:27:57 +02:00
Antoine Pitrou e71258a0e6 Issue #15955: Add an option to limit the output size in bz2.decompress().
Patch by Nikolaus Rath.
2015-02-26 13:08:07 +01:00
Steve Dower f63dab5a84 Back-out wcstok deprecation suppression and updates calls to use wcstok_s. 2015-02-25 20:48:01 -08:00
Serhiy Storchaka 06a13f81ea Issue #23152: Move declarations back to posixmodule.c.
Declarations of Windows-specific auxilary functions need Windows types
from windows.h.  Instead of including windows.h in Python.h and making
it available to all Windows users, it is simpler and safer just move
declarations to the single file that needs them.
2015-02-22 21:34:54 +02:00
Serhiy Storchaka 12ebbc74f1 Issue #23152: Move declaration into a header and exclude from stable API. 2015-02-22 19:39:36 +02:00
Steve Dower bf1f376b3e Issue #23152: Renames time_t_to_FILE_TIME to _Py_time_t_to_FILE_TIME, removes unused struct win32_stat and return value 2015-02-21 15:26:02 -08:00
Steve Dower a2af1a5a5a Issue #23152: Renames attribute_data_to_stat to _Py_attribute_data_to_stat 2015-02-21 10:04:10 -08:00
Steve Dower f2f373f593 Issue #23152: Implement _Py_fstat() to support files larger than 2 GB on Windows.
fstat() may fail with EOVERFLOW on files larger than 2 GB because the file size type is an signed 32-bit integer.
2015-02-21 08:44:05 -08:00
Serhiy Storchaka df80706f14 Issue #23215: Multibyte codecs with custom error handlers that ignores errors
consumed too much memory and raised SystemError or MemoryError.
Original patch by Aleksi Torhamo.
2015-02-21 01:21:08 +02:00
Serhiy Storchaka a1543cdcd6 Issue #23215: Multibyte codecs with custom error handlers that ignores errors
consumed too much memory and raised SystemError or MemoryError.
Original patch by Aleksi Torhamo.
2015-02-21 01:19:58 +02:00
Serhiy Storchaka 254dd59068 Issue #5700: io.FileIO() called flush() after closing the file.
flush() was not called in close() if closefd=False.
2015-02-21 00:35:53 +02:00
Serhiy Storchaka a3712a9a6c Issue #5700: io.FileIO() called flush() after closing the file.
flush() was not called in close() if closefd=False.
2015-02-21 00:35:09 +02:00
Serhiy Storchaka 79d8f3f123 Regenerated Argument Clinic checksums. 2015-02-20 12:46:11 +02:00
Raymond Hettinger 7a4f43a8dd Improve struct cache locality by bring commonly accessed fields close together. 2015-02-20 00:50:04 -08:00
Serhiy Storchaka 483405bcca Issue #22883: Got rid of outdated references to PyInt and PyString in comments. 2015-02-17 10:14:30 +02:00
Serhiy Storchaka 3584056ca5 Shoould be Py_MIN, not Py_MAX. 2015-02-16 20:54:03 +02:00
Serhiy Storchaka 26861b0b29 Issue #23450: Fixed possible integer overflows. 2015-02-16 20:52:17 +02:00
Serhiy Storchaka 4d0d982985 Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integer
overflows.  Added few missed PyErr_NoMemory().
2015-02-16 13:33:32 +02:00
Serhiy Storchaka 1a1ff29659 Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integer
overflows.  Added few missed PyErr_NoMemory().
2015-02-16 13:28:22 +02:00
Serhiy Storchaka 53fa8b2a4b Fixed few compiler warnings. 2015-02-16 09:40:12 +02:00
Serhiy Storchaka c86ca26d32 Issue #23096: Pickle representation of floats with protocol 0 now is the same
for both Python and C implementations.
2015-02-15 14:18:32 +02:00
Berker Peksag 9ab1cc4fe4 Issue #13637: Improve exception message of a2b_* functions.
Patch by Vajrasky Kok.
2015-02-15 00:31:26 +02:00
Berker Peksag 3cd30c2cee Issue #13637: Improve exception message of a2b_* functions.
Patch by Vajrasky Kok.
2015-02-15 00:31:00 +02:00
Victor Stinner cf40a9e640 Issue #23450: Fix signal.set_wakeup_fd() on Windows
Detect integer overflow on the file descriptor of the socket on 64-bit Python.
2015-02-12 16:34:54 +01:00
Victor Stinner 385efb4d99 Merge 3.4 (faulthandler) 2015-02-11 14:23:46 +01:00
Victor Stinner 7a5567a92c Issue #23433: Fix faulthandler._stack_overflow()
Fix undefined behaviour: don't compare pointers. Use Py_uintptr_t type instead
of void*. It fixes test_faulthandler on Fedora 22 which now uses GCC 5.
2015-02-11 14:23:35 +01:00
Raymond Hettinger eb6b554fbc Update copyright. 2015-02-10 22:37:22 -06:00
Benjamin Peterson 5ef01e9b93 merge 3.4 (#23361) 2015-02-09 21:00:00 -05:00
Benjamin Peterson 22ef9f722e merge 3.3 (#23361) 2015-02-09 20:58:52 -05:00
Benjamin Peterson 8ce6806498 add overflow checking (closes #23361) 2015-02-09 20:58:12 -05:00
Charles-François Natali 6e6c59b508 Issue #23285: PEP 475 -- Retry system calls failing with EINTR. 2015-02-07 13:27:50 +00:00
Serhiy Storchaka 6cfb61f163 Issue #23392: Added tests for marshal C API that works with FILE*. 2015-02-06 09:00:44 +02:00
Serhiy Storchaka b51813403f Issue #23392: Added tests for marshal C API that works with FILE*. 2015-02-06 08:58:56 +02:00
Stefan Krah a7559c04e0 Issue #14203: Temporary fix for the compile failure on Windows. 2015-02-03 22:27:21 +01:00
Stefan Krah 650c1e818d Issue #14203: Remove obsolete support for view==NULL in bytesiobuf_getbuffer()
and array_buffer_getbuf().
2015-02-03 21:43:23 +01:00
Serhiy Storchaka 38c30e6c8e Issue #15381: Fixed a bug in BytesIO.write().
It was expected that string_size == PyBytes_GET_SIZE(buf) if the buffer is
shared, but truncate() and __setstate__() can set string_size without
unsharing the buffer.
2015-02-03 18:51:58 +02:00
Stefan Krah 5178d91be0 Issue #14203: Remove obsolete support for view==NULL in PyBuffer_FillInfo()
and bytearray_getbuffer().  Both functions now raise BufferError in that
case.
2015-02-03 16:57:21 +01:00
Serhiy Storchaka b9765eec5c Issue #15381: Try to fix refcount bug. Empty and 1-byte buffers are always shared. 2015-02-03 14:57:49 +02:00
Serhiy Storchaka 87d0b45485 Issue #15381: Optimized io.BytesIO to make less allocations and copyings. 2015-02-03 11:30:10 +02:00
Serhiy Storchaka 83e802796c Issue #22818: Splitting on a pattern that could match an empty string now
raises a warning.  Patterns that can only match empty strings are now
rejected.
2015-02-03 11:04:19 +02:00
Serhiy Storchaka 32ca3dcb97 Issue #23099: Closing io.BytesIO with exported buffer is rejected now to
prevent corrupting exported buffer.
2015-02-03 09:30:51 +02:00
Serhiy Storchaka c057c3859c Issue #23099: Closing io.BytesIO with exported buffer is rejected now to
prevent corrupting exported buffer.
2015-02-03 02:00:18 +02:00
Serhiy Storchaka 7a27c97216 Issues #23363, #23364, #23365, #23366: Fixed itertools overflow tests.
Used PyMem_New to check overflow.
2015-02-03 01:50:31 +02:00
Serhiy Storchaka b5e8e57555 Issues #23363, #23364, #23365, #23366: Fixed itertools overflow tests.
Used PyMem_New to check overflow.
2015-02-03 01:35:10 +02:00
Serhiy Storchaka dee948b359 Issues #23363, #23364, #23365, #23366: Fixed itertools overflow tests.
Used PyMem_New to check overflow.
2015-02-03 01:34:09 +02:00
Serhiy Storchaka 3dd3e26680 Issue #22896: Avoid to use PyObject_AsCharBuffer(), PyObject_AsReadBuffer()
and PyObject_AsWriteBuffer().
2015-02-03 01:25:42 +02:00
Serhiy Storchaka 4fdb68491e Issue #22896: Avoid to use PyObject_AsCharBuffer(), PyObject_AsReadBuffer()
and PyObject_AsWriteBuffer().
2015-02-03 01:21:08 +02:00
Raymond Hettinger 0e259f18f7 Optimization guides suggest copying memory in an ascending direction when possible. 2015-02-01 22:53:41 -08:00
Benjamin Peterson 5d0bb852a2 merge 3.4 (#23364, #23363) 2015-02-01 21:36:01 -05:00
Benjamin Peterson c468b537cd merge 3.3 (#23364, #23363) 2015-02-01 21:35:34 -05:00
Benjamin Peterson 0eaabf1c05 check for overflows in permutations() and product() (closes #23363, closes #23364) 2015-02-01 21:34:07 -05:00
Benjamin Peterson 38d9772622 merge 3.4 (#23365) 2015-02-01 21:11:54 -05:00
Benjamin Peterson f635dc32b1 merge 3.3 (#23365) 2015-02-01 21:11:39 -05:00
Benjamin Peterson 6f082297b2 check for overflow in combinations_with_replacement (closes #23365) 2015-02-01 21:10:47 -05:00
Benjamin Peterson 4db56d5002 merge 3.4 (#23366) 2015-02-01 21:01:43 -05:00
Benjamin Peterson 819c4e9bc4 merge 3.3 (#23366) 2015-02-01 21:00:15 -05:00
Benjamin Peterson 4b40eeb339 detect overflow in combinations (closes #23366) 2015-02-01 20:59:00 -05:00
Benjamin Peterson 71cf91cc09 merge 3.4 (#23369) 2015-02-01 18:00:19 -05:00
Benjamin Peterson 3675cd9db1 merge 3.3 (#23369) 2015-02-01 17:59:49 -05:00
Benjamin Peterson e3bfe19358 fix possible overflow in encode_basestring_ascii (closes #23369) 2015-02-01 17:53:53 -05:00