Commit graph

6637 commits

Author SHA1 Message Date
Miss Islington (bot)
5c65834d80
bpo-44219: Release the GIL during isatty syscalls (GH-28250)
Release the GIL while performing isatty() system calls on arbitrary
file descriptors. In particular, this affects os.isatty(),
os.device_encoding() and io.TextIOWrapper. By extension,
io.open() in text mode is also affected.
(cherry picked from commit 06148b1870)

Co-authored-by: Vincent Michel <vxgmichel@gmail.com>
2021-09-09 06:40:42 -07:00
Miss Islington (bot)
41c2374024
[3.9] bpo-45083: Include the exception class qualname when formatting an exception (GH-28119) (GH-28135)
* bpo-45083: Include the exception class qualname when formatting an exception (GH-28119)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
(cherry picked from commit b4b6342848)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-09-03 18:56:05 +02:00
Miss Islington (bot)
720aef48b5
bpo-44449: faulthandler don't modify frame refcnt (GH-27850)
Fix a crash in the signal handler of the faulthandler module: no
longer modify the reference count of frame objects.
(cherry picked from commit fe997e1a67)

Co-authored-by: Victor Stinner <vstinner@python.org>
2021-08-30 06:56:03 -07:00
Miss Islington (bot)
6f4cdeddb9
bpo-25782: avoid hang in PyErr_SetObject when current exception has a cycle in its context chain (GH-27626) (GH-27707)
Co-authored-by: Dennis Sweeney 36520290+sweeneyde@users.noreply.github.com
(cherry picked from commit d5c217475c)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2021-08-10 13:08:41 +02:00
Miss Islington (bot)
ed718e9b07
bpo-44856: Possible reference leak in error paths of update_bases() and __build_class__ (GH-27647) (GH-27651)
(cherry picked from commit a40675c659)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-08-07 13:17:41 +02:00
Miss Islington (bot)
791c28a56f
bpo-44849: Fix os.set_inheritable() on FreeBSD 14 with O_PATH (GH-27623)
Fix the os.set_inheritable() function on FreeBSD 14 for file
descriptor opened with the O_PATH flag: ignore the EBADF error on
ioctl(), fallback on the fcntl() implementation.
(cherry picked from commit c24896c0e3)

Co-authored-by: Victor Stinner <vstinner@python.org>
2021-08-06 06:42:51 -07:00
Miss Islington (bot)
0b551db04a
bpo-39091: Fix segfault when Exception constructor returns non-exception for gen.throw. (GH-17658) (GH-27573)
Co-authored-by: Benjamin Peterson <benjamin@python.org>
(cherry picked from commit 83ca46b778)

Co-authored-by: Noah <33094578+coolreader18@users.noreply.github.com>
2021-08-03 12:10:54 +02:00
Mark Shannon
7ebd7465a5
Set line number of END_ASYNC_FOR so that it doesn't show in traces. (GH-27255) 2021-07-20 12:09:56 +02:00
Miss Islington (bot)
6fb4248cd9
bpo-44472: Fix ltrace functionality when exceptions are raised (GH-26822) (#26831)
(cherry picked from commit 06cda808f1)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2021-07-12 17:11:10 +02:00
Steve Dower
863e3d5c7e
bpo-41180: Replace marshal code.__new__ audit event with marshal.load[s] and marshal.dumps (GH-26971) 2021-06-30 18:52:39 +01:00
Victor Stinner
5ed7827b16
bpo-44441: _PyImport_Fini2() resets PyImport_Inittab (GH-26874) (GH-26878)
Py_RunMain() now resets PyImport_Inittab to its initial value at
exit. It must be possible to call PyImport_AppendInittab() or
PyImport_ExtendInittab() at each Python initialization.

(cherry picked from commit 489699ca05)
2021-06-23 17:47:33 +02:00
Miss Islington (bot)
57b3ca7f0a
bpo-41299: Reduce lag in Windows threading timeouts by using a higher precision time source (GH-26568)
(cherry picked from commit 449e6f0ef3)

Co-authored-by: Ryan Hileman <lunixbochs@gmail.com>
2021-06-11 15:03:10 -07:00
Batuhan Taskaya
de58b319af
[3.9] bpo-11105: Do not crash when compiling recursive ASTs (GH-20594) (GH-26522)
When compiling an AST object with a direct / indirect reference
cycles, on the conversion phase because of exceeding amount of
calls, a segfault was raised. This patch adds recursion guards to
places for preventing user inputs to not to crash AST but instead
raise a RecursionError..
(cherry picked from commit f3491242e4)

Co-authored-by: Batuhan Taskaya <batuhan@python.org>
2021-06-03 22:22:34 +01:00
Jakub Kulík
d3cc68900d
[3.9] bpo-43667: Fix broken Unicode encoding in non-UTF locales on Solaris (GH-25096) (GH-25847)
(cherry picked from commit 9032cf5cb1)

Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
2021-05-21 16:59:39 +02:00
Miss Islington (bot)
133013e8a1
bpo-28146: Fix a confusing error message in str.format() (GH-24213)
Automerge-Triggered-By: GH:pitrou
(cherry picked from commit 4aeee0b47b)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
2021-05-13 14:35:30 -07:00
Steve Dower
23822e2c65
bpo-44070: No longer eagerly makes import filenames absolute, except for extension modules (GH-26025) 2021-05-10 23:45:50 +01:00
Steve Dower
bb2f3ff7a8
bpo-42800: Add audit events for f_code and tb_frame (GH-24182)
Accessing the following attributes will now fire PEP 578 style audit hooks as (object.__getattr__, obj, name):
* PyTracebackObject: tb_frame
* PyFrameObject: f_code
* PyGenObject: gi_code, gi_frame
* PyCoroObject: cr_code, cr_frame
* PyAsyncGenObject: ag_code, ag_frame
2021-05-03 14:06:36 +01:00
Steve Dower
0af99b44ed
bpo-43105: Importlib now resolves relative paths when creating module spec objects from file locations (GH-25121) 2021-04-07 12:35:36 +01:00
Gregory P. Smith
c7b0feca25
[3.9] bpo-43710: Rollback the 3.9 bpo-42500 fix, it broke the ABI in 3.9.3 (#25179)
This reverts commit 8b795ab554.

It changed the PyThreadState structure size, breaking the ABI in 3.9.3.
2021-04-04 13:02:29 +02:00
Miss Islington (bot)
ff4715a733
bpo-43660: Fix crash when displaying exceptions with custom values for sys.stderr (GH-25075) (GH-25083)
(cherry picked from commit 09b90a037d)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2021-03-30 00:24:33 +01:00
Antoine Pitrou
ac17ed60f2
[3.9] bpo-43517: Fix false positive in detection of circular imports (GH-24895) (GH-24948)
(cherry picked from commit 2fd16ef406)

Co-authored-by: Antoine Pitrou <antoine@python.org>

Automerge-Triggered-By: GH:pitrou
2021-03-20 12:40:18 -07:00
Miss Islington (bot)
aa967ec4d4
bpo-35883: Py_DecodeLocale() escapes invalid Unicode characters (GH-24843)
Python no longer fails at startup with a fatal error if a command
line argument contains an invalid Unicode character.

The Py_DecodeLocale() function now escapes byte sequences which would
be decoded as Unicode characters outside the [U+0000; U+10ffff]
range.

Use MAX_UNICODE constant in unicodeobject.c.
(cherry picked from commit 9976834f80)

Co-authored-by: Victor Stinner <vstinner@python.org>
2021-03-17 14:11:14 -07:00
Serhiy Storchaka
651fc30af7
bpo-43499: Silence compiler warnings about using legacy C API on Windows (GH-24873) 2021-03-16 08:03:37 +02:00
Mark Shannon
8b795ab554
bpo-42500: Fix recursion in or after except (GH-23568) (#24501)
* Use counter, rather boolean state when handling soft overflows.

(cherry picked from commit 4e7a69bdb6)
2021-03-02 11:36:38 +01:00
cptpcrd
6893523bed
bpo-42780: Fix set_inheritable() for O_PATH file descriptors on Linux (GH-24172) (GH-24278)
(cherry picked from commit 7dc71c425c)
2021-01-21 11:46:35 +01:00
Miss Islington (bot)
fa12749bcd
Bring Python into the new year. (GH-24036)
(cherry picked from commit de6f20a6de)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
2021-01-01 09:27:48 -08:00
Miss Islington (bot)
1c70d40e94
bpo-26564: fix obsolete comment in traceback.c (GH-23819)
(cherry picked from commit 40125ab325)

Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
2020-12-17 05:19:58 -08:00
Victor Stinner
f0e42ae03c
bpo-32381: Fix PyRun_SimpleFileExFlags() encoding (GH-23642) (GH-23692)
Fix encoding name when running a ".pyc" file on Windows:
PyRun_SimpleFileExFlags() now uses the correct encoding to decode the
filename.

* Add pyrun_file() subfunction.
* Add pyrun_simple_file() subfunction.
* PyRun_SimpleFileExFlags() now calls _Py_fopen_obj() rather than
  _Py_fopen().

(cherry picked from commit b6d98c10ff)
2020-12-08 16:16:05 +01:00
Brandt Bucher
60463e8e4f
bpo-42536: GC track recycled tuples (GH-23623) (GH-23651)
Several built-in and standard library types now ensure that their internal result tuples are always tracked by the garbage collector:

- collections.OrderedDict.items
- dict.items
- enumerate
- functools.reduce
- itertools.combinations
- itertools.combinations_with_replacement
- itertools.permutations
- itertools.product
- itertools.zip_longest
- zip

Previously, they could have become untracked by a prior garbage collection.
(cherry picked from commit 226a012d1c)
2020-12-07 20:07:48 +00:00
Miss Islington (bot)
9b34f34aa9
bpo-42521: Add note about 'Python -d' only working on debug builds (GH-23607)
(cherry picked from commit 99b594404d)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2020-12-02 14:01:23 -08:00
Ronald Oussoren
e8b1c038b1
[3.9] bpo-41100: Support macOS 11 and Apple Silicon (GH-22855) (GH-23295)
* [3.9] bpo-41100: Support macOS 11 and Apple Silicon (GH-22855)

Co-authored-by:  Lawrence D’Anna <lawrence_danna@apple.com>

* Add support for macOS 11 and Apple Silicon (aka arm64)

  As a side effect of this work use the system copy of libffi on macOS, and remove the vendored copy

* Support building on recent versions of macOS while deploying to older versions

  This allows building installers on macOS 11 while still supporting macOS 10.9..
(cherry picked from commit 41761933c1)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>

* Back port of changes to _decimal to support arm64

* temp_dir is in test.support in 3.9
2020-11-22 11:18:40 +01:00
Christian Heimes
35bf8ea7be
[3.9] bpo-40998: Fix a refleak in create_filter() (GH-23365) (GH-23369)
(cherry picked from commit d1e38d4023)
2020-11-18 09:45:29 -08:00
Miss Islington (bot)
994c68f586
bpo-40998: Address compiler warnings found by ubsan (GH-20929)
Signed-off-by: Christian Heimes <christian@python.org>

Automerge-Triggered-By: GH:tiran
(cherry picked from commit 07f2adedf0)

Co-authored-by: Christian Heimes <christian@python.org>
2020-11-18 08:01:48 -08:00
Irit Katriel
48a9c0eb2a
[3.9] bpo-39934: Account for control blocks in 'except' in compiler. (GH-22395) (GH-23303)
* bpo-39934: backport PR 22395 to 3.9
2020-11-17 19:31:55 +00:00
Victor Stinner
05a5d697f4
bpo-41686: Always create the SIGINT event on Windows (GH-23344) (GH-23347)
bpo-41686, bpo-41713: On Windows, the SIGINT event,
_PyOS_SigintEvent(), is now created even if Python is configured to
not install signal handlers (PyConfig.install_signal_handlers=0 or
Py_InitializeEx(0)).
2020-11-17 18:58:12 +01:00
Miss Islington (bot)
e5729aef6f
bpo-42296: On Windows, fix CTRL+C regression (GH-23257)
On Windows, fix a regression in signal handling which prevented to
interrupt a program using CTRL+C. The signal handler can be run in a
thread different than the Python thread, in which case the test
deciding if the thread can handle signals is wrong.

On Windows, _PyEval_SignalReceived() now always sets eval_breaker to
1 since it cannot test _Py_ThreadCanHandleSignals(), and
  eval_frame_handle_pending() always calls
  _Py_ThreadCanHandleSignals() to recompute eval_breaker.
(cherry picked from commit d96a7a8313)

Co-authored-by: Victor Stinner <vstinner@python.org>
2020-11-13 06:11:38 -08:00
Inada Naoki
07a44d9572
bpo-42057: Fix peephole optimizer (GH-22802) 2020-10-22 11:06:07 +09:00
Miss Skeleton (bot)
c17ff5cad2
bpo-38324: Fix test__locale.py Windows failures (GH-20529)
Use wide-char _W_* fields of lconv structure on Windows
Remove "ps_AF" from test__locale.known_numerics on Windows
(cherry picked from commit f2312037e3)

Co-authored-by: TIGirardi <tiagoigirardi@gmail.com>
2020-10-20 05:07:14 -07:00
Miss Skeleton (bot)
f07448bef4
bpo-41894: Fix UnicodeDecodeError while loading native module (GH-22466)
When running in a non-UTF-8 locale, if an error occurs while importing a
native Python module (say because a dependent share library is missing),
the error message string returned may contain non-ASCII code points
causing a UnicodeDecodeError.

PyUnicode_DecodeFSDefault is used for buffers which may contain
filesystem  paths. For consistency with os.strerror(),
PyUnicode_DecodeLocale is used for buffers which contain system error
messages. While the shortname parameter is always encoded in ASCII
according to PEP 489, it is left decoded using PyUnicode_FromString to
minimize the changes and since it should not affect the decoding (albeit
_potentially_ slower).

In dynload_hpux, since the error buffer contains a message generated
from a static ASCII string and the module filesystem path,
PyUnicode_DecodeFSDefault is used instead of PyUnicode_DecodeLocale as
is used elsewhere.

* bpo-41894: Fix bugs in dynload error msg handling

For both dynload_aix and dynload_hpux, properly handle the possibility
that decoding strings may return NULL and when such an error happens,
properly decrement any previously decoded strings and return early.

In addition, in dynload_aix, ensure that we pass the decoded string
*object* pathname_ob to PyErr_SetImportError instead of the original
pathname buffer.

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

Co-authored-by: Kevin Adler <kadler@us.ibm.com>
2020-10-14 19:25:45 -07:00
Miss Skeleton (bot)
391a544f2a
bpo-41993: Fix possible issues in remove_module() (GH-22631) (GH-22647)
* PyMapping_HasKey() is not safe because it silences all exceptions and can return incorrect result.
* Informative exceptions from PyMapping_DelItem() are overridden with RuntimeError and
  the original exception raised before calling remove_module() is lost.
* There is a race condition between PyMapping_HasKey() and PyMapping_DelItem().
(cherry picked from commit 8287aadb75)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-10-14 12:09:44 +03:00
Miss Islington (bot)
7aa534c956
bpo-41819: Fix compiler warning in init_dump_ascii_wstr() (GH-22332)
Fix the compiler warning:

format specifies type `wint_t` (aka `int`) but the argument has type `unsigned int`
(cherry picked from commit c322948892)

Co-authored-by: Samuel Marks <807580+SamuelMarks@users.noreply.github.com>
2020-09-21 01:58:27 -07:00
Pablo Galindo
55e0836849
[3.9] bpo-41631: _ast module uses again a global state (GH-21961) (GH-22258)
Partially revert commit ac46eb4ad6:
"bpo-38113: Update the Python-ast.c generator to PEP384 (gh-15957)".

Using a module state per module instance is causing subtle practical
problems.

For example, the Mercurial project replaces the __import__() function
to implement lazy import, whereas Python expected that "import _ast"
always return a fully initialized _ast module.

Add _PyAST_Fini() to clear the state at exit.

The _ast module has no state (set _astmodule.m_size to 0). Remove
astmodule_traverse(), astmodule_clear() and astmodule_free()
functions..
(cherry picked from commit e5fbe0cbd4)

Co-authored-by: Victor Stinner <vstinner@python.org>
2020-09-15 20:32:56 +02:00
Miss Islington (bot)
b2376f9141
Fix compiler warnings in init_dump_ascii_wstr() (GH-22150)
Fix GCC 9.3 (using -O3) warnings on x86:

initconfig.c: In function ‘init_dump_ascii_wstr’:
initconfig.c:2679:34: warning: format ‘%lc’ expects argument of type
‘wint_t’, but argument 2 has type ‘wchar_t’ {aka ‘long int’}
 2679 |             PySys_WriteStderr("%lc", ch);
initconfig.c:2682:38: warning: format ‘%x’ expects argument of type
‘unsigned int’, but argument 2 has type ‘wchar_t’ {aka ‘long int’}
 2682 |             PySys_WriteStderr("\\x%02x", ch);
initconfig.c:2686:38: warning: format ‘%x’ expects argument of type
‘unsigned int’, but argument 2 has type ‘wchar_t’ {aka ‘long int’}
 2686 |             PySys_WriteStderr("\\U%08x", ch);
initconfig.c:2690:38: warning: format ‘%x’ expects argument of type
‘unsigned int’, but argument 2 has type ‘wchar_t’ {aka ‘long int’}
 2690 |             PySys_WriteStderr("\\u%04x", ch);
(cherry picked from commit 640e8e1d5f)

Co-authored-by: Victor Stinner <vstinner@python.org>
2020-09-09 03:31:25 -07:00
Miss Islington (bot)
11a82c7220
bpo-41525: Make the Python program help ASCII-only (GH-21836)
(cherry picked from commit 58de1dd6a8)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-09-08 17:47:53 -07:00
Miss Islington (bot)
d64d78be20
bpo-41531: Fix compilation of dict literals with more than 0xFFFF elements (GH-21850) (GH-22107)
(cherry picked from commit c51db0ea40)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2020-09-05 00:38:50 +01:00
Miss Islington (bot)
106c1df736
closes bpo-41533: Fix a potential memory leak when allocating a stack (GH-21847)
Free the stack allocated in va_build_stack if do_mkstack fails
and the stack is not a small_stack
(cherry picked from commit 75c80b0bda)

Co-authored-by: Tony Solomonik <tony.solomonik@gmail.com>
2020-09-04 15:56:04 -07:00
Miss Islington (bot)
c16a2a1b64
bpo-41681: Fix for f-string/str.format error description when using 2 , in format specifier (GH-22036) (GH-22041)
* Fixed `f-string/str.format` error description when using two `,` in format specifier.

Co-authored-by: millefalcon <hanish0019@hmail.com>
(cherry picked from commit 0d6aa7f0ee)

Co-authored-by: han-solo <hanish0019@gmail.com>

Co-authored-by: han-solo <hanish0019@gmail.com>
2020-09-01 11:45:59 -04:00
Miss Islington (bot)
901c2eae6e
bpo-41524: fix pointer bug in PyOS_mystr{n}icmp (GH-21845) (GH-21978) 2020-08-30 15:53:09 +09:00
Victor Stinner
d2bea2636d
[3.9] bpo-41194: Convert _ast extension to PEP 489 (GH-21807)
* bpo-41194: Convert _ast extension to PEP 489 (GH-21293)

Convert the _ast extension module to PEP 489 "Multiphase
initialization". Replace the global _ast state with a module state.

(cherry picked from commit b1cc6ba73a)

* bpo-41204: Fix compiler warning in ast_type_init() (GH-21307)

(cherry picked from commit 1f76453173)
2020-08-10 15:55:54 +02:00
Miss Islington (bot)
f2f6759a78
Fix -Wstrict-prototypes warning in thread_pthread.h. (GH-21477)
(cherry picked from commit ea62a4bd54)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2020-07-15 06:30:26 -07:00