Skip to content

Commit 1bf8b25

Browse files
committed
Merge remote-tracking branch 'upstream/main' into pythongh-99203
2 parents 0cfc858 + 7a37523 commit 1bf8b25

File tree

705 files changed

+26363
-19525
lines changed

Some content is hidden

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

705 files changed

+26363
-19525
lines changed

.azure-pipelines/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
displayName: Pre-build checks
99

1010
pool:
11-
vmImage: ubuntu-20.04
11+
vmImage: ubuntu-22.04
1212

1313
steps:
1414
- template: ./prebuild-checks.yml
@@ -20,7 +20,7 @@ jobs:
2020
condition: and(succeeded(), eq(dependencies.Prebuild.outputs['docs.run'], 'true'))
2121

2222
pool:
23-
vmImage: ubuntu-20.04
23+
vmImage: ubuntu-22.04
2424

2525
steps:
2626
- template: ./docs-steps.yml
@@ -52,7 +52,7 @@ jobs:
5252
condition: and(succeeded(), eq(dependencies.Prebuild.outputs['tests.run'], 'true'))
5353

5454
pool:
55-
vmImage: ubuntu-20.04
55+
vmImage: ubuntu-22.04
5656

5757
variables:
5858
testRunTitle: '$(build.sourceBranchName)-linux'
@@ -78,7 +78,7 @@ jobs:
7878
)
7979
8080
pool:
81-
vmImage: ubuntu-20.04
81+
vmImage: ubuntu-22.04
8282

8383
variables:
8484
testRunTitle: '$(Build.SourceBranchName)-linux-coverage'

.azure-pipelines/pr.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
displayName: Pre-build checks
99

1010
pool:
11-
vmImage: ubuntu-20.04
11+
vmImage: ubuntu-22.04
1212

1313
steps:
1414
- template: ./prebuild-checks.yml
@@ -20,7 +20,7 @@ jobs:
2020
condition: and(succeeded(), eq(dependencies.Prebuild.outputs['docs.run'], 'true'))
2121

2222
pool:
23-
vmImage: ubuntu-20.04
23+
vmImage: ubuntu-22.04
2424

2525
steps:
2626
- template: ./docs-steps.yml
@@ -52,7 +52,7 @@ jobs:
5252
condition: and(succeeded(), eq(dependencies.Prebuild.outputs['tests.run'], 'true'))
5353

5454
pool:
55-
vmImage: ubuntu-20.04
55+
vmImage: ubuntu-22.04
5656

5757
variables:
5858
testRunTitle: '$(system.pullRequest.TargetBranch)-linux'
@@ -78,7 +78,7 @@ jobs:
7878
)
7979
8080
pool:
81-
vmImage: ubuntu-20.04
81+
vmImage: ubuntu-22.04
8282

8383
variables:
8484
testRunTitle: '$(Build.SourceBranchName)-linux-coverage'

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

+1-1
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

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# GitHub
88
.github/** @ezio-melotti
99

10+
# Build system
11+
configure* @erlend-aasland @corona10
12+
1013
# asyncio
1114
**/*asyncio* @1st1 @asvetlov @gvanrossum @kumaraditya303
1215

@@ -63,7 +66,7 @@ Python/traceback.c @iritkatriel
6366
# bytecode.
6467
**/*import*.c @brettcannon @encukou @ericsnowcurrently @ncoghlan @warsaw
6568
**/*import*.py @brettcannon @encukou @ericsnowcurrently @ncoghlan @warsaw
66-
**/*importlib/resources/* @jaraco @warsaw @brettcannon @FFY00
69+
**/*importlib/resources/* @jaraco @warsaw @FFY00
6770
**/importlib/metadata/* @jaraco @warsaw
6871

6972
# Dates and times
@@ -144,7 +147,7 @@ Lib/ast.py @isidentical
144147
**/*cgi* @ethanfurman
145148
**/*tarfile* @ethanfurman
146149

147-
**/*tomllib* @encukou
150+
**/*tomllib* @encukou @hauntsaninja
148151

149152
**/*sysconfig* @FFY00
150153

@@ -153,7 +156,7 @@ Lib/ast.py @isidentical
153156
**/*osx_support* @python/macos-team
154157

155158
# pathlib
156-
**/*pathlib* @brettcannon
159+
**/*pathlib* @barneygale
157160

158161
# zipfile.Path
159162
**/*zipfile/*_path.py @jaraco

.github/workflows/build.yml

+1-1
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

-10
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:

.github/workflows/stale.yml

+1-1
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/Makefile

+24-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ PAPEROPT_letter = -D latex_elements.papersize=letterpaper
2121
ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees $(PAPEROPT_$(PAPER)) -j auto \
2222
$(SPHINXOPTS) $(SPHINXERRORHANDLING) . build/$(BUILDER) $(SOURCES)
2323

24-
.PHONY: help build html htmlhelp latex text texinfo epub changes linkcheck \
25-
coverage doctest pydoc-topics htmlview clean clean-venv venv dist check serve \
26-
autobuild-dev autobuild-dev-html autobuild-stable autobuild-stable-html
27-
24+
.PHONY: help
2825
help:
2926
@echo "Please use \`make <target>' where <target> is one of"
3027
@echo " clean to remove build files"
@@ -44,6 +41,7 @@ help:
4441
@echo " dist to create a \"dist\" directory with archived docs for download"
4542
@echo " check to run a check for frequent markup errors"
4643

44+
.PHONY: build
4745
build:
4846
-mkdir -p build
4947
# Look first for a Misc/NEWS file (building from a source release tarball
@@ -70,70 +68,85 @@ build:
7068
$(SPHINXBUILD) $(ALLSPHINXOPTS)
7169
@echo
7270

71+
.PHONY: html
7372
html: BUILDER = html
7473
html: build
7574
@echo "Build finished. The HTML pages are in build/html."
7675

76+
.PHONY: htmlhelp
7777
htmlhelp: BUILDER = htmlhelp
7878
htmlhelp: build
7979
@echo "Build finished; now you can run HTML Help Workshop with the" \
8080
"build/htmlhelp/pydoc.hhp project file."
8181

82+
.PHONY: latex
8283
latex: BUILDER = latex
8384
latex: build
8485
@echo "Build finished; the LaTeX files are in build/latex."
8586
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
8687
"run these through (pdf)latex."
8788

89+
.PHONY: text
8890
text: BUILDER = text
8991
text: build
9092
@echo "Build finished; the text files are in build/text."
9193

94+
.PHONY: texinfo
9295
texinfo: BUILDER = texinfo
9396
texinfo: build
9497
@echo "Build finished; the python.texi file is in build/texinfo."
9598
@echo "Run \`make info' in that directory to run it through makeinfo."
9699

100+
.PHONY: epub
97101
epub: BUILDER = epub
98102
epub: build
99103
@echo "Build finished; the epub files are in build/epub."
100104

105+
.PHONY: changes
101106
changes: BUILDER = changes
102107
changes: build
103108
@echo "The overview file is in build/changes."
104109

110+
.PHONY: linkcheck
105111
linkcheck: BUILDER = linkcheck
106112
linkcheck:
107113
@$(MAKE) build BUILDER=$(BUILDER) || { \
108114
echo "Link check complete; look for any errors in the above output" \
109115
"or in build/$(BUILDER)/output.txt"; \
110116
false; }
111117

118+
.PHONY: coverage
112119
coverage: BUILDER = coverage
113120
coverage: build
114121
@echo "Coverage finished; see c.txt and python.txt in build/coverage"
115122

123+
.PHONY: doctest
116124
doctest: BUILDER = doctest
117125
doctest:
118126
@$(MAKE) build BUILDER=$(BUILDER) || { \
119127
echo "Testing of doctests in the sources finished, look at the" \
120128
"results in build/doctest/output.txt"; \
121129
false; }
122130

131+
.PHONY: pydoc-topics
123132
pydoc-topics: BUILDER = pydoc-topics
124133
pydoc-topics: build
125134
@echo "Building finished; now run this:" \
126135
"cp build/pydoc-topics/topics.py ../Lib/pydoc_data/topics.py"
127136

137+
.PHONY: htmlview
128138
htmlview: html
129139
$(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('build/html/index.html'))"
130140

141+
.PHONY: clean
131142
clean: clean-venv
132143
-rm -rf build/*
133144

145+
.PHONY: clean-venv
134146
clean-venv:
135147
rm -rf $(VENVDIR)
136148

149+
.PHONY: venv
137150
venv:
138151
@if [ -d $(VENVDIR) ] ; then \
139152
echo "venv already exists."; \
@@ -145,6 +158,7 @@ venv:
145158
echo "The venv has been created in the $(VENVDIR) directory"; \
146159
fi
147160

161+
.PHONY: dist
148162
dist:
149163
rm -rf dist
150164
mkdir -p dist
@@ -199,12 +213,14 @@ dist:
199213
rm -r dist/python-$(DISTVERSION)-docs-texinfo
200214
rm dist/python-$(DISTVERSION)-docs-texinfo.tar
201215

216+
.PHONY: check
202217
check:
203218
# Check the docs and NEWS files with sphinx-lint.
204219
# Ignore the tools and venv dirs and check that the default role is not used.
205220
$(SPHINXLINT) -i tools -i $(VENVDIR) --enable default-role
206221
$(SPHINXLINT) --enable default-role ../Misc/NEWS.d/next/
207222

223+
.PHONY: serve
208224
serve:
209225
@echo "The serve target was removed, use htmlview instead (see bpo-36329)"
210226

@@ -216,22 +232,26 @@ serve:
216232
# output files)
217233

218234
# for development releases: always build
235+
.PHONY: autobuild-dev
219236
autobuild-dev:
220237
make dist SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1'
221238

222239
# for quick rebuilds (HTML only)
240+
.PHONY: autobuild-dev-html
223241
autobuild-dev-html:
224242
make html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1'
225243

226244
# for stable releases: only build if not in pre-release stage (alpha, beta)
227245
# release candidate downloads are okay, since the stable tree can be in that stage
246+
.PHONY: autobuild-stable
228247
autobuild-stable:
229248
@case $(DISTVERSION) in *[ab]*) \
230249
echo "Not building; $(DISTVERSION) is not a release version."; \
231250
exit 1;; \
232251
esac
233252
@make autobuild-dev
234253

254+
.PHONY: autobuild-stable-html
235255
autobuild-stable-html:
236256
@case $(DISTVERSION) in *[ab]*) \
237257
echo "Not building; $(DISTVERSION) is not a release version."; \

Doc/_static/og-image.png

14.2 KB
Loading

Doc/c-api/apiabiversion.rst

+2
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

+35-19
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

0 commit comments

Comments
 (0)