Skip to content

Commit 576c914

Browse files
Merge remote-tracking branch 'origin/main' into more_load_attr
2 parents fe02743 + 2eea959 commit 576c914

File tree

164 files changed

+2340
-1592
lines changed

Some content is hidden

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

164 files changed

+2340
-1592
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ jobs:
235235
strategy:
236236
fail-fast: false
237237
matrix:
238-
openssl_ver: [1.1.1s, 3.0.7]
238+
openssl_ver: [1.1.1s, 3.0.7, 3.1.0-beta1]
239239
env:
240240
OPENSSL_VER: ${{ matrix.openssl_ver }}
241241
MULTISSL_DIR: ${{ github.workspace }}/multissl

.github/workflows/doc.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,8 @@ jobs:
5050
run: make -C Doc/ venv
5151
- name: 'Check documentation'
5252
run: make -C Doc/ check
53-
- name: 'Upload NEWS'
54-
uses: actions/upload-artifact@v3
55-
with:
56-
name: NEWS
57-
path: Doc/build/NEWS
5853
- name: 'Build HTML documentation'
5954
run: make -C Doc/ SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" html
60-
- name: 'Upload docs'
61-
uses: actions/upload-artifact@v3
62-
with:
63-
name: doc-html
64-
path: Doc/build/html
6555

6656
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
6757
doctest:

Doc/c-api/apiabiversion.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ See :ref:`stable` for a discussion of API and ABI stability across versions.
5858
Thus ``3.4.1a2`` is hexversion ``0x030401a2`` and ``3.10.0`` is
5959
hexversion ``0x030a00f0``.
6060

61+
Use this for numeric comparisons, e.g. ``#if PY_VERSION_HEX >= ...``.
62+
6163
This version is also available via the symbol :data:`Py_Version`.
6264

6365
.. c:var:: const unsigned long Py_Version

Doc/c-api/arg.rst

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,39 @@ These formats allow accessing an object as a contiguous chunk of memory.
3434
You don't have to provide raw storage for the returned unicode or bytes
3535
area.
3636

37-
In general, when a format sets a pointer to a buffer, the buffer is
38-
managed by the corresponding Python object, and the buffer shares
39-
the lifetime of this object. You won't have to release any memory yourself.
40-
The only exceptions are ``es``, ``es#``, ``et`` and ``et#``.
41-
42-
However, when a :c:type:`Py_buffer` structure gets filled, the underlying
43-
buffer is locked so that the caller can subsequently use the buffer even
44-
inside a :c:type:`Py_BEGIN_ALLOW_THREADS` block without the risk of mutable data
45-
being resized or destroyed. As a result, **you have to call**
46-
:c:func:`PyBuffer_Release` after you have finished processing the data (or
47-
in any early abort case).
48-
4937
Unless otherwise stated, buffers are not NUL-terminated.
5038

51-
Some formats require a read-only :term:`bytes-like object`, and set a
52-
pointer instead of a buffer structure. They work by checking that
53-
the object's :c:member:`PyBufferProcs.bf_releasebuffer` field is ``NULL``,
54-
which disallows mutable objects such as :class:`bytearray`.
39+
There are three ways strings and buffers can be converted to C:
40+
41+
* Formats such as ``y*`` and ``s*`` fill a :c:type:`Py_buffer` structure.
42+
This locks the underlying buffer so that the caller can subsequently use
43+
the buffer even inside a :c:type:`Py_BEGIN_ALLOW_THREADS`
44+
block without the risk of mutable data being resized or destroyed.
45+
As a result, **you have to call** :c:func:`PyBuffer_Release` after you have
46+
finished processing the data (or in any early abort case).
47+
48+
* The ``es``, ``es#``, ``et`` and ``et#`` formats allocate the result buffer.
49+
**You have to call** :c:func:`PyMem_Free` after you have finished
50+
processing the data (or in any early abort case).
51+
52+
* .. _c-arg-borrowed-buffer:
53+
54+
Other formats take a :class:`str` or a read-only :term:`bytes-like object`,
55+
such as :class:`bytes`, and provide a ``const char *`` pointer to
56+
its buffer.
57+
In this case the buffer is "borrowed": it is managed by the corresponding
58+
Python object, and shares the lifetime of this object.
59+
You won't have to release any memory yourself.
60+
61+
To ensure that the underlying buffer may be safely borrowed, the object's
62+
:c:member:`PyBufferProcs.bf_releasebuffer` field must be ``NULL``.
63+
This disallows common mutable objects such as :class:`bytearray`,
64+
but also some read-only objects such as :class:`memoryview` of
65+
:class:`bytes`.
66+
67+
Besides this ``bf_releasebuffer`` requirement, there is no check to verify
68+
whether the input object is immutable (e.g. whether it would honor a request
69+
for a writable buffer, or whether another thread can mutate the data).
5570

5671
.. note::
5772

@@ -89,7 +104,7 @@ which disallows mutable objects such as :class:`bytearray`.
89104
Unicode objects are converted to C strings using ``'utf-8'`` encoding.
90105

91106
``s#`` (:class:`str`, read-only :term:`bytes-like object`) [const char \*, :c:type:`Py_ssize_t`]
92-
Like ``s*``, except that it doesn't accept mutable objects.
107+
Like ``s*``, except that it provides a :ref:`borrowed buffer <c-arg-borrowed-buffer>`.
93108
The result is stored into two C variables,
94109
the first one a pointer to a C string, the second one its length.
95110
The string may contain embedded null bytes. Unicode objects are converted
@@ -108,8 +123,9 @@ which disallows mutable objects such as :class:`bytearray`.
108123
pointer is set to ``NULL``.
109124

110125
``y`` (read-only :term:`bytes-like object`) [const char \*]
111-
This format converts a bytes-like object to a C pointer to a character
112-
string; it does not accept Unicode objects. The bytes buffer must not
126+
This format converts a bytes-like object to a C pointer to a
127+
:ref:`borrowed <c-arg-borrowed-buffer>` character string;
128+
it does not accept Unicode objects. The bytes buffer must not
113129
contain embedded null bytes; if it does, a :exc:`ValueError`
114130
exception is raised.
115131

Doc/c-api/structures.rst

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -228,29 +228,30 @@ Implementing functions and methods
228228
Structure used to describe a method of an extension type. This structure has
229229
four fields:
230230
231-
+------------------+---------------+-------------------------------+
232-
| Field | C Type | Meaning |
233-
+==================+===============+===============================+
234-
| :attr:`ml_name` | const char \* | name of the method |
235-
+------------------+---------------+-------------------------------+
236-
| :attr:`ml_meth` | PyCFunction | pointer to the C |
237-
| | | implementation |
238-
+------------------+---------------+-------------------------------+
239-
| :attr:`ml_flags` | int | flag bits indicating how the |
240-
| | | call should be constructed |
241-
+------------------+---------------+-------------------------------+
242-
| :attr:`ml_doc` | const char \* | points to the contents of the |
243-
| | | docstring |
244-
+------------------+---------------+-------------------------------+
245-
246-
The :attr:`ml_meth` is a C function pointer. The functions may be of different
231+
.. c:member:: const char* ml_name
232+
233+
name of the method
234+
235+
.. c:member:: PyCFunction ml_meth
236+
237+
pointer to the C implementation
238+
239+
.. c:member:: int ml_flags
240+
241+
flags bits indicating how the call should be constructed
242+
243+
.. c:member:: const char* ml_doc
244+
245+
points to the contents of the docstring
246+
247+
The :c:member:`ml_meth` is a C function pointer. The functions may be of different
247248
types, but they always return :c:expr:`PyObject*`. If the function is not of
248249
the :c:type:`PyCFunction`, the compiler will require a cast in the method table.
249250
Even though :c:type:`PyCFunction` defines the first parameter as
250251
:c:expr:`PyObject*`, it is common that the method implementation uses the
251252
specific C type of the *self* object.
252253
253-
The :attr:`ml_flags` field is a bitfield which can include the following flags.
254+
The :c:member:`ml_flags` field is a bitfield which can include the following flags.
254255
The individual flags indicate either a calling convention or a binding
255256
convention.
256257

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Quick Reference
147147
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
148148
| :c:member:`~PyTypeObject.tp_vectorcall` | :c:type:`vectorcallfunc` | | | | | |
149149
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
150-
| :c:member:`~PyTypeObject.tp_watched` | char | | | | | |
150+
| [:c:member:`~PyTypeObject.tp_watched`] | char | | | | | |
151151
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
152152

153153
.. [#slots]

Doc/faq/programming.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ Yes. The coding style required for standard library modules is documented as
113113
Core Language
114114
=============
115115

116+
.. _faq-unboundlocalerror:
117+
116118
Why am I getting an UnboundLocalError when the variable has a value?
117119
--------------------------------------------------------------------
118120

Doc/library/asyncio-eventloop.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,8 @@ Watching file descriptors
932932

933933
.. method:: loop.remove_reader(fd)
934934

935-
Stop monitoring the *fd* file descriptor for read availability.
935+
Stop monitoring the *fd* file descriptor for read availability. Returns
936+
``True`` if *fd* was previously being monitored for reads.
936937

937938
.. method:: loop.add_writer(fd, callback, *args)
938939

@@ -945,7 +946,8 @@ Watching file descriptors
945946

946947
.. method:: loop.remove_writer(fd)
947948

948-
Stop monitoring the *fd* file descriptor for write availability.
949+
Stop monitoring the *fd* file descriptor for write availability. Returns
950+
``True`` if *fd* was previously being monitored for writes.
949951

950952
See also :ref:`Platform Support <asyncio-platform-support>` section
951953
for some limitations of these methods.

Doc/library/contextvars.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ Manual Context Management
144144
To get a copy of the current context use the
145145
:func:`~contextvars.copy_context` function.
146146

147+
Every thread will have a different top-level :class:`~contextvars.Context`
148+
object. This means that a :class:`ContextVar` object behaves in a similar
149+
fashion to :func:`threading.local()` when values are assigned in different
150+
threads.
151+
147152
Context implements the :class:`collections.abc.Mapping` interface.
148153

149154
.. method:: run(callable, *args, **kwargs)

Doc/library/functions.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,10 @@ are always available. They are listed here in alphabetical order.
17331733
.. versionchanged:: 3.8
17341734
The *start* parameter can be specified as a keyword argument.
17351735

1736+
.. versionchanged:: 3.12 Summation of floats switched to an algorithm
1737+
that gives higher accuracy on most builds.
1738+
1739+
17361740
.. class:: super()
17371741
super(type, object_or_type=None)
17381742

0 commit comments

Comments
 (0)