Skip to content

Commit 720a1d0

Browse files
Merge remote-tracking branch 'upstream/main' into tail-call
2 parents b7f5faf + 87fb8b1 commit 720a1d0

32 files changed

+590
-63
lines changed

Android/android-env.sh

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# This script must be sourced with the following variables already set:
2-
: ${ANDROID_HOME:?} # Path to Android SDK
3-
: ${HOST:?} # GNU target triplet
2+
: "${ANDROID_HOME:?}" # Path to Android SDK
3+
: "${HOST:?}" # GNU target triplet
44

55
# You may also override the following:
6-
: ${api_level:=24} # Minimum Android API level the build will run on
7-
: ${PREFIX:-} # Path in which to find required libraries
6+
: "${api_level:=24}" # Minimum Android API level the build will run on
7+
: "${PREFIX:-}" # Path in which to find required libraries
88

99

1010
# Print all messages on stderr so they're visible when running within build-wheel.
@@ -27,20 +27,20 @@ fail() {
2727
ndk_version=27.1.12297006
2828

2929
ndk=$ANDROID_HOME/ndk/$ndk_version
30-
if ! [ -e $ndk ]; then
30+
if ! [ -e "$ndk" ]; then
3131
log "Installing NDK - this may take several minutes"
32-
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "ndk;$ndk_version"
32+
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "ndk;$ndk_version"
3333
fi
3434

35-
if [ $HOST = "arm-linux-androideabi" ]; then
35+
if [ "$HOST" = "arm-linux-androideabi" ]; then
3636
clang_triplet=armv7a-linux-androideabi
3737
else
38-
clang_triplet=$HOST
38+
clang_triplet="$HOST"
3939
fi
4040

4141
# These variables are based on BuildSystemMaintainers.md above, and
4242
# $ndk/build/cmake/android.toolchain.cmake.
43-
toolchain=$(echo $ndk/toolchains/llvm/prebuilt/*)
43+
toolchain=$(echo "$ndk"/toolchains/llvm/prebuilt/*)
4444
export AR="$toolchain/bin/llvm-ar"
4545
export AS="$toolchain/bin/llvm-as"
4646
export CC="$toolchain/bin/${clang_triplet}${api_level}-clang"
@@ -72,12 +72,12 @@ LDFLAGS="$LDFLAGS -lm"
7272

7373
# -mstackrealign is included where necessary in the clang launcher scripts which are
7474
# pointed to by $CC, so we don't need to include it here.
75-
if [ $HOST = "arm-linux-androideabi" ]; then
75+
if [ "$HOST" = "arm-linux-androideabi" ]; then
7676
CFLAGS="$CFLAGS -march=armv7-a -mthumb"
7777
fi
7878

7979
if [ -n "${PREFIX:-}" ]; then
80-
abs_prefix=$(realpath $PREFIX)
80+
abs_prefix="$(realpath "$PREFIX")"
8181
CFLAGS="$CFLAGS -I$abs_prefix/include"
8282
LDFLAGS="$LDFLAGS -L$abs_prefix/lib"
8383

@@ -87,11 +87,13 @@ fi
8787

8888
# When compiling C++, some build systems will combine CFLAGS and CXXFLAGS, and some will
8989
# use CXXFLAGS alone.
90-
export CXXFLAGS=$CFLAGS
90+
export CXXFLAGS="$CFLAGS"
9191

9292
# Use the same variable name as conda-build
93-
if [ $(uname) = "Darwin" ]; then
94-
export CPU_COUNT=$(sysctl -n hw.ncpu)
93+
if [ "$(uname)" = "Darwin" ]; then
94+
CPU_COUNT="$(sysctl -n hw.ncpu)"
95+
export CPU_COUNT
9596
else
96-
export CPU_COUNT=$(nproc)
97+
CPU_COUNT="$(nproc)"
98+
export CPU_COUNT
9799
fi

Doc/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,6 @@
560560
r'https://github.com/python/cpython/tree/.*': 'https://github.com/python/cpython/blob/.*',
561561
# Intentional HTTP use at Misc/NEWS.d/3.5.0a1.rst
562562
r'http://www.python.org/$': 'https://www.python.org/$',
563-
# Used in license page, keep as is
564-
r'https://www.zope.org/': r'https://www.zope.dev/',
565563
# Microsoft's redirects to learn.microsoft.com
566564
r'https://msdn.microsoft.com/.*': 'https://learn.microsoft.com/.*',
567565
r'https://docs.microsoft.com/.*': 'https://learn.microsoft.com/.*',

Doc/library/os.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,33 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
16591659
:exc:`InterruptedError` exception (see :pep:`475` for the rationale).
16601660

16611661

1662+
.. function:: readinto(fd, buffer, /)
1663+
1664+
Read from a file descriptor *fd* into a mutable
1665+
:ref:`buffer object <bufferobjects>` *buffer*.
1666+
1667+
The *buffer* should be mutable and :term:`bytes-like <bytes-like object>`. On
1668+
success, returns the number of bytes read. Less bytes may be read than the
1669+
size of the buffer. The underlying system call will be retried when
1670+
interrupted by a signal, unless the signal handler raises an exception.
1671+
Other errors will not be retried and an error will be raised.
1672+
1673+
Returns 0 if *fd* is at end of file or if the provided *buffer* has
1674+
length 0 (which can be used to check for errors without reading data).
1675+
Never returns negative.
1676+
1677+
.. note::
1678+
1679+
This function is intended for low-level I/O and must be applied to a file
1680+
descriptor as returned by :func:`os.open` or :func:`os.pipe`. To read a
1681+
"file object" returned by the built-in function :func:`open`, or
1682+
:data:`sys.stdin`, use its member functions, for example
1683+
:meth:`io.BufferedIOBase.readinto`, :meth:`io.BufferedIOBase.read`, or
1684+
:meth:`io.TextIOBase.read`
1685+
1686+
.. versionadded:: next
1687+
1688+
16621689
.. function:: sendfile(out_fd, in_fd, offset, count)
16631690
sendfile(out_fd, in_fd, offset, count, headers=(), trailers=(), flags=0)
16641691

Doc/reference/import.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,10 @@ module.
762762

763763
The current working directory -- denoted by an empty string -- is handled
764764
slightly differently from other entries on :data:`sys.path`. First, if the
765-
current working directory is found to not exist, no value is stored in
766-
:data:`sys.path_importer_cache`. Second, the value for the current working
767-
directory is looked up fresh for each module lookup. Third, the path used for
768-
:data:`sys.path_importer_cache` and returned by
765+
current working directory cannot be determined or is found not to exist, no
766+
value is stored in :data:`sys.path_importer_cache`. Second, the value for the
767+
current working directory is looked up fresh for each module lookup. Third,
768+
the path used for :data:`sys.path_importer_cache` and returned by
769769
:meth:`importlib.machinery.PathFinder.find_spec` will be the actual current
770770
working directory and not the empty string.
771771

Doc/whatsnew/3.14.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@ os
561561
to the :mod:`os` module.
562562
(Contributed by James Roy in :gh:`127688`.)
563563

564+
* Add the :func:`os.readinto` function to read into a
565+
:ref:`buffer object <bufferobjects>` from a file descriptor.
566+
(Contributed by Cody Maloney in :gh:`129205`.)
567+
564568

565569
pathlib
566570
-------

Lib/asyncio/staggered.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from . import exceptions as exceptions_mod
99
from . import locks
1010
from . import tasks
11+
from . import futures
1112

1213

1314
async def staggered_race(coro_fns, delay, *, loop=None):
@@ -63,6 +64,7 @@ async def staggered_race(coro_fns, delay, *, loop=None):
6364
"""
6465
# TODO: when we have aiter() and anext(), allow async iterables in coro_fns.
6566
loop = loop or events.get_running_loop()
67+
parent_task = tasks.current_task(loop)
6668
enum_coro_fns = enumerate(coro_fns)
6769
winner_result = None
6870
winner_index = None
@@ -73,6 +75,7 @@ async def staggered_race(coro_fns, delay, *, loop=None):
7375

7476
def task_done(task):
7577
running_tasks.discard(task)
78+
futures.future_discard_from_awaited_by(task, parent_task)
7679
if (
7780
on_completed_fut is not None
7881
and not on_completed_fut.done()
@@ -110,6 +113,7 @@ async def run_one_coro(ok_to_start, previous_failed) -> None:
110113
this_failed = locks.Event()
111114
next_ok_to_start = locks.Event()
112115
next_task = loop.create_task(run_one_coro(next_ok_to_start, this_failed))
116+
futures.future_add_to_awaited_by(next_task, parent_task)
113117
running_tasks.add(next_task)
114118
next_task.add_done_callback(task_done)
115119
# next_task has been appended to running_tasks so next_task is ok to
@@ -148,6 +152,7 @@ async def run_one_coro(ok_to_start, previous_failed) -> None:
148152
try:
149153
ok_to_start = locks.Event()
150154
first_task = loop.create_task(run_one_coro(ok_to_start, None))
155+
futures.future_add_to_awaited_by(first_task, parent_task)
151156
running_tasks.add(first_task)
152157
first_task.add_done_callback(task_done)
153158
# first_task has been appended to running_tasks so first_task is ok to start.
@@ -171,4 +176,4 @@ async def run_one_coro(ok_to_start, previous_failed) -> None:
171176
raise propagate_cancellation_error
172177
return winner_result, winner_index, exceptions
173178
finally:
174-
del exceptions, propagate_cancellation_error, unhandled_exceptions
179+
del exceptions, propagate_cancellation_error, unhandled_exceptions, parent_task

Lib/configparser.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,11 +1105,7 @@ def _handle_continuation_line(self, st, line, fpname):
11051105
def _handle_rest(self, st, line, fpname):
11061106
# a section header or option header?
11071107
if self._allow_unnamed_section and st.cursect is None:
1108-
st.sectname = UNNAMED_SECTION
1109-
st.cursect = self._dict()
1110-
self._sections[st.sectname] = st.cursect
1111-
self._proxies[st.sectname] = SectionProxy(self, st.sectname)
1112-
st.elements_added.add(st.sectname)
1108+
self._handle_header(st, UNNAMED_SECTION, fpname)
11131109

11141110
st.indent_level = st.cur_indent_level
11151111
# is it a section header?
@@ -1118,10 +1114,10 @@ def _handle_rest(self, st, line, fpname):
11181114
if not mo and st.cursect is None:
11191115
raise MissingSectionHeaderError(fpname, st.lineno, line)
11201116

1121-
self._handle_header(st, mo, fpname) if mo else self._handle_option(st, line, fpname)
1117+
self._handle_header(st, mo.group('header'), fpname) if mo else self._handle_option(st, line, fpname)
11221118

1123-
def _handle_header(self, st, mo, fpname):
1124-
st.sectname = mo.group('header')
1119+
def _handle_header(self, st, sectname, fpname):
1120+
st.sectname = sectname
11251121
if st.sectname in self._sections:
11261122
if self._strict and st.sectname in st.elements_added:
11271123
raise DuplicateSectionError(st.sectname, fpname,

Lib/importlib/_bootstrap_external.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ def _path_importer_cache(cls, path):
12441244
if path == '':
12451245
try:
12461246
path = _os.getcwd()
1247-
except FileNotFoundError:
1247+
except (FileNotFoundError, PermissionError):
12481248
# Don't cache the failure as the cwd can easily change to
12491249
# a valid directory later on.
12501250
return None

Lib/importlib/resources/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
"""Read resources contained within a package."""
1+
"""
2+
Read resources contained within a package.
3+
4+
This codebase is shared between importlib.resources in the stdlib
5+
and importlib_resources in PyPI. See
6+
https://github.com/python/importlib_metadata/wiki/Development-Methodology
7+
for more detail.
8+
"""
29

310
from ._common import (
411
as_file,

Lib/importlib/resources/_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ def get_resource_reader(package: types.ModuleType) -> Optional[ResourceReader]:
6666
# zipimport.zipimporter does not support weak references, resulting in a
6767
# TypeError. That seems terrible.
6868
spec = package.__spec__
69-
reader = getattr(spec.loader, 'get_resource_reader', None) # type: ignore
69+
reader = getattr(spec.loader, 'get_resource_reader', None) # type: ignore[union-attr]
7070
if reader is None:
7171
return None
72-
return reader(spec.name) # type: ignore
72+
return reader(spec.name) # type: ignore[union-attr]
7373

7474

7575
@functools.singledispatch

0 commit comments

Comments
 (0)