Skip to content

Commit 0bb0c69

Browse files
committed
Merge branch 'main' into cached_property
* main: (37 commits) pythongh-98251: Allow venv to pass along PYTHON* variables to pip and ensurepip when they do not impact path resolution (pythonGH-98259) Bpo-41246: IOCP Proactor avoid callback code duplication (python#21399) bpo-46364: Use sockets for stdin of asyncio only on AIX (python#30596) pythongh-98178: syslog() is not thread-safe on macOS (python#98213) Mark all targets in `Doc/Makefile` as `PHONY` (pythonGH-98189) pythongh-97982: Factorize PyUnicode_Count() and unicode_count() code (python#98025) pythongh-96265: Formatting changes for faq/general (python#98129) tutorial: remove "with single quotes" (python#98204) pythongh-97669: Remove Tools/scripts/startuptime.py (python#98214) signalmodule.c uses _PyErr_WriteUnraisableMsg() (python#98217) pythongh-97669: Fix test_tools reference leak (python#98216) pythongh-97669: Create Tools/patchcheck/ directory (python#98186) pythongh-65046: Link to logging cookbook from asyncio docs (python#98207) Formatting fixes in contextlib docs (python#98111) pythongh-95276: Add callable entry to the glossary (python#95738) pythongh-96130: Rephrase use of "typecheck" verb for clarity (python#98144) Fix some incorrect indentation around the main switch (python#98177) pythongh-98172: Fix formatting in `except*` docs (python#98173) pythongh-97982: Remove asciilib_count() (python#98164) pythongh-95756: Free and NULL-out code caches when needed (pythonGH-98181) ...
2 parents 26c2659 + 2fe44f7 commit 0bb0c69

File tree

76 files changed

+490
-2633
lines changed

Some content is hidden

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

76 files changed

+490
-2633
lines changed

.azure-pipelines/posix-steps.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ steps:
6868
- ${{ if eq(parameters.patchcheck, 'true') }}:
6969
- script: |
7070
git fetch origin
71-
./python Tools/scripts/patchcheck.py --ci true
71+
./python Tools/patchcheck/patchcheck.py --ci true
7272
displayName: 'Run patchcheck.py'
7373
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
7474

.github/workflows/build.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
- name: Add ccache to PATH
7474
run: echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
7575
- name: Configure ccache action
76-
uses: hendrikmuhs/ccache-action@v1
76+
uses: hendrikmuhs/ccache-action@v1.2
7777
- name: Check Autoconf version 2.69 and aclocal 1.16.3
7878
run: |
7979
grep "Generated by GNU Autoconf 2.69" configure
@@ -202,7 +202,7 @@ jobs:
202202
run: |
203203
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
204204
- name: Configure ccache action
205-
uses: hendrikmuhs/ccache-action@v1
205+
uses: hendrikmuhs/ccache-action@v1.2
206206
- name: Setup directory envs for out-of-tree builds
207207
run: |
208208
echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV
@@ -265,7 +265,7 @@ jobs:
265265
run: |
266266
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
267267
- name: Configure ccache action
268-
uses: hendrikmuhs/ccache-action@v1
268+
uses: hendrikmuhs/ccache-action@v1.2
269269
- name: Configure CPython
270270
run: ./configure --with-pydebug --with-openssl=$OPENSSL_DIR
271271
- name: Build CPython
@@ -309,7 +309,7 @@ jobs:
309309
run: |
310310
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
311311
- name: Configure ccache action
312-
uses: hendrikmuhs/ccache-action@v1
312+
uses: hendrikmuhs/ccache-action@v1.2
313313
- name: Configure CPython
314314
run: ./configure --with-address-sanitizer --without-pymalloc
315315
- name: Build CPython

Doc/Makefile

+3-16
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ 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 changes linkcheck \
25-
suspicious coverage doctest pydoc-topics htmlview clean dist check serve \
26-
autobuild-dev autobuild-stable venv
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
2727

2828
help:
2929
@echo "Please use \`make <target>' where <target> is one of"
@@ -42,7 +42,6 @@ help:
4242
@echo " doctest to run doctests in the documentation"
4343
@echo " pydoc-topics to regenerate the pydoc topics file"
4444
@echo " dist to create a \"dist\" directory with archived docs for download"
45-
@echo " suspicious to check for suspicious markup in output text"
4645
@echo " check to run a check for frequent markup errors"
4746

4847
build:
@@ -110,18 +109,6 @@ linkcheck:
110109
"or in build/$(BUILDER)/output.txt"; \
111110
false; }
112111

113-
suspicious: BUILDER = suspicious
114-
suspicious:
115-
@$(MAKE) build BUILDER=$(BUILDER) || { \
116-
echo "Suspicious check complete; look for any errors in the above output" \
117-
"or in build/$(BUILDER)/suspicious.csv. If all issues are false" \
118-
"positives, append that file to tools/susp-ignored.csv."; \
119-
false; }
120-
@echo "⚠ make suspicious is deprecated and will be removed soon."
121-
@echo "⚠ Use:"
122-
@echo "⚠ make check"
123-
@echo "⚠ instead."
124-
125112
coverage: BUILDER = coverage
126113
coverage: build
127114
@echo "Coverage finished; see c.txt and python.txt in build/coverage"

Doc/README.rst

-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ Available make targets are:
9393
plain text documentation for the labels defined in
9494
``tools/pyspecific.py`` -- pydoc needs these to show topic and keyword help.
9595

96-
* "suspicious", which checks the parsed markup for text that looks like
97-
malformed and thus unconverted reST.
98-
9996
* "check", which checks for frequent markup errors.
10097

10198
* "serve", which serves the build/html directory on port 8000.

Doc/c-api/buffer.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ a buffer, see :c:func:`PyObject_GetBuffer`.
9999
For :term:`contiguous` arrays, the value points to the beginning of
100100
the memory block.
101101

102-
.. c:member:: void *obj
102+
.. c:member:: PyObject *obj
103103
104104
A new reference to the exporting object. The reference is owned by
105105
the consumer and automatically decremented and set to ``NULL`` by

Doc/c-api/memoryview.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ any other object.
5555
*mview* **must** be a memoryview instance; this macro doesn't check its type,
5656
you must do it yourself or you will risk crashes.
5757
58-
.. c:function:: Py_buffer *PyMemoryView_GET_BASE(PyObject *mview)
58+
.. c:function:: PyObject *PyMemoryView_GET_BASE(PyObject *mview)
5959
6060
Return either a pointer to the exporting object that the memoryview is based
6161
on or ``NULL`` if the memoryview has been created by one of the functions

Doc/faq/general.rst

+18-12
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,15 @@ find packages of interest to you.
125125
How does the Python version numbering scheme work?
126126
--------------------------------------------------
127127

128-
Python versions are numbered A.B.C or A.B. A is the major version number -- it
129-
is only incremented for really major changes in the language. B is the minor
130-
version number, incremented for less earth-shattering changes. C is the
131-
micro-level -- it is incremented for each bugfix release. See :pep:`6` for more
132-
information about bugfix releases.
128+
Python versions are numbered "A.B.C" or "A.B":
129+
130+
* *A* is the major version number -- it is only incremented for really major
131+
changes in the language.
132+
* *B* is the minor version number -- it is incremented for less earth-shattering
133+
changes.
134+
* *C* is the micro version number -- it is incremented for each bugfix release.
135+
136+
See :pep:`6` for more information about bugfix releases.
133137

134138
Not all releases are bugfix releases. In the run-up to a new major release, a
135139
series of development releases are made, denoted as alpha, beta, or release
@@ -139,12 +143,14 @@ Betas are more stable, preserving existing interfaces but possibly adding new
139143
modules, and release candidates are frozen, making no changes except as needed
140144
to fix critical bugs.
141145

142-
Alpha, beta and release candidate versions have an additional suffix. The
143-
suffix for an alpha version is "aN" for some small number N, the suffix for a
144-
beta version is "bN" for some small number N, and the suffix for a release
145-
candidate version is "rcN" for some small number N. In other words, all versions
146-
labeled 2.0aN precede the versions labeled 2.0bN, which precede versions labeled
147-
2.0rcN, and *those* precede 2.0.
146+
Alpha, beta and release candidate versions have an additional suffix:
147+
148+
* The suffix for an alpha version is "aN" for some small number *N*.
149+
* The suffix for a beta version is "bN" for some small number *N*.
150+
* The suffix for a release candidate version is "rcN" for some small number *N*.
151+
152+
In other words, all versions labeled *2.0aN* precede the versions labeled
153+
*2.0bN*, which precede versions labeled *2.0rcN*, and *those* precede 2.0.
148154

149155
You may also find version numbers with a "+" suffix, e.g. "2.2+". These are
150156
unreleased versions, built directly from the CPython development repository. In
@@ -429,7 +435,7 @@ With the interpreter, documentation is never far from the student as they are
429435
programming.
430436

431437
There are also good IDEs for Python. IDLE is a cross-platform IDE for Python
432-
that is written in Python using Tkinter. PythonWin is a Windows-specific IDE.
438+
that is written in Python using Tkinter.
433439
Emacs users will be happy to know that there is a very good Python mode for
434440
Emacs. All of these programming environments provide syntax highlighting,
435441
auto-indenting, and access to the interactive interpreter while coding. Consult

Doc/glossary.rst

+10
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ Glossary
210210
A list of bytecode instructions can be found in the documentation for
211211
:ref:`the dis module <bytecodes>`.
212212

213+
callable
214+
A callable is an object that can be called, possibly with a set
215+
of arguments (see :term:`argument`), with the following syntax::
216+
217+
callable(argument1, argument2, ...)
218+
219+
A :term:`function`, and by extension a :term:`method`, is a callable.
220+
An instance of a class that implements the :meth:`~object.__call__`
221+
method is also a callable.
222+
213223
callback
214224
A subroutine function which is passed as an argument to be executed at
215225
some point in the future.

Doc/howto/logging-cookbook.rst

+2
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ configuration::
332332
print('complete')
333333

334334

335+
.. _blocking-handlers:
336+
335337
Dealing with handlers that block
336338
--------------------------------
337339

Doc/library/asyncio-dev.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ adjusted::
149149

150150

151151
Network logging can block the event loop. It is recommended to use
152-
a separate thread for handling logs or use non-blocking IO.
152+
a separate thread for handling logs or use non-blocking IO. For example,
153+
see :ref:`blocking-handlers`.
153154

154155

155156
.. _asyncio-coroutine-not-scheduled:

Doc/library/contextlib.rst

+17-11
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Functions and classes provided:
6666
# Code to release resource, e.g.:
6767
release_resource(resource)
6868

69+
The function can then be used like this::
70+
6971
>>> with managed_resource(timeout=3600) as resource:
7072
... # Resource is released at the end of this block,
7173
... # even if code in the block raises an exception
@@ -140,9 +142,9 @@ Functions and classes provided:
140142
finally:
141143
print(f'it took {time.monotonic() - now}s to run')
142144

143-
@timeit()
144-
async def main():
145-
# ... async code ...
145+
@timeit()
146+
async def main():
147+
# ... async code ...
146148

147149
When used as a decorator, a new generator instance is implicitly created on
148150
each function call. This allows the otherwise "one-shot" context managers
@@ -249,15 +251,15 @@ Functions and classes provided:
249251
:ref:`asynchronous context managers <async-context-managers>`::
250252

251253
async def send_http(session=None):
252-
if not session:
253-
# If no http session, create it with aiohttp
254-
cm = aiohttp.ClientSession()
255-
else:
256-
# Caller is responsible for closing the session
257-
cm = nullcontext(session)
254+
if not session:
255+
# If no http session, create it with aiohttp
256+
cm = aiohttp.ClientSession()
257+
else:
258+
# Caller is responsible for closing the session
259+
cm = nullcontext(session)
258260

259-
async with cm as session:
260-
# Send http requests with session
261+
async with cm as session:
262+
# Send http requests with session
261263

262264
.. versionadded:: 3.7
263265

@@ -396,6 +398,8 @@ Functions and classes provided:
396398
print('Finishing')
397399
return False
398400

401+
The class can then be used like this::
402+
399403
>>> @mycontext()
400404
... def function():
401405
... print('The bit in the middle')
@@ -466,6 +470,8 @@ Functions and classes provided:
466470
print('Finishing')
467471
return False
468472

473+
The class can then be used like this::
474+
469475
>>> @mycontext()
470476
... async def function():
471477
... print('The bit in the middle')

Doc/library/copyreg.rst

+6-9
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,17 @@ Such constructors may be factory functions or class instances.
2525
hence not valid as a constructor), raises :exc:`TypeError`.
2626

2727

28-
.. function:: pickle(type, function, constructor=None)
28+
.. function:: pickle(type, function, constructor_ob=None)
2929

3030
Declares that *function* should be used as a "reduction" function for objects
3131
of type *type*. *function* should return either a string or a tuple
32-
containing two or three elements.
32+
containing two or three elements. See the :attr:`~pickle.Pickler.dispatch_table`
33+
for more details on the interface of *function*.
3334

34-
The optional *constructor* parameter, if provided, is a callable object which
35-
can be used to reconstruct the object when called with the tuple of arguments
36-
returned by *function* at pickling time. A :exc:`TypeError` is raised if the
37-
*constructor* is not callable.
35+
The *constructor_ob* parameter is a legacy feature and is now ignored, but if
36+
passed it must be a callable.
3837

39-
See the :mod:`pickle` module for more details on the interface
40-
expected of *function* and *constructor*. Note that the
41-
:attr:`~pickle.Pickler.dispatch_table` attribute of a pickler
38+
Note that the :attr:`~pickle.Pickler.dispatch_table` attribute of a pickler
4239
object or subclass of :class:`pickle.Pickler` can also be used for
4340
declaring reduction functions.
4441

Doc/library/os.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ process and user.
304304

305305
.. function:: getenv(key, default=None)
306306

307-
Return the value of the environment variable *key* if it exists, or
308-
*default* if it doesn't. *key*, *default* and the result are str. Note that
307+
Return the value of the environment variable *key* as a string if it exists, or
308+
*default* if it doesn't. *key* is a string. Note that
309309
since :func:`getenv` uses :data:`os.environ`, the mapping of :func:`getenv` is
310310
similarly also captured on import, and the function may not reflect
311311
future environment changes.
@@ -319,8 +319,8 @@ process and user.
319319

320320
.. function:: getenvb(key, default=None)
321321

322-
Return the value of the environment variable *key* if it exists, or
323-
*default* if it doesn't. *key*, *default* and the result are bytes. Note that
322+
Return the value of the environment variable *key* as bytes if it exists, or
323+
*default* if it doesn't. *key* must be bytes. Note that
324324
since :func:`getenvb` uses :data:`os.environb`, the mapping of :func:`getenvb` is
325325
similarly also captured on import, and the function may not reflect
326326
future environment changes.

Doc/library/typing.rst

+10-10
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ A type alias is defined by assigning the type to the alias. In this example,
105105
def scale(scalar: float, vector: Vector) -> Vector:
106106
return [scalar * num for num in vector]
107107

108-
# typechecks; a list of floats qualifies as a Vector.
108+
# passes type checking; a list of floats qualifies as a Vector.
109109
new_vector = scale(2.0, [1.0, -4.2, 5.4])
110110

111111
Type aliases are useful for simplifying complex type signatures. For example::
@@ -147,10 +147,10 @@ of the original type. This is useful in helping catch logical errors::
147147
def get_user_name(user_id: UserId) -> str:
148148
...
149149

150-
# typechecks
150+
# passes type checking
151151
user_a = get_user_name(UserId(42351))
152152

153-
# does not typecheck; an int is not a UserId
153+
# fails type checking; an int is not a UserId
154154
user_b = get_user_name(-1)
155155

156156
You may still perform all ``int`` operations on a variable of type ``UserId``,
@@ -176,7 +176,7 @@ It is invalid to create a subtype of ``Derived``::
176176

177177
UserId = NewType('UserId', int)
178178

179-
# Fails at runtime and does not typecheck
179+
# Fails at runtime and does not pass type checking
180180
class AdminUserId(UserId): pass
181181

182182
However, it is possible to create a :class:`NewType` based on a 'derived' ``NewType``::
@@ -463,12 +463,12 @@ value of type :data:`Any` and assign it to any variable::
463463
s = a # OK
464464

465465
def foo(item: Any) -> int:
466-
# Typechecks; 'item' could be any type,
466+
# Passes type checking; 'item' could be any type,
467467
# and that type might have a 'bar' method
468468
item.bar()
469469
...
470470

471-
Notice that no typechecking is performed when assigning a value of type
471+
Notice that no type checking is performed when assigning a value of type
472472
:data:`Any` to a more precise type. For example, the static type checker did
473473
not report an error when assigning ``a`` to ``s`` even though ``s`` was
474474
declared to be of type :class:`str` and receives an :class:`int` value at
@@ -500,20 +500,20 @@ reject almost all operations on it, and assigning it to a variable (or using
500500
it as a return value) of a more specialized type is a type error. For example::
501501

502502
def hash_a(item: object) -> int:
503-
# Fails; an object does not have a 'magic' method.
503+
# Fails type checking; an object does not have a 'magic' method.
504504
item.magic()
505505
...
506506

507507
def hash_b(item: Any) -> int:
508-
# Typechecks
508+
# Passes type checking
509509
item.magic()
510510
...
511511

512-
# Typechecks, since ints and strs are subclasses of object
512+
# Passes type checking, since ints and strs are subclasses of object
513513
hash_a(42)
514514
hash_a("foo")
515515

516-
# Typechecks, since Any is compatible with all types
516+
# Passes type checking, since Any is compatible with all types
517517
hash_b(42)
518518
hash_b("foo")
519519

0 commit comments

Comments
 (0)