Commit Graph

5327 Commits

Author SHA1 Message Date
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
Victor Stinner 31906b42fd bpo-30225: Fix is_valid_fd() on macOS Tiger (#1443) (#1449)
is_valid_fd() now uses fstat() instead of dup() on macOS to return 0
on a pipe when the other side of the pipe is closed. fstat() fails
with EBADF in that case, whereas dup() succeed.
(cherry picked from commit 1c4670ea0c)
2017-05-04 13:21:10 +02:00
Serhiy Storchaka bf4bb2e430 bpo-29935: Fixed error messages in the index() method of tuple, list and deque (#887) (#907)
when pass indices of wrong type.
(cherry picked from commit d4edfc9abf)
2017-03-30 19:46:59 +03:00
INADA Naoki fe30339534 bpo-29859: Fix error messages from return codes for pthread_* calls (GH-753)
(cherry picked from commit d7fa6b259e)
2017-03-22 03:46:26 +09:00
Serhiy Storchaka aac875fa2f [3.6] bpo-8256: Fixed possible failing or crashing input() (#641)
if attributes "encoding" or "errors" of sys.stdin or sys.stdout are not set or are not strings.
2017-03-12 21:52:17 +02:00
Serhiy Storchaka 4652d82a51 bpo-29746: Update marshal docs to Python 3. (#547) (#631)
(cherry picked from commit c611a5b1d4)
2017-03-12 10:05:05 +02:00
Xiang Zhang 16416c22f9 bpo-29770: remove outdated PYO related info (GH-590) (GH-612) 2017-03-11 14:07:30 +08:00
Victor Stinner 68d2980940 bpo-29619: Convert st_ino using unsigned integer (#557) (#584)
bpo-29619: os.stat() and os.DirEntry.inodeo() now convert inode
(st_ino) using unsigned integers.

(cherry picked from commit 0f6d73343d)
(Misc/NEWS conflict handled manually.)
2017-03-09 18:43:39 +01:00
Ned Deily 5976b9a88b Refresh Python/importlib.h and Python/importlib_external.h (#464) 2017-03-04 07:04:41 -05:00
Ned Deily 95c50e5aed [3.6] bpo-27593: Get SCM build info from git instead of hg. (#446) (#454)
* bpo-27593: Get SCM build info from git instead of hg. (#446)

sys.version and the platform module python_build(),
python_branch(), and python_revision() functions now use
git information rather than hg when building from a repo.

Based on original patches by Brett Cannon and Steve Dower.
(cherry picked from commit 5c4b0d063a)
2017-03-04 01:05:06 -05:00
Yury Selivanov dea5101ae1 bpo-28893: Set __cause__ for errors in async iteration protocol (#407) 2017-03-02 22:28:07 -05:00
INADA Naoki 023532e558 bpo-29684: Fix minor regression of PyEval_CallObjectWithKeywords. (GH-378) 2017-03-01 21:14:43 +09:00
Berker Peksag 7accf2033d bpo-29655: Fixed possible reference leaks in `import *`. (#301) (#348)
Patch by Matthias Bussonnier.

(cherry picked from commit 160edb4357)
2017-02-27 20:41:21 +03:00
Martijn Pieters 53039ad381 bpo-28598: Support __rmod__ for RHS subclasses of str in % string formatting operations (#95) 2017-02-27 19:08:01 +03:00
INADA Naoki 3ab24bdd47 bpo-29607: Fix stack_effect computation for CALL_FUNCTION_EX (GH-219)
(cherry picked from commit 3a9ac827c7)
2017-02-22 02:33:24 +09:00
Serhiy Storchaka ad9422559f Issue #26729: Fixed __text_signature__ for sorted().
Patch by Erik Welch.
2017-01-23 12:30:35 +02:00
Serhiy Storchaka 3a1042567c Issue #26729: Fixed __text_signature__ for sorted().
Patch by Erik Welch.
2017-01-23 12:29:47 +02:00
Serhiy Storchaka 398ef5c08f Issue #29327: Fixed a crash when pass the iterable keyword argument to sorted(). 2017-01-20 08:33:06 +02:00