Skip to content

Commit ba36dc0

Browse files
authored
Merge branch 'main' into warnings-as-error-2
2 parents c06c3db + 3de7cc1 commit ba36dc0

File tree

11 files changed

+58
-45
lines changed

11 files changed

+58
-45
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.8.2
3+
rev: v0.9.1
44
hooks:
55
- id: ruff
66
name: Run Ruff (lint) on Doc/
@@ -29,12 +29,10 @@ repos:
2929
- id: black
3030
name: Run Black on Tools/build/check_warnings.py
3131
files: ^Tools/build/check_warnings.py
32-
language_version: python3.12
3332
args: [--line-length=79]
3433
- id: black
3534
name: Run Black on Tools/jit/
3635
files: ^Tools/jit/
37-
language_version: python3.12
3836

3937
- repo: https://github.com/pre-commit/pre-commit-hooks
4038
rev: v5.0.0
@@ -51,19 +49,19 @@ repos:
5149
types_or: [c, inc, python, rst]
5250

5351
- repo: https://github.com/python-jsonschema/check-jsonschema
54-
rev: 0.30.0
52+
rev: 0.31.0
5553
hooks:
5654
- id: check-dependabot
5755
- id: check-github-workflows
5856
- id: check-readthedocs
5957

6058
- repo: https://github.com/rhysd/actionlint
61-
rev: v1.7.4
59+
rev: v1.7.6
6260
hooks:
6361
- id: actionlint
6462

6563
- repo: https://github.com/woodruffw/zizmor-pre-commit
66-
rev: v0.8.0
64+
rev: v1.1.1
6765
hooks:
6866
- id: zizmor
6967

Doc/library/os.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5411,6 +5411,8 @@ information, consult your Unix manpages.
54115411
The following scheduling policies are exposed if they are supported by the
54125412
operating system.
54135413

5414+
.. _os-scheduling-policy:
5415+
54145416
.. data:: SCHED_OTHER
54155417

54165418
The default scheduling policy.
@@ -5514,7 +5516,7 @@ operating system.
55145516

55155517
.. function:: sched_yield()
55165518

5517-
Voluntarily relinquish the CPU.
5519+
Voluntarily relinquish the CPU. See :manpage:`sched_yield(2)` for details.
55185520

55195521

55205522
.. function:: sched_setaffinity(pid, mask, /)

Doc/library/time.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ Functions
385385
The suspension time may be longer than requested by an arbitrary amount,
386386
because of the scheduling of other activity in the system.
387387

388+
.. rubric:: Windows implementation
389+
388390
On Windows, if *secs* is zero, the thread relinquishes the remainder of its
389391
time slice to any other thread that is ready to run. If there are no other
390392
threads ready to run, the function returns immediately, and the thread
@@ -393,12 +395,19 @@ Functions
393395
<https://learn.microsoft.com/windows-hardware/drivers/kernel/high-resolution-timers>`_
394396
which provides resolution of 100 nanoseconds. If *secs* is zero, ``Sleep(0)`` is used.
395397

396-
Unix implementation:
398+
.. rubric:: Unix implementation
397399

398400
* Use ``clock_nanosleep()`` if available (resolution: 1 nanosecond);
399401
* Or use ``nanosleep()`` if available (resolution: 1 nanosecond);
400402
* Or use ``select()`` (resolution: 1 microsecond).
401403

404+
.. note::
405+
406+
To emulate a "no-op", use :keyword:`pass` instead of ``time.sleep(0)``.
407+
408+
To voluntarily relinquish the CPU, specify a real-time :ref:`scheduling
409+
policy <os-scheduling-policy>` and use :func:`os.sched_yield` instead.
410+
402411
.. audit-event:: time.sleep secs
403412

404413
.. versionchanged:: 3.5

Lib/csv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ class excel:
6363
written as two quotes
6464
"""
6565

66-
import re
6766
import types
6867
from _csv import Error, writer, reader, register_dialect, \
6968
unregister_dialect, get_dialect, list_dialects, \
@@ -281,6 +280,7 @@ def _guess_quote_and_delimiter(self, data, delimiters):
281280
If there is no quotechar the delimiter can't be determined
282281
this way.
283282
"""
283+
import re
284284

285285
matches = []
286286
for restr in (r'(?P<delim>[^\w\n"\'])(?P<space> ?)(?P<quote>["\']).*?(?P=quote)(?P=delim)', # ,".*?",

Lib/test/test_tracemalloc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,8 @@ def test_stop_untrack(self):
11031103

11041104
@unittest.skipIf(_testcapi is None, 'need _testcapi')
11051105
@threading_helper.requires_working_threading()
1106+
# gh-128679: Test crash on a debug build (especially on FreeBSD).
1107+
@unittest.skipIf(support.Py_DEBUG, 'need release build')
11061108
def test_tracemalloc_track_race(self):
11071109
# gh-128679: Test fix for tracemalloc.stop() race condition
11081110
_testcapi.tracemalloc_track_race()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Reduce the import time of :mod:`csv` by up to five times, by importing
2+
:mod:`re` on demand. In particular, ``re`` is no more implicitly exposed
3+
as ``csv.re``. Patch by Bénédikt Tran.

Modules/_threadmodule.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,12 +2450,12 @@ _thread_set_name_impl(PyObject *module, PyObject *name_obj)
24502450
return NULL;
24512451
}
24522452

2453-
#ifdef PYTHREAD_NAME_MAXLEN
2454-
// Truncate to PYTHREAD_NAME_MAXLEN bytes + the NUL byte if needed
2455-
if (PyBytes_GET_SIZE(name_encoded) > PYTHREAD_NAME_MAXLEN) {
2453+
#ifdef _PYTHREAD_NAME_MAXLEN
2454+
// Truncate to _PYTHREAD_NAME_MAXLEN bytes + the NUL byte if needed
2455+
if (PyBytes_GET_SIZE(name_encoded) > _PYTHREAD_NAME_MAXLEN) {
24562456
PyObject *truncated;
24572457
truncated = PyBytes_FromStringAndSize(PyBytes_AS_STRING(name_encoded),
2458-
PYTHREAD_NAME_MAXLEN);
2458+
_PYTHREAD_NAME_MAXLEN);
24592459
if (truncated == NULL) {
24602460
Py_DECREF(name_encoded);
24612461
return NULL;
@@ -2490,14 +2490,14 @@ _thread_set_name_impl(PyObject *module, PyObject *name_obj)
24902490
return NULL;
24912491
}
24922492

2493-
if (len > PYTHREAD_NAME_MAXLEN) {
2493+
if (len > _PYTHREAD_NAME_MAXLEN) {
24942494
// Truncate the name
2495-
Py_UCS4 ch = name[PYTHREAD_NAME_MAXLEN-1];
2495+
Py_UCS4 ch = name[_PYTHREAD_NAME_MAXLEN-1];
24962496
if (Py_UNICODE_IS_HIGH_SURROGATE(ch)) {
2497-
name[PYTHREAD_NAME_MAXLEN-1] = 0;
2497+
name[_PYTHREAD_NAME_MAXLEN-1] = 0;
24982498
}
24992499
else {
2500-
name[PYTHREAD_NAME_MAXLEN] = 0;
2500+
name[_PYTHREAD_NAME_MAXLEN] = 0;
25012501
}
25022502
}
25032503

@@ -2645,9 +2645,9 @@ thread_module_exec(PyObject *module)
26452645

26462646
llist_init(&state->shutdown_handles);
26472647

2648-
#ifdef PYTHREAD_NAME_MAXLEN
2648+
#ifdef _PYTHREAD_NAME_MAXLEN
26492649
if (PyModule_AddIntConstant(module, "_NAME_MAXLEN",
2650-
PYTHREAD_NAME_MAXLEN) < 0) {
2650+
_PYTHREAD_NAME_MAXLEN) < 0) {
26512651
return -1;
26522652
}
26532653
#endif

PC/pyconfig.h.in

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
753753
/* Define if libssl has X509_VERIFY_PARAM_set1_host and related function */
754754
#define HAVE_X509_VERIFY_PARAM_SET1_HOST 1
755755

756-
// Truncate the thread name to 64 characters. The OS limit is 32766 wide
757-
// characters, but long names aren't of practical use.
758-
#define PYTHREAD_NAME_MAXLEN 32766
756+
// Truncate the thread name to 32766 characters.
757+
#define _PYTHREAD_NAME_MAXLEN 32766
759758

760759
#endif /* !Py_CONFIG_H */

configure

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7539,19 +7539,19 @@ _RESTORE_VAR([CPPFLAGS])
75397539

75407540
# gh-59705: Maximum length in bytes of a thread name
75417541
case "$ac_sys_system" in
7542-
Linux*) PYTHREAD_NAME_MAXLEN=15;; # Linux and Android
7543-
SunOS*) PYTHREAD_NAME_MAXLEN=31;;
7544-
NetBSD*) PYTHREAD_NAME_MAXLEN=31;;
7545-
Darwin) PYTHREAD_NAME_MAXLEN=63;;
7546-
iOS) PYTHREAD_NAME_MAXLEN=63;;
7547-
FreeBSD*) PYTHREAD_NAME_MAXLEN=98;;
7548-
*) PYTHREAD_NAME_MAXLEN=;;
7542+
Linux*) _PYTHREAD_NAME_MAXLEN=15;; # Linux and Android
7543+
SunOS*) _PYTHREAD_NAME_MAXLEN=31;;
7544+
NetBSD*) _PYTHREAD_NAME_MAXLEN=31;;
7545+
Darwin) _PYTHREAD_NAME_MAXLEN=63;;
7546+
iOS) _PYTHREAD_NAME_MAXLEN=63;;
7547+
FreeBSD*) _PYTHREAD_NAME_MAXLEN=98;;
7548+
*) _PYTHREAD_NAME_MAXLEN=;;
75497549
esac
7550-
if test -n "$PYTHREAD_NAME_MAXLEN"; then
7551-
AC_DEFINE_UNQUOTED([PYTHREAD_NAME_MAXLEN], [$PYTHREAD_NAME_MAXLEN],
7550+
if test -n "$_PYTHREAD_NAME_MAXLEN"; then
7551+
AC_DEFINE_UNQUOTED([_PYTHREAD_NAME_MAXLEN], [$_PYTHREAD_NAME_MAXLEN],
75527552
[Maximum length in bytes of a thread name])
75537553
fi
7554-
AC_SUBST([PYTHREAD_NAME_MAXLEN])
7554+
AC_SUBST([_PYTHREAD_NAME_MAXLEN])
75557555

75567556

75577557
# stdlib

0 commit comments

Comments
 (0)