Skip to content

Commit 2cdfb41

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents fc1042f + 1c0a104 commit 2cdfb41

26 files changed

+224
-172
lines changed

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ check: _ensure-pre-commit
294294

295295
.PHONY: serve
296296
serve:
297-
@echo "The serve target was removed, use htmlview instead (see bpo-36329)"
297+
@echo "The serve target was removed, use htmllive instead (see gh-80510)"
298298

299299
# Targets for daily automated doc build
300300
# By default, Sphinx only rebuilds pages where the page content has changed.

Include/internal/pycore_interp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ struct _is {
130130
uint64_t next_unique_id;
131131
/* The linked list of threads, newest first. */
132132
PyThreadState *head;
133+
_PyThreadStateImpl *preallocated;
133134
/* The thread currently executing in the __main__ module, if any. */
134135
PyThreadState *main;
135136
/* Used in Modules/_threadmodule.c. */
@@ -278,9 +279,10 @@ struct _is {
278279
struct _Py_interp_cached_objects cached_objects;
279280
struct _Py_interp_static_objects static_objects;
280281

282+
Py_ssize_t _interactive_src_count;
283+
281284
/* the initial PyInterpreterState.threads.head */
282285
_PyThreadStateImpl _initial_thread;
283-
Py_ssize_t _interactive_src_count;
284286
};
285287

286288

Include/internal/pycore_runtime_init.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ extern PyTypeObject _PyExc_MemoryError;
118118
{ \
119119
.id_refcount = -1, \
120120
._whence = _PyInterpreterState_WHENCE_NOTSET, \
121+
.threads = { \
122+
.preallocated = &(INTERP)._initial_thread, \
123+
}, \
121124
.imports = IMPORTS_INIT, \
122125
.ceval = { \
123126
.recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \

Lib/_pydatetime.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,19 @@ def __new__(cls, days=0, seconds=0, microseconds=0,
651651
# guide the C implementation; it's way more convoluted than speed-
652652
# ignoring auto-overflow-to-long idiomatic Python could be.
653653

654-
# XXX Check that all inputs are ints or floats.
654+
for name, value in (
655+
("days", days),
656+
("seconds", seconds),
657+
("microseconds", microseconds),
658+
("milliseconds", milliseconds),
659+
("minutes", minutes),
660+
("hours", hours),
661+
("weeks", weeks)
662+
):
663+
if not isinstance(value, (int, float)):
664+
raise TypeError(
665+
f"unsupported type for timedelta {name} component: {type(value).__name__}"
666+
)
655667

656668
# Final values, all integer.
657669
# s and us fit in 32-bit signed ints; d isn't bounded.

Lib/test/datetimetester.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
510510

511511
def test_constructor(self):
512512
eq = self.assertEqual
513+
ra = self.assertRaises
513514
td = timedelta
514515

515516
# Check keyword args to constructor
@@ -533,6 +534,15 @@ def test_constructor(self):
533534
eq(td(seconds=0.001), td(milliseconds=1))
534535
eq(td(milliseconds=0.001), td(microseconds=1))
535536

537+
# Check type of args to constructor
538+
ra(TypeError, lambda: td(weeks='1'))
539+
ra(TypeError, lambda: td(days='1'))
540+
ra(TypeError, lambda: td(hours='1'))
541+
ra(TypeError, lambda: td(minutes='1'))
542+
ra(TypeError, lambda: td(seconds='1'))
543+
ra(TypeError, lambda: td(milliseconds='1'))
544+
ra(TypeError, lambda: td(microseconds='1'))
545+
536546
def test_computations(self):
537547
eq = self.assertEqual
538548
td = timedelta

Lib/test/libregrtest/mypy.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ strict = True
1515

1616
# Various stricter settings that we can't yet enable
1717
# Try to enable these in the following order:
18-
disallow_any_generics = False
1918
disallow_incomplete_defs = False
2019
disallow_untyped_calls = False
2120
disallow_untyped_defs = False

Lib/test/libregrtest/results.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import sys
22
import trace
3+
from typing import TYPE_CHECKING
34

45
from .runtests import RunTests
56
from .result import State, TestResult, TestStats, Location
67
from .utils import (
78
StrPath, TestName, TestTuple, TestList, FilterDict,
89
printlist, count, format_duration)
910

11+
if TYPE_CHECKING:
12+
from xml.etree.ElementTree import Element
13+
1014

1115
# Python uses exit code 1 when an exception is not caught
1216
# argparse.ArgumentParser.error() uses exit code 2
@@ -34,7 +38,7 @@ def __init__(self) -> None:
3438
self.test_times: list[tuple[float, TestName]] = []
3539
self.stats = TestStats()
3640
# used by --junit-xml
37-
self.testsuite_xml: list = []
41+
self.testsuite_xml: list['Element'] = []
3842
# used by -T with -j
3943
self.covered_lines: set[Location] = set()
4044

Lib/test/libregrtest/runtests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class JsonFile:
2828
file: int | None
2929
file_type: str
3030

31-
def configure_subprocess(self, popen_kwargs: dict) -> None:
31+
def configure_subprocess(self, popen_kwargs: dict[str, Any]) -> None:
3232
match self.file_type:
3333
case JsonFileType.UNIX_FD:
3434
# Unix file descriptor

Lib/test/libregrtest/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
def create_worker_process(runtests: WorkerRunTests, output_fd: int,
23-
tmp_dir: StrPath | None = None) -> subprocess.Popen:
23+
tmp_dir: StrPath | None = None) -> subprocess.Popen[str]:
2424
worker_json = runtests.as_json()
2525

2626
cmd = runtests.create_python_cmd()

Lib/test/support/os_helper.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,7 @@ def fd_count():
632632
if hasattr(os, 'sysconf'):
633633
try:
634634
MAXFD = os.sysconf("SC_OPEN_MAX")
635-
except (OSError, ValueError):
636-
# gh-118201: ValueError is raised intermittently on iOS
635+
except OSError:
637636
pass
638637

639638
old_modes = None

0 commit comments

Comments
 (0)