Skip to content

Commit 64cc626

Browse files
committed
Merge remote-tracking branch 'cpython/main' into pythongh-99726-2
2 parents 23a4dcc + c84e6f3 commit 64cc626

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+471
-408
lines changed

Doc/c-api/buffer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ Buffer-related functions
499499
This function fails if *len* != *src->len*.
500500
501501
502-
.. c:function:: int PyObject_CopyData(Py_buffer *dest, Py_buffer *src)
502+
.. c:function:: int PyObject_CopyData(PyObject *dest, PyObject *src)
503503
504504
Copy data from *src* to *dest* buffer. Can convert between C-style and
505505
or Fortran-style buffers.

Doc/library/pathlib.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ we also call *flavours*:
105105
PurePosixPath('setup.py')
106106

107107
Each element of *pathsegments* can be either a string representing a
108-
path segment, an object implementing the :class:`os.PathLike` interface
109-
which returns a string, or another path object::
108+
path segment, or an object implementing the :class:`os.PathLike` interface
109+
where the :meth:`~os.PathLike.__fspath__` method returns a string,
110+
such as another path object::
110111

111112
>>> PurePath('foo', 'some/path', 'bar')
112113
PurePosixPath('foo/some/path/bar')

Doc/library/stdtypes.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,14 @@ class`. In addition, it provides a few more methods:
530530
is ``False``.
531531

532532
The default values can be used to conveniently turn an integer into a
533-
single byte object. However, when using the default arguments, don't try
534-
to convert a value greater than 255 or you'll get an :exc:`OverflowError`::
533+
single byte object::
535534

536535
>>> (65).to_bytes()
537536
b'A'
538537

538+
However, when using the default arguments, don't try
539+
to convert a value greater than 255 or you'll get an :exc:`OverflowError`.
540+
539541
Equivalent to::
540542

541543
def to_bytes(n, length=1, byteorder='big', signed=False):

Doc/library/test.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ The :mod:`test.support` module defines the following functions:
540540

541541
Get size of a page in bytes.
542542

543-
.. versionadded:: 3.12
543+
.. versionadded:: 3.12
544544

545545

546546
.. function:: setswitchinterval(interval)

Doc/library/unittest.mock.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ available, and then make assertions about how they have been used:
7272
:attr:`side_effect` allows you to perform side effects, including raising an
7373
exception when a mock is called:
7474

75+
>>> from unittest.mock import Mock
7576
>>> mock = Mock(side_effect=KeyError('foo'))
7677
>>> mock()
7778
Traceback (most recent call last):

Doc/tools/extensions/c_annotations.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from docutils.parsers.rst import directives
2525
from docutils.parsers.rst import Directive
2626
from docutils.statemachine import StringList
27+
from sphinx.locale import _ as sphinx_gettext
2728
import csv
2829

2930
from sphinx import addnodes
@@ -168,11 +169,11 @@ def add_annotations(self, app, doctree):
168169
elif not entry.result_type.endswith("Object*"):
169170
continue
170171
if entry.result_refs is None:
171-
rc = 'Return value: Always NULL.'
172+
rc = sphinx_gettext('Return value: Always NULL.')
172173
elif entry.result_refs:
173-
rc = 'Return value: New reference.'
174+
rc = sphinx_gettext('Return value: New reference.')
174175
else:
175-
rc = 'Return value: Borrowed reference.'
176+
rc = sphinx_gettext('Return value: Borrowed reference.')
176177
node.insert(0, nodes.emphasis(rc, rc, classes=['refcount']))
177178

178179

Doc/tools/templates/dummy.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
{% trans %}Deprecated since version {deprecated}, will be removed in version {removed}{% endtrans %}
88
{% trans %}Deprecated since version {deprecated}, removed in version {removed}{% endtrans %}
99

10+
In extensions/c_annotations.py:
11+
12+
{% trans %}Return value: Always NULL.{% endtrans %}
13+
{% trans %}Return value: New reference.{% endtrans %}
14+
{% trans %}Return value: Borrowed reference.{% endtrans %}
1015

1116
In docsbuild-scripts, when rewriting indexsidebar.html with actual versions:
1217

Doc/using/configure.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ also be used to improve performance.
326326

327327
Enable C-level code profiling with ``gprof`` (disabled by default).
328328

329+
.. cmdoption:: --with-strict-overflow
330+
331+
Add ``-fstrict-overflow`` to the C compiler flags (by default we add
332+
``-fno-strict-overflow`` instead).
333+
329334

330335
.. _debug-build:
331336

Include/internal/pycore_pymath.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,6 @@ static inline void _Py_ADJUST_ERANGE2(double x, double y)
5656
}
5757
}
5858

59-
// Return the maximum value of integral type *type*.
60-
#define _Py_IntegralTypeMax(type) \
61-
(_Py_IS_TYPE_SIGNED(type) ? (((((type)1 << (sizeof(type)*CHAR_BIT - 2)) - 1) << 1) + 1) : ~(type)0)
62-
63-
// Return the minimum value of integral type *type*.
64-
#define _Py_IntegralTypeMin(type) \
65-
(_Py_IS_TYPE_SIGNED(type) ? -_Py_IntegralTypeMax(type) - 1 : 0)
66-
67-
// Check whether *v* is in the range of integral type *type*. This is most
68-
// useful if *v* is floating-point, since demoting a floating-point *v* to an
69-
// integral type that cannot represent *v*'s integral part is undefined
70-
// behavior.
71-
#define _Py_InIntegralTypeRange(type, v) \
72-
(_Py_IntegralTypeMin(type) <= v && v <= _Py_IntegralTypeMax(type))
73-
7459

7560
//--- HAVE_PY_SET_53BIT_PRECISION macro ------------------------------------
7661
//

Lib/argparse.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,18 @@ def _format_actions_usage(self, actions, groups):
403403
except ValueError:
404404
continue
405405
else:
406-
end = start + len(group._group_actions)
406+
group_action_count = len(group._group_actions)
407+
end = start + group_action_count
407408
if actions[start:end] == group._group_actions:
409+
410+
suppressed_actions_count = 0
408411
for action in group._group_actions:
409412
group_actions.add(action)
413+
if action.help is SUPPRESS:
414+
suppressed_actions_count += 1
415+
416+
exposed_actions_count = group_action_count - suppressed_actions_count
417+
410418
if not group.required:
411419
if start in inserts:
412420
inserts[start] += ' ['
@@ -416,7 +424,7 @@ def _format_actions_usage(self, actions, groups):
416424
inserts[end] += ']'
417425
else:
418426
inserts[end] = ']'
419-
else:
427+
elif exposed_actions_count > 1:
420428
if start in inserts:
421429
inserts[start] += ' ('
422430
else:
@@ -490,7 +498,6 @@ def _format_actions_usage(self, actions, groups):
490498
text = _re.sub(r'(%s) ' % open, r'\1', text)
491499
text = _re.sub(r' (%s)' % close, r'\1', text)
492500
text = _re.sub(r'%s *%s' % (open, close), r'', text)
493-
text = _re.sub(r'\(([^|]*)\)', r'\1', text)
494501
text = text.strip()
495502

496503
# return the text

0 commit comments

Comments
 (0)