Commit Graph

14519 Commits

Author SHA1 Message Date
Radislav Chugunov ca3ea9ad05
gh-109746: Make _thread.start_new_thread delete state of new thread on its startup failure (GH-109761)
If Python fails to start newly created thread
due to failure of underlying PyThread_start_new_thread() call,
its state should be removed from interpreter' thread states list
to avoid its double cleanup.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-22 21:20:07 +02:00
Sam Gross f83ca6962a
gh-127065: Make `methodcaller` thread-safe in free threading build (#127109)
The `methodcaller` C vectorcall implementation uses an arguments array
that is shared across calls. The first argument is modified on every
invocation. This isn't thread-safe in the free threading build. I think
it's also not safe in general, but for now just disable it in the free
threading build.
2024-11-22 09:21:59 -05:00
Victor Stinner 3c2bd66e21
gh-126316: Make grp.getgrall() thread-safe: add a mutex (#127055)
grpmodule.c is no longer built with the limited C API, since PyMutex
is excluded from the limited C API.
2024-11-21 15:47:24 +01:00
Serhiy Storchaka 4803cd0244
gh-126727: Fix locale.nl_langinfo(locale.ERA) (GH-126730)
It now returns multiple era description segments separated by semicolons.
Previously it only returned the first segment on platforms with Glibc.
2024-11-21 13:16:08 +02:00
Justin Applegate 29cbcbd73b
gh-126991: Fix reference leak in loading pickle's opcode BUILD (GH-126990)
If PyObject_SetItem() fails in the `load_build()` function of _pickle.c, no DECREF for the `dict` variable.
2024-11-19 18:00:35 +02:00
Malcolm Smith c5c9286804
gh-118201: Simplify conv_confname (#126089) 2024-11-19 10:42:19 -05:00
Hugo van Kemenade 899fdb213d
Revert "GH-126491: GC: Mark objects reachable from roots before doing cycle collection (GH-126502)" (#126983) 2024-11-19 11:25:09 +02:00
Victor Stinner b3687ad454
gh-126876: Fix socket internal_select() for large timeout (#126968)
If the timeout is larger than INT_MAX, replace it with INT_MAX, in
the poll() code path.

Add an unit test.
2024-11-19 09:08:42 +01:00
Filipe Laíns 🇵🇸 0063f5f314
getpath: fix warning typo (#126978) 2024-11-18 23:50:01 +00:00
Brandt Bucher 4cd10762b0
GH-126795: Increase the JIT threshold from 16 to 4096 (GH-126816) 2024-11-18 11:11:23 -08:00
Mark Shannon b0fcc2c47a
GH-126491: GC: Mark objects reachable from roots before doing cycle collection (GH-126502)
* Mark almost all reachable objects before doing collection phase

* Add stats for objects marked

* Visit new frames before each increment

* Remove lazy dict tracking

* Update docs

* Clearer calculation of work to do.
2024-11-18 14:31:26 +00:00
Serhiy Storchaka f9c5573ded
gh-101955: Fix SystemError in possesive quantifier with alternative and group (GH-111362)
Co-authored-by: <wjssz@users.noreply.github.com>
2024-11-18 13:43:44 +02:00
Serhiy Storchaka 7538e7f569
gh-67877: Fix memory leaks in terminated RE matching (GH-126840)
If SRE(match) function terminates abruptly, either because of a signal
or because memory allocation fails, allocated SRE_REPEAT blocks might
be never released.

Co-authored-by: <wjssz@users.noreply.github.com>
2024-11-18 11:53:45 +02:00
George Alexopoulos 8717f792f7
gh-126554: ctypes: Correctly handle NULL dlsym values (GH-126555)
For dlsym(), a return value of NULL does not necessarily indicate
an error [1].

Therefore, to avoid using stale (or NULL) dlerror() values, we must:

 1. clear the previous error state by calling dlerror()
 2. call dlsym()
 3. call dlerror()

If the return value of dlerror() is not NULL, an error occured.

In ctypes we choose to treat a NULL return value from dlsym()
as a "not found" error. This is the same as the fallback
message we use on Windows, Cygwin or when getting/formatting
the error reason fails.

[1]: https://man7.org/linux/man-pages/man3/dlsym.3.html

Signed-off-by: Georgios Alexopoulos <grgalex42@gmail.com>
Signed-off-by: Georgios Alexopoulos <grgalex@ba.uoa.gr>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-11-15 11:05:51 +01:00
Victor Stinner 3fecbe9255
gh-126433: Update hacl-star (GH-126791)
Retrieve the change: "Lib_Memzero0.c: Fix compiler warning on 32-bit Windows".
2024-11-15 00:22:50 +00:00
Marc Culler 47cbf03885
gh-124111: Update tkinter for compatibility with Tcl/Tk 9.0.0 (GH-124156) 2024-11-14 12:45:08 -06:00
Seth Michael Larson 3c99969094
gh-126623: Update libexpat to 2.6.4, make future updates easier (GH-126792)
Update libexpat to 2.6.4, make future updates easier.
2024-11-13 18:31:20 +00:00
Peter Bierma d00878b06a
gh-123619: Add an unstable C API function for enabling deferred reference counting (GH-123635)
Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-11-13 13:27:16 +00:00
Sam Gross 5610860840
gh-126688: Reinit import lock after fork (#126692)
The PyMutex implementation supports unlocking after fork because we
clear the list of waiters in parking_lot.c. This doesn't work as well
for _PyRecursiveMutex because on some systems, such as SerenityOS, the
thread id is not preserved across fork().
2024-11-12 15:53:58 -05:00
Eric Snow 73cf069099
gh-76785: Improved Subinterpreters Compatibility with 3.12 (2/2) (gh-126707)
These changes makes it easier to backport the _interpreters, _interpqueues, and _interpchannels modules to Python 3.12.

This involves the following:

* add the _PyXI_GET_STATE() and _PyXI_GET_GLOBAL_STATE() macros
* add _PyXIData_lookup_context_t and _PyXIData_GetLookupContext()
* add _Py_xi_state_init() and _Py_xi_state_fini()
2024-11-12 10:41:51 -07:00
Serhiy Storchaka 6b2a19681e
gh-95382: Use cache for indentations in the JSON encoder (GH-118636) 2024-11-12 17:19:15 +00:00
Hugo van Kemenade 91f4908798
gh-126133: Only use start year in PSF copyright, remove end years (#126236) 2024-11-12 15:59:19 +02:00
RUANG (James Roy) 8ff7efb46d
gh-126061: Add PyLong_IsPositive/Zero/Negative() functions (#126065)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-11-12 14:18:06 +01:00
Sayandip Dutta abb90ba46c
gh-125916: Allow functools.reduce() 'initial' to be a keyword argument (#125917) 2024-11-12 13:11:58 +00:00
Bénédikt Tran 6e3bb8a913
gh-126595: fix a crash when calling `itertools.count(sys.maxsize)` (#126617) 2024-11-12 14:10:10 +01:00
Kumar Aditya 37c57dfad1
gh-126405: fix use-after-free in `_asyncio.Future.remove_done_callback` (#126733) 2024-11-12 18:01:34 +05:30
Eric Snow a6d48e8f83
gh-76785: Improved Subinterpreters Compatibility with 3.12 (1/2) (gh-126704)
These changes makes it easier to backport the _interpreters, _interpqueues, and _interpchannels modules to Python 3.12.

This involves the following:

* rename several structs and typedefs
* add several typedefs
* stop using the PyThreadState.state field directly in parking_lot.c
2024-11-11 15:58:46 -07:00
Eric Snow b697d8c48e
gh-76785: Minor Cleanup of Exception-related Cross-interpreter State (gh-126602)
This change makes it easier to backport the _interpreters, _interpqueues, and _interpchannels modules to Python 3.12.
2024-11-11 14:49:41 -07:00
sobolevn 9fc2808eaf
gh-126654: Fix crash in several functions in `_interpreters` module (#126678) 2024-11-11 17:05:56 +05:30
Kumar Aditya b19d12f447
remove minor redundant code from `_asyncio` (#126578) 2024-11-08 13:17:03 +00:00
Kumar Aditya a3e8e7bbc3
GH-107803: use circular double linked list for tasks in `_asyncio` (#126577) 2024-11-08 12:51:11 +00:00
Serhiy Storchaka 061e50f196
gh-122943: Add the varpos parameter in _PyArg_UnpackKeywords (GH-126564)
Remove _PyArg_UnpackKeywordsWithVararg.
Add comments for integer arguments of _PyArg_UnpackKeywords.
2024-11-08 14:23:50 +02:00
Serhiy Storchaka 06a8b0bb5e
gh-122943: Remove the object converter for var-positional parameter (GH-126560) 2024-11-08 05:41:54 +00:00
Serhiy Storchaka 1f777396f5
gh-122943: Rework support of var-positional parameter in Argument Clinic (GH-122945)
Move creation of a tuple for var-positional parameter out of
_PyArg_UnpackKeywordsWithVararg().
Merge _PyArg_UnpackKeywordsWithVararg() with _PyArg_UnpackKeywords().
Add a new parameter in _PyArg_UnpackKeywords().

The "parameters" and "converters" attributes of ParseArgsCodeGen no
longer contain the var-positional parameter. It is now available as the
"varpos" attribute. Optimize code generation for var-positional
parameter and reuse the same generating code for functions with and without
keyword parameters.

Add special converters for var-positional parameter. "tuple" represents it as
a Python tuple and "array" represents it as a continuous array of PyObject*.
"object" is a temporary alias of "tuple".
2024-11-07 23:40:03 +02:00
Eric Snow 9357fdcaf0
gh-76785: Minor Cleanup of "Cross-interpreter" Code (gh-126457)
The primary objective here is to allow some later changes to be cleaner. Mostly this involves renaming things and moving a few things around.

* CrossInterpreterData -> XIData
* crossinterpdatafunc -> xidatafunc
* split out pycore_crossinterp_data_registry.h
* add _PyXIData_lookup_t
2024-11-07 09:32:42 -07:00
Gregory P. Smith d46d3f2ec7
Cleanup multiprocessing comment and unusual import error message (#126532)
Define constants as constants rather than calling `list(range(2))`.
Explain which values must remain in sync via comments.
2024-11-07 00:06:14 -08:00
Serhiy Storchaka 223d3dc554
gh-125631: Enable setting persistent_id and persistent_load of pickler and unpickler (GH-125752)
pickle.Pickler.persistent_id and pickle.Unpickler.persistent_load can
again be overridden as instance attributes.
2024-11-07 08:53:02 +02:00
Victor Stinner a1c57bcfd2
gh-126461: Fix _Unpickler_ReadFromFile() error handling (#126485)
Handle _Unpickler_SetStringInput() failure.
2024-11-06 14:24:46 +01:00
Victor Stinner b1c4ffc205
gh-126455: Disallow _ssl.SSLSocket instantiation (#126481)
Prevent creation of incomplete/invalid _ssl.SSLSocket objects when
created directly.
2024-11-06 11:59:39 +01:00
Victor Stinner 09d7083962
gh-126433: Change channel_info.count to int64_t (#126447)
Fix compiler warnings on 32-bit Windows: change channel_info.count
type from Py_ssize_t to int64_t in _interpchannelsmodule.c.
2024-11-06 15:50:17 +05:30
Victor Stinner 0b67ce930a
gh-126433: Fix compiler warnings on 32-bit Windows (#126444) 2024-11-05 16:05:13 +01:00
sobolevn 75872605aa
gh-126425: Refactor `_lsprof_Profiler_enable` (#126426)
- Explicit memory management for `None` objects (since we still try to treat immortal objects as regular objects)
- Respect possible errors of `sys.monitoring.register_callback` call
2024-11-05 15:23:24 +03:00
Lukas Geiger 3d4fda2165
gh-119793: Prefer `map(..., strict=True)` over starmap/zip in examples (#126407) 2024-11-05 08:53:32 +01:00
Serhiy Storchaka d3840503b0
gh-126303: Fix pickling and copying of os.sched_param objects (GH-126336) 2024-11-05 08:23:17 +02:00
mpage 2e95c5ba3b
gh-115999: Implement thread-local bytecode and enable specialization for `BINARY_OP` (#123926)
Each thread specializes a thread-local copy of the bytecode, created on the first RESUME, in free-threaded builds. All copies of the bytecode for a code object are stored in the co_tlbc array on the code object. Threads reserve a globally unique index identifying its copy of the bytecode in all co_tlbc arrays at thread creation and release the index at thread destruction. The first entry in every co_tlbc array always points to the "main" copy of the bytecode that is stored at the end of the code object. This ensures that no bytecode is copied for programs that do not use threads.

Thread-local bytecode can be disabled at runtime by providing either -X tlbc=0 or PYTHON_TLBC=0. Disabling thread-local bytecode also disables specialization.

Concurrent modifications to the bytecode made by the specializing interpreter and instrumentation use atomics, with specialization taking care not to overwrite an instruction that was instrumented concurrently.
2024-11-04 11:13:32 -08:00
sobolevn c806cd5af6
gh-126220: Adapt `_lsprof` to Argument Clinic (#126233)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-11-04 19:18:21 +03:00
Bénédikt Tran 19d9358437
gh-126313: Fix a crash in curses.napms() due to incorrect error handling (GH-126351) 2024-11-03 15:08:34 +00:00
Nico-Posada f032f6ba8f
gh-126138: Fix use-after-free in `_asyncio.Task` by evil `__getattribute__` (#126305)
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-11-02 13:16:00 +05:30
Sergey B Kirpichev 8477951a1c
gh-120026: soft deprecate Py_HUGE_VAL macro (#120027)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2024-11-01 22:04:31 +00:00
sobolevn 28b148fb32
gh-126220: Fix crash on calls to `_lsprof.Profiler` methods with 0 args (backportable) (#126271)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-11-02 00:53:29 +03:00