Skip to content

Commit 0ec31ab

Browse files
Merge branch 'main' of https://github.com/python/cpython into gh-127049-pid-reuse-race
2 parents 9c30492 + 44ea950 commit 0ec31ab

16 files changed

Lines changed: 96 additions & 21 deletions

File tree

Doc/c-api/type.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ but need extra remarks for use as slots:
699699
700700
.. soft-deprecated:: 3.15
701701
702-
When not targetting older Python versions, pefer :c:macro:`!Py_tp_bases`.
702+
When not targeting older Python versions, prefer :c:macro:`!Py_tp_bases`.
703703
704704
The following slots do not correspond to public fields in the
705705
underlying structures:

Doc/library/ast.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ Control flow
13661366

13671367
``try`` blocks which are followed by ``except*`` clauses. The attributes are the
13681368
same as for :class:`Try` but the :class:`ExceptHandler` nodes in ``handlers``
1369-
are interpreted as ``except*`` blocks rather then ``except``.
1369+
are interpreted as ``except*`` blocks rather than ``except``.
13701370

13711371
.. doctest::
13721372

Doc/library/compression.zstd.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ Advanced parameter control
503503
The :meth:`~.bounds` method can be used on any attribute to get the valid
504504
values for that parameter.
505505

506-
Parameters are optional; any omitted parameter will have it's value selected
506+
Parameters are optional; any omitted parameter will have its value selected
507507
automatically.
508508

509509
Example getting the lower and upper bound of :attr:`~.compression_level`::
@@ -732,7 +732,7 @@ Advanced parameter control
732732

733733
An :class:`~enum.IntEnum` containing the advanced decompression parameter
734734
keys that can be used when decompressing data. Parameters are optional; any
735-
omitted parameter will have it's value selected automatically.
735+
omitted parameter will have its value selected automatically.
736736

737737
The :meth:`~.bounds` method can be used on any attribute to get the valid
738738
values for that parameter.

Doc/library/secrets.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Other functions
137137
:term:`bytes-like objects <bytes-like object>`
138138
*a* and *b* are equal, otherwise ``False``,
139139
using a "constant-time compare" to reduce the risk of
140-
`timing attacks <https://codahale.com/a-lesson-in-timing-attacks/>`_.
140+
`timing attacks <https://web.archive.org/web/20250815071532/https://codahale.com/a-lesson-in-timing-attacks/>`__.
141141
See :func:`hmac.compare_digest` for additional details.
142142

143143

Doc/library/sys.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only
21352135
returned by the :func:`open` function. Their parameters are chosen as
21362136
follows:
21372137

2138-
* The encoding and error handling are is initialized from
2138+
* The encoding and error handling are initialized from
21392139
:c:member:`PyConfig.stdio_encoding` and :c:member:`PyConfig.stdio_errors`.
21402140

21412141
On Windows, UTF-8 is used for the console device. Non-character

Lib/test/test_asyncio/test_subprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def test_kill_issue43884(self):
220220
# kills the process and all its children.
221221
creationflags = CREATE_NEW_PROCESS_GROUP
222222
proc = self.loop.run_until_complete(
223-
asyncio.create_subprocess_shell(blocking_shell_command, stdout=asyncio.subprocess.PIPE,
223+
asyncio.create_subprocess_shell(blocking_shell_command,
224224
creationflags=creationflags)
225225
)
226226
self.loop.run_until_complete(asyncio.sleep(1))

Lib/test/test_ctypes/test_pointers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
c_long, c_ulong, c_longlong, c_ulonglong,
1212
c_float, c_double)
1313
from ctypes import _pointer_type_cache, _pointer_type_cache_fallback
14+
from test import support
1415
from test.support import import_helper
1516
from weakref import WeakSet
1617
_ctypes_test = import_helper.import_module("_ctypes_test")
@@ -409,10 +410,9 @@ class BadType(ctypes._Pointer):
409410
pass
410411

411412
func = ctypes.pythonapi.Py_GetVersion
412-
func.argtypes = (BadType,)
413-
414-
with self.assertRaises(ctypes.ArgumentError):
415-
func(object())
413+
with support.swap_attr(func, 'argtypes', (BadType,)):
414+
with self.assertRaises(ctypes.ArgumentError):
415+
func(object())
416416

417417
class PointerTypeCacheTestCase(unittest.TestCase):
418418
# dummy tests to check warnings and base behavior

Lib/test/test_external_inspection.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,56 @@ def _extract_coroutine_stacks_lineno_only(self, stack_trace):
438438
# ============================================================================
439439

440440

441+
@requires_remote_subprocess_debugging()
442+
class TestSelfStackTrace(RemoteInspectionTestBase):
443+
@skip_if_not_supported
444+
@unittest.skipIf(
445+
sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED,
446+
"Test only runs on Linux with process_vm_readv support",
447+
)
448+
def test_self_trace_with_large_linetable(self):
449+
script = textwrap.dedent("""\
450+
import os
451+
import _remote_debugging
452+
453+
assignments = "\\n".join(
454+
f"value_{i} = {i}" for i in range(1000)
455+
)
456+
expected_lineno = len(assignments.splitlines()) + 1
457+
source = (
458+
f"{assignments}\\n"
459+
"stack_trace = "
460+
"_remote_debugging.RemoteUnwinder(os.getpid()).get_stack_trace()\\n"
461+
)
462+
code = compile(source, "large_linetable.py", "exec")
463+
assert len(code.co_linetable) > 4096, len(code.co_linetable)
464+
namespace = {"os": os, "_remote_debugging": _remote_debugging}
465+
exec(code, namespace)
466+
large_linetable_frames = [
467+
frame
468+
for interpreter in namespace["stack_trace"]
469+
for thread in interpreter.threads
470+
for frame in thread.frame_info
471+
if frame.filename == "large_linetable.py"
472+
]
473+
assert len(large_linetable_frames) == 1, large_linetable_frames
474+
assert large_linetable_frames[0].location.lineno == expected_lineno, (
475+
large_linetable_frames[0]
476+
)
477+
""")
478+
479+
result = subprocess.run(
480+
[sys.executable, "-c", script],
481+
capture_output=True,
482+
text=True,
483+
timeout=SHORT_TIMEOUT,
484+
)
485+
self.assertEqual(
486+
result.returncode, 0,
487+
f"stdout: {result.stdout}\nstderr: {result.stderr}"
488+
)
489+
490+
441491
@requires_remote_subprocess_debugging()
442492
class TestGetStackTrace(RemoteInspectionTestBase):
443493
@skip_if_not_supported

Lib/test/test_winapi.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@
1212
MAXIMUM_WAIT_OBJECTS = 64
1313
MAXIMUM_BATCHED_WAIT_OBJECTS = (MAXIMUM_WAIT_OBJECTS - 1) ** 2
1414

15+
16+
def close_events(events):
17+
for handle in events:
18+
_winapi.CloseHandle(handle)
19+
20+
1521
class WinAPIBatchedWaitForMultipleObjectsTests(unittest.TestCase):
1622
def _events_waitall_test(self, n):
1723
evts = [_winapi.CreateEventW(0, False, False, None) for _ in range(n)]
24+
self.addCleanup(close_events, evts)
1825

1926
with self.assertRaises(TimeoutError):
2027
_winapi.BatchedWaitForMultipleObjects(evts, True, 100)
@@ -42,6 +49,7 @@ def _events_waitall_test(self, n):
4249

4350
def _events_waitany_test(self, n):
4451
evts = [_winapi.CreateEventW(0, False, False, None) for _ in range(n)]
52+
self.addCleanup(close_events, evts)
4553

4654
with self.assertRaises(TimeoutError):
4755
_winapi.BatchedWaitForMultipleObjects(evts, False, 100)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix building the :mod:`math` module on FreeBSD.
2+
Define ``_ISOC23_SOURCE`` to make the C23 library declarations
3+
(such as ``sinpi()`` in ``math.h``) visible.

0 commit comments

Comments
 (0)