Commit Graph

5378 Commits

Author SHA1 Message Date
Miss Islington (bot) e1ebf51f76 bpo-24596: Decref module in PyRun_SimpleFileExFlags() on SystemExit (GH-7918) (GH-8069)
PyErr_Print() will not return when the exception is a SystemExit, so
decref the __main__ module object in that case.
(cherry picked from commit d8cba5d16f)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-07-03 22:17:46 +02:00
Miss Islington (bot) 8f8ad2c382
bpo-33451: Close pyc files before calling PyEval_EvalCode() (GH-7884)
Directly executed pyc files were being kept open longer than necessary.
(cherry picked from commit ea737751b1)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-06-23 20:41:40 -07:00
Miss Islington (bot) 4251d2a354
bpo-31849: Fix warning in pyhash.c (GH-6799)
(cherry picked from commit a8eb58546b)

Co-authored-by: A. Jesse Jiryu Davis <jesse@emptysquare.net>
2018-06-04 10:14:26 -07:00
T. Wouters 500a419a7a
[3.6] bpo-32591: fix abort in _PyErr_WarnUnawaitedCoroutine during shutdown (GH-5337) (#6536)
When an unawaited coroutine is collected very late in shutdown --
like, during the final GC at the end of PyImport_Cleanup -- then it
was triggering an interpreter abort, because we'd try to look up the
"warnings" module and not only was it missing (we were prepared for
that), but the entire module system was missing (which we were not
prepared for).

I've tried to fix this at the source, by making the utility function
get_warnings_attr robust against this in general. Note that it already
has the convention that it can return NULL without setting an error,
which is how it signals that the attribute it was asked to fetch is
missing, and that all callers already check for NULL returns.

There's a similar check for being late in shutdown at the top of
warn_explicit, which might be unnecessary after this fix, but I'm not
sure so I'm going to leave it..
(cherry picked from commit dba976b8a2)

Co-authored-by: Nathaniel J. Smith <njs@pobox.com>
2018-05-31 12:20:46 +02:00
Miss Islington (bot) 0fe3be0392 bpo-33677: Fix signatures of tp_clear handlers for AST and deque. (GH-7196) (GH-7269)
(cherry picked from commit a5c42284e6)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-05-31 09:10:28 +03:00
Miss Islington (bot) 0d17e60b33
bpo-28055: Fix unaligned accesses in siphash24(). (GH-6123)
The hash implementation casts the input pointer to uint64_t* and directly reads
from this, which may cause unaligned accesses. Use memcpy() instead so this code
will not crash with SIGBUS on sparc.

https://bugs.gentoo.org/show_bug.cgi?id=636400
(cherry picked from commit 1e2ec8a996)

Co-authored-by: Rolf Eike Beer <eike@sf-mail.de>
2018-05-13 04:40:03 -07:00
Serhiy Storchaka b16681fb1e
[3.6] bpo-33330: Improve error handling in PyImport_Cleanup(). (GH-6564). (GH-6604)
(cherry picked from commit e9d9494d6b)
2018-04-26 03:27:51 +03:00
Miss Islington (bot) 3468a05f6a [3.6] bpo-29673: fix gdb scripts pystack and pystackv (GH-6126) (GH-6400)
(cherry picked from commit 3a9ccee0e5)

Co-authored-by: Marcel Plch <gmarcel.plch@gmail.com>
2018-04-06 18:15:34 -04:00
Miss Islington (bot) 2350a47652
bpo-33231: Fix potential leak in normalizestring() (GH-6386)
(cherry picked from commit 0c1c4563a6)

Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
2018-04-06 00:37:03 -07:00
Miss Islington (bot) 4fd6c27dc8
bpo-29922: Improve error messages in 'async with' (GH-6352)
when __aenter__() or __aexit__() return non-awaitable object.
(cherry picked from commit a68f2f0578)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-04-04 07:09:14 -07:00
Serhiy Storchaka 25c869edd6
[3.6] bpo-33132: Fix reference counting issues in the compiler. (GH-6209). (GH-6321)
(cherry picked from commit a95d98607e)
2018-03-31 23:54:13 +03:00
Serhiy Storchaka 18d7edf32e
[3.6] bpo-33041: Fixed jumping if the function contains an "async for" loop. (GH-6154). (GH-6199)
(cherry picked from commit b9744e924c)
2018-03-23 15:45:37 +02:00
Miss Islington (bot) f3e6eadbcf [3.6] bpo-33021: Release the GIL during fstat() calls (GH-6019) (GH-6160)
fstat may block for long time if the file descriptor is on a
non-responsive NFS server, hanging all threads. Most fstat() calls are
handled by _Py_fstat(), releasing the GIL internally, but but
_Py_fstat_noraise() does not release the GIL, and most calls release the
GIL explicitly around it.

This patch fixes last 2 calls to _Py_fstat_no_raise(), avoiding hangs
when calling:
- mmap.mmap()
- os.urandom()
- random.seed()
(cherry picked from commit 4484f9dca9)

Co-authored-by: Nir Soffer <nirsof@gmail.com>
2018-03-20 20:40:18 +01:00
Miss Islington (bot) d0826340d9
[3.7] bpo-33041: Add missed error checks when compile "async for" (GH-6053) (GH-6060)
and remove redundant code.
(cherry picked from commit 67ee07795b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit 9e94c0d3c7)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-03-10 11:32:49 -08:00
Barry Warsaw 86ea851346
Revert "[3.6] bpo-32303 - Consistency fixes for namespace loaders (GH-5481) (#5504)" (#5911)
This reverts commit a71397fb66.
2018-02-26 11:23:24 -08:00
Miss Islington (bot) 65a13c19e8
bpo-32869: Fix incorrect dst buffer size for MultiByteToWideChar (GH-5739)
This function expects the destination buffer size to be given
in wide characters, not bytes.
(cherry picked from commit b3b4a9d300)

Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
2018-02-18 10:58:09 -08:00
Miss Islington (bot) b90c68586e bpo-32777: Fix _Py_set_inheritable async-safety in subprocess (GH-5560) (GH-5563)
Fix a rare but potential pre-exec child process deadlock in subprocess on POSIX systems when marking file descriptors inheritable on exec in the child process.  This bug appears to have been introduced in 3.4 with the inheritable file descriptors support.

This also changes Python/fileutils.c `set_inheritable` to use the "slow" two `fcntl` syscall path instead of the "fast" single `ioctl` syscall path when asked to be async signal safe (by way of being asked not to raise exceptions).  `ioctl` is not a POSIX async-signal-safe approved function.

ref: http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html
(cherry picked from commit c1e46e94de)

Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
2018-02-05 22:51:10 -08:00
Terry Jan Reedy c90a5dec03
[3.6] bpo-32746: Fix multiple typos (GH-5144) (GH-5522)
Fix typos found by codespell in docs, docstrings, and comments.
Fixes for the following files were in post-3.6 code and not backported:
Lib/ctypes/_aix.py (new), Lib/test/test_concurrent_futures.py,
Modules/_asynciomodule.c, Modules/_pickle.c, Objects/obmalloc.c.

(cherry picked from commit c3d9508ff2)
2018-02-03 21:00:24 -05:00
Barry Warsaw a71397fb66
[3.6] bpo-32303 - Consistency fixes for namespace loaders (GH-5481) (#5504)
* Make sure ``__spec__.loader`` matches ``__loader__`` for namespace packages.
* Make sure ``__spec__.origin` matches ``__file__`` for namespace packages.

https://bugs.python.org/issue32303
https://bugs.python.org/issue32305.
(cherry picked from commit bbbcf8693b)

Co-authored-by: Barry Warsaw <barry@python.org>
2018-02-02 23:21:14 -05:00
Miss Islington (bot) f61951b10c bpo-32674: Improve the docstring for __import__ (GH-5339) (GH-5489)
Clarify that the level argument is used to determine whether to
perform absolute or relative imports: 0 is absolute, while a positive number
is the number of parent directories to search relative to the current module.
(cherry picked from commit 461d225b19)

Co-authored-by: oldk <oldk1331@users.noreply.github.com>
2018-02-02 08:32:19 -05:00
Miss Islington (bot) f31c70b0d6 Fix typo in thread_nt.h code comment (GH-5211) (GH-5226)
The comment for PyThread_allocate_lock says "It has too be implemented ...".
There was an extra "o" in ".. to be implemented.."
(cherry picked from commit 6027802ca7)
2018-01-17 16:40:33 -08:00
Victor Stinner b92c159efa
[3.6] bpo-32555: Fix locale encodings (#5193)
On FreeBSD and Solaris, os.strerror() now always decode the byte
string from the current locale encoding, rather than using
ASCII/surrogateescape in some cases.

Changes:

* Add _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx() which has an
  additional current_locale parameter.
* PyUnicode_DecodeLocale(), PyUnicode_DecodeLocaleAndSize() and
* PyUnicode_EncodeLocale() now always use the current locale
* encoding, instead of using Py_DecodeLocale()/Py_EncodeLocale().
* Document encoding in Py_DecodeLocale() and Py_EncodeLocale()
  documentations.
* Add USE_FORCE_ASCII define to not define
  decode_ascii_surrogateescape() on Android.
2018-01-15 23:43:24 +01:00
Victor Stinner 5f959c4f9e
[3.6] bpo-31900: Fix localeconv() encoding for LC_NUMERIC (#4174) (#5192)
* Add _Py_GetLocaleconvNumeric() function: decode decimal_point and
  thousands_sep fields of localeconv() from the LC_NUMERIC encoding,
  rather than decoding from the LC_CTYPE encoding.
* Modify locale.localeconv() and "n" formatter of str.format() (for
  int, float and complex to use _Py_GetLocaleconvNumeric()
  internally.

(cherry picked from commit cb064fc232)
2018-01-15 23:23:47 +01:00
Miss Islington (bot) e29573910c advance copyright years to 2018 (GH-5094) (#5104)
(cherry picked from commit 65f2a6dcc2)
2018-01-05 23:12:14 -08:00
Miss Islington (bot) 5659743b56 bpo-32365: Fix a reference leak when compile __debug__. (GH-4916) (#4918)
It was introduced in bpo-27169.
(cherry picked from commit bd6ec4d79e)
2017-12-18 15:11:51 +02:00
Victor Stinner da2b79867e
compile.c: Remove unused varible (#4886)
Fix a compiler warning.
2017-12-15 16:29:48 +01:00
Serhiy Storchaka b580f4f2bf
[3.6] bpo-30416: Protect the optimizer during constant folding. (#4865)
It no longer spends much time doing complex calculations and no
longer consumes much memory for creating large constants that will
be dropped later.

This fixes also bpo-21074.
2017-12-15 14:12:14 +02:00
Serhiy Storchaka b82da9ebb2
[3.6] bpo-27169: The __debug__ constant is now optimized out at compile time. (GH-4880) (#4882)
This fixes also bpo-22091..
(cherry picked from commit 3325a6780c)
2017-12-15 13:26:26 +02:00
Victor Stinner 22097aaa77
bpo-32329: Fix sys.flags.hash_randomization (#4875)
sys.flags.hash_randomization is now properly set to 0 when hash
randomization is turned off by PYTHONHASHSEED=0.
2017-12-15 01:39:48 +01:00
Nick Coghlan c8f32aae0a
[3.6] bpo-32176: Set CO_NOFREE in the code object constructor (GH-4684)
Previously, CO_NOFREE was set in the compiler, which meant
it could end up being set incorrectly when code objects
were created directly. Setting it in the constructor based
on freevars and cellvars ensures it is always accurate,
regardless of how the code object is defined.

(cherry picked from commit 078f1814f1)
2017-12-03 23:32:54 +10:00
Miss Islington (bot) 9881e4e538 Don't hide unexpected errors in PyErr_WarnExplicitObject(). (GH-4585) (#4662)
(cherry picked from commit a561862048)
2017-12-01 09:21:45 +02:00
Victor Stinner e10c9de9d7
bpo-20891: Fix PyGILState_Ensure() (#4650) (#4655)
When PyGILState_Ensure() is called in a non-Python thread before
PyEval_InitThreads(), only call PyEval_InitThreads() after calling
PyThreadState_New() to fix a crash.

Add an unit test in test_embed.

Enhance also embedded tests, backport from master:

* Add test_pre_initialization_api()
* Set PYTHONIOENCODING environment variable in
  test_forced_io_encoding()

(cherry picked from commit b4d1e1f7c1)
2017-11-30 23:36:49 +01:00
Miss Islington (bot) d15bb5fcad bpo-32011: Revert "Issue GH-15480: Remove the deprecated and unused TYPE_INT64 code from marshal." (GH-4381) (#4405)
Simplify the reverted code.

This reverts commit e9bbe8b87b.
(cherry picked from commit 00987f6230)
2017-11-15 18:05:58 +02:00
Serhiy Storchaka 3864248866
[3.6] bpo-31949: Fixed several issues in printing tracebacks (PyTraceBack_Print()). (GH-4289) (#4406)
* Setting sys.tracebacklimit to 0 or less now suppresses printing tracebacks.
* Setting sys.tracebacklimit to None now causes using the default limit.
* Setting sys.tracebacklimit to an integer larger than LONG_MAX now means using
  the limit LONG_MAX rather than the default limit.
* Fixed integer overflows in the case of more than 2**31 traceback items on
  Windows.
* Fixed output errors handling..
(cherry picked from commit edad8eebee)
2017-11-15 18:04:46 +02:00
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