Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cc34df5

Browse files
Merge branch 'main' into asyncio-get_event_loop3-3.12
2 parents 1e22c6f + d9dff4c commit cc34df5

336 files changed

Lines changed: 7033 additions & 10513 deletions

File tree

Some content is hidden

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

.azure-pipelines/windows-layout-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ steps:
1212
displayName: Show layout info (${{ parameters.kind }})
1313

1414
- ${{ if eq(parameters.fulltest, 'true') }}:
15-
- script: .\python.exe -m test -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0 --junit-xml="$(Build.BinariesDirectory)\test-results-${{ parameters.kind }}.xml" --tempdir "$(Build.BinariesDirectory)\tmp-${{ parameters.kind }}-$(arch)"
15+
- script: .\python.exe -m test -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0 --junit-xml="$(Build.BinariesDirectory)\test-results-${{ parameters.kind }}.xml" --tempdir "$(Build.BinariesDirectory)\tmp-${{ parameters.kind }}-$(arch)" -i test_launcher
1616
workingDirectory: $(Build.BinariesDirectory)\layout-${{ parameters.kind }}-$(arch)
1717
displayName: ${{ parameters.kind }} Tests
1818
env:

.github/CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Python/traceback.c @iritkatriel
6363
# bytecode.
6464
**/*import*.c @brettcannon @encukou @ericsnowcurrently @ncoghlan @warsaw
6565
**/*import*.py @brettcannon @encukou @ericsnowcurrently @ncoghlan @warsaw
66-
**/*importlib/resources/* @jaraco @warsaw @brettcannon @FFY00
66+
**/*importlib/resources/* @jaraco @warsaw @FFY00
6767
**/importlib/metadata/* @jaraco @warsaw
6868

6969
# Dates and times
@@ -144,7 +144,7 @@ Lib/ast.py @isidentical
144144
**/*cgi* @ethanfurman
145145
**/*tarfile* @ethanfurman
146146

147-
**/*tomllib* @encukou
147+
**/*tomllib* @encukou @hauntsaninja
148148

149149
**/*sysconfig* @FFY00
150150

@@ -153,7 +153,7 @@ Lib/ast.py @isidentical
153153
**/*osx_support* @python/macos-team
154154

155155
# pathlib
156-
**/*pathlib* @brettcannon
156+
**/*pathlib* @barneygale
157157

158158
# zipfile.Path
159159
**/*zipfile/*_path.py @jaraco

.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/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
steps:
1717
- name: "Check PRs"
18-
uses: actions/stale@v6
18+
uses: actions/stale@v7
1919
with:
2020
repo-token: ${{ secrets.GITHUB_TOKEN }}
2121
stale-pr-message: 'This PR is stale because it has been open for 30 days with no activity.'

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/init.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ code, or when embedding the Python interpreter:
10491049
.. versionchanged:: 3.2
10501050
This function cannot be called before :c:func:`Py_Initialize()` anymore.
10511051
1052-
.. deprecated-removed:: 3.9 3.11
1052+
.. deprecated:: 3.9
10531053
10541054
.. index:: module: _thread
10551055
@@ -1063,7 +1063,7 @@ code, or when embedding the Python interpreter:
10631063
.. versionchanged:: 3.7
10641064
The :term:`GIL` is now initialized by :c:func:`Py_Initialize()`.
10651065
1066-
.. deprecated-removed:: 3.9 3.11
1066+
.. deprecated:: 3.9
10671067
10681068
10691069
.. c:function:: PyThreadState* PyEval_SaveThread()

Doc/c-api/structures.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ Defining Getters and Setters
615615
616616
.. c:member:: getter PyGetSetDef.get
617617
618-
C funtion to get the attribute.
618+
C function to get the attribute.
619619
620620
.. c:member:: setter PyGetSetDef.set
621621

Doc/c-api/typeobj.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ slot typedefs
452452
| | | |
453453
| | :c:type:`PyObject` * | |
454454
| | :c:type:`Py_ssize_t` | |
455+
| | :c:type:`PyObject` * | |
455456
+-----------------------------+-----------------------------+----------------------+
456457
| :c:type:`objobjproc` | .. line-block:: | int |
457458
| | | |
@@ -2633,7 +2634,7 @@ Slot Type typedefs
26332634
26342635
.. c:type:: PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t)
26352636
2636-
.. c:type:: int (*ssizeobjargproc)(PyObject *, Py_ssize_t)
2637+
.. c:type:: int (*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *)
26372638
26382639
.. c:type:: int (*objobjproc)(PyObject *, PyObject *)
26392640

Doc/copyright.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Copyright
44

55
Python and this documentation is:
66

7-
Copyright © 2001-2022 Python Software Foundation. All rights reserved.
7+
Copyright © 2001-2023 Python Software Foundation. All rights reserved.
88

99
Copyright © 2000 BeOpen.com. All rights reserved.
1010

Doc/faq/programming.rst

Lines changed: 42 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

@@ -1024,6 +1026,46 @@ What does 'UnicodeDecodeError' or 'UnicodeEncodeError' error mean?
10241026
See the :ref:`unicode-howto`.
10251027

10261028

1029+
.. _faq-programming-raw-string-backslash:
1030+
1031+
Can I end a raw string with an odd number of backslashes?
1032+
---------------------------------------------------------
1033+
1034+
A raw string ending with an odd number of backslashes will escape the string's quote::
1035+
1036+
>>> r'C:\this\will\not\work\'
1037+
File "<stdin>", line 1
1038+
r'C:\this\will\not\work\'
1039+
^
1040+
SyntaxError: unterminated string literal (detected at line 1)
1041+
1042+
There are several workarounds for this. One is to use regular strings and double
1043+
the backslashes::
1044+
1045+
>>> 'C:\\this\\will\\work\\'
1046+
'C:\\this\\will\\work\\'
1047+
1048+
Another is to concatenate a regular string containing an escaped backslash to the
1049+
raw string::
1050+
1051+
>>> r'C:\this\will\work' '\\'
1052+
'C:\\this\\will\\work\\'
1053+
1054+
It is also possible to use :func:`os.path.join` to append a backslash on Windows::
1055+
1056+
>>> os.path.join(r'C:\this\will\work', '')
1057+
'C:\\this\\will\\work\\'
1058+
1059+
Note that while a backslash will "escape" a quote for the purposes of
1060+
determining where the raw string ends, no escaping occurs when interpreting the
1061+
value of the raw string. That is, the backslash remains present in the value of
1062+
the raw string::
1063+
1064+
>>> r'backslash\'preserved'
1065+
"backslash\\'preserved"
1066+
1067+
Also see the specification in the :ref:`language reference <strings>`.
1068+
10271069
Performance
10281070
===========
10291071

0 commit comments

Comments
 (0)