Commit Graph

5344 Commits

Author SHA1 Message Date
xdegaye ea5b545e38
[3.6] bpo-30696: Fix the REPL looping endlessly when no memory (GH-4160). (#4379)
(cherry picked from commit e0582a37c8)
2017-11-12 17:33:16 +01:00
xdegaye 4b27d51222 [3.6] bpo-30697: Fix PyErr_NormalizeException() when no memory (GH-2327). (#4135)
(cherry picked from commit 56d1f5ca32)
2017-10-26 17:48:48 +02:00
Serhiy Storchaka 2b5cbbb13c [3.6] bpo-21720: Restore the Python 2.7 logic in handling a fromlist. (GH-4118) (#4128)
BytesWarning no longer emitted when the fromlist argument of
__import__() or the __all__ attribute of the module contain bytes
instances..
(cherry picked from commit 41c56940c6)
2017-10-26 12:02:54 +03:00
xdegaye d5d79545b7 [3.6] bpo-30817: Fix PyErr_PrintEx() when no memory (GH-2526). (#4107)
(cherry picked from commit 66caacf2f0)
2017-10-24 16:42:33 +02:00
Miss Islington (bot) 1e78ed6825 bpo-31825: Fixed OverflowError in the 'unicode-escape' codec (GH-4058) (#4059)
and in codecs.escape_decode() when decode an escaped non-ascii byte.
(cherry picked from commit 56cb465cc9)
2017-10-20 17:41:29 +03:00
Pablo Galindo 95602b368b [3.6] bpo-31786: Make functions in the select module blocking when timeout is a small negative value. (GH-4003). (#4022)
(cherry picked from commit 2c15b29aea)
2017-10-18 11:12:47 +03:00
Miss Islington (bot) 2712247ec9 [3.6] bpo-28603: Fix formatting tracebacks for unhashable exceptions (GH-4014) (#4024)
(cherry picked from commit de86073a76)
2017-10-18 01:14:19 +03:00
Miss Islington (bot) 59b5c139d2 [3.6] bpo-31780: Fix incorrect error message for ',x', ',b', ',o' specs (GH-4002) (#4004)
Patch by Pablo.
(cherry picked from commit 28773ca7a7)
2017-10-15 00:01:28 -04:00
Serhiy Storchaka 6f059ab80a [3.6] bpo-31642: Restore blocking "from" import by setting None in sys.modules. (GH-3834). (#3923)
(cherry picked from commit f07e2b64df)
2017-10-08 12:51:55 +03:00
Miss Islington (bot) 8aafd5fd79 [3.6] remove tabs from getcompiler.c (GH-3892) (#3893)
(cherry picked from commit a8ed11742b)
2017-10-05 08:41:06 -07:00
Miss Islington (bot) a4dfe1c9ea [3.6] bpo-31592: Fix an assertion failure in Python parser in case of a bad unicodedata.normalize(). (GH-3767) (#3836)
(cherry picked from commit 7dc46d8cf5)
2017-09-30 22:51:37 +03:00
Miss Islington (bot) 66c2b9f13e [3.6] bpo-31285: Remove splitlines identifier from Python/_warnings.c (GH-3803) (#3829)
(forgot to remove it in GH-3219)
(cherry picked from commit 8b4ff53c44)
2017-09-29 22:26:45 +03:00
Miss Islington (bot) 084f80b82c [3.6] bpo-31588: Validate return value of __prepare__() methods (GH-3790)
Class execution requires that __prepare__() methods return
a proper execution namespace. Check for that immediately
after calling __prepare__(), rather than passing it through
to the code execution machinery and potentially triggering
SystemError (in debug builds) or a cryptic TypeError
(in release builds).

Patch by Oren Milman.
(cherry picked from commit 5837d0418f)
2017-09-28 02:21:33 +10:00
Serhiy Storchaka 90fe25a051 [3.6] bpo-31285: Fix an assertion failure and a SystemError in warnings.warn_explicit. (GH-3219) (#3775)
(cherry picked from commit 91fb0afe18)
2017-09-27 07:38:03 +03:00
Serhiy Storchaka f0db2dfda7 [3.6] bpo-31492: Fix assertion failures in case of a module with a bad __name__ attribute. (GH-3620). (#3773)
(cherry picked from commit 6db7033192)
2017-09-27 07:33:00 +03:00
Miss Islington (bot) 415cc1fa57 [3.6] bpo-31566: Fix an assertion failure in _warnings.warn() in case of a bad __name__ global. (GH-3717) (#3730)
(cherry picked from commit 5d3e80021a)
2017-09-24 23:14:41 +03:00
Miss Islington (bot) 99a51d4e5b [3.6] bpo-31315: Fix an assertion failure in imp.create_dynamic(), when spec.name is not a string. (GH-3257) (#3653)
(cherry picked from commit 9974e1bcf3)
2017-09-19 15:51:19 +03:00
Miss Islington (bot) 5dbb28ecec [3.6] bpo-31418: Fix an assertion failure in PyErr_WriteUnraisable() in case of an exception with a bad __module__ attribute. (GH-3539) (#3556)
(cherry picked from commit f6e61df015)
2017-09-14 09:41:39 +03:00
Victor Stinner c0e77364ca [3.6] bpo-30923: Silence fall-through warnings included in -Wextra since gcc-7.0 (#3518)
* bpo-30923: Disable warning that has been part of -Wextra since gcc-7.0. (#3142)

(cherry picked from commit d73a960c57)

* bpo-30923: Silence fall-through warnings included in -Wextra since gcc-7.0. (#3157)

(cherry picked from commit f432a3234f)

* bpo-31275: Small refactoring to silence a fall-through warning. (#3206)

(cherry picked from commit 138753c1b9)
2017-09-12 16:09:44 -07:00
Serhiy Storchaka 9adc87b0f8 [3.6] bpo-31416: Fix assertion failures in case of a bad warnings.filters or warnings.defaultaction. (GH-3496) (#3509)
Patch by Oren Milman..
(cherry picked from commit 9d984fd2b0)
2017-09-12 09:48:27 +03:00
Benjamin Peterson cb356c2ecc [3.6] bpo-31373: remove overly strict float range checks (GH-3486) (#3495)
This undoes a853a8ba78 except for the pytime.c
parts. We want to continue to allow IEEE 754 doubles larger than FLT_MAX to be
rounded into finite floats. Tests were added to very this behavior.
(cherry picked from commit 2bb69a5b4e)
2017-09-11 23:08:49 -07:00
Serhiy Storchaka 7972ed2111 [3.6] bpo-31411: Prevent raising a SystemError in case warnings.onceregistry is not a dictionary. (GH-3485). (#3494)
(cherry picked from commit 252033d50e)
2017-09-11 10:01:47 +03:00
Serhiy Storchaka c67838da2c [3.6] bpo-29526: Add reference to help('FORMATTING') in format() builtin (GH-166). (#3491)
(cherry picked from commit 2e6bb4484e)
2017-09-11 09:26:15 +03:00
Miss Islington (bot) a4baf1c543 [3.6] bpo-26669: Fix nan arg value error in pytime.c (GH-3085) (GH-3467)
* Modify NaN check function and error message
* Fix pytime.c when arg is nan
* fix whitespace
(cherry picked from commit 829dacce4f)
2017-09-08 21:53:04 -07:00
Serhiy Storchaka ddb536ba7b [3.6] bpo-31393: Fix the use of PyUnicode_READY(). (GH-3451). (#3453)
(cherry picked from commit e3b2b4b8d9)
2017-09-08 10:43:54 +03:00
Zackery Spytz f032e9237a [3.6] bpo-30640: Fix undefined behavior in _PyFunction_FastCallDict() and PyEval_EvalCodeEx() (GH-2919) (#2964)
k + 1 was calculated with k = NULL..
(cherry picked from commit c6ea8974e2)
2017-09-08 03:17:38 +02:00
Miss Islington (bot) b03623227e [3.6] fixes bpo-31373: fix undefined floating-point demotions (GH-3396) (#3424)
(cherry picked from commit a853a8ba78)
2017-09-07 11:35:03 -07:00
Miss Islington (bot) aa1afc72c1 bpo-30465: Fix lineno and col_offset in fstring AST nodes (GH-1800) (gh-3409)
For f-string ast nodes, fix the line and columns so that tools such as flake8 can identify them correctly.
(cherry picked from commit e7c566caf1)
2017-09-06 19:43:04 -07:00
INADA Naoki 2eea952b1b bpo-31095: fix potential crash during GC (GH-3195)
(cherry picked from commit a6296d34a4)
2017-09-04 12:31:09 +09:00
Serhiy Storchaka f3b891718e [3.6] bpo-31070: Fix a race condition in importlib _get_module_lock(). (GH-3033). (#3038)
(cherry picked from commit 9b0d1d647e)
2017-08-09 14:56:13 +03:00
Yuan Chao Chou a0cb7db8e4 Fix a shadow-compatible-local warning (#2181)
Change the shadowing naming, 'value' (Python-ast.c:4686), to 'val'
to prevent the variables from being misused.
2017-08-04 10:53:42 -07:00
Serhiy Storchaka 946a0b69e2 [3.6] bpo-31071: Avoid masking original TypeError in call with * unpacking (GH-2957) (#2991)
when other arguments are passed.
(cherry picked from commit 25e4f77)
2017-08-03 12:14:35 +03:00
Victor Stinner bb323b261d bpo-30891: Fix again importlib _find_and_load() (#2665) (#2801)
Use sys.modules.get() in the "with _ModuleLockManager(name):" block
to protect the dictionary key with the module lock and use an atomic
get to prevent race condition.

Remove also _bootstrap._POPULATE since it was unused
(_bootstrap_external now has its own _POPULATE object), add a new
_SENTINEL object instead.
(cherry picked from commit e72b1359f8)
2017-07-21 13:28:55 +02:00
Serhiy Storchaka 28343e3392 [3.6] bpo-30876: Relative import from unloaded package now reimports the package (GH-2639) (#2676)
instead of failing with SystemError.

Relative import from non-package now fails with ImportError rather than
SystemError.
(cherry picked from commit 8a9cd20edc)
2017-07-16 07:44:25 +03:00
Victor Stinner fe6e686c27 bpo-30891: Fix importlib _find_and_load() race condition (#2646) (#2651)
* Rewrite importlib _get_module_lock(): it is now responsible to hold
  the imp lock directly.
* _find_and_load() now holds the module lock to check if name is in
  sys.modules to prevent a race condition
(cherry picked from commit 4f9a446f3f)
2017-07-10 23:16:27 +02:00
Serhiy Storchaka 03b0e8374b [3.6] bpo-30814: Fixed a race condition when import a submodule from a package. (GH-2580). (#2598)
(cherry picked from commit b4baacee1a)
2017-07-06 08:38:24 +03:00
Masayuki Yamamoto e3a0ff0d76 [3.6] bpo-30854: Fix compile error when --without-threads (GH-2581) (#2583)
* bpo-30854: Fix compile error when --without-threads

* bpo-30854: fix news
(cherry picked from commit 0c31163093)
2017-07-05 11:24:46 +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
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
Antoine Pitrou 55ab604e3f [3.6] bpo-30765: Avoid blocking when PyThread_acquire_lock() is asked not to (GH-2403) (#2418)
* bpo-30765: Avoid blocking when PyThread_acquire_lock() is asked not to lock

This is especially important if PyThread_acquire_lock() is called reentrantly
(for example from a signal handler).

* Update 2017-06-26-14-29-50.bpo-30765.Q5iBmf.rst

* Avoid core logic when taking the mutex failed
(cherry picked from commit f84ac420c2)
2017-06-26 21:57:28 +02:00
Serhiy Storchaka 2eca5b465f [3.6] bpo-30682: Removed a too-strict assertion that failed for certain f-strings. (GH-2232) (#2242)
This caused a segfault on eval("f'\\\n'") and eval("f'\\\r'") in debug build..
(cherry picked from commit 11e97f2f80)
2017-06-16 09:29:42 -04:00
Serhiy Storchaka fab05de214 [3.6] bpo-30626: Fix error handling in PyImport_Import(). (GH-2103) (#2221)
In rare circumstances PyImport_Import() could return NULL without raising
an error.
(cherry picked from commit 145541c)
2017-06-15 21:15:11 +03:00
Victor Stinner 932946ca14 bpo-30604: Fix __PyCodeExtraState_Get() prototype (#2152)
Replace __PyCodeExtraState_Get() with __PyCodeExtraState_Get(void) to
fix the following GCC warning:

./Include/pystate.h:63:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
 __PyCodeExtraState* __PyCodeExtraState_Get();
2017-06-13 10:39:30 +02:00
Dino Viehland 2997fec01e [3.6] bpo-30604: Move co_extra_freefuncs to interpreter state to avoid crashes in threads (#2015)
* Move co_extra_freefuncs to interpreter state to avoid crashes in
multi-threaded scenarios involving deletion of code objects

* Don't require that extra be zero initialized

* Build test list instead of defining empty test class

* Ensure extra is always assigned on success

* Keep the old fields in the thread state object, just don't use them
Add new linked list of code extra objects on a per-interpreter basis
  so that interpreter state size isn't changed

* Rename __PyCodeExtraState_Get and add comment about it going away in 3.7
Fix sort order of import's in test_code.py

* Remove an extraneous space

* Remove docstrings for comments

* Touch up formatting

* Fix casing of coextra local

* Fix casing of another variable

* Prefix PyCodeExtraState with __ to match C API for getting it

* Update NEWS file for bpo-30604
2017-06-12 21:46:35 -04: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
Serhiy Storchaka 570b1c971c [3.6] bpo-30529: Fix errors for invalid whitespaces in f-string subexpressions. (GH-1888) (#2013)
'invalid character in identifier' now is raised instead of
'f-string: empty expression not allowed' if a subexpression contains
only whitespaces and they are not accepted by Python parser.
(cherry picked from commit 2e9cd58)
2017-06-09 00:38:06 +03:00
Serhiy Storchaka 68e5af89d4 [3.6] bpo-30567: Fix refleak in sys.getwindowsversion (GH-1940) (#1970)
(cherry picked from commit 48fb766)
2017-06-06 19:23:02 +03:00
Serhiy Storchaka 89a3102640 [3.6] bpo-29104: Fixed parsing backslashes in f-strings. (GH-490) (#1812)
(cherry picked from commit 0cd7a3f)
2017-05-25 14:18:55 +03:00
Łukasz Langa d29feccec3 [3.6] bpo-30395 _PyGILState_Reinit deadlock fix (GH-1734) (#1740)
head_lock could be held by another thread when fork happened. We should
reset it to avoid deadlock.
(cherry picked from commit f82c951d1c)
2017-05-22 22:23:05 -07:00
Xiang Zhang 98b49a00d4 bpo-30281: Fix the default value for stop in PySlice_Unpack() (#1480) (#1529) 2017-05-10 19:00:15 +08:00