Skip to content

Commit

Permalink
Merge branch 'main' of github.com:python/cpython into pythongh-102251
Browse files Browse the repository at this point in the history
  • Loading branch information
sunmy2019 committed Jun 1, 2023
2 parents 20307d0 + f332594 commit 75230b0
Show file tree
Hide file tree
Showing 108 changed files with 3,398 additions and 2,323 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,20 @@ jobs:
with:
filter: |
Doc/**
Misc/**
# Temporarily skip paths with spaces
# (i.e. "C API", "Core and Builtins")
# to avoid "Error: One of your files includes a space".
# Pending https://github.com/python/core-workflow/issues/186
# Misc/**
Misc/NEWS.d/next/Build/**
Misc/NEWS.d/next/Documentation/**
Misc/NEWS.d/next/IDLE/**
Misc/NEWS.d/next/Library/**
Misc/NEWS.d/next/Security/**
Misc/NEWS.d/next/Tests/**
Misc/NEWS.d/next/Tools-Demos/**
Misc/NEWS.d/next/Windows/**
Misc/NEWS.d/next/macOS/**
.github/workflows/reusable-docs.yml
- name: Check for docs changes
if: >-
Expand Down
18 changes: 9 additions & 9 deletions Doc/c-api/arg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,18 @@ unit; the entry in (round) parentheses is the Python object type that matches
the format unit; and the entry in [square] brackets is the type of the C
variable(s) whose address should be passed.

.. _arg-parsing-string-and-buffers:

Strings and buffers
-------------------

.. note::

On Python 3.12 and older, the macro :c:macro:`!PY_SSIZE_T_CLEAN` must be
defined before including :file:`Python.h` to use all ``#`` variants of
formats (``s#``, ``y#``, etc.) explained below.
This is not necessary on Python 3.13 and later.

These formats allow accessing an object as a contiguous chunk of memory.
You don't have to provide raw storage for the returned unicode or bytes
area.
Expand Down Expand Up @@ -68,15 +77,6 @@ There are three ways strings and buffers can be converted to C:
whether the input object is immutable (e.g. whether it would honor a request
for a writable buffer, or whether another thread can mutate the data).

.. note::

For all ``#`` variants of formats (``s#``, ``y#``, etc.), the macro
:c:macro:`PY_SSIZE_T_CLEAN` must be defined before including
:file:`Python.h`. On Python 3.9 and older, the type of the length argument
is :c:type:`Py_ssize_t` if the :c:macro:`PY_SSIZE_T_CLEAN` macro is defined,
or int otherwise.


``s`` (:class:`str`) [const char \*]
Convert a Unicode object to a C pointer to a character string.
A pointer to an existing string is stored in the character pointer
Expand Down
12 changes: 12 additions & 0 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,18 @@ Exception Objects
Set :attr:`~BaseException.args` of exception *ex* to *args*.
.. c:function:: PyObject* PyUnstable_Exc_PrepReraiseStar(PyObject *orig, PyObject *excs)
Implement part of the interpreter's implementation of :keyword:`!except*`.
*orig* is the original exception that was caught, and *excs* is the list of
the exceptions that need to be raised. This list contains the the unhandled
part of *orig*, if any, as well as the exceptions that were raised from the
:keyword:`!except*` clauses (so they have a different traceback from *orig*) and
those that were reraised (and have the same traceback as *orig*).
Return the :exc:`ExceptionGroup` that needs to be reraised in the end, or
``None`` if there is nothing to reraise.
.. versionadded:: 3.12
.. _unicodeexceptions:
Expand Down
3 changes: 0 additions & 3 deletions Doc/data/stable_abi.dat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Doc/extending/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ the module and a copyright notice if you like).
headers are included.

It is recommended to always define ``PY_SSIZE_T_CLEAN`` before including
``Python.h``. See :ref:`parsetuple` for a description of this macro.
``Python.h``. See :ref:`arg-parsing-string-and-buffers` for a description of this macro.

All user-visible symbols defined by :file:`Python.h` have a prefix of ``Py`` or
``PY``, except those defined in standard header files. For convenience, and
Expand Down Expand Up @@ -649,7 +649,7 @@ Note that any Python object references which are provided to the caller are

Some example calls::

#define PY_SSIZE_T_CLEAN /* Make "s#" use Py_ssize_t rather than int. */
#define PY_SSIZE_T_CLEAN
#include <Python.h>

::
Expand Down Expand Up @@ -745,7 +745,7 @@ it returns false and raises an appropriate exception.
Here is an example module which uses keywords, based on an example by Geoff
Philbrick ([email protected])::

#define PY_SSIZE_T_CLEAN /* Make "s#" use Py_ssize_t rather than int. */
#define PY_SSIZE_T_CLEAN
#include <Python.h>

static PyObject *
Expand Down
10 changes: 5 additions & 5 deletions Doc/library/ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1744,17 +1744,17 @@ aliases.
Function and class definitions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. class:: FunctionDef(name, type_params, args, body, decorator_list, returns, type_comment)
.. class:: FunctionDef(name, args, body, decorator_list, returns, type_comment, type_params)

A function definition.

* ``name`` is a raw string of the function name.
* ``type_params`` is a list of :ref:`type parameters <ast-type-params>`.
* ``args`` is an :class:`arguments` node.
* ``body`` is the list of nodes inside the function.
* ``decorator_list`` is the list of decorators to be applied, stored outermost
first (i.e. the first in the list will be applied last).
* ``returns`` is the return annotation.
* ``type_params`` is a list of :ref:`type parameters <ast-type-params>`.

.. attribute:: type_comment

Expand Down Expand Up @@ -1917,19 +1917,19 @@ Function and class definitions
type_ignores=[])


.. class:: ClassDef(name, type_params, bases, keywords, body, decorator_list)
.. class:: ClassDef(name, bases, keywords, body, decorator_list, type_params)

A class definition.

* ``name`` is a raw string for the class name
* ``type_params`` is a list of :ref:`type parameters <ast-type-params>`.
* ``bases`` is a list of nodes for explicitly specified base classes.
* ``keywords`` is a list of :class:`keyword` nodes, principally for 'metaclass'.
Other keywords will be passed to the metaclass, as per `PEP-3115
<https://peps.python.org/pep-3115/>`_.
* ``body`` is a list of nodes representing the code within the class
definition.
* ``decorator_list`` is a list of nodes, as in :class:`FunctionDef`.
* ``type_params`` is a list of :ref:`type parameters <ast-type-params>`.

.. doctest::

Expand Down Expand Up @@ -1961,7 +1961,7 @@ Function and class definitions
Async and await
^^^^^^^^^^^^^^^

.. class:: AsyncFunctionDef(name, args, body, decorator_list, returns, type_comment)
.. class:: AsyncFunctionDef(name, args, body, decorator_list, returns, type_comment, type_params)

An ``async def`` function definition. Has the same fields as
:class:`FunctionDef`.
Expand Down
11 changes: 11 additions & 0 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,13 @@ Pure paths provide the following methods and properties:
>>> PurePath('a/b.py').match('/*.py')
False

The *pattern* may be another path object; this speeds up matching the same
pattern against multiple files::

>>> pattern = PurePath('*.py')
>>> PurePath('a/b.py').match(pattern)
True

As with other methods, case-sensitivity follows platform defaults::

>>> PurePosixPath('b.py').match('*.PY')
Expand All @@ -581,6 +588,10 @@ Pure paths provide the following methods and properties:
.. versionadded:: 3.12
The *case_sensitive* argument.

.. versionchanged:: 3.13
Support for the recursive wildcard "``**``" was added. In previous
versions, it acted like the non-recursive wildcard "``*``".


.. method:: PurePath.relative_to(other, walk_up=False)

Expand Down
Loading

0 comments on commit 75230b0

Please sign in to comment.