Skip to content

Commit

Permalink
Merge branch 'main' into inlinecomp2
Browse files Browse the repository at this point in the history
* main: (47 commits)
  pythongh-97696 Remove unnecessary check for eager_start kwarg (python#104188)
  pythonGH-104308: socket.getnameinfo should release the GIL (python#104307)
  pythongh-104310: Add importlib.util.allowing_all_extensions() (pythongh-104311)
  pythongh-99113: A Per-Interpreter GIL! (pythongh-104210)
  pythonGH-104284: Fix documentation gettext build (python#104296)
  pythongh-89550: Buffer GzipFile.write to reduce execution time by ~15% (python#101251)
  pythongh-104223: Fix issues with inheriting from buffer classes (python#104227)
  pythongh-99108: fix typo in Modules/Setup (python#104293)
  pythonGH-104145: Use fully-qualified cross reference types for the bisect module (python#104172)
  pythongh-103193: Improve `getattr_static` test coverage (python#104286)
  Trim trailing whitespace and test on CI (python#104275)
  pythongh-102500: Remove mention of bytes shorthand (python#104281)
  pythongh-97696: Improve and fix documentation for asyncio eager tasks (python#104256)
  pythongh-99108: Replace SHA3 implementation HACL* version (python#103597)
  pythongh-104273: Remove redundant len() calls in argparse function (python#104274)
  pythongh-64660: Don't hardcode Argument Clinic return converter result variable name (python#104200)
  pythongh-104265 Disallow instantiation of `_csv.Reader` and `_csv.Writer` (python#104266)
  pythonGH-102613: Improve performance of `pathlib.Path.rglob()` (pythonGH-104244)
  pythongh-103650: Fix perf maps address format (python#103651)
  pythonGH-89812: Churn `pathlib.Path` methods (pythonGH-104243)
  ...
  • Loading branch information
carljm committed May 9, 2023
2 parents ffae4e6 + bf89d42 commit 76077cd
Show file tree
Hide file tree
Showing 147 changed files with 3,589 additions and 1,549 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -7,6 +7,9 @@
# GitHub
.github/** @ezio-melotti @hugovk

# pre-commit
.pre-commit-config.yaml @hugovk @AlexWaygood

# Build system
configure* @erlend-aasland @corona10

Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/lint.yml
@@ -0,0 +1,22 @@
name: Lint

on: [push, pull_request, workflow_dispatch]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- uses: pre-commit/action@v3.0.0
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: trailing-whitespace
types_or: [c, python, rst]
2 changes: 1 addition & 1 deletion Doc/c-api/dict.rst
Expand Up @@ -154,7 +154,7 @@ Dictionary Objects
.. c:function:: Py_ssize_t PyDict_Size(PyObject *p)
.. index:: builtin: len
.. index:: pair: built-in function; len
Return the number of items in the dictionary. This is equivalent to
``len(p)`` on a dictionary.
Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/import.rst
Expand Up @@ -41,7 +41,7 @@ Importing Modules
.. c:function:: PyObject* PyImport_ImportModuleEx(const char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
.. index:: builtin: __import__
.. index:: pair: built-in function; __import__
Import a module. This is best described by referring to the built-in Python
function :func:`__import__`.
Expand Down Expand Up @@ -120,7 +120,7 @@ Importing Modules
.. c:function:: PyObject* PyImport_ExecCodeModule(const char *name, PyObject *co)
.. index:: builtin: compile
.. index:: pair: built-in function; compile
Given a module name (possibly of the form ``package.module``) and a code object
read from a Python bytecode file or obtained from the built-in function
Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/list.rst
Expand Up @@ -45,7 +45,7 @@ List Objects
.. c:function:: Py_ssize_t PyList_Size(PyObject *list)
.. index:: builtin: len
.. index:: pair: built-in function; len
Return the length of the list object in *list*; this is equivalent to
``len(list)`` on a list object.
Expand Down Expand Up @@ -138,7 +138,7 @@ List Objects
.. c:function:: PyObject* PyList_AsTuple(PyObject *list)
.. index:: builtin: tuple
.. index:: pair: built-in function; tuple
Return a new tuple object containing the contents of *list*; equivalent to
``tuple(list)``.
2 changes: 1 addition & 1 deletion Doc/c-api/mapping.rst
Expand Up @@ -20,7 +20,7 @@ See also :c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem` and
.. c:function:: Py_ssize_t PyMapping_Size(PyObject *o)
Py_ssize_t PyMapping_Length(PyObject *o)
.. index:: builtin: len
.. index:: pair: built-in function; len
Returns the number of keys in object *o* on success, and ``-1`` on failure.
This is equivalent to the Python expression ``len(o)``.
Expand Down
12 changes: 6 additions & 6 deletions Doc/c-api/number.rst
Expand Up @@ -64,15 +64,15 @@ Number Protocol
.. c:function:: PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2)
.. index:: builtin: divmod
.. index:: pair: built-in function; divmod
See the built-in function :func:`divmod`. Returns ``NULL`` on failure. This is
the equivalent of the Python expression ``divmod(o1, o2)``.
.. c:function:: PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3)
.. index:: builtin: pow
.. index:: pair: built-in function; pow
See the built-in function :func:`pow`. Returns ``NULL`` on failure. This is the
equivalent of the Python expression ``pow(o1, o2, o3)``, where *o3* is optional.
Expand All @@ -94,7 +94,7 @@ Number Protocol
.. c:function:: PyObject* PyNumber_Absolute(PyObject *o)
.. index:: builtin: abs
.. index:: pair: built-in function; abs
Returns the absolute value of *o*, or ``NULL`` on failure. This is the equivalent
of the Python expression ``abs(o)``.
Expand Down Expand Up @@ -192,7 +192,7 @@ Number Protocol
.. c:function:: PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3)
.. index:: builtin: pow
.. index:: pair: built-in function; pow
See the built-in function :func:`pow`. Returns ``NULL`` on failure. The operation
is done *in-place* when *o1* supports it. This is the equivalent of the Python
Expand Down Expand Up @@ -238,15 +238,15 @@ Number Protocol
.. c:function:: PyObject* PyNumber_Long(PyObject *o)
.. index:: builtin: int
.. index:: pair: built-in function; int
Returns the *o* converted to an integer object on success, or ``NULL`` on
failure. This is the equivalent of the Python expression ``int(o)``.
.. c:function:: PyObject* PyNumber_Float(PyObject *o)
.. index:: builtin: float
.. index:: pair: built-in function; float
Returns the *o* converted to a float object on success, or ``NULL`` on failure.
This is the equivalent of the Python expression ``float(o)``.
Expand Down
12 changes: 6 additions & 6 deletions Doc/c-api/object.rst
Expand Up @@ -190,7 +190,7 @@ Object Protocol
.. c:function:: PyObject* PyObject_Repr(PyObject *o)
.. index:: builtin: repr
.. index:: pair: built-in function; repr
Compute a string representation of object *o*. Returns the string
representation on success, ``NULL`` on failure. This is the equivalent of the
Expand All @@ -202,7 +202,7 @@ Object Protocol
.. c:function:: PyObject* PyObject_ASCII(PyObject *o)
.. index:: builtin: ascii
.. index:: pair: built-in function; ascii
As :c:func:`PyObject_Repr`, compute a string representation of object *o*, but
escape the non-ASCII characters in the string returned by
Expand All @@ -227,7 +227,7 @@ Object Protocol
.. c:function:: PyObject* PyObject_Bytes(PyObject *o)
.. index:: builtin: bytes
.. index:: pair: built-in function; bytes
Compute a bytes representation of object *o*. ``NULL`` is returned on
failure and a bytes object on success. This is equivalent to the Python
Expand Down Expand Up @@ -278,7 +278,7 @@ Object Protocol
.. c:function:: Py_hash_t PyObject_Hash(PyObject *o)
.. index:: builtin: hash
.. index:: pair: built-in function; hash
Compute and return the hash value of an object *o*. On failure, return ``-1``.
This is the equivalent of the Python expression ``hash(o)``.
Expand Down Expand Up @@ -312,7 +312,7 @@ Object Protocol
.. c:function:: PyObject* PyObject_Type(PyObject *o)
.. index:: builtin: type
.. index:: pair: built-in function; type
When *o* is non-``NULL``, returns a type object corresponding to the object type
of object *o*. On failure, raises :exc:`SystemError` and returns ``NULL``. This
Expand All @@ -332,7 +332,7 @@ Object Protocol
.. c:function:: Py_ssize_t PyObject_Size(PyObject *o)
Py_ssize_t PyObject_Length(PyObject *o)
.. index:: builtin: len
.. index:: pair: built-in function; len
Return the length of object *o*. If the object *o* provides either the sequence
and mapping protocols, the sequence length is returned. On error, ``-1`` is
Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/sequence.rst
Expand Up @@ -18,7 +18,7 @@ Sequence Protocol
.. c:function:: Py_ssize_t PySequence_Size(PyObject *o)
Py_ssize_t PySequence_Length(PyObject *o)
.. index:: builtin: len
.. index:: pair: built-in function; len
Returns the number of objects in sequence *o* on success, and ``-1`` on
failure. This is equivalent to the Python expression ``len(o)``.
Expand Down Expand Up @@ -120,7 +120,7 @@ Sequence Protocol
.. c:function:: PyObject* PySequence_Tuple(PyObject *o)
.. index:: builtin: tuple
.. index:: pair: built-in function; tuple
Return a tuple object with the same contents as the sequence or iterable *o*,
or ``NULL`` on failure. If *o* is a tuple, a new reference will be returned,
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/set.rst
Expand Up @@ -107,7 +107,7 @@ or :class:`frozenset` or instances of their subtypes.
.. c:function:: Py_ssize_t PySet_Size(PyObject *anyset)
.. index:: builtin: len
.. index:: pair: built-in function; len
Return the length of a :class:`set` or :class:`frozenset` object. Equivalent to
``len(anyset)``. Raises a :exc:`PyExc_SystemError` if *anyset* is not a
Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/structures.rst
Expand Up @@ -347,7 +347,7 @@ method.
.. data:: METH_CLASS
.. index:: builtin: classmethod
.. index:: pair: built-in function; classmethod
The method will be passed the type object as the first parameter rather
than an instance of the type. This is used to create *class methods*,
Expand All @@ -357,7 +357,7 @@ method.
.. data:: METH_STATIC
.. index:: builtin: staticmethod
.. index:: pair: built-in function; staticmethod
The method will be passed ``NULL`` as the first parameter rather than an
instance of the type. This is used to create *static methods*, similar to
Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/typeobj.rst
Expand Up @@ -805,7 +805,7 @@ and :c:type:`PyType_Type` effectively act as defaults.)

.. c:member:: reprfunc PyTypeObject.tp_repr
.. index:: builtin: repr
.. index:: pair: built-in function; repr

An optional pointer to a function that implements the built-in function
:func:`repr`.
Expand Down Expand Up @@ -870,7 +870,7 @@ and :c:type:`PyType_Type` effectively act as defaults.)

.. c:member:: hashfunc PyTypeObject.tp_hash
.. index:: builtin: hash
.. index:: pair: built-in function; hash

An optional pointer to a function that implements the built-in function
:func:`hash`.
Expand Down
2 changes: 1 addition & 1 deletion Doc/extending/newtypes.rst
Expand Up @@ -149,7 +149,7 @@ done. This can be done using the :c:func:`PyErr_Fetch` and

.. index::
single: string; object representation
builtin: repr
pair: built-in function; repr

Object Presentation
-------------------
Expand Down
29 changes: 25 additions & 4 deletions Doc/library/asyncio-task.rst
Expand Up @@ -560,6 +560,13 @@ Eager Task Factory
using the provided *custom_task_constructor* when creating a new task instead
of the default :class:`Task`.

*custom_task_constructor* must be a *callable* with the signature matching
the signature of :class:`Task.__init__ <Task>`.
The callable must return a :class:`asyncio.Task`-compatible object.

This function returns a *callable* intended to be used as a task factory of an
event loop via :meth:`loop.set_task_factory(factory) <loop.set_task_factory>`).

.. versionadded:: 3.12


Expand Down Expand Up @@ -1014,7 +1021,7 @@ Introspection
Task Object
===========

.. class:: Task(coro, *, loop=None, name=None)
.. class:: Task(coro, *, loop=None, name=None, context=None, eager_start=False)

A :class:`Future-like <Future>` object that runs a Python
:ref:`coroutine <coroutine>`. Not thread-safe.
Expand Down Expand Up @@ -1049,9 +1056,17 @@ Task Object
APIs except :meth:`Future.set_result` and
:meth:`Future.set_exception`.

Tasks support the :mod:`contextvars` module. When a Task
is created it copies the current context and later runs its
coroutine in the copied context.
An optional keyword-only *context* argument allows specifying a
custom :class:`contextvars.Context` for the *coro* to run in.
If no *context* is provided, the Task copies the current context
and later runs its coroutine in the copied context.

An optional keyword-only *eager_start* argument allows eagerly starting
the execution of the :class:`asyncio.Task` at task creation time.
If set to ``True`` and the event loop is running, the task will start
executing the coroutine immediately, until the first time the coroutine
blocks. If the coroutine returns or raises without blocking, the task
will be finished eagerly and will skip scheduling to the event loop.

.. versionchanged:: 3.7
Added support for the :mod:`contextvars` module.
Expand All @@ -1063,6 +1078,12 @@ Task Object
Deprecation warning is emitted if *loop* is not specified
and there is no running event loop.

.. versionchanged:: 3.11
Added the *context* parameter.

.. versionchanged:: 3.12
Added the *eager_start* parameter.

.. method:: done()

Return ``True`` if the Task is *done*.
Expand Down

0 comments on commit 76077cd

Please sign in to comment.