Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-89812-pathlib-tests-misc
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Jul 1, 2023
2 parents 9c37a53 + 6e01055 commit 13fee78
Show file tree
Hide file tree
Showing 188 changed files with 6,587 additions and 3,034 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ Parser/parser.c generated
Parser/token.c generated
Programs/test_frozenmain.h generated
Python/Python-ast.c generated
Python/executor_cases.c.h generated
Python/generated_cases.c.h generated
Python/opcode_metadata.h generated
Python/opcode_targets.h generated
Python/stdlib_module_names.h generated
Tools/peg_generator/pegen/grammar_parser.py generated
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/require-pr-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
timeout-minutes: 10

steps:
- uses: mheap/github-action-required-labels@v4
- uses: mheap/github-action-required-labels@v5
with:
mode: exactly
count: 0
Expand Down
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ repos:
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
types: [python]
exclude: Lib/test/coding20731.py
- id: trailing-whitespace
types_or: [c, python, rst]

Expand Down
13 changes: 0 additions & 13 deletions Doc/c-api/call.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,6 @@ function as with any other callable.
:c:func:`PyObject_Vectorcall` will usually be most efficient.


.. note::

In CPython 3.8, the vectorcall API and related functions were available
provisionally under names with a leading underscore:
``_PyObject_Vectorcall``, ``_Py_TPFLAGS_HAVE_VECTORCALL``,
``_PyObject_VectorcallMethod``, ``_PyVectorcall_Function``,
``_PyObject_CallOneArg``, ``_PyObject_CallMethodNoArgs``,
``_PyObject_CallMethodOneArg``.
Additionally, ``PyObject_VectorcallDict`` was available as
``_PyObject_FastCallDict``.
The old names are still defined as aliases of the new, non-underscored names.


Recursion Control
.................

Expand Down
10 changes: 5 additions & 5 deletions Doc/c-api/complex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ Complex Numbers as Python Objects
Return the :c:type:`Py_complex` value of the complex number *op*.
If *op* is not a Python complex number object but has a :meth:`__complex__`
If *op* is not a Python complex number object but has a :meth:`~object.__complex__`
method, this method will first be called to convert *op* to a Python complex
number object. If ``__complex__()`` is not defined then it falls back to
:meth:`__float__`. If ``__float__()`` is not defined then it falls back
to :meth:`__index__`. Upon failure, this method returns ``-1.0`` as a real
number object. If :meth:`!__complex__` is not defined then it falls back to
:meth:`~object.__float__`. If :meth:`!__float__` is not defined then it falls back
to :meth:`~object.__index__`. Upon failure, this method returns ``-1.0`` as a real
value.
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
Use :meth:`~object.__index__` if available.
19 changes: 12 additions & 7 deletions Doc/c-api/dict.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ Dictionary Objects
Return the object from dictionary *p* which has a key *key*. Return ``NULL``
if the key *key* is not present, but *without* setting an exception.
Note that exceptions which occur while calling :meth:`__hash__` and
:meth:`__eq__` methods will get suppressed.
To get error reporting use :c:func:`PyDict_GetItemWithError()` instead.
.. note::
Exceptions that occur while this calls :meth:`~object.__hash__` and
:meth:`~object.__eq__` methods are silently ignored.
Prefer the :c:func:`PyDict_GetItemWithError` function instead.
.. versionchanged:: 3.10
Calling this API without :term:`GIL` held had been allowed for historical
Expand All @@ -120,10 +122,13 @@ Dictionary Objects
This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as a
:c:expr:`const char*`, rather than a :c:expr:`PyObject*`.
Note that exceptions which occur while calling :meth:`__hash__` and
:meth:`__eq__` methods and creating a temporary string object
will get suppressed.
To get error reporting use :c:func:`PyDict_GetItemWithError()` instead.
.. note::
Exceptions that occur while this calls :meth:`~object.__hash__` and
:meth:`~object.__eq__` methods or while creating the temporary :class:`str`
object are silently ignored.
Prefer using the :c:func:`PyDict_GetItemWithError` function with your own
:c:func:`PyUnicode_FromString` *key* instead.
.. c:function:: PyObject* PyDict_SetDefault(PyObject *p, PyObject *key, PyObject *defaultobj)
Expand Down
6 changes: 3 additions & 3 deletions Doc/c-api/float.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ Floating Point Objects
.. c:function:: double PyFloat_AsDouble(PyObject *pyfloat)
Return a C :c:expr:`double` representation of the contents of *pyfloat*. If
*pyfloat* is not a Python floating point object but has a :meth:`__float__`
*pyfloat* is not a Python floating point object but has a :meth:`~object.__float__`
method, this method will first be called to convert *pyfloat* into a float.
If ``__float__()`` is not defined then it falls back to :meth:`__index__`.
If :meth:`!__float__` is not defined then it falls back to :meth:`~object.__index__`.
This method returns ``-1.0`` upon failure, so one should call
:c:func:`PyErr_Occurred` to check for errors.
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
Use :meth:`~object.__index__` if available.
.. c:function:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)
Expand Down
4 changes: 4 additions & 0 deletions Doc/c-api/list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ List Objects
Macro form of :c:func:`PyList_SetItem` without error checking. This is
normally only used to fill in new lists where there is no previous content.
Bounds checking is performed as an assertion if Python is built in
:ref:`debug mode <debug-build>` or :option:`with assertions
<--with-assertions>`.
.. note::
This macro "steals" a reference to *item*, and, unlike
Expand Down
36 changes: 18 additions & 18 deletions Doc/c-api/long.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
single: OverflowError (built-in exception)
Return a C :c:expr:`long` representation of *obj*. If *obj* is not an
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method
(if present) to convert it to a :c:type:`PyLongObject`.
Raise :exc:`OverflowError` if the value of *obj* is out of range for a
Expand All @@ -130,16 +130,16 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
Use :meth:`~object.__index__` if available.
.. versionchanged:: 3.10
This function will no longer use :meth:`__int__`.
This function will no longer use :meth:`~object.__int__`.
.. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)
Return a C :c:expr:`long` representation of *obj*. If *obj* is not an
instance of :c:type:`PyLongObject`, first call its :meth:`__index__`
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__`
method (if present) to convert it to a :c:type:`PyLongObject`.
If the value of *obj* is greater than :const:`LONG_MAX` or less than
Expand All @@ -150,10 +150,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
Use :meth:`~object.__index__` if available.
.. versionchanged:: 3.10
This function will no longer use :meth:`__int__`.
This function will no longer use :meth:`~object.__int__`.
.. c:function:: long long PyLong_AsLongLong(PyObject *obj)
Expand All @@ -162,7 +162,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
single: OverflowError (built-in exception)
Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method
(if present) to convert it to a :c:type:`PyLongObject`.
Raise :exc:`OverflowError` if the value of *obj* is out of range for a
Expand All @@ -171,16 +171,16 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
Use :meth:`~object.__index__` if available.
.. versionchanged:: 3.10
This function will no longer use :meth:`__int__`.
This function will no longer use :meth:`~object.__int__`.
.. c:function:: long long PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)
Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method
(if present) to convert it to a :c:type:`PyLongObject`.
If the value of *obj* is greater than :const:`LLONG_MAX` or less than
Expand All @@ -193,10 +193,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
.. versionadded:: 3.2
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
Use :meth:`~object.__index__` if available.
.. versionchanged:: 3.10
This function will no longer use :meth:`__int__`.
This function will no longer use :meth:`~object.__int__`.
.. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)
Expand Down Expand Up @@ -267,7 +267,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *obj)
Return a C :c:expr:`unsigned long` representation of *obj*. If *obj* is not
an instance of :c:type:`PyLongObject`, first call its :meth:`__index__`
an instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__`
method (if present) to convert it to a :c:type:`PyLongObject`.
If the value of *obj* is out of range for an :c:expr:`unsigned long`,
Expand All @@ -277,17 +277,17 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
disambiguate.
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
Use :meth:`~object.__index__` if available.
.. versionchanged:: 3.10
This function will no longer use :meth:`__int__`.
This function will no longer use :meth:`~object.__int__`.
.. c:function:: unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)
Return a C :c:expr:`unsigned long long` representation of *obj*. If *obj*
is not an instance of :c:type:`PyLongObject`, first call its
:meth:`__index__` method (if present) to convert it to a
:meth:`~object.__index__` method (if present) to convert it to a
:c:type:`PyLongObject`.
If the value of *obj* is out of range for an :c:expr:`unsigned long long`,
Expand All @@ -297,10 +297,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
to disambiguate.
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
Use :meth:`~object.__index__` if available.
.. versionchanged:: 3.10
This function will no longer use :meth:`__int__`.
This function will no longer use :meth:`~object.__int__`.
.. c:function:: double PyLong_AsDouble(PyObject *pylong)
Expand Down
18 changes: 11 additions & 7 deletions Doc/c-api/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ Object Protocol
is equivalent to the Python expression ``hasattr(o, attr_name)``. This function
always succeeds.
Note that exceptions which occur while calling :meth:`__getattr__` and
:meth:`__getattribute__` methods will get suppressed.
To get error reporting use :c:func:`PyObject_GetAttr()` instead.
.. note::
Exceptions that occur when this calls :meth:`~object.__getattr__` and
:meth:`~object.__getattribute__` methods are silently ignored.
For proper error handling, use :c:func:`PyObject_GetAttr` instead.
.. c:function:: int PyObject_HasAttrString(PyObject *o, const char *attr_name)
Expand All @@ -44,10 +46,12 @@ Object Protocol
is equivalent to the Python expression ``hasattr(o, attr_name)``. This function
always succeeds.
Note that exceptions which occur while calling :meth:`__getattr__` and
:meth:`__getattribute__` methods and creating a temporary string object
will get suppressed.
To get error reporting use :c:func:`PyObject_GetAttrString()` instead.
.. note::
Exceptions that occur when this calls :meth:`~object.__getattr__` and
:meth:`~object.__getattribute__` methods or while creating the temporary :class:`str`
object are silently ignored.
For proper error handling, use :c:func:`PyObject_GetAttrString` instead.
.. c:function:: PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name)
Expand Down
23 changes: 16 additions & 7 deletions Doc/c-api/tuple.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ Tuple Objects
Like :c:func:`PyTuple_SetItem`, but does no error checking, and should *only* be
used to fill in brand new tuples.
Bounds checking is performed as an assertion if Python is built in
:ref:`debug mode <debug-build>` or :option:`with assertions <--with-assertions>`.
.. note::
This function "steals" a reference to *o*, and, unlike
Expand Down Expand Up @@ -194,12 +197,17 @@ type.
.. c:function:: PyObject* PyStructSequence_GetItem(PyObject *p, Py_ssize_t pos)
Return the object at position *pos* in the struct sequence pointed to by *p*.
No bounds checking is performed.
Bounds checking is performed as an assertion if Python is built in
:ref:`debug mode <debug-build>` or :option:`with assertions <--with-assertions>`.
.. c:function:: PyObject* PyStructSequence_GET_ITEM(PyObject *p, Py_ssize_t pos)
Macro equivalent of :c:func:`PyStructSequence_GetItem`.
Alias to :c:func:`PyStructSequence_GetItem`.
.. versionchanged:: 3.13
Now implemented as an alias to :c:func:`PyStructSequence_GetItem`.
.. c:function:: void PyStructSequence_SetItem(PyObject *p, Py_ssize_t pos, PyObject *o)
Expand All @@ -208,16 +216,17 @@ type.
:c:func:`PyTuple_SET_ITEM`, this should only be used to fill in brand new
instances.
Bounds checking is performed as an assertion if Python is built in
:ref:`debug mode <debug-build>` or :option:`with assertions <--with-assertions>`.
.. note::
This function "steals" a reference to *o*.
.. c:function:: void PyStructSequence_SET_ITEM(PyObject *p, Py_ssize_t *pos, PyObject *o)
Similar to :c:func:`PyStructSequence_SetItem`, but implemented as a static
inlined function.
Alias to :c:func:`PyStructSequence_SetItem`.
.. note::
This function "steals" a reference to *o*.
.. versionchanged:: 3.13
Now implemented as an alias to :c:func:`PyStructSequence_SetItem`.
6 changes: 6 additions & 0 deletions Doc/c-api/weakref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,17 @@ as much as it can.
except when it cannot be destroyed before the last usage of the borrowed
reference.
.. deprecated-removed:: 3.13 3.15
Use :c:func:`PyWeakref_GetRef` instead.
.. c:function:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
Similar to :c:func:`PyWeakref_GetObject`, but does no error checking.
.. deprecated-removed:: 3.13 3.15
Use :c:func:`PyWeakref_GetRef` instead.
.. c:function:: void PyObject_ClearWeakRefs(PyObject *object)
Expand Down
Loading

0 comments on commit 13fee78

Please sign in to comment.