[Python-checkins] gh-126548: Add a thread-unsafety warning for `importlib.reload()` (GH-136704)
https://github.com/python/cpython/commit/69d8fe50ddc4dbe757c9929a532e2e882f0261ba commit: 69d8fe50ddc4dbe757c9929a532e2e882f0261ba branch: main author: Bartosz Sławecki committer: ZeroIntensity date: 2025-07-16T12:34:14-04:00 summary: gh-126548: Add a thread-unsafety warning for `importlib.reload()` (GH-136704) files: M Doc/library/importlib.rst diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index ea5a77028683b3..4f374be778d6b3 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -206,6 +206,10 @@ Functions :exc:`ModuleNotFoundError` is raised when the module being reloaded lacks a :class:`~importlib.machinery.ModuleSpec`. + .. warning:: + This function is not thread-safe. Calling it from multiple threads can result + in unexpected behavior. It's recommended to use the :class:`threading.Lock` + or other synchronization primitives for thread-safe module reloading. :mod:`importlib.abc` -- Abstract base classes related to import --- ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-126548: Add a thread-unsafety warning for `importlib.reload()` (GH-136704) (GH-136723)
https://github.com/python/cpython/commit/6943d8ef275a5b4a687a730287d9421e2fae3fae commit: 6943d8ef275a5b4a687a730287d9421e2fae3fae branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-16T16:40:11Z summary: [3.14] gh-126548: Add a thread-unsafety warning for `importlib.reload()` (GH-136704) (GH-136723) gh-126548: Add a thread-unsafety warning for `importlib.reload()` (GH-136704) (cherry picked from commit 69d8fe50ddc4dbe757c9929a532e2e882f0261ba) Co-authored-by: Bartosz Sławecki files: M Doc/library/importlib.rst diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index ea5a77028683b3..4f374be778d6b3 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -206,6 +206,10 @@ Functions :exc:`ModuleNotFoundError` is raised when the module being reloaded lacks a :class:`~importlib.machinery.ModuleSpec`. + .. warning:: + This function is not thread-safe. Calling it from multiple threads can result + in unexpected behavior. It's recommended to use the :class:`threading.Lock` + or other synchronization primitives for thread-safe module reloading. :mod:`importlib.abc` -- Abstract base classes related to import --- ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-126548: Add a thread-unsafety warning for `importlib.reload()` (GH-136704) (GH-136724)
https://github.com/python/cpython/commit/883223919fd56225e1d2b9ebb1235932fca9a957 commit: 883223919fd56225e1d2b9ebb1235932fca9a957 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-16T16:40:22Z summary: [3.13] gh-126548: Add a thread-unsafety warning for `importlib.reload()` (GH-136704) (GH-136724) gh-126548: Add a thread-unsafety warning for `importlib.reload()` (GH-136704) (cherry picked from commit 69d8fe50ddc4dbe757c9929a532e2e882f0261ba) Co-authored-by: Bartosz Sławecki files: M Doc/library/importlib.rst diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index be252eaef64417..4402af1393555a 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -206,6 +206,10 @@ Functions :exc:`ModuleNotFoundError` is raised when the module being reloaded lacks a :class:`~importlib.machinery.ModuleSpec`. + .. warning:: + This function is not thread-safe. Calling it from multiple threads can result + in unexpected behavior. It's recommended to use the :class:`threading.Lock` + or other synchronization primitives for thread-safe module reloading. :mod:`importlib.abc` -- Abstract base classes related to import --- ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-136288: Fix error message in `_testcapi/vectorcall.c` (GH-136258)
https://github.com/python/cpython/commit/d1d5dce14f90d777608e4403d09079421ff55944
commit: d1d5dce14f90d777608e4403d09079421ff55944
branch: main
author: William S Fulton
committer: ZeroIntensity
date: 2025-07-04T11:54:00-04:00
summary:
gh-136288: Fix error message in `_testcapi/vectorcall.c` (GH-136258)
Use the %N format specifier instead of %s and `PyType_GetName`.
files:
M Modules/_testcapi/vectorcall.c
diff --git a/Modules/_testcapi/vectorcall.c b/Modules/_testcapi/vectorcall.c
index 03aaacb328e0b6..f89dcb6c4cf03c 100644
--- a/Modules/_testcapi/vectorcall.c
+++ b/Modules/_testcapi/vectorcall.c
@@ -179,14 +179,14 @@ _testcapi_VectorCallClass_set_vectorcall_impl(PyObject
*self,
if (!PyObject_TypeCheck(self, type)) {
return PyErr_Format(
PyExc_TypeError,
-"expected %s instance",
-PyType_GetName(type));
+"expected %N instance",
+type);
}
if (!type->tp_vectorcall_offset) {
return PyErr_Format(
PyExc_TypeError,
-"type %s has no vectorcall offset",
-PyType_GetName(type));
+"type %N has no vectorcall offset",
+type);
}
*(vectorcallfunc*)((char*)self + type->tp_vectorcall_offset) = (
VectorCallClass_vectorcall);
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] Docs: Move "or" outside monospace syntax in `tarfile.rst` (GH-136263)
https://github.com/python/cpython/commit/ade19880943509945da193202ca89e0b2b6fbd75 commit: ade19880943509945da193202ca89e0b2b6fbd75 branch: main author: Rafael Fontenelle committer: ZeroIntensity date: 2025-07-04T10:40:32-04:00 summary: Docs: Move "or" outside monospace syntax in `tarfile.rst` (GH-136263) files: M Doc/library/tarfile.rst diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst index 70466fbbc4d8f9..99e8ef7b886035 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -63,8 +63,8 @@ Some facts and figures: +--+-+ | mode | action | +==+=+ - | ``'r' or 'r:*'`` | Open for reading with transparent | - | | compression (recommended). | + | ``'r'`` or | Open for reading with transparent | + | ``'r:*'``| compression (recommended). | +--+-+ | ``'r:'`` | Open for reading exclusively without| | | compression.| @@ -98,10 +98,11 @@ Some facts and figures: | | Raise a :exc:`FileExistsError` exception| | | if it already exists. | +--+-+ - | ``'a' or 'a:'`` | Open for appending with no compression. The | - | | file is created if it does not exist. | + | ``'a'`` or | Open for appending with no compression. The | + | ``'a:'`` | file is created if it does not exist. | +--+-+ - | ``'w' or 'w:'`` | Open for uncompressed writing. | + | ``'w'`` or | Open for uncompressed writing. | + | ``'w:'`` | | +--+-+ | ``'w:gz'`` | Open for gzip compressed writing. | +--+-+ ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] Docs: Move "or" outside monospace syntax in `tarfile.rst` (GH-136263) (GH-136290)
https://github.com/python/cpython/commit/1a2898a383ac5b57a7e0eba34ccab2055d79f1aa commit: 1a2898a383ac5b57a7e0eba34ccab2055d79f1aa branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-04T14:46:57Z summary: [3.14] Docs: Move "or" outside monospace syntax in `tarfile.rst` (GH-136263) (GH-136290) Docs: Move "or" outside monospace syntax in `tarfile.rst` (GH-136263) (cherry picked from commit ade19880943509945da193202ca89e0b2b6fbd75) Co-authored-by: Rafael Fontenelle files: M Doc/library/tarfile.rst diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst index f1298514bd5b0e..8d10db8f2c2921 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -63,8 +63,8 @@ Some facts and figures: +--+-+ | mode | action | +==+=+ - | ``'r' or 'r:*'`` | Open for reading with transparent | - | | compression (recommended). | + | ``'r'`` or | Open for reading with transparent | + | ``'r:*'``| compression (recommended). | +--+-+ | ``'r:'`` | Open for reading exclusively without| | | compression.| @@ -98,10 +98,11 @@ Some facts and figures: | | Raise a :exc:`FileExistsError` exception| | | if it already exists. | +--+-+ - | ``'a' or 'a:'`` | Open for appending with no compression. The | - | | file is created if it does not exist. | + | ``'a'`` or | Open for appending with no compression. The | + | ``'a:'`` | file is created if it does not exist. | +--+-+ - | ``'w' or 'w:'`` | Open for uncompressed writing. | + | ``'w'`` or | Open for uncompressed writing. | + | ``'w:'`` | | +--+-+ | ``'w:gz'`` | Open for gzip compressed writing. | +--+-+ ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-136288: Fix error message in `_testcapi/vectorcall.c` (GH-136258) (GH-136295)
https://github.com/python/cpython/commit/a717ed986dd8853fd6a27ee4830e72e6cb3c6c0a commit: a717ed986dd8853fd6a27ee4830e72e6cb3c6c0a branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-04T16:17:10Z summary: [3.13] gh-136288: Fix error message in `_testcapi/vectorcall.c` (GH-136258) (GH-136295) gh-136288: Fix error message in `_testcapi/vectorcall.c` (GH-136258) Use the %N format specifier instead of %s and `PyType_GetName`. (cherry picked from commit d1d5dce14f90d777608e4403d09079421ff55944) Co-authored-by: William S Fulton files: M Modules/_testcapi/vectorcall.c diff --git a/Modules/_testcapi/vectorcall.c b/Modules/_testcapi/vectorcall.c index 03aaacb328e0b6..f89dcb6c4cf03c 100644 --- a/Modules/_testcapi/vectorcall.c +++ b/Modules/_testcapi/vectorcall.c @@ -179,14 +179,14 @@ _testcapi_VectorCallClass_set_vectorcall_impl(PyObject *self, if (!PyObject_TypeCheck(self, type)) { return PyErr_Format( PyExc_TypeError, -"expected %s instance", -PyType_GetName(type)); +"expected %N instance", +type); } if (!type->tp_vectorcall_offset) { return PyErr_Format( PyExc_TypeError, -"type %s has no vectorcall offset", -PyType_GetName(type)); +"type %N has no vectorcall offset", +type); } *(vectorcallfunc*)((char*)self + type->tp_vectorcall_offset) = ( VectorCallClass_vectorcall); ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-136288: Fix error message in `_testcapi/vectorcall.c` (GH-136258) (GH-136294)
https://github.com/python/cpython/commit/6d21cc54fffbe56df3372f65227160bf27807158 commit: 6d21cc54fffbe56df3372f65227160bf27807158 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-04T16:18:32Z summary: [3.14] gh-136288: Fix error message in `_testcapi/vectorcall.c` (GH-136258) (GH-136294) gh-136288: Fix error message in `_testcapi/vectorcall.c` (GH-136258) Use the %N format specifier instead of %s and `PyType_GetName`. (cherry picked from commit d1d5dce14f90d777608e4403d09079421ff55944) Co-authored-by: William S Fulton files: M Modules/_testcapi/vectorcall.c diff --git a/Modules/_testcapi/vectorcall.c b/Modules/_testcapi/vectorcall.c index 03aaacb328e0b6..f89dcb6c4cf03c 100644 --- a/Modules/_testcapi/vectorcall.c +++ b/Modules/_testcapi/vectorcall.c @@ -179,14 +179,14 @@ _testcapi_VectorCallClass_set_vectorcall_impl(PyObject *self, if (!PyObject_TypeCheck(self, type)) { return PyErr_Format( PyExc_TypeError, -"expected %s instance", -PyType_GetName(type)); +"expected %N instance", +type); } if (!type->tp_vectorcall_offset) { return PyErr_Format( PyExc_TypeError, -"type %s has no vectorcall offset", -PyType_GetName(type)); +"type %N has no vectorcall offset", +type); } *(vectorcallfunc*)((char*)self + type->tp_vectorcall_offset) = ( VectorCallClass_vectorcall); ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-135906: Use `_PyObject_CAST` in internal headers (GH-135892)
https://github.com/python/cpython/commit/fe187fae8d8321f1b8d3c9560a35efe904de4217
commit: fe187fae8d8321f1b8d3c9560a35efe904de4217
branch: main
author: Charlie Lin
committer: ZeroIntensity
date: 2025-07-07T12:56:14-04:00
summary:
gh-135906: Use `_PyObject_CAST` in internal headers (GH-135892)
Fixes build errors encountered in python-greenlet/greenlet#450 when building
greenlet on the free-threaded build.
-
Co-authored-by: Peter Bierma
Co-authored-by: Victor Stinner
files:
A Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst
M Include/internal/pycore_object.h
M Include/internal/pycore_stackref.h
diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h
index 8fe9875fae0687..40f8ca68c00b72 100644
--- a/Include/internal/pycore_object.h
+++ b/Include/internal/pycore_object.h
@@ -614,7 +614,7 @@ static inline PyObject *
_Py_XGetRef(PyObject **ptr)
{
for (;;) {
-PyObject *value = _Py_atomic_load_ptr(ptr);
+PyObject *value = _PyObject_CAST(_Py_atomic_load_ptr(ptr));
if (value == NULL) {
return value;
}
@@ -629,7 +629,7 @@ _Py_XGetRef(PyObject **ptr)
static inline PyObject *
_Py_TryXGetRef(PyObject **ptr)
{
-PyObject *value = _Py_atomic_load_ptr(ptr);
+PyObject *value = _PyObject_CAST(_Py_atomic_load_ptr(ptr));
if (value == NULL) {
return value;
}
diff --git a/Include/internal/pycore_stackref.h
b/Include/internal/pycore_stackref.h
index 48a40a4c3479c7..6bf82d8322f508 100644
--- a/Include/internal/pycore_stackref.h
+++ b/Include/internal/pycore_stackref.h
@@ -829,7 +829,7 @@ _Py_TryIncrefCompareStackRef(PyObject **src, PyObject *op,
_PyStackRef *out)
static inline int
_Py_TryXGetStackRef(PyObject **src, _PyStackRef *out)
{
-PyObject *op = _Py_atomic_load_ptr_relaxed(src);
+PyObject *op = _PyObject_CAST(_Py_atomic_load_ptr_relaxed(src));
if (op == NULL) {
*out = PyStackRef_NULL;
return 1;
diff --git
a/Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst
b/Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst
new file mode 100644
index 00..7852759a702804
--- /dev/null
+++ b/Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst
@@ -0,0 +1 @@
+Fix compilation errors when compiling the internal headers with a C++ compiler.
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] [3.14] gh-135906: Use `_PyObject_CAST` in internal headers (GH-135892) (GH-136392)
https://github.com/python/cpython/commit/c72699086fe49ed127c1276e96027729381ea8c7 commit: c72699086fe49ed127c1276e96027729381ea8c7 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-07T17:21:28Z summary: [3.14] gh-135906: Use `_PyObject_CAST` in internal headers (GH-135892) (GH-136392) gh-135906: Use `_PyObject_CAST` in internal headers (GH-135892) Fixes build errors encountered in python-greenlet/greenlet#450 when building greenlet on the free-threaded build. - (cherry picked from commit fe187fae8d8321f1b8d3c9560a35efe904de4217) Co-authored-by: Charlie Lin Co-authored-by: Peter Bierma Co-authored-by: Victor Stinner files: A Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst M Include/internal/pycore_object.h M Include/internal/pycore_stackref.h diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h index 1f9c7b1bf55b3f..12c5614834f565 100644 --- a/Include/internal/pycore_object.h +++ b/Include/internal/pycore_object.h @@ -614,7 +614,7 @@ static inline PyObject * _Py_XGetRef(PyObject **ptr) { for (;;) { -PyObject *value = _Py_atomic_load_ptr(ptr); +PyObject *value = _PyObject_CAST(_Py_atomic_load_ptr(ptr)); if (value == NULL) { return value; } @@ -629,7 +629,7 @@ _Py_XGetRef(PyObject **ptr) static inline PyObject * _Py_TryXGetRef(PyObject **ptr) { -PyObject *value = _Py_atomic_load_ptr(ptr); +PyObject *value = _PyObject_CAST(_Py_atomic_load_ptr(ptr)); if (value == NULL) { return value; } diff --git a/Include/internal/pycore_stackref.h b/Include/internal/pycore_stackref.h index 21306b95f9c2e4..0ce759fc743d82 100644 --- a/Include/internal/pycore_stackref.h +++ b/Include/internal/pycore_stackref.h @@ -765,7 +765,7 @@ _Py_TryIncrefCompareStackRef(PyObject **src, PyObject *op, _PyStackRef *out) static inline int _Py_TryXGetStackRef(PyObject **src, _PyStackRef *out) { -PyObject *op = _Py_atomic_load_ptr_relaxed(src); +PyObject *op = _PyObject_CAST(_Py_atomic_load_ptr_relaxed(src)); if (op == NULL) { *out = PyStackRef_NULL; return 1; diff --git a/Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst b/Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst new file mode 100644 index 00..7852759a702804 --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst @@ -0,0 +1 @@ +Fix compilation errors when compiling the internal headers with a C++ compiler. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-131825: Fix `sqlite3` timezone-naive adapter recipe (GH-136270) (GH-136468)
https://github.com/python/cpython/commit/217638588f69d024dd394fdd90f40ddf9f8ed2a6 commit: 217638588f69d024dd394fdd90f40ddf9f8ed2a6 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-09T14:13:02Z summary: [3.13] gh-131825: Fix `sqlite3` timezone-naive adapter recipe (GH-136270) (GH-136468) gh-131825: Fix `sqlite3` timezone-naive adapter recipe (GH-136270) (cherry picked from commit 6a6cd3c07c0300c8799878a48d555470be2a52f7) Co-authored-by: NekrodNIK <[email protected]> files: M Doc/library/sqlite3.rst diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 2a8463310ca880..950a7f13067504 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -2307,7 +2307,7 @@ This section shows recipes for common adapters and converters. def adapt_datetime_iso(val): """Adapt datetime.datetime to timezone-naive ISO 8601 date.""" - return val.isoformat() + return val.replace(tzinfo=None).isoformat() def adapt_datetime_epoch(val): """Adapt datetime.datetime to Unix timestamp.""" ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-131825: Fix `sqlite3` timezone-naive adapter recipe (GH-136270)
https://github.com/python/cpython/commit/6a6cd3c07c0300c8799878a48d555470be2a52f7 commit: 6a6cd3c07c0300c8799878a48d555470be2a52f7 branch: main author: NekrodNIK <[email protected]> committer: ZeroIntensity date: 2025-07-09T10:06:42-04:00 summary: gh-131825: Fix `sqlite3` timezone-naive adapter recipe (GH-136270) files: M Doc/library/sqlite3.rst diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 641e1f1de03a1d..a14af6d3d88df2 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -2288,7 +2288,7 @@ This section shows recipes for common adapters and converters. def adapt_datetime_iso(val): """Adapt datetime.datetime to timezone-naive ISO 8601 date.""" - return val.isoformat() + return val.replace(tzinfo=None).isoformat() def adapt_datetime_epoch(val): """Adapt datetime.datetime to Unix timestamp.""" ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-131825: Fix `sqlite3` timezone-naive adapter recipe (GH-136270) (GH-136467)
https://github.com/python/cpython/commit/75640d4b1f65b316089f294c93745febabeffc87 commit: 75640d4b1f65b316089f294c93745febabeffc87 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-09T14:12:47Z summary: [3.14] gh-131825: Fix `sqlite3` timezone-naive adapter recipe (GH-136270) (GH-136467) gh-131825: Fix `sqlite3` timezone-naive adapter recipe (GH-136270) (cherry picked from commit 6a6cd3c07c0300c8799878a48d555470be2a52f7) Co-authored-by: NekrodNIK <[email protected]> files: M Doc/library/sqlite3.rst diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index e2726e53f09cd6..e939e61a9676ee 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -2289,7 +2289,7 @@ This section shows recipes for common adapters and converters. def adapt_datetime_iso(val): """Adapt datetime.datetime to timezone-naive ISO 8601 date.""" - return val.isoformat() + return val.replace(tzinfo=None).isoformat() def adapt_datetime_epoch(val): """Adapt datetime.datetime to Unix timestamp.""" ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-81520: Document unexpected `os.path.ismount` behaviour with btrfs subvolumes (GH-136058) (GH-136471)
https://github.com/python/cpython/commit/78359403c56cf2fa9461851da958ad044a34649d commit: 78359403c56cf2fa9461851da958ad044a34649d branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-09T16:00:54Z summary: [3.14] gh-81520: Document unexpected `os.path.ismount` behaviour with btrfs subvolumes (GH-136058) (GH-136471) gh-81520: Document unexpected `os.path.ismount` behaviour with btrfs subvolumes (GH-136058) (cherry picked from commit 591abcc01fcf1c65c7fdfaca7274f5d3f9f022da) Co-authored-by: Oskar Roesler files: M Doc/library/os.path.rst diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst index cd2c5dfbb3f122..32a2970d2d3a2c 100644 --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -298,9 +298,10 @@ the :mod:`glob` module.) device than *path*, or whether :file:`{path}/..` and *path* point to the same i-node on the same device --- this should detect mount points for all Unix and POSIX variants. It is not able to reliably detect bind mounts on the - same filesystem. On Windows, a drive letter root and a share UNC are - always mount points, and for any other path ``GetVolumePathName`` is called - to see if it is different from the input path. + same filesystem. On Linux systems, it will always return ``True`` for btrfs + subvolumes, even if they aren't mount points. On Windows, a drive letter root + and a share UNC are always mount points, and for any other path + ``GetVolumePathName`` is called to see if it is different from the input path. .. versionchanged:: 3.4 Added support for detecting non-root mount points on Windows. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-81520: Document unexpected `os.path.ismount` behaviour with btrfs subvolumes (GH-136058) (GH-136473)
https://github.com/python/cpython/commit/6c81051aa8813665f1d3f651da90a146cb07a8bf commit: 6c81051aa8813665f1d3f651da90a146cb07a8bf branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-09T16:02:49Z summary: [3.13] gh-81520: Document unexpected `os.path.ismount` behaviour with btrfs subvolumes (GH-136058) (GH-136473) gh-81520: Document unexpected `os.path.ismount` behaviour with btrfs subvolumes (GH-136058) (cherry picked from commit 591abcc01fcf1c65c7fdfaca7274f5d3f9f022da) Co-authored-by: Oskar Roesler files: M Doc/library/os.path.rst diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst index 8713581d1c05ed..35cfb96ba09564 100644 --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -298,9 +298,10 @@ the :mod:`glob` module.) device than *path*, or whether :file:`{path}/..` and *path* point to the same i-node on the same device --- this should detect mount points for all Unix and POSIX variants. It is not able to reliably detect bind mounts on the - same filesystem. On Windows, a drive letter root and a share UNC are - always mount points, and for any other path ``GetVolumePathName`` is called - to see if it is different from the input path. + same filesystem. On Linux systems, it will always return ``True`` for btrfs + subvolumes, even if they aren't mount points. On Windows, a drive letter root + and a share UNC are always mount points, and for any other path + ``GetVolumePathName`` is called to see if it is different from the input path. .. versionchanged:: 3.4 Added support for detecting non-root mount points on Windows. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-81520: Document unexpected `os.path.ismount` behaviour with btrfs subvolumes (GH-136058)
https://github.com/python/cpython/commit/591abcc01fcf1c65c7fdfaca7274f5d3f9f022da
commit: 591abcc01fcf1c65c7fdfaca7274f5d3f9f022da
branch: main
author: Oskar Roesler
committer: ZeroIntensity
date: 2025-07-09T11:54:58-04:00
summary:
gh-81520: Document unexpected `os.path.ismount` behaviour with btrfs subvolumes
(GH-136058)
files:
M Doc/library/os.path.rst
diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst
index f72aee19d8f332..1c1cf07a655ae7 100644
--- a/Doc/library/os.path.rst
+++ b/Doc/library/os.path.rst
@@ -298,9 +298,10 @@ the :mod:`glob` module.)
device than *path*, or whether :file:`{path}/..` and *path* point to the
same
i-node on the same device --- this should detect mount points for all Unix
and POSIX variants. It is not able to reliably detect bind mounts on the
- same filesystem. On Windows, a drive letter root and a share UNC are
- always mount points, and for any other path ``GetVolumePathName`` is called
- to see if it is different from the input path.
+ same filesystem. On Linux systems, it will always return ``True`` for btrfs
+ subvolumes, even if they aren't mount points. On Windows, a drive letter
root
+ and a share UNC are always mount points, and for any other path
+ ``GetVolumePathName`` is called to see if it is different from the input
path.
.. versionchanged:: 3.4
Added support for detecting non-root mount points on Windows.
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] [3.14] gh-132346: Docs: Clarify that reference counts aren't stable between versions (GH-132352) (GH-136613)
https://github.com/python/cpython/commit/9ee72ab266a15906aa7e714ac601b3186e1ef51c commit: 9ee72ab266a15906aa7e714ac601b3186e1ef51c branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-13T09:17:48Z summary: [3.14] gh-132346: Docs: Clarify that reference counts aren't stable between versions (GH-132352) (GH-136613) gh-132346: Docs: Clarify that reference counts aren't stable between versions (GH-132352) (cherry picked from commit 3dbe02ccd3eefc48ac9fa14427bb4cdb82d1ebae) Co-authored-by: Peter Bierma files: M Doc/glossary.rst diff --git a/Doc/glossary.rst b/Doc/glossary.rst index 705b0a9279c6d4..199a917f9f101e 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -1208,6 +1208,11 @@ Glossary :func:`sys.getrefcount` function to return the reference count for a particular object. + In :term:`CPython`, reference counts are not considered to be stable + or well-defined values; the number of references to an object, and how + that number is affected by Python code, may be different between + versions. + regular package A traditional :term:`package`, such as a directory containing an ``__init__.py`` file. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] Docs: Fix and improve the `PyUnstable_Object_EnableDeferredRefcount` documentation (GH-135323)
https://github.com/python/cpython/commit/0d4fd10fbab2767fad3eb27639905c8885b88c89 commit: 0d4fd10fbab2767fad3eb27639905c8885b88c89 branch: main author: Peter Bierma committer: ZeroIntensity date: 2025-07-13T02:46:13-04:00 summary: Docs: Fix and improve the `PyUnstable_Object_EnableDeferredRefcount` documentation (GH-135323) files: M Doc/c-api/object.rst diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst index 21fa1491b33d86..55f0d0f9fb7ff8 100644 --- a/Doc/c-api/object.rst +++ b/Doc/c-api/object.rst @@ -611,12 +611,13 @@ Object Protocol if supported by the runtime. In the :term:`free-threaded ` build, this allows the interpreter to avoid reference count adjustments to *obj*, which may improve multi-threaded performance. The tradeoff is - that *obj* will only be deallocated by the tracing garbage collector. + that *obj* will only be deallocated by the tracing garbage collector, and + not when the interpreter no longer has any references to it. - This function returns ``1`` if deferred reference counting is enabled on *obj* - (including when it was enabled before the call), + This function returns ``1`` if deferred reference counting is enabled on *obj*, and ``0`` if deferred reference counting is not supported or if the hint was - ignored by the runtime. This function is thread-safe, and cannot fail. + ignored by the interpreter, such as when deferred reference counting is already + enabled on *obj*. This function is thread-safe, and cannot fail. This function does nothing on builds with the :term:`GIL` enabled, which do not support deferred reference counting. This also does nothing if *obj* is not @@ -624,7 +625,8 @@ Object Protocol :c:func:`PyObject_GC_IsTracked`). This function is intended to be used soon after *obj* is created, - by the code that creates it. + by the code that creates it, such as in the object's :c:member:`~PyTypeObject.tp_new` + slot. .. versionadded:: 3.14 ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-132346: Docs: Clarify that reference counts aren't stable between versions (GH-132352)
https://github.com/python/cpython/commit/3dbe02ccd3eefc48ac9fa14427bb4cdb82d1ebae commit: 3dbe02ccd3eefc48ac9fa14427bb4cdb82d1ebae branch: main author: Peter Bierma committer: ZeroIntensity date: 2025-07-13T05:10:37-04:00 summary: gh-132346: Docs: Clarify that reference counts aren't stable between versions (GH-132352) files: M Doc/glossary.rst diff --git a/Doc/glossary.rst b/Doc/glossary.rst index 705b0a9279c6d4..199a917f9f101e 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -1208,6 +1208,11 @@ Glossary :func:`sys.getrefcount` function to return the reference count for a particular object. + In :term:`CPython`, reference counts are not considered to be stable + or well-defined values; the number of references to an object, and how + that number is affected by Python code, may be different between + versions. + regular package A traditional :term:`package`, such as a directory containing an ``__init__.py`` file. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-132346: Docs: Clarify that reference counts aren't stable between versions (GH-132352) (GH-136614)
https://github.com/python/cpython/commit/fac28e47910ac2debcfe994b02a38b68a28b3eb5 commit: fac28e47910ac2debcfe994b02a38b68a28b3eb5 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-13T09:18:27Z summary: [3.13] gh-132346: Docs: Clarify that reference counts aren't stable between versions (GH-132352) (GH-136614) gh-132346: Docs: Clarify that reference counts aren't stable between versions (GH-132352) (cherry picked from commit 3dbe02ccd3eefc48ac9fa14427bb4cdb82d1ebae) Co-authored-by: Peter Bierma files: M Doc/glossary.rst diff --git a/Doc/glossary.rst b/Doc/glossary.rst index 118d4fbe30fda7..9e44b156e73322 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -1163,6 +1163,11 @@ Glossary :func:`sys.getrefcount` function to return the reference count for a particular object. + In :term:`CPython`, reference counts are not considered to be stable + or well-defined values; the number of references to an object, and how + that number is affected by Python code, may be different between + versions. + regular package A traditional :term:`package`, such as a directory containing an ``__init__.py`` file. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-136394: Fix race condition in test_zstd (GH-136432)
https://github.com/python/cpython/commit/f519918ec6c125715d4efc9713ba80e83346e466 commit: f519918ec6c125715d4efc9713ba80e83346e466 branch: main author: Rogdham <[email protected]> committer: ZeroIntensity date: 2025-07-10T08:47:27-04:00 summary: gh-136394: Fix race condition in test_zstd (GH-136432) files: M Lib/test/test_zstd.py diff --git a/Lib/test/test_zstd.py b/Lib/test/test_zstd.py index 90b2adc9665480..6358cc78739cd9 100644 --- a/Lib/test/test_zstd.py +++ b/Lib/test/test_zstd.py @@ -2673,8 +2673,12 @@ def test_compress_locking(self): input = b'a'* (16*_1K) num_threads = 8 +# gh-136394: the first output of .compress() includes the frame header +# we run the first .compress() call outside of the threaded portion +# to make the test order-independent + comp = ZstdCompressor() -parts = [] +parts = [comp.compress(input, ZstdCompressor.FLUSH_BLOCK)] for _ in range(num_threads): res = comp.compress(input, ZstdCompressor.FLUSH_BLOCK) if res: @@ -2683,7 +2687,7 @@ def test_compress_locking(self): expected = b''.join(parts) + rest1 comp = ZstdCompressor() -output = [] +output = [comp.compress(input, ZstdCompressor.FLUSH_BLOCK)] def run_method(method, input_data, output_data): res = method(input_data, ZstdCompressor.FLUSH_BLOCK) if res: ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-136394: Fix race condition in test_zstd (GH-136432) (GH-136506)
https://github.com/python/cpython/commit/da8bcfd949885a9a057038ef0095f442b05ee29a commit: da8bcfd949885a9a057038ef0095f442b05ee29a branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-10T09:13:34-04:00 summary: [3.14] gh-136394: Fix race condition in test_zstd (GH-136432) (GH-136506) gh-136394: Fix race condition in test_zstd (GH-136432) (cherry picked from commit f519918ec6c125715d4efc9713ba80e83346e466) Co-authored-by: Rogdham <[email protected]> files: M Lib/test/test_zstd.py diff --git a/Lib/test/test_zstd.py b/Lib/test/test_zstd.py index e83caaf4c07b13..cf618534add387 100644 --- a/Lib/test/test_zstd.py +++ b/Lib/test/test_zstd.py @@ -2674,8 +2674,12 @@ def test_compress_locking(self): input = b'a'* (16*_1K) num_threads = 8 +# gh-136394: the first output of .compress() includes the frame header +# we run the first .compress() call outside of the threaded portion +# to make the test order-independent + comp = ZstdCompressor() -parts = [] +parts = [comp.compress(input, ZstdCompressor.FLUSH_BLOCK)] for _ in range(num_threads): res = comp.compress(input, ZstdCompressor.FLUSH_BLOCK) if res: @@ -2684,7 +2688,7 @@ def test_compress_locking(self): expected = b''.join(parts) + rest1 comp = ZstdCompressor() -output = [] +output = [comp.compress(input, ZstdCompressor.FLUSH_BLOCK)] def run_method(method, input_data, output_data): res = method(input_data, ZstdCompressor.FLUSH_BLOCK) if res: ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] Docs: Fix and improve the `PyUnstable_Object_EnableDeferredRefcount` documentation (GH-135323) (GH-136610)
https://github.com/python/cpython/commit/a1ed132a19ac8a799d1c187527ce16e543e8146f commit: a1ed132a19ac8a799d1c187527ce16e543e8146f branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-13T06:52:58Z summary: [3.14] Docs: Fix and improve the `PyUnstable_Object_EnableDeferredRefcount` documentation (GH-135323) (GH-136610) Docs: Fix and improve the `PyUnstable_Object_EnableDeferredRefcount` documentation (GH-135323) (cherry picked from commit 0d4fd10fbab2767fad3eb27639905c8885b88c89) Co-authored-by: Peter Bierma files: M Doc/c-api/object.rst diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst index 0fd159f1eb87f8..241fbd3a4866c7 100644 --- a/Doc/c-api/object.rst +++ b/Doc/c-api/object.rst @@ -596,12 +596,13 @@ Object Protocol if supported by the runtime. In the :term:`free-threaded ` build, this allows the interpreter to avoid reference count adjustments to *obj*, which may improve multi-threaded performance. The tradeoff is - that *obj* will only be deallocated by the tracing garbage collector. + that *obj* will only be deallocated by the tracing garbage collector, and + not when the interpreter no longer has any references to it. - This function returns ``1`` if deferred reference counting is enabled on *obj* - (including when it was enabled before the call), + This function returns ``1`` if deferred reference counting is enabled on *obj*, and ``0`` if deferred reference counting is not supported or if the hint was - ignored by the runtime. This function is thread-safe, and cannot fail. + ignored by the interpreter, such as when deferred reference counting is already + enabled on *obj*. This function is thread-safe, and cannot fail. This function does nothing on builds with the :term:`GIL` enabled, which do not support deferred reference counting. This also does nothing if *obj* is not @@ -609,7 +610,8 @@ Object Protocol :c:func:`PyObject_GC_IsTracked`). This function is intended to be used soon after *obj* is created, - by the code that creates it. + by the code that creates it, such as in the object's :c:member:`~PyTypeObject.tp_new` + slot. .. versionadded:: 3.14 ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] Docs: Fix indentation in `slice` class of `functions.rst` (GH-134393) (#135948)
https://github.com/python/cpython/commit/39bbf59a1922f92d91b6bec657d0458f9843c8a9 commit: 39bbf59a1922f92d91b6bec657d0458f9843c8a9 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-25T17:52:59Z summary: [3.14] Docs: Fix indentation in `slice` class of `functions.rst` (GH-134393) (#135948) Docs: Fix indentation in `slice` class of `functions.rst` (GH-134393) Paragraph should not be under `slice.step`. It applies to the whole class. (cherry picked from commit 6227662ff3bf838d31e9441eda935d24733d705a) Co-authored-by: Rob Reynolds <[email protected]> files: M Doc/library/functions.rst diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 2ecce3dba5a0b9..80bd1275973f8d 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1839,15 +1839,15 @@ are always available. They are listed here in alphabetical order. ``range(start, stop, step)``. The *start* and *step* arguments default to ``None``. + Slice objects have read-only data attributes :attr:`!start`, + :attr:`!stop`, and :attr:`!step` which merely return the argument + values (or their default). They have no other explicit functionality; + however, they are used by NumPy and other third-party packages. + .. attribute:: slice.start .. attribute:: slice.stop .. attribute:: slice.step - Slice objects have read-only data attributes :attr:`!start`, - :attr:`!stop`, and :attr:`!step` which merely return the argument - values (or their default). They have no other explicit functionality; - however, they are used by NumPy and other third-party packages. - Slice objects are also generated when extended indexing syntax is used. For example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See :func:`itertools.islice` for an alternate version that returns an ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] Docs: Fix indentation in `slice` class of `functions.rst` (GH-134393)
https://github.com/python/cpython/commit/6227662ff3bf838d31e9441eda935d24733d705a commit: 6227662ff3bf838d31e9441eda935d24733d705a branch: main author: Rob Reynolds committer: ZeroIntensity date: 2025-06-25T13:40:00-04:00 summary: Docs: Fix indentation in `slice` class of `functions.rst` (GH-134393) Paragraph should not be under `slice.step`. It applies to the whole class. - Co-authored-by: Rob Reynolds <[email protected]> files: M Doc/library/functions.rst diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 2ecce3dba5a0b9..80bd1275973f8d 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1839,15 +1839,15 @@ are always available. They are listed here in alphabetical order. ``range(start, stop, step)``. The *start* and *step* arguments default to ``None``. + Slice objects have read-only data attributes :attr:`!start`, + :attr:`!stop`, and :attr:`!step` which merely return the argument + values (or their default). They have no other explicit functionality; + however, they are used by NumPy and other third-party packages. + .. attribute:: slice.start .. attribute:: slice.stop .. attribute:: slice.step - Slice objects have read-only data attributes :attr:`!start`, - :attr:`!stop`, and :attr:`!step` which merely return the argument - values (or their default). They have no other explicit functionality; - however, they are used by NumPy and other third-party packages. - Slice objects are also generated when extended indexing syntax is used. For example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See :func:`itertools.islice` for an alternate version that returns an ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] Docs: Fix indentation in `slice` class of `functions.rst` (GH-134393) (GH-135949)
https://github.com/python/cpython/commit/335d7da5db642bac97b23f547387716569f92326 commit: 335d7da5db642bac97b23f547387716569f92326 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-25T17:45:57Z summary: [3.13] Docs: Fix indentation in `slice` class of `functions.rst` (GH-134393) (GH-135949) Docs: Fix indentation in `slice` class of `functions.rst` (GH-134393) Paragraph should not be under `slice.step`. It applies to the whole class. (cherry picked from commit 6227662ff3bf838d31e9441eda935d24733d705a) Co-authored-by: Rob Reynolds <[email protected]> files: M Doc/library/functions.rst diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 6faa208d8b0b83..4453a083327af4 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1827,15 +1827,15 @@ are always available. They are listed here in alphabetical order. ``range(start, stop, step)``. The *start* and *step* arguments default to ``None``. + Slice objects have read-only data attributes :attr:`!start`, + :attr:`!stop`, and :attr:`!step` which merely return the argument + values (or their default). They have no other explicit functionality; + however, they are used by NumPy and other third-party packages. + .. attribute:: slice.start .. attribute:: slice.stop .. attribute:: slice.step - Slice objects have read-only data attributes :attr:`!start`, - :attr:`!stop`, and :attr:`!step` which merely return the argument - values (or their default). They have no other explicit functionality; - however, they are used by NumPy and other third-party packages. - Slice objects are also generated when extended indexing syntax is used. For example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See :func:`itertools.islice` for an alternate version that returns an ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-136135: Doc: Fix some broken links (GH-136137) (GH-136220)
https://github.com/python/cpython/commit/b86d3f0d69de51971ecb530e9a7603466d76c8ab commit: b86d3f0d69de51971ecb530e9a7603466d76c8ab branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-03T00:57:39Z summary: [3.14] gh-136135: Doc: Fix some broken links (GH-136137) (GH-136220) gh-136135: Doc: Fix some broken links (GH-136137) (cherry picked from commit 135ba86212ad116af3cc4a6ba656bc8cfaab131a) Co-authored-by: Weilin Du <[email protected]> files: M Doc/howto/functional.rst M Doc/installing/index.rst diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst index aff651ffc2b91a..b0b2414a1a02c8 100644 --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -1217,7 +1217,7 @@ flow inside a program. The book uses Scheme for its examples, but many of the design approaches described in these chapters are applicable to functional-style Python code. -https://www.defmacro.org/ramblings/fp.html: A general introduction to functional +https://defmacro.org/2006/06/19/fp.html: A general introduction to functional programming that uses Java examples and has a lengthy historical introduction. https://en.wikipedia.org/wiki/Functional_programming: General Wikipedia entry diff --git a/Doc/installing/index.rst b/Doc/installing/index.rst index a46c1caefe4d8a..3a485a43a5a751 100644 --- a/Doc/installing/index.rst +++ b/Doc/installing/index.rst @@ -188,7 +188,7 @@ switch:: Once the Development & Deployment part of PPUG is fleshed out, some of those sections should be linked from new questions here (most notably, we should have a question about avoiding depending on PyPI that links to - https://packaging.python.org/en/latest/mirrors/) + https://packaging.python.org/en/latest/guides/index-mirrors-and-caches/) Common installation issues ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-136135: Doc: Fix some broken links (GH-136137)
https://github.com/python/cpython/commit/135ba86212ad116af3cc4a6ba656bc8cfaab131a commit: 135ba86212ad116af3cc4a6ba656bc8cfaab131a branch: main author: Weilin Du <[email protected]> committer: ZeroIntensity date: 2025-07-02T20:51:31-04:00 summary: gh-136135: Doc: Fix some broken links (GH-136137) files: M Doc/howto/functional.rst M Doc/installing/index.rst diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst index 78e56e0c64fb10..053558e389030a 100644 --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -1217,7 +1217,7 @@ flow inside a program. The book uses Scheme for its examples, but many of the design approaches described in these chapters are applicable to functional-style Python code. -https://www.defmacro.org/ramblings/fp.html: A general introduction to functional +https://defmacro.org/2006/06/19/fp.html: A general introduction to functional programming that uses Java examples and has a lengthy historical introduction. https://en.wikipedia.org/wiki/Functional_programming: General Wikipedia entry diff --git a/Doc/installing/index.rst b/Doc/installing/index.rst index a46c1caefe4d8a..3a485a43a5a751 100644 --- a/Doc/installing/index.rst +++ b/Doc/installing/index.rst @@ -188,7 +188,7 @@ switch:: Once the Development & Deployment part of PPUG is fleshed out, some of those sections should be linked from new questions here (most notably, we should have a question about avoiding depending on PyPI that links to - https://packaging.python.org/en/latest/mirrors/) + https://packaging.python.org/en/latest/guides/index-mirrors-and-caches/) Common installation issues ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-136135: Doc: Fix some broken links (GH-136137) (GH-136219)
https://github.com/python/cpython/commit/004f4643387e19069718ffdb1437de830697c2d2 commit: 004f4643387e19069718ffdb1437de830697c2d2 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-03T00:59:13Z summary: [3.13] gh-136135: Doc: Fix some broken links (GH-136137) (GH-136219) gh-136135: Doc: Fix some broken links (GH-136137) (cherry picked from commit 135ba86212ad116af3cc4a6ba656bc8cfaab131a) Co-authored-by: Weilin Du <[email protected]> files: M Doc/howto/functional.rst M Doc/installing/index.rst diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst index aff651ffc2b91a..b0b2414a1a02c8 100644 --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -1217,7 +1217,7 @@ flow inside a program. The book uses Scheme for its examples, but many of the design approaches described in these chapters are applicable to functional-style Python code. -https://www.defmacro.org/ramblings/fp.html: A general introduction to functional +https://defmacro.org/2006/06/19/fp.html: A general introduction to functional programming that uses Java examples and has a lengthy historical introduction. https://en.wikipedia.org/wiki/Functional_programming: General Wikipedia entry diff --git a/Doc/installing/index.rst b/Doc/installing/index.rst index a46c1caefe4d8a..3a485a43a5a751 100644 --- a/Doc/installing/index.rst +++ b/Doc/installing/index.rst @@ -188,7 +188,7 @@ switch:: Once the Development & Deployment part of PPUG is fleshed out, some of those sections should be linked from new questions here (most notably, we should have a question about avoiding depending on PyPI that links to - https://packaging.python.org/en/latest/mirrors/) + https://packaging.python.org/en/latest/guides/index-mirrors-and-caches/) Common installation issues ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-101100: Fix references in `http.cookiejar` docs (GH-136238)
https://github.com/python/cpython/commit/f0c7344a8fbfe67c05981cce67562e7facfae73d commit: f0c7344a8fbfe67c05981cce67562e7facfae73d branch: main author: Weilin Du <[email protected]> committer: ZeroIntensity date: 2025-07-05T09:29:02-04:00 summary: gh-101100: Fix references in `http.cookiejar` docs (GH-136238) files: M Doc/library/http.cookiejar.rst diff --git a/Doc/library/http.cookiejar.rst b/Doc/library/http.cookiejar.rst index 23ddecf873876d..251aea891c3f98 100644 --- a/Doc/library/http.cookiejar.rst +++ b/Doc/library/http.cookiejar.rst @@ -570,7 +570,7 @@ Netscape protocol strictness switches: Don't allow setting cookies whose path doesn't path-match request URI. -:attr:`strict_ns_domain` is a collection of flags. Its value is constructed by +:attr:`~DefaultCookiePolicy.strict_ns_domain` is a collection of flags. Its value is constructed by or-ing together (for example, ``DomainStrictNoDots|DomainStrictNonDomain`` means both flags are set). ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-101100: Fix references in `http.cookiejar` docs (GH-136238) (GH-136317)
https://github.com/python/cpython/commit/e7a2d2ae2c9f8f473d851900ab3e3bc193710f84 commit: e7a2d2ae2c9f8f473d851900ab3e3bc193710f84 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-05T13:35:52Z summary: [3.13] gh-101100: Fix references in `http.cookiejar` docs (GH-136238) (GH-136317) gh-101100: Fix references in `http.cookiejar` docs (GH-136238) (cherry picked from commit f0c7344a8fbfe67c05981cce67562e7facfae73d) Co-authored-by: Weilin Du <[email protected]> files: M Doc/library/http.cookiejar.rst diff --git a/Doc/library/http.cookiejar.rst b/Doc/library/http.cookiejar.rst index 23ddecf873876d..251aea891c3f98 100644 --- a/Doc/library/http.cookiejar.rst +++ b/Doc/library/http.cookiejar.rst @@ -570,7 +570,7 @@ Netscape protocol strictness switches: Don't allow setting cookies whose path doesn't path-match request URI. -:attr:`strict_ns_domain` is a collection of flags. Its value is constructed by +:attr:`~DefaultCookiePolicy.strict_ns_domain` is a collection of flags. Its value is constructed by or-ing together (for example, ``DomainStrictNoDots|DomainStrictNonDomain`` means both flags are set). ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-101100: Fix references in `http.cookiejar` docs (GH-136238) (GH-136318)
https://github.com/python/cpython/commit/53584d307add2c6f32e4bf9a34a3ffa310a1dcd0 commit: 53584d307add2c6f32e4bf9a34a3ffa310a1dcd0 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-05T13:35:24Z summary: [3.14] gh-101100: Fix references in `http.cookiejar` docs (GH-136238) (GH-136318) gh-101100: Fix references in `http.cookiejar` docs (GH-136238) (cherry picked from commit f0c7344a8fbfe67c05981cce67562e7facfae73d) Co-authored-by: Weilin Du <[email protected]> files: M Doc/library/http.cookiejar.rst diff --git a/Doc/library/http.cookiejar.rst b/Doc/library/http.cookiejar.rst index 23ddecf873876d..251aea891c3f98 100644 --- a/Doc/library/http.cookiejar.rst +++ b/Doc/library/http.cookiejar.rst @@ -570,7 +570,7 @@ Netscape protocol strictness switches: Don't allow setting cookies whose path doesn't path-match request URI. -:attr:`strict_ns_domain` is a collection of flags. Its value is constructed by +:attr:`~DefaultCookiePolicy.strict_ns_domain` is a collection of flags. Its value is constructed by or-ing together (for example, ``DomainStrictNoDots|DomainStrictNonDomain`` means both flags are set). ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] Docs: Move "or" outside monospace syntax in tarfile.rst (GH-136263) (GH-136348)
https://github.com/python/cpython/commit/bc3390c00a27be3b51de6375034bfc6dac3ffac9 commit: bc3390c00a27be3b51de6375034bfc6dac3ffac9 branch: 3.13 author: Rafael Fontenelle committer: ZeroIntensity date: 2025-07-06T21:24:51-04:00 summary: [3.13] Docs: Move "or" outside monospace syntax in tarfile.rst (GH-136263) (GH-136348) Docs: Move "or" outside monospace syntax in `tarfile.rst` (GH-136263) (cherry picked from commit ade19880943509945da193202ca89e0b2b6fbd75) files: M Doc/library/tarfile.rst diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst index 1c2f3b13b54a80..e821989396051f 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -56,8 +56,8 @@ Some facts and figures: +--+-+ | mode | action | +==+=+ - | ``'r' or 'r:*'`` | Open for reading with transparent | - | | compression (recommended). | + | ``'r'`` or | Open for reading with transparent | + | ``'r:*'``| compression (recommended). | +--+-+ | ``'r:'`` | Open for reading exclusively without| | | compression.| @@ -85,10 +85,11 @@ Some facts and figures: | | Raise a :exc:`FileExistsError` exception| | | if it already exists. | +--+-+ - | ``'a' or 'a:'`` | Open for appending with no compression. The | - | | file is created if it does not exist. | + | ``'a'`` or | Open for appending with no compression. The | + | ``'a:'`` | file is created if it does not exist. | +--+-+ - | ``'w' or 'w:'`` | Open for uncompressed writing. | + | ``'w'`` or | Open for uncompressed writing. | + | ``'w:'`` | | +--+-+ | ``'w:gz'`` | Open for gzip compressed writing. | +--+-+ ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-131885: Update documented signatures for `csv.{writer,reader}` (GH-136085) (GH-136121)
https://github.com/python/cpython/commit/ad5f88eafa93d6b150a00730cdbb4cb4f55c74e8 commit: ad5f88eafa93d6b150a00730cdbb4cb4f55c74e8 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-30T13:38:49Z summary: [3.13] gh-131885: Update documented signatures for `csv.{writer,reader}` (GH-136085) (GH-136121) gh-131885: Update documented signatures for `csv.{writer,reader}` (GH-136085) (cherry picked from commit 75f40595e555e7d016cf9d2da8aaddb78bb20b2f) Co-authored-by: Adam Dangoor files: M Doc/library/csv.rst diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst index 246999c64e4d68..d39c4ca4a5838b 100644 --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -53,7 +53,7 @@ The :mod:`csv` module defines the following functions: .. index:: single: universal newlines; csv.reader function -.. function:: reader(csvfile, dialect='excel', **fmtparams) +.. function:: reader(csvfile, /, dialect='excel', **fmtparams) Return a :ref:`reader object ` that will process lines from the given *csvfile*. A csvfile must be an iterable of @@ -84,7 +84,7 @@ The :mod:`csv` module defines the following functions: Spam, Lovely Spam, Wonderful Spam -.. function:: writer(csvfile, dialect='excel', **fmtparams) +.. function:: writer(csvfile, /, dialect='excel', **fmtparams) Return a writer object responsible for converting the user's data into delimited strings on the given file-like object. *csvfile* can be any object with a ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-131885: Update documented signatures for `csv.{writer,reader}` (GH-136085) (GH-136120)
https://github.com/python/cpython/commit/ed7719a08d28eed8cf720fe721b881332db527eb commit: ed7719a08d28eed8cf720fe721b881332db527eb branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-30T13:38:57Z summary: [3.14] gh-131885: Update documented signatures for `csv.{writer,reader}` (GH-136085) (GH-136120) gh-131885: Update documented signatures for `csv.{writer,reader}` (GH-136085) (cherry picked from commit 75f40595e555e7d016cf9d2da8aaddb78bb20b2f) Co-authored-by: Adam Dangoor files: M Doc/library/csv.rst diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst index 246999c64e4d68..d39c4ca4a5838b 100644 --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -53,7 +53,7 @@ The :mod:`csv` module defines the following functions: .. index:: single: universal newlines; csv.reader function -.. function:: reader(csvfile, dialect='excel', **fmtparams) +.. function:: reader(csvfile, /, dialect='excel', **fmtparams) Return a :ref:`reader object ` that will process lines from the given *csvfile*. A csvfile must be an iterable of @@ -84,7 +84,7 @@ The :mod:`csv` module defines the following functions: Spam, Lovely Spam, Wonderful Spam -.. function:: writer(csvfile, dialect='excel', **fmtparams) +.. function:: writer(csvfile, /, dialect='excel', **fmtparams) Return a writer object responsible for converting the user's data into delimited strings on the given file-like object. *csvfile* can be any object with a ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-131885: Update documented signatures for `csv.{writer,reader}` (GH-136085)
https://github.com/python/cpython/commit/75f40595e555e7d016cf9d2da8aaddb78bb20b2f
commit: 75f40595e555e7d016cf9d2da8aaddb78bb20b2f
branch: main
author: Adam Dangoor
committer: ZeroIntensity
date: 2025-06-30T09:32:51-04:00
summary:
gh-131885: Update documented signatures for `csv.{writer,reader}` (GH-136085)
files:
M Doc/library/csv.rst
diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst
index 246999c64e4d68..d39c4ca4a5838b 100644
--- a/Doc/library/csv.rst
+++ b/Doc/library/csv.rst
@@ -53,7 +53,7 @@ The :mod:`csv` module defines the following functions:
.. index::
single: universal newlines; csv.reader function
-.. function:: reader(csvfile, dialect='excel', **fmtparams)
+.. function:: reader(csvfile, /, dialect='excel', **fmtparams)
Return a :ref:`reader object ` that will process
lines from the given *csvfile*. A csvfile must be an iterable of
@@ -84,7 +84,7 @@ The :mod:`csv` module defines the following functions:
Spam, Lovely Spam, Wonderful Spam
-.. function:: writer(csvfile, dialect='excel', **fmtparams)
+.. function:: writer(csvfile, /, dialect='excel', **fmtparams)
Return a writer object responsible for converting the user's data into
delimited
strings on the given file-like object. *csvfile* can be any object with a
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] [3.14] gh-133982: Use implementation-specific `open` in `test_fileio.OtherFileTests` (GH-135364) (GH-136148)
https://github.com/python/cpython/commit/028901e97ffb7c10fb07fbe45229c4f37ee6067d commit: 028901e97ffb7c10fb07fbe45229c4f37ee6067d branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-30T22:23:34Z summary: [3.14] gh-133982: Use implementation-specific `open` in `test_fileio.OtherFileTests` (GH-135364) (GH-136148) gh-133982: Use implementation-specific `open` in `test_fileio.OtherFileTests` (GH-135364) (cherry picked from commit 23caccf74ce2c8dc5d9c5eb6350d21ef20c6ea0b) Co-authored-by: Cody Maloney files: M Lib/test/test_fileio.py diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index 5a0f033ebb82d2..e3d54f6315aade 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -591,7 +591,7 @@ def testBytesOpen(self): try: f.write(b"abc") f.close() -with open(TESTFN_ASCII, "rb") as f: +with self.open(TESTFN_ASCII, "rb") as f: self.assertEqual(f.read(), b"abc") finally: os.unlink(TESTFN_ASCII) @@ -608,7 +608,7 @@ def testUtf8BytesOpen(self): try: f.write(b"abc") f.close() -with open(TESTFN_UNICODE, "rb") as f: +with self.open(TESTFN_UNICODE, "rb") as f: self.assertEqual(f.read(), b"abc") finally: os.unlink(TESTFN_UNICODE) @@ -692,13 +692,13 @@ def bug801631(): def testAppend(self): try: -f = open(TESTFN, 'wb') +f = self.FileIO(TESTFN, 'wb') f.write(b'spam') f.close() -f = open(TESTFN, 'ab') +f = self.FileIO(TESTFN, 'ab') f.write(b'eggs') f.close() -f = open(TESTFN, 'rb') +f = self.FileIO(TESTFN, 'rb') d = f.read() f.close() self.assertEqual(d, b'spameggs') @@ -734,6 +734,7 @@ def __setattr__(self, name, value): class COtherFileTests(OtherFileTests, unittest.TestCase): FileIO = _io.FileIO modulename = '_io' +open = _io.open @cpython_only def testInvalidFd_overflow(self): @@ -755,6 +756,7 @@ def test_open_code(self): class PyOtherFileTests(OtherFileTests, unittest.TestCase): FileIO = _pyio.FileIO modulename = '_pyio' +open = _pyio.open def test_open_code(self): # Check that the default behaviour of open_code matches ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-133982: Use implementation-specific `open` in `test_fileio.OtherFileTests` (GH-135364)
https://github.com/python/cpython/commit/23caccf74ce2c8dc5d9c5eb6350d21ef20c6ea0b commit: 23caccf74ce2c8dc5d9c5eb6350d21ef20c6ea0b branch: main author: Cody Maloney committer: ZeroIntensity date: 2025-06-30T17:56:11-04:00 summary: gh-133982: Use implementation-specific `open` in `test_fileio.OtherFileTests` (GH-135364) files: M Lib/test/test_fileio.py diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index 5a0f033ebb82d2..e3d54f6315aade 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -591,7 +591,7 @@ def testBytesOpen(self): try: f.write(b"abc") f.close() -with open(TESTFN_ASCII, "rb") as f: +with self.open(TESTFN_ASCII, "rb") as f: self.assertEqual(f.read(), b"abc") finally: os.unlink(TESTFN_ASCII) @@ -608,7 +608,7 @@ def testUtf8BytesOpen(self): try: f.write(b"abc") f.close() -with open(TESTFN_UNICODE, "rb") as f: +with self.open(TESTFN_UNICODE, "rb") as f: self.assertEqual(f.read(), b"abc") finally: os.unlink(TESTFN_UNICODE) @@ -692,13 +692,13 @@ def bug801631(): def testAppend(self): try: -f = open(TESTFN, 'wb') +f = self.FileIO(TESTFN, 'wb') f.write(b'spam') f.close() -f = open(TESTFN, 'ab') +f = self.FileIO(TESTFN, 'ab') f.write(b'eggs') f.close() -f = open(TESTFN, 'rb') +f = self.FileIO(TESTFN, 'rb') d = f.read() f.close() self.assertEqual(d, b'spameggs') @@ -734,6 +734,7 @@ def __setattr__(self, name, value): class COtherFileTests(OtherFileTests, unittest.TestCase): FileIO = _io.FileIO modulename = '_io' +open = _io.open @cpython_only def testInvalidFd_overflow(self): @@ -755,6 +756,7 @@ def test_open_code(self): class PyOtherFileTests(OtherFileTests, unittest.TestCase): FileIO = _pyio.FileIO modulename = '_pyio' +open = _pyio.open def test_open_code(self): # Check that the default behaviour of open_code matches ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-133982: Use implementation-specific `open` in `test_fileio.OtherFileTests` (GH-135364) (GH-136149)
https://github.com/python/cpython/commit/1e3466a1ae5bdcee42a3dfdbd8aaa17135a6ecc2 commit: 1e3466a1ae5bdcee42a3dfdbd8aaa17135a6ecc2 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-30T22:19:14Z summary: [3.13] gh-133982: Use implementation-specific `open` in `test_fileio.OtherFileTests` (GH-135364) (GH-136149) gh-133982: Use implementation-specific `open` in `test_fileio.OtherFileTests` (GH-135364) (cherry picked from commit 23caccf74ce2c8dc5d9c5eb6350d21ef20c6ea0b) Co-authored-by: Cody Maloney files: M Lib/test/test_fileio.py diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index 0611d1749f41c1..fdb36ed997d046 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -451,7 +451,7 @@ def testBytesOpen(self): try: f.write(b"abc") f.close() -with open(TESTFN_ASCII, "rb") as f: +with self.open(TESTFN_ASCII, "rb") as f: self.assertEqual(f.read(), b"abc") finally: os.unlink(TESTFN_ASCII) @@ -468,7 +468,7 @@ def testUtf8BytesOpen(self): try: f.write(b"abc") f.close() -with open(TESTFN_UNICODE, "rb") as f: +with self.open(TESTFN_UNICODE, "rb") as f: self.assertEqual(f.read(), b"abc") finally: os.unlink(TESTFN_UNICODE) @@ -552,13 +552,13 @@ def bug801631(): def testAppend(self): try: -f = open(TESTFN, 'wb') +f = self.FileIO(TESTFN, 'wb') f.write(b'spam') f.close() -f = open(TESTFN, 'ab') +f = self.FileIO(TESTFN, 'ab') f.write(b'eggs') f.close() -f = open(TESTFN, 'rb') +f = self.FileIO(TESTFN, 'rb') d = f.read() f.close() self.assertEqual(d, b'spameggs') @@ -594,6 +594,7 @@ def __setattr__(self, name, value): class COtherFileTests(OtherFileTests, unittest.TestCase): FileIO = _io.FileIO modulename = '_io' +open = _io.open @cpython_only def testInvalidFd_overflow(self): @@ -615,6 +616,7 @@ def test_open_code(self): class PyOtherFileTests(OtherFileTests, unittest.TestCase): FileIO = _pyio.FileIO modulename = '_pyio' +open = _pyio.open def test_open_code(self): # Check that the default behaviour of open_code matches ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-135110: Fix misleading `generator.close()` documentation (GH-135152) (GH-135986)
https://github.com/python/cpython/commit/a7246323a28a707e8dab9437b1c07ffbc0d5d5a0 commit: a7246323a28a707e8dab9437b1c07ffbc0d5d5a0 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-26T13:34:11Z summary: [3.13] gh-135110: Fix misleading `generator.close()` documentation (GH-135152) (GH-135986) gh-135110: Fix misleading `generator.close()` documentation (GH-135152) The documentation incorrectly stated that generator.close() 'raises' a GeneratorExit exception. This was misleading because the method doesn't raise the exception to the caller - it sends the exception internally to the generator and returns None. (cherry picked from commit 0d76dccc3b4376ba075a1737f58809e3d833) Co-authored-by: Connor Denihan <[email protected]> files: M Doc/howto/functional.rst M Doc/reference/expressions.rst diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst index 1f0608fb0fc53f..aff651ffc2b91a 100644 --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -602,7 +602,7 @@ generators: raise an exception inside the generator; the exception is raised by the ``yield`` expression where the generator's execution is paused. -* :meth:`~generator.close` raises a :exc:`GeneratorExit` exception inside the +* :meth:`~generator.close` sends a :exc:`GeneratorExit` exception to the generator to terminate the iteration. On receiving this exception, the generator's code must either raise :exc:`GeneratorExit` or :exc:`StopIteration`; catching the exception and doing anything else is diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 55bae3df25e495..d88134b0edbcad 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -627,8 +627,10 @@ is already executing raises a :exc:`ValueError` exception. .. method:: generator.close() - Raises a :exc:`GeneratorExit` at the point where the generator function was - paused. If the generator function catches the exception and returns a + Raises a :exc:`GeneratorExit` exception at the point where the generator + function was paused (equivalent to calling ``throw(GeneratorExit)``). + The exception is raised by the yield expression where the generator was paused. + If the generator function catches the exception and returns a value, this value is returned from :meth:`close`. If the generator function is already closed, or raises :exc:`GeneratorExit` (by not catching the exception), :meth:`close` returns :const:`None`. If the generator yields a ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-135110: Fix misleading `generator.close()` documentation (GH-135152) (GH-135985)
https://github.com/python/cpython/commit/ad6c90f5ba2f597d352f1c770a729eba917f131b commit: ad6c90f5ba2f597d352f1c770a729eba917f131b branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-26T13:34:33Z summary: [3.14] gh-135110: Fix misleading `generator.close()` documentation (GH-135152) (GH-135985) gh-135110: Fix misleading `generator.close()` documentation (GH-135152) The documentation incorrectly stated that generator.close() 'raises' a GeneratorExit exception. This was misleading because the method doesn't raise the exception to the caller - it sends the exception internally to the generator and returns None. (cherry picked from commit 0d76dccc3b4376ba075a1737f58809e3d833) Co-authored-by: Connor Denihan <[email protected]> files: M Doc/howto/functional.rst M Doc/reference/expressions.rst diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst index 1f0608fb0fc53f..aff651ffc2b91a 100644 --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -602,7 +602,7 @@ generators: raise an exception inside the generator; the exception is raised by the ``yield`` expression where the generator's execution is paused. -* :meth:`~generator.close` raises a :exc:`GeneratorExit` exception inside the +* :meth:`~generator.close` sends a :exc:`GeneratorExit` exception to the generator to terminate the iteration. On receiving this exception, the generator's code must either raise :exc:`GeneratorExit` or :exc:`StopIteration`; catching the exception and doing anything else is diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 17f39aaf5f57cd..24544a055c3ed2 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -625,8 +625,10 @@ is already executing raises a :exc:`ValueError` exception. .. method:: generator.close() - Raises a :exc:`GeneratorExit` at the point where the generator function was - paused. If the generator function catches the exception and returns a + Raises a :exc:`GeneratorExit` exception at the point where the generator + function was paused (equivalent to calling ``throw(GeneratorExit)``). + The exception is raised by the yield expression where the generator was paused. + If the generator function catches the exception and returns a value, this value is returned from :meth:`close`. If the generator function is already closed, or raises :exc:`GeneratorExit` (by not catching the exception), :meth:`close` returns :const:`None`. If the generator yields a ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] Docs: Fix duplicate word typos (GH-135958)
https://github.com/python/cpython/commit/34ce1920ca33c11ca2c379ed0ef30a91010bef4f commit: 34ce1920ca33c11ca2c379ed0ef30a91010bef4f branch: main author: Brian Schubert committer: ZeroIntensity date: 2025-06-26T20:00:19-04:00 summary: Docs: Fix duplicate word typos (GH-135958) files: M Doc/c-api/init.rst M Doc/c-api/long.rst M Doc/extending/newtypes_tutorial.rst M Doc/library/ctypes.rst M Doc/library/email.header.rst M Doc/library/exceptions.rst M Doc/library/faulthandler.rst M Doc/library/mmap.rst M Doc/library/pathlib.rst M Doc/library/socketserver.rst M Doc/library/threading.rst M Doc/using/cmdline.rst M Doc/whatsnew/3.13.rst diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 3106bf9808f254..41fd4ea14ef12f 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -1250,7 +1250,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`. .. c:function:: void PyInterpreterState_Clear(PyInterpreterState *interp) Reset all information in an interpreter state object. There must be - an :term:`attached thread state` for the the interpreter. + an :term:`attached thread state` for the interpreter. .. audit-event:: cpython.PyInterpreterState_Clear "" c.PyInterpreterState_Clear diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst index 25d9e62e387279..2d0bda76697e81 100644 --- a/Doc/c-api/long.rst +++ b/Doc/c-api/long.rst @@ -439,7 +439,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate. All *n_bytes* of the buffer are written: large buffers are padded with zeroes. - If the returned value is greater than than *n_bytes*, the value was + If the returned value is greater than *n_bytes*, the value was truncated: as many of the lowest bits of the value as could fit are written, and the higher bits are ignored. This matches the typical behavior of a C-style downcast. diff --git a/Doc/extending/newtypes_tutorial.rst b/Doc/extending/newtypes_tutorial.rst index f14690de4f86e8..3bbee33bd50698 100644 --- a/Doc/extending/newtypes_tutorial.rst +++ b/Doc/extending/newtypes_tutorial.rst @@ -277,7 +277,7 @@ be an instance of a subclass. The explicit cast to ``CustomObject *`` above is needed because we defined ``Custom_dealloc`` to take a ``PyObject *`` argument, as the ``tp_dealloc`` function pointer expects to receive a ``PyObject *`` argument. - By assigning to the the ``tp_dealloc`` slot of a type, we declare + By assigning to the ``tp_dealloc`` slot of a type, we declare that it can only be called with instances of our ``CustomObject`` class, so the cast to ``(CustomObject *)`` is safe. This is object-oriented polymorphism, in C! diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index e00fe9c8145f12..846cece3761858 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -2965,7 +2965,7 @@ fields, or any other data types containing pointer type fields. .. attribute:: is_anonymous True if this field is anonymous, that is, it contains nested sub-fields - that should be be merged into a containing structure or union. + that should be merged into a containing structure or union. .. _ctypes-arrays-pointers: diff --git a/Doc/library/email.header.rst b/Doc/library/email.header.rst index c3392a62b8ee79..f49885b8785235 100644 --- a/Doc/library/email.header.rst +++ b/Doc/library/email.header.rst @@ -206,7 +206,7 @@ The :mod:`email.header` module also provides the following convenient functions. .. note:: - This function exists for for backwards compatibility only. For + This function exists for backwards compatibility only. For new code, we recommend using :class:`email.headerregistry.HeaderRegistry`. @@ -225,5 +225,5 @@ The :mod:`email.header` module also provides the following convenient functions. .. note:: - This function exists for for backwards compatibility only, and is + This function exists for backwards compatibility only, and is not recommended for use in new code. diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index bb72032891ea98..9806ae80905ca0 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -1048,7 +1048,7 @@ their subgroups based on the types of the contained exceptions. subclasses that need a different constructor signature need to override that rather than :meth:`~object.__init__`. For example, the following defines an exception group subclass which accepts an exit_code and - and constructs the group's message from it. :: + constructs the group's message from it. :: class Errors(ExceptionGroup): def __new__(cls, errors, exit_code): diff --git a/Doc/library/faulthandler.rst b/Doc/library/faulthandler.rst index 5058b85bffb15c..1977f4d3ba3916 100644 --- a/Doc/library/faulthandler.rst +++ b/Doc/library/faulthandler.rst @@ -90,7 +90,7 @@ An error will be printed
[Python-checkins] [3.14] Docs: Fix duplicate word typos (GH-135958) (GH-136007)
https://github.com/python/cpython/commit/b99a417a6a068dc1f71f1c9f735f1ec0612e0031 commit: b99a417a6a068dc1f71f1c9f735f1ec0612e0031 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-27T00:05:53Z summary: [3.14] Docs: Fix duplicate word typos (GH-135958) (GH-136007) (cherry picked from commit 34ce1920ca33c11ca2c379ed0ef30a91010bef4f) Co-authored-by: Brian Schubert files: M Doc/c-api/init.rst M Doc/c-api/long.rst M Doc/extending/newtypes_tutorial.rst M Doc/library/ctypes.rst M Doc/library/email.header.rst M Doc/library/exceptions.rst M Doc/library/faulthandler.rst M Doc/library/mmap.rst M Doc/library/pathlib.rst M Doc/library/socketserver.rst M Doc/library/threading.rst M Doc/using/cmdline.rst M Doc/whatsnew/3.13.rst diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 4434eead7e56eb..dc96ed7f719fcf 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -1414,7 +1414,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`. .. c:function:: void PyInterpreterState_Clear(PyInterpreterState *interp) Reset all information in an interpreter state object. There must be - an :term:`attached thread state` for the the interpreter. + an :term:`attached thread state` for the interpreter. .. audit-event:: cpython.PyInterpreterState_Clear "" c.PyInterpreterState_Clear diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst index 25d9e62e387279..2d0bda76697e81 100644 --- a/Doc/c-api/long.rst +++ b/Doc/c-api/long.rst @@ -439,7 +439,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate. All *n_bytes* of the buffer are written: large buffers are padded with zeroes. - If the returned value is greater than than *n_bytes*, the value was + If the returned value is greater than *n_bytes*, the value was truncated: as many of the lowest bits of the value as could fit are written, and the higher bits are ignored. This matches the typical behavior of a C-style downcast. diff --git a/Doc/extending/newtypes_tutorial.rst b/Doc/extending/newtypes_tutorial.rst index f14690de4f86e8..3bbee33bd50698 100644 --- a/Doc/extending/newtypes_tutorial.rst +++ b/Doc/extending/newtypes_tutorial.rst @@ -277,7 +277,7 @@ be an instance of a subclass. The explicit cast to ``CustomObject *`` above is needed because we defined ``Custom_dealloc`` to take a ``PyObject *`` argument, as the ``tp_dealloc`` function pointer expects to receive a ``PyObject *`` argument. - By assigning to the the ``tp_dealloc`` slot of a type, we declare + By assigning to the ``tp_dealloc`` slot of a type, we declare that it can only be called with instances of our ``CustomObject`` class, so the cast to ``(CustomObject *)`` is safe. This is object-oriented polymorphism, in C! diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index e00fe9c8145f12..846cece3761858 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -2965,7 +2965,7 @@ fields, or any other data types containing pointer type fields. .. attribute:: is_anonymous True if this field is anonymous, that is, it contains nested sub-fields - that should be be merged into a containing structure or union. + that should be merged into a containing structure or union. .. _ctypes-arrays-pointers: diff --git a/Doc/library/email.header.rst b/Doc/library/email.header.rst index c3392a62b8ee79..f49885b8785235 100644 --- a/Doc/library/email.header.rst +++ b/Doc/library/email.header.rst @@ -206,7 +206,7 @@ The :mod:`email.header` module also provides the following convenient functions. .. note:: - This function exists for for backwards compatibility only. For + This function exists for backwards compatibility only. For new code, we recommend using :class:`email.headerregistry.HeaderRegistry`. @@ -225,5 +225,5 @@ The :mod:`email.header` module also provides the following convenient functions. .. note:: - This function exists for for backwards compatibility only, and is + This function exists for backwards compatibility only, and is not recommended for use in new code. diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index bb72032891ea98..9806ae80905ca0 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -1048,7 +1048,7 @@ their subgroups based on the types of the contained exceptions. subclasses that need a different constructor signature need to override that rather than :meth:`~object.__init__`. For example, the following defines an exception group subclass which accepts an exit_code and - and constructs the group's message from it. :: + constructs the group's message from it. :: class Errors(ExceptionGroup): def __new__(cls, errors, exit_code): diff --git a/Doc/library/faulthandler.rst b/Doc/libr
[Python-checkins] [3.13] Docs: Fix duplicate word typos (GH-135958) (GH-136008)
https://github.com/python/cpython/commit/cee66dd2a0639c8fcd4f2fcaf307e4bc9631950d commit: cee66dd2a0639c8fcd4f2fcaf307e4bc9631950d branch: 3.13 author: Brian Schubert committer: ZeroIntensity date: 2025-06-26T20:13:46-04:00 summary: [3.13] Docs: Fix duplicate word typos (GH-135958) (GH-136008) (cherry picked from commit 34ce1920ca33c11ca2c379ed0ef30a91010bef4f) files: M Doc/c-api/long.rst M Doc/library/email.header.rst M Doc/library/exceptions.rst M Doc/library/mmap.rst M Doc/library/socketserver.rst M Doc/whatsnew/3.13.rst diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst index 1f899b1df196f2..2d36dfe80362f3 100644 --- a/Doc/c-api/long.rst +++ b/Doc/c-api/long.rst @@ -382,7 +382,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate. All *n_bytes* of the buffer are written: large buffers are padded with zeroes. - If the returned value is greater than than *n_bytes*, the value was + If the returned value is greater than *n_bytes*, the value was truncated: as many of the lowest bits of the value as could fit are written, and the higher bits are ignored. This matches the typical behavior of a C-style downcast. diff --git a/Doc/library/email.header.rst b/Doc/library/email.header.rst index c3392a62b8ee79..f49885b8785235 100644 --- a/Doc/library/email.header.rst +++ b/Doc/library/email.header.rst @@ -206,7 +206,7 @@ The :mod:`email.header` module also provides the following convenient functions. .. note:: - This function exists for for backwards compatibility only. For + This function exists for backwards compatibility only. For new code, we recommend using :class:`email.headerregistry.HeaderRegistry`. @@ -225,5 +225,5 @@ The :mod:`email.header` module also provides the following convenient functions. .. note:: - This function exists for for backwards compatibility only, and is + This function exists for backwards compatibility only, and is not recommended for use in new code. diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index cf8b95129d31d3..9b6e532a4833cf 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -1038,7 +1038,7 @@ their subgroups based on the types of the contained exceptions. subclasses that need a different constructor signature need to override that rather than :meth:`~object.__init__`. For example, the following defines an exception group subclass which accepts an exit_code and - and constructs the group's message from it. :: + constructs the group's message from it. :: class Errors(ExceptionGroup): def __new__(cls, errors, exit_code): diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst index 4e20c07331a220..8fca79b23e4e15 100644 --- a/Doc/library/mmap.rst +++ b/Doc/library/mmap.rst @@ -269,7 +269,7 @@ To map anonymous memory, -1 should be passed as the fileno along with the length Resizing a map created with *access* of :const:`ACCESS_READ` or :const:`ACCESS_COPY`, will raise a :exc:`TypeError` exception. - Resizing a map created with with *trackfd* set to ``False``, + Resizing a map created with *trackfd* set to ``False``, will raise a :exc:`ValueError` exception. **On Windows**: Resizing the map will raise an :exc:`OSError` if there are other diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst index 72e9a2e10804a8..8e699be8c83631 100644 --- a/Doc/library/socketserver.rst +++ b/Doc/library/socketserver.rst @@ -535,7 +535,7 @@ objects that simplify communication by providing the standard file interface):: The difference is that the ``readline()`` call in the second handler will call ``recv()`` multiple times until it encounters a newline character, while the -the first handler had to use a ``recv()`` loop to accumulate data until a +first handler had to use a ``recv()`` loop to accumulate data until a newline itself. If it had just used a single ``recv()`` without the loop it would just have returned what has been received so far from the client. TCP is stream based: data arrives in the order it was sent, but there no diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index bd3716aa11ee4a..1b969b3fd2ec54 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -2005,7 +2005,7 @@ New Deprecations (Contributed by Alex Waygood in :gh:`105566` and :gh:`105570`.) * Deprecate the :func:`typing.no_type_check_decorator` decorator function, -to be removed in in Python 3.15. +to be removed in Python 3.15. After eight years in the :mod:`typing` module, it has yet to be supported by any major type checker. (Contributed by Alex Waygood in :gh:`106309`.) ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//li
[Python-checkins] gh-76595: Add note on `PyCapsule_Import` behavior (GH-134022)
https://github.com/python/cpython/commit/579acf45629fa0b7787ec78fa4049fc6a6388b71 commit: 579acf45629fa0b7787ec78fa4049fc6a6388b71 branch: main author: Nicolas Trangez committer: ZeroIntensity date: 2025-06-28T09:01:41-04:00 summary: gh-76595: Add note on `PyCapsule_Import` behavior (GH-134022) files: M Doc/c-api/capsule.rst diff --git a/Doc/c-api/capsule.rst b/Doc/c-api/capsule.rst index cdb8aa33e9fd32..64dc4f5275b512 100644 --- a/Doc/c-api/capsule.rst +++ b/Doc/c-api/capsule.rst @@ -105,9 +105,19 @@ Refer to :ref:`using-capsules` for more information on using these objects. ``module.attribute``. The *name* stored in the capsule must match this string exactly. + This function splits *name* on the ``.`` character, and imports the first + element. It then processes further elements using attribute lookups. + Return the capsule's internal *pointer* on success. On failure, set an exception and return ``NULL``. + .. note:: + + If *name* points to an attribute of some submodule or subpackage, this + submodule or subpackage must be previously imported using other means + (for example, by using :c:func:`PyImport_ImportModule`) for the + attribute lookups to succeed. + .. versionchanged:: 3.3 *no_block* has no effect anymore. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-76595: Add note on `PyCapsule_Import` behavior (GH-134022) (GH-136075)
https://github.com/python/cpython/commit/a2f1d22a362cccab59691fa4fa2b202475480b04 commit: a2f1d22a362cccab59691fa4fa2b202475480b04 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-28T13:07:42Z summary: [3.13] gh-76595: Add note on `PyCapsule_Import` behavior (GH-134022) (GH-136075) gh-76595: Add note on `PyCapsule_Import` behavior (GH-134022) (cherry picked from commit 579acf45629fa0b7787ec78fa4049fc6a6388b71) Co-authored-by: Nicolas Trangez files: M Doc/c-api/capsule.rst diff --git a/Doc/c-api/capsule.rst b/Doc/c-api/capsule.rst index cdb8aa33e9fd32..64dc4f5275b512 100644 --- a/Doc/c-api/capsule.rst +++ b/Doc/c-api/capsule.rst @@ -105,9 +105,19 @@ Refer to :ref:`using-capsules` for more information on using these objects. ``module.attribute``. The *name* stored in the capsule must match this string exactly. + This function splits *name* on the ``.`` character, and imports the first + element. It then processes further elements using attribute lookups. + Return the capsule's internal *pointer* on success. On failure, set an exception and return ``NULL``. + .. note:: + + If *name* points to an attribute of some submodule or subpackage, this + submodule or subpackage must be previously imported using other means + (for example, by using :c:func:`PyImport_ImportModule`) for the + attribute lookups to succeed. + .. versionchanged:: 3.3 *no_block* has no effect anymore. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-76595: Add note on `PyCapsule_Import` behavior (GH-134022) (GH-136074)
https://github.com/python/cpython/commit/42e13b8f8a6823a3dcd426a0ad6dcf3f080c7469 commit: 42e13b8f8a6823a3dcd426a0ad6dcf3f080c7469 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-28T13:08:15Z summary: [3.14] gh-76595: Add note on `PyCapsule_Import` behavior (GH-134022) (GH-136074) gh-76595: Add note on `PyCapsule_Import` behavior (GH-134022) (cherry picked from commit 579acf45629fa0b7787ec78fa4049fc6a6388b71) Co-authored-by: Nicolas Trangez files: M Doc/c-api/capsule.rst diff --git a/Doc/c-api/capsule.rst b/Doc/c-api/capsule.rst index cdb8aa33e9fd32..64dc4f5275b512 100644 --- a/Doc/c-api/capsule.rst +++ b/Doc/c-api/capsule.rst @@ -105,9 +105,19 @@ Refer to :ref:`using-capsules` for more information on using these objects. ``module.attribute``. The *name* stored in the capsule must match this string exactly. + This function splits *name* on the ``.`` character, and imports the first + element. It then processes further elements using attribute lookups. + Return the capsule's internal *pointer* on success. On failure, set an exception and return ``NULL``. + .. note:: + + If *name* points to an attribute of some submodule or subpackage, this + submodule or subpackage must be previously imported using other means + (for example, by using :c:func:`PyImport_ImportModule`) for the + attribute lookups to succeed. + .. versionchanged:: 3.3 *no_block* has no effect anymore. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-127604: Docs: Include a C stack in the `faulthandler` example (GH-136081) (GH-136102)
https://github.com/python/cpython/commit/231d8012225ed5c33f6e4e60573e53fece65fa1e commit: 231d8012225ed5c33f6e4e60573e53fece65fa1e branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-29T15:05:40Z summary: [3.14] gh-127604: Docs: Include a C stack in the `faulthandler` example (GH-136081) (GH-136102) * gh-127604: Docs: Include a C stack in the `faulthandler` example (GH-136081) (cherry picked from commit 39478479146f1f4188119a0e7ffdcdc7b6016bd7) Co-authored-by: Peter Bierma files: M Doc/library/faulthandler.rst diff --git a/Doc/library/faulthandler.rst b/Doc/library/faulthandler.rst index 1977f4d3ba3916..f81e6bf5810f86 100644 --- a/Doc/library/faulthandler.rst +++ b/Doc/library/faulthandler.rst @@ -228,6 +228,41 @@ handler: Fatal Python error: Segmentation fault Current thread 0x7fb899f39700 (most recent call first): - File "/home/python/cpython/Lib/ctypes/__init__.py", line 486 in string_at + File "/opt/python/Lib/ctypes/__init__.py", line 486 in string_at File "", line 1 in + +Current thread's C stack trace (most recent call first): + Binary file "/opt/python/python", at _Py_DumpStack+0x42 [0x5b27f7d7147e] + Binary file "/opt/python/python", at +0x32dcbd [0x5b27f7d85cbd] + Binary file "/opt/python/python", at +0x32df8a [0x5b27f7d85f8a] + Binary file "/usr/lib/libc.so.6", at +0x3def0 [0x77b73226bef0] + Binary file "/usr/lib/libc.so.6", at +0x17ef9c [0x77b7323acf9c] + Binary file "/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-x86_64-linux-gnu.so", at +0xcdf6 [0x77b7315dddf6] + Binary file "/usr/lib/libffi.so.8", at +0x7976 [0x77b73158f976] + Binary file "/usr/lib/libffi.so.8", at +0x413c [0x77b73158c13c] + Binary file "/usr/lib/libffi.so.8", at ffi_call+0x12e [0x77b73158ef0e] + Binary file "/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-x86_64-linux-gnu.so", at +0x15a33 [0x77b7315e6a33] + Binary file "/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-x86_64-linux-gnu.so", at +0x164fa [0x77b7315e74fa] + Binary file "/opt/python/build/lib.linux-x86_64-3.14/_ctypes.cpython-314d-x86_64-linux-gnu.so", at +0xc624 [0x77b7315dd624] + Binary file "/opt/python/python", at _PyObject_MakeTpCall+0xce [0x5b27f7b73883] + Binary file "/opt/python/python", at +0x11bab6 [0x5b27f7b73ab6] + Binary file "/opt/python/python", at PyObject_Vectorcall+0x23 [0x5b27f7b73b04] + Binary file "/opt/python/python", at _PyEval_EvalFrameDefault+0x490c [0x5b27f7cbb302] + Binary file "/opt/python/python", at +0x2818e6 [0x5b27f7cd98e6] + Binary file "/opt/python/python", at +0x281aab [0x5b27f7cd9aab] + Binary file "/opt/python/python", at PyEval_EvalCode+0xc5 [0x5b27f7cd9ba3] + Binary file "/opt/python/python", at +0x255957 [0x5b27f7cad957] + Binary file "/opt/python/python", at +0x255ab4 [0x5b27f7cadab4] + Binary file "/opt/python/python", at _PyEval_EvalFrameDefault+0x6c3e [0x5b27f7cbd634] + Binary file "/opt/python/python", at +0x2818e6 [0x5b27f7cd98e6] + Binary file "/opt/python/python", at +0x281aab [0x5b27f7cd9aab] + Binary file "/opt/python/python", at +0x11b6e1 [0x5b27f7b736e1] + Binary file "/opt/python/python", at +0x11d348 [0x5b27f7b75348] + Binary file "/opt/python/python", at +0x11d626 [0x5b27f7b75626] + Binary file "/opt/python/python", at PyObject_Call+0x20 [0x5b27f7b7565e] + Binary file "/opt/python/python", at +0x32a67a [0x5b27f7d8267a] + Binary file "/opt/python/python", at +0x32a7f8 [0x5b27f7d827f8] + Binary file "/opt/python/python", at +0x32ac1b [0x5b27f7d82c1b] + Binary file "/opt/python/python", at Py_RunMain+0x31 [0x5b27f7d82ebe] + Segmentation fault ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-127604: Docs: Include a C stack in the `faulthandler` example (GH-136081)
https://github.com/python/cpython/commit/39478479146f1f4188119a0e7ffdcdc7b6016bd7 commit: 39478479146f1f4188119a0e7ffdcdc7b6016bd7 branch: main author: Peter Bierma committer: ZeroIntensity date: 2025-06-29T10:58:26-04:00 summary: gh-127604: Docs: Include a C stack in the `faulthandler` example (GH-136081) files: M Doc/library/faulthandler.rst diff --git a/Doc/library/faulthandler.rst b/Doc/library/faulthandler.rst index 1977f4d3ba3916..677966a8b2eaab 100644 --- a/Doc/library/faulthandler.rst +++ b/Doc/library/faulthandler.rst @@ -228,6 +228,41 @@ handler: Fatal Python error: Segmentation fault Current thread 0x7fb899f39700 (most recent call first): - File "/home/python/cpython/Lib/ctypes/__init__.py", line 486 in string_at + File "/opt/python/Lib/ctypes/__init__.py", line 486 in string_at File "", line 1 in + +Current thread's C stack trace (most recent call first): + Binary file "/opt/python/python", at _Py_DumpStack+0x42 [0x5b27f7d7147e] + Binary file "/opt/python/python", at +0x32dcbd [0x5b27f7d85cbd] + Binary file "/opt/python/python", at +0x32df8a [0x5b27f7d85f8a] + Binary file "/usr/lib/libc.so.6", at +0x3def0 [0x77b73226bef0] + Binary file "/usr/lib/libc.so.6", at +0x17ef9c [0x77b7323acf9c] + Binary file "/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-x86_64-linux-gnu.so", at +0xcdf6 [0x77b7315dddf6] + Binary file "/usr/lib/libffi.so.8", at +0x7976 [0x77b73158f976] + Binary file "/usr/lib/libffi.so.8", at +0x413c [0x77b73158c13c] + Binary file "/usr/lib/libffi.so.8", at ffi_call+0x12e [0x77b73158ef0e] + Binary file "/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-x86_64-linux-gnu.so", at +0x15a33 [0x77b7315e6a33] + Binary file "/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-x86_64-linux-gnu.so", at +0x164fa [0x77b7315e74fa] + Binary file "/opt/python/build/lib.linux-x86_64-3.15/_ctypes.cpython-315d-x86_64-linux-gnu.so", at +0xc624 [0x77b7315dd624] + Binary file "/opt/python/python", at _PyObject_MakeTpCall+0xce [0x5b27f7b73883] + Binary file "/opt/python/python", at +0x11bab6 [0x5b27f7b73ab6] + Binary file "/opt/python/python", at PyObject_Vectorcall+0x23 [0x5b27f7b73b04] + Binary file "/opt/python/python", at _PyEval_EvalFrameDefault+0x490c [0x5b27f7cbb302] + Binary file "/opt/python/python", at +0x2818e6 [0x5b27f7cd98e6] + Binary file "/opt/python/python", at +0x281aab [0x5b27f7cd9aab] + Binary file "/opt/python/python", at PyEval_EvalCode+0xc5 [0x5b27f7cd9ba3] + Binary file "/opt/python/python", at +0x255957 [0x5b27f7cad957] + Binary file "/opt/python/python", at +0x255ab4 [0x5b27f7cadab4] + Binary file "/opt/python/python", at _PyEval_EvalFrameDefault+0x6c3e [0x5b27f7cbd634] + Binary file "/opt/python/python", at +0x2818e6 [0x5b27f7cd98e6] + Binary file "/opt/python/python", at +0x281aab [0x5b27f7cd9aab] + Binary file "/opt/python/python", at +0x11b6e1 [0x5b27f7b736e1] + Binary file "/opt/python/python", at +0x11d348 [0x5b27f7b75348] + Binary file "/opt/python/python", at +0x11d626 [0x5b27f7b75626] + Binary file "/opt/python/python", at PyObject_Call+0x20 [0x5b27f7b7565e] + Binary file "/opt/python/python", at +0x32a67a [0x5b27f7d8267a] + Binary file "/opt/python/python", at +0x32a7f8 [0x5b27f7d827f8] + Binary file "/opt/python/python", at +0x32ac1b [0x5b27f7d82c1b] + Binary file "/opt/python/python", at Py_RunMain+0x31 [0x5b27f7d82ebe] + Segmentation fault ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-136421: Load `_datetime` static types during interpreter initialization (GH-136583) (GH-136943)
https://github.com/python/cpython/commit/ecd97caaf5923764d22f6bd29339b8416c0c1917 commit: ecd97caaf5923764d22f6bd29339b8416c0c1917 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-21T19:23:05-04:00 summary: [3.14] gh-136421: Load `_datetime` static types during interpreter initialization (GH-136583) (GH-136943) gh-136421: Load `_datetime` static types during interpreter initialization (GH-136583) `_datetime` is a special module, because it's the only non-builtin C extension that contains static types. As such, it would initialize static types in the module's execution function, which can run concurrently. Since static type initialization is not thread-safe, this caused crashes. This fixes it by moving the initialization of `_datetime`'s static types to interpreter startup (where all other static types are initialized), which is already properly protected through other locks. (cherry picked from commit a10960699a2b3e4e62896331c4f9cfd162ebf440) Co-authored-by: Peter Bierma files: A Misc/NEWS.d/next/Core_and_Builtins/2025-07-12-09-59-14.gh-issue-136421.ZD1rNj.rst M Include/internal/pycore_pylifecycle.h M Lib/test/datetimetester.py M Modules/Setup.bootstrap.in M Modules/Setup.stdlib.in M Modules/_datetimemodule.c M PCbuild/_freeze_module.vcxproj M Python/pylifecycle.c diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h index 6e89ca33e4208c..8faf7a4d403f84 100644 --- a/Include/internal/pycore_pylifecycle.h +++ b/Include/internal/pycore_pylifecycle.h @@ -41,6 +41,7 @@ extern PyStatus _Py_HashRandomization_Init(const PyConfig *); extern PyStatus _PyGC_Init(PyInterpreterState *interp); extern PyStatus _PyAtExit_Init(PyInterpreterState *interp); +extern PyStatus _PyDateTime_InitTypes(PyInterpreterState *interp); /* Various internal finalizers */ diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index 1b551254f86c32..1c1cbd03d02ccc 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -7275,6 +7275,34 @@ def test_update_type_cache(self): """) script_helper.assert_python_ok('-c', script) +def test_concurrent_initialization_subinterpreter(self): +# gh-136421: Concurrent initialization of _datetime across multiple +# interpreters wasn't thread-safe due to its static types. + +# Run in a subprocess to ensure we get a clean version of _datetime +script = """if True: +from concurrent.futures import InterpreterPoolExecutor + +def func(): +import _datetime +print('a', end='') + +with InterpreterPoolExecutor() as executor: +for _ in range(8): +executor.submit(func) +""" +rc, out, err = script_helper.assert_python_ok("-c", script) +self.assertEqual(rc, 0) +self.assertEqual(out, b"a" * 8) +self.assertEqual(err, b"") + +# Now test against concurrent reinitialization +script = "import _datetime\n" + script +rc, out, err = script_helper.assert_python_ok("-c", script) +self.assertEqual(rc, 0) +self.assertEqual(out, b"a" * 8) +self.assertEqual(err, b"") + def load_tests(loader, standard_tests, pattern): standard_tests.addTest(ZoneInfoCompleteTest()) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-07-12-09-59-14.gh-issue-136421.ZD1rNj.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-07-12-09-59-14.gh-issue-136421.ZD1rNj.rst new file mode 100644 index 00..dcc73267a78546 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-07-12-09-59-14.gh-issue-136421.ZD1rNj.rst @@ -0,0 +1 @@ +Fix crash when initializing :mod:`datetime` concurrently. diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in index 2b2e8cb3e3cacd..65a1fefe72e92e 100644 --- a/Modules/Setup.bootstrap.in +++ b/Modules/Setup.bootstrap.in @@ -12,6 +12,8 @@ posix posixmodule.c _signal signalmodule.c _tracemalloc _tracemalloc.c _suggestions _suggestions.c +# needs libm and on some platforms librt +_datetime _datetimemodule.c # modules used by importlib, deepfreeze, freeze, runpy, and sysconfig _codecs _codecsmodule.c diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index 3a38a60a152e8c..905ea4aa2e57a9 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -56,9 +56,6 @@ @MODULE_CMATH_TRUE@cmath cmathmodule.c @MODULE__STATISTICS_TRUE@_statistics _statisticsmodule.c -# needs libm and on some platforms librt -@MODULE__DATETIME_TRUE@_datetime _datetimemodule.c - # _decimal uses libmpdec # either static libmpdec.a from Modules/_decimal/libmpdec or libmpdec.so # with ./configure --with-system-libmpdec diff --git a/Modul
[Python-checkins] gh-136492: Add `FrameLocalsProxyType` to `types` (GH-136546)
https://github.com/python/cpython/commit/8f59fbb082a4d64619aeededc47b3b45212d2341 commit: 8f59fbb082a4d64619aeededc47b3b45212d2341 branch: main author: Peter Bierma committer: ZeroIntensity date: 2025-07-20T20:49:00+02:00 summary: gh-136492: Add `FrameLocalsProxyType` to `types` (GH-136546) Co-authored-by: Jelle Zijlstra Co-authored-by: Adam Turner <[email protected]> files: A Misc/NEWS.d/next/Library/2025-07-11-10-23-44.gh-issue-136492.BVi5h0.rst M Doc/library/types.rst M Doc/whatsnew/3.15.rst M Lib/test/test_inspect/test_inspect.py M Lib/test/test_types.py M Lib/types.py M Modules/_typesmodule.c M Objects/frameobject.c diff --git a/Doc/library/types.rst b/Doc/library/types.rst index 2bedd7fdd3c8c8..207024a7619902 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -333,6 +333,16 @@ Standard names are defined for the following types: :attr:`tb.tb_frame ` if ``tb`` is a traceback object. +.. data:: FrameLocalsProxyType + + The type of frame locals proxy objects, as found on the + :attr:`frame.f_locals` attribute. + + .. versionadded:: next + + .. seealso:: :pep:`667` + + .. data:: GetSetDescriptorType The type of objects defined in extension modules with ``PyGetSetDef``, such diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 7e47fa263d9a5e..4d4fb77ad4f030 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -312,6 +312,15 @@ tarfile and :cve:`2025-4435`.) +types +-- + +* Expose the write-through :func:`locals` proxy type + as :data:`types.FrameLocalsProxyType`. + This represents the type of the :attr:`frame.f_locals` attribute, + as described in :pep:`667`. + + unittest diff --git a/Lib/test/test_inspect/test_inspect.py b/Lib/test/test_inspect/test_inspect.py index 4f3983d83c7c06..30e01b8cd87a75 100644 --- a/Lib/test/test_inspect/test_inspect.py +++ b/Lib/test/test_inspect/test_inspect.py @@ -5786,6 +5786,7 @@ def test_types_module_has_signatures(self): 'AsyncGeneratorType': {'athrow'}, 'CoroutineType': {'throw'}, 'GeneratorType': {'throw'}, +'FrameLocalsProxyType': {'setdefault', 'pop', 'get'}, } self._test_module_has_signatures(types, unsupported_signature=unsupported_signature, diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index fccdcc975e6c43..9b0ae709d7968d 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -53,6 +53,7 @@ def test_names(self): 'AsyncGeneratorType', 'BuiltinFunctionType', 'BuiltinMethodType', 'CapsuleType', 'CellType', 'ClassMethodDescriptorType', 'CodeType', 'CoroutineType', 'EllipsisType', 'FrameType', 'FunctionType', +'FrameLocalsProxyType', 'GeneratorType', 'GenericAlias', 'GetSetDescriptorType', 'LambdaType', 'MappingProxyType', 'MemberDescriptorType', 'MethodDescriptorType', 'MethodType', 'MethodWrapperType', @@ -711,6 +712,16 @@ def call(part): """ assert_python_ok("-c", code) +def test_frame_locals_proxy_type(self): +self.assertIsInstance(types.FrameLocalsProxyType, type) +self.assertIsInstance(types.FrameLocalsProxyType.__doc__, str) +self.assertEqual(types.FrameLocalsProxyType.__module__, 'builtins') +self.assertEqual(types.FrameLocalsProxyType.__name__, 'FrameLocalsProxy') + +frame = inspect.currentframe() +self.assertIsNotNone(frame) +self.assertIsInstance(frame.f_locals, types.FrameLocalsProxyType) + class UnionTests(unittest.TestCase): diff --git a/Lib/types.py b/Lib/types.py index cf0549315a7814..f96c75b46daba7 100644 --- a/Lib/types.py +++ b/Lib/types.py @@ -58,7 +58,10 @@ def _m(self): pass raise TypeError except TypeError as exc: TracebackType = type(exc.__traceback__) -FrameType = type(exc.__traceback__.tb_frame) + +_f = (lambda: sys._getframe())() +FrameType = type(_f) +FrameLocalsProxyType = type(_f.f_locals) GetSetDescriptorType = type(FunctionType.__code__) MemberDescriptorType = type(FunctionType.__globals__) diff --git a/Misc/NEWS.d/next/Library/2025-07-11-10-23-44.gh-issue-136492.BVi5h0.rst b/Misc/NEWS.d/next/Library/2025-07-11-10-23-44.gh-issue-136492.BVi5h0.rst new file mode 100644 index 00..7ab5b068a7f691 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-07-11-10-23-44.gh-issue-136492.BVi5h0.rst @@ -0,0 +1 @@ +Expose :pep:`667`'s :data:`~types.FrameLocalsProxyType` in the :mod:`types` module. di
[Python-checkins] gh-136421: Load `_datetime` static types during interpreter initialization (GH-136583)
https://github.com/python/cpython/commit/a10960699a2b3e4e62896331c4f9cfd162ebf440
commit: a10960699a2b3e4e62896331c4f9cfd162ebf440
branch: main
author: Peter Bierma
committer: ZeroIntensity
date: 2025-07-21T13:47:26-04:00
summary:
gh-136421: Load `_datetime` static types during interpreter initialization
(GH-136583)
`_datetime` is a special module, because it's the only non-builtin C extension
that contains static types. As such, it would initialize static types in the
module's execution function, which can run concurrently. Since static type
initialization is not thread-safe, this caused crashes. This fixes it by moving
the initialization of `_datetime`'s static types to interpreter startup (where
all other static types are initialized), which is already properly protected
through other locks.
files:
A
Misc/NEWS.d/next/Core_and_Builtins/2025-07-12-09-59-14.gh-issue-136421.ZD1rNj.rst
M Include/internal/pycore_pylifecycle.h
M Lib/test/datetimetester.py
M Modules/Setup.bootstrap.in
M Modules/Setup.stdlib.in
M Modules/_datetimemodule.c
M PCbuild/_freeze_module.vcxproj
M Python/pylifecycle.c
diff --git a/Include/internal/pycore_pylifecycle.h
b/Include/internal/pycore_pylifecycle.h
index 6e89ca33e4208c..8faf7a4d403f84 100644
--- a/Include/internal/pycore_pylifecycle.h
+++ b/Include/internal/pycore_pylifecycle.h
@@ -41,6 +41,7 @@ extern PyStatus _Py_HashRandomization_Init(const PyConfig *);
extern PyStatus _PyGC_Init(PyInterpreterState *interp);
extern PyStatus _PyAtExit_Init(PyInterpreterState *interp);
+extern PyStatus _PyDateTime_InitTypes(PyInterpreterState *interp);
/* Various internal finalizers */
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index 93b3382b9c654e..3bd3a866570042 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -7295,6 +7295,34 @@ def test_update_type_cache(self):
""")
script_helper.assert_python_ok('-c', script)
+def test_concurrent_initialization_subinterpreter(self):
+# gh-136421: Concurrent initialization of _datetime across multiple
+# interpreters wasn't thread-safe due to its static types.
+
+# Run in a subprocess to ensure we get a clean version of _datetime
+script = """if True:
+from concurrent.futures import InterpreterPoolExecutor
+
+def func():
+import _datetime
+print('a', end='')
+
+with InterpreterPoolExecutor() as executor:
+for _ in range(8):
+executor.submit(func)
+"""
+rc, out, err = script_helper.assert_python_ok("-c", script)
+self.assertEqual(rc, 0)
+self.assertEqual(out, b"a" * 8)
+self.assertEqual(err, b"")
+
+# Now test against concurrent reinitialization
+script = "import _datetime\n" + script
+rc, out, err = script_helper.assert_python_ok("-c", script)
+self.assertEqual(rc, 0)
+self.assertEqual(out, b"a" * 8)
+self.assertEqual(err, b"")
+
def load_tests(loader, standard_tests, pattern):
standard_tests.addTest(ZoneInfoCompleteTest())
diff --git
a/Misc/NEWS.d/next/Core_and_Builtins/2025-07-12-09-59-14.gh-issue-136421.ZD1rNj.rst
b/Misc/NEWS.d/next/Core_and_Builtins/2025-07-12-09-59-14.gh-issue-136421.ZD1rNj.rst
new file mode 100644
index 00..dcc73267a78546
--- /dev/null
+++
b/Misc/NEWS.d/next/Core_and_Builtins/2025-07-12-09-59-14.gh-issue-136421.ZD1rNj.rst
@@ -0,0 +1 @@
+Fix crash when initializing :mod:`datetime` concurrently.
diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in
index 2b2e8cb3e3cacd..65a1fefe72e92e 100644
--- a/Modules/Setup.bootstrap.in
+++ b/Modules/Setup.bootstrap.in
@@ -12,6 +12,8 @@ posix posixmodule.c
_signal signalmodule.c
_tracemalloc _tracemalloc.c
_suggestions _suggestions.c
+# needs libm and on some platforms librt
+_datetime _datetimemodule.c
# modules used by importlib, deepfreeze, freeze, runpy, and sysconfig
_codecs _codecsmodule.c
diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in
index 86c8eb27c0a6c7..7f4c4a806737ac 100644
--- a/Modules/Setup.stdlib.in
+++ b/Modules/Setup.stdlib.in
@@ -55,9 +55,6 @@
@MODULE_CMATH_TRUE@cmath cmathmodule.c
@MODULE__STATISTICS_TRUE@_statistics _statisticsmodule.c
-# needs libm and on some platforms librt
-@MODULE__DATETIME_TRUE@_datetime _datetimemodule.c
-
# _decimal uses libmpdec
# either static libmpdec.a from Modules/_decimal/libmpdec or libmpdec.so
# with ./configure --with-system-libmpdec
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 7a6426593d021f..01039dfeec0719 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -14,6 +14,7 @@
#include "pycore_object.h"// _PyObject_Init()
#include "pyco
[Python-checkins] [3.14] Docs: Emphasize parameter name in `pkgutil.iter_importers` (GH-135597) (GH-135710)
https://github.com/python/cpython/commit/250bb7fffd0b7270064505a3acaa025a268985ce commit: 250bb7fffd0b7270064505a3acaa025a268985ce branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-19T13:02:22Z summary: [3.14] Docs: Emphasize parameter name in `pkgutil.iter_importers` (GH-135597) (GH-135710) Docs: Emphasize parameter name in `pkgutil.iter_importers` (GH-135597) (cherry picked from commit ff639af8eee11e7ca0b2724bc10652a00e5d) Co-authored-by: Rafael Fontenelle files: M Doc/library/pkgutil.rst diff --git a/Doc/library/pkgutil.rst b/Doc/library/pkgutil.rst index 20b8f6bcf19117..47d24b6f7d06bb 100644 --- a/Doc/library/pkgutil.rst +++ b/Doc/library/pkgutil.rst @@ -69,8 +69,8 @@ support. Yield :term:`finder` objects for the given module name. - If fullname contains a ``'.'``, the finders will be for the package - containing fullname, otherwise they will be all registered top level + If *fullname* contains a ``'.'``, the finders will be for the package + containing *fullname*, otherwise they will be all registered top level finders (i.e. those on both :data:`sys.meta_path` and :data:`sys.path_hooks`). If the named module is in a package, that package is imported as a side ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] Docs: Emphasize parameter name in `pkgutil.iter_importers` (GH-135597) (GH-135711)
https://github.com/python/cpython/commit/af48f39a440a5c23d89508c038da5d560e74fe48 commit: af48f39a440a5c23d89508c038da5d560e74fe48 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-19T13:04:46Z summary: [3.13] Docs: Emphasize parameter name in `pkgutil.iter_importers` (GH-135597) (GH-135711) Docs: Emphasize parameter name in `pkgutil.iter_importers` (GH-135597) (cherry picked from commit ff639af8eee11e7ca0b2724bc10652a00e5d) Co-authored-by: Rafael Fontenelle files: M Doc/library/pkgutil.rst diff --git a/Doc/library/pkgutil.rst b/Doc/library/pkgutil.rst index 4a39d53a5f1440..b17a317244da9e 100644 --- a/Doc/library/pkgutil.rst +++ b/Doc/library/pkgutil.rst @@ -109,8 +109,8 @@ support. Yield :term:`finder` objects for the given module name. - If fullname contains a ``'.'``, the finders will be for the package - containing fullname, otherwise they will be all registered top level + If *fullname* contains a ``'.'``, the finders will be for the package + containing *fullname*, otherwise they will be all registered top level finders (i.e. those on both :data:`sys.meta_path` and :data:`sys.path_hooks`). If the named module is in a package, that package is imported as a side ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] Docs: Add missing lines between regex and text (GH-134505)
https://github.com/python/cpython/commit/754190287ece5a2e66684161aadafb18f5f44868 commit: 754190287ece5a2e66684161aadafb18f5f44868 branch: main author: Rafael Fontenelle committer: ZeroIntensity date: 2025-06-19T11:01:29-04:00 summary: Docs: Add missing lines between regex and text (GH-134505) files: M Doc/howto/regex.rst diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst index e543f6d5657d79..7486a378dbb06f 100644 --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -1016,7 +1016,9 @@ extension. This regular expression matches ``foo.bar`` and Now, consider complicating the problem a bit; what if you want to match filenames where the extension is not ``bat``? Some incorrect attempts: -``.*[.][^b].*$`` The first attempt above tries to exclude ``bat`` by requiring +``.*[.][^b].*$`` + +The first attempt above tries to exclude ``bat`` by requiring that the first character of the extension is not a ``b``. This is wrong, because the pattern also doesn't match ``foo.bar``. @@ -1043,7 +1045,9 @@ confusing. A negative lookahead cuts through all this confusion: -``.*[.](?!bat$)[^.]*$`` The negative lookahead means: if the expression ``bat`` +``.*[.](?!bat$)[^.]*$`` + +The negative lookahead means: if the expression ``bat`` doesn't match at this point, try the rest of the pattern; if ``bat$`` does match, the whole pattern will fail. The trailing ``$`` is required to ensure that something like ``sample.batch``, where the extension only starts with ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] Docs: Add missing lines between regex and text (GH-134505) (GH-135718)
https://github.com/python/cpython/commit/a7abb8c8e6970f01d12c34d956b2cc9d31a41235 commit: a7abb8c8e6970f01d12c34d956b2cc9d31a41235 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-19T15:07:12Z summary: [3.14] Docs: Add missing lines between regex and text (GH-134505) (GH-135718) Docs: Add missing lines between regex and text (GH-134505) (cherry picked from commit 754190287ece5a2e66684161aadafb18f5f44868) Co-authored-by: Rafael Fontenelle files: M Doc/howto/regex.rst diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst index e543f6d5657d79..7486a378dbb06f 100644 --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -1016,7 +1016,9 @@ extension. This regular expression matches ``foo.bar`` and Now, consider complicating the problem a bit; what if you want to match filenames where the extension is not ``bat``? Some incorrect attempts: -``.*[.][^b].*$`` The first attempt above tries to exclude ``bat`` by requiring +``.*[.][^b].*$`` + +The first attempt above tries to exclude ``bat`` by requiring that the first character of the extension is not a ``b``. This is wrong, because the pattern also doesn't match ``foo.bar``. @@ -1043,7 +1045,9 @@ confusing. A negative lookahead cuts through all this confusion: -``.*[.](?!bat$)[^.]*$`` The negative lookahead means: if the expression ``bat`` +``.*[.](?!bat$)[^.]*$`` + +The negative lookahead means: if the expression ``bat`` doesn't match at this point, try the rest of the pattern; if ``bat$`` does match, the whole pattern will fail. The trailing ``$`` is required to ensure that something like ``sample.batch``, where the extension only starts with ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] Docs: Add missing lines between regex and text (GH-134505) (GH-135719)
https://github.com/python/cpython/commit/2537188f9562441a34fc5d329a8e2948a1106016 commit: 2537188f9562441a34fc5d329a8e2948a1106016 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-19T15:07:40Z summary: [3.13] Docs: Add missing lines between regex and text (GH-134505) (GH-135719) Docs: Add missing lines between regex and text (GH-134505) (cherry picked from commit 754190287ece5a2e66684161aadafb18f5f44868) Co-authored-by: Rafael Fontenelle files: M Doc/howto/regex.rst diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst index 5e2f9a9d1837fe..031caea3cec360 100644 --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -1013,7 +1013,9 @@ extension. This regular expression matches ``foo.bar`` and Now, consider complicating the problem a bit; what if you want to match filenames where the extension is not ``bat``? Some incorrect attempts: -``.*[.][^b].*$`` The first attempt above tries to exclude ``bat`` by requiring +``.*[.][^b].*$`` + +The first attempt above tries to exclude ``bat`` by requiring that the first character of the extension is not a ``b``. This is wrong, because the pattern also doesn't match ``foo.bar``. @@ -1040,7 +1042,9 @@ confusing. A negative lookahead cuts through all this confusion: -``.*[.](?!bat$)[^.]*$`` The negative lookahead means: if the expression ``bat`` +``.*[.](?!bat$)[^.]*$`` + +The negative lookahead means: if the expression ``bat`` doesn't match at this point, try the rest of the pattern; if ``bat$`` does match, the whole pattern will fail. The trailing ``$`` is required to ensure that something like ``sample.batch``, where the extension only starts with ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] Docs: Emphasize parameter name in `pkgutil.iter_importers` (GH-135597)
https://github.com/python/cpython/commit/ff639af8eee11e7ca0b2724bc10652a00e5d commit: ff639af8eee11e7ca0b2724bc10652a00e5d branch: main author: Rafael Fontenelle committer: ZeroIntensity date: 2025-06-19T08:56:43-04:00 summary: Docs: Emphasize parameter name in `pkgutil.iter_importers` (GH-135597) files: M Doc/library/pkgutil.rst diff --git a/Doc/library/pkgutil.rst b/Doc/library/pkgutil.rst index 20b8f6bcf19117..47d24b6f7d06bb 100644 --- a/Doc/library/pkgutil.rst +++ b/Doc/library/pkgutil.rst @@ -69,8 +69,8 @@ support. Yield :term:`finder` objects for the given module name. - If fullname contains a ``'.'``, the finders will be for the package - containing fullname, otherwise they will be all registered top level + If *fullname* contains a ``'.'``, the finders will be for the package + containing *fullname*, otherwise they will be all registered top level finders (i.e. those on both :data:`sys.meta_path` and :data:`sys.path_hooks`). If the named module is in a package, that package is imported as a side ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] Docs: Fix markups for emphasis (GH-135598) (GH-135686)
https://github.com/python/cpython/commit/dfe0e30c80ea6f6fd3d13c578df1a53516854f1c commit: dfe0e30c80ea6f6fd3d13c578df1a53516854f1c branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-18T17:44:43Z summary: [3.13] Docs: Fix markups for emphasis (GH-135598) (GH-135686) Docs: Fix markups for emphasis (GH-135598) The word emphasis character `_` is not supported as sphinx markup, so changed to `*`. (cherry picked from commit 46c60e0d0b716e8e6f0b74a0f9d0542605b1efd4) Co-authored-by: Yuki Kobayashi files: M Doc/c-api/refcounting.rst M Doc/library/logging.config.rst diff --git a/Doc/c-api/refcounting.rst b/Doc/c-api/refcounting.rst index d75dad737bc992..524341794d241d 100644 --- a/Doc/c-api/refcounting.rst +++ b/Doc/c-api/refcounting.rst @@ -201,7 +201,7 @@ of Python objects. Py_SETREF(dst, src); - That arranges to set *dst* to *src* _before_ releasing the reference + That arranges to set *dst* to *src* *before* releasing the reference to the old value of *dst*, so that any code triggered as a side-effect of *dst* getting torn down no longer believes *dst* points to a valid object. diff --git a/Doc/library/logging.config.rst b/Doc/library/logging.config.rst index f8c71005a53028..96cca3073fec7e 100644 --- a/Doc/library/logging.config.rst +++ b/Doc/library/logging.config.rst @@ -586,7 +586,7 @@ configuration dictionary for the handler named ``foo``, and later (once that handler has been configured) it points to the configured handler instance. Thus, ``cfg://handlers.foo`` could resolve to either a dictionary or a handler instance. In general, it is wise to name handlers in a way such that dependent -handlers are configured _after_ any handlers they depend on; that allows +handlers are configured *after* any handlers they depend on; that allows something like ``cfg://handlers.foo`` to be used in configuring a handler that depends on handler ``foo``. If that dependent handler were named ``bar``, problems would result, because the configuration of ``bar`` would be attempted ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] Docs: Fix markups for emphasis (GH-135598) (GH-135685)
https://github.com/python/cpython/commit/1734b295b3c2b06ed296c29a9081bd6d0da8f75b commit: 1734b295b3c2b06ed296c29a9081bd6d0da8f75b branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-18T17:39:06Z summary: [3.14] Docs: Fix markups for emphasis (GH-135598) (GH-135685) Docs: Fix markups for emphasis (GH-135598) The word emphasis character `_` is not supported as sphinx markup, so changed to `*`. (cherry picked from commit 46c60e0d0b716e8e6f0b74a0f9d0542605b1efd4) Co-authored-by: Yuki Kobayashi files: M Doc/c-api/refcounting.rst M Doc/library/logging.config.rst diff --git a/Doc/c-api/refcounting.rst b/Doc/c-api/refcounting.rst index b23f016f9b0a06..57a0728d4e9af4 100644 --- a/Doc/c-api/refcounting.rst +++ b/Doc/c-api/refcounting.rst @@ -210,7 +210,7 @@ of Python objects. Py_SETREF(dst, src); - That arranges to set *dst* to *src* _before_ releasing the reference + That arranges to set *dst* to *src* *before* releasing the reference to the old value of *dst*, so that any code triggered as a side-effect of *dst* getting torn down no longer believes *dst* points to a valid object. diff --git a/Doc/library/logging.config.rst b/Doc/library/logging.config.rst index f8c71005a53028..96cca3073fec7e 100644 --- a/Doc/library/logging.config.rst +++ b/Doc/library/logging.config.rst @@ -586,7 +586,7 @@ configuration dictionary for the handler named ``foo``, and later (once that handler has been configured) it points to the configured handler instance. Thus, ``cfg://handlers.foo`` could resolve to either a dictionary or a handler instance. In general, it is wise to name handlers in a way such that dependent -handlers are configured _after_ any handlers they depend on; that allows +handlers are configured *after* any handlers they depend on; that allows something like ``cfg://handlers.foo`` to be used in configuring a handler that depends on handler ``foo``. If that dependent handler were named ``bar``, problems would result, because the configuration of ``bar`` would be attempted ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] Docs: Fix markups for emphasis (GH-135598)
https://github.com/python/cpython/commit/46c60e0d0b716e8e6f0b74a0f9d0542605b1efd4 commit: 46c60e0d0b716e8e6f0b74a0f9d0542605b1efd4 branch: main author: Yuki Kobayashi committer: ZeroIntensity date: 2025-06-18T13:32:43-04:00 summary: Docs: Fix markups for emphasis (GH-135598) The word emphasis character `_` is not supported as sphinx markup, so changed to `*`. files: M Doc/c-api/refcounting.rst M Doc/library/logging.config.rst diff --git a/Doc/c-api/refcounting.rst b/Doc/c-api/refcounting.rst index b23f016f9b0a06..57a0728d4e9af4 100644 --- a/Doc/c-api/refcounting.rst +++ b/Doc/c-api/refcounting.rst @@ -210,7 +210,7 @@ of Python objects. Py_SETREF(dst, src); - That arranges to set *dst* to *src* _before_ releasing the reference + That arranges to set *dst* to *src* *before* releasing the reference to the old value of *dst*, so that any code triggered as a side-effect of *dst* getting torn down no longer believes *dst* points to a valid object. diff --git a/Doc/library/logging.config.rst b/Doc/library/logging.config.rst index f8c71005a53028..96cca3073fec7e 100644 --- a/Doc/library/logging.config.rst +++ b/Doc/library/logging.config.rst @@ -586,7 +586,7 @@ configuration dictionary for the handler named ``foo``, and later (once that handler has been configured) it points to the configured handler instance. Thus, ``cfg://handlers.foo`` could resolve to either a dictionary or a handler instance. In general, it is wise to name handlers in a way such that dependent -handlers are configured _after_ any handlers they depend on; that allows +handlers are configured *after* any handlers they depend on; that allows something like ``cfg://handlers.foo`` to be used in configuring a handler that depends on handler ``foo``. If that dependent handler were named ``bar``, problems would result, because the configuration of ``bar`` would be attempted ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] Docs: Document `PyExceptionClass` functions in the C API (GH-135697)
https://github.com/python/cpython/commit/59963e866a1bb8128a50cd53d1b13eeab03df06e commit: 59963e866a1bb8128a50cd53d1b13eeab03df06e branch: main author: Yuki Kobayashi committer: ZeroIntensity date: 2025-06-20T09:57:04-04:00 summary: Docs: Document `PyExceptionClass` functions in the C API (GH-135697) * Docs: Document `PyExceptionClass_Name` `PyExceptionClass_Name` is an undocumented function in the limited API. * Document `PyExceptionClass_Check` files: M Doc/c-api/exceptions.rst diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index 885dbeb75303d1..a750cda3e2d474 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -749,6 +749,16 @@ Exception Classes .. versionadded:: 3.2 +.. c:function:: int PyExceptionClass_Check(PyObject *ob) + + Return non-zero if *ob* is an exception class, zero otherwise. This function always succeeds. + + +.. c:function:: const char *PyExceptionClass_Name(PyObject *ob) + + Return :c:member:`~PyTypeObject.tp_name` of the exception class *ob*. + + Exception Objects = ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] Docs: Document `PyExceptionClass` functions in the C API (GH-135697) (GH-135757)
https://github.com/python/cpython/commit/bd24261728e6b3c0c383746b72ad3ef34ed07bf1 commit: bd24261728e6b3c0c383746b72ad3ef34ed07bf1 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-20T14:03:46Z summary: [3.14] Docs: Document `PyExceptionClass` functions in the C API (GH-135697) (GH-135757) Docs: Document `PyExceptionClass` functions in the C API (GH-135697) * Docs: Document `PyExceptionClass_Name` `PyExceptionClass_Name` is an undocumented function in the limited API. * Document `PyExceptionClass_Check` (cherry picked from commit 59963e866a1bb8128a50cd53d1b13eeab03df06e) Co-authored-by: Yuki Kobayashi files: M Doc/c-api/exceptions.rst diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index 885dbeb75303d1..a750cda3e2d474 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -749,6 +749,16 @@ Exception Classes .. versionadded:: 3.2 +.. c:function:: int PyExceptionClass_Check(PyObject *ob) + + Return non-zero if *ob* is an exception class, zero otherwise. This function always succeeds. + + +.. c:function:: const char *PyExceptionClass_Name(PyObject *ob) + + Return :c:member:`~PyTypeObject.tp_name` of the exception class *ob*. + + Exception Objects = ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] Docs: Document `PyExceptionClass` functions in the C API (GH-135697) (GH-135758)
https://github.com/python/cpython/commit/c6e26ef881471a9d1b68e72e203b5d346a5f5f9a commit: c6e26ef881471a9d1b68e72e203b5d346a5f5f9a branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-20T14:03:10Z summary: [3.13] Docs: Document `PyExceptionClass` functions in the C API (GH-135697) (GH-135758) Docs: Document `PyExceptionClass` functions in the C API (GH-135697) * Docs: Document `PyExceptionClass_Name` `PyExceptionClass_Name` is an undocumented function in the limited API. * Document `PyExceptionClass_Check` (cherry picked from commit 59963e866a1bb8128a50cd53d1b13eeab03df06e) Co-authored-by: Yuki Kobayashi files: M Doc/c-api/exceptions.rst diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index bb1339db140fb2..e7ae464b8918d8 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -749,6 +749,16 @@ Exception Classes .. versionadded:: 3.2 +.. c:function:: int PyExceptionClass_Check(PyObject *ob) + + Return non-zero if *ob* is an exception class, zero otherwise. This function always succeeds. + + +.. c:function:: const char *PyExceptionClass_Name(PyObject *ob) + + Return :c:member:`~PyTypeObject.tp_name` of the exception class *ob*. + + Exception Objects = ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] Docs: Add cross-reference for `positional_item` in the `calls` productionlist (GH-129977) (GH-135940)
https://github.com/python/cpython/commit/8ef0398238f68721bc5bffa3446f1ed6b2155cc4 commit: 8ef0398238f68721bc5bffa3446f1ed6b2155cc4 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-25T14:30:42Z summary: [3.14] Docs: Add cross-reference for `positional_item` in the `calls` productionlist (GH-129977) (GH-135940) Docs: Add cross-reference for `positional_item` in the `calls` productionlist (GH-129977) Add missing hyperlink for `positional_item` (cherry picked from commit d2154912b3b10823c138e904e74f2a1e7e7ca96c) Co-authored-by: HarryLHW <[email protected]> files: M Doc/reference/expressions.rst diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 429b3cd1f006a2..17f39aaf5f57cd 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -1023,7 +1023,7 @@ series of :term:`arguments `: : ["," `keywords_arguments`] : | `starred_and_keywords` ["," `keywords_arguments`] : | `keywords_arguments` - positional_arguments: positional_item ("," positional_item)* + positional_arguments: `positional_item` ("," `positional_item`)* positional_item: `assignment_expression` | "*" `expression` starred_and_keywords: ("*" `expression` | `keyword_item`) : ("," "*" `expression` | "," `keyword_item`)* ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] Docs: Add cross-reference for `positional_item` in the `calls` productionlist (GH-129977)
https://github.com/python/cpython/commit/d2154912b3b10823c138e904e74f2a1e7e7ca96c commit: d2154912b3b10823c138e904e74f2a1e7e7ca96c branch: main author: HarryLHW <[email protected]> committer: ZeroIntensity date: 2025-06-25T10:24:58-04:00 summary: Docs: Add cross-reference for `positional_item` in the `calls` productionlist (GH-129977) Add missing hyperlink for `positional_item` files: M Doc/reference/expressions.rst diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 429b3cd1f006a2..17f39aaf5f57cd 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -1023,7 +1023,7 @@ series of :term:`arguments `: : ["," `keywords_arguments`] : | `starred_and_keywords` ["," `keywords_arguments`] : | `keywords_arguments` - positional_arguments: positional_item ("," positional_item)* + positional_arguments: `positional_item` ("," `positional_item`)* positional_item: `assignment_expression` | "*" `expression` starred_and_keywords: ("*" `expression` | `keyword_item`) : ("," "*" `expression` | "," `keyword_item`)* ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] Docs: Add cross-reference for `positional_item` in the `calls` productionlist (GH-129977) (GH-135941)
https://github.com/python/cpython/commit/86c050a5ca9f27851ecc85f436c4dac42d2004df commit: 86c050a5ca9f27851ecc85f436c4dac42d2004df branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-25T14:31:25Z summary: [3.13] Docs: Add cross-reference for `positional_item` in the `calls` productionlist (GH-129977) (GH-135941) Docs: Add cross-reference for `positional_item` in the `calls` productionlist (GH-129977) Add missing hyperlink for `positional_item` (cherry picked from commit d2154912b3b10823c138e904e74f2a1e7e7ca96c) Co-authored-by: HarryLHW <[email protected]> files: M Doc/reference/expressions.rst diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index b237d52c3e75b5..55bae3df25e495 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -1025,7 +1025,7 @@ series of :term:`arguments `: : ["," `keywords_arguments`] : | `starred_and_keywords` ["," `keywords_arguments`] : | `keywords_arguments` - positional_arguments: positional_item ("," positional_item)* + positional_arguments: `positional_item` ("," `positional_item`)* positional_item: `assignment_expression` | "*" `expression` starred_and_keywords: ("*" `expression` | `keyword_item`) : ("," "*" `expression` | "," `keyword_item`)* ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] Fix example according to PEP 750 in "What's new in 3.14" (GH-134727) (GH-135870)
https://github.com/python/cpython/commit/7227aa4bfafaa519867ad59e697c47e78c7a643f commit: 7227aa4bfafaa519867ad59e697c47e78c7a643f branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-23T23:42:04Z summary: [3.14] Fix example according to PEP 750 in "What's new in 3.14" (GH-134727) (GH-135870) Fix example according to PEP 750 in "What's new in 3.14" (GH-134727) A redundant extra part was written. Added a closing tag, to match the usage in PEP 750. (cherry picked from commit 2793b68f758c10fb63b264787f10d46a71fc8086) Co-authored-by: Vincent Poulailleau files: M Doc/whatsnew/3.14.rst diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index c1906610932cec..7564f4a168e16e 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -278,7 +278,7 @@ As another example, generating HTML attributes from data: attributes = {"src": "shrubbery.jpg", "alt": "looks nice"} template = t"" - assert html(template) == '' + assert html(template) == '' Compared to using an f-string, the ``html`` function has access to template attributes containing the original information: static strings, interpolations, and values ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] Fix example according to PEP 750 in "What's new in 3.14" (GH-134727)
https://github.com/python/cpython/commit/2793b68f758c10fb63b264787f10d46a71fc8086
commit: 2793b68f758c10fb63b264787f10d46a71fc8086
branch: main
author: Vincent Poulailleau
committer: ZeroIntensity
date: 2025-06-23T19:36:30-04:00
summary:
Fix example according to PEP 750 in "What's new in 3.14" (GH-134727)
A redundant extra part was written. Added a closing tag, to match the usage in
PEP 750.
files:
M Doc/whatsnew/3.14.rst
diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst
index f0a87a9ada7bab..8b20e42d7d8e07 100644
--- a/Doc/whatsnew/3.14.rst
+++ b/Doc/whatsnew/3.14.rst
@@ -278,7 +278,7 @@ As another example, generating HTML attributes from data:
attributes = {"src": "shrubbery.jpg", "alt": "looks nice"}
template = t""
- assert html(template) == ''
+ assert html(template) == ''
Compared to using an f-string, the ``html`` function has access to template
attributes
containing the original information: static strings, interpolations, and values
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] Docs: Use `arguments` to replace `args` in `argparse.rst` (GH-135510)
https://github.com/python/cpython/commit/caad163b691b2343d823541cfbf741f481ee9f3e commit: caad163b691b2343d823541cfbf741f481ee9f3e branch: main author: Yongzi Li <[email protected]> committer: ZeroIntensity date: 2025-06-23T18:53:33-04:00 summary: Docs: Use `arguments` to replace `args` in `argparse.rst` (GH-135510) files: M Doc/library/argparse.rst diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 17f126cc065a82..a03d88092dbf1f 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -955,7 +955,7 @@ See also :ref:`specifying-ambiguous-arguments`. The supported values are: .. index:: single: + (plus); in argparse module -* ``'+'``. Just like ``'*'``, all command-line args present are gathered into a +* ``'+'``. Just like ``'*'``, all command-line arguments present are gathered into a list. Additionally, an error message will be generated if there wasn't at least one command-line argument present. For example:: ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] Docs: Use `arguments` to replace `args` in `argparse.rst` (GH-135510) (GH-135866)
https://github.com/python/cpython/commit/c9cbe060a227b114c97e38603df46b12b4e29afe commit: c9cbe060a227b114c97e38603df46b12b4e29afe branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-23T22:59:24Z summary: [3.14] Docs: Use `arguments` to replace `args` in `argparse.rst` (GH-135510) (GH-135866) Docs: Use `arguments` to replace `args` in `argparse.rst` (GH-135510) (cherry picked from commit caad163b691b2343d823541cfbf741f481ee9f3e) Co-authored-by: Yongzi Li <[email protected]> files: M Doc/library/argparse.rst diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 17f126cc065a82..a03d88092dbf1f 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -955,7 +955,7 @@ See also :ref:`specifying-ambiguous-arguments`. The supported values are: .. index:: single: + (plus); in argparse module -* ``'+'``. Just like ``'*'``, all command-line args present are gathered into a +* ``'+'``. Just like ``'*'``, all command-line arguments present are gathered into a list. Additionally, an error message will be generated if there wasn't at least one command-line argument present. For example:: ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] Docs: Use `arguments` to replace `args` in `argparse.rst` (GH-135510) (GH-135867)
https://github.com/python/cpython/commit/980d6cc0c8a540ce45e40c5e75d1fb3e05a5133a commit: 980d6cc0c8a540ce45e40c5e75d1fb3e05a5133a branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-23T22:59:17Z summary: [3.13] Docs: Use `arguments` to replace `args` in `argparse.rst` (GH-135510) (GH-135867) Docs: Use `arguments` to replace `args` in `argparse.rst` (GH-135510) (cherry picked from commit caad163b691b2343d823541cfbf741f481ee9f3e) Co-authored-by: Yongzi Li <[email protected]> files: M Doc/library/argparse.rst diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 1acaab444bdb27..46c8ead493340f 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -862,7 +862,7 @@ See also :ref:`specifying-ambiguous-arguments`. The supported values are: .. index:: single: + (plus); in argparse module -* ``'+'``. Just like ``'*'``, all command-line args present are gathered into a +* ``'+'``. Just like ``'*'``, all command-line arguments present are gathered into a list. Additionally, an error message will be generated if there wasn't at least one command-line argument present. For example:: ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] Docs: Remove unnecessary trailing backslashes (GH-135781)
https://github.com/python/cpython/commit/6a16b3c440cf9ecabecd3e90f44310e3b0765780 commit: 6a16b3c440cf9ecabecd3e90f44310e3b0765780 branch: main author: Rafael Fontenelle committer: ZeroIntensity date: 2025-06-21T09:01:14-04:00 summary: Docs: Remove unnecessary trailing backslashes (GH-135781) This fixes Sphinx's gettext extraction for translations. files: M Doc/c-api/extension-modules.rst diff --git a/Doc/c-api/extension-modules.rst b/Doc/c-api/extension-modules.rst index 4c8212f2f5e7f7..3d331e6ec12f76 100644 --- a/Doc/c-api/extension-modules.rst +++ b/Doc/c-api/extension-modules.rst @@ -242,6 +242,6 @@ in the following ways: * Single-phase modules support module lookup functions like :c:func:`PyState_FindModule`. -.. [#testsinglephase] ``_testsinglephase`` is an internal module used \ - in CPython's self-test suite; your installation may or may not \ +.. [#testsinglephase] ``_testsinglephase`` is an internal module used + in CPython's self-test suite; your installation may or may not include it. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] Docs: Remove unnecessary trailing backslashes (GH-135781) (GH-135791)
https://github.com/python/cpython/commit/73e2089ed135d38ec814e8a8ce348bf3db0607f6 commit: 73e2089ed135d38ec814e8a8ce348bf3db0607f6 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-06-21T13:07:51Z summary: [3.14] Docs: Remove unnecessary trailing backslashes (GH-135781) (GH-135791) Docs: Remove unnecessary trailing backslashes (GH-135781) This fixes Sphinx's gettext extraction for translations. (cherry picked from commit 6a16b3c440cf9ecabecd3e90f44310e3b0765780) Co-authored-by: Rafael Fontenelle files: M Doc/c-api/extension-modules.rst diff --git a/Doc/c-api/extension-modules.rst b/Doc/c-api/extension-modules.rst index 4c8212f2f5e7f7..3d331e6ec12f76 100644 --- a/Doc/c-api/extension-modules.rst +++ b/Doc/c-api/extension-modules.rst @@ -242,6 +242,6 @@ in the following ways: * Single-phase modules support module lookup functions like :c:func:`PyState_FindModule`. -.. [#testsinglephase] ``_testsinglephase`` is an internal module used \ - in CPython's self-test suite; your installation may or may not \ +.. [#testsinglephase] ``_testsinglephase`` is an internal module used + in CPython's self-test suite; your installation may or may not include it. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-135110: Fix misleading `generator.close()` documentation (GH-135152)
https://github.com/python/cpython/commit/0d76dccc3b4376ba075a1737f58809e3d833 commit: 0d76dccc3b4376ba075a1737f58809e3d833 branch: main author: Connor Denihan <[email protected]> committer: ZeroIntensity date: 2025-06-26T09:27:25-04:00 summary: gh-135110: Fix misleading `generator.close()` documentation (GH-135152) The documentation incorrectly stated that generator.close() 'raises' a GeneratorExit exception. This was misleading because the method doesn't raise the exception to the caller - it sends the exception internally to the generator and returns None. files: M Doc/howto/functional.rst M Doc/reference/expressions.rst diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst index b4f3463afee812..78e56e0c64fb10 100644 --- a/Doc/howto/functional.rst +++ b/Doc/howto/functional.rst @@ -602,7 +602,7 @@ generators: raise an exception inside the generator; the exception is raised by the ``yield`` expression where the generator's execution is paused. -* :meth:`~generator.close` raises a :exc:`GeneratorExit` exception inside the +* :meth:`~generator.close` sends a :exc:`GeneratorExit` exception to the generator to terminate the iteration. On receiving this exception, the generator's code must either raise :exc:`GeneratorExit` or :exc:`StopIteration`; catching the exception and doing anything else is diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 17f39aaf5f57cd..24544a055c3ed2 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -625,8 +625,10 @@ is already executing raises a :exc:`ValueError` exception. .. method:: generator.close() - Raises a :exc:`GeneratorExit` at the point where the generator function was - paused. If the generator function catches the exception and returns a + Raises a :exc:`GeneratorExit` exception at the point where the generator + function was paused (equivalent to calling ``throw(GeneratorExit)``). + The exception is raised by the yield expression where the generator was paused. + If the generator function catches the exception and returns a value, this value is returned from :meth:`close`. If the generator function is already closed, or raises :exc:`GeneratorExit` (by not catching the exception), :meth:`close` returns :const:`None`. If the generator yields a ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.14] gh-136470: Correct InterpreterPoolExecutor's default thread name (GH-136472) (GH-136889)
https://github.com/python/cpython/commit/9663f93a50469828e3c149c6b535227170a29409 commit: 9663f93a50469828e3c149c6b535227170a29409 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-21T00:00:19Z summary: [3.14] gh-136470: Correct InterpreterPoolExecutor's default thread name (GH-136472) (GH-136889) gh-136470: Correct InterpreterPoolExecutor's default thread name (GH-136472) The OS thread name is now correctly prefixed with `InterpreterPoolExecutor` instead of `ThreadPoolExecutor`. (cherry picked from commit 246be21de1e2a51d757c747902108dfec13e0605) Co-authored-by: AN Long files: A Misc/NEWS.d/next/Library/2025-07-10-00-47-37.gh-issue-136470.KlUEUG.rst M Lib/concurrent/futures/interpreter.py M Lib/test/test_concurrent_futures/test_interpreter_pool.py diff --git a/Lib/concurrent/futures/interpreter.py b/Lib/concurrent/futures/interpreter.py index cbb60ce80c1813..53c6e757ded2e3 100644 --- a/Lib/concurrent/futures/interpreter.py +++ b/Lib/concurrent/futures/interpreter.py @@ -118,5 +118,7 @@ def __init__(self, max_workers=None, thread_name_prefix='', each worker interpreter. initargs: A tuple of arguments to pass to the initializer. """ +thread_name_prefix = (thread_name_prefix or + (f"InterpreterPoolExecutor-{self._counter()}")) super().__init__(max_workers, thread_name_prefix, initializer, initargs) diff --git a/Lib/test/test_concurrent_futures/test_interpreter_pool.py b/Lib/test/test_concurrent_futures/test_interpreter_pool.py index d5c032d01cdf5d..7241fcc4b1e74d 100644 --- a/Lib/test/test_concurrent_futures/test_interpreter_pool.py +++ b/Lib/test/test_concurrent_futures/test_interpreter_pool.py @@ -1,3 +1,4 @@ +import _thread import asyncio import contextlib import io @@ -498,6 +499,20 @@ def test_import_interpreter_pool_executor(self): self.assertEqual(p.stdout.decode(), '') self.assertEqual(p.stderr.decode(), '') +def test_thread_name_prefix(self): +self.assertStartsWith(self.executor._thread_name_prefix, + "InterpreterPoolExecutor-") + [email protected](hasattr(_thread, '_get_name'), "missing _thread._get_name") +def test_thread_name_prefix_with_thread_get_name(self): +def get_thread_name(): +import _thread +return _thread._get_name() + +# Some platforms (Linux) are using 16 bytes to store the thread name, +# so only compare the first 15 bytes (without the trailing \n). +self.assertStartsWith(self.executor.submit(get_thread_name).result(), + "InterpreterPoolExecutor-"[:15]) class AsyncioTest(InterpretersMixin, testasyncio_utils.TestCase): diff --git a/Misc/NEWS.d/next/Library/2025-07-10-00-47-37.gh-issue-136470.KlUEUG.rst b/Misc/NEWS.d/next/Library/2025-07-10-00-47-37.gh-issue-136470.KlUEUG.rst new file mode 100644 index 00..5a0429cae07168 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-07-10-00-47-37.gh-issue-136470.KlUEUG.rst @@ -0,0 +1,2 @@ +Correct :class:`concurrent.futures.InterpreterPoolExecutor`'s default thread +name. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-136470: Correct InterpreterPoolExecutor's default thread name (GH-136472)
https://github.com/python/cpython/commit/246be21de1e2a51d757c747902108dfec13e0605
commit: 246be21de1e2a51d757c747902108dfec13e0605
branch: main
author: AN Long
committer: ZeroIntensity
date: 2025-07-20T23:34:32Z
summary:
gh-136470: Correct InterpreterPoolExecutor's default thread name (GH-136472)
The OS thread name is now correctly prefixed with `InterpreterPoolExecutor`
instead of `ThreadPoolExecutor`.
files:
A Misc/NEWS.d/next/Library/2025-07-10-00-47-37.gh-issue-136470.KlUEUG.rst
M Lib/concurrent/futures/interpreter.py
M Lib/test/test_concurrent_futures/test_interpreter_pool.py
diff --git a/Lib/concurrent/futures/interpreter.py
b/Lib/concurrent/futures/interpreter.py
index cbb60ce80c1813..53c6e757ded2e3 100644
--- a/Lib/concurrent/futures/interpreter.py
+++ b/Lib/concurrent/futures/interpreter.py
@@ -118,5 +118,7 @@ def __init__(self, max_workers=None, thread_name_prefix='',
each worker interpreter.
initargs: A tuple of arguments to pass to the initializer.
"""
+thread_name_prefix = (thread_name_prefix or
+ (f"InterpreterPoolExecutor-{self._counter()}"))
super().__init__(max_workers, thread_name_prefix,
initializer, initargs)
diff --git a/Lib/test/test_concurrent_futures/test_interpreter_pool.py
b/Lib/test/test_concurrent_futures/test_interpreter_pool.py
index d5c032d01cdf5d..7241fcc4b1e74d 100644
--- a/Lib/test/test_concurrent_futures/test_interpreter_pool.py
+++ b/Lib/test/test_concurrent_futures/test_interpreter_pool.py
@@ -1,3 +1,4 @@
+import _thread
import asyncio
import contextlib
import io
@@ -498,6 +499,20 @@ def test_import_interpreter_pool_executor(self):
self.assertEqual(p.stdout.decode(), '')
self.assertEqual(p.stderr.decode(), '')
+def test_thread_name_prefix(self):
+self.assertStartsWith(self.executor._thread_name_prefix,
+ "InterpreterPoolExecutor-")
+
[email protected](hasattr(_thread, '_get_name'), "missing
_thread._get_name")
+def test_thread_name_prefix_with_thread_get_name(self):
+def get_thread_name():
+import _thread
+return _thread._get_name()
+
+# Some platforms (Linux) are using 16 bytes to store the thread name,
+# so only compare the first 15 bytes (without the trailing \n).
+self.assertStartsWith(self.executor.submit(get_thread_name).result(),
+ "InterpreterPoolExecutor-"[:15])
class AsyncioTest(InterpretersMixin, testasyncio_utils.TestCase):
diff --git
a/Misc/NEWS.d/next/Library/2025-07-10-00-47-37.gh-issue-136470.KlUEUG.rst
b/Misc/NEWS.d/next/Library/2025-07-10-00-47-37.gh-issue-136470.KlUEUG.rst
new file mode 100644
index 00..5a0429cae07168
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-07-10-00-47-37.gh-issue-136470.KlUEUG.rst
@@ -0,0 +1,2 @@
+Correct :class:`concurrent.futures.InterpreterPoolExecutor`'s default thread
+name.
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] gh-137093: Fix race condition in `test_embed.test_bpo20891` (GH-137094)
https://github.com/python/cpython/commit/9b451fb457a5de9ed535a0e2f41161dfaa9a419a
commit: 9b451fb457a5de9ed535a0e2f41161dfaa9a419a
branch: main
author: Peter Bierma
committer: ZeroIntensity
date: 2025-07-25T08:33:18-04:00
summary:
gh-137093: Fix race condition in `test_embed.test_bpo20891` (GH-137094)
Use a `PyEvent` instead of a lock to fix a race on the free-threaded build.
files:
M Programs/_testembed.c
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index 88936bbc699c30..28c004c3c5ac2c 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -379,9 +379,9 @@ static int test_pre_initialization_sys_options(void)
/* bpo-20891: Avoid race condition when initialising the GIL */
-static void bpo20891_thread(void *lockp)
+static void bpo20891_thread(void *eventp)
{
-PyThread_type_lock lock = *((PyThread_type_lock*)lockp);
+PyEvent *event = (PyEvent *)eventp;
PyGILState_STATE state = PyGILState_Ensure();
if (!PyGILState_Check()) {
@@ -390,8 +390,7 @@ static void bpo20891_thread(void *lockp)
}
PyGILState_Release(state);
-
-PyThread_release_lock(lock);
+_PyEvent_Notify(event);
}
static int test_bpo20891(void)
@@ -401,27 +400,16 @@ static int test_bpo20891(void)
/* bpo-20891: Calling PyGILState_Ensure in a non-Python thread must not
crash. */
-PyThread_type_lock lock = PyThread_allocate_lock();
-if (!lock) {
-error("PyThread_allocate_lock failed!");
-return 1;
-}
-
+PyEvent event = {0};
_testembed_initialize();
-unsigned long thrd = PyThread_start_new_thread(bpo20891_thread, &lock);
+unsigned long thrd = PyThread_start_new_thread(bpo20891_thread, &event);
if (thrd == PYTHREAD_INVALID_THREAD_ID) {
error("PyThread_start_new_thread failed!");
return 1;
}
-PyThread_acquire_lock(lock, WAIT_LOCK);
-Py_BEGIN_ALLOW_THREADS
-/* wait until the thread exit */
-PyThread_acquire_lock(lock, WAIT_LOCK);
-Py_END_ALLOW_THREADS
-
-PyThread_free_lock(lock);
+PyEvent_Wait(&event);
Py_Finalize();
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] [3.13] gh-130522: Fix unraisable TypeError in threading at interpreter shutdown (GH-131537) (GH-137106)
https://github.com/python/cpython/commit/8f4121168a1e243bf10615011913b785a6a00f12 commit: 8f4121168a1e243bf10615011913b785a6a00f12 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-07-25T15:14:27Z summary: [3.13] gh-130522: Fix unraisable TypeError in threading at interpreter shutdown (GH-131537) (GH-137106) gh-130522: Fix unraisable TypeError in threading at interpreter shutdown (GH-131537) (cherry picked from commit cb93b6fc5ea525f8075cb53ec373356fec63903a) Co-authored-by: Tyler Kennedy Co-authored-by: Peter Bierma files: A Misc/NEWS.d/next/Library/2025-07-25-09-21-56.gh-issue-130522.Crwq68.rst M Lib/test/test_threading.py M Lib/threading.py diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index 9ba5f68fd4a53c..3ed7fdb3fabde6 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -1849,6 +1849,23 @@ def modify_file(): t.start() t.join() +def test_dummy_thread_on_interpreter_shutdown(self): +# GH-130522: When `threading` held a reference to itself and then a +# _DummyThread() object was created, destruction of the dummy thread +# would emit an unraisable exception at shutdown, due to a lock being +# destroyed. +code = """if True: +import sys +import threading + +threading.x = sys.modules[__name__] +x = threading._DummyThread() +""" +rc, out, err = assert_python_ok("-c", code) +self.assertEqual(rc, 0) +self.assertEqual(out, b"") +self.assertEqual(err, b"") + class ThreadRunFail(threading.Thread): def run(self): diff --git a/Lib/threading.py b/Lib/threading.py index 11f1b5af6ac1b3..acf5090716c9be 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -1381,7 +1381,7 @@ def __init__(self, dummy_thread): # the related _DummyThread will be kept forever! _thread_local_info._track_dummy_thread_ref = self -def __del__(self): +def __del__(self, _active_limbo_lock=_active_limbo_lock, _active=_active): with _active_limbo_lock: if _active.get(self._tident) is self._dummy_thread: _active.pop(self._tident, None) diff --git a/Misc/NEWS.d/next/Library/2025-07-25-09-21-56.gh-issue-130522.Crwq68.rst b/Misc/NEWS.d/next/Library/2025-07-25-09-21-56.gh-issue-130522.Crwq68.rst new file mode 100644 index 00..6c2246631dda9e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-07-25-09-21-56.gh-issue-130522.Crwq68.rst @@ -0,0 +1,2 @@ +Fix unraisable :exc:`TypeError` raised during :term:`interpreter shutdown` +in the :mod:`threading` module. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-137282: Fix `TypeError` in tab completion and `dir()` of `concurrent.futures` (GH-137214)
https://github.com/python/cpython/commit/2a87af062b79d914ce0120f1f1763213c1ebe8c4
commit: 2a87af062b79d914ce0120f1f1763213c1ebe8c4
branch: main
author: Henry Schreiner
committer: ZeroIntensity
date: 2025-07-31T16:17:27Z
summary:
gh-137282: Fix `TypeError` in tab completion and `dir()` of
`concurrent.futures` (GH-137214)
Signed-off-by: Henry Schreiner
files:
A Misc/NEWS.d/next/Library/2025-07-31-10-31-56.gh-issue-137282.GOCwIC.rst
M Lib/concurrent/futures/__init__.py
M Lib/test/test___all__.py
diff --git a/Lib/concurrent/futures/__init__.py
b/Lib/concurrent/futures/__init__.py
index e717222cf98b32..d6ac4b3e0b675f 100644
--- a/Lib/concurrent/futures/__init__.py
+++ b/Lib/concurrent/futures/__init__.py
@@ -44,7 +44,7 @@
def __dir__():
-return __all__ + ('__author__', '__doc__')
+return __all__ + ['__author__', '__doc__']
def __getattr__(name):
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index f35b1194308262..8ded9f99248372 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -72,6 +72,8 @@ def check_all(self, modname):
all_set = set(all_list)
self.assertCountEqual(all_set, all_list, "in module
{}".format(modname))
self.assertEqual(keys, all_set, "in module {}".format(modname))
+# Verify __dir__ is non-empty and doesn't produce an error
+self.assertTrue(dir(sys.modules[modname]))
def walk_modules(self, basedir, modpath):
for fn in sorted(os.listdir(basedir)):
diff --git
a/Misc/NEWS.d/next/Library/2025-07-31-10-31-56.gh-issue-137282.GOCwIC.rst
b/Misc/NEWS.d/next/Library/2025-07-31-10-31-56.gh-issue-137282.GOCwIC.rst
new file mode 100644
index 00..78f169ea029b17
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-07-31-10-31-56.gh-issue-137282.GOCwIC.rst
@@ -0,0 +1 @@
+Fix tab completion and :func:`dir` on :mod:`concurrent.futures`.
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] gh-137257: Upgrade bundled pip to 25.2 (GH-137258)
https://github.com/python/cpython/commit/506542b5966073203f0da71a487de24e596b7979 commit: 506542b5966073203f0da71a487de24e596b7979 branch: main author: Richard Si committer: ZeroIntensity date: 2025-08-03T22:00:17-04:00 summary: gh-137257: Upgrade bundled pip to 25.2 (GH-137258) files: A Lib/ensurepip/_bundled/pip-25.2-py3-none-any.whl A Misc/NEWS.d/next/Library/2025-07-30-18-07-33.gh-issue-137257.XBtzf2.rst D Lib/ensurepip/_bundled/pip-25.1.1-py3-none-any.whl M Lib/ensurepip/__init__.py diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py index aa641e94a8b336..4bd85990e8614a 100644 --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -10,7 +10,7 @@ __all__ = ["version", "bootstrap"] -_PIP_VERSION = "25.1.1" +_PIP_VERSION = "25.2" # Directory of system wheel packages. Some Linux distribution packaging # policies recommend against bundling dependencies. For example, Fedora diff --git a/Lib/ensurepip/_bundled/pip-25.1.1-py3-none-any.whl b/Lib/ensurepip/_bundled/pip-25.2-py3-none-any.whl similarity index 58% rename from Lib/ensurepip/_bundled/pip-25.1.1-py3-none-any.whl rename to Lib/ensurepip/_bundled/pip-25.2-py3-none-any.whl index 2fdcfbf9ff8139..e14bb3f37c0ff4 100644 Binary files a/Lib/ensurepip/_bundled/pip-25.1.1-py3-none-any.whl and b/Lib/ensurepip/_bundled/pip-25.2-py3-none-any.whl differ diff --git a/Misc/NEWS.d/next/Library/2025-07-30-18-07-33.gh-issue-137257.XBtzf2.rst b/Misc/NEWS.d/next/Library/2025-07-30-18-07-33.gh-issue-137257.XBtzf2.rst new file mode 100644 index 00..fad609854025c0 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-07-30-18-07-33.gh-issue-137257.XBtzf2.rst @@ -0,0 +1 @@ +Bump the version of pip bundled in ensurepip to version 25.2 ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-137257: Upgrade bundled pip to 25.2 (GH-137258) (GH-137362)
https://github.com/python/cpython/commit/1ba09b2f0445eb80fd255ee2d9cbbdc859e0bb41 commit: 1ba09b2f0445eb80fd255ee2d9cbbdc859e0bb41 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-08-04T02:23:25Z summary: [3.13] gh-137257: Upgrade bundled pip to 25.2 (GH-137258) (GH-137362) gh-137257: Upgrade bundled pip to 25.2 (GH-137258) (cherry picked from commit 506542b5966073203f0da71a487de24e596b7979) Co-authored-by: Richard Si files: A Lib/ensurepip/_bundled/pip-25.2-py3-none-any.whl A Misc/NEWS.d/next/Library/2025-07-30-18-07-33.gh-issue-137257.XBtzf2.rst D Lib/ensurepip/_bundled/pip-25.1.1-py3-none-any.whl M Lib/ensurepip/__init__.py diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py index ed8157707d7604..ab6d32478e4e40 100644 --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -10,7 +10,7 @@ __all__ = ["version", "bootstrap"] -_PIP_VERSION = "25.1.1" +_PIP_VERSION = "25.2" # Directory of system wheel packages. Some Linux distribution packaging # policies recommend against bundling dependencies. For example, Fedora diff --git a/Lib/ensurepip/_bundled/pip-25.1.1-py3-none-any.whl b/Lib/ensurepip/_bundled/pip-25.2-py3-none-any.whl similarity index 58% rename from Lib/ensurepip/_bundled/pip-25.1.1-py3-none-any.whl rename to Lib/ensurepip/_bundled/pip-25.2-py3-none-any.whl index 2fdcfbf9ff8139..e14bb3f37c0ff4 100644 Binary files a/Lib/ensurepip/_bundled/pip-25.1.1-py3-none-any.whl and b/Lib/ensurepip/_bundled/pip-25.2-py3-none-any.whl differ diff --git a/Misc/NEWS.d/next/Library/2025-07-30-18-07-33.gh-issue-137257.XBtzf2.rst b/Misc/NEWS.d/next/Library/2025-07-30-18-07-33.gh-issue-137257.XBtzf2.rst new file mode 100644 index 00..fad609854025c0 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-07-30-18-07-33.gh-issue-137257.XBtzf2.rst @@ -0,0 +1 @@ +Bump the version of pip bundled in ensurepip to version 25.2 ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-134170: Add colorization to unraisable exceptions (#134183)
https://github.com/python/cpython/commit/e8251dc0ae6a85f6a0e427ae64fb0fe847eb3cf8 commit: e8251dc0ae6a85f6a0e427ae64fb0fe847eb3cf8 branch: main author: Peter Bierma committer: ZeroIntensity date: 2025-08-04T14:35:00Z summary: gh-134170: Add colorization to unraisable exceptions (#134183) Default implementation of sys.unraisablehook() now uses traceback._print_exception_bltin() to print exceptions with colorized text. Co-authored-by: Bénédikt Tran <[email protected]> Co-authored-by: Victor Stinner files: A Misc/NEWS.d/next/Core_and_Builtins/2025-05-18-10-50-46.gh-issue-134170.J0Hvmi.rst M Doc/library/sys.rst M Doc/whatsnew/3.15.rst M Lib/test/test_capi/test_exceptions.py M Lib/test/test_cmd_line.py M Lib/test/test_concurrent_futures/test_shutdown.py M Lib/test/test_signal.py M Lib/test/test_sys.py M Lib/test/test_threading.py M Lib/traceback.py M Python/errors.c diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 52f0af31c68726..771e0f2709a4aa 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -2152,11 +2152,16 @@ always available. Unless explicitly noted otherwise, all variables are read-only The default hook formats :attr:`!err_msg` and :attr:`!object` as: ``f'{err_msg}: {object!r}'``; use "Exception ignored in" error message - if :attr:`!err_msg` is ``None``. + if :attr:`!err_msg` is ``None``. Similar to the :mod:`traceback` module, + this adds color to exceptions by default. This can be disabled using + :ref:`environment variables `. :func:`sys.unraisablehook` can be overridden to control how unraisable exceptions are handled. + .. versionchanged:: next + Exceptions are now printed with colorful text. + .. seealso:: :func:`excepthook` which handles uncaught exceptions. diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index e716d7bb0f2a5c..54964da473760d 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -200,6 +200,10 @@ Other language changes * Several error messages incorrectly using the term "argument" have been corrected. (Contributed by Stan Ulbrych in :gh:`133382`.) +* Unraisable exceptions are now highlighted with color by default. This can be + controlled by :ref:`environment variables `. + (Contributed by Peter Bierma in :gh:`134170`.) + New modules === diff --git a/Lib/test/test_capi/test_exceptions.py b/Lib/test/test_capi/test_exceptions.py index ade55338e63b69..4967f02b007e06 100644 --- a/Lib/test/test_capi/test_exceptions.py +++ b/Lib/test/test_capi/test_exceptions.py @@ -6,7 +6,7 @@ import textwrap from test import support -from test.support import import_helper +from test.support import import_helper, force_not_colorized from test.support.os_helper import TESTFN, TESTFN_UNDECODABLE from test.support.script_helper import assert_python_failure, assert_python_ok from test.support.testcase import ExceptionIsLikeMixin @@ -337,6 +337,10 @@ def test_err_writeunraisable(self): self.assertIsNone(cm.unraisable.err_msg) self.assertIsNone(cm.unraisable.object) +@force_not_colorized +def test_err_writeunraisable_lines(self): +writeunraisable = _testcapi.err_writeunraisable + with (support.swap_attr(sys, 'unraisablehook', None), support.captured_stderr() as stderr): writeunraisable(CustomError('oops!'), hex) @@ -387,6 +391,10 @@ def test_err_formatunraisable(self): self.assertIsNone(cm.unraisable.err_msg) self.assertIsNone(cm.unraisable.object) +@force_not_colorized +def test_err_formatunraisable_lines(self): +formatunraisable = _testcapi.err_formatunraisable + with (support.swap_attr(sys, 'unraisablehook', None), support.captured_stderr() as stderr): formatunraisable(CustomError('oops!'), b'Error in %R', []) diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index f30a1874ab96d4..3ed7a360d64e3c 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -489,6 +489,7 @@ def test_unmached_quote(self): self.assertRegex(err.decode('ascii', 'ignore'), 'SyntaxError') self.assertEqual(b'', out) +@force_not_colorized def test_stdout_flush_at_shutdown(self): # Issue #5319: if stdout.flush() fails at shutdown, an error should # be printed out. diff --git a/Lib/test/test_concurrent_futures/test_shutdown.py b/Lib/test/test_concurrent_futures/test_shutdown.py index 99b315b47e2530..43812248104c91 100644 --- a/Lib/test/test_concurrent_futures/test_shutdown.py +++ b/Lib/test/test_concurrent_futures/test_shutdown.py @@ -49,6 +49,7 @@ def test_interpreter_shutdown(self): self.assertFalse(err) self.assertEqual(out.strip(), b"apple") [email protected]_not_colorized de
[Python-checkins] gh-137514: Add a free-threading wrapper for mutexes (GH-137515)
https://github.com/python/cpython/commit/082f370cdd0ec1484b033c70ec81b4b7a972ee2c
commit: 082f370cdd0ec1484b033c70ec81b4b7a972ee2c
branch: main
author: Peter Bierma
committer: ZeroIntensity
date: 2025-08-07T11:24:50-04:00
summary:
gh-137514: Add a free-threading wrapper for mutexes (GH-137515)
Add `FT_MUTEX_LOCK`/`FT_MUTEX_UNLOCK`, which call `PyMutex_Lock` and
`PyMutex_Unlock` on the free-threaded build, and no-op otherwise.
files:
M Include/internal/pycore_pyatomic_ft_wrappers.h
M Modules/_ctypes/malloc_closure.c
M Objects/codeobject.c
M Objects/unicodeobject.c
M Parser/pegen.c
M Python/ceval_gil.c
M Python/codecs.c
M Python/legacy_tracing.c
M Python/pystate.c
diff --git a/Include/internal/pycore_pyatomic_ft_wrappers.h
b/Include/internal/pycore_pyatomic_ft_wrappers.h
index 3e41e2fd1569ca..c31c33657002ec 100644
--- a/Include/internal/pycore_pyatomic_ft_wrappers.h
+++ b/Include/internal/pycore_pyatomic_ft_wrappers.h
@@ -111,6 +111,8 @@ extern "C" {
_Py_atomic_load_ullong_relaxed(&value)
#define FT_ATOMIC_ADD_SSIZE(value, new_value) \
(void)_Py_atomic_add_ssize(&value, new_value)
+#define FT_MUTEX_LOCK(lock) PyMutex_Lock(lock)
+#define FT_MUTEX_UNLOCK(lock) PyMutex_Unlock(lock)
#else
#define FT_ATOMIC_LOAD_PTR(value) value
@@ -159,6 +161,8 @@ extern "C" {
#define FT_ATOMIC_LOAD_ULLONG_RELAXED(value) value
#define FT_ATOMIC_STORE_ULLONG_RELAXED(value, new_value) value = new_value
#define FT_ATOMIC_ADD_SSIZE(value, new_value) (void)(value += new_value)
+#define FT_MUTEX_LOCK(lock) do {} while (0)
+#define FT_MUTEX_UNLOCK(lock) do {} while (0)
#endif
diff --git a/Modules/_ctypes/malloc_closure.c b/Modules/_ctypes/malloc_closure.c
index 80ba96614bff79..db405acf8727b5 100644
--- a/Modules/_ctypes/malloc_closure.c
+++ b/Modules/_ctypes/malloc_closure.c
@@ -30,11 +30,6 @@
#ifdef Py_GIL_DISABLED
static PyMutex malloc_closure_lock;
-# define MALLOC_CLOSURE_LOCK() PyMutex_Lock(&malloc_closure_lock)
-# define MALLOC_CLOSURE_UNLOCK() PyMutex_Unlock(&malloc_closure_lock)
-#else
-# define MALLOC_CLOSURE_LOCK() ((void)0)
-# define MALLOC_CLOSURE_UNLOCK() ((void)0)
#endif
typedef union _tagITEM {
@@ -120,11 +115,11 @@ void Py_ffi_closure_free(void *p)
}
#endif
#endif
-MALLOC_CLOSURE_LOCK();
+FT_MUTEX_LOCK(&malloc_closure_lock);
ITEM *item = (ITEM *)p;
item->next = free_list;
free_list = item;
-MALLOC_CLOSURE_UNLOCK();
+FT_MUTEX_UNLOCK(&malloc_closure_lock);
}
/* return one item from the free list, allocating more if needed */
@@ -143,13 +138,13 @@ void *Py_ffi_closure_alloc(size_t size, void** codeloc)
}
#endif
#endif
-MALLOC_CLOSURE_LOCK();
+FT_MUTEX_LOCK(&malloc_closure_lock);
ITEM *item;
if (!free_list) {
more_core();
}
if (!free_list) {
-MALLOC_CLOSURE_UNLOCK();
+FT_MUTEX_UNLOCK(&malloc_closure_lock);
return NULL;
}
item = free_list;
@@ -160,6 +155,6 @@ void *Py_ffi_closure_alloc(size_t size, void** codeloc)
#else
*codeloc = (void *)item;
#endif
-MALLOC_CLOSURE_UNLOCK();
+FT_MUTEX_UNLOCK(&malloc_closure_lock);
return (void *)item;
}
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 42e021679b583f..478c571345cd03 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -550,16 +550,12 @@ init_code(PyCodeObject *co, struct _PyCodeConstructor
*con)
co->co_framesize = nlocalsplus + con->stacksize + FRAME_SPECIALS_SIZE;
co->co_ncellvars = ncellvars;
co->co_nfreevars = nfreevars;
-#ifdef Py_GIL_DISABLED
-PyMutex_Lock(&interp->func_state.mutex);
-#endif
+FT_MUTEX_LOCK(&interp->func_state.mutex);
co->co_version = interp->func_state.next_version;
if (interp->func_state.next_version != 0) {
interp->func_state.next_version++;
}
-#ifdef Py_GIL_DISABLED
-PyMutex_Unlock(&interp->func_state.mutex);
-#endif
+FT_MUTEX_UNLOCK(&interp->func_state.mutex);
co->_co_monitoring = NULL;
co->_co_instrumentation_version = 0;
/* not set */
@@ -689,7 +685,7 @@ intern_code_constants(struct _PyCodeConstructor *con)
#ifdef Py_GIL_DISABLED
PyInterpreterState *interp = _PyInterpreterState_GET();
struct _py_code_state *state = &interp->code_state;
-PyMutex_Lock(&state->mutex);
+FT_MUTEX_LOCK(&state->mutex);
#endif
if (intern_strings(con->names) < 0) {
goto error;
@@ -700,15 +696,11 @@ intern_code_constants(struct _PyCodeConstructor *con)
if (intern_strings(con->localsplusnames) < 0) {
goto error;
}
-#ifdef Py_GIL_DISABLED
-PyMutex_Unlock(&state->mutex);
-#endif
+FT_MUTEX_UNLOCK(&state->mutex);
return 0;
error:
-#ifdef Py_GIL_DISABLED
-PyMutex_Unlock(&state->mutex);
-#endif
+FT_MUTEX_UNLOCK(&state->mutex);
return -1;
}
[Python-checkins] [3.13] gh-137440: Update comment in Python/hamt.c on importing for testing (GH-137441) (GH-137520)
https://github.com/python/cpython/commit/599454e65d3d45ca2a88b33d7de3145a753a5ed5 commit: 599454e65d3d45ca2a88b33d7de3145a753a5ed5 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-08-07T16:54:52Z summary: [3.13] gh-137440: Update comment in Python/hamt.c on importing for testing (GH-137441) (GH-137520) gh-137440: Update comment in Python/hamt.c on importing for testing (GH-137441) Switch from `_testcapi` to `_testinternalcapi`. (cherry picked from commit 7ab68cd50658f76abc9e0f12e6212736e2440720) Co-authored-by: Bartosz Sławecki files: M Python/hamt.c diff --git a/Python/hamt.c b/Python/hamt.c index a8fbb00b807934..91abaecd3e7287 100644 --- a/Python/hamt.c +++ b/Python/hamt.c @@ -256,9 +256,9 @@ Debug = The HAMT datatype is accessible for testing purposes under the -`_testcapi` module: +`_testinternalcapi` module: ->>> from _testcapi import hamt +>>> from _testinternalcapi import hamt >>> h = hamt() >>> h2 = h.set('a', 2) >>> h3 = h2.set('b', 3) ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-137440: Update comment in Python/hamt.c on importing for testing (GH-137441)
https://github.com/python/cpython/commit/7ab68cd50658f76abc9e0f12e6212736e2440720
commit: 7ab68cd50658f76abc9e0f12e6212736e2440720
branch: main
author: Bartosz Sławecki
committer: ZeroIntensity
date: 2025-08-07T09:50:49-04:00
summary:
gh-137440: Update comment in Python/hamt.c on importing for testing (GH-137441)
Switch from `_testcapi` to `_testinternalcapi`.
files:
M Python/hamt.c
diff --git a/Python/hamt.c b/Python/hamt.c
index 906149cc6cdbdc..e372b1a1b4c18b 100644
--- a/Python/hamt.c
+++ b/Python/hamt.c
@@ -256,9 +256,9 @@ Debug
=
The HAMT datatype is accessible for testing purposes under the
-`_testcapi` module:
+`_testinternalcapi` module:
->>> from _testcapi import hamt
+>>> from _testinternalcapi import hamt
>>> h = hamt()
>>> h2 = h.set('a', 2)
>>> h3 = h2.set('b', 3)
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] [3.13] gh-137583: Only lock the SSL context, not the SSL socket (GH-137588) (GH-137613)
https://github.com/python/cpython/commit/da39cb9716a5fd781e5ded25f0f203462c88aa02
commit: da39cb9716a5fd781e5ded25f0f203462c88aa02
branch: 3.13
author: Peter Bierma
committer: ZeroIntensity
date: 2025-08-11T22:05:13-04:00
summary:
[3.13] gh-137583: Only lock the SSL context, not the SSL socket (GH-137588)
(GH-137613)
Fixes a deadlock introduced in 3.13.6.
(cherry picked from commit 55788a90967e82a9ea05b45c06a293b46ec53d72)
files:
A Misc/NEWS.d/next/Library/2025-08-09-08-53-32.gh-issue-137583.s6OZud.rst
M Lib/test/test_ssl.py
M Modules/_ssl.c
M Modules/_ssl/debughelpers.c
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 36f2fdddc96233..37766288a3c1a5 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -4584,6 +4584,42 @@ def server_callback(identity):
with client_context.wrap_socket(socket.socket()) as s:
s.connect((HOST, server.port))
+def test_thread_recv_while_main_thread_sends(self):
+# GH-137583: Locking was added to calls to send() and recv() on SSL
+# socket objects. This seemed fine at the surface level because those
+# calls weren't re-entrant, but recv() calls would implicitly mimick
+# holding a lock by blocking until it received data. This means that
+# if a thread started to infinitely block until data was received,
calls
+# to send() would deadlock, because it would wait forever on the lock
+# that the recv() call held.
+data = b"1" * 1024
+event = threading.Event()
+def background(sock):
+event.set()
+received = sock.recv(len(data))
+self.assertEqual(received, data)
+
+client_context, server_context, hostname = testing_context()
+server = ThreadedEchoServer(context=server_context)
+with server:
+with client_context.wrap_socket(socket.socket(),
+server_hostname=hostname) as sock:
+sock.connect((HOST, server.port))
+sock.settimeout(1)
+sock.setblocking(1)
+# Ensure that the server is ready to accept requests
+sock.sendall(b"123")
+self.assertEqual(sock.recv(3), b"123")
+with threading_helper.catch_threading_exception() as cm:
+thread = threading.Thread(target=background,
+ args=(sock,), daemon=True)
+thread.start()
+event.wait()
+sock.sendall(data)
+thread.join()
+if cm.exc_value is not None:
+raise cm.exc_value
+
@unittest.skipUnless(has_tls_version('TLSv1_3'), "Test needs TLS 1.3")
class TestPostHandshakeAuth(unittest.TestCase):
diff --git
a/Misc/NEWS.d/next/Library/2025-08-09-08-53-32.gh-issue-137583.s6OZud.rst
b/Misc/NEWS.d/next/Library/2025-08-09-08-53-32.gh-issue-137583.s6OZud.rst
new file mode 100644
index 00..3843cc7c8c5524
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-08-09-08-53-32.gh-issue-137583.s6OZud.rst
@@ -0,0 +1,4 @@
+Fix a deadlock introduced in 3.13.6 when a call to
+:meth:`ssl.SSLSocket.recv ` was blocked in one thread,
+and then another method on the object (such as :meth:`ssl.SSLSocket.send
`)
+was subsequently called in another thread.
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 981c3d6a936ec8..fd8c16b92547c8 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -332,9 +332,6 @@ typedef struct {
* and shutdown methods check for chained exceptions.
*/
PyObject *exc;
-/* Lock to synchronize calls when the thread state is detached.
- See also gh-134698. */
-PyMutex tstate_mutex;
} PySSLSocket;
typedef struct {
@@ -846,7 +843,6 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject
*sock,
self->server_hostname = NULL;
self->err = err;
self->exc = NULL;
-self->tstate_mutex = (PyMutex){0};
/* Make sure the SSL error state is initialized */
ERR_clear_error();
@@ -919,12 +915,12 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject
*sock,
BIO_set_nbio(SSL_get_wbio(self->ssl), 1);
}
-PySSL_BEGIN_ALLOW_THREADS(self)
+Py_BEGIN_ALLOW_THREADS;
if (socket_type == PY_SSL_CLIENT)
SSL_set_connect_state(self->ssl);
else
SSL_set_accept_state(self->ssl);
-PySSL_END_ALLOW_THREADS(self)
+Py_END_ALLOW_THREADS;
self->socket_type = socket_type;
if (sock != NULL) {
@@ -993,10 +989,11 @@ _ssl__SSLSocket_do_handshake_impl(PySSLSocket *self)
/* Actually negotiate SSL connection */
/* XXX If SSL_do_handshake() returns 0, it's also a failure. */
do {
-PySSL_BEGIN_ALLOW_THREADS(self)
+Py_BEGIN_ALLOW_THREADS
ret = SSL_do_handshake(self->ssl);
[Python-checkins] [3.13] gh-44538: Mention nested classes/functions in doctest docs (GH-137870) (GH-137917)
https://github.com/python/cpython/commit/d1882577a32125870c0bc8030d90221068b6b071 commit: d1882577a32125870c0bc8030d90221068b6b071 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-08-18T15:05:12Z summary: [3.13] gh-44538: Mention nested classes/functions in doctest docs (GH-137870) (GH-137917) gh-44538: Mention nested classes/functions in doctest docs (GH-137870) (cherry picked from commit 138ed6db9f89171983dc32af4e7ad2e73d46a940) Co-authored-by: Bartosz Sławecki files: M Doc/library/doctest.rst diff --git a/Doc/library/doctest.rst b/Doc/library/doctest.rst index d1ccfc20981523..e6f89ea981acd8 100644 --- a/Doc/library/doctest.rst +++ b/Doc/library/doctest.rst @@ -346,6 +346,13 @@ searches them recursively for docstrings, which are then scanned for tests. Any classes found are recursively searched similarly, to test docstrings in their contained methods and nested classes. +.. note:: + + ``doctest`` can only automatically discover classes and functions that are + defined at the module level or inside other classes. + + Since nested classes and functions only exist when an outer function + is called, they cannot be discovered. Define them outside to make them visible. .. _doctest-finding-examples: ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-44538: Mention nested classes/functions in doctest docs (GH-137870)
https://github.com/python/cpython/commit/138ed6db9f89171983dc32af4e7ad2e73d46a940 commit: 138ed6db9f89171983dc32af4e7ad2e73d46a940 branch: main author: Bartosz Sławecki committer: ZeroIntensity date: 2025-08-18T10:58:23-04:00 summary: gh-44538: Mention nested classes/functions in doctest docs (GH-137870) files: M Doc/library/doctest.rst diff --git a/Doc/library/doctest.rst b/Doc/library/doctest.rst index 5a2c6bdd27c386..02b73ccd3f3d19 100644 --- a/Doc/library/doctest.rst +++ b/Doc/library/doctest.rst @@ -350,6 +350,13 @@ searches them recursively for docstrings, which are then scanned for tests. Any classes found are recursively searched similarly, to test docstrings in their contained methods and nested classes. +.. note:: + + ``doctest`` can only automatically discover classes and functions that are + defined at the module level or inside other classes. + + Since nested classes and functions only exist when an outer function + is called, they cannot be discovered. Define them outside to make them visible. .. _doctest-finding-examples: ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-131178: Add tests for `site` command-line interface (GH-133582)
https://github.com/python/cpython/commit/03f5519d776e28ffd0b8344ef328ecddf863fe0a commit: 03f5519d776e28ffd0b8344ef328ecddf863fe0a branch: main author: ggqlq <[email protected]> committer: ZeroIntensity date: 2025-08-15T14:00:43-04:00 summary: gh-131178: Add tests for `site` command-line interface (GH-133582) files: M Lib/test/test_site.py diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index d0e3294263557e..39c451fa41 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -13,6 +13,7 @@ from test.support import socket_helper from test.support import captured_stderr from test.support.os_helper import TESTFN, EnvironmentVarGuard +from test.support.script_helper import spawn_python, kill_python import ast import builtins import glob @@ -25,6 +26,7 @@ import sys import sysconfig import tempfile +from textwrap import dedent import urllib.error import urllib.request from unittest import mock @@ -803,5 +805,107 @@ def test_underpth_dll_file(self): self.assertTrue(rc, "sys.path is incorrect") +class CommandLineTests(unittest.TestCase): +def exists(self, path): +if path is not None and os.path.isdir(path): +return "exists" +else: +return "doesn't exist" + +def get_excepted_output(self, *args): +if len(args) == 0: +user_base = site.getuserbase() +user_site = site.getusersitepackages() +output = io.StringIO() +output.write("sys.path = [\n") +for dir in sys.path: +output.write("%r,\n" % (dir,)) +output.write("]\n") +output.write(f"USER_BASE: {user_base} ({self.exists(user_base)})\n") +output.write(f"USER_SITE: {user_site} ({self.exists(user_site)})\n") +output.write(f"ENABLE_USER_SITE: {site.ENABLE_USER_SITE}\n") +return 0, dedent(output.getvalue()).strip() + +buffer = [] +if '--user-base' in args: +buffer.append(site.getuserbase()) +if '--user-site' in args: +buffer.append(site.getusersitepackages()) + +if buffer: +return_code = 3 +if site.ENABLE_USER_SITE: +return_code = 0 +elif site.ENABLE_USER_SITE is False: +return_code = 1 +elif site.ENABLE_USER_SITE is None: +return_code = 2 +output = os.pathsep.join(buffer) +return return_code, os.path.normpath(dedent(output).strip()) +else: +return 10, None + +def invoke_command_line(self, *args): +args = ["-m", "site", *args] + +with EnvironmentVarGuard() as env: +env["PYTHONUTF8"] = "1" +env["PYTHONIOENCODING"] = "utf-8" +proc = spawn_python(*args, text=True, env=env, +encoding='utf-8', errors='replace') + +output = kill_python(proc) +return_code = proc.returncode +return return_code, os.path.normpath(dedent(output).strip()) + [email protected]_subprocess() +def test_no_args(self): +return_code, output = self.invoke_command_line() +excepted_return_code, _ = self.get_excepted_output() +self.assertEqual(return_code, excepted_return_code) +lines = output.splitlines() +self.assertEqual(lines[0], "sys.path = [") +self.assertEqual(lines[-4], "]") +excepted_base = f"USER_BASE: '{site.getuserbase()}'" +\ +f" ({self.exists(site.getuserbase())})" +self.assertEqual(lines[-3], excepted_base) +excepted_site = f"USER_SITE: '{site.getusersitepackages()}'" +\ +f" ({self.exists(site.getusersitepackages())})" +self.assertEqual(lines[-2], excepted_site) +self.assertEqual(lines[-1], f"ENABLE_USER_SITE: {site.ENABLE_USER_SITE}") + [email protected]_subprocess() +def test_unknown_args(self): +return_code, output = self.invoke_command_line("--unknown-arg") +excepted_return_code, _ = self.get_excepted_output("--unknown-arg") +self.assertEqual(return_code, excepted_return_code) +self.assertIn('[--user-base] [--user-site]', output) + [email protected]_subprocess() +def test_base_arg(self): +return_code, output = self.invoke_command_line("--user-base") +excepted = self.get_excepted_output("--user-base") +excepted_return_code, excepted_output = excepted +self.assertEqual(return_code, excepted_return_code) +self.assertEqual(output, excepted_output) + [email protected]_s
[Python-checkins] gh-139098: Use multiphase initialization in `_testcapi` (GH-139102)
https://github.com/python/cpython/commit/49f1c302df2621dcc2aa0386d90ed8502e0ed024
commit: 49f1c302df2621dcc2aa0386d90ed8502e0ed024
branch: main
author: Peter Bierma
committer: ZeroIntensity
date: 2025-09-18T11:00:50Z
summary:
gh-139098: Use multiphase initialization in `_testcapi` (GH-139102)
Use multiphase initialization in the _testcapi module to allow loading in
subinterpreters. The isolation here isn't perfect as there's still some use of
globals, but _testcapi should generally work in other interpreters.
files:
M Modules/_testcapi/heaptype.c
M Modules/_testcapimodule.c
diff --git a/Modules/_testcapi/heaptype.c b/Modules/_testcapi/heaptype.c
index 257e0256655976..69dcf072da1815 100644
--- a/Modules/_testcapi/heaptype.c
+++ b/Modules/_testcapi/heaptype.c
@@ -782,10 +782,7 @@ heapctypesubclasswithfinalizer_finalize(PyObject *self)
/* Save the current exception, if any. */
PyObject *exc = PyErr_GetRaisedException();
-if (_testcapimodule == NULL) {
-goto cleanup_finalize;
-}
-PyObject *m = PyState_FindModule(_testcapimodule);
+PyObject *m = PyType_GetModule(Py_TYPE(self));
if (m == NULL) {
goto cleanup_finalize;
}
@@ -1402,8 +1399,8 @@ _PyTestCapi_Init_Heaptype(PyObject *m) {
if (subclass_with_finalizer_bases == NULL) {
return -1;
}
-PyObject *HeapCTypeSubclassWithFinalizer = PyType_FromSpecWithBases(
-&HeapCTypeSubclassWithFinalizer_spec, subclass_with_finalizer_bases);
+PyObject *HeapCTypeSubclassWithFinalizer = PyType_FromModuleAndSpec(
+m, &HeapCTypeSubclassWithFinalizer_spec,
subclass_with_finalizer_bases);
Py_DECREF(subclass_with_finalizer_bases);
ADD("HeapCTypeSubclassWithFinalizer", HeapCTypeSubclassWithFinalizer);
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index c80a780e22ca34..a5c4604056ab4e 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -3243,75 +3243,56 @@ create_managed_dict_type(void)
return PyType_FromSpec(&ManagedDict_spec);
}
-static struct PyModuleDef _testcapimodule = {
-PyModuleDef_HEAD_INIT,
-.m_name = "_testcapi",
-.m_size = sizeof(testcapistate_t),
-.m_methods = TestMethods,
-};
-
-/* Per PEP 489, this module will not be converted to multi-phase initialization
- */
-
-PyMODINIT_FUNC
-PyInit__testcapi(void)
+static int
+_testcapi_exec(PyObject *m)
{
-PyObject *m;
-
-m = PyModule_Create(&_testcapimodule);
-if (m == NULL)
-return NULL;
-#ifdef Py_GIL_DISABLED
-PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
-#endif
-
Py_SET_TYPE(&_HashInheritanceTester_Type, &PyType_Type);
if (PyType_Ready(&_HashInheritanceTester_Type) < 0) {
-return NULL;
+return -1;
}
if (PyType_Ready(&matmulType) < 0)
-return NULL;
+return -1;
Py_INCREF(&matmulType);
PyModule_AddObject(m, "matmulType", (PyObject *)&matmulType);
if (PyType_Ready(&ipowType) < 0) {
-return NULL;
+return -1;
}
Py_INCREF(&ipowType);
PyModule_AddObject(m, "ipowType", (PyObject *)&ipowType);
if (PyType_Ready(&awaitType) < 0)
-return NULL;
+return -1;
Py_INCREF(&awaitType);
PyModule_AddObject(m, "awaitType", (PyObject *)&awaitType);
MyList_Type.tp_base = &PyList_Type;
if (PyType_Ready(&MyList_Type) < 0)
-return NULL;
+return -1;
Py_INCREF(&MyList_Type);
PyModule_AddObject(m, "MyList", (PyObject *)&MyList_Type);
if (PyType_Ready(&GenericAlias_Type) < 0)
-return NULL;
+return -1;
Py_INCREF(&GenericAlias_Type);
PyModule_AddObject(m, "GenericAlias", (PyObject *)&GenericAlias_Type);
if (PyType_Ready(&Generic_Type) < 0)
-return NULL;
+return -1;
Py_INCREF(&Generic_Type);
PyModule_AddObject(m, "Generic", (PyObject *)&Generic_Type);
if (PyType_Ready(&MethInstance_Type) < 0)
-return NULL;
+return -1;
Py_INCREF(&MethInstance_Type);
PyModule_AddObject(m, "MethInstance", (PyObject *)&MethInstance_Type);
if (PyType_Ready(&MethClass_Type) < 0)
-return NULL;
+return -1;
Py_INCREF(&MethClass_Type);
PyModule_AddObject(m, "MethClass", (PyObject *)&MethClass_Type);
if (PyType_Ready(&MethStatic_Type) < 0)
-return NULL;
+return -1;
Py_INCREF(&MethStatic_Type);
PyModule_AddObject(m, "MethStatic", (PyObject *)&MethStatic_Type);
@@ -3354,13 +3335,13 @@ PyInit__testcapi(void)
PyModule_AddObject(m, "UINT64_MAX", PyLong_FromUInt64(UINT64_MAX));
if (PyModule_AddIntMacro(m, Py_single_input)) {
-return
[Python-checkins] gh-135729: Store reference to globals in `Interpreter._decref` (GH-139104)
https://github.com/python/cpython/commit/571210b8f34a54922e5eb11d65060d7a77b8bdf0 commit: 571210b8f34a54922e5eb11d65060d7a77b8bdf0 branch: main author: Peter Bierma committer: ZeroIntensity date: 2025-09-18T11:17:51Z summary: gh-135729: Store reference to globals in `Interpreter._decref` (GH-139104) files: A Misc/NEWS.d/next/Library/2025-09-18-05-32-18.gh-issue-135729.8AmMza.rst M Lib/concurrent/interpreters/__init__.py M Lib/test/test_interpreters/test_api.py diff --git a/Lib/concurrent/interpreters/__init__.py b/Lib/concurrent/interpreters/__init__.py index aa46a2b37a48d5..ea4147ee9a25da 100644 --- a/Lib/concurrent/interpreters/__init__.py +++ b/Lib/concurrent/interpreters/__init__.py @@ -149,12 +149,17 @@ def __del__(self): def __reduce__(self): return (type(self), (self._id,)) -def _decref(self): +# gh-135729: Globals might be destroyed by the time this is called, so we +# need to keep references ourself +def _decref(self, *, +InterpreterNotFoundError=InterpreterNotFoundError, +_interp_decref=_interpreters.decref, +): if not self._ownsref: return self._ownsref = False try: -_interpreters.decref(self._id) +_interp_decref(self._id) except InterpreterNotFoundError: pass diff --git a/Lib/test/test_interpreters/test_api.py b/Lib/test/test_interpreters/test_api.py index 3fee98ea93e637..1f38a43be51e7a 100644 --- a/Lib/test/test_interpreters/test_api.py +++ b/Lib/test/test_interpreters/test_api.py @@ -419,6 +419,22 @@ def test_pickle(self): unpickled = pickle.loads(data) self.assertEqual(unpickled, interp) [email protected]_subprocess() +@force_not_colorized +def test_cleanup_in_repl(self): +# GH-135729: Using a subinterpreter in the REPL would lead to an unraisable +# exception during finalization +repl = script_helper.spawn_python("-i") +script = b"""if True: +from concurrent import interpreters +interpreters.create() +exit()""" +stdout, stderr = repl.communicate(script) +self.assertIsNone(stderr) +self.assertIn(b"remaining subinterpreters", stdout) +self.assertNotIn(b"Traceback", stdout) + + class TestInterpreterIsRunning(TestBase): diff --git a/Misc/NEWS.d/next/Library/2025-09-18-05-32-18.gh-issue-135729.8AmMza.rst b/Misc/NEWS.d/next/Library/2025-09-18-05-32-18.gh-issue-135729.8AmMza.rst new file mode 100644 index 00..1777839a1bf633 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-09-18-05-32-18.gh-issue-135729.8AmMza.rst @@ -0,0 +1,2 @@ +Fix unraisable exception during finalization when using +:mod:`concurrent.interpreters` in the REPL. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] [3.13] gh-112729: Correctly fail when the process is out of memory during interpreter creation (GH-139164) (GH-139169)
https://github.com/python/cpython/commit/63dd27da3ba17a9584907cf179c0f33ba92de98a
commit: 63dd27da3ba17a9584907cf179c0f33ba92de98a
branch: 3.13
author: Peter Bierma
committer: ZeroIntensity
date: 2025-09-19T15:09:44Z
summary:
[3.13] gh-112729: Correctly fail when the process is out of memory during
interpreter creation (GH-139164) (GH-139169)
* gh-112729: Correctly fail when the process is out of memory during
interpreter creation (GH-139164)
(cherry picked from commit d06113c7a7cac76a28847702685e601b79f71bf8)
files:
A Misc/NEWS.d/next/Library/2025-09-19-09-36-42.gh-issue-112729.mmty0_.rst
M Lib/test/test_interpreters/test_stress.py
M Python/pylifecycle.c
diff --git a/Lib/test/test_interpreters/test_stress.py
b/Lib/test/test_interpreters/test_stress.py
index fae2f38cb5534b..a39c9352f728d3 100644
--- a/Lib/test/test_interpreters/test_stress.py
+++ b/Lib/test/test_interpreters/test_stress.py
@@ -7,6 +7,7 @@
# Raise SkipTest if subinterpreters not supported.
import_helper.import_module('_interpreters')
from test.support import interpreters
+from test.support.interpreters import InterpreterError
from .utils import TestBase
@@ -74,6 +75,14 @@ def run():
start.set()
support.gc_collect()
+def test_create_interpreter_no_memory(self):
+import _interpreters
+_testcapi = import_helper.import_module("_testcapi")
+
+with self.assertRaises(InterpreterError):
+_testcapi.set_nomemory(0, 1)
+_interpreters.create()
+
if __name__ == '__main__':
# Test needs to be a package, so we can do relative imports.
diff --git
a/Misc/NEWS.d/next/Library/2025-09-19-09-36-42.gh-issue-112729.mmty0_.rst
b/Misc/NEWS.d/next/Library/2025-09-19-09-36-42.gh-issue-112729.mmty0_.rst
new file mode 100644
index 00..07485fcf9f1a58
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-09-19-09-36-42.gh-issue-112729.mmty0_.rst
@@ -0,0 +1,2 @@
+Fix crash when calling ``_interpreters.create`` when the
+process is out of memory.
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 01fd36e52fc11e..8cc6bd0fa78906 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -2301,18 +2301,17 @@ new_interpreter(PyThreadState **tstate_p,
interpreters: disable PyGILState_Check(). */
runtime->gilstate.check_enabled = 0;
-PyInterpreterState *interp = PyInterpreterState_New();
+// XXX Might new_interpreter() have been called without the GIL held?
+PyThreadState *save_tstate = _PyThreadState_GET();
+PyThreadState *tstate = NULL;
+PyInterpreterState *interp;
+status = _PyInterpreterState_New(save_tstate, &interp);
if (interp == NULL) {
-*tstate_p = NULL;
-return _PyStatus_OK();
+goto error;
}
_PyInterpreterState_SetWhence(interp, whence);
interp->_ready = 1;
-// XXX Might new_interpreter() have been called without the GIL held?
-PyThreadState *save_tstate = _PyThreadState_GET();
-PyThreadState *tstate = NULL;
-
/* From this point until the init_interp_create_gil() call,
we must not do anything that requires that the GIL be held
(or otherwise exist). That applies whether or not the new
@@ -2388,7 +2387,7 @@ new_interpreter(PyThreadState **tstate_p,
*tstate_p = NULL;
if (tstate != NULL) {
Py_EndInterpreter(tstate);
-} else {
+} else if (interp != NULL) {
PyInterpreterState_Delete(interp);
}
if (save_tstate != NULL) {
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] gh-138479: Ensure that `__typing_subst__` returns a tuple (GH-138482)
https://github.com/python/cpython/commit/1da989be74eaa94590ec28e750e5352de1ead227
commit: 1da989be74eaa94590ec28e750e5352de1ead227
branch: main
author: Peter Bierma
committer: ZeroIntensity
date: 2025-09-11T06:39:09-04:00
summary:
gh-138479: Ensure that `__typing_subst__` returns a tuple (GH-138482)
Raise an exception if __typing_subst__ returns a non-tuple object.
-
Co-authored-by: Serhiy Storchaka
files:
A
Misc/NEWS.d/next/Core_and_Builtins/2025-09-03-17-00-30.gh-issue-138479.qUxgWs.rst
M Lib/test/test_typing.py
M Objects/genericaliasobject.c
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 0fc5415c390145..8238c62f0715f8 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -5844,6 +5844,23 @@ class A:
with self.assertRaises(TypeError):
a[int]
+def test_return_non_tuple_while_unpacking(self):
+# GH-138497: GenericAlias objects didn't ensure that __typing_subst__
actually
+# returned a tuple
+class EvilTypeVar:
+__typing_is_unpacked_typevartuple__ = True
+def __typing_prepare_subst__(*_):
+return None # any value
+def __typing_subst__(*_):
+return 42 # not tuple
+
+evil = EvilTypeVar()
+# Create a dummy TypeAlias that will be given the evil generic from
+# above.
+type type_alias[*_] = 0
+with self.assertRaisesRegex(TypeError,
".+__typing_subst__.+tuple.+int.*"):
+type_alias[evil][0]
+
class ClassVarTests(BaseTestCase):
diff --git
a/Misc/NEWS.d/next/Core_and_Builtins/2025-09-03-17-00-30.gh-issue-138479.qUxgWs.rst
b/Misc/NEWS.d/next/Core_and_Builtins/2025-09-03-17-00-30.gh-issue-138479.qUxgWs.rst
new file mode 100644
index 00..c94640af3b053c
--- /dev/null
+++
b/Misc/NEWS.d/next/Core_and_Builtins/2025-09-03-17-00-30.gh-issue-138479.qUxgWs.rst
@@ -0,0 +1,2 @@
+Fix a crash when a generic object's ``__typing_subst__`` returns an object
+that isn't a :class:`tuple`.
diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c
index b3ff933c9b584e..8b526f43f1e053 100644
--- a/Objects/genericaliasobject.c
+++ b/Objects/genericaliasobject.c
@@ -525,12 +525,24 @@ _Py_subs_parameters(PyObject *self, PyObject *args,
PyObject *parameters, PyObje
return NULL;
}
if (unpack) {
+if (!PyTuple_Check(arg)) {
+Py_DECREF(newargs);
+Py_DECREF(item);
+Py_XDECREF(tuple_args);
+PyObject *original = PyTuple_GET_ITEM(args, iarg);
+PyErr_Format(PyExc_TypeError,
+ "expected __typing_subst__ of %T objects to
return a tuple, not %T",
+ original, arg);
+Py_DECREF(arg);
+return NULL;
+}
jarg = tuple_extend(&newargs, jarg,
&PyTuple_GET_ITEM(arg, 0), PyTuple_GET_SIZE(arg));
Py_DECREF(arg);
if (jarg < 0) {
Py_DECREF(item);
Py_XDECREF(tuple_args);
+assert(newargs == NULL);
return NULL;
}
}
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] gh-112729: Correctly fail when the process is out of memory during interpreter creation (GH-139164)
https://github.com/python/cpython/commit/d06113c7a7cac76a28847702685e601b79f71bf8
commit: d06113c7a7cac76a28847702685e601b79f71bf8
branch: main
author: Peter Bierma
committer: ZeroIntensity
date: 2025-09-19T10:41:09-04:00
summary:
gh-112729: Correctly fail when the process is out of memory during interpreter
creation (GH-139164)
files:
A Misc/NEWS.d/next/Library/2025-09-19-09-36-42.gh-issue-112729.mmty0_.rst
M Lib/test/test_interpreters/test_stress.py
M Python/pylifecycle.c
diff --git a/Lib/test/test_interpreters/test_stress.py
b/Lib/test/test_interpreters/test_stress.py
index e25e67a0d4f445..6b40a536bd3c31 100644
--- a/Lib/test/test_interpreters/test_stress.py
+++ b/Lib/test/test_interpreters/test_stress.py
@@ -7,6 +7,7 @@
# Raise SkipTest if subinterpreters not supported.
import_helper.import_module('_interpreters')
from concurrent import interpreters
+from concurrent.interpreters import InterpreterError
from .utils import TestBase
@@ -74,6 +75,14 @@ def run():
start.set()
support.gc_collect()
+def test_create_interpreter_no_memory(self):
+import _interpreters
+_testcapi = import_helper.import_module("_testcapi")
+
+with self.assertRaises(InterpreterError):
+_testcapi.set_nomemory(0, 1)
+_interpreters.create()
+
if __name__ == '__main__':
# Test needs to be a package, so we can do relative imports.
diff --git
a/Misc/NEWS.d/next/Library/2025-09-19-09-36-42.gh-issue-112729.mmty0_.rst
b/Misc/NEWS.d/next/Library/2025-09-19-09-36-42.gh-issue-112729.mmty0_.rst
new file mode 100644
index 00..950853a696f315
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-09-19-09-36-42.gh-issue-112729.mmty0_.rst
@@ -0,0 +1,2 @@
+Fix crash when calling :func:`concurrent.interpreters.create` when the
+process is out of memory.
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 37231889740609..37af58a68d7883 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -2411,18 +2411,17 @@ new_interpreter(PyThreadState **tstate_p,
interpreters: disable PyGILState_Check(). */
runtime->gilstate.check_enabled = 0;
-PyInterpreterState *interp = PyInterpreterState_New();
+// XXX Might new_interpreter() have been called without the GIL held?
+PyThreadState *save_tstate = _PyThreadState_GET();
+PyThreadState *tstate = NULL;
+PyInterpreterState *interp;
+status = _PyInterpreterState_New(save_tstate, &interp);
if (interp == NULL) {
-*tstate_p = NULL;
-return _PyStatus_OK();
+goto error;
}
_PyInterpreterState_SetWhence(interp, whence);
interp->_ready = 1;
-// XXX Might new_interpreter() have been called without the GIL held?
-PyThreadState *save_tstate = _PyThreadState_GET();
-PyThreadState *tstate = NULL;
-
/* From this point until the init_interp_create_gil() call,
we must not do anything that requires that the GIL be held
(or otherwise exist). That applies whether or not the new
@@ -2498,7 +2497,7 @@ new_interpreter(PyThreadState **tstate_p,
*tstate_p = NULL;
if (tstate != NULL) {
Py_EndInterpreter(tstate);
-} else {
+} else if (interp != NULL) {
PyInterpreterState_Delete(interp);
}
if (save_tstate != NULL) {
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] [3.13] Document `Py_AddPendingCall()` change with subinterpreters in 3.12 (GH-139117) (GH-139119)
https://github.com/python/cpython/commit/24b699231bba785d30309969fec9a049b2a294ac commit: 24b699231bba785d30309969fec9a049b2a294ac branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: ZeroIntensity date: 2025-09-18T12:17:06Z summary: [3.13] Document `Py_AddPendingCall()` change with subinterpreters in 3.12 (GH-139117) (GH-139119) Document `Py_AddPendingCall()` change with subinterpreters in 3.12 (GH-139117) Prior to 3.9, Py_AddPendingCall() would always run pending calls in the main interpreter, but then each interpreter got their own ceval state, and they were scheduled for any interpreter. In GH-104813, this was undone, so Py_AddPendingCall() would always schedule for the main interpreter. (cherry picked from commit 89ff88be89328964dbc50a474a84c566fe920b46) Co-authored-by: Peter Bierma files: M Doc/c-api/init.rst diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 7669d194d8b130..211b902ad1e4e4 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -1944,6 +1944,10 @@ pointer and a void pointer argument. called from the main interpreter. Each subinterpreter now has its own list of scheduled calls. + .. versionchanged:: 3.12 + This function now always schedules *func* to be run in the main + interpreter. + .. _profiling: Profiling and Tracing ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
[Python-checkins] gh-126016: Remove bad assertion in `PyThreadState_Clear` (GH-139158)
https://github.com/python/cpython/commit/9243a4b93397f04237a5112011ee03433eda0462
commit: 9243a4b93397f04237a5112011ee03433eda0462
branch: main
author: Peter Bierma
committer: ZeroIntensity
date: 2025-09-19T12:17:05Z
summary:
gh-126016: Remove bad assertion in `PyThreadState_Clear` (GH-139158)
In the _interpreters module, we use PyEval_EvalCode() to run Python code in
another interpreter. However, when the process receives a KeyboardInterrupt,
PyEval_EvalCode() will jump straight to finalization rather than returning.
This prevents us from cleaning up and marking the thread as "not running main",
which triggers an assertion in PyThreadState_Clear() on debug builds. Since
everything else works as intended, remove that assertion.
files:
A Misc/NEWS.d/next/Library/2025-09-19-07-41-52.gh-issue-126016.Uz9W6h.rst
M Lib/test/test_interpreters/test_api.py
M Python/pystate.c
diff --git a/Lib/test/test_interpreters/test_api.py
b/Lib/test/test_interpreters/test_api.py
index 1f38a43be51e7a..8e9f1c3204a8bb 100644
--- a/Lib/test/test_interpreters/test_api.py
+++ b/Lib/test/test_interpreters/test_api.py
@@ -1,6 +1,7 @@
import contextlib
import os
import pickle
+import signal
import sys
from textwrap import dedent
import threading
@@ -11,7 +12,7 @@
from test.support import os_helper
from test.support import script_helper
from test.support import import_helper
-from test.support.script_helper import assert_python_ok
+from test.support.script_helper import assert_python_ok, spawn_python
# Raise SkipTest if subinterpreters not supported.
_interpreters = import_helper.import_module('_interpreters')
from concurrent import interpreters
@@ -434,6 +435,31 @@ def test_cleanup_in_repl(self):
self.assertIn(b"remaining subinterpreters", stdout)
self.assertNotIn(b"Traceback", stdout)
[email protected]_subprocess()
[email protected](os.name == 'nt', "signals don't work well on windows")
+def test_keyboard_interrupt_in_thread_running_interp(self):
+import subprocess
+source = f"""if True:
+from concurrent import interpreters
+from threading import Thread
+
+def test():
+import time
+print('a', flush=True, end='')
+time.sleep(10)
+
+interp = interpreters.create()
+interp.call_in_thread(test)
+"""
+
+with spawn_python("-c", source, stderr=subprocess.PIPE) as proc:
+self.assertEqual(proc.stdout.read(1), b'a')
+proc.send_signal(signal.SIGINT)
+proc.stderr.flush()
+error = proc.stderr.read()
+self.assertIn(b"KeyboardInterrupt", error)
+retcode = proc.wait()
+self.assertEqual(retcode, 0)
class TestInterpreterIsRunning(TestBase):
diff --git
a/Misc/NEWS.d/next/Library/2025-09-19-07-41-52.gh-issue-126016.Uz9W6h.rst
b/Misc/NEWS.d/next/Library/2025-09-19-07-41-52.gh-issue-126016.Uz9W6h.rst
new file mode 100644
index 00..feb09294bec982
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-09-19-07-41-52.gh-issue-126016.Uz9W6h.rst
@@ -0,0 +1,2 @@
+Fix an assertion failure when sending :exc:`KeyboardInterrupt` to a Python
+process running a subinterpreter in a separate thread.
diff --git a/Python/pystate.c b/Python/pystate.c
index 29c713dccc9fe8..dbed609f29aa07 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -1625,7 +1625,11 @@ PyThreadState_Clear(PyThreadState *tstate)
{
assert(tstate->_status.initialized && !tstate->_status.cleared);
assert(current_fast_get()->interp == tstate->interp);
-assert(!_PyThreadState_IsRunningMain(tstate));
+// GH-126016: In the _interpreters module, KeyboardInterrupt exceptions
+// during PyEval_EvalCode() are sent to finalization, which doesn't let us
+// mark threads as "not running main". So, for now this assertion is
+// disabled.
+// XXX assert(!_PyThreadState_IsRunningMain(tstate));
// XXX assert(!tstate->_status.bound || tstate->_status.unbound);
tstate->_status.finalizing = 1; // just in case
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] [3.13] gh-134163: Fix an infinite loop when the process runs out of memory in a `try` block (GH-138491)
https://github.com/python/cpython/commit/afec6a546049b80fdbaf18baa3a4d2cbc535ce58
commit: afec6a546049b80fdbaf18baa3a4d2cbc535ce58
branch: 3.13
author: yihong
committer: ZeroIntensity
date: 2025-09-10T12:54:42-04:00
summary:
[3.13] gh-134163: Fix an infinite loop when the process runs out of memory in a
`try` block (GH-138491)
Signed-off-by: yihong0618
Co-authored-by: Peter Bierma
files:
A
Misc/NEWS.d/next/Core_and_Builtins/2025-09-04-11-52-23.gh-issue-134163.EqKyn8.rst
M Lib/test/test_exceptions.py
M Python/ceval.c
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index c91f66629483e5..939783956d62d6 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -1843,6 +1843,38 @@ def test_memory_error_in_subinterp(self):
rc, _, err = script_helper.assert_python_ok("-c", code)
self.assertIn(b'MemoryError', err)
+@cpython_only
+# Python built with Py_TRACE_REFS fail with a fatal error in
+# _PyRefchain_Trace() on memory allocation error.
[email protected](support.Py_TRACE_REFS, 'cannot test Py_TRACE_REFS build')
+def test_exec_set_nomemory_hang(self):
+import_module("_testcapi")
+# gh-134163: A MemoryError inside code that was wrapped by a try/except
+# block would lead to an infinite loop.
+
+# The frame_lasti needs to be greater than 257 to prevent
+# PyLong_FromLong() from returning cached integers, which
+# don't require a memory allocation. Prepend some dummy code
+# to artificially increase the instruction index.
+warmup_code = "a = list(range(0, 1))\n" * 20
+user_input = warmup_code + dedent("""
+try:
+import _testcapi
+_testcapi.set_nomemory(0)
+b = list(range(1000, 2000))
+except Exception as e:
+import traceback
+traceback.print_exc()
+""")
+with SuppressCrashReport():
+with script_helper.spawn_python('-c', user_input) as p:
+p.wait()
+output = p.stdout.read()
+
+self.assertIn(p.returncode, (0, 1))
+self.assertGreater(len(output), 0) # At minimum, should not hang
+self.assertIn(b"MemoryError", output)
+
class NameErrorTests(unittest.TestCase):
def test_name_error_has_name(self):
diff --git
a/Misc/NEWS.d/next/Core_and_Builtins/2025-09-04-11-52-23.gh-issue-134163.EqKyn8.rst
b/Misc/NEWS.d/next/Core_and_Builtins/2025-09-04-11-52-23.gh-issue-134163.EqKyn8.rst
new file mode 100644
index 00..24e8efda2b627d
--- /dev/null
+++
b/Misc/NEWS.d/next/Core_and_Builtins/2025-09-04-11-52-23.gh-issue-134163.EqKyn8.rst
@@ -0,0 +1 @@
+Fix a hang when the process is out of memory inside an exception handler.
diff --git a/Python/ceval.c b/Python/ceval.c
index 8c0cb29863cc60..511e39f0c2e2dd 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -912,7 +912,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate,
_PyInterpreterFrame *frame, int
int frame_lasti = _PyInterpreterFrame_LASTI(frame);
PyObject *lasti = PyLong_FromLong(frame_lasti);
if (lasti == NULL) {
-goto exception_unwind;
+// Instead of going back to exception_unwind (which would
cause
+// infinite recursion), directly exit to let the original
exception
+// propagate up and hopefully be handled at a higher level.
+_PyFrame_SetStackPointer(frame, stack_pointer);
+goto exit_unwind;
}
PUSH(lasti);
}
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
[Python-checkins] gh-136003: Execute pre-finalization callbacks in a loop (GH-136004)
https://github.com/python/cpython/commit/21914979335edee4f2b4d0afa5ba857a87b78bd1
commit: 21914979335edee4f2b4d0afa5ba857a87b78bd1
branch: main
author: Peter Bierma
committer: ZeroIntensity
date: 2025-09-18T08:29:12-04:00
summary:
gh-136003: Execute pre-finalization callbacks in a loop (GH-136004)
files:
A
Misc/NEWS.d/next/Core_and_Builtins/2025-06-26-18-44-34.gh-issue-136003.sln51d.rst
M Include/cpython/pystate.h
M Lib/test/test_atexit.py
M Lib/test/test_capi/test_misc.py
M Lib/threading.py
M Modules/_testinternalcapi.c
M Modules/_threadmodule.c
M Python/pylifecycle.c
M Python/pystate.c
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index bd9d8aaefe5400..ac8798ff6129a0 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -107,6 +107,7 @@ struct _ts {
# define _PyThreadState_WHENCE_THREADING 3
# define _PyThreadState_WHENCE_GILSTATE 4
# define _PyThreadState_WHENCE_EXEC 5
+# define _PyThreadState_WHENCE_THREADING_DAEMON 6
#endif
/* Currently holds the GIL. Must be its own field to avoid data races */
diff --git a/Lib/test/test_atexit.py b/Lib/test/test_atexit.py
index eb01da6e88a8bc..66142a108d5d93 100644
--- a/Lib/test/test_atexit.py
+++ b/Lib/test/test_atexit.py
@@ -79,6 +79,62 @@ def thready():
# want them to affect the rest of the tests.
script_helper.assert_python_ok("-c", textwrap.dedent(source))
+@threading_helper.requires_working_threading()
+def test_thread_created_in_atexit(self):
+source = """if True:
+import atexit
+import threading
+import time
+
+
+def run():
+print(24)
+time.sleep(1)
+print(42)
+
[email protected]
+def start_thread():
+threading.Thread(target=run).start()
+"""
+return_code, stdout, stderr = script_helper.assert_python_ok("-c",
source)
+self.assertEqual(return_code, 0)
+self.assertEqual(stdout,
f"24{os.linesep}42{os.linesep}".encode("utf-8"))
+self.assertEqual(stderr, b"")
+
+@threading_helper.requires_working_threading()
[email protected](hasattr(os, "pipe"), "requires os.pipe()")
+def test_thread_created_in_atexit_subinterpreter(self):
+try:
+from concurrent import interpreters
+except ImportError:
+self.skipTest("subinterpreters are not available")
+
+read, write = os.pipe()
+source = f"""if True:
+import atexit
+import threading
+import time
+import os
+
+def run():
+os.write({write}, b'spanish')
+time.sleep(1)
+os.write({write}, b'inquisition')
+
[email protected]
+def start_thread():
+threading.Thread(target=run).start()
+"""
+interp = interpreters.create()
+try:
+interp.exec(source)
+
+# Close the interpreter to invoke atexit callbacks
+interp.close()
+self.assertEqual(os.read(read, 100), b"spanishinquisition")
+finally:
+os.close(read)
+os.close(write)
@support.cpython_only
class SubinterpreterTest(unittest.TestCase):
diff --git a/Lib/test/test_capi/test_misc.py b/Lib/test/test_capi/test_misc.py
index ef950f5df04ad3..fe1287167d3e74 100644
--- a/Lib/test/test_capi/test_misc.py
+++ b/Lib/test/test_capi/test_misc.py
@@ -22,6 +22,7 @@
from test import support
from test.support import MISSING_C_DOCSTRINGS
from test.support import import_helper
+from test.support import script_helper
from test.support import threading_helper
from test.support import warnings_helper
from test.support import requires_limited_api
@@ -1641,6 +1642,36 @@ def subthread():
self.assertEqual(actual, int(interpid))
+@threading_helper.requires_working_threading()
+def test_pending_call_creates_thread(self):
+source = """
+import _testinternalcapi
+import threading
+import time
+
+
+def output():
+print(24)
+time.sleep(1)
+print(42)
+
+
+def callback():
+threading.Thread(target=output).start()
+
+
+def create_pending_call():
+time.sleep(1)
+_testinternalcapi.simple_pending_call(callback)
+
+
+threading.Thread(target=create_pending_call).start()
+"""
+return_code, stdout, stderr = script_helper.assert_python_ok('-c',
textwrap.dedent(source))
+self.assertEqual(return_code, 0)
+self.assertEqual(stdout,
f"24{os.linesep}42{os.linesep}".encode("utf-8"))
+self.assertEqual(stderr, b"")
+
class SubinterpreterTest(unittest.TestCase):
@@ -1949,6 +1980,41
[Python-checkins] Document `Py_AddPendingCall()` change with subinterpreters in 3.12 (GH-139117)
https://github.com/python/cpython/commit/89ff88be89328964dbc50a474a84c566fe920b46 commit: 89ff88be89328964dbc50a474a84c566fe920b46 branch: main author: Peter Bierma committer: ZeroIntensity date: 2025-09-18T12:10:41Z summary: Document `Py_AddPendingCall()` change with subinterpreters in 3.12 (GH-139117) Prior to 3.9, Py_AddPendingCall() would always run pending calls in the main interpreter, but then each interpreter got their own ceval state, and they were scheduled for any interpreter. In GH-104813, this was undone, so Py_AddPendingCall() would always schedule for the main interpreter. files: M Doc/c-api/init.rst diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 199b64387266bf..4b8884f48e8b28 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -1834,6 +1834,10 @@ pointer and a void pointer argument. called from the main interpreter. Each subinterpreter now has its own list of scheduled calls. + .. versionchanged:: 3.12 + This function now always schedules *func* to be run in the main + interpreter. + .. _profiling: Profiling and Tracing ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
