Commit Graph

7570 Commits

Author SHA1 Message Date
Miss Islington (bot) f1f85a42ea
[3.11] gh-109351: Fix crash when compiling AST with invalid NamedExpr (GH-109352) (#109380)
gh-109351: Fix crash when compiling AST with invalid NamedExpr (GH-109352)
(cherry picked from commit 79101edb03)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-09-13 16:32:08 +00:00
Irit Katriel 1e8696133c
[3.11] gh-109179: Fix traceback display for SyntaxErrors with notes (#109197) (#109283)
gh-109179: Fix traceback display for SyntaxErrors with notes (#109197)

(cherry picked from commit ecd21a629a)
2023-09-12 09:57:28 +00:00
Victor Stinner 82a18069a1
[3.11] gh-108987: Fix _thread.start_new_thread() race condition (#109135) (#109272)
gh-108987: Fix _thread.start_new_thread() race condition (#109135)

Fix _thread.start_new_thread() race condition. If a thread is created
during Python finalization, the newly spawned thread now exits
immediately instead of trying to access freed memory and lead to a
crash.

thread_run() calls PyEval_AcquireThread() which checks if the thread
must exit. The problem was that tstate was dereferenced earlier in
_PyThreadState_Bind() which leads to a crash most of the time.

Move _PyThreadState_CheckConsistency() from thread_run() to
_PyThreadState_Bind().

(cherry picked from commit 517cd82ea7)
2023-09-11 19:33:08 +02:00
Miss Islington (bot) c20658249d
[3.11] gh-109207: Fix SystemError when printing symtable entry object. (GH-109225) (GH-109228)
(cherry picked from commit 4297499696)

Co-authored-by: 云line <31395137+yunline@users.noreply.github.com>
2023-09-10 16:50:22 +03:00
Serhiy Storchaka 50e4143f8d
[3.11] Check the result of PySet_Contains() for error in Python/symtable.c (GH-109146) (GH-109158)
(cherry picked from commit 87a7faf6b6)
2023-09-08 19:28:18 +00:00
Miss Islington (bot) c1a2ef5efc
[3.11] gh-106922: Fix error location for constructs with spaces and parentheses (GH-108959) (#109148)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2023-09-08 16:56:10 +00:00
Victor Stinner b55cf2c2d8
[3.11] gh-104690: thread_run() checks for tstate dangling pointer (#109056) (#109134)
gh-104690: thread_run() checks for tstate dangling pointer (#109056)

thread_run() of _threadmodule.c now calls
_PyThreadState_CheckConsistency() to check if tstate is a dangling
pointer when Python is built in debug mode.

Rename ceval_gil.c is_tstate_valid() to
_PyThreadState_CheckConsistency() to reuse it in _threadmodule.c.

(cherry picked from commit f63d37877a)
2023-09-08 11:10:33 +00:00
Serhiy Storchaka b9fc536399
[3.11] gh-107913: Fix possible losses of OSError error codes (GH-107930) (GH-108524)
Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be
called immediately after using the C API which sets errno or the Windows
error code.
(cherry picked from commit 2b15536fa9)
2023-08-27 12:18:58 +00:00
Miss Islington (bot) ed67e60f48
[3.11] gh-107916: Save the error code before decoding the filename in PyErr_SetFromErrnoWithFilename() etc (GH-107929) (GH-108206)
(cherry picked from commit 80bdebdd85)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-21 11:53:05 +00:00
Serhiy Storchaka 92a578409b
[3.11] gh-107915: Handle errors in C API functions PyErr_Set*() and PyErr_Format() (GH-107918) (GH-108135)
Such C API functions as PyErr_SetString(), PyErr_Format(),
PyErr_SetFromErrnoWithFilename() and many others no longer crash or
ignore errors if it failed to format the error message or decode the
filename. Instead, they keep a corresponding error.
(cherry picked from commit 633ea217a8)
2023-08-19 12:22:13 +00:00
Steve Dower ccf81e1088
[3.11] gh-106242: Fix path truncation in os.path.normpath (GH-106816) (#107982)
Co-authored-by: Finn Womack <flan313@gmail.com>
2023-08-15 19:07:52 +02:00
Serhiy Storchaka fced79f91e
[3.11] gh-86493: Fix possible leaks in some modules initialization (GH-106768) (GH-106855) (GH-106863)
[3.11] [3.12] gh-86493: Fix possible leaks in some modules initialization (GH-106768) (GH-106855)

Fix _ssl, _stat, _testinternalcapi, _threadmodule, cmath, math, posix, time.
(cherry picked from commit 3e65baee72).
(cherry picked from commit a423ddbdea)
2023-07-19 09:40:38 +03:00
Miss Islington (bot) ddfe8eb45f
[3.11] Document PYTHONSAFEPATH along side -P (GH-106122) (#106353)
(cherry picked from commit 0355625d94)

Co-authored-by: Jeremy Paige <ucodery@gmail.com>
2023-07-05 13:21:45 +02:00
Miss Islington (bot) b937ca0a5a
[3.11] gh-101006: Improve error handling when read marshal data (GH-101007) (GH-106227)
* EOFError no longer overrides other errors such as MemoryError or OSError at
  the start of the object.
* Raise more relevant error when the NULL object occurs as a code object
  component.
* Minimize an overhead of calling PyErr_Occurred().
(cherry picked from commit 8bf6904b22)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-06-29 13:47:30 +03:00
Kumar Aditya 307c59a0c1
[3.11] gh-105979: Fix exception handling in unmarshal_frozen_code (`Python/import.c`) (GH-105980). (#106100)
* [3.11] gh-105979: Fix exception handling in `unmarshal_frozen_code` (`Python/import.c`) (GH-105980).
(cherry picked from commit cd5280367a)

Co-authored-by: chgnrdv <52372310+chgnrdv@users.noreply.github.com>
2023-06-26 09:00:51 +00:00
Serhiy Storchaka dbe416b82b
[3.11] gh-106033: Get rid of new occurrences of PyDict_GetItem and Py… (#106040)
[3.11] gh-106033: Get rid of new occurrences of PyDict_GetItem and PyObject_HasAttr (GH-106034)

These functions are broken by design because they discard any exceptions raised
inside, including MemoryError and KeyboardInterrupt.  They should not be
used in new code..
(cherry picked from commit 1d33d53780)
2023-06-24 16:41:02 -07:00
Serhiy Storchaka 26d87fd5c7
[3.11] gh-106030: Miscellaneous fixes in Python/suggestions.c (GH-106… (GH-106039)
* PyUnicode_CompareWithASCIIString() only works if the second argument
  is ASCII string.
* Refleak in get_suggestions_for_name_error.
* Add some missing error checks.

(cherry picked from commit c8c162ef52)
2023-06-23 21:13:07 +03:00
Miss Islington (bot) 2944a6cc0a
[3.11] GH-105840: Fix assertion failures when specializing calls with too many __defaults__ (GH-105864)
GH-105840: Fix assertion failures when specializing calls with too many __defaults__ (GH-105847)
(cherry picked from commit 2beab5bdef)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2023-06-16 18:30:22 +00:00
Miss Islington (bot) c0c4186858
[3.11] GH-105588: Add missing error checks to some obj2ast_* converters (GH-105839)
GH-105588: Add missing error checks to some obj2ast_* converters (GH-105589)
(cherry picked from commit a4056c8f9c)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2023-06-15 23:13:51 +00:00
Miss Islington (bot) 171aa086f2
[3.11] gh-105673: Fix uninitialized warning in sysmodule.c (GH-105674) (#105676)
In sys_add_xoption(), 'value' may be uninitialized for some error paths.
(cherry picked from commit a8d69fe92c)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-06-12 09:13:03 +00:00
Erlend E. Aasland f98d475ee3
[3.11] gh-105375: Improve error handling in the sys extension module (#105611) (#105666)
(cherry picked from commit 41cddc2e93)

In _PySys_AddXOptionWithError() and sys_add_xoption(),
bail on first error to prevent exceptions from possibly being
overwritten.
2023-06-11 21:08:40 +00:00
Miss Islington (bot) 05c73e1cd8
[3.11] gh-105375: Improve PyErr_WarnExplicit() error handling (GH-105610) (#105660)
Bail on first error to prevent exceptions from possibly being
overwritten.
(cherry picked from commit 567d6ae8e7)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-11 19:46:02 +00:00
Miss Islington (bot) b3d95d4e61
[3.11] gh-105375: Improve error handling in the builtins extension module (GH-105585) (#105650)
(cherry picked from commit d4fa52934a)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-11 11:13:45 +00:00
Erlend E. Aasland 90e357bc8a
[3.11] gh-105375: Improve error handling in compiler_enter_scope() (#105494) (#105582)
(cherry picked from commit 6c832ddcf2)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-06-09 17:36:06 +00:00
Jelle Zijlstra 48957888d2
[3.11] gh-105164: Detect annotations inside match blocks (GH-105177). (#105314)
(cherry picked from commit 69d1245685)
2023-06-05 13:46:12 +00:00
Miss Islington (bot) 8de607ab1c
[3.11] gh-105184: document that marshal functions can fail and need to be checked with PyErr_Occurred (GH-105185) (#105219)
gh-105184: document that marshal functions can fail and need to be checked with PyErr_Occurred (GH-105185)
(cherry picked from commit ee26ca13a1)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2023-06-02 08:28:35 +00:00
Mark Shannon 7b3bc95067
[3.11] GH-102818: Do not call PyTraceBack_Here in sys.settrace trampoline (GH-104650)
Backport of GH-104579
2023-05-19 19:08:43 +01:00
Carl Meyer 667e4ece98
[3.11] gh-104615: don't make unsafe swaps in apply_static_swaps (GH-104620). (#104636)
(cherry picked from commit 0589c6a4d3)
2023-05-19 12:04:04 -06:00
Irit Katriel 52a18feaaa
[3.11] gh-104482: Fix error handling bugs in ast.c (#104514) 2023-05-16 10:14:36 +01:00
Brandt Bucher fbb6def08a
[3.11] GH-104405: Add missing PEP 523 checks (GH-104441) 2023-05-12 23:03:47 +00:00
Lysandros Nikolaou a09d3901a5
[3.11] gh-96670: Raise SyntaxError when parsing NULL bytes (GH-97594) (#104195) 2023-05-07 11:12:04 +01:00
Miss Islington (bot) 15ffcf76e1
[3.11] gh-104018: remove unused format "z" handling in string formatfloat() (GH-104107) (#104260)
gh-104018: remove unused format "z" handling in string formatfloat() (GH-104107)

This is a cleanup overlooked in PR GH-104033.
(cherry picked from commit 69621d1b09)

Co-authored-by: John Belmonte <john@neggie.net>
2023-05-07 05:06:06 +00:00
Miss Islington (bot) 8f23cadc4c
[3.11] gh-103886: Improve `builtins.__doc__` (GH-104179) (#104257)
gh-103886: Improve `builtins.__doc__` (GH-104179)
(cherry picked from commit b35711d17a)

Co-authored-by: Tomas R <tomas.roun8@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-07 02:28:04 +00:00
Tian Gao fee3c91a19
[3.11] GH-103971: Fix incorrect locations for code following case blocks 2023-04-28 20:08:25 +00:00
Irit Katriel 93a9535d54
[3.11] gh-101517: fix line number propagation in code generated for except* (#103550) (#103816)
Manual backport of https://github.com/python/cpython/pull/103550.



<!-- gh-issue-number: gh-101517 -->
* Issue: gh-101517
<!-- /gh-issue-number -->

---------

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-04-25 18:08:54 +01:00
Max Bachmann b28f919007
[3.11] gh-102281: Fix potential nullptr dereference + use of uninitia… (#103040)
[3.11] gh-102281: Fix potential nullptr dereference + use of uninitialized memory (gh-102282)
(cherry picked from commit afa6092ee4)
2023-03-25 16:35:00 -07:00
Miss Islington (bot) 4c6b354699
gh-98608: Fix Failure-handling in new_interpreter() (gh-102658)
The error-handling code in new_interpreter() has been broken for a while.  We hadn't noticed because those code mostly doesn't fail.  (I noticed while working on gh-101660.)  The problem is that we try to clear/delete the newly-created thread/interpreter using itself, which just failed.  The solution is to switch back to the calling thread state first.

(cherry picked from commit d1b883b52a)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
https: //github.com/python/cpython/issues/98608
2023-03-21 12:13:31 -07:00
Mark Shannon d149f15d63
[3.11] gh-101975: Fixed a potential SegFault on garbage collection (GH-102803) (GH-102807)
Authored-by: gaogaotiantian <gaogaotiantian@hotmail.com>
2023-03-20 14:42:15 +00:00
Miss Islington (bot) 63fd954100
gh-102356: Add thrashcan macros to filter object dealloc (GH-102426)
Add thrashcan macros to the deallocator of the filter objects to protect against deeply nested destruction of chains of nested filters.
(cherry picked from commit 66aa78cbe6)

Co-authored-by: Marta Gómez Macías <mgmacias@google.com>
2023-03-05 03:25:48 -08:00
Kumar Aditya 026faf20cc
[3.11] GH-102126: fix deadlock at shutdown when clearing thread state… (#102234)
[3.11] GH-102126: fix deadlock at shutdown when clearing thread states (GH-102222)

(cherry picked from commit 5f11478ce7)
2023-02-25 21:00:05 +05:30
Miss Islington (bot) ddb65c47b1
[3.11] gh-97786: Fix compiler warnings in pytime.c (GH-101826) (#102062)
gh-97786: Fix compiler warnings in pytime.c (GH-101826)

Fixes compiler warnings in pytime.c.
(cherry picked from commit b1b375e267)

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-02-22 19:11:59 +00:00
Miss Islington (bot) 1633aea0e4
[3.11] gh-101967: add a missing error check (GH-101968) (#102015)
gh-101967: add a missing error check (GH-101968)
(cherry picked from commit 89413bbccb)

Co-authored-by: Eclips4 <80244920+Eclips4@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-02-21 13:01:15 +00:00
Miss Islington (bot) e8ce85de59
gh-101614: Don't treat python3_d.dll as a Python DLL when checking extension modules for incompatibility (GH-101615)
(cherry picked from commit 3a88de7a0a)

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-02-08 06:50:43 -08:00
Łukasz Langa 955ba2839b
[3.11] gh-101072: support default and kw default in PyEval_EvalCodeEx for 3.11+ (GH-101127) (#101636)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Matthieu Dartiailh <m.dartiailh@gmail.com>
2023-02-07 13:36:35 +00:00
Dong-hee Na 0c37ea9aba
[3.11] gh-101400: Fix incorrect lineno in exception message on contin… (gh-101447) 2023-01-31 23:53:14 +09:00
Miss Islington (bot) 07d1f99e8f
[3.11] Update copyright years to 2023. (gh-100848) (GH-100849)
(cherry picked from commit 11f99323c2)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2023-01-08 17:57:17 -08:00
Shantanu be7c19723f
[3.11] gh-100776: Fix misleading default value in help(input) (GH-100788) (#100841)
(cherry picked from commit a2141882f2)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-01-08 01:23:12 -08:00
Miss Islington (bot) b1e314ab9f
gh-95778: add doc missing in some places (GH-100627)
(cherry picked from commit 46521826cb)

Co-authored-by: Éric <earaujo@caravan.coop>
2022-12-30 13:51:06 -08:00
colorfulappl a3dbd4c70e
[3.11] gh-64490: Fix bugs in argument clinic varargs processing (GH-32092) (#100368)
(cherry picked from commit 0da728387c)
2022-12-28 02:10:06 +01:00
Gregory P. Smith a852c5f8ee
[3.11] Correct CVE-2020-10735 documentation (GH-100306). (#100476)
(cherry picked from commit 1cf3d78c92)

Co-authored-by: Jeremy Paige <ucodery@gmail.com>
2022-12-23 18:07:50 -08:00