Skip to content

Commit e29c8f5

Browse files
authored
Merge branch 'main' into asyncio_to_thread_clean
2 parents ac322ea + f41e9c7 commit e29c8f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+458
-212
lines changed

.github/workflows/posix-deps-apt.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,10 @@ apt-get -yq install \
2525
uuid-dev \
2626
xvfb \
2727
zlib1g-dev
28+
29+
# Workaround missing libmpdec-dev on ubuntu 24.04:
30+
# https://launchpad.net/~ondrej/+archive/ubuntu/php
31+
# https://deb.sury.org/
32+
sudo add-apt-repository ppa:ondrej/php
33+
apt-get update
34+
apt-get -yq install libmpdec-dev

Doc/c-api/init.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,6 +2277,18 @@ The C-API provides a basic mutual exclusion lock.
22772277
22782278
.. versionadded:: 3.13
22792279
2280+
.. c:function:: int PyMutex_IsLocked(PyMutex *m)
2281+
2282+
Returns non-zero if the mutex *m* is currently locked, zero otherwise.
2283+
2284+
.. note::
2285+
2286+
This function is intended for use in assertions and debugging only and
2287+
should not be used to make concurrency control decisions, as the lock
2288+
state may change immediately after the check.
2289+
2290+
.. versionadded:: next
2291+
22802292
.. _python-critical-section-api:
22812293
22822294
Python Critical Section API

Doc/deprecations/pending-removal-in-3.15.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ Pending removal in Python 3.15
9797
After eight years in the :mod:`typing` module,
9898
it has yet to be supported by any major type checker.
9999

100+
* :mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules.
101+
100102
* :mod:`wave`:
101103

102104
* The ``getmark()``, ``setmark()`` and ``getmarkers()`` methods of

Doc/deprecations/pending-removal-in-future.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ although there is currently no date scheduled for their removal.
8989
underscore.
9090
(Contributed by Serhiy Storchaka in :gh:`91760`.)
9191

92-
* :mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules.
93-
9492
* :mod:`shutil`: :func:`~shutil.rmtree`'s *onerror* parameter is deprecated in
9593
Python 3.12; use the *onexc* parameter instead.
9694

Doc/library/exceptions.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,9 @@ The following exceptions are the exceptions that are usually raised.
429429

430430
* Creating a new Python thread.
431431
* :meth:`Joining <threading.Thread.join>` a running daemon thread.
432-
* :func:`os.fork`.
432+
* :func:`os.fork`,
433+
* acquiring a lock such as :class:`threading.Lock`, when it is known that
434+
the operation would otherwise deadlock.
433435

434436
See also the :func:`sys.is_finalizing` function.
435437

@@ -440,6 +442,11 @@ The following exceptions are the exceptions that are usually raised.
440442

441443
:meth:`threading.Thread.join` can now raise this exception.
442444

445+
.. versionchanged:: next
446+
447+
This exception may be raised when acquiring :meth:`threading.Lock`
448+
or :meth:`threading.RLock`.
449+
443450
.. exception:: RecursionError
444451

445452
This exception is derived from :exc:`RuntimeError`. It is raised when the

Doc/library/fractions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ another rational number, or from a string.
142142

143143
.. versionadded:: 3.12
144144

145-
.. classmethod:: from_float(flt)
145+
.. classmethod:: from_float(f)
146146

147147
Alternative constructor which only accepts instances of
148148
:class:`float` or :class:`numbers.Integral`. Beware that

Doc/whatsnew/3.15.rst

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,15 @@ shelve
140140
sqlite3
141141
-------
142142

143-
* Support SQL keyword completion in the :mod:`sqlite3` command-line interface.
144-
(Contributed by Long Tan in :gh:`133393`.)
143+
* The :ref:`command-line interface <sqlite3-cli>` has several new features:
144+
145+
* SQL keyword completion on <tab>.
146+
(Contributed by Long Tan in :gh:`133393`.)
147+
148+
* Prompts, error messages, and help text are now colored.
149+
This is enabled by default, see :ref:`using-on-controlling-color` for
150+
details.
151+
(Contributed by Stan Ulbrych and Łukasz Langa in :gh:`133461`)
145152

146153

147154
ssl
@@ -245,6 +252,13 @@ platform
245252
(Contributed by Alexey Makridenko in :gh:`133604`.)
246253

247254

255+
sre_*
256+
-----
257+
258+
* Removed :mod:`!sre_compile`, :mod:`!sre_constants` and :mod:`!sre_parse` modules.
259+
(Contributed by Stan Ulbrych in :gh:`135994`.)
260+
261+
248262
sysconfig
249263
---------
250264

@@ -296,6 +310,11 @@ that may require changes to your code.
296310
Build changes
297311
=============
298312

313+
* Removed implicit fallback to the bundled copy of the ``libmpdec`` library.
314+
Now this should be explicitly enabled with :option:`--with-system-libmpdec`
315+
set to ``no`` or with :option:`!--without-system-libmpdec`.
316+
(Contributed by Sergey B Kirpichev in :gh:`115119`.)
317+
299318

300319
C API changes
301320
=============
@@ -327,6 +346,13 @@ Porting to Python 3.15
327346

328347
(Contributed by Serhiy Storchaka in :gh:`133595`.)
329348

349+
* Private functions promoted to public C APIs:
350+
351+
* ``PyMutex_IsLocked()`` : :c:func:`PyMutex_IsLocked`
352+
353+
The |pythoncapi_compat_project| can be used to get most of these new
354+
functions on Python 3.14 and older.
355+
330356
Deprecated C APIs
331357
-----------------
332358

Include/cpython/lock.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ PyAPI_FUNC(void) PyMutex_Lock(PyMutex *m);
3636
// exported function for unlocking the mutex
3737
PyAPI_FUNC(void) PyMutex_Unlock(PyMutex *m);
3838

39+
// exported function for checking if the mutex is locked
40+
PyAPI_FUNC(int) PyMutex_IsLocked(PyMutex *m);
41+
3942
// Locks the mutex.
4043
//
4144
// If the mutex is currently locked, the calling thread will be parked until
@@ -61,3 +64,11 @@ _PyMutex_Unlock(PyMutex *m)
6164
}
6265
}
6366
#define PyMutex_Unlock _PyMutex_Unlock
67+
68+
// Checks if the mutex is currently locked.
69+
static inline int
70+
_PyMutex_IsLocked(PyMutex *m)
71+
{
72+
return (_Py_atomic_load_uint8(&m->_bits) & _Py_LOCKED) != 0;
73+
}
74+
#define PyMutex_IsLocked _PyMutex_IsLocked

Include/internal/pycore_lock.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ PyMutex_LockFast(PyMutex *m)
2525
return _Py_atomic_compare_exchange_uint8(lock_bits, &expected, _Py_LOCKED);
2626
}
2727

28-
// Checks if the mutex is currently locked.
29-
static inline int
30-
PyMutex_IsLocked(PyMutex *m)
31-
{
32-
return (_Py_atomic_load_uint8(&m->_bits) & _Py_LOCKED) != 0;
33-
}
34-
3528
// Re-initializes the mutex after a fork to the unlocked state.
3629
static inline void
3730
_PyMutex_at_fork_reinit(PyMutex *m)
@@ -51,6 +44,11 @@ typedef enum _PyLockFlags {
5144

5245
// Fail if interrupted by a signal while waiting on the lock.
5346
_PY_FAIL_IF_INTERRUPTED = 4,
47+
48+
// Locking & unlocking this lock requires attached thread state.
49+
// If locking returns PY_LOCK_FAILURE, a Python exception *may* be raised.
50+
// (Intended for use with _PY_LOCK_HANDLE_SIGNALS and _PY_LOCK_DETACH.)
51+
_PY_LOCK_PYTHONLOCK = 8,
5452
} _PyLockFlags;
5553

5654
// Lock a mutex with an optional timeout and additional options. See

Include/internal/pycore_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ extern PyObject *_PyType_LookupRefAndVersion(PyTypeObject *, PyObject *,
918918
extern unsigned int
919919
_PyType_LookupStackRefAndVersion(PyTypeObject *type, PyObject *name, _PyStackRef *out);
920920

921-
extern int _PyObject_GetMethodStackRef(PyThreadState *ts, PyObject *obj,
921+
PyAPI_FUNC(int) _PyObject_GetMethodStackRef(PyThreadState *ts, PyObject *obj,
922922
PyObject *name, _PyStackRef *method);
923923

924924
// Cache the provided init method in the specialization cache of type if the

0 commit comments

Comments
 (0)