Skip to content

Commit

Permalink
Merge branch 'main' into cached_property
Browse files Browse the repository at this point in the history
* 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)
  ...
  • Loading branch information
carljm committed Oct 14, 2022
2 parents 26c2659 + 2fe44f7 commit 0bb0c69
Show file tree
Hide file tree
Showing 76 changed files with 490 additions and 2,633 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/posix-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ steps:
- ${{ if eq(parameters.patchcheck, 'true') }}:
- script: |
git fetch origin
./python Tools/scripts/patchcheck.py --ci true
./python Tools/patchcheck/patchcheck.py --ci true
displayName: 'Run patchcheck.py'
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
- name: Add ccache to PATH
run: echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
- name: Configure ccache action
uses: hendrikmuhs/ccache-action@v1
uses: hendrikmuhs/ccache-action@v1.2
- name: Check Autoconf version 2.69 and aclocal 1.16.3
run: |
grep "Generated by GNU Autoconf 2.69" configure
Expand Down Expand Up @@ -202,7 +202,7 @@ jobs:
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
- name: Configure ccache action
uses: hendrikmuhs/ccache-action@v1
uses: hendrikmuhs/ccache-action@v1.2
- name: Setup directory envs for out-of-tree builds
run: |
echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV
Expand Down Expand Up @@ -265,7 +265,7 @@ jobs:
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
- name: Configure ccache action
uses: hendrikmuhs/ccache-action@v1
uses: hendrikmuhs/ccache-action@v1.2
- name: Configure CPython
run: ./configure --with-pydebug --with-openssl=$OPENSSL_DIR
- name: Build CPython
Expand Down Expand Up @@ -309,7 +309,7 @@ jobs:
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
- name: Configure ccache action
uses: hendrikmuhs/ccache-action@v1
uses: hendrikmuhs/ccache-action@v1.2
- name: Configure CPython
run: ./configure --with-address-sanitizer --without-pymalloc
- name: Build CPython
Expand Down
19 changes: 3 additions & 16 deletions Doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ PAPEROPT_letter = -D latex_elements.papersize=letterpaper
ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees $(PAPEROPT_$(PAPER)) -j auto \
$(SPHINXOPTS) $(SPHINXERRORHANDLING) . build/$(BUILDER) $(SOURCES)

.PHONY: help build html htmlhelp latex text texinfo changes linkcheck \
suspicious coverage doctest pydoc-topics htmlview clean dist check serve \
autobuild-dev autobuild-stable venv
.PHONY: help build html htmlhelp latex text texinfo epub changes linkcheck \
coverage doctest pydoc-topics htmlview clean clean-venv venv dist check serve \
autobuild-dev autobuild-dev-html autobuild-stable autobuild-stable-html

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

build:
Expand Down Expand Up @@ -110,18 +109,6 @@ linkcheck:
"or in build/$(BUILDER)/output.txt"; \
false; }

suspicious: BUILDER = suspicious
suspicious:
@$(MAKE) build BUILDER=$(BUILDER) || { \
echo "Suspicious check complete; look for any errors in the above output" \
"or in build/$(BUILDER)/suspicious.csv. If all issues are false" \
"positives, append that file to tools/susp-ignored.csv."; \
false; }
@echo "⚠ make suspicious is deprecated and will be removed soon."
@echo "⚠ Use:"
@echo "⚠ make check"
@echo "⚠ instead."

coverage: BUILDER = coverage
coverage: build
@echo "Coverage finished; see c.txt and python.txt in build/coverage"
Expand Down
3 changes: 0 additions & 3 deletions Doc/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ Available make targets are:
plain text documentation for the labels defined in
``tools/pyspecific.py`` -- pydoc needs these to show topic and keyword help.

* "suspicious", which checks the parsed markup for text that looks like
malformed and thus unconverted reST.

* "check", which checks for frequent markup errors.

* "serve", which serves the build/html directory on port 8000.
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/buffer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ a buffer, see :c:func:`PyObject_GetBuffer`.
For :term:`contiguous` arrays, the value points to the beginning of
the memory block.

.. c:member:: void *obj
.. c:member:: PyObject *obj
A new reference to the exporting object. The reference is owned by
the consumer and automatically decremented and set to ``NULL`` by
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/memoryview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ any other object.
*mview* **must** be a memoryview instance; this macro doesn't check its type,
you must do it yourself or you will risk crashes.
.. c:function:: Py_buffer *PyMemoryView_GET_BASE(PyObject *mview)
.. c:function:: PyObject *PyMemoryView_GET_BASE(PyObject *mview)
Return either a pointer to the exporting object that the memoryview is based
on or ``NULL`` if the memoryview has been created by one of the functions
Expand Down
30 changes: 18 additions & 12 deletions Doc/faq/general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,15 @@ find packages of interest to you.
How does the Python version numbering scheme work?
--------------------------------------------------

Python versions are numbered A.B.C or A.B. A is the major version number -- it
is only incremented for really major changes in the language. B is the minor
version number, incremented for less earth-shattering changes. C is the
micro-level -- it is incremented for each bugfix release. See :pep:`6` for more
information about bugfix releases.
Python versions are numbered "A.B.C" or "A.B":

* *A* is the major version number -- it is only incremented for really major
changes in the language.
* *B* is the minor version number -- it is incremented for less earth-shattering
changes.
* *C* is the micro version number -- it is incremented for each bugfix release.

See :pep:`6` for more information about bugfix releases.

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

Alpha, beta and release candidate versions have an additional suffix. The
suffix for an alpha version is "aN" for some small number N, the suffix for a
beta version is "bN" for some small number N, and the suffix for a release
candidate version is "rcN" for some small number N. In other words, all versions
labeled 2.0aN precede the versions labeled 2.0bN, which precede versions labeled
2.0rcN, and *those* precede 2.0.
Alpha, beta and release candidate versions have an additional suffix:

* The suffix for an alpha version is "aN" for some small number *N*.
* The suffix for a beta version is "bN" for some small number *N*.
* The suffix for a release candidate version is "rcN" for some small number *N*.

In other words, all versions labeled *2.0aN* precede the versions labeled
*2.0bN*, which precede versions labeled *2.0rcN*, and *those* precede 2.0.

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

There are also good IDEs for Python. IDLE is a cross-platform IDE for Python
that is written in Python using Tkinter. PythonWin is a Windows-specific IDE.
that is written in Python using Tkinter.
Emacs users will be happy to know that there is a very good Python mode for
Emacs. All of these programming environments provide syntax highlighting,
auto-indenting, and access to the interactive interpreter while coding. Consult
Expand Down
10 changes: 10 additions & 0 deletions Doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ Glossary
A list of bytecode instructions can be found in the documentation for
:ref:`the dis module <bytecodes>`.

callable
A callable is an object that can be called, possibly with a set
of arguments (see :term:`argument`), with the following syntax::

callable(argument1, argument2, ...)

A :term:`function`, and by extension a :term:`method`, is a callable.
An instance of a class that implements the :meth:`~object.__call__`
method is also a callable.

callback
A subroutine function which is passed as an argument to be executed at
some point in the future.
Expand Down
2 changes: 2 additions & 0 deletions Doc/howto/logging-cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ configuration::
print('complete')


.. _blocking-handlers:

Dealing with handlers that block
--------------------------------

Expand Down
3 changes: 2 additions & 1 deletion Doc/library/asyncio-dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ adjusted::


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


.. _asyncio-coroutine-not-scheduled:
Expand Down
28 changes: 17 additions & 11 deletions Doc/library/contextlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Functions and classes provided:
# Code to release resource, e.g.:
release_resource(resource)

The function can then be used like this::

>>> with managed_resource(timeout=3600) as resource:
... # Resource is released at the end of this block,
... # even if code in the block raises an exception
Expand Down Expand Up @@ -140,9 +142,9 @@ Functions and classes provided:
finally:
print(f'it took {time.monotonic() - now}s to run')

@timeit()
async def main():
# ... async code ...
@timeit()
async def main():
# ... async code ...

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

async def send_http(session=None):
if not session:
# If no http session, create it with aiohttp
cm = aiohttp.ClientSession()
else:
# Caller is responsible for closing the session
cm = nullcontext(session)
if not session:
# If no http session, create it with aiohttp
cm = aiohttp.ClientSession()
else:
# Caller is responsible for closing the session
cm = nullcontext(session)

async with cm as session:
# Send http requests with session
async with cm as session:
# Send http requests with session

.. versionadded:: 3.7

Expand Down Expand Up @@ -396,6 +398,8 @@ Functions and classes provided:
print('Finishing')
return False

The class can then be used like this::

>>> @mycontext()
... def function():
... print('The bit in the middle')
Expand Down Expand Up @@ -466,6 +470,8 @@ Functions and classes provided:
print('Finishing')
return False

The class can then be used like this::

>>> @mycontext()
... async def function():
... print('The bit in the middle')
Expand Down
15 changes: 6 additions & 9 deletions Doc/library/copyreg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,17 @@ Such constructors may be factory functions or class instances.
hence not valid as a constructor), raises :exc:`TypeError`.


.. function:: pickle(type, function, constructor=None)
.. function:: pickle(type, function, constructor_ob=None)

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

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

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

Expand Down
8 changes: 4 additions & 4 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ process and user.

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

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

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

Return the value of the environment variable *key* if it exists, or
*default* if it doesn't. *key*, *default* and the result are bytes. Note that
Return the value of the environment variable *key* as bytes if it exists, or
*default* if it doesn't. *key* must be bytes. Note that
since :func:`getenvb` uses :data:`os.environb`, the mapping of :func:`getenvb` is
similarly also captured on import, and the function may not reflect
future environment changes.
Expand Down
20 changes: 10 additions & 10 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ A type alias is defined by assigning the type to the alias. In this example,
def scale(scalar: float, vector: Vector) -> Vector:
return [scalar * num for num in vector]

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

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

# typechecks
# passes type checking
user_a = get_user_name(UserId(42351))

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

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

UserId = NewType('UserId', int)

# Fails at runtime and does not typecheck
# Fails at runtime and does not pass type checking
class AdminUserId(UserId): pass

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

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

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

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

def hash_b(item: Any) -> int:
# Typechecks
# Passes type checking
item.magic()
...

# Typechecks, since ints and strs are subclasses of object
# Passes type checking, since ints and strs are subclasses of object
hash_a(42)
hash_a("foo")

# Typechecks, since Any is compatible with all types
# Passes type checking, since Any is compatible with all types
hash_b(42)
hash_b("foo")

Expand Down
Loading

0 comments on commit 0bb0c69

Please sign in to comment.