Commit graph

4690 commits

Author SHA1 Message Date
Miss Islington (bot)
82e26d6bd0
[3.12] gh-118207: Rename the COMMON_FIELDS macro in funcobject.h and undef it after use (GH-118208) (#118269)
gh-118207: Rename the COMMON_FIELDS macro in funcobject.h and undef it after use (GH-118208)
(cherry picked from commit 796b3fb280)

Co-authored-by: Itamar Oren <itamarost@gmail.com>
2024-04-25 22:29:45 -07:00
Miss Islington (bot)
04d07964f2
[3.12] gh-112536: Define _Py_THREAD_SANITIZER on GCC when TSan is enabled (GH-117702) (#117713)
gh-112536: Define `_Py_THREAD_SANITIZER` on GCC when TSan is enabled (GH-117702)

The `__has_feature(thread_sanitizer)` is a Clang-ism. Although new
versions of GCC implement `__has_feature`, the `defined(__has_feature)`
check still fails on GCC so we don't use that code path.
(cherry picked from commit 79eec66e3d)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-04-10 14:38:10 +00:00
Thomas Wouters
26831278d8 Post 3.12.3 2024-04-09 17:25:54 +02:00
Thomas Wouters
f6650f9ad7 Python 3.12.3 2024-04-09 10:09:14 +02:00
Serhiy Storchaka
da2f9d1417
[3.12] gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064) (GH-117070)
(cherry picked from commit 519b2ae22b)
2024-03-20 16:44:05 +02:00
Miss Islington (bot)
5da6e3082c
[3.12] gh-116869: Make C API compatible with ISO C90 (GH-116950) (#117011)
gh-116869: Make C API compatible with ISO C90 (GH-116950)

Make the C API compatible with -Werror=declaration-after-statement
compiler flag again.
(cherry picked from commit a9c304cf02)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-03-19 16:06:15 +00:00
Antoine Pitrou
2ac1b48a04
[3.12] gh-112536: Add support for thread sanitizer (TSAN) (gh-112648) (#116924)
* [3.12] gh-112536: Add support for thread sanitizer (TSAN) (gh-112648)
(cherry picked from commit 88cb972000)

* Remove doc for configure option (leave it hidden in this branch)

---------

Co-authored-by: Samet YASLAN <sametyaslan@gmail.com>
2024-03-17 16:33:35 +01:00
Sebastian Pipping
0a01ed6c2a
[3.12] gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623) (GH-116248)
Allow controlling Expat >=2.6.0 reparse deferral (CVE-2023-52425) by adding five new methods:

- `xml.etree.ElementTree.XMLParser.flush`
- `xml.etree.ElementTree.XMLPullParser.flush`
- `xml.parsers.expat.xmlparser.GetReparseDeferralEnabled`
- `xml.parsers.expat.xmlparser.SetReparseDeferralEnabled`
- `xml.sax.expatreader.ExpatParser.flush`

Based on the "flush" idea from https://github.com/python/cpython/pull/115138#issuecomment-1932444270 .

- Please treat as a security fix related to CVE-2023-52425.

(cherry picked from commit 6a95676bb5)
(cherry picked from commit 73807eb634)
(cherry picked from commit eda2963378)

---------

Includes code suggested-by: Snild Dolkow <snild@sony.com>
and by core dev Serhiy Storchaka.
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-03-06 22:01:45 +00:00
Terry Jan Reedy
84b023d243
[3.12] chore: fix typos (#116345) (#116370)
Co-authored-by: cui fliter <imcusg@gmail.com>
(cherry picked from commit e7ba6e9dbe)
2024-03-05 18:51:17 +00:00
Mark Shannon
4d87832d87
[3.12] GH-112215: Backport C recursion changes (GH-115083) 2024-02-13 10:45:59 +01:00
Miss Islington (bot)
3a67d3272c
[3.12] gh-114828: parenthesize non-atomic macro definitions in pycore_symtable.h (GH-115143) (#115149)
gh-114828: parenthesize non-atomic macro definitions in pycore_symtable.h (GH-115143)
(cherry picked from commit 8f0998e844)

Co-authored-by: Carl Meyer <carl@oddbird.net>
2024-02-07 20:39:22 +00:00
Thomas Wouters
55cd0bff73 Post 3.12.2 2024-02-07 00:44:32 +01:00
Thomas Wouters
6abddd9f6a Python 3.12.2 2024-02-06 21:19:44 +01:00
Serhiy Storchaka
d58a5f453f
[3.12] gh-106905: Use separate structs to track recursion depth in each PyAST_mod2obj call. (GH-113035) (GH-113472)
(cherry picked from commit 48c49739f5)

Co-authored-by: Yilei Yang <yileiyang@google.com>
Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
2023-12-25 19:20:07 +00:00
Irit Katriel
9d72a5cae7
[3.12] gh-113297: Fix segfault in compiler for with statement with 19 context managers (#113327) (#113404) 2023-12-23 13:29:11 +00:00
Miss Islington (bot)
c34c9e3b9a
[3.12] gh-112867: fix for WITH_PYMALLOC_RADIX_TREE=0 (GH-112885) (#113068)
gh-112867: fix for WITH_PYMALLOC_RADIX_TREE=0 (GH-112885)

The _obmalloc_usage structure is only defined if the obmalloc radix tree
is enabled.
(cherry picked from commit 890ce430d9)

Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
2023-12-13 13:06:43 -08:00
Ronald Oussoren
65371511b9
[3.12] gh-110820: Disable test_signal.test_stress_modifying_handlers on macOS (GH-112834)
* gh-110820: Make sure processor specific defines are correct for Universal 2 build on macOS (#112828)

A number of processor specific defines are different for x86-64 and
arm64, and need to be adjusted in pymacconfig.h.

(cherry picked from commit 15a80b15af)
2023-12-09 15:53:16 +01:00
Thomas Wouters
71cbc6a78f Post 3.12.1 2023-12-08 01:39:55 +01:00
Thomas Wouters
2305ca5144 Python 3.12.1 2023-12-07 21:46:47 +01:00
Victor Stinner
f27271619e
[3.12] gh-112125: Fix None.__ne__(None) returning NotImplemented instead of … (#112827)
gh-112125: Fix None.__ne__(None) returning NotImplemented instead of False (#112504)

(cherry picked from commit 9c3458e058)

Co-authored-by: andrewluotechnologies <44252973+andrewluotechnologies@users.noreply.github.com>
2023-12-07 13:41:00 +00:00
Miss Islington (bot)
e005dabe13
[3.12] gh-106550: Fix sign conversion in pycore_code.h (GH-112613) (#112696)
gh-106550: Fix sign conversion in pycore_code.h (GH-112613)

Fix sign conversion in pycore_code.h: use unsigned integers and cast
explicitly when needed.
(cherry picked from commit a74902a14c)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-12-04 11:14:13 +00:00
Victor Stinner
05f5d416de
[3.12] gh-106560: Fix redundant declarations in Include/ (#112611) (#112650)
gh-106560: Fix redundant declarations in Include/ (#112611)

Don't declare PyBool_Type and PyLong_Type twice, but only once.

Compiler warnings seen by building Python with gcc -Wredundant-decls.
2023-12-03 11:45:32 +00:00
Pablo Galindo Salgado
11232c1299
[3.12] gh-112367: Only free perf trampoline arenas at shutdown (GH-112368) (#112590)
(cherry picked from commit a73aa48e6b)

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2023-12-01 16:05:31 +00:00
Miss Islington (bot)
7eff607deb
[3.12] gh-111058: Change coro.cr_frame/gen.gi_frame to be None for a closed coroutine/generator. (GH-112428) (#112589) 2023-12-01 14:13:15 +00:00
Miss Islington (bot)
f7251e2af3
[3.12] gh-111698: Restrict Py_mod_multiple_interpreters to 3.12+ Under Py_LIMITED_API (gh-111707) (gh-111787)
This should have been done in gh-104148.

(A similar fix has already be done for that slot's value macros, and backported to 3.12.  See gh-110968.)
(cherry picked from commit 836e0a75d5)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2023-11-27 19:42:27 -07:00
Miss Islington (bot)
0aceac557d
[3.12] gh-109894: Fix initialization of static MemoryError in subinterpreter (gh-110911) (gh-111238)
Fixes GH-109894

* set `interp.static_objects.last_resort_memory_error.args` to empty tuple to avoid crash on `PyErr_Display()` call
* allow `_PyExc_InitGlobalObjects()` to be called on subinterpreter init

---------

(cherry picked from commit 47d3e2ed93)

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-11-27 19:41:53 -07:00
Eric Snow
1e1a30f9f4
[3.12] gh-110310: Add a Per-Interpreter XID Registry for Heap Types (gh-110311) (gh-110714)
We do the following:

* add a per-interpreter XID registry (PyInterpreterState.xidregistry)
* put heap types there (keep static types in _PyRuntimeState.xidregistry)
* clear the registries during interpreter/runtime finalization
* avoid duplicate entries in the registry (when _PyCrossInterpreterData_RegisterClass() is called more than once for a type)
* use Py_TYPE() instead of PyObject_Type() in _PyCrossInterpreterData_Lookup()

The per-interpreter registry helps preserve isolation between interpreters.  This is important when heap types are registered, which is something we haven't been doing yet but I will likely do soon.

(cherry-picked from commit 80dc39e1dc)
2023-11-28 02:36:29 +00:00
Eric Snow
0122b4d7c9
[3.12] gh-105716: Support Background Threads in Subinterpreters Consistently (gh-109921) (gh-110707)
The existence of background threads running on a subinterpreter was preventing interpreters from getting properly destroyed, as well as impacting the ability to run the interpreter again. It also affected how we wait for non-daemon threads to finish.

We add PyInterpreterState.threads.main, with some internal C-API functions.

(cherry-picked from commit 1dd9dee45d)
2023-11-27 19:01:05 -07:00
Eric Snow
82ae5a609d
[3.12] gh-109793: Allow Switching Interpreters During Finalization (gh-109794) (gh-110705)
Essentially, we should check the thread ID rather than the thread state pointer.
2023-11-28 00:58:02 +00:00
Eric Snow
4f71f1680d
[3.12] gh-106931: Intern Statically Allocated Strings Globally (gh-107272) (gh-110713)
We tried this before with a dict and for all interned strings.  That ran into problems due to interpreter isolation.  However, exclusively using a per-interpreter cache caused some inconsistency that can eliminate the benefit of interning.  Here we circle back to using a global cache, but only for statically allocated strings.  We also use a more-basic _Py_hashtable_t for that global cache instead of a dict.

Ideally we would only have the global cache, but the optional isolation of each interpreter's allocator means that a non-static string object must not outlive its interpreter.  Thus we would have to store a copy of each such interned string in the global cache, tied to the main interpreter.

(cherry-picked from commit b72947a8d2)
2023-11-27 23:51:12 +00:00
Eric Snow
313554457e
[3.12] gh-109853: Fix sys.path[0] For Subinterpreters (gh-109994) (gh-110701)
This change makes sure sys.path[0] is set properly for subinterpreters.  Before, it wasn't getting set at all.

This change does not address the broader concerns from gh-109853.

(cherry-picked from commit a040a32ea2)
2023-11-27 22:21:12 +00:00
Eric Snow
592a849fdf
[3.12] gh-76785: Use Pending Calls When Releasing Cross-Interpreter Data (gh-109556) (gh-112288)
This fixes some crashes in the _xxinterpchannels module, due to a race between interpreters.
(cherry picked from commit fd7e08a6f3)
2023-11-27 14:49:48 -07:00
Victor Stinner
d3d2cfead7
[3.12] gh-110968: Py_MOD_PER_INTERPRETER_GIL_SUPPORTED was added to 3.12 (#111588)
Constants like Py_MOD_PER_INTERPRETER_GIL_SUPPORTED were only added
to the limited C API version 3.12 and newer.
2023-11-01 18:13:31 +01:00
Lysandros Nikolaou
3b87e520fc
[3.12] gh-107450: Check for overflow in the tokenizer and fix overflow test (GH-110832) (#110931)
(cherry picked from commit a1ac5590e0)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Filipe Laíns <lains@riseup.net>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-16 18:59:18 +02:00
Victor Stinner
4936fa9541
[3.12] gh-108987: Fix _thread.start_new_thread() race condition (#109135) (#110342)
* 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)

* gh-109795: `_thread.start_new_thread`: allocate thread bootstate using raw memory allocator (#109808)

(cherry picked from commit 1b8f2366b3)

---------

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
2023-10-04 11:20:31 +00:00
Pablo Galindo Salgado
f6cb2e4815
[3.12] gh-109596: Ensure repeated rules in the grammar are not allowed and fix incorrect soft keywords (GH-109606). (#109752)
(cherry picked from commit b28ffaa193)
2023-10-02 17:22:07 +02:00
Victor Stinner
30748d36b3
[3.12] gh-104690: thread_run() checks for tstate dangling pointer (#109056) (#109133)
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-10-02 16:55:06 +02:00
Thomas Wouters
531d2df280 Post 3.12.0 2023-10-02 16:41:41 +02:00
Thomas Wouters
0fb18b02c8 Python 3.12.0 2023-10-02 13:48:14 +02:00
Thomas Wouters
4a0c118d6a Post 3.12.0rc3 2023-09-19 13:02:42 +02:00
Thomas Wouters
b973ab3c3b Python 3.12.0rc3 2023-09-18 21:48:09 +02:00
Miss Islington (bot)
74a7f5d2da
[3.12] gh-109496: Detect Py_DECREF() after dealloc in debug mode (GH-109539) (#109545)
gh-109496: Detect Py_DECREF() after dealloc in debug mode (GH-109539)

On a Python built in debug mode, Py_DECREF() now calls
_Py_NegativeRefcount() if the object is a dangling pointer to
deallocated memory: memory filled with 0xDD "dead byte" by the debug
hook on memory allocators. The fix is to check the reference count
*before* checking for _Py_IsImmortal().

Add test_decref_freed_object() to test_capi.test_misc.
(cherry picked from commit 0bb0d88e2d)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-09-18 17:39:27 +00:00
Thomas Wouters
8c7655554c Post 3.12.0rc2 2023-09-06 12:27:54 +02:00
Thomas Wouters
40913a56ed Python 3.12.0rc2 2023-09-05 23:57:19 +02:00
Mark Shannon
7ee021f999
[3.12] GH-108390: Prevent non-local events being set with sys.monitoring.set_local_events() (GH-108420) (#108899)
* GH-108390: Prevent non-local events being set with `sys.monitoring.set_local_events()` (GH-108420)

* Restore generated objects

* Restore size of monitoring arrays in code object for 3.12 ABI compatibility.

* Update ABI file
2023-09-05 11:29:38 +00:00
Victor Stinner
7269916cd7
[3.12] gh-63760: Don't declare gethostname() on Solaris (#108817) (#108824)
gh-63760: Don't declare gethostname() on Solaris (#108817)

Since 2005, Solaris defines gethostname(). socketmodule.c no longer
has to define gethostname() for Solaris.

Oracle Solaris and OpenSolaris have patches to remove the
gethostname() definition in Python:

* https://github.com/oracle/solaris-userland/blob/master/components/python/python37/patches/15-gethostname.patch
* https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/python/python37/patches/15-gethostname.patch
* https://github.com/omniosorg/omnios-build/blob/master/build/python27/patches/24-gethostname.patch

Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
(cherry picked from commit 0e6d582b3b)
2023-09-02 23:47:25 +02:00
Steve Dower
ede9895881
[3.12] gh-106242: Fix path truncation in os.path.normpath (GH-106816) (#107981)
* gh-106242: Fix path truncation in os.path.normpath (GH-106816)
* gh-106242: Minor fixup to avoid compiler warnings

---------

Co-authored-by: Finn Womack <flan313@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-08-17 01:19:48 +02:00
Eric Snow
aa9707dda9
[3.12] gh-107080: Fix Py_TRACE_REFS Crashes Under Isolated Subinterpreters (#107751)
* Unrevert "[3.12] gh-107080: Fix Py_TRACE_REFS Crashes Under Isolated Subinterpreters (gh-107567) (#107599)".

This reverts commit 6e4eec7606 (gh-107648).

* Initialize each interpreter's refchain properly.

* Skip test_basic_multiple_interpreters_deleted_no_reset on tracerefs builds.
2023-08-16 12:03:05 +02:00
Miss Islington (bot)
00bfed7cba
[3.12] gh-91051: fix segfault when using all 8 type watchers (GH-107853) (#107876)
* gh-91051: fix segfault when using all 8 type watchers (GH-107853)
(cherry picked from commit 66e4edd734)

Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-08-16 11:58:54 +02:00
Miss Islington (bot)
ddca26188d
[3.12] GH-107724: Fix the signature of PY_THROW callback functions. (GH-107725) (#107802)
GH-107724: Fix the signature of `PY_THROW` callback functions. (GH-107725)
(cherry picked from commit 52fbcf61b5)

Co-authored-by: Mark Shannon <mark@hotpy.org>
2023-08-11 11:58:27 +02:00