Skip to content

Commit 5ca8040

Browse files
committed
Merge branch 'main' into missing-backticks
2 parents 7f1a56b + 630cd37 commit 5ca8040

File tree

10 files changed

+152
-17
lines changed

10 files changed

+152
-17
lines changed

Doc/c-api/dict.rst

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,92 @@ Dictionary View Objects
477477
478478
Return true if *op* is an instance of a dictionary items view. This function
479479
always succeeds.
480+
481+
482+
Ordered Dictionaries
483+
^^^^^^^^^^^^^^^^^^^^
484+
485+
Python's C API provides interface for :class:`collections.OrderedDict` from C.
486+
Since Python 3.7, dictionaries are ordered by default, so there is usually
487+
little need for these functions; prefer ``PyDict*`` where possible.
488+
489+
490+
.. c:var:: PyTypeObject PyODict_Type
491+
492+
Type object for ordered dictionaries. This is the same object as
493+
:class:`collections.OrderedDict` in the Python layer.
494+
495+
496+
.. c:function:: int PyODict_Check(PyObject *od)
497+
498+
Return true if *od* is an ordered dictionary object or an instance of a
499+
subtype of the :class:`~collections.OrderedDict` type. This function
500+
always succeeds.
501+
502+
503+
.. c:function:: int PyODict_CheckExact(PyObject *od)
504+
505+
Return true if *od* is an ordered dictionary object, but not an instance of
506+
a subtype of the :class:`~collections.OrderedDict` type.
507+
This function always succeeds.
508+
509+
510+
.. c:var:: PyTypeObject PyODictKeys_Type
511+
512+
Analogous to :c:type:`PyDictKeys_Type` for ordered dictionaries.
513+
514+
515+
.. c:var:: PyTypeObject PyODictValues_Type
516+
517+
Analogous to :c:type:`PyDictValues_Type` for ordered dictionaries.
518+
519+
520+
.. c:var:: PyTypeObject PyODictItems_Type
521+
522+
Analogous to :c:type:`PyDictItems_Type` for ordered dictionaries.
523+
524+
525+
.. c:function:: PyObject *PyODict_New(void)
526+
527+
Return a new empty ordered dictionary, or ``NULL`` on failure.
528+
529+
This is analogous to :c:func:`PyDict_New`.
530+
531+
532+
.. c:function:: int PyODict_SetItem(PyObject *od, PyObject *key, PyObject *value)
533+
534+
Insert *value* into the ordered dictionary *od* with a key of *key*.
535+
Return ``0`` on success or ``-1`` with an exception set on failure.
536+
537+
This is analogous to :c:func:`PyDict_SetItem`.
538+
539+
540+
.. c:function:: int PyODict_DelItem(PyObject *od, PyObject *key)
541+
542+
Remove the entry in the ordered dictionary *od* with key *key*.
543+
Return ``0`` on success or ``-1`` with an exception set on failure.
544+
545+
This is analogous to :c:func:`PyDict_DelItem`.
546+
547+
548+
These are :term:`soft deprecated` aliases to ``PyDict`` APIs:
549+
550+
551+
.. list-table::
552+
:widths: auto
553+
:header-rows: 1
554+
555+
* * ``PyODict``
556+
* ``PyDict``
557+
* * .. c:macro:: PyODict_GetItem(od, key)
558+
* :c:func:`PyDict_GetItem`
559+
* * .. c:macro:: PyODict_GetItemWithError(od, key)
560+
* :c:func:`PyDict_GetItemWithError`
561+
* * .. c:macro:: PyODict_GetItemString(od, key)
562+
* :c:func:`PyDict_GetItemString`
563+
* * .. c:macro:: PyODict_Contains(od, key)
564+
* :c:func:`PyDict_Contains`
565+
* * .. c:macro:: PyODict_Size(od)
566+
* :c:func:`PyDict_Size`
567+
* * .. c:macro:: PyODict_SIZE(od)
568+
* :c:func:`PyDict_GET_SIZE`

Doc/c-api/float.rst

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Floating-Point Objects
8787
``<math.h>`` header.
8888
8989
.. deprecated:: 3.15
90-
The macro is soft deprecated.
90+
The macro is :term:`soft deprecated`.
9191
9292
9393
.. c:macro:: Py_NAN
@@ -99,6 +99,14 @@ Floating-Point Objects
9999
the C11 standard ``<math.h>`` header.
100100
101101
102+
.. c:macro:: Py_HUGE_VAL
103+
104+
Equivalent to :c:macro:`!INFINITY`.
105+
106+
.. deprecated:: 3.14
107+
The macro is :term:`soft deprecated`.
108+
109+
102110
.. c:macro:: Py_MATH_E
103111
104112
The definition (accurate for a :c:expr:`double` type) of the :data:`math.e` constant.
@@ -147,6 +155,34 @@ Floating-Point Objects
147155
return PyFloat_FromDouble(copysign(INFINITY, sign));
148156
149157
158+
.. c:macro:: Py_IS_FINITE(X)
159+
160+
Return ``1`` if the given floating-point number *X* is finite,
161+
that is, it is normal, subnormal or zero, but not infinite or NaN.
162+
Return ``0`` otherwise.
163+
164+
.. deprecated:: 3.14
165+
The macro is :term:`soft deprecated`. Use :c:macro:`!isfinite` instead.
166+
167+
168+
.. c:macro:: Py_IS_INFINITY(X)
169+
170+
Return ``1`` if the given floating-point number *X* is positive or negative
171+
infinity. Return ``0`` otherwise.
172+
173+
.. deprecated:: 3.14
174+
The macro is :term:`soft deprecated`. Use :c:macro:`!isinf` instead.
175+
176+
177+
.. c:macro:: Py_IS_NAN(X)
178+
179+
Return ``1`` if the given floating-point number *X* is a not-a-number (NaN)
180+
value. Return ``0`` otherwise.
181+
182+
.. deprecated:: 3.14
183+
The macro is :term:`soft deprecated`. Use :c:macro:`!isnan` instead.
184+
185+
150186
Pack and Unpack functions
151187
-------------------------
152188

Doc/c-api/intro.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ complete listing.
183183

184184
.. versionadded:: 3.6
185185

186+
.. c:macro:: Py_MEMCPY(dest, src, n)
187+
188+
This is a :term:`soft deprecated` alias to :c:func:`!memcpy`.
189+
Use :c:func:`!memcpy` directly instead.
190+
191+
.. deprecated:: 3.14
192+
The macro is :term:`soft deprecated`.
193+
186194
.. c:macro:: Py_MIN(x, y)
187195
188196
Return the minimum value between ``x`` and ``y``.

Doc/c-api/iterator.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Other Iterator Objects
108108
.. c:var:: PyTypeObject PyDictRevIterValue_Type
109109
.. c:var:: PyTypeObject PyDictIterItem_Type
110110
.. c:var:: PyTypeObject PyDictRevIterItem_Type
111+
.. c:var:: PyTypeObject PyODictIter_Type
111112
112113
Type objects for iterators of various built-in objects.
113114

Lib/_pyio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def nreadahead():
546546
res += b
547547
if res.endswith(b"\n"):
548548
break
549-
return bytes(res)
549+
return res.take_bytes()
550550

551551
def __iter__(self):
552552
self._checkClosed()
@@ -620,15 +620,15 @@ def read(self, size=-1):
620620
if n < 0 or n > len(b):
621621
raise ValueError(f"readinto returned {n} outside buffer size {len(b)}")
622622
del b[n:]
623-
return bytes(b)
623+
return b.take_bytes()
624624

625625
def readall(self):
626626
"""Read until EOF, using multiple read() call."""
627627
res = bytearray()
628628
while data := self.read(DEFAULT_BUFFER_SIZE):
629629
res += data
630630
if res:
631-
return bytes(res)
631+
return res.take_bytes()
632632
else:
633633
# b'' or None
634634
return data
@@ -1738,7 +1738,7 @@ def readall(self):
17381738
assert len(result) - bytes_read >= 1, \
17391739
"os.readinto buffer size 0 will result in erroneous EOF / returns 0"
17401740
result.resize(bytes_read)
1741-
return bytes(result)
1741+
return result.take_bytes()
17421742

17431743
def readinto(self, buffer):
17441744
"""Same as RawIOBase.readinto()."""

Lib/test/test_io/test_bufferedio.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,8 @@ def test_flush_and_readinto(self):
12771277
def _readinto(bufio, n=-1):
12781278
b = bytearray(n if n >= 0 else 9999)
12791279
n = bufio.readinto(b)
1280-
return bytes(b[:n])
1280+
b.resize(n)
1281+
return b.take_bytes()
12811282
self.check_flush_and_read(_readinto)
12821283

12831284
def test_flush_and_peek(self):

Lib/test/test_io/test_largefile.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ class TestFileMethods(LargeFileTest):
5656
(i.e. > 2 GiB) files.
5757
"""
5858

59-
# _pyio.FileIO.readall() uses a temporary bytearray then casted to bytes,
60-
# so memuse=2 is needed
61-
@bigmemtest(size=size, memuse=2, dry_run=False)
59+
@bigmemtest(size=size, memuse=1, dry_run=False)
6260
def test_large_read(self, _size):
6361
# bpo-24658: Test that a read greater than 2GB does not fail.
6462
with self.open(TESTFN, "rb") as f:
@@ -154,7 +152,7 @@ def test_seekable(self):
154152
f.seek(pos)
155153
self.assertTrue(f.seekable())
156154

157-
@bigmemtest(size=size, memuse=2, dry_run=False)
155+
@bigmemtest(size=size, memuse=1, dry_run=False)
158156
def test_seek_readall(self, _size):
159157
# Seek which doesn't change position should readall successfully.
160158
with self.open(TESTFN, 'rb') as f:

Lib/test/test_profiling/test_sampling_profiler.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3311,6 +3311,8 @@ def test_native_frames_disabled(self):
33113311
self.assertNotIn("<native>", output)
33123312

33133313

3314+
@requires_subprocess()
3315+
@skip_if_not_supported
33143316
class TestProcessPoolExecutorSupport(unittest.TestCase):
33153317
"""
33163318
Test that ProcessPoolExecutor works correctly with profiling.sampling.
@@ -3339,12 +3341,15 @@ def worker(x):
33393341
"-d", "5",
33403342
"-i", "100000",
33413343
script,
3344+
stdout=subprocess.PIPE,
33423345
stderr=subprocess.PIPE,
33433346
text=True
33443347
) as proc:
3345-
proc.wait(timeout=SHORT_TIMEOUT)
3346-
stdout = proc.stdout.read()
3347-
stderr = proc.stderr.read()
3348+
try:
3349+
stdout, stderr = proc.communicate(timeout=SHORT_TIMEOUT)
3350+
except subprocess.TimeoutExpired:
3351+
proc.kill()
3352+
stdout, stderr = proc.communicate()
33483353

33493354
if "PermissionError" in stderr:
33503355
self.skipTest("Insufficient permissions for remote profiling")

Misc/NEWS.d/3.14.0a1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6092,7 +6092,7 @@ Patch by Victor Stinner.
60926092
.. nonce: qOr9GF
60936093
.. section: C API
60946094
6095-
Soft deprecate the :c:macro:`!Py_MEMCPY` macro: use directly ``memcpy()``
6095+
Soft deprecate the :c:macro:`Py_MEMCPY` macro: use directly ``memcpy()``
60966096
instead. Patch by Victor Stinner.
60976097

60986098
..

Misc/NEWS.d/next/Documentation/2025-10-27-23-06-01.gh-issue-140578.FMBdEn.rst

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)