Commit Graph

9909 Commits

Author SHA1 Message Date
Segev Finer d8b5216f99 [3.6] bpo-31018: Switch to GH-pragma pack from __declspec(align) (GH-2848) (#2868)
(cherry picked from commit 39243779f4)
2017-07-25 19:20:38 +02:00
Xiang Zhang 241c4a28d9 bpo-30961: Fix decrementing a borrowed reference in tracemalloc. (#2747) (#2748)
(cherry picked from commit 4ed5ad79ec)
2017-07-19 00:50:52 +08:00
Serhiy Storchaka a819e5e1e6 [3.6] bpo-30936: Fix a reference leak in json when fail to sort keys. (GH-2712). (#2727)
(cherry picked from commit 49f6449ef4)
2017-07-16 07:48:08 +03:00
Serhiy Storchaka ecfe4f678b [3.6] bpo-30879: os.listdir() and os.scandir() now emit bytes names when (GH-2634) (#2656)
called with bytes-like argument..
(cherry picked from commit 1180e5a518)
2017-07-11 07:16:11 +03:00
Victor Stinner 044e156426 bpo-30892: Fix _elementtree module initialization (#2647) (#2649)
Handle getattr(copy, 'deepcopy') error in _elementtree module
initialization.
(cherry picked from commit b136f11f3a)
2017-07-10 23:12:37 +02:00
Nir Soffer 04f77d4677 [3.6] bpo-29854: Fix segfault in call_readline() (GH-728)
If history-length is set in .inputrc, and the history file is double the
history size (or more), history_get(N) returns NULL, and python
segfaults. Fix that by checking for NULL return value.

It seems that the root cause is incorrect handling of bigger history in
readline, but Python should not segfault even if readline returns
unexpected value.

This issue affects only GNU readline. When using libedit emulation
system history size option does not work.
2017-07-08 21:51:21 +03:00
Ned Deily 05b72ede95 bpo-30797, bpo-30694: Avoid _GNU_SOURCE redefined warning in xmlparse.c (#2615) 2017-07-07 01:31:43 -04:00
Yury Selivanov aaa4f99151 [3.6] bpo-30828: Fix out of bounds write in `asyncio.CFuture.remove_done_callback() (GH-2569) (#2590)
(cherry picked from commit 833a3b0d37)
2017-07-05 14:03:10 -04:00
Victor Stinner 580cd5cd36 bpo-30319: socket.close() now ignores ECONNRESET (#2565) (#2566)
socket.close() was modified in Python 3.6 to raise OSError on
failure: see bpo-26685.
(cherry picked from commit 67e1478dba)
2017-07-04 16:46:10 +02:00
Antoine Pitrou 3024c05290 [3.6] bpo-30703: Improve signal delivery (GH-2415) (#2527)
* [3.6] bpo-30703: Improve signal delivery (GH-2415)

* Improve signal delivery

Avoid using Py_AddPendingCall from signal handler, to avoid calling signal-unsafe functions.

* Remove unused function

* Improve comments

* Add stress test

* Adapt for --without-threads

* Add second stress test

* Add NEWS blurb

* Address comments @haypo.
(cherry picked from commit c08177a1cc)

* bpo-30796: Fix failures in signal delivery stress test (#2488)

* bpo-30796: Fix failures in signal delivery stress test

setitimer() can have a poor minimum resolution on some machines,
this would make the test reach its deadline (and a stray signal
could then kill a subsequent test).

* Make sure to clear the itimer after the test
2017-07-01 19:12:05 +02:00
Antoine Pitrou 6f3cb059fd [3.6] bpo-30807: signal.setitimer() may disable the timer by mistake (GH-2493) (#2497)
* bpo-30807: signal.setitimer() may disable the timer by mistake

* Add NEWS blurb
(cherry picked from commit 729780a810)
2017-06-30 10:54:24 +02:00
Victor Stinner 1d56ed5210 _winconsoleio: Fix memory leak (#2485)
Fix memory leak when _winconsoleio tries to open a non-console file:
free the name buffer.
2017-06-29 10:53:34 +02:00
Victor Stinner b78fbaaeab bpo-30602: Fix refleak in os.spawnv() (#2212) (#2486)
When os.spawnv() fails while handling arguments, free correctly
argvlist: pass lastarg+1 rather than lastarg to free_string_array()
to also free the first item.
(cherry picked from commit 8acb4cf2b3)
2017-06-29 10:53:22 +02:00
Serhiy Storchaka 0834905d9b [3.6] bpo-13617: Reject embedded null characters in wchar* strings. (GH-2302) (#2462)
Based on patch by Victor Stinner.

Add private C API function _PyUnicode_AsUnicode() which is similar to
PyUnicode_AsUnicode(), but checks for null characters..
(cherry picked from commit f7eae0adfc)
2017-06-28 09:27:35 +03:00
Serhiy Storchaka 0edffa3073 [3.6] bpo-30708: Check for null characters in PyUnicode_AsWideCharString(). (GH-2285) (#2443)
Raise a ValueError if the second argument is NULL and the wchar_t\*
string contains null characters..
(cherry picked from commit e613e6add5)
2017-06-27 21:08:58 +03:00
Emily Morehouse 2d348f7a72 [3.6] bpo-30769: Fix reference leak introduced in 77703942c5 (GH-2416) (#2425)
New error condition paths were introduced, which did not decrement
`key2` and `val2` objects.  Therefore, decrement references before
jumping to the error label.

Signed-off-by: Eric N. Vander Weele <ericvw@gmail.com>
(cherry picked from commit a7874c73c0)
2017-06-27 07:59:25 +03:00
Serhiy Storchaka 9c2dc0c58a [3.6] bpo-30746: Prohibited the '=' character in environment variable names (GH-2382) (#2391)
in `os.putenv()` and `os.spawn*()`..
(cherry picked from commit 77703942c5)
2017-06-25 09:49:15 +03:00
Serhiy Storchaka 0e1f9e8d3e [3.6] bpo-30745: Fix compiler warnings introduced in bpo-30730. (GH-2376) (#2378)
(cherry picked from commit 0ee32c1)
2017-06-24 16:28:26 +03:00
Serhiy Storchaka e7135751b8 [3.6] bpo-30730: Prevent environment variables injection in subprocess on Windows. (GH-2325) (#2360)
Prevent passing other invalid environment variables and command arguments..
(cherry picked from commit d174d24a5d)
2017-06-23 20:17:38 +03:00
Victor Stinner c472fb6b27 bpo-30602: Fix lastarg in os.spawnve() (#2287) (#2357)
Fix a regression introduced by myself in the commit
526b22657c.
(cherry picked from commit c8d6ab2e25)
2017-06-23 15:21:24 +02:00
Victor Stinner 4a66524006 bpo-30694: Upgrade Modules/expat/ to libexpat 2.2.1 (#2300) (#2313)
New file: Modules/expat/siphash.h.
(cherry picked from commit 5ff7132313)
2017-06-21 16:05:11 +02:00
Serhiy Storchaka f75f6edb1f [3.6] bpo-30650: Fixed a syntax error: missed right parentheses (GH-2154) (#2215)
(cherry picked from commit 0d32218)
2017-06-15 16:57:53 +03:00
Victor Stinner 86b95370c4 bpo-29591: Upgrade Modules/expat to libexpat 2.2 (#2164) (#2200)
* bpo-29591: Upgrade Modules/expat to libexpat 2.2

* bpo-29591: Restore Python changes on expat

* bpo-29591: Remove expat config of unsupported platforms

Remove the configuration (Modules/expat/*config.h) of unsupported
platforms:

* Amiga
* MacOS Classic on PPC32
* Open Watcom

* bpo-29591: Remove useless XML_HAS_SET_HASH_SALT

The XML_HAS_SET_HASH_SALT define of Modules/expat/expat.h became
useless since our local expat copy was upgrade to expat 2.1 (it's now
expat 2.2.0).

(cherry picked from commit 23ec4b57e1)
2017-06-15 01:26:16 +02:00
Serhiy Storchaka d89dc844d2 [3.6] bpo-28994: Fixed errors handling in atexit._run_exitfuncs(). (GH-2034) (#2121)
The traceback no longer displayed for SystemExit raised in a callback registered by atexit..
(cherry picked from commit 3fd54d4a7e)
2017-06-12 09:02:13 +03:00
Yury Selivanov 176f2ebdad bpo-30508: Don't log exceptions if Task/Future "cancel()" method was called. (#2109) 2017-06-11 14:00:14 +00:00
Zachary Ware 964c261dc9 [3.6] bpo-27425: Be more explicit in .gitattributes (GH-840) (GH-2083)
Also updates checked-in line endings on some files
2017-06-10 15:39:29 -05:00
Serhiy Storchaka 911068e250 [3.6] Regenerate Argument Clinic code for bpo-19180. (GH-2073). (#2077)
(cherry picked from commit 5f31d5cf6e)
2017-06-10 13:48:53 +03:00
Victor Stinner 0b7629cd84 bpo-30038: fix race condition in signal delivery + wakeup fd (#1082) (#2075)
Before, it was possible to get the following sequence of
events (especially on Windows, where the C-level signal handler for
SIGINT is run in a separate thread):

- SIGINT arrives
- trip_signal is called
- trip_signal writes to the wakeup fd
- the main thread wakes up from select()-or-equivalent
- the main thread checks for pending signals, but doesn't see any
- the main thread drains the wakeup fd
- the main thread goes back to sleep
- trip_signal sets is_tripped=1 and calls Py_AddPendingCall to notify
  the main thread the it should run the Python-level signal handler
- the main thread doesn't notice because it's asleep

This has been causing repeated failures in the Trio test suite:
  https://github.com/python-trio/trio/issues/119
(cherry picked from commit 4ae0149697)
2017-06-10 11:20:03 +02:00
Yury Selivanov e89f95bfd0 [3.6] bpo-30039: Don't run signal handlers while resuming a yield from stack (GH-1081) (#1640)
If we have a chain of generators/coroutines that are 'yield from'ing
each other, then resuming the stack works like:

- call send() on the outermost generator
- this enters _PyEval_EvalFrameDefault, which re-executes the
  YIELD_FROM opcode
- which calls send() on the next generator
- which enters _PyEval_EvalFrameDefault, which re-executes the
  YIELD_FROM opcode
- ...etc.

However, every time we enter _PyEval_EvalFrameDefault, the first thing
we do is to check for pending signals, and if there are any then we
run the signal handler. And if it raises an exception, then we
immediately propagate that exception *instead* of starting to execute
bytecode. This means that e.g. a SIGINT at the wrong moment can "break
the chain" – it can be raised in the middle of our yield from chain,
with the bottom part of the stack abandoned for the garbage collector.

The fix is pretty simple: there's already a special case in
_PyEval_EvalFrameEx where it skips running signal handlers if the next
opcode is SETUP_FINALLY. (I don't see how this accomplishes anything
useful, but that's another story.) If we extend this check to also
skip running signal handlers when the next opcode is YIELD_FROM, then
that closes the hole – now the exception can only be raised at the
innermost stack frame.

This shouldn't have any performance implications, because the opcode
check happens inside the "slow path" after we've already determined
that there's a pending signal or something similar for us to process;
the vast majority of the time this isn't true and the new check
doesn't run at all..
(cherry picked from commit ab4413a7e9)
2017-06-09 17:06:39 -04:00
Victor Stinner b7577456c4 bpo-30524: Write unit tests for FASTCALL (#2022) (#2030)
Test C functions:

* _PyObject_FastCall()
* _PyObject_FastCallDict()
* _PyObject_FastCallKeywords()
(cherry picked from commit 3b5cf85edc)
2017-06-09 22:28:32 +02:00
Nick Coghlan c422959dac [3.6] bpo-19180: Updated references for RFC 1750, RFC 3280 & RFC 4366
* RFC 1750 has been been obsoleted by RFC 4086.
* RFC 3280 has been obsoleted by RFC 5280.
* RFC 4366 has been obsoleted by RFC 6066.
(cherry picked from commit 63c2c8ac17)
2017-06-09 22:37:53 +10:00
Victor Stinner 31b950ab86 bpo-30601: Fix a refleak in WindowsConsoleIO (#2003) (#2008)
Fix a reference leak in _io._WindowsConsoleIO: PyUnicode_FSDecoder()
always initialize decodedname when it succeed and it doesn't clear
input decodedname object.
(cherry picked from commit 29adc13bd7)
2017-06-08 23:13:12 +02:00
Nathaniel J. Smith 854f7ba1d5 [3.6] bpo-30594: Fixed refcounting in newPySSLSocket (GH-1992) (#1994)
If pass a server_hostname= that fails IDNA decoding to SSLContext.wrap_socket or SSLContext.wrap_bio, then the SSLContext object had a spurious Py_DECREF called on it, eventually leading to segfaults.
(cherry picked from commit 65ece7ca23)
2017-06-08 14:14:40 +03:00
Steve Dower 2bafc0dcca [3.6] bpo-30557: faulthandler now correctly filters and displays exception … (#1960)
* bpo-30557: faulthandler now correctly filters and displays exception codes on Windows (#1924)

* bpo-30557: faulthandler now correctly filters and displays exception codes on Windows

* Adds test for non-fatal exceptions.

* Adds bpo number to comment.

* bpo-30557: Fix test_faulthandler (#1969)

On Windows 8, 8.1 and 10 at least, the exit code is the exception
code (no bit is cleared).
2017-06-06 13:47:14 -07:00
Steve Dower c63ae1122f bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails (#1912) (#1925)
* bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails

* bpo-30544: _io._WindowsConsoleIO.write raises the wrong error when WriteConsoleW fails
2017-06-02 14:39:05 -07:00
Mariatta 94d8261d1c [3.6] bpo-29960 _random.Random corrupted on exception in setstate(). … (#1287)
(cherry picked from commit 9616a82e78)
2017-05-27 07:20:24 -07:00
Xiang Zhang 54af41d42e bpo-30003: Fix handling escape characters in HZ codec (#1556) (#1719) 2017-05-23 01:03:00 +08:00
Victor Stinner 69f3a5ac28 tmtotuple(): use time_t for gmtoff (#1276) (#1635)
timegm() return type is time_t, not int. Use time_t to prevent the
following compiler warning on Windows:

timemodule.c: warning C4244: '=': conversion from 'time_t' to 'int',
              possible loss of data
(cherry picked from commit 0d659e5614)
2017-05-17 14:45:45 -07:00
Xiang Zhang aad1caf55f bpo-30242: resolve some undefined behaviours in struct (#1418) (#1586) 2017-05-15 13:17:28 +08:00
INADA Naoki 3dc7c52a9f bpo-30048: asyncio: fix Task.cancel() was ignored. (GH-1546)
when there are no more `await` or `yield (from)` before return in coroutine,
cancel was ignored.

example:

    async def coro():
        asyncio.Task.current_task().cancel()
        return 42
    ...
    res = await coro()  # should raise CancelledError

(cherry picked from commit 991adca012)
2017-05-11 21:56:42 +09:00
Xiang Zhang 72e1b61da0 bpo-29990: Fix range checking in GB18030 decoder (#1495) (#1507)
When decoding a 4-byte GB18030 sequence, the first and third byte cannot exceed 0xFE.
2017-05-09 12:16:50 +08:00
Serhiy Storchaka 39b73dd513 [3.6] bpo-30243: Fixed the possibility of a crash in _json. (GH-1420) (#1469)
It was possible to get a core dump by using uninitialized
_json objects. Now __new__ methods create initialized objects.
__init__ methods are removed..
(cherry picked from commit 76a3e51a40)
2017-05-05 10:40:30 +03:00
Serhiy Storchaka 1bebd8a219 [3.6] bpo-30184: Add tests for invalid use of PyArg_ParseTupleAndKeywords. (GH-1316). (#1441)
(cherry picked from commit 5f161fd86d)
2017-05-04 06:50:28 +03:00
Antoine Pitrou 0c2ff0898d Backport bpo-30205 to 3.6 (#1403) 2017-05-03 00:14:29 +02:00
Victor Stinner 3a8f8ea2ac bpo-30125: Fix faulthandler.disable() on Windows (#1243)
On Windows, faulthandler.disable() now removes the exception handler
installed by faulthandler.enable().
2017-04-21 23:17:33 +02:00
Serhiy Storchaka e254617262 [3.6] bpo-30065: Fixed arguments validation in _posixsubprocess.fork_exec(). (GH-1110) (#1186)
(cherry picked from commit 66bffd1)
2017-04-19 23:59:02 +03:00
Serhiy Storchaka 39dedb6e1a [3.6] bpo-30070: Fixed leaks and crashes in errors handling in the parser module. (GH-1131). (#1184)
(cherry picked from commit a79f4c2195)
2017-04-19 23:22:19 +03:00
Serhiy Storchaka 680fea4067 bpo-30061: Check if PyObject_Size()/PySequence_Size()/PyMapping_Size() (#1096) (#1180)
raised an error.

(cherry picked from commit bf623ae884)
2017-04-19 21:22:49 +03:00
Xiang Zhang d5fa5f3ce7 bpo-30068: add missing iter(self) in _io._IOBase.readlines when hint is present (#1130) (#1150) 2017-04-15 13:25:15 +08:00
Mariatta 8e7201342d [3.6] bpo-29738: Fix memory leak in _get_crl_dp (GH-526) (GH-1142)
* Remove conditional on free of `dps`, since `dps` is now allocated for
all versions of OpenSSL
* Remove call to `x509_check_ca` since it was only used to cache
the `crldp` field of the certificate
CRL_DIST_POINTS_free is available in all supported versions of OpenSSL
(recent 0.9.8+) and LibreSSL.
(cherry picked from commit 2849cc34a8)
2017-04-14 18:34:11 -07:00