Commit graph

8154 commits

Author SHA1 Message Date
Miss Islington (bot)
ffde4cddc9
[3.12] gh-98442: fix locations of with statement's cleanup instructions (GH-120763) (#120787)
gh-98442: fix locations of with statement's cleanup instructions (GH-120763)
(cherry picked from commit 55596ae044)


gh-98442: fix location of with statement's cleanup instructions

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2024-09-15 19:14:19 +00:00
Miss Islington (bot)
1248524940
[3.12] gh-123892: Add "_wmi" to sys.stdlib_module_names (GH-123893) (#123897)
gh-123892: Add "_wmi" to sys.stdlib_module_names (GH-123893)
(cherry picked from commit fb1b51a58d)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-09-10 10:11:56 +00:00
Miss Islington (bot)
22ec9cb823
[3.12] gh-93691: fix too broad source locations of with-statement instructions (GH-120125) (#123605)
gh-93691: fix too broad source locations of with-statement instructions (GH-120125)
(cherry picked from commit eca3f7762c)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2024-09-02 14:45:09 +00:00
Irit Katriel
0181aa2e3e
[3.12] gh-123142: fix too wide source location of GET_ITER/GET_AITER (GH-123420). (#123436)
(cherry picked from commit 61bef6245c)
2024-08-28 18:41:40 +01:00
Donghee Na
6e6855950a
[3.12] gh-123083: Fix a potential use-after-free in ``STORE_ATTR_WITH… (#123237)
[3.12] gh-123083: Fix a potential use-after-free in ``STORE_ATTR_WITH_HINT`` (gh-123092)
(cherry picked from commit 297f2e093e)
2024-08-23 01:37:40 +09:00
Irit Katriel
fbbde4dc6a
[3.12] gh-123142: Fix too wide source locations in tracebacks of exceptions from broken iterables in comprehensions (GH-123173). (#123210)
(cherry picked from commit ec89620e5e)
2024-08-22 10:22:43 +01:00
Serhiy Storchaka
f2cc8ad989
[3.12] gh-118814: Fix the TypeVar constructor when name is passed by keyword (GH-122664) (GH-122807)
Fix _PyArg_UnpackKeywordsWithVararg for the case when argument for
positional-or-keyword parameter is passed by keyword.
There was only one such case in the stdlib -- the TypeVar constructor.
(cherry picked from commit 540fcc62f5)
2024-08-08 09:49:50 +03:00
neonene
6b8a9a1061
[3.12] gh-122334: Fix crash when importing ssl after re-initialization (GH-122481) (#122495)
Fix crash when importing ssl after re-initialization

The current METH_FASTCALL|METH_KEYWORDS functions in a non-builtin module can cause segfaults after restarting the main interpreter, invoking _PyArg_UnpackKeywords() with an insufficiently cleared _PyArg_Parser struct.

This patch fixes the invalidation of the static argument parsers.
2024-08-02 13:44:55 +00:00
Miss Islington (bot)
257c413cd1
[3.12] gh-122029: Log call events in sys.setprofile when it's a method with c function (GH-122072) (GH-122206)
gh-122029: Log call events in sys.setprofile when it's a method with c function (GH-122072)

Log call events in sys.setprofile when it is a method with a C function.
(cherry picked from commit e91ef13861)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2024-07-23 22:44:43 +00:00
Serhiy Storchaka
39dea212f4
[3.12] gh-121905: Consistently use "floating-point" instead of "floating point" (GH-121907) (GH-122013)
(cherry picked from commit 1a0c7b9ba4)
2024-07-19 09:08:33 +00:00
Serhiy Storchaka
874eed6cfe
[3.12] gh-121153: Fix some errors with use of _PyLong_CompactValue() (GH-121154)
* The result has type Py_ssize_t, not intptr_t.
* Type cast between unsigned and signed integer types should be explicit.
* Downcasting should be explicit.
* Fix integer overflow check in sum().
(cherry picked from commit 1801545)
2024-07-17 07:58:25 +00:00
Kirill Podoprigora
b455a5a55c
[3.12] gh-121657: Display correct error message for yield from outsid… (GH-121769)
(cherry picked from commit 178e44de8f)

Co-authored-by: Gregor <36135323+gege-hoho@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-07-15 21:26:10 +02:00
Miss Islington (bot)
9e542f9a46
[3.12] gh-121390: tracemalloc: Fix tracebacks memory leak (GH-121391) (#121393)
gh-121390: tracemalloc: Fix tracebacks memory leak (GH-121391)

The tracemalloc_tracebacks hash table has traceback keys and NULL
values, but its destructors do not reflect this -- key_destroy_func is
NULL while value_destroy_func is raw_free. Swap these to free the
traceback keys instead.
(cherry picked from commit db39bc42f9)

Co-authored-by: Josh Brobst <jbrobst@proton.me>
2024-07-05 06:59:06 +00:00
Miss Islington (bot)
b1bccab588
[3.12] gh-120811: Fix reference leak upon _PyContext_Exit failure (GH-120812) (#120844)
gh-120811: Fix reference leak upon `_PyContext_Exit` failure (GH-120812)
(cherry picked from commit aed31beca9)

Co-authored-by: Peter <zintensitydev@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-06-22 16:44:31 +05:30
Jelle Zijlstra
d62cbba235
[3.12] gh-120722: Set position on RETURN_VALUE in lambda (GH-120724) (#120739)
(cherry picked from commit d8f27cb114)
2024-06-19 13:19:39 +00:00
Irit Katriel
5d997b5d4e
[3.12] gh-119897: Revert buggy optimization which was removed in 3.13 (#120467) 2024-06-18 10:45:40 +01:00
Irit Katriel
5a6cc3c67f
[3.12] gh-93691: fix too broad source locations of for statement iterators (GH-120330 (#120405)
[3.12] gh-93691: fix too broad source locations of for statement iterators (GH-120330).
(cherry picked from commit 97b69db167)
2024-06-13 11:38:36 +01:00
Miss Islington (bot)
f75abf8bcf
[3.12] gh-120343: Fix column offsets of multiline tokens in tokenize (GH-120391) (#120428)
(cherry picked from commit 4b5d3e0e72)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2024-06-12 19:10:35 +00:00
Miss Islington (bot)
0315fdc24d
[3.12] gh-120343: Do not reset byte_col_offset_diff after multiline tokens (GH-120352) (#120356)
(cherry picked from commit 1b62bcee94)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2024-06-11 17:22:16 +00:00
Miss Islington (bot)
82c93ea55a
[3.12] gh-119666: fix multiple class-scope comprehensions referencing __class__ (GH-120295) (#120300) 2024-06-10 00:37:15 -04:00
Victor Stinner
b3b5278475
[3.12] gh-120155: Fix optimize_and_assemble_code_unit() error handling (#120231)
gh-120155: Fix optimize_and_assemble_code_unit() error handling

Don't use 'g' before it's being initialized: don't use the 'error'
label if consts_dict_keys_inorder() failed.

Fix the Coverity issue:

Error: UNINIT (CWE-457):
Python-3.12.2/Python/compile.c:7670:5: skipped_decl: Jumping over declaration of ""g"".
Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_block_list"" when calling ""_PyCfgBuilder_Fini"".
Python-3.12.2/Python/compile.c:7714:5: uninit_use_in_call: Using uninitialized value ""g.g_entryblock"" when calling ""_PyCfgBuilder_Fini"".
  7712|       Py_XDECREF(consts);
  7713|       instr_sequence_fini(&optimized_instrs);
  7714|->     _PyCfgBuilder_Fini(&g);
  7715|       return co;
  7716|   }
2024-06-07 17:17:06 +02:00
Jelle Zijlstra
dc40226ea1
[3.12] gh-119311: Fix name mangling with PEP 695 generic classes (#119464) (#119644)
* [3.12] gh-119311: Fix name mangling with PEP 695 generic classes (#119464)

Fixes #119311. Fixes #119395.

(cherry picked from commit a9a74da4a0)
2024-06-04 19:55:45 +00:00
Victor Stinner
e3e7607167
[3.12] gh-111499: Fix PYTHONMALLOCSTATS at Python exit (#120021) (#120023)
gh-111499: Fix PYTHONMALLOCSTATS at Python exit (#120021)

Call _PyObject_DebugMallocStats() earlier in Py_FinalizeEx(), before
the interpreter is deleted.

(cherry picked from commit 5a1205b641)
2024-06-04 09:58:49 +00:00
Jelle Zijlstra
3bf7a5079c
[3.12] gh-119821: Fix refleak in LOAD_FROM_DICT_OR_GLOBALS (#119975) 2024-06-03 12:26:25 -07:00
Jelle Zijlstra
6d9677d78e
[3.12] gh-119821: Support non-dict globals in LOAD_FROM_DICT_OR_GLOBALS (#119822) (#119890)
The implementation basically copies LOAD_GLOBAL. Possibly it could be deduplicated,
but that seems like it may get hairy since the two operations have different operands.

This is important to fix in 3.14 for PEP 649, but it's a bug in earlier versions too,
and we should backport to 3.13 and 3.12 if possible.

(cherry picked from commit 80a4e38994)
2024-05-31 21:56:38 -07:00
Sam Gross
738cf21609
[3.12] gh-119585: Fix crash involving PyGILState_Release() and PyThreadState_Clear() (GH-119753) (#119861)
Make sure that `gilstate_counter` is not zero in when calling
`PyThreadState_Clear()`. A destructor called from `PyThreadState_Clear()` may
call back into `PyGILState_Ensure()` and `PyGILState_Release()`. If
`gilstate_counter` is zero, it will try to create a new thread state before
the current active thread state is destroyed, leading to an assertion failure
or crash.
(cherry picked from commit bcc1be39cb)
2024-05-31 15:42:09 +00:00
Miss Islington (bot)
a62681c405
[3.12] gh-119704: Fix reference leak in the `Python/Python-tokenize.c` (GH-119705) (#119708) 2024-05-29 07:18:04 +00:00
Miss Islington (bot)
4a0af0cfdc
[3.12] gh-119118: Fix performance regression in tokenize module (GH-119615) (#119683)
- Cache line object to avoid creating a Unicode object
  for all of the tokens in the same line.
- Speed up byte offset to column offset conversion by using the
  smallest buffer possible to measure the difference.

(cherry picked from commit d87b015106)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2024-05-28 22:49:02 +02:00
Eric Snow
0d5fe2c7b4
[3.12] gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across Interpreters (gh-119331) (gh-119425)
_PyArg_Parser holds static global data generated for modules by Argument Clinic.  The _PyArg_Parser.kwtuple field is a tuple object, even though it's stored within a static global.  In some cases the tuple is statically allocated and thus it's okay that it gets shared by multiple interpreters.  However, in other cases the tuple is set lazily, allocated from the heap using the active interprepreter at the point the tuple is needed.

This is a problem once that interpreter is destroyed since _PyArg_Parser.kwtuple becomes at dangling pointer, leading to crashes.  It isn't a problem if the tuple is allocated under the main interpreter, since its lifetime is bound to the lifetime of the runtime.  The solution here is to temporarily switch to the main interpreter.  The alternative would be to always statically allocate the tuple.

This change also fixes a bug where only the most recent parser was added to the global linked list.

(cherry picked from commit 81865002ae)
2024-05-22 22:26:58 +00:00
Miss Islington (bot)
3706eef02a
[3.12] gh-118513: Fix sibling comprehensions with a name bound in one and global in the other (GH-118526) (#118548)
gh-118513: Fix sibling comprehensions with a name bound in one and global in the other (GH-118526)
(cherry picked from commit c8deb1e4b4)

Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-05-03 14:40:05 +00:00
Irit Katriel
238efbecab
[3.12] gh-118272: Clear generator frame's locals when the generator is closed (#118451) 2024-05-02 16:22:50 +01:00
Irit Katriel
ebef3c5ba4
[3.12] gh-116767: fix crash on 'async with' with many context managers (GH-118348) (#118477)
gh-116767: fix crash on 'async with' with many context managers (GH-118348)

Account for `add_stopiteration_handler` pushing a block for `async with`.
To allow generator functions that previously almost hit the `CO_MAXBLOCKS`
limit by nesting non-async blocks, the limit is increased by 1.
This increase allows one more block in non-generator functions.

(cherry picked from commit c1bf4874c1)
2024-05-01 18:23:29 +01:00
Miss Islington (bot)
e7c774996a
[3.12] gh-91565: Replace bugs.python.org links with Devguide/GitHub ones (GH-91568) (GH-117890)
gh-91565: Replace bugs.python.org links with Devguide/GitHub ones  (GH-91568)

(cherry picked from commit 3de09cadde)

Co-authored-by: Steve (Gadget) Barnes <gadgetsteve@hotmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2024-04-15 12:59:34 +00:00
Serhiy Storchaka
0325a8a8cd
[3.12] gh-90300: Remove reference to PYTHON_FROZEN_MODULES in Python CLI help (GH-117035)
Fix error introduced in 4be9fa8961.
2024-03-19 20:05:08 +00:00
Serhiy Storchaka
4be9fa8961
[3.12] gh-90300: Improve the Python CLI help output (GH-115853) (GH-117022)
* document equivalent command-line options for all environment variables
* document equivalent environment variables for all command-line options
* reduce the size of variable and option descriptions to minimum
* remove the ending period in single-sentence descriptions

(cherry picked from commit b85572c47d)

Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-03-19 18:33:34 +00:00
Tian Gao
688623d402
[3.12] gh-116735: Use MISSING for CALL event if argument is absen… (#116873)
[3.12] gh-116735: Use `MISSING` for `CALL` event if argument is absent (GH-116737)
2024-03-19 17:00:54 +00:00
Antoine Pitrou
25243b1461
[3.12] gh-112536: Add TSAN build on Github Actions (GH-116872)
(cherry picked from commit 20578a1f68)

Co-authored-by: Donghee Na <donghee.na@python.org>
2024-03-18 09:52:54 +00:00
Tian Gao
56a3c5f767
[3.12] gh-116626: Emit CALL events for all `INSTRUMENTED_CALL_FUNCTION_EX (GH-116732)
Backport of GH-116627
2024-03-14 16:23:15 +00:00
Serhiy Storchaka
fc4d5fdffe
[3.12] gh-90300: Fix undocumented envvars in the Python CLI help (GH-116765) (GH-116797)
(cherry picked from commit 19ac28bd08)
2024-03-14 14:50:39 +02:00
Serhiy Storchaka
991710af02
[3.12] gh-90300: Document equivalent -X options for envvars in the Python CLI help (GH-116756) (GH-116786)
(cherry picked from commit 8c6db45ce3)
2024-03-14 12:04:14 +02:00
Serhiy Storchaka
870cd901ea
[3.12] gh-90300: Sort the -X options and some envvars in the Python CLI help (GH-116739) (GH-116766)
(cherry picked from commit e54bdeab9c)
2024-03-13 23:02:29 +00:00
Miss Islington (bot)
89b5c5e321
[3.12] gh-90300: Fix cmdline.rst (GH-116721) (GH-116724)
* Fix the description of the "-b" option.
* Add references to environment variables for "-s" and "-X dev" options.
(cherry picked from commit 33662d4e01)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-13 13:46:58 +00:00
Miss Islington (bot)
2647afeab6
[3.12] gh-116447: Fix possible UB in arraymodule and getargs (GH-116459) (#116496)
gh-116447: Fix possible UB in `arraymodule` and `getargs` (GH-116459)
(cherry picked from commit fdb2d90a27)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-08 11:22:07 +00:00
Miss Islington (bot)
9a42cfa368
[3.12] gh-116326: Handler errors correctly in getwindowsversion in sysmodule (GH-116339) (#116354)
* gh-116326: Handler errors correctly in `getwindowsversion` in `sysmodule` (GH-116339)
(cherry picked from commit c91bdf86ef)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-05 18:52:15 +03:00
Miss Islington (bot)
0f70c14939
[3.12] gh-115320: Refactor get_hash_info in sysmodule.c not to swallow errors (GH-115321) (#116323)
gh-115320: Refactor `get_hash_info` in `sysmodule.c` not to swallow errors (GH-115321)
(cherry picked from commit 207030f552)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-04 21:13:38 +00:00
Irit Katriel
6359141867
[3.12] gh-116034: fix location info on the error of a failed assertion (#116054) 2024-02-29 12:36:54 +00:00
Łukasz Langa
2bdd1d6f15
[3.12] gh-90300: Reformat the Python CLI help output (GH-93415) (#115847)
(cherry picked from commit 2e92ffd7fa)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-23 18:23:16 +01:00
Miss Islington (bot)
bf0e072980
[3.12] gh-96497: Mangle name before symtable lookup in 'symtable_extend_namedexpr_scope' (GH-96561) (GH-115603)
(cherry picked from commit 664965a1c1)

Co-authored-by: wookie184 <wookie1840@gmail.com>
2024-02-17 14:49:39 +02:00
Mark Shannon
4d87832d87
[3.12] GH-112215: Backport C recursion changes (GH-115083) 2024-02-13 10:45:59 +01:00
Serhiy Storchaka
d8346d6c06
[3.12] gh-115011: Improve support of __index__() in setters of members with unsigned integer type (GH-115029) (GH-115294)
Setters for members with an unsigned integer type now support
the same range of valid values for objects that has a __index__()
method as for int.

Previously, Py_T_UINT, Py_T_ULONG and Py_T_ULLONG did not support
objects that has a __index__() method larger than LONG_MAX.

Py_T_ULLONG did not support negative ints. Now it supports them and
emits a RuntimeWarning.
(cherry picked from commit d9d6909697)
2024-02-11 11:56:17 +00:00