From 77d2f6ed58dc54834f90acceabe78f939f34a6cc Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Fri, 12 Jun 2026 11:49:48 +0800 Subject: [PATCH 1/3] Update patch to Python 3.13.14. --- Makefile | 2 +- patch/Python/Python.patch | 70530 +++++++++++++++++++++++++++++++++++- 2 files changed, 69780 insertions(+), 752 deletions(-) diff --git a/Makefile b/Makefile index 5862497e..21b83dc1 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ BUILD_NUMBER=custom # of a release cycle, as official binaries won't be published. # PYTHON_MICRO_VERSION is the full version number, without any alpha/beta/rc suffix. (e.g., 3.10.0) # PYTHON_VER is the major/minor version (e.g., 3.10) -PYTHON_VERSION=3.13.11 +PYTHON_VERSION=3.13.14 PYTHON_PKG_VERSION=$(PYTHON_VERSION) PYTHON_MICRO_VERSION=$(shell echo $(PYTHON_VERSION) | grep -Eo "\d+\.\d+\.\d+") PYTHON_PKG_MICRO_VERSION=$(shell echo $(PYTHON_PKG_VERSION) | grep -Eo "\d+\.\d+\.\d+") diff --git a/patch/Python/Python.patch b/patch/Python/Python.patch index dc94847e..654ad6a7 100644 --- a/patch/Python/Python.patch +++ b/patch/Python/Python.patch @@ -1,10 +1,12 @@ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml -index 6347ffb3e11..19259c069d7 100644 +index ff08c7583fc..19259c069d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml -@@ -2,6 +2,10 @@ +@@ -1,7 +1,11 @@ + repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.13.2 +- rev: a27a2e47c7751b639d2b5badf0ef6ff11fee893f # frozen: v0.15.4 ++ rev: v0.13.2 hooks: + - id: ruff-check + name: Run Ruff (lint) on Apple/ @@ -13,7 +15,7 @@ index 6347ffb3e11..19259c069d7 100644 - id: ruff-check name: Run Ruff (lint) on Doc/ args: [--exit-non-zero-on-fix] -@@ -26,6 +30,10 @@ +@@ -26,47 +30,35 @@ name: Run Ruff (lint) on Tools/wasm/ args: [--exit-non-zero-on-fix, --config=Tools/wasm/.ruff.toml] files: ^Tools/wasm/ @@ -23,7 +25,796 @@ index 6347ffb3e11..19259c069d7 100644 + files: ^Apple - id: ruff-format name: Run Ruff (format) on Doc/ - args: [--check] +- args: [--exit-non-zero-on-fix] ++ args: [--check] + files: ^Doc/ + - id: ruff-format + name: Run Ruff (format) on Tools/wasm/ +- args: [--exit-non-zero-on-fix, --config=Tools/wasm/.ruff.toml] ++ args: [--check, --config=Tools/wasm/.ruff.toml] + files: ^Tools/wasm/ + + - repo: https://github.com/psf/black-pre-commit-mirror +- rev: ea488cebbfd88a5f50b8bd95d5c829d0bb76feb8 # frozen: 26.1.0 ++ rev: 25.9.0 + hooks: + - id: black + name: Run Black on Tools/jit/ + files: ^Tools/jit/ + + - repo: https://github.com/Lucas-C/pre-commit-hooks +- rev: ad1b27d73581aa16cca06fc4a0761fc563ffe8e8 # frozen: v1.5.6 ++ rev: v1.5.5 + hooks: + - id: remove-tabs + types: [python] + exclude: ^Tools/c-analyzer/cpython/_parser.py + +- - repo: local +- hooks: +- - id: blurb-no-space-c-api +- name: Check C API news entries +- language: fail +- entry: Space found in path, move to Misc/NEWS.d/next/C_API/ +- files: Misc/NEWS.d/next/C API/20.*.rst +- +- - repo: local +- hooks: +- - id: blurb-no-space-core-and-builtins +- name: Check Core and Builtins news entries +- language: fail +- entry: Space found in path, move to Misc/NEWS.d/next/Core_and_Builtins/ +- files: Misc/NEWS.d/next/Core and Builtins/20.*.rst +- + - repo: https://github.com/pre-commit/pre-commit-hooks +- rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0 ++ rev: v6.0.0 + hooks: + - id: check-case-conflict + - id: check-merge-conflict +@@ -78,33 +70,30 @@ + exclude: Lib/test/tokenizedata/coding20731.py + - id: end-of-file-fixer + files: '^\.github/CODEOWNERS$' +- - id: mixed-line-ending +- args: [--fix=auto] +- exclude: '^Lib/test/.*data/' + - id: trailing-whitespace + types_or: [c, inc, python, rst, yaml] + - id: trailing-whitespace + files: '^\.github/CODEOWNERS|\.(gram)$' + + - repo: https://github.com/python-jsonschema/check-jsonschema +- rev: 9f48a48aa91a6040d749ad68ec70907d907a5a7f # frozen: 0.37.0 ++ rev: 0.34.0 + hooks: + - id: check-dependabot + - id: check-github-workflows + - id: check-readthedocs + + - repo: https://github.com/rhysd/actionlint +- rev: 393031adb9afb225ee52ae2ccd7a5af5525e03e8 # frozen: v1.7.11 ++ rev: v1.7.7 + hooks: + - id: actionlint + +- - repo: https://github.com/zizmorcore/zizmor-pre-commit +- rev: b546b77c44c466a54a42af5499dcc0dcc1a3193f # frozen: v1.22.0 ++ - repo: https://github.com/woodruffw/zizmor-pre-commit ++ rev: v1.14.1 + hooks: + - id: zizmor + + - repo: https://github.com/sphinx-contrib/sphinx-lint +- rev: c883505f64b59c3c5c9375191e4ad9f98e727ccd # frozen: v1.0.2 ++ rev: v1.0.0 + hooks: + - id: sphinx-lint + args: [--enable=default-role] +diff --git a/Android/README.md b/Android/README.md +index 0004f26e72b..9f71aeb934f 100644 +--- a/Android/README.md ++++ b/Android/README.md +@@ -103,6 +103,14 @@ + Actions, the test script will do this automatically using the commands shown + [here](https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/). + ++The test suite can usually be run on a device with 2 GB of RAM, but this is ++borderline, so you may need to increase it to 4 GB. As of Android ++Studio Koala, 2 GB is the default for all emulators, although the user interface ++may indicate otherwise. Locate the emulator's directory under `~/.android/avd`, ++and find `hw.ramSize` in both config.ini and hardware-qemu.ini. Either set these ++manually to the same value, or use the Android Studio Device Manager, which will ++update both files. ++ + You can run the test suite either: + + * Within the CPython repository, after doing a build as described above. On +diff --git a/Android/android.py b/Android/android.py +index 7c316079854..50a0da47530 100755 +--- a/Android/android.py ++++ b/Android/android.py +@@ -15,7 +15,6 @@ + from asyncio import wait_for + from contextlib import asynccontextmanager + from datetime import datetime, timezone +-from enum import IntEnum, auto + from glob import glob + from os.path import abspath, basename, relpath + from pathlib import Path +@@ -34,12 +33,7 @@ + TESTBED_DIR = ANDROID_DIR / "testbed" + CROSS_BUILD_DIR = PYTHON_DIR / "cross-build" + +-HOSTS = [ +- "aarch64-linux-android", +- "arm-linux-androideabi", +- "i686-linux-android", +- "x86_64-linux-android", +-] ++HOSTS = ["aarch64-linux-android", "x86_64-linux-android"] + APP_ID = "org.python.testbed" + DECODE_ARGS = ("UTF-8", "backslashreplace") + +@@ -67,19 +61,6 @@ + hidden_output = [] + + +-# Based on android/log.h in the NDK. +-class LogPriority(IntEnum): +- UNKNOWN = 0 +- DEFAULT = auto() +- VERBOSE = auto() +- DEBUG = auto() +- INFO = auto() +- WARN = auto() +- ERROR = auto() +- FATAL = auto() +- SILENT = auto() +- +- + def log_verbose(context, line, stream=sys.stdout): + if context.verbose: + stream.write(line) +@@ -210,53 +191,38 @@ + # + # If you're a member of the Python core team, and you'd like to be able to push + # these tags yourself, please contact Malcolm Smith or Russell Keith-Magee. +-def unpack_deps(host, prefix_dir, cache_dir): ++def unpack_deps(host, prefix_dir): + os.chdir(prefix_dir) + deps_url = "https://github.com/beeware/cpython-android-source-deps/releases/download" +- for name_ver in [ +- "bzip2-1.0.8-3", +- "libffi-3.4.4-3", +- "openssl-3.0.21-0", +- "sqlite-3.50.4-0", +- "xz-5.4.6-1" +- ]: ++ for name_ver in ["bzip2-1.0.8-3", "libffi-3.4.4-3", "openssl-3.0.18-0", ++ "sqlite-3.50.4-0", "xz-5.4.6-1"]: + filename = f"{name_ver}-{host}.tar.gz" +- out_path = download(f"{deps_url}/{name_ver}/{filename}", cache_dir) +- shutil.unpack_archive(out_path) ++ download(f"{deps_url}/{name_ver}/{filename}") ++ shutil.unpack_archive(filename) ++ os.remove(filename) + + +-def download(url, cache_dir): +- out_path = cache_dir / basename(url) +- cache_dir.mkdir(parents=True, exist_ok=True) +- if not out_path.is_file(): +- run(["curl", "-Lf", "--retry", "5", "--retry-all-errors", "-o", out_path, url]) +- else: +- print(f"Using cached version of {basename(url)}") ++def download(url, target_dir="."): ++ out_path = f"{target_dir}/{basename(url)}" ++ run(["curl", "-Lf", "--retry", "5", "--retry-all-errors", "-o", out_path, url]) + return out_path + + +-def configure_host_python(context, host=None): +- if host is None: +- host = context.host ++def configure_host_python(context): + if context.clean: +- clean(host) ++ clean(context.host) + +- host_dir = subdir(host, create=True) ++ host_dir = subdir(context.host, create=True) + prefix_dir = host_dir / "prefix" + if not prefix_dir.exists(): + prefix_dir.mkdir() +- cache_dir = ( +- Path(context.cache_dir).resolve() +- if context.cache_dir +- else CROSS_BUILD_DIR / "downloads" +- ) +- unpack_deps(host, prefix_dir, cache_dir) ++ unpack_deps(context.host, prefix_dir) + + os.chdir(host_dir) + command = [ + # Basic cross-compiling configuration + relpath(PYTHON_DIR / "configure"), +- f"--host={host}", ++ f"--host={context.host}", + f"--build={sysconfig.get_config_var('BUILD_GNU_TYPE')}", + f"--with-build-python={build_python_path()}", + "--without-ensurepip", +@@ -272,16 +238,14 @@ + + if context.args: + command.extend(context.args) +- run(command, host=host) ++ run(command, host=context.host) + + +-def make_host_python(context, host=None): +- if host is None: +- host = context.host ++def make_host_python(context): + # The CFLAGS and LDFLAGS set in android-env include the prefix dir, so + # delete any previous Python installation to prevent it being used during + # the build. +- host_dir = subdir(host) ++ host_dir = subdir(context.host) + prefix_dir = host_dir / "prefix" + for pattern in ("include/python*", "lib/libpython*", "lib/python*"): + delete_glob(f"{prefix_dir}/{pattern}") +@@ -300,28 +264,20 @@ + ) + + +-def build_targets(context): +- if context.target in {"all", "build"}: +- configure_build_python(context) +- make_build_python(context) +- +- for host in HOSTS: +- if context.target in {"all", "hosts", host}: +- configure_host_python(context, host) +- make_host_python(context, host) ++def build_all(context): ++ steps = [configure_build_python, make_build_python, configure_host_python, ++ make_host_python] ++ for step in steps: ++ step(context) + + + def clean(host): + delete_glob(CROSS_BUILD_DIR / host) + + +-def clean_targets(context): +- if context.target in {"all", "build"}: +- clean("build") +- +- for host in HOSTS: +- if context.target in {"all", "hosts", host}: +- clean(host) ++def clean_all(context): ++ for host in HOSTS + ["build"]: ++ clean(host) + + + def setup_ci(): +@@ -398,6 +354,17 @@ + os.chmod(out_path, 0o755) + + ++# run_testbed will build the app automatically, but it's useful to have this as ++# a separate command to allow running the app outside of this script. ++def build_testbed(context): ++ setup_sdk() ++ setup_testbed() ++ run( ++ [gradlew, "--console", "plain", "packageDebug", "packageDebugAndroidTest"], ++ cwd=TESTBED_DIR, ++ ) ++ ++ + # Work around a bug involving sys.exit and TaskGroups + # (https://github.com/python/cpython/issues/101515). + def exit(*args): +@@ -538,23 +505,21 @@ + pid = await wait_for(find_pid(serial), startup_timeout) + + # `--pid` requires API level 24 or higher. +- # +- # `--binary` mode is used in order to detect which messages end with a +- # newline, which most of the other modes don't indicate (except `--format +- # long`). For example, every time pytest runs a test, it prints a "." and +- # flushes the stream. Each "." becomes a separate log message, but we should +- # show them all on the same line. +- args = [adb, "-s", serial, "logcat", "--pid", pid, "--binary"] ++ args = [adb, "-s", serial, "logcat", "--pid", pid, "--format", "tag"] + logcat_started = False + async with async_process( +- *args, stdout=subprocess.PIPE, stderr=None ++ *args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + ) as process: +- while True: +- try: +- priority, tag, message = await read_logcat(process.stdout) ++ while line := (await process.stdout.readline()).decode(*DECODE_ARGS): ++ if match := re.fullmatch(r"([A-Z])/(.*)", line, re.DOTALL): + logcat_started = True +- except asyncio.IncompleteReadError: +- break ++ level, message = match.groups() ++ else: ++ # If the regex doesn't match, this is either a logcat startup ++ # error, or the second or subsequent line of a multi-line ++ # message. Python won't produce multi-line messages, but other ++ # components might. ++ level, message = None, line + + # Exclude high-volume messages which are rarely useful. + if context.verbose < 2 and "from python test_syslog" in message: +@@ -562,23 +527,25 @@ + + # Put high-level messages on stderr so they're highlighted in the + # buildbot logs. This will include Python's own stderr. +- stream = sys.stderr if priority >= LogPriority.WARN else sys.stdout +- +- # The app's stdout and stderr should be passed through transparently +- # to our own corresponding streams. +- if tag in ["python.stdout", "python.stderr"]: +- global python_started +- python_started = True +- stream.write(message) +- stream.flush() ++ stream = ( ++ sys.stderr ++ if level in ["W", "E", "F"] # WARNING, ERROR, FATAL (aka ASSERT) ++ else sys.stdout ++ ) ++ ++ # To simplify automated processing of the output, e.g. a buildbot ++ # posting a failure notice on a GitHub PR, we strip the level and ++ # tag indicators from Python's stdout and stderr. ++ for prefix in ["python.stdout: ", "python.stderr: "]: ++ if message.startswith(prefix): ++ global python_started ++ python_started = True ++ stream.write(message.removeprefix(prefix)) ++ break + else: + # Non-Python messages add a lot of noise, but they may +- # sometimes help explain a failure. Format them in the same way +- # as `logcat --format tag`. +- formatted = f"{priority.name[0]}/{tag}: {message}" +- if not formatted.endswith("\n"): +- formatted += "\n" +- log_verbose(context, formatted, stream) ++ # sometimes help explain a failure. ++ log_verbose(context, line, stream) + + # If the device disconnects while logcat is running, which always + # happens in --managed mode, some versions of adb return non-zero. +@@ -589,44 +556,6 @@ + raise CalledProcessError(status, args) + + +-# Read one binary log message from the given StreamReader. The message format is +-# described at https://android.stackexchange.com/a/74660. All supported versions +-# of Android use format version 2 or later. +-async def read_logcat(stream): +- async def read_bytes(size): +- return await stream.readexactly(size) +- +- async def read_int(size): +- return int.from_bytes(await read_bytes(size), "little") +- +- payload_len = await read_int(2) +- if payload_len < 2: +- # 1 byte for priority, 1 byte for null terminator of tag. +- raise ValueError(f"payload length {payload_len} is too short") +- +- header_len = await read_int(2) +- if header_len < 4: +- raise ValueError(f"header length {header_len} is too short") +- await read_bytes(header_len - 4) # Ignore other header fields. +- +- priority_int = await read_int(1) +- try: +- priority = LogPriority(priority_int) +- except ValueError: +- priority = LogPriority.UNKNOWN +- +- payload_fields = (await read_bytes(payload_len - 1)).split(b"\0") +- if len(payload_fields) < 2: +- raise ValueError( +- f"payload {payload!r} does not contain at least 2 " +- f"null-separated fields" +- ) +- tag, message, *_ = [ +- field.decode(*DECODE_ARGS) for field in payload_fields +- ] +- return priority, tag, message +- +- + def stop_app(serial): + run([adb, "-s", serial, "shell", "am", "force-stop", APP_ID], log=False) + +@@ -639,10 +568,6 @@ + task_prefix = "connected" + env["ANDROID_SERIAL"] = context.connected + +- # Ensure that CROSS_BUILD_DIR is in the Gradle environment, regardless +- # of whether it was set by environment variable or `--cross-build-dir`. +- env["CROSS_BUILD_DIR"] = CROSS_BUILD_DIR +- + if context.ci_mode: + context.args[0:0] = [ + # See _add_ci_python_opts in libregrtest/main.py. +@@ -869,18 +794,6 @@ + + def add_parser(*args, **kwargs): + parser = subcommands.add_parser(*args, **kwargs) +- parser.add_argument( +- "--cross-build-dir", +- action="store", +- default=os.environ.get("CROSS_BUILD_DIR"), +- dest="cross_build_dir", +- type=Path, +- help=( +- "Path to the cross-build directory " +- f"(default: {CROSS_BUILD_DIR}). Can also be set " +- "with the CROSS_BUILD_DIR environment variable." +- ), +- ) + parser.add_argument( + "-v", "--verbose", action="count", default=0, + help="Show verbose output. Use twice to be even more verbose.") +@@ -888,9 +801,8 @@ + + # Subcommands + build = add_parser( +- "build", +- help="Run configure and make for the selected target" +- ) ++ "build", help="Run configure-build, make-build, configure-host and " ++ "make-host") + configure_build = add_parser( + "configure-build", help="Run `configure` for the build Python") + add_parser( +@@ -900,47 +812,20 @@ + make_host = add_parser( + "make-host", help="Run `make` for Android") + +- clean = add_parser( +- "clean", +- help="Delete build directories for the selected target" +- ) +- ++ add_parser("clean", help="Delete all build directories") ++ add_parser("build-testbed", help="Build the testbed app") + test = add_parser("test", help="Run the testbed app") + package = add_parser("package", help="Make a release package") + ci = add_parser("ci", help="Run build, package and test") + env = add_parser("env", help="Print environment variables") + + # Common arguments +- # --cache-dir option +- for cmd in [configure_host, build, ci]: +- cmd.add_argument( +- "--cache-dir", +- default=os.environ.get("CACHE_DIR"), +- help="The directory to store cached downloads.", +- ) +- +- # --clean option + for subcommand in [build, configure_build, configure_host, ci]: + subcommand.add_argument( + "--clean", action="store_true", default=False, dest="clean", + help="Delete the relevant build directories first") + +- # Allow "all", "build" and "hosts" targets for some commands +- for subcommand in [clean, build]: +- subcommand.add_argument( +- "target", +- nargs="?", +- default="all", +- choices=["all", "build", "hosts"] + HOSTS, +- help=( +- "The host triplet (e.g., aarch64-linux-android), " +- "or 'build' for just the build platform, or 'hosts' for all " +- "host platforms, or 'all' for the build platform and all " +- "hosts. Defaults to 'all'" +- ), +- ) +- +- host_commands = [configure_host, make_host, package, ci] ++ host_commands = [build, configure_host, make_host, package, ci] + if in_source_tree: + host_commands.append(env) + for subcommand in host_commands: +@@ -1002,19 +887,14 @@ + stream.reconfigure(line_buffering=True) + + context = parse_args() +- +- # Set the CROSS_BUILD_DIR if an argument was provided +- if context.cross_build_dir: +- global CROSS_BUILD_DIR +- CROSS_BUILD_DIR = context.cross_build_dir.resolve() +- + dispatch = { + "configure-build": configure_build_python, + "make-build": make_build_python, + "configure-host": configure_host_python, + "make-host": make_host_python, +- "build": build_targets, +- "clean": clean_targets, ++ "build": build_all, ++ "clean": clean_all, ++ "build-testbed": build_testbed, + "test": run_testbed, + "package": package, + "ci": ci, +diff --git a/Android/testbed/app/build.gradle.kts b/Android/testbed/app/build.gradle.kts +index bd8334b64bb..14d43d8c4d5 100644 +--- a/Android/testbed/app/build.gradle.kts ++++ b/Android/testbed/app/build.gradle.kts +@@ -8,26 +8,16 @@ + + val ANDROID_DIR = file("../..") + val PYTHON_DIR = ANDROID_DIR.parentFile!! +-val PYTHON_CROSS_DIR = file(System.getenv("CROSS_BUILD_DIR") ?: "$PYTHON_DIR/cross-build") ++val PYTHON_CROSS_DIR = file("$PYTHON_DIR/cross-build") + val inSourceTree = ( + ANDROID_DIR.name == "Android" && file("$PYTHON_DIR/pyconfig.h.in").exists() + ) + + val KNOWN_ABIS = mapOf( + "aarch64-linux-android" to "arm64-v8a", +- "arm-linux-androideabi" to "armeabi-v7a", +- "i686-linux-android" to "x86", + "x86_64-linux-android" to "x86_64", + ) + +-val osArch = System.getProperty("os.arch") +-val NATIVE_ABI = mapOf( +- "aarch64" to "arm64-v8a", +- "amd64" to "x86_64", +- "arm64" to "arm64-v8a", +- "x86_64" to "x86_64", +-)[osArch] ?: throw GradleException("Unknown os.arch '$osArch'") +- + // Discover prefixes. + val prefixes = ArrayList() + if (inSourceTree) { +@@ -102,15 +92,7 @@ + } + throw GradleException("Failed to find API level in $androidEnvFile") + } +- +- // This controls the API level of the maxVersion managed emulator, which is used +- // by CI and cibuildwheel. +- // * 33 has excessive buffering in the logcat client +- // (https://cs.android.com/android/_/android/platform/system/logging/+/d340721894f223327339010df59b0ac514308826). +- // * 34 consumes too much disk space on GitHub Actions (#142289). +- // * 35 has issues connecting to the internet (#142387). +- // * 36 and later are not available as aosp_atd images yet. +- targetSdk = 32 ++ targetSdk = 35 + + versionCode = 1 + versionName = "1.0" +@@ -143,10 +125,9 @@ + path("src/main/c/CMakeLists.txt") + } + +- // Set this property to something nonexistent but non-empty. Otherwise it'll use the +- // default list, which ignores asset directories beginning with an underscore, and +- // maybe also other files required by tests. +- aaptOptions.ignoreAssetsPattern = "android-testbed-dont-ignore-anything" ++ // Set this property to something non-empty, otherwise it'll use the default ++ // list, which ignores asset directories beginning with an underscore. ++ aaptOptions.ignoreAssetsPattern = ".git" + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 +@@ -159,9 +140,6 @@ + testOptions { + managedDevices { + localDevices { +- // systemImageSource should use what its documentation calls an +- // "explicit source", i.e. the sdkmanager package name format, because +- // that will be required in CreateEmulatorTask below. + create("minVersion") { + device = "Small Phone" + +@@ -170,13 +148,13 @@ + + // ATD devices are smaller and faster, but have a minimum + // API level of 30. +- systemImageSource = if (apiLevel >= 30) "aosp_atd" else "default" ++ systemImageSource = if (apiLevel >= 30) "aosp-atd" else "aosp" + } + + create("maxVersion") { + device = "Small Phone" + apiLevel = defaultConfig.targetSdk!! +- systemImageSource = "aosp_atd" ++ systemImageSource = "aosp-atd" + } + } + +@@ -202,138 +180,6 @@ + } + + +-afterEvaluate { +- // Every new emulator has a maximum of 2 GB RAM, regardless of its hardware profile +- // (https://cs.android.com/android-studio/platform/tools/base/+/refs/tags/studio-2025.3.2:sdklib/src/main/java/com/android/sdklib/internal/avd/EmulatedProperties.java;l=68). +- // This is barely enough to test Python, and not enough to test Pandas +- // (https://github.com/python/cpython/pull/137186#issuecomment-3136301023, +- // https://github.com/pandas-dev/pandas/pull/63405#issuecomment-3667846159). +- // So we'll increase it by editing the emulator configuration files. +- // +- // If the emulator doesn't exist yet, we want to edit it after it's created, but +- // before it starts for the first time. Otherwise it'll need to be cold-booted +- // again, which would slow down the first run, which is likely the only run in CI +- // environments. But the Setup task both creates and starts the emulator if it +- // doesn't already exist. So we create it ourselves before the Setup task runs. +- for (device in android.testOptions.managedDevices.localDevices) { +- val createTask = tasks.register("${device.name}Create") { +- this.device = device.device +- apiLevel = device.apiLevel +- systemImageSource = device.systemImageSource +- abi = NATIVE_ABI +- } +- tasks.named("${device.name}Setup") { +- dependsOn(createTask) +- } +- } +-} +- +-abstract class CreateEmulatorTask : DefaultTask() { +- @get:Input abstract val device: Property +- @get:Input abstract val apiLevel: Property +- @get:Input abstract val systemImageSource: Property +- @get:Input abstract val abi: Property +- @get:Inject abstract val execOps: ExecOperations +- +- private val avdName by lazy { +- listOf( +- "dev${apiLevel.get()}", +- systemImageSource.get(), +- abi.get(), +- device.get().replace(' ', '_'), +- ).joinToString("_") +- } +- +- private val avdDir by lazy { +- // XDG_CONFIG_HOME is respected by both avdmanager and Gradle. +- val userHome = System.getenv("ANDROID_USER_HOME") ?: ( +- (System.getenv("XDG_CONFIG_HOME") ?: System.getProperty("user.home")!!) +- + "/.android" +- ) +- File("$userHome/avd/gradle-managed", "$avdName.avd") +- } +- +- @TaskAction +- fun run() { +- if (!avdDir.exists()) { +- createAvd() +- } +- updateAvd() +- } +- +- fun createAvd() { +- val systemImage = listOf( +- "system-images", +- "android-${apiLevel.get()}", +- systemImageSource.get(), +- abi.get(), +- ).joinToString(";") +- +- runCmdlineTool("sdkmanager", systemImage) +- runCmdlineTool( +- "avdmanager", "create", "avd", +- "--name", avdName, +- "--path", avdDir, +- "--device", device.get().lowercase().replace(" ", "_"), +- "--package", systemImage, +- ) +- +- val iniName = "$avdName.ini" +- if (!File(avdDir.parentFile.parentFile, iniName).renameTo( +- File(avdDir.parentFile, iniName) +- )) { +- throw GradleException("Failed to rename $iniName") +- } +- } +- +- fun updateAvd() { +- for (filename in listOf( +- "config.ini", // Created by avdmanager; always exists +- "hardware-qemu.ini", // Created on first run; might not exist +- )) { +- val iniFile = File(avdDir, filename) +- if (!iniFile.exists()) { +- if (filename == "config.ini") { +- throw GradleException("$iniFile does not exist") +- } +- continue +- } +- +- val iniText = iniFile.readText() +- val pattern = Regex( +- """^\s*hw.ramSize\s*=\s*(.+?)\s*$""", RegexOption.MULTILINE +- ) +- val matches = pattern.findAll(iniText).toList() +- if (matches.size != 1) { +- throw GradleException( +- "Found ${matches.size} instances of $pattern in $iniFile; expected 1" +- ) +- } +- +- val expectedRam = "4096" +- if (matches[0].groupValues[1] != expectedRam) { +- iniFile.writeText( +- iniText.replace(pattern, "hw.ramSize = $expectedRam") +- ) +- } +- } +- } +- +- fun runCmdlineTool(tool: String, vararg args: Any) { +- val androidHome = System.getenv("ANDROID_HOME")!! +- val exeSuffix = +- if (System.getProperty("os.name").lowercase().startsWith("win")) ".exe" +- else "" +- val command = +- listOf("$androidHome/cmdline-tools/latest/bin/$tool$exeSuffix", *args) +- println(command.joinToString(" ")) +- execOps.exec { +- commandLine(command) +- } +- } +-} +- +- + // Create some custom tasks to copy Python and its standard library from + // elsewhere in the repository. + androidComponents.onVariants { variant -> +@@ -383,12 +229,6 @@ + from(cwd) + } + } +- +- // A filename ending with .gz will be automatically decompressed +- // while building the APK. Avoid this by adding a dash to the end, +- // and add an extra dash to any filenames that already end with one. +- // This will be undone in MainActivity.kt. +- rename(""".*(\.gz|-)""", "$0-") + } + } + +diff --git a/Android/testbed/app/src/main/java/org/python/testbed/MainActivity.kt b/Android/testbed/app/src/main/java/org/python/testbed/MainActivity.kt +index dc49cdb9a9f..5727b0fe6c3 100644 +--- a/Android/testbed/app/src/main/java/org/python/testbed/MainActivity.kt ++++ b/Android/testbed/app/src/main/java/org/python/testbed/MainActivity.kt +@@ -80,9 +80,7 @@ + continue + } + input.use { +- // Undo the .gz workaround from build.gradle.kts. +- val outputName = name.replace(Regex("""(.*)-"""), "$1") +- File(targetSubdir, outputName).outputStream().use { output -> ++ File(targetSubdir, name).outputStream().use { output -> + input.copyTo(output) + } + } +diff --git a/Apple/.ruff.toml b/Apple/.ruff.toml +new file mode 100644 +index 00000000000..4cdc39ebee4 --- /dev/null +++ b/Apple/.ruff.toml @@ -0,0 +1,22 @@ @@ -49,6 +840,9 @@ index 6347ffb3e11..19259c069d7 100644 + "W", # pycodestyle + "YTT", # flake8-2020 +] +diff --git a/Apple/__main__.py b/Apple/__main__.py +new file mode 100644 +index 00000000000..b134bbad972 --- /dev/null +++ b/Apple/__main__.py @@ -0,0 +1,1111 @@ @@ -928,7 +1722,7 @@ index 6347ffb3e11..19259c069d7 100644 + + [ + "--", + "test", -+ f"--{context.ci_mode}-ci", ++ f"--{context.ci_mode or 'fast'}-ci", + "--single-process", + "--no-randomize", + # Timeout handling requires subprocesses; explicitly setting @@ -1163,6 +1957,9 @@ index 6347ffb3e11..19259c069d7 100644 + stream.reconfigure(line_buffering=True) + + main() +diff --git a/Apple/iOS/README.md b/Apple/iOS/README.md +new file mode 100644 +index 00000000000..7ee257b5d64 --- /dev/null +++ b/Apple/iOS/README.md @@ -0,0 +1,339 @@ @@ -1505,6 +2302,9 @@ index 6347ffb3e11..19259c069d7 100644 +(this will likely be your own name), and plug in a physical device to your +macOS machine with a USB cable. You should then be able to select your physical +device from the list of targets in the pulldown in the Xcode titlebar. +diff --git a/Apple/iOS/Resources/Info.plist.in b/Apple/iOS/Resources/Info.plist.in +new file mode 100644 +index 00000000000..26ef7a95de4 --- /dev/null +++ b/Apple/iOS/Resources/Info.plist.in @@ -0,0 +1,34 @@ @@ -1542,81 +2342,129 @@ index 6347ffb3e11..19259c069d7 100644 + @IPHONEOS_DEPLOYMENT_TARGET@ + + +diff --git a/Apple/iOS/Resources/bin/arm64-apple-ios-ar b/Apple/iOS/Resources/bin/arm64-apple-ios-ar +new file mode 100755 +index 00000000000..3cf3eb21874 --- /dev/null +++ b/Apple/iOS/Resources/bin/arm64-apple-ios-ar @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphoneos${IOS_SDK_VERSION} ar "$@" +diff --git a/Apple/iOS/Resources/bin/arm64-apple-ios-clang b/Apple/iOS/Resources/bin/arm64-apple-ios-clang +new file mode 100755 +index 00000000000..f50d5b5142f --- /dev/null +++ b/Apple/iOS/Resources/bin/arm64-apple-ios-clang @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphoneos${IOS_SDK_VERSION} clang -target arm64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET} "$@" +diff --git a/Apple/iOS/Resources/bin/arm64-apple-ios-clang++ b/Apple/iOS/Resources/bin/arm64-apple-ios-clang++ +new file mode 100755 +index 00000000000..0794731d7dc --- /dev/null +++ b/Apple/iOS/Resources/bin/arm64-apple-ios-clang++ @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphoneos${IOS_SDK_VERSION} clang++ -target arm64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET} "$@" +diff --git a/Apple/iOS/Resources/bin/arm64-apple-ios-cpp b/Apple/iOS/Resources/bin/arm64-apple-ios-cpp +new file mode 100755 +index 00000000000..24fa1506bab --- /dev/null +++ b/Apple/iOS/Resources/bin/arm64-apple-ios-cpp @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphoneos${IOS_SDK_VERSION} clang -target arm64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET} -E "$@" +diff --git a/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-ar b/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-ar +new file mode 100755 +index 00000000000..b836b6db902 --- /dev/null +++ b/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-ar @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphonesimulator${IOS_SDK_VERSION} ar "$@" +diff --git a/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-clang b/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-clang +new file mode 100755 +index 00000000000..4891a00876e --- /dev/null +++ b/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-clang @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphonesimulator${IOS_SDK_VERSION} clang -target arm64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-clang++ b/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-clang++ +new file mode 100755 +index 00000000000..58b2a5f6f18 --- /dev/null +++ b/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-clang++ @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphonesimulator${IOS_SDK_VERSION} clang++ -target arm64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-cpp b/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-cpp +new file mode 100755 +index 00000000000..c9df94e8b7c --- /dev/null +++ b/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-cpp @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphonesimulator${IOS_SDK_VERSION} clang -target arm64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-simulator -E "$@" +diff --git a/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-strip b/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-strip +new file mode 100755 +index 00000000000..fd59d309b73 --- /dev/null +++ b/Apple/iOS/Resources/bin/arm64-apple-ios-simulator-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphonesimulator${IOS_SDK_VERSION} strip -arch arm64 "$@" +diff --git a/Apple/iOS/Resources/bin/arm64-apple-ios-strip b/Apple/iOS/Resources/bin/arm64-apple-ios-strip +new file mode 100755 +index 00000000000..75e823a3d02 --- /dev/null +++ b/Apple/iOS/Resources/bin/arm64-apple-ios-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphoneos${IOS_SDK_VERSION} strip -arch arm64 "$@" +diff --git a/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-ar b/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-ar +new file mode 100755 +index 00000000000..b836b6db902 --- /dev/null +++ b/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-ar @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphonesimulator${IOS_SDK_VERSION} ar "$@" +diff --git a/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-clang b/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-clang +new file mode 100755 +index 00000000000..f4739a7b945 --- /dev/null +++ b/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-clang @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphonesimulator${IOS_SDK_VERSION} clang -target x86_64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-clang++ b/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-clang++ +new file mode 100755 +index 00000000000..c348ae4c103 --- /dev/null +++ b/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-clang++ @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphonesimulator${IOS_SDK_VERSION} clang++ -target x86_64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-cpp b/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-cpp +new file mode 100755 +index 00000000000..6d7f8084c9f --- /dev/null +++ b/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-cpp @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphonesimulator${IOS_SDK_VERSION} clang -target x86_64-apple-ios${IPHONEOS_DEPLOYMENT_TARGET}-simulator -E "$@" +diff --git a/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-strip b/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-strip +new file mode 100755 +index 00000000000..c5cfb289291 --- /dev/null +++ b/Apple/iOS/Resources/bin/x86_64-apple-ios-simulator-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphonesimulator${IOS_SDK_VERSION} strip -arch x86_64 "$@" +diff --git a/Apple/iOS/Resources/pyconfig.h b/Apple/iOS/Resources/pyconfig.h +new file mode 100644 +index 00000000000..4acff2c6051 --- /dev/null +++ b/Apple/iOS/Resources/pyconfig.h @@ -0,0 +1,7 @@ @@ -1627,6 +2475,9 @@ index 6347ffb3e11..19259c069d7 100644 +#ifdef __x86_64__ +#include "pyconfig-x86_64.h" +#endif +diff --git a/Apple/testbed/Python.xcframework/Info.plist b/Apple/testbed/Python.xcframework/Info.plist +new file mode 100644 +index 00000000000..0587f4735f7 --- /dev/null +++ b/Apple/testbed/Python.xcframework/Info.plist @@ -0,0 +1,136 @@ @@ -1766,6 +2617,9 @@ index 6347ffb3e11..19259c069d7 100644 + 1.0 + + +diff --git a/Apple/testbed/Python.xcframework/build/iOS-dylib-Info-template.plist b/Apple/testbed/Python.xcframework/build/iOS-dylib-Info-template.plist +new file mode 100644 +index 00000000000..d6caa01c1e4 --- /dev/null +++ b/Apple/testbed/Python.xcframework/build/iOS-dylib-Info-template.plist @@ -0,0 +1,26 @@ @@ -1795,6 +2649,9 @@ index 6347ffb3e11..19259c069d7 100644 + 1 + + +diff --git a/Apple/testbed/Python.xcframework/build/tvOS-dylib-Info-template.plist b/Apple/testbed/Python.xcframework/build/tvOS-dylib-Info-template.plist +new file mode 100644 +index 00000000000..a20d476fa7b --- /dev/null +++ b/Apple/testbed/Python.xcframework/build/tvOS-dylib-Info-template.plist @@ -0,0 +1,26 @@ @@ -1824,6 +2681,9 @@ index 6347ffb3e11..19259c069d7 100644 + 1 + + +diff --git a/Apple/testbed/Python.xcframework/build/utils.sh b/Apple/testbed/Python.xcframework/build/utils.sh +new file mode 100755 +index 00000000000..aa56a29dcbd --- /dev/null +++ b/Apple/testbed/Python.xcframework/build/utils.sh @@ -0,0 +1,180 @@ @@ -2007,6 +2867,9 @@ index 6347ffb3e11..19259c069d7 100644 + process_dylibs $PYTHON_XCFRAMEWORK_PATH $package_path + done +} +diff --git a/Apple/testbed/Python.xcframework/build/watchOS-dylib-Info-template.plist b/Apple/testbed/Python.xcframework/build/watchOS-dylib-Info-template.plist +new file mode 100644 +index 00000000000..6f8c0bc2095 --- /dev/null +++ b/Apple/testbed/Python.xcframework/build/watchOS-dylib-Info-template.plist @@ -0,0 +1,26 @@ @@ -2036,6 +2899,9 @@ index 6347ffb3e11..19259c069d7 100644 + 1 + + +diff --git a/Apple/testbed/Python.xcframework/build/xrOS-dylib-Info-template.plist b/Apple/testbed/Python.xcframework/build/xrOS-dylib-Info-template.plist +new file mode 100644 +index 00000000000..e91673b4fbc --- /dev/null +++ b/Apple/testbed/Python.xcframework/build/xrOS-dylib-Info-template.plist @@ -0,0 +1,30 @@ @@ -2069,6 +2935,9 @@ index 6347ffb3e11..19259c069d7 100644 + + + +diff --git a/Apple/testbed/Python.xcframework/ios-arm64/README b/Apple/testbed/Python.xcframework/ios-arm64/README +new file mode 100644 +index 00000000000..c1b076d12cd --- /dev/null +++ b/Apple/testbed/Python.xcframework/ios-arm64/README @@ -0,0 +1,4 @@ @@ -2076,6 +2945,9 @@ index 6347ffb3e11..19259c069d7 100644 + +It should be used as a target for `--enable-framework` when compiling an iOS on-device +build for testing purposes. +diff --git a/Apple/testbed/Python.xcframework/ios-arm64_x86_64-simulator/README b/Apple/testbed/Python.xcframework/ios-arm64_x86_64-simulator/README +new file mode 100644 +index 00000000000..ae334e5d769 --- /dev/null +++ b/Apple/testbed/Python.xcframework/ios-arm64_x86_64-simulator/README @@ -0,0 +1,4 @@ @@ -2083,6 +2955,9 @@ index 6347ffb3e11..19259c069d7 100644 + +It should be used as a target for `--enable-framework` when compiling an iOS simulator +build for testing purposes (either x86_64 or ARM64). +diff --git a/Apple/testbed/Python.xcframework/tvos-arm64/README b/Apple/testbed/Python.xcframework/tvos-arm64/README +new file mode 100644 +index 00000000000..ebd648d04bd --- /dev/null +++ b/Apple/testbed/Python.xcframework/tvos-arm64/README @@ -0,0 +1,4 @@ @@ -2090,6 +2965,9 @@ index 6347ffb3e11..19259c069d7 100644 + +It should be used as a target for `--enable-framework` when compiling a tvOS +on-device build for testing purposes. +diff --git a/Apple/testbed/Python.xcframework/tvos-arm64_x86_64-simulator/README b/Apple/testbed/Python.xcframework/tvos-arm64_x86_64-simulator/README +new file mode 100644 +index 00000000000..f8163468d8c --- /dev/null +++ b/Apple/testbed/Python.xcframework/tvos-arm64_x86_64-simulator/README @@ -0,0 +1,4 @@ @@ -2097,6 +2975,9 @@ index 6347ffb3e11..19259c069d7 100644 + +It should be used as a target for `--enable-framework` when compiling a tvOS +simulator build for testing purposes (either x86_64 or ARM64). +diff --git a/Apple/testbed/Python.xcframework/watchos-arm64_32/README b/Apple/testbed/Python.xcframework/watchos-arm64_32/README +new file mode 100644 +index 00000000000..696af231df3 --- /dev/null +++ b/Apple/testbed/Python.xcframework/watchos-arm64_32/README @@ -0,0 +1,4 @@ @@ -2104,6 +2985,9 @@ index 6347ffb3e11..19259c069d7 100644 + +It should be used as a target for `--enable-framework` when compiling a watchOS on-device +build for testing purposes. +diff --git a/Apple/testbed/Python.xcframework/watchos-arm64_x86_64-simulator/README b/Apple/testbed/Python.xcframework/watchos-arm64_x86_64-simulator/README +new file mode 100644 +index 00000000000..d38e1e98276 --- /dev/null +++ b/Apple/testbed/Python.xcframework/watchos-arm64_x86_64-simulator/README @@ -0,0 +1,4 @@ @@ -2111,6 +2995,9 @@ index 6347ffb3e11..19259c069d7 100644 + +It should be used as a target for `--enable-framework` when compiling a watchOS +simulator build for testing purposes (either x86_64 or ARM64). +diff --git a/Apple/testbed/Python.xcframework/xros-arm64-simulator/README b/Apple/testbed/Python.xcframework/xros-arm64-simulator/README +new file mode 100644 +index 00000000000..7bb0ad4b6ba --- /dev/null +++ b/Apple/testbed/Python.xcframework/xros-arm64-simulator/README @@ -0,0 +1,4 @@ @@ -2118,6 +3005,9 @@ index 6347ffb3e11..19259c069d7 100644 + +It should be used as a target for `--enable-framework` when compiling an visionOS simulator +build for testing purposes (either x86_64 or ARM64). +diff --git a/Apple/testbed/Python.xcframework/xros-arm64/README b/Apple/testbed/Python.xcframework/xros-arm64/README +new file mode 100644 +index 00000000000..2fc2112e477 --- /dev/null +++ b/Apple/testbed/Python.xcframework/xros-arm64/README @@ -0,0 +1,4 @@ @@ -2125,6 +3015,9 @@ index 6347ffb3e11..19259c069d7 100644 + +It should be used as a target for `--enable-framework` when compiling an visionOS on-device +build for testing purposes. +diff --git a/Apple/testbed/Testbed.lldbinit b/Apple/testbed/Testbed.lldbinit +new file mode 100644 +index 00000000000..4cf00dd0f9d --- /dev/null +++ b/Apple/testbed/Testbed.lldbinit @@ -0,0 +1,4 @@ @@ -2132,6 +3025,9 @@ index 6347ffb3e11..19259c069d7 100644 +process handle SIGUSR1 -n true -p true -s false +process handle SIGUSR2 -n true -p true -s false +process handle SIGXFSZ -n true -p true -s false +diff --git a/Apple/testbed/TestbedTests/TestbedTests.m b/Apple/testbed/TestbedTests/TestbedTests.m +new file mode 100644 +index 00000000000..cc0d9224042 --- /dev/null +++ b/Apple/testbed/TestbedTests/TestbedTests.m @@ -0,0 +1,198 @@ @@ -2333,6 +3229,9 @@ index 6347ffb3e11..19259c069d7 100644 + + +@end +diff --git a/Apple/testbed/__main__.py b/Apple/testbed/__main__.py +new file mode 100644 +index 00000000000..0ed3b7f64c1 --- /dev/null +++ b/Apple/testbed/__main__.py @@ -0,0 +1,456 @@ @@ -2792,6 +3691,9 @@ index 6347ffb3e11..19259c069d7 100644 + for stream in [sys.stdout, sys.stderr]: + stream.reconfigure(line_buffering=True) + main() +diff --git a/Apple/testbed/iOSTestbed.xcodeproj/project.pbxproj b/Apple/testbed/iOSTestbed.xcodeproj/project.pbxproj +new file mode 100644 +index 00000000000..f8835a3bc58 --- /dev/null +++ b/Apple/testbed/iOSTestbed.xcodeproj/project.pbxproj @@ -0,0 +1,557 @@ @@ -3352,6 +4254,9 @@ index 6347ffb3e11..19259c069d7 100644 + }; + rootObject = 607A660A2B0EFA380010BFC8 /* Project object */; +} +diff --git a/Apple/testbed/iOSTestbed.xcodeproj/xcshareddata/xcschemes/iOSTestbed.xcscheme b/Apple/testbed/iOSTestbed.xcodeproj/xcshareddata/xcschemes/iOSTestbed.xcscheme +new file mode 100644 +index 00000000000..3c330a4152b --- /dev/null +++ b/Apple/testbed/iOSTestbed.xcodeproj/xcshareddata/xcschemes/iOSTestbed.xcscheme @@ -0,0 +1,97 @@ @@ -3452,6 +4357,9 @@ index 6347ffb3e11..19259c069d7 100644 + revealArchiveInOrganizer = "YES"> + + +diff --git a/Apple/testbed/iOSTestbed.xctestplan b/Apple/testbed/iOSTestbed.xctestplan +new file mode 100644 +index 00000000000..0c4ab9eb2ba --- /dev/null +++ b/Apple/testbed/iOSTestbed.xctestplan @@ -0,0 +1,46 @@ @@ -3501,6 +4409,9 @@ index 6347ffb3e11..19259c069d7 100644 + ], + "version" : 1 +} +diff --git a/Apple/testbed/iOSTestbed/AppDelegate.h b/Apple/testbed/iOSTestbed/AppDelegate.h +new file mode 100644 +index 00000000000..f695b3b5efc --- /dev/null +++ b/Apple/testbed/iOSTestbed/AppDelegate.h @@ -0,0 +1,11 @@ @@ -3515,6 +4426,9 @@ index 6347ffb3e11..19259c069d7 100644 + + +@end +diff --git a/Apple/testbed/iOSTestbed/AppDelegate.m b/Apple/testbed/iOSTestbed/AppDelegate.m +new file mode 100644 +index 00000000000..e5085399d0c --- /dev/null +++ b/Apple/testbed/iOSTestbed/AppDelegate.m @@ -0,0 +1,19 @@ @@ -3537,6 +4451,9 @@ index 6347ffb3e11..19259c069d7 100644 +} + +@end +diff --git a/Apple/testbed/iOSTestbed/Assets.xcassets/AccentColor.colorset/Contents.json b/Apple/testbed/iOSTestbed/Assets.xcassets/AccentColor.colorset/Contents.json +new file mode 100644 +index 00000000000..eb878970081 --- /dev/null +++ b/Apple/testbed/iOSTestbed/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ @@ -3551,6 +4468,9 @@ index 6347ffb3e11..19259c069d7 100644 + "version" : 1 + } +} +diff --git a/Apple/testbed/iOSTestbed/Assets.xcassets/AppIcon.appiconset/Contents.json b/Apple/testbed/iOSTestbed/Assets.xcassets/AppIcon.appiconset/Contents.json +new file mode 100644 +index 00000000000..13613e3ee1a --- /dev/null +++ b/Apple/testbed/iOSTestbed/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ @@ -3567,6 +4487,9 @@ index 6347ffb3e11..19259c069d7 100644 + "version" : 1 + } +} +diff --git a/Apple/testbed/iOSTestbed/Assets.xcassets/Contents.json b/Apple/testbed/iOSTestbed/Assets.xcassets/Contents.json +new file mode 100644 +index 00000000000..73c00596a7f --- /dev/null +++ b/Apple/testbed/iOSTestbed/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ @@ -3576,6 +4499,9 @@ index 6347ffb3e11..19259c069d7 100644 + "version" : 1 + } +} +diff --git a/Apple/testbed/iOSTestbed/Base.lproj/LaunchScreen.storyboard b/Apple/testbed/iOSTestbed/Base.lproj/LaunchScreen.storyboard +new file mode 100644 +index 00000000000..5daafe73a86 --- /dev/null +++ b/Apple/testbed/iOSTestbed/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,9 @@ @@ -3588,6 +4514,9 @@ index 6347ffb3e11..19259c069d7 100644 + + + +diff --git a/Apple/testbed/iOSTestbed/app/README b/Apple/testbed/iOSTestbed/app/README +new file mode 100644 +index 00000000000..46c0e8e2a29 --- /dev/null +++ b/Apple/testbed/iOSTestbed/app/README @@ -0,0 +1,7 @@ @@ -3598,6 +4527,9 @@ index 6347ffb3e11..19259c069d7 100644 + +When the test suite runs, this folder will be on the PYTHONPATH, and will be the +working directory for the test suite. +diff --git a/Apple/testbed/iOSTestbed/app_packages/README b/Apple/testbed/iOSTestbed/app_packages/README +new file mode 100644 +index 00000000000..02c2beccfbd --- /dev/null +++ b/Apple/testbed/iOSTestbed/app_packages/README @@ -0,0 +1,7 @@ @@ -3608,6 +4540,9 @@ index 6347ffb3e11..19259c069d7 100644 +Framework form. + +When the test suite runs, this folder will be on the PYTHONPATH. +diff --git a/Apple/testbed/iOSTestbed/iOSTestbed-Info.plist b/Apple/testbed/iOSTestbed/iOSTestbed-Info.plist +new file mode 100644 +index 00000000000..fea45e1fad6 --- /dev/null +++ b/Apple/testbed/iOSTestbed/iOSTestbed-Info.plist @@ -0,0 +1,52 @@ @@ -3663,6 +4598,9 @@ index 6347ffb3e11..19259c069d7 100644 + + + +diff --git a/Apple/testbed/iOSTestbed/main.m b/Apple/testbed/iOSTestbed/main.m +new file mode 100644 +index 00000000000..e32bd78c9b4 --- /dev/null +++ b/Apple/testbed/iOSTestbed/main.m @@ -0,0 +1,16 @@ @@ -3682,6 +4620,9 @@ index 6347ffb3e11..19259c069d7 100644 + return UIApplicationMain(argc, argv, nil, appDelegateClassName); + } +} +diff --git a/Apple/testbed/tvOSTestbed.xcodeproj/project.pbxproj b/Apple/testbed/tvOSTestbed.xcodeproj/project.pbxproj +new file mode 100644 +index 00000000000..85e7047dfb7 --- /dev/null +++ b/Apple/testbed/tvOSTestbed.xcodeproj/project.pbxproj @@ -0,0 +1,506 @@ @@ -4191,6 +5132,9 @@ index 6347ffb3e11..19259c069d7 100644 + }; + rootObject = EE989E462DCD6E780036B268 /* Project object */; +} +diff --git a/Apple/testbed/tvOSTestbed.xcodeproj/xcshareddata/xcschemes/tvOSTestbed.xcscheme b/Apple/testbed/tvOSTestbed.xcodeproj/xcshareddata/xcschemes/tvOSTestbed.xcscheme +new file mode 100644 +index 00000000000..c3f3f894a1f --- /dev/null +++ b/Apple/testbed/tvOSTestbed.xcodeproj/xcshareddata/xcschemes/tvOSTestbed.xcscheme @@ -0,0 +1,97 @@ @@ -4291,6 +5235,9 @@ index 6347ffb3e11..19259c069d7 100644 + revealArchiveInOrganizer = "YES"> + + +diff --git a/Apple/testbed/tvOSTestbed.xctestplan b/Apple/testbed/tvOSTestbed.xctestplan +new file mode 100644 +index 00000000000..f996facc178 --- /dev/null +++ b/Apple/testbed/tvOSTestbed.xctestplan @@ -0,0 +1,46 @@ @@ -4341,6 +5288,9 @@ index 6347ffb3e11..19259c069d7 100644 + "version" : 1 +} \ No newline at end of file +diff --git a/Apple/testbed/tvOSTestbed/AppDelegate.h b/Apple/testbed/tvOSTestbed/AppDelegate.h +new file mode 100644 +index 00000000000..112c9ed64b8 --- /dev/null +++ b/Apple/testbed/tvOSTestbed/AppDelegate.h @@ -0,0 +1,11 @@ @@ -4355,6 +5305,9 @@ index 6347ffb3e11..19259c069d7 100644 + + +@end +diff --git a/Apple/testbed/tvOSTestbed/AppDelegate.m b/Apple/testbed/tvOSTestbed/AppDelegate.m +new file mode 100644 +index 00000000000..bd91fb2d7d6 --- /dev/null +++ b/Apple/testbed/tvOSTestbed/AppDelegate.m @@ -0,0 +1,19 @@ @@ -4377,6 +5330,9 @@ index 6347ffb3e11..19259c069d7 100644 +} + +@end +diff --git a/Apple/testbed/tvOSTestbed/Base.lproj/LaunchScreen.storyboard b/Apple/testbed/tvOSTestbed/Base.lproj/LaunchScreen.storyboard +new file mode 100644 +index 00000000000..660ba53de4f --- /dev/null +++ b/Apple/testbed/tvOSTestbed/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,24 @@ @@ -4404,6 +5360,9 @@ index 6347ffb3e11..19259c069d7 100644 + + + +diff --git a/Apple/testbed/tvOSTestbed/app/README b/Apple/testbed/tvOSTestbed/app/README +new file mode 100644 +index 00000000000..46c0e8e2a29 --- /dev/null +++ b/Apple/testbed/tvOSTestbed/app/README @@ -0,0 +1,7 @@ @@ -4414,6 +5373,9 @@ index 6347ffb3e11..19259c069d7 100644 + +When the test suite runs, this folder will be on the PYTHONPATH, and will be the +working directory for the test suite. +diff --git a/Apple/testbed/tvOSTestbed/app_packages/README b/Apple/testbed/tvOSTestbed/app_packages/README +new file mode 100644 +index 00000000000..02c2beccfbd --- /dev/null +++ b/Apple/testbed/tvOSTestbed/app_packages/README @@ -0,0 +1,7 @@ @@ -4424,6 +5386,9 @@ index 6347ffb3e11..19259c069d7 100644 +Framework form. + +When the test suite runs, this folder will be on the PYTHONPATH. +diff --git a/Apple/testbed/tvOSTestbed/main.m b/Apple/testbed/tvOSTestbed/main.m +new file mode 100644 +index 00000000000..d5808fbb933 --- /dev/null +++ b/Apple/testbed/tvOSTestbed/main.m @@ -0,0 +1,16 @@ @@ -4443,6 +5408,9 @@ index 6347ffb3e11..19259c069d7 100644 + return UIApplicationMain(argc, argv, nil, appDelegateClassName); + } +} +diff --git a/Apple/testbed/tvOSTestbed/tvOSTestbed-Info.plist b/Apple/testbed/tvOSTestbed/tvOSTestbed-Info.plist +new file mode 100644 +index 00000000000..f08f6098999 --- /dev/null +++ b/Apple/testbed/tvOSTestbed/tvOSTestbed-Info.plist @@ -0,0 +1,52 @@ @@ -4498,6 +5466,9 @@ index 6347ffb3e11..19259c069d7 100644 + + + +diff --git a/Apple/testbed/visionOSTestbed.xcodeproj/project.pbxproj b/Apple/testbed/visionOSTestbed.xcodeproj/project.pbxproj +new file mode 100644 +index 00000000000..0fd5df716b1 --- /dev/null +++ b/Apple/testbed/visionOSTestbed.xcodeproj/project.pbxproj @@ -0,0 +1,558 @@ @@ -5059,6 +6030,9 @@ index 6347ffb3e11..19259c069d7 100644 + }; + rootObject = 607A660A2B0EFA380010BFC8 /* Project object */; +} +diff --git a/Apple/testbed/visionOSTestbed.xcodeproj/xcshareddata/xcschemes/visionOSTestbed.xcscheme b/Apple/testbed/visionOSTestbed.xcodeproj/xcshareddata/xcschemes/visionOSTestbed.xcscheme +new file mode 100644 +index 00000000000..b8397ea7cf1 --- /dev/null +++ b/Apple/testbed/visionOSTestbed.xcodeproj/xcshareddata/xcschemes/visionOSTestbed.xcscheme @@ -0,0 +1,97 @@ @@ -5159,6 +6133,9 @@ index 6347ffb3e11..19259c069d7 100644 + revealArchiveInOrganizer = "YES"> + + +diff --git a/Apple/testbed/visionOSTestbed.xctestplan b/Apple/testbed/visionOSTestbed.xctestplan +new file mode 100644 +index 00000000000..73a2be8c22a --- /dev/null +++ b/Apple/testbed/visionOSTestbed.xctestplan @@ -0,0 +1,46 @@ @@ -5209,6 +6186,9 @@ index 6347ffb3e11..19259c069d7 100644 + "version" : 1 +} \ No newline at end of file +diff --git a/Apple/testbed/visionOSTestbed/AppDelegate.h b/Apple/testbed/visionOSTestbed/AppDelegate.h +new file mode 100644 +index 00000000000..8fe7ec8e64e --- /dev/null +++ b/Apple/testbed/visionOSTestbed/AppDelegate.h @@ -0,0 +1,11 @@ @@ -5223,6 +6203,9 @@ index 6347ffb3e11..19259c069d7 100644 + + +@end +diff --git a/Apple/testbed/visionOSTestbed/AppDelegate.m b/Apple/testbed/visionOSTestbed/AppDelegate.m +new file mode 100644 +index 00000000000..b3ff14f7255 --- /dev/null +++ b/Apple/testbed/visionOSTestbed/AppDelegate.m @@ -0,0 +1,19 @@ @@ -5245,6 +6228,9 @@ index 6347ffb3e11..19259c069d7 100644 +} + +@end +diff --git a/Apple/testbed/visionOSTestbed/Assets.xcassets/AccentColor.colorset/Contents.json b/Apple/testbed/visionOSTestbed/Assets.xcassets/AccentColor.colorset/Contents.json +new file mode 100644 +index 00000000000..eb878970081 --- /dev/null +++ b/Apple/testbed/visionOSTestbed/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ @@ -5259,6 +6245,9 @@ index 6347ffb3e11..19259c069d7 100644 + "version" : 1 + } +} +diff --git a/Apple/testbed/visionOSTestbed/Assets.xcassets/AppIcon.appiconset/Contents.json b/Apple/testbed/visionOSTestbed/Assets.xcassets/AppIcon.appiconset/Contents.json +new file mode 100644 +index 00000000000..13613e3ee1a --- /dev/null +++ b/Apple/testbed/visionOSTestbed/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ @@ -5275,6 +6264,9 @@ index 6347ffb3e11..19259c069d7 100644 + "version" : 1 + } +} +diff --git a/Apple/testbed/visionOSTestbed/Assets.xcassets/Contents.json b/Apple/testbed/visionOSTestbed/Assets.xcassets/Contents.json +new file mode 100644 +index 00000000000..73c00596a7f --- /dev/null +++ b/Apple/testbed/visionOSTestbed/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ @@ -5284,6 +6276,9 @@ index 6347ffb3e11..19259c069d7 100644 + "version" : 1 + } +} +diff --git a/Apple/testbed/visionOSTestbed/app/README b/Apple/testbed/visionOSTestbed/app/README +new file mode 100644 +index 00000000000..af22c685f87 --- /dev/null +++ b/Apple/testbed/visionOSTestbed/app/README @@ -0,0 +1,7 @@ @@ -5294,6 +6289,9 @@ index 6347ffb3e11..19259c069d7 100644 + +When the test suite runs, this folder will be on the PYTHONPATH, and will be the +working directory for the test suite. +diff --git a/Apple/testbed/visionOSTestbed/app_packages/README b/Apple/testbed/visionOSTestbed/app_packages/README +new file mode 100644 +index 00000000000..42d7fdeb813 --- /dev/null +++ b/Apple/testbed/visionOSTestbed/app_packages/README @@ -0,0 +1,7 @@ @@ -5304,6 +6302,9 @@ index 6347ffb3e11..19259c069d7 100644 +iOS Framework form. + +When the test suite runs, this folder will be on the PYTHONPATH. +diff --git a/Apple/testbed/visionOSTestbed/main.m b/Apple/testbed/visionOSTestbed/main.m +new file mode 100644 +index 00000000000..2bb491f25c8 --- /dev/null +++ b/Apple/testbed/visionOSTestbed/main.m @@ -0,0 +1,16 @@ @@ -5323,6 +6324,9 @@ index 6347ffb3e11..19259c069d7 100644 + return UIApplicationMain(argc, argv, nil, appDelegateClassName); + } +} +diff --git a/Apple/testbed/visionOSTestbed/visionOSTestbed-Info.plist b/Apple/testbed/visionOSTestbed/visionOSTestbed-Info.plist +new file mode 100644 +index 00000000000..fce9298555d --- /dev/null +++ b/Apple/testbed/visionOSTestbed/visionOSTestbed-Info.plist @@ -0,0 +1,56 @@ @@ -5382,6 +6386,9 @@ index 6347ffb3e11..19259c069d7 100644 + + + +diff --git a/Apple/tvOS/README.rst b/Apple/tvOS/README.rst +new file mode 100644 +index 00000000000..1f793252caf --- /dev/null +++ b/Apple/tvOS/README.rst @@ -0,0 +1,108 @@ @@ -5493,6 +6500,9 @@ index 6347ffb3e11..19259c069d7 100644 + +Using a framework-based Python on tvOS +====================================== +diff --git a/Apple/tvOS/Resources/Info.plist.in b/Apple/tvOS/Resources/Info.plist.in +new file mode 100644 +index 00000000000..ab3050804b8 --- /dev/null +++ b/Apple/tvOS/Resources/Info.plist.in @@ -0,0 +1,34 @@ @@ -5530,81 +6540,129 @@ index 6347ffb3e11..19259c069d7 100644 + @TVOS_DEPLOYMENT_TARGET@ + + +diff --git a/Apple/tvOS/Resources/bin/arm64-apple-tvos-ar b/Apple/tvOS/Resources/bin/arm64-apple-tvos-ar +new file mode 100755 +index 00000000000..e302748a13c --- /dev/null +++ b/Apple/tvOS/Resources/bin/arm64-apple-tvos-ar @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk appletvos${TVOS_SDK_VERSION} ar "$@" +diff --git a/Apple/tvOS/Resources/bin/arm64-apple-tvos-clang b/Apple/tvOS/Resources/bin/arm64-apple-tvos-clang +new file mode 100755 +index 00000000000..7fb6d3d901c --- /dev/null +++ b/Apple/tvOS/Resources/bin/arm64-apple-tvos-clang @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk appletvos${TVOS_SDK_VERSION} clang -target arm64-apple-tvos${TVOS_DEPLOYMENT_TARGET} "$@" +diff --git a/Apple/tvOS/Resources/bin/arm64-apple-tvos-clang++ b/Apple/tvOS/Resources/bin/arm64-apple-tvos-clang++ +new file mode 100755 +index 00000000000..33bfb1367c3 --- /dev/null +++ b/Apple/tvOS/Resources/bin/arm64-apple-tvos-clang++ @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk appletvos${TVOS_SDK_VERSION} clang++ -target arm64-apple-tvos${TVOS_DEPLOYMENT_TARGET} "$@" +diff --git a/Apple/tvOS/Resources/bin/arm64-apple-tvos-cpp b/Apple/tvOS/Resources/bin/arm64-apple-tvos-cpp +new file mode 100755 +index 00000000000..641c1bc8d18 --- /dev/null +++ b/Apple/tvOS/Resources/bin/arm64-apple-tvos-cpp @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk appletvos${TVOS_SDK_VERSION} clang -target arm64-apple-tvos${TVOS_DEPLOYMENT_TARGET} -E "$@" +diff --git a/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-ar b/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-ar +new file mode 100755 +index 00000000000..87ef5015aae --- /dev/null +++ b/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-ar @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} ar "$@" +diff --git a/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-clang b/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-clang +new file mode 100755 +index 00000000000..c8719cb0318 --- /dev/null +++ b/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-clang @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} clang -target arm64-apple-tvos${TVOS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-clang++ b/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-clang++ +new file mode 100755 +index 00000000000..e3f0e720f7f --- /dev/null +++ b/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-clang++ @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} clang++ -target arm64-apple-tvos${TVOS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-cpp b/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-cpp +new file mode 100755 +index 00000000000..f9a37b72a61 --- /dev/null +++ b/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-cpp @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} clang -target arm64-apple-tvos${TVOS_DEPLOYMENT_TARGET}-simulator -E "$@" +diff --git a/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-strip b/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-strip +new file mode 100755 +index 00000000000..a8cce95233e --- /dev/null +++ b/Apple/tvOS/Resources/bin/arm64-apple-tvos-simulator-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} strip -arch arm64 "$@" +diff --git a/Apple/tvOS/Resources/bin/arm64-apple-tvos-strip b/Apple/tvOS/Resources/bin/arm64-apple-tvos-strip +new file mode 100755 +index 00000000000..ee1d2b95ff1 --- /dev/null +++ b/Apple/tvOS/Resources/bin/arm64-apple-tvos-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk iphoneos${TVOS_SDK_VERSION} strip -arch arm64 "$@" +diff --git a/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-ar b/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-ar +new file mode 100755 +index 00000000000..87ef5015aae --- /dev/null +++ b/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-ar @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} ar "$@" +diff --git a/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-clang b/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-clang +new file mode 100755 +index 00000000000..ea0cc26cbd9 --- /dev/null +++ b/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-clang @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} clang -target x86_64-apple-tvos${TVOS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-clang++ b/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-clang++ +new file mode 100755 +index 00000000000..f18f3603169 --- /dev/null +++ b/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-clang++ @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} clang++ -target x86_64-apple-tvos${TVOS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-cpp b/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-cpp +new file mode 100755 +index 00000000000..b98054d1ce2 --- /dev/null +++ b/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-cpp @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} clang -target x86_64-apple-tvos${TVOS_DEPLOYMENT_TARGET}-simulator -E "$@" +diff --git a/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-strip b/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-strip +new file mode 100755 +index 00000000000..f6a884b4aef --- /dev/null +++ b/Apple/tvOS/Resources/bin/x86_64-apple-tvos-simulator-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk appletvsimulator${TVOS_SDK_VERSION} strip -arch x86_64 "$@" +diff --git a/Apple/tvOS/Resources/pyconfig.h b/Apple/tvOS/Resources/pyconfig.h +new file mode 100644 +index 00000000000..4acff2c6051 --- /dev/null +++ b/Apple/tvOS/Resources/pyconfig.h @@ -0,0 +1,7 @@ @@ -5615,6 +6673,9 @@ index 6347ffb3e11..19259c069d7 100644 +#ifdef __x86_64__ +#include "pyconfig-x86_64.h" +#endif +diff --git a/Apple/visionOS/Resources/Info.plist.in b/Apple/visionOS/Resources/Info.plist.in +new file mode 100644 +index 00000000000..2679440da67 --- /dev/null +++ b/Apple/visionOS/Resources/Info.plist.in @@ -0,0 +1,34 @@ @@ -5652,62 +6713,98 @@ index 6347ffb3e11..19259c069d7 100644 + @XROS_DEPLOYMENT_TARGET@ + + +diff --git a/Apple/visionOS/Resources/bin/arm64-apple-xros-ar b/Apple/visionOS/Resources/bin/arm64-apple-xros-ar +new file mode 100755 +index 00000000000..9fd78a205f3 --- /dev/null +++ b/Apple/visionOS/Resources/bin/arm64-apple-xros-ar @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk xros${XROS_SDK_VERSION} ar "$@" +diff --git a/Apple/visionOS/Resources/bin/arm64-apple-xros-clang b/Apple/visionOS/Resources/bin/arm64-apple-xros-clang +new file mode 100755 +index 00000000000..9a1a757cbd0 --- /dev/null +++ b/Apple/visionOS/Resources/bin/arm64-apple-xros-clang @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk xros${XROS_SDK_VERSION} clang -target arm64-apple-xros${XROS_DEPLOYMENT_TARGET} "$@" +diff --git a/Apple/visionOS/Resources/bin/arm64-apple-xros-clang++ b/Apple/visionOS/Resources/bin/arm64-apple-xros-clang++ +new file mode 100755 +index 00000000000..f64fcfc11cd --- /dev/null +++ b/Apple/visionOS/Resources/bin/arm64-apple-xros-clang++ @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk xros${XROS_SDK_VERSION} clang++ -target arm64-apple-xros${XROS_DEPLOYMENT_TARGET} "$@" +diff --git a/Apple/visionOS/Resources/bin/arm64-apple-xros-cpp b/Apple/visionOS/Resources/bin/arm64-apple-xros-cpp +new file mode 100755 +index 00000000000..d6492eff052 --- /dev/null +++ b/Apple/visionOS/Resources/bin/arm64-apple-xros-cpp @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk xros${XROS_SDK_VERSION} clang -target arm64-apple-xros${XROS_DEPLOYMENT_TARGET} -E "$@" +diff --git a/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-ar b/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-ar +new file mode 100755 +index 00000000000..b202330fb5d --- /dev/null +++ b/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-ar @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk xrsimulator${XROS_SDK_VERSION} ar "$@" +diff --git a/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-clang b/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-clang +new file mode 100755 +index 00000000000..87b0aba0751 --- /dev/null +++ b/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-clang @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk xrsimulator${XROS_SDK_VERSION} clang -target arm64-apple-xros${XROS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-clang++ b/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-clang++ +new file mode 100755 +index 00000000000..c89d48f1cb8 --- /dev/null +++ b/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-clang++ @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk xrsimulator${XROS_SDK_VERSION} clang++ -target arm64-apple-xros${XROS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-cpp b/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-cpp +new file mode 100755 +index 00000000000..ee11e018ae0 --- /dev/null +++ b/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-cpp @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk xrsimulator${XROS_SDK_VERSION} clang -target arm64-apple-xros${XROS_DEPLOYMENT_TARGET}-simulator -E "$@" +diff --git a/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-strip b/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-strip +new file mode 100644 +index 00000000000..376aff61a23 --- /dev/null +++ b/Apple/visionOS/Resources/bin/arm64-apple-xros-simulator-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk xrsimulator${XROS_SDK_VERSION} strip -arch arm64 "$@" +diff --git a/Apple/visionOS/Resources/bin/arm64-apple-xros-strip b/Apple/visionOS/Resources/bin/arm64-apple-xros-strip +new file mode 100644 +index 00000000000..2de3ba5d31c --- /dev/null +++ b/Apple/visionOS/Resources/bin/arm64-apple-xros-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk xros${XROS_SDK_VERSION} strip -arch arm64 "$@" +diff --git a/Apple/visionOS/Resources/pyconfig.h b/Apple/visionOS/Resources/pyconfig.h +new file mode 100644 +index 00000000000..2a433078400 --- /dev/null +++ b/Apple/visionOS/Resources/pyconfig.h @@ -0,0 +1,3 @@ +#ifdef __arm64__ +#include "pyconfig-arm64.h" +#endif +diff --git a/Apple/watchOS/README.rst b/Apple/watchOS/README.rst +new file mode 100644 +index 00000000000..35221478452 --- /dev/null +++ b/Apple/watchOS/README.rst @@ -0,0 +1,108 @@ @@ -5819,6 +6916,9 @@ index 6347ffb3e11..19259c069d7 100644 + +Using a framework-based Python on watchOS +====================================== +diff --git a/Apple/watchOS/Resources/Info.plist.in b/Apple/watchOS/Resources/Info.plist.in +new file mode 100644 +index 00000000000..e83ddfd2a43 --- /dev/null +++ b/Apple/watchOS/Resources/Info.plist.in @@ -0,0 +1,34 @@ @@ -5856,81 +6956,129 @@ index 6347ffb3e11..19259c069d7 100644 + @WATCHOS_DEPLOYMENT_TARGET@ + + +diff --git a/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-ar b/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-ar +new file mode 100755 +index 00000000000..dda2b211bd5 --- /dev/null +++ b/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-ar @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} ar "$@" +diff --git a/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-clang b/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-clang +new file mode 100755 +index 00000000000..fe834d3efe4 --- /dev/null +++ b/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-clang @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} clang -target arm64-apple-watchos${WATCHOS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-clang++ b/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-clang++ +new file mode 100755 +index 00000000000..757f3a26d8f --- /dev/null +++ b/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-clang++ @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} clang++ -target arm64-apple-watchos${WATCHOS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-cpp b/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-cpp +new file mode 100755 +index 00000000000..fdb57d9e010 --- /dev/null +++ b/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-cpp @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk watchsimulator clang -target arm64-apple-watchos${WATCHOS_DEPLOYMENT_TARGET}-simulator -E "$@" +diff --git a/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-strip b/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-strip +new file mode 100755 +index 00000000000..e28e3f7597a --- /dev/null +++ b/Apple/watchOS/Resources/bin/arm64-apple-watchos-simulator-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} strip -arch arm64 "$@" +diff --git a/Apple/watchOS/Resources/bin/arm64-apple-watchos-strip b/Apple/watchOS/Resources/bin/arm64-apple-watchos-strip +new file mode 100755 +index 00000000000..efe5a1260ad --- /dev/null +++ b/Apple/watchOS/Resources/bin/arm64-apple-watchos-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchos${WATCHOS_SDK_VERSION} strip -arch arm64 "$@" +diff --git a/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-ar b/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-ar +new file mode 100755 +index 00000000000..029f9a32073 --- /dev/null +++ b/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-ar @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk watchos${WATCHOS_SDK_VERSION} ar "$@" +diff --git a/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-clang b/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-clang +new file mode 100755 +index 00000000000..285036d4010 --- /dev/null +++ b/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-clang @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk watchos${WATCHOS_SDK_VERSION} clang -target arm64_32-apple-watchos${WATCHOS_DEPLOYMENT_TARGET} "$@" +diff --git a/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-clang++ b/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-clang++ +new file mode 100755 +index 00000000000..c8f60ebec51 --- /dev/null +++ b/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-clang++ @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk watchos${WATCHOS_SDK_VERSION} clang++ -target arm64_32-apple-watchos${WATCHOS_DEPLOYMENT_TARGET} "$@" +diff --git a/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-cpp b/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-cpp +new file mode 100755 +index 00000000000..b411fc25aa4 --- /dev/null +++ b/Apple/watchOS/Resources/bin/arm64_32-apple-watchos-cpp @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk watchos${WATCHOS_SDK_VERSION} clang -target arm64_32-apple-watchos${WATCHOS_DEPLOYMENT_TARGET} -E "$@" +diff --git a/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-ar b/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-ar +new file mode 100755 +index 00000000000..dda2b211bd5 --- /dev/null +++ b/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-ar @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} ar "$@" +diff --git a/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-clang b/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-clang +new file mode 100755 +index 00000000000..4776b9b5348 --- /dev/null +++ b/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-clang @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} clang -target x86_64-apple-watchos${WATCHOS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-clang++ b/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-clang++ +new file mode 100755 +index 00000000000..e9b0c5f4b87 --- /dev/null +++ b/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-clang++ @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} clang++ -target x86_64-apple-watchos${WATCHOS_DEPLOYMENT_TARGET}-simulator "$@" +diff --git a/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-cpp b/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-cpp +new file mode 100755 +index 00000000000..d3b821c5f7f --- /dev/null +++ b/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-cpp @@ -0,0 +1,2 @@ +#!/bin/bash +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} clang -target x86_64-apple-watchos${WATCHOS_DEPLOYMENT_TARGET}-simulator -E "$@" +diff --git a/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-strip b/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-strip +new file mode 100755 +index 00000000000..105c78281f9 --- /dev/null +++ b/Apple/watchOS/Resources/bin/x86_64-apple-watchos-simulator-strip @@ -0,0 +1,2 @@ +#!/bin/sh +xcrun --sdk watchsimulator${WATCHOS_SDK_VERSION} strip -arch x86_64 "$@" +diff --git a/Apple/watchOS/Resources/pyconfig.h b/Apple/watchOS/Resources/pyconfig.h +new file mode 100644 +index 00000000000..f842b987b2e --- /dev/null +++ b/Apple/watchOS/Resources/pyconfig.h @@ -0,0 +1,11 @@ @@ -5945,126 +7093,19115 @@ index 6347ffb3e11..19259c069d7 100644 +#ifdef __x86_64__ +#include "pyconfig-x86_64.h" +#endif -diff --git a/Doc/using/ios.rst b/Doc/using/ios.rst -index 9921fd6114b..4ed18f4938c 100644 ---- a/Doc/using/ios.rst -+++ b/Doc/using/ios.rst -@@ -170,7 +170,7 @@ - To add Python to an iOS Xcode project: +diff --git a/Doc/Makefile b/Doc/Makefile +index 60ffcd286e3..f16d9cacb1b 100644 +--- a/Doc/Makefile ++++ b/Doc/Makefile +@@ -58,7 +58,7 @@ + @if [ -f ../Misc/NEWS ] ; then \ + echo "Using existing Misc/NEWS file"; \ + cp ../Misc/NEWS build/NEWS; \ +- elif $(BLURB) --version && $(SPHINXBUILD) --version ; then \ ++ elif $(BLURB) help >/dev/null 2>&1 && $(SPHINXBUILD) --version >/dev/null 2>&1; then \ + if [ -d ../Misc/NEWS.d ]; then \ + echo "Building NEWS from Misc/NEWS.d with blurb"; \ + $(BLURB) merge -f build/NEWS; \ +@@ -140,8 +140,7 @@ + pydoc-topics: BUILDER = pydoc-topics + pydoc-topics: build + @echo "Building finished; now run this:" \ +- "cp build/pydoc-topics/topics.py ../Lib/pydoc_data/topics.py" \ +- "&& cp build/pydoc-topics/module_docs.py ../Lib/pydoc_data/module_docs.py" ++ "cp build/pydoc-topics/topics.py ../Lib/pydoc_data/topics.py" - 1. Build or obtain a Python ``XCFramework``. See the instructions in -- :source:`iOS/README.rst` (in the CPython source distribution) for details on -+ :source:`Apple/iOS/README.md` (in the CPython source distribution) for details on - how to build a Python ``XCFramework``. At a minimum, you will need a build - that supports ``arm64-apple-ios``, plus one of either - ``arm64-apple-ios-simulator`` or ``x86_64-apple-ios-simulator``. -@@ -180,22 +180,19 @@ - of your project; however, you can use any other location that you want by - adjusting paths as needed. + .PHONY: gettext + gettext: BUILDER = gettext +diff --git a/Doc/bugs.rst b/Doc/bugs.rst +index 9f2b9876ba5..1d27579e53f 100644 +--- a/Doc/bugs.rst ++++ b/Doc/bugs.rst +@@ -9,7 +9,7 @@ + know of any deficiencies you find in Python. --3. Drag the ``iOS/Resources/dylib-Info-template.plist`` file into your project, -- and ensure it is associated with the app target. + It can be sometimes faster to fix bugs yourself and contribute patches to +-Python as it streamlines the process and involves fewer people. Learn how to ++Python as it streamlines the process and involves less people. Learn how to + :ref:`contribute `. + + Documentation bugs +diff --git a/Doc/c-api/call.rst b/Doc/c-api/call.rst +index 9838879a528..7198d6bc056 100644 +--- a/Doc/c-api/call.rst ++++ b/Doc/c-api/call.rst +@@ -347,8 +347,6 @@ + + .. versionadded:: 3.9 + +-.. c:function:: PyObject* _PyObject_Vectorcall(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames) +- :no-typesetting: + + .. c:function:: PyObject* PyObject_Vectorcall(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames) + +@@ -360,12 +358,7 @@ + Return the result of the call on success, or raise an exception and return + *NULL* on failure. + +- .. versionadded:: 3.8 as ``_PyObject_Vectorcall`` - --4. Add your application code as a folder in your Xcode project. In the -+3. Add your application code as a folder in your Xcode project. In the - following instructions, we'll assume that your user code is in a folder - named ``app`` in the root of your project; you can use any other location by - adjusting paths as needed. Ensure that this folder is associated with your - app target. +- .. versionchanged:: 3.9 +- +- Renamed to the current name, without the leading underscore. +- The old provisional name is :term:`soft deprecated`. ++ .. versionadded:: 3.9 --5. Select the app target by selecting the root node of your Xcode project, then -+4. Select the app target by selecting the root node of your Xcode project, then - the target name in the sidebar that appears. + .. c:function:: PyObject* PyObject_VectorcallDict(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwdict) --6. In the "General" settings, under "Frameworks, Libraries and Embedded -+5. In the "General" settings, under "Frameworks, Libraries and Embedded - Content", add ``Python.xcframework``, with "Embed & Sign" selected. +diff --git a/Doc/c-api/code.rst b/Doc/c-api/code.rst +index c461ab936f6..32974fa4825 100644 +--- a/Doc/c-api/code.rst ++++ b/Doc/c-api/code.rst +@@ -69,14 +69,13 @@ + The old name is deprecated, but will remain available until the + signature changes again. --7. In the "Build Settings" tab, modify the following: -+6. In the "Build Settings" tab, modify the following: +-.. c:function:: PyCodeObject* PyCode_NewWithPosOnlyArgs(...) +- :no-typesetting: +- + .. c:function:: PyCodeObject* PyUnstable_Code_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, PyObject *qualname, int firstlineno, PyObject *linetable, PyObject *exceptiontable) - - Build Options + Similar to :c:func:`PyUnstable_Code_New`, but with an extra "posonlyargcount" for positional-only arguments. + The same caveats that apply to ``PyUnstable_Code_New`` also apply to this function. -@@ -211,86 +208,24 @@ ++ .. index:: single: PyCode_NewWithPosOnlyArgs (C function) ++ + .. versionadded:: 3.8 as ``PyCode_NewWithPosOnlyArgs`` - * Quoted Include In Framework Header: No + .. versionchanged:: 3.11 +@@ -295,9 +294,6 @@ + this functionality is a CPython implementation detail, and the API + may change without deprecation warnings. --8. Add a build step that copies the Python standard library into your app. In -- the "Build Phases" tab, add a new "Run Script" build step *before* the -- "Embed Frameworks" step, but *after* the "Copy Bundle Resources" step. Name -- the step "Install Target Specific Python Standard Library", disable the -- "Based on dependency analysis" checkbox, and set the script content to: -+7. Add a build step that processes the Python standard library, and your own -+ Python binary dependencies. In the "Build Phases" tab, add a new "Run -+ Script" build step *before* the "Embed Frameworks" step, but *after* the -+ "Copy Bundle Resources" step. Name the step "Process Python libraries", -+ disable the "Based on dependency analysis" checkbox, and set the script -+ content to: +-.. c:function:: Py_ssize_t _PyEval_RequestCodeExtraIndex(freefunc free) +- :no-typesetting: +- + .. c:function:: Py_ssize_t PyUnstable_Eval_RequestCodeExtraIndex(freefunc free) - .. code-block:: bash + Return a new opaque index value used to adding data to code objects. +@@ -310,6 +306,8 @@ + *free* will be called on non-``NULL`` data stored under the new index. + Use :c:func:`Py_DecRef` when storing :c:type:`PyObject`. -- set -e ++ .. index:: single: _PyEval_RequestCodeExtraIndex (C function) ++ + .. versionadded:: 3.6 as ``_PyEval_RequestCodeExtraIndex`` + + .. versionchanged:: 3.12 +@@ -318,9 +316,6 @@ + The old private name is deprecated, but will be available until the API + changes. + +-.. c:function:: int _PyCode_GetExtra(PyObject *code, Py_ssize_t index, void **extra) +- :no-typesetting: - -- mkdir -p "$CODESIGNING_FOLDER_PATH/python/lib" -- if [ "$EFFECTIVE_PLATFORM_NAME" = "-iphonesimulator" ]; then -- echo "Installing Python modules for iOS Simulator" -- rsync -au --delete "$PROJECT_DIR/Python.xcframework/ios-arm64_x86_64-simulator/lib/" "$CODESIGNING_FOLDER_PATH/python/lib/" -- else -- echo "Installing Python modules for iOS Device" -- rsync -au --delete "$PROJECT_DIR/Python.xcframework/ios-arm64/lib/" "$CODESIGNING_FOLDER_PATH/python/lib/" -- fi -+ set -e -+ source $PROJECT_DIR/Python.xcframework/build/build_utils.sh -+ install_python Python.xcframework app + .. c:function:: int PyUnstable_Code_GetExtra(PyObject *code, Py_ssize_t index, void **extra) -- Note that the name of the simulator "slice" in the XCframework may be -- different, depending the CPU architectures your ``XCFramework`` supports. -+ If you have placed your XCframework somewhere other than the root of your -+ project, modify the path to the first argument. + Set *extra* to the extra data stored under the given index. +@@ -329,6 +324,8 @@ + If no data was set under the index, set *extra* to ``NULL`` and return + 0 without setting an exception. --9. Add a second build step that processes the binary extension modules in the -- standard library into "Framework" format. Add a "Run Script" build step -- *directly after* the one you added in step 8, named "Prepare Python Binary -- Modules". It should also have "Based on dependency analysis" unchecked, with -- the following script content: ++ .. index:: single: _PyCode_GetExtra (C function) ++ + .. versionadded:: 3.6 as ``_PyCode_GetExtra`` + + .. versionchanged:: 3.12 +@@ -337,14 +334,13 @@ + The old private name is deprecated, but will be available until the API + changes. + +-.. c:function:: int _PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra) +- :no-typesetting: - -- .. code-block:: bash + .. c:function:: int PyUnstable_Code_SetExtra(PyObject *code, Py_ssize_t index, void *extra) + + Set the extra data stored under the given index to *extra*. + Return 0 on success. Set an exception and return -1 on failure. + ++ .. index:: single: _PyCode_SetExtra (C function) ++ + .. versionadded:: 3.6 as ``_PyCode_SetExtra`` + + .. versionchanged:: 3.12 +diff --git a/Doc/c-api/conversion.rst b/Doc/c-api/conversion.rst +index f91ca221090..327b396f144 100644 +--- a/Doc/c-api/conversion.rst ++++ b/Doc/c-api/conversion.rst +@@ -130,8 +130,6 @@ + + *flags* can be zero or more of the following values or-ed together: + +- .. c:namespace:: NULL - -- set -e + .. c:macro:: Py_DTSF_SIGN + + Always precede the returned string with a sign +@@ -153,21 +151,9 @@ + + .. versionadded:: 3.11 + +- If *ptype* is non-``NULL``, then the value it points to will be set to one +- of the following constants depending on the type of *val*: - -- install_dylib () { -- INSTALL_BASE=$1 -- FULL_EXT=$2 +- .. list-table:: +- :header-rows: 1 +- :align: left - -- # The name of the extension file -- EXT=$(basename "$FULL_EXT") -- # The location of the extension file, relative to the bundle -- RELATIVE_EXT=${FULL_EXT#$CODESIGNING_FOLDER_PATH/} -- # The path to the extension file, relative to the install base -- PYTHON_EXT=${RELATIVE_EXT/$INSTALL_BASE/} -- # The full dotted name of the extension module, constructed from the file path. -- FULL_MODULE_NAME=$(echo $PYTHON_EXT | cut -d "." -f 1 | tr "/" "."); -- # A bundle identifier; not actually used, but required by Xcode framework packaging -- FRAMEWORK_BUNDLE_ID=$(echo $PRODUCT_BUNDLE_IDENTIFIER.$FULL_MODULE_NAME | tr "_" "-") -- # The name of the framework folder. -- FRAMEWORK_FOLDER="Frameworks/$FULL_MODULE_NAME.framework" +- * - *\*ptype* +- - type of *val* +- * - .. c:macro:: Py_DTST_FINITE +- - finite number +- * - .. c:macro:: Py_DTST_INFINITE +- - infinite number +- * - .. c:macro:: Py_DTST_NAN +- - not a number ++ If *ptype* is non-``NULL``, then the value it points to will be set to one of ++ ``Py_DTST_FINITE``, ``Py_DTST_INFINITE``, or ``Py_DTST_NAN``, signifying that ++ *val* is a finite number, an infinite number, or not a number, respectively. + + The return value is a pointer to *buffer* with the converted string or + ``NULL`` if the conversion failed. The caller is responsible for freeing the +diff --git a/Doc/c-api/dict.rst b/Doc/c-api/dict.rst +index b45bb043502..20ae06df64b 100644 +--- a/Doc/c-api/dict.rst ++++ b/Doc/c-api/dict.rst +@@ -118,7 +118,7 @@ + * If the key is present, set *\*result* to a new :term:`strong reference` + to the value and return ``1``. + * If the key is missing, set *\*result* to ``NULL`` and return ``0``. +- * On error, raise an exception, set *\*result* to ``NULL`` and return ``-1``. ++ * On error, raise an exception and return ``-1``. + + .. versionadded:: 3.13 + +diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst +index 1791f53f30e..508a1a3cb4b 100644 +--- a/Doc/c-api/exceptions.rst ++++ b/Doc/c-api/exceptions.rst +@@ -412,7 +412,7 @@ + + .. c:function:: int PyErr_WarnFormat(PyObject *category, Py_ssize_t stack_level, const char *format, ...) + +- Function similar to :c:func:`PyErr_WarnEx`, but uses ++ Function similar to :c:func:`PyErr_WarnEx`, but use + :c:func:`PyUnicode_FromFormat` to format the warning message. *format* is + an ASCII-encoded string. + +@@ -673,40 +673,28 @@ + single: SIGINT (C macro) + single: KeyboardInterrupt (built-in exception) + +- Handle external interruptions, such as signals or activating a debugger, +- whose processing has been delayed until it is safe +- to run Python code and/or raise exceptions. ++ This function interacts with Python's signal handling. + +- For example, pressing :kbd:`Ctrl-C` causes a terminal to send the +- :py:data:`signal.SIGINT` signal. +- This function executes the corresponding Python signal handler, which, +- by default, raises the :exc:`KeyboardInterrupt` exception. ++ If the function is called from the main thread and under the main Python ++ interpreter, it checks whether a signal has been sent to the processes ++ and if so, invokes the corresponding signal handler. If the :mod:`signal` ++ module is supported, this can invoke a signal handler written in Python. + +- :c:func:`!PyErr_CheckSignals` should be called by long-running C code +- frequently enough so that the response appears immediate to humans. ++ The function attempts to handle all pending signals, and then returns ``0``. ++ However, if a Python signal handler raises an exception, the error ++ indicator is set and the function returns ``-1`` immediately (such that ++ other pending signals may not have been handled yet: they will be on the ++ next :c:func:`PyErr_CheckSignals()` invocation). + +- Handlers invoked by this function currently include: ++ If the function is called from a non-main thread, or under a non-main ++ Python interpreter, it does nothing and returns ``0``. + +- - Signal handlers, including Python functions registered using +- the :mod:`signal` module. ++ This function can be called by long-running C code that wants to ++ be interruptible by user requests (such as by pressing Ctrl-C). + +- Signal handlers are only run in the main thread of the main interpreter. - -- # If the framework folder doesn't exist, create it. -- if [ ! -d "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER" ]; then -- echo "Creating framework for $RELATIVE_EXT" -- mkdir -p "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER" -- cp "$CODESIGNING_FOLDER_PATH/dylib-Info-template.plist" "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/Info.plist" -- plutil -replace CFBundleExecutable -string "$FULL_MODULE_NAME" "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/Info.plist" -- plutil -replace CFBundleIdentifier -string "$FRAMEWORK_BUNDLE_ID" "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/Info.plist" -- fi +- (This is where the function got the name: originally, signals +- were the only way to interrupt the interpreter.) - -- echo "Installing binary for $FRAMEWORK_FOLDER/$FULL_MODULE_NAME" -- mv "$FULL_EXT" "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/$FULL_MODULE_NAME" -- # Create a placeholder .fwork file where the .so was -- echo "$FRAMEWORK_FOLDER/$FULL_MODULE_NAME" > ${FULL_EXT%.so}.fwork -- # Create a back reference to the .so file location in the framework -- echo "${RELATIVE_EXT%.so}.fwork" > "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/$FULL_MODULE_NAME.origin" -- } +- - Running the garbage collector, if necessary. +- +- If any handler raises an exception, immediately return ``-1`` with that +- exception set. +- Any remaining interruptions are left to be processed on the next +- :c:func:`PyErr_CheckSignals()` invocation, if appropriate. +- +- If all handlers finish successfully, or there are no handlers to run, +- return ``0``. +- +- .. versionchanged:: 3.12 +- This function may now invoke the garbage collector. ++ .. note:: ++ The default Python signal handler for :c:macro:`!SIGINT` raises the ++ :exc:`KeyboardInterrupt` exception. + + + .. c:function:: void PyErr_SetInterrupt() +diff --git a/Doc/c-api/file.rst b/Doc/c-api/file.rst +index 1bb5c1b7685..9d01254ddb2 100644 +--- a/Doc/c-api/file.rst ++++ b/Doc/c-api/file.rst +@@ -123,13 +123,10 @@ + + Write object *obj* to file object *p*. The only supported flag for *flags* is + :c:macro:`Py_PRINT_RAW`; if given, the :func:`str` of the object is written +- instead of the :func:`repr`. +- +- If *obj* is ``NULL``, write the string ``""``. +- +- Return ``0`` on success or ``-1`` on failure; the ++ instead of the :func:`repr`. Return ``0`` on success or ``-1`` on failure; the + appropriate exception will be set. + ++ + .. c:function:: int PyFile_WriteString(const char *s, PyObject *p) + + Write string *s* to file object *p*. Return ``0`` on success or ``-1`` on +diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst +index 5a2dc7ecc07..d5b1c233459 100644 +--- a/Doc/c-api/float.rst ++++ b/Doc/c-api/float.rst +@@ -80,7 +80,7 @@ + + .. c:macro:: Py_INFINITY + +- This macro expands to a constant expression of type :c:expr:`double`, that ++ This macro expands a to constant expression of type :c:expr:`double`, that + represents the positive infinity. + + On most platforms, this is equivalent to the :c:macro:`!INFINITY` macro from +@@ -89,7 +89,7 @@ + + .. c:macro:: Py_NAN + +- This macro expands to a constant expression of type :c:expr:`double`, that ++ This macro expands a to constant expression of type :c:expr:`double`, that + represents a quiet not-a-number (qNaN) value. + + On most platforms, this is equivalent to the :c:macro:`!NAN` macro from +diff --git a/Doc/c-api/frame.rst b/Doc/c-api/frame.rst +index 967cfc72765..fb17cf7f1da 100644 +--- a/Doc/c-api/frame.rst ++++ b/Doc/c-api/frame.rst +@@ -50,7 +50,6 @@ + + Return a :term:`strong reference`, or ``NULL`` if *frame* has no outer + frame. +- This raises no exceptions. + + .. versionadded:: 3.9 + +diff --git a/Doc/c-api/gcsupport.rst b/Doc/c-api/gcsupport.rst +index afec8cbea93..3e23605778f 100644 +--- a/Doc/c-api/gcsupport.rst ++++ b/Doc/c-api/gcsupport.rst +@@ -175,10 +175,6 @@ + object argument. If *visit* returns a non-zero value that value should be + returned immediately. + +- The traversal function must not have any side effects. Implementations +- may not modify the reference counts of any Python objects nor create or +- destroy any Python objects. +- + To simplify writing :c:member:`~PyTypeObject.tp_traverse` handlers, a :c:func:`Py_VISIT` macro is + provided. In order to use this macro, the :c:member:`~PyTypeObject.tp_traverse` implementation + must name its arguments exactly *visit* and *arg*: +diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst +index 8e0c2ce6444..af46325f7c9 100644 +--- a/Doc/c-api/init.rst ++++ b/Doc/c-api/init.rst +@@ -1463,7 +1463,7 @@ + + Get the current interpreter. + +- Issue a fatal error if there is no current Python thread state or no current ++ Issue a fatal error if there no current Python thread state or no current + interpreter. It cannot return NULL. + + The caller must hold the GIL. +@@ -2051,7 +2051,7 @@ + *what* when after any bytecode is processed after which the exception becomes + set within the frame being executed. The effect of this is that as exception + propagation causes the Python stack to unwind, the callback is called upon +- return to each frame as the exception propagates. Only trace functions receive ++ return to each frame as the exception propagates. Only trace functions receives + these events; they are not needed by the profiler. + + +@@ -2179,7 +2179,7 @@ + the tracer function is called. Return ``0`` on success. Set an exception and + return ``-1`` on error. + +- Note that tracer functions **must not** create Python objects inside or ++ Not that tracer functions **must not** create Python objects inside or + otherwise the call will be re-entrant. The tracer also **must not** clear + any existing exception or set an exception. The GIL will be held every time + the tracer function is called. +diff --git a/Doc/c-api/init_config.rst b/Doc/c-api/init_config.rst +index c34f1e03c87..612aa2aa711 100644 +--- a/Doc/c-api/init_config.rst ++++ b/Doc/c-api/init_config.rst +@@ -532,7 +532,7 @@ + + Most ``PyConfig`` methods :ref:`preinitialize Python ` if needed. + In that case, the Python preinitialization configuration +- (:c:type:`PyPreConfig`) is based on the :c:type:`PyConfig`. If configuration ++ (:c:type:`PyPreConfig`) in based on the :c:type:`PyConfig`. If configuration + fields which are in common with :c:type:`PyPreConfig` are tuned, they must + be set before calling a :c:type:`PyConfig` method: + +diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst +index a49dde40a1c..6596250afef 100644 +--- a/Doc/c-api/intro.rst ++++ b/Doc/c-api/intro.rst +@@ -139,35 +139,6 @@ + + .. versionadded:: 3.3 + +-.. c:macro:: Py_ALIGNED(num) +- +- Specify alignment to *num* bytes on compilers that support it. +- +- Consider using the C11 standard ``_Alignas`` specifier over this macro. +- +-.. c:macro:: Py_ARITHMETIC_RIGHT_SHIFT(type, integer, positions) +- +- Similar to ``integer >> positions``, but forces sign extension, as the C +- standard does not define whether a right-shift of a signed integer will +- perform sign extension or a zero-fill. +- +- *integer* should be any signed integer type. +- *positions* is the number of positions to shift to the right. +- +- Both *integer* and *positions* can be evaluated more than once; +- consequently, avoid directly passing a function call or some other +- operation with side-effects to this macro. Instead, store the result as a +- variable and then pass it. +- +- *type* is unused and only kept for backwards compatibility. Historically, +- *type* was used to cast *integer*. +- +- .. versionchanged:: 3.1 +- +- This macro is now valid for all signed integer types, not just those for +- which ``unsigned type`` is legal. As a result, *type* is no longer +- used. +- + .. c:macro:: Py_ALWAYS_INLINE + + Ask the compiler to always inline a static inline function. The compiler can +@@ -190,15 +161,6 @@ + + .. versionadded:: 3.11 + +-.. c:macro:: Py_CAN_START_THREADS +- +- If this macro is defined, then the current system is able to start threads. +- +- Currently, all systems supported by CPython (per :pep:`11`), with the +- exception of some WebAssembly platforms, support starting threads. +- +- .. versionadded:: 3.13 +- + .. c:macro:: Py_CHARMASK(c) + + Argument must be a character or an integer in the range [-128, 127] or [0, +@@ -216,35 +178,11 @@ + .. versionchanged:: 3.8 + MSVC support was added. + +-.. c:macro:: Py_FORCE_EXPANSION(X) +- +- This is equivalent to ``X``, which is useful for token-pasting in +- macros, as macro expansions in *X* are forcefully evaluated by the +- preprocessor. +- +-.. c:macro:: Py_GCC_ATTRIBUTE(name) +- +- Use a GCC attribute *name*, hiding it from compilers that don't support GCC +- attributes (such as MSVC). +- +- This expands to ``__attribute__((name))`` on a GCC compiler, and expands +- to nothing on compilers that don't support GCC attributes. +- + .. c:macro:: Py_GETENV(s) + + Like ``getenv(s)``, but returns ``NULL`` if :option:`-E` was passed on the + command line (see :c:member:`PyConfig.use_environment`). + +-.. c:macro:: Py_LL(number) +- +- Use *number* as a ``long long`` integer literal. +- +- This usally expands to *number* followed by ``LL``, but will expand to some +- compiler-specific suffixes (such as ``I64``) on older compilers. +- +- In modern versions of Python, this macro is not very useful, as C99 and +- later require the ``LL`` suffix to be valid for an integer. +- + .. c:macro:: Py_LOCAL(type) + + Declare a function returning the specified *type* using a fast-calling +@@ -256,14 +194,6 @@ + Equivalent to :c:macro:`Py_LOCAL` but additionally requests the function + be inlined. + +-.. c:macro:: Py_LOCAL_SYMBOL +- +- Macro used to declare a symbol as local to the shared library (hidden). +- On supported platforms, it ensures the symbol is not exported. +- +- On compatible versions of GCC/Clang, it +- expands to ``__attribute__((visibility("hidden")))``. +- + .. c:macro:: Py_MAX(x, y) + + Return the maximum value between ``x`` and ``y``. +@@ -294,22 +224,6 @@ + + .. versionadded:: 3.11 + +-.. c:macro:: Py_SAFE_DOWNCAST(value, larger, smaller) +- +- Cast *value* to type *smaller* from type *larger*, validating that no +- information was lost. +- +- On release builds of Python, this is roughly equivalent to +- ``(smaller) value`` (in C++, ``static_cast(value)`` will be +- used instead). +- +- On debug builds (implying that :c:macro:`Py_DEBUG` is defined), this asserts +- that no information was lost with the cast from *larger* to *smaller*. +- +- *value*, *larger*, and *smaller* may all be evaluated more than once in the +- expression; consequently, do not pass an expression with side-effects directly to +- this macro. +- + .. c:macro:: Py_STRINGIFY(x) + + Convert ``x`` to a C string. E.g. ``Py_STRINGIFY(123)`` returns +@@ -317,14 +231,6 @@ + + .. versionadded:: 3.4 + +-.. c:macro:: Py_ULL(number) +- +- Similar to :c:macro:`Py_LL`, but *number* will be an ``unsigned long long`` +- literal instead. This is done by appending ``U`` to the result of ``Py_LL``. +- +- In modern versions of Python, this macro is not very useful, as C99 and +- later require the ``ULL``/``LLU`` suffixes to be valid for an integer. +- + .. c:macro:: Py_UNREACHABLE() + + Use this when you have a code path that cannot be reached by design. +@@ -336,7 +242,7 @@ + avoids a warning about unreachable code. For example, the macro is + implemented with ``__builtin_unreachable()`` on GCC in release mode. + +- A use for ``Py_UNREACHABLE()`` is following a call to a function that ++ A use for ``Py_UNREACHABLE()`` is following a call a function that + never returns but that is not declared :c:macro:`_Py_NO_RETURN`. + + If a code path is very unlikely code but can be reached under exceptional +@@ -434,48 +340,6 @@ + sizeof(array) / sizeof((array)[0]) + + +-.. c:macro:: Py_EXPORTED_SYMBOL +- +- Macro used to declare a symbol (function or data) as exported. +- On Windows, this expands to ``__declspec(dllexport)``. +- On compatible versions of GCC/Clang, it +- expands to ``__attribute__((visibility("default")))``. +- This macro is for defining the C API itself; extension modules should not use it. +- +- +-.. c:macro:: Py_IMPORTED_SYMBOL +- +- Macro used to declare a symbol as imported. +- On Windows, this expands to ``__declspec(dllimport)``. +- This macro is for defining the C API itself; extension modules should not use it. +- +- +-.. c:macro:: PyAPI_FUNC(type) +- +- Macro used by CPython to declare a function as part of the C API. +- Its expansion depends on the platform and build configuration. +- This macro is intended for defining CPython's C API itself; +- extension modules should not use it for their own symbols. +- +- +-.. c:macro:: PyAPI_DATA(type) +- +- Macro used by CPython to declare a public global variable as part of the C API. +- Its expansion depends on the platform and build configuration. +- This macro is intended for defining CPython's C API itself; +- extension modules should not use it for their own symbols. +- +-.. c:macro:: Py_VA_COPY +- +- This is a :term:`soft deprecated` alias to the C99-standard ``va_copy`` +- function. +- +- Historically, this would use a compiler-specific method to copy a ``va_list``. +- +- .. versionchanged:: 3.6 +- This is now an alias to ``va_copy``. +- +- + .. _api-objects: + + Objects, Types and Reference Counts +diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst +index 1dbd6b37c6a..2d70f46f3e4 100644 +--- a/Doc/c-api/long.rst ++++ b/Doc/c-api/long.rst +@@ -403,8 +403,8 @@ + + Otherwise, returns the number of bytes required to store the value. + If this is equal to or less than *n_bytes*, the entire value was copied. +- All *n_bytes* of the buffer are written: remaining bytes filled by +- copies of the sign bit. ++ All *n_bytes* of the buffer are written: large buffers are padded with ++ zeroes. + + If the returned value is greater than *n_bytes*, the value was + truncated: as many of the lowest bits of the value as could fit are written, +diff --git a/Doc/c-api/memory.rst b/Doc/c-api/memory.rst +index 734b3298a8c..b93b3ebec73 100644 +--- a/Doc/c-api/memory.rst ++++ b/Doc/c-api/memory.rst +@@ -294,39 +294,17 @@ + + Same as :c:func:`PyMem_Free`. + +- +-Deprecated aliases +------------------- +- +-These are :term:`soft deprecated` aliases to existing functions and macros. +-They exist solely for backwards compatibility. +- +-.. list-table:: +- :widths: auto +- :header-rows: 1 +- +- * * Deprecated alias +- * Corresponding function or macro +- * * .. c:macro:: PyMem_MALLOC(size) +- * :c:func:`PyMem_Malloc` +- * * .. c:macro:: PyMem_NEW(type, size) +- * :c:macro:`PyMem_New` +- * * .. c:macro:: PyMem_REALLOC(ptr, size) +- * :c:func:`PyMem_Realloc` +- * * .. c:macro:: PyMem_RESIZE(ptr, type, size) +- * :c:macro:`PyMem_Resize` +- * * .. c:macro:: PyMem_FREE(ptr) +- * :c:func:`PyMem_Free` +- * * .. c:macro:: PyMem_DEL(ptr) +- * :c:func:`PyMem_Free` +- +-.. versionchanged:: 3.4 +- +- The macros are now aliases of the corresponding functions and macros. +- Previously, their behavior was the same, but their use did not necessarily +- preserve binary compatibility across Python versions. +- +-.. deprecated:: 2.0 ++In addition, the following macro sets are provided for calling the Python memory ++allocator directly, without involving the C API functions listed above. However, ++note that their use does not preserve binary compatibility across Python ++versions and is therefore deprecated in extension modules. ++ ++* ``PyMem_MALLOC(size)`` ++* ``PyMem_NEW(type, size)`` ++* ``PyMem_REALLOC(ptr, size)`` ++* ``PyMem_RESIZE(ptr, type, size)`` ++* ``PyMem_FREE(ptr)`` ++* ``PyMem_DEL(ptr)`` + + + .. _objectinterface: +diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst +index 7601f5ee9f5..23a4cfb0e47 100644 +--- a/Doc/c-api/module.rst ++++ b/Doc/c-api/module.rst +@@ -263,12 +263,6 @@ + .. versionchanged:: 3.9 + No longer called before the module state is allocated. + +- +-.. c:var:: PyTypeObject PyModuleDef_Type +- +- The type of ``PyModuleDef`` objects. +- +- + Single-phase initialization + ........................... + +@@ -535,9 +529,6 @@ + ``PyModuleDef``, using either ``PyModule_Create`` or + ``PyModule_FromDefAndSpec``. + +- Return ``0`` on success. +- Return ``-1`` with an exception set on error. +- + .. versionadded:: 3.5 + + .. c:function:: int PyModule_AddFunctions(PyObject *module, PyMethodDef *functions) +diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst +index be4e5847022..416465c2a42 100644 +--- a/Doc/c-api/object.rst ++++ b/Doc/c-api/object.rst +@@ -319,8 +319,6 @@ + representation on success, ``NULL`` on failure. This is the equivalent of the + Python expression ``repr(o)``. Called by the :func:`repr` built-in function. + +- If argument is ``NULL``, return the string ``''``. +- + .. versionchanged:: 3.4 + This function now includes a debug assertion to help ensure that it + does not silently discard an active exception. +@@ -335,8 +333,6 @@ + a string similar to that returned by :c:func:`PyObject_Repr` in Python 2. + Called by the :func:`ascii` built-in function. + +- If argument is ``NULL``, return the string ``''``. +- + .. index:: string; PyObject_Str (C function) + + +@@ -347,8 +343,6 @@ + Python expression ``str(o)``. Called by the :func:`str` built-in function + and, therefore, by the :func:`print` function. + +- If argument is ``NULL``, return the string ``''``. +- + .. versionchanged:: 3.4 + This function now includes a debug assertion to help ensure that it + does not silently discard an active exception. +@@ -364,8 +358,6 @@ + a TypeError is raised when *o* is an integer instead of a zero-initialized + bytes object. + +- If argument is ``NULL``, return the :class:`bytes` object ``b''``. +- + + .. c:function:: int PyObject_IsSubclass(PyObject *derived, PyObject *cls) + +diff --git a/Doc/c-api/set.rst b/Doc/c-api/set.rst +index 09c0fb6b9c5..cba823aa027 100644 +--- a/Doc/c-api/set.rst ++++ b/Doc/c-api/set.rst +@@ -147,7 +147,7 @@ + + Return ``1`` if found and removed, ``0`` if not found (no action taken), and ``-1`` if an + error is encountered. Does not raise :exc:`KeyError` for missing keys. Raise a +- :exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~set.discard` ++ :exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~frozenset.discard` + method, this function does not automatically convert unhashable sets into + temporary frozensets. Raise :exc:`SystemError` if *set* is not an + instance of :class:`set` or its subtype. +diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst +index ca94cf18165..1688528d99a 100644 +--- a/Doc/c-api/structures.rst ++++ b/Doc/c-api/structures.rst +@@ -365,7 +365,7 @@ + + + These two constants are not used to indicate the calling convention but the +-binding when used with methods of classes. These may not be used for functions ++binding when use with methods of classes. These may not be used for functions + defined for modules. At most one of these flags may be set for any given + method. + +diff --git a/Doc/c-api/type.rst b/Doc/c-api/type.rst +index 1d94718b2d2..84a5b0fc3c0 100644 +--- a/Doc/c-api/type.rst ++++ b/Doc/c-api/type.rst +@@ -259,10 +259,6 @@ + Return the module object associated with the given type when the type was + created using :c:func:`PyType_FromModuleAndSpec`. + +- The returned reference is :term:`borrowed ` from *type*, +- and will be valid as long as you hold a reference to *type*. +- Do not release it with :c:func:`Py_DECREF` or similar. +- + If no module is associated with the given type, sets :py:class:`TypeError` + and returns ``NULL``. + +diff --git a/Doc/c-api/typehints.rst b/Doc/c-api/typehints.rst +index ec2fba6da8b..98fe68737de 100644 +--- a/Doc/c-api/typehints.rst ++++ b/Doc/c-api/typehints.rst +@@ -31,7 +31,7 @@ + static PyMethodDef my_obj_methods[] = { + // Other methods. + ... +- {"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, "my_obj is generic over its contained type"} ++ {"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, "See PEP 585"} + ... + } + +diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst +index 561f95cb90a..0b816e4a703 100644 +--- a/Doc/c-api/typeobj.rst ++++ b/Doc/c-api/typeobj.rst +@@ -611,7 +611,9 @@ + argument, and store in the instance's :c:member:`~PyVarObject.ob_size` field. + Note that the :c:member:`~PyVarObject.ob_size` field may later be used for + other purposes. For example, :py:type:`int` instances use the bits of +- :c:member:`~PyVarObject.ob_size` in an implementation-defined way. ++ :c:member:`~PyVarObject.ob_size` in an implementation-defined ++ way; the underlying storage and its size should be accessed using ++ :c:func:`PyLong_Export`. + + .. note:: + +@@ -1286,9 +1288,6 @@ + type structure. + + +- .. c:macro:: _Py_TPFLAGS_HAVE_VECTORCALL +- :no-typesetting: +- + .. c:macro:: Py_TPFLAGS_HAVE_VECTORCALL + + This bit is set when the class implements +@@ -1300,12 +1299,7 @@ + This bit is inherited if :c:member:`~PyTypeObject.tp_call` is also + inherited. + +- .. versionadded:: 3.8 as ``_Py_TPFLAGS_HAVE_VECTORCALL`` +- +- .. versionchanged:: 3.9 +- +- Renamed to the current name, without the leading underscore. +- The old provisional name is :term:`soft deprecated`. ++ .. versionadded:: 3.9 + + .. versionchanged:: 3.12 + +@@ -1412,52 +1406,6 @@ + It will be removed in a future version of CPython + + +- .. c:macro:: Py_TPFLAGS_HAVE_VERSION_TAG +- +- This is a :term:`soft deprecated` macro that does nothing. +- Historically, this would indicate that the +- :c:member:`~PyTypeObject.tp_version_tag` field was available and +- initialized. +- +- +- .. c:macro:: Py_TPFLAGS_INLINE_VALUES +- +- This bit indicates that instances of this type will have an "inline values" +- array (containing the object's attributes) placed directly after the end +- of the object. +- +- This requires that :c:macro:`Py_TPFLAGS_HAVE_GC` is set. +- +- **Inheritance:** +- +- This flag is not inherited. +- +- .. versionadded:: 3.13 +- +- +- .. c:macro:: Py_TPFLAGS_IS_ABSTRACT +- +- This bit indicates that this is an abstract type and therefore cannot +- be instantiated. +- +- **Inheritance:** +- +- This flag is not inherited. +- +- .. seealso:: +- :mod:`abc` +- +- +- .. c:macro:: Py_TPFLAGS_HAVE_STACKLESS_EXTENSION +- +- Internal. Do not set or unset this flag. +- Historically, this was a reserved flag for use in Stackless Python. +- +- .. warning:: +- This flag is present in header files, but is not be used. +- This may be removed in a future version of CPython. +- +- + .. c:member:: const char* PyTypeObject.tp_doc + + .. corresponding-type-slot:: Py_tp_doc +@@ -1535,11 +1483,6 @@ + but the instance has no strong reference to the elements inside it, as they + are allowed to be removed even if the instance is still alive). + +- .. warning:: +- The traversal function must not have any side effects. It must not +- modify the reference counts of any Python objects nor create or destroy +- any Python objects. +- + Note that :c:func:`Py_VISIT` requires the *visit* and *arg* parameters to + :c:func:`!local_traverse` to have these specific names; don't name them just + anything. +@@ -2743,13 +2686,13 @@ + steps: + + (1) Check if the request can be met. If not, raise :exc:`BufferError`, +- set ``view->obj`` to ``NULL`` and return ``-1``. ++ set :c:expr:`view->obj` to ``NULL`` and return ``-1``. + + (2) Fill in the requested fields. + + (3) Increment an internal counter for the number of exports. + +- (4) Set ``view->obj`` to *exporter* and increment ``view->obj``. ++ (4) Set :c:expr:`view->obj` to *exporter* and increment :c:expr:`view->obj`. + + (5) Return ``0``. + +@@ -2757,10 +2700,10 @@ + schemes can be used: + + * Re-export: Each member of the tree acts as the exporting object and +- sets ``view->obj`` to a new reference to itself. ++ sets :c:expr:`view->obj` to a new reference to itself. + + * Redirect: The buffer request is redirected to the root object of the +- tree. Here, ``view->obj`` will be a new reference to the root ++ tree. Here, :c:expr:`view->obj` will be a new reference to the root + object. + + The individual fields of *view* are described in section +@@ -2804,7 +2747,7 @@ + *view* argument. + + +- This function MUST NOT decrement ``view->obj``, since that is ++ This function MUST NOT decrement :c:expr:`view->obj`, since that is + done automatically in :c:func:`PyBuffer_Release` (this scheme is + useful for breaking reference cycles). + +diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst +index feca7a92e27..1aedd7bed1f 100644 +--- a/Doc/c-api/unicode.rst ++++ b/Doc/c-api/unicode.rst +@@ -682,7 +682,7 @@ + Fail if *fill_char* is bigger than the string maximum character, or if the + string has more than 1 reference. + +- Return the number of written characters, or return ``-1`` and raise an ++ Return the number of written character, or return ``-1`` and raise an + exception on error. + + .. versionadded:: 3.3 +@@ -1082,7 +1082,7 @@ + .. versionadded:: 3.3 + + .. versionchanged:: 3.7 +- The return type is now ``const char *`` rather than ``char *``. ++ The return type is now ``const char *`` rather of ``char *``. + + .. versionchanged:: 3.10 + This function is a part of the :ref:`limited API `. +@@ -1104,7 +1104,7 @@ + .. versionadded:: 3.3 + + .. versionchanged:: 3.7 +- The return type is now ``const char *`` rather than ``char *``. ++ The return type is now ``const char *`` rather of ``char *``. + + + UTF-32 Codecs +diff --git a/Doc/c-api/veryhigh.rst b/Doc/c-api/veryhigh.rst +index 6256bf7a145..7eb9f0b54ab 100644 +--- a/Doc/c-api/veryhigh.rst ++++ b/Doc/c-api/veryhigh.rst +@@ -191,7 +191,7 @@ + objects *globals* and *locals* with the compiler flags specified by + *flags*. *globals* must be a dictionary; *locals* can be any object + that implements the mapping protocol. The parameter *start* specifies +- the start symbol and must be one of the :ref:`available start symbols `. ++ the start symbol and must one of the :ref:`available start symbols `. + + Returns the result of executing the code as a Python object, or ``NULL`` if an + exception was raised. +diff --git a/Doc/c-api/weakref.rst b/Doc/c-api/weakref.rst +index ae19d5feea1..c769e081013 100644 +--- a/Doc/c-api/weakref.rst ++++ b/Doc/c-api/weakref.rst +@@ -42,8 +42,8 @@ + callable object that receives notification when *ob* is garbage collected; it + should accept a single parameter, which will be the weak reference object + itself. *callback* may also be ``None`` or ``NULL``. If *ob* is not a +- weakly referenceable object, this will raise :exc:`TypeError` and return +- ``NULL``. ++ weakly referenceable object, or if *callback* is not callable, ``None``, or ++ ``NULL``, this will return ``NULL`` and raise :exc:`TypeError`. + + .. seealso:: + :c:func:`PyType_SUPPORTS_WEAKREFS` for checking if *ob* is weakly +@@ -58,8 +58,8 @@ + be a callable object that receives notification when *ob* is garbage + collected; it should accept a single parameter, which will be the weak + reference object itself. *callback* may also be ``None`` or ``NULL``. If *ob* +- weakly referenceable object, this will raise :exc:`TypeError` and return +- ``NULL``. ++ is not a weakly referenceable object, or if *callback* is not callable, ++ ``None``, or ``NULL``, this will return ``NULL`` and raise :exc:`TypeError`. + + .. seealso:: + :c:func:`PyType_SUPPORTS_WEAKREFS` for checking if *ob* is weakly +diff --git a/Doc/conf.py b/Doc/conf.py +index 1443db83b43..fd7db014092 100644 +--- a/Doc/conf.py ++++ b/Doc/conf.py +@@ -8,13 +8,15 @@ + + import os + import sys ++from importlib import import_module + from importlib.util import find_spec + + # Make our custom extensions available to Sphinx + sys.path.append(os.path.abspath('tools/extensions')) + sys.path.append(os.path.abspath('includes')) + +-from patchlevel import get_header_version_info, get_version_info ++# Python specific content from Doc/Tools/extensions/pyspecific.py ++from pyspecific import SOURCE_URI + + # General configuration + # --------------------- +@@ -39,7 +41,6 @@ + + # Skip if downstream redistributors haven't installed them + _OPTIONAL_EXTENSIONS = ( +- 'linklint.ext', + 'notfound.extension', + 'sphinxext.opengraph', + ) +@@ -68,12 +69,11 @@ + # General substitutions. + project = 'Python' + copyright = "2001-%Y, Python Software Foundation" +-_doc_authors = 'Python documentation authors' + + # We look for the Include/patchlevel.h file in the current Python source tree + # and replace the values accordingly. + # See Doc/tools/extensions/patchlevel.py +-version, release = get_version_info() ++version, release = import_module('patchlevel').get_version_info() + + rst_epilog = f""" + .. |python_version_literal| replace:: ``Python {version}`` +@@ -166,7 +166,6 @@ + ('c:type', '__int64'), + ('c:type', 'unsigned __int64'), + ('c:type', 'double'), +- ('c:type', '_Float16'), + # Standard C structures + ('c:struct', 'in6_addr'), + ('c:struct', 'in_addr'), +@@ -355,74 +354,69 @@ + + # Grouping the document tree into LaTeX files. List of tuples + # (source start file, target name, title, author, document class [howto/manual]). ++_stdauthor = 'The Python development team' + latex_documents = [ +- ('c-api/index', 'c-api.tex', 'The Python/C API', _doc_authors, 'manual'), ++ ('c-api/index', 'c-api.tex', 'The Python/C API', _stdauthor, 'manual'), + ( + 'extending/index', + 'extending.tex', + 'Extending and Embedding Python', +- _doc_authors, ++ _stdauthor, + 'manual', + ), + ( + 'installing/index', + 'installing.tex', + 'Installing Python Modules', +- _doc_authors, ++ _stdauthor, + 'manual', + ), + ( + 'library/index', + 'library.tex', + 'The Python Library Reference', +- _doc_authors, ++ _stdauthor, + 'manual', + ), + ( + 'reference/index', + 'reference.tex', + 'The Python Language Reference', +- _doc_authors, ++ _stdauthor, + 'manual', + ), + ( + 'tutorial/index', + 'tutorial.tex', + 'Python Tutorial', +- _doc_authors, ++ _stdauthor, + 'manual', + ), + ( + 'using/index', + 'using.tex', + 'Python Setup and Usage', +- _doc_authors, ++ _stdauthor, + 'manual', + ), + ( + 'faq/index', + 'faq.tex', + 'Python Frequently Asked Questions', +- _doc_authors, ++ _stdauthor, + 'manual', + ), + ( + 'whatsnew/' + version, + 'whatsnew.tex', + 'What\'s New in Python', +- _doc_authors, ++ 'A. M. Kuchling', + 'howto', + ), + ] + # Collect all HOWTOs individually + latex_documents.extend( +- ( +- 'howto/' + fn[:-4], +- 'howto-' + fn[:-4] + '.tex', +- '', +- _doc_authors, +- 'howto', +- ) ++ ('howto/' + fn[:-4], 'howto-' + fn[:-4] + '.tex', '', _stdauthor, 'howto') + for fn in os.listdir('howto') + if fn.endswith('.rst') and fn != 'index.rst' + ) +@@ -433,7 +427,7 @@ + # Options for Epub output + # ----------------------- + +-epub_author = _doc_authors ++epub_author = 'Python Documentation Authors' + epub_publisher = 'Python Software Foundation' + epub_exclude_files = ('index.xhtml', 'download.xhtml') + +@@ -545,20 +539,15 @@ + r'https://unix.org/version2/whatsnew/lp64_wp.html', + ] + +- + # Options for sphinx.ext.extlinks + # ------------------------------- + +-v = get_header_version_info() +-branch = "main" if v.releaselevel == "alpha" else f"{v.major}.{v.minor}" +- + # This config is a dictionary of external sites, + # mapping unique short aliases to a base URL and a prefix. + # https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html + extlinks = { +- "oss-fuzz": ("https://issues.oss-fuzz.com/issues/%s", "#%s"), + "pypi": ("https://pypi.org/project/%s/", "%s"), +- "source": (f"https://github.com/python/cpython/tree/{branch}/%s", "%s"), ++ "source": (SOURCE_URI, "%s"), + } + extlinks_detect_hardcoded_links = True + +@@ -569,17 +558,6 @@ + refcount_file = 'data/refcounts.dat' + stable_abi_file = 'data/stable_abi.dat' + +-# Options for notfound.extension +-# ------------------------------- +- +-if not os.getenv("READTHEDOCS"): +- if language_code: +- notfound_urls_prefix = ( +- f'/{language_code.replace("_", "-").lower()}/{version}/' +- ) +- else: +- notfound_urls_prefix = f'/{version}/' +- + # Options for sphinxext-opengraph + # ------------------------------- + +diff --git a/Doc/data/python3.13.abi b/Doc/data/python3.13.abi +index e0588167eba..619d84ae4ab 100644 +--- a/Doc/data/python3.13.abi ++++ b/Doc/data/python3.13.abi +@@ -1143,7 +1143,6 @@ + + + +- + + + +@@ -1670,7 +1669,7 @@ + + + +- ++ + + + +@@ -1688,7 +1687,7 @@ + + + +- ++ + + + +@@ -1703,7 +1702,7 @@ + + + +- ++ + + + +@@ -1737,10 +1736,10 @@ + + + +- ++ + + +- ++ + + + +@@ -1828,11 +1827,11 @@ + + + +- ++ + + + +- ++ + + + +@@ -1844,14 +1843,14 @@ + + + +- ++ + + + + + + +- ++ + + + +@@ -1870,7 +1869,7 @@ + + + +- ++ + + + +@@ -1898,7 +1897,7 @@ + + + +- ++ + + + +@@ -1940,7 +1939,7 @@ + + + +- ++ + + + +@@ -1957,7 +1956,7 @@ + + + +- ++ + + + +@@ -1974,7 +1973,7 @@ + + + +- ++ + + + +@@ -2001,13 +2000,13 @@ + + + +- ++ + + + + + +- ++ + + + +@@ -2015,7 +2014,7 @@ + + + +- ++ + + + +@@ -2100,7 +2099,7 @@ + + + +- ++ + + + +@@ -2125,7 +2124,7 @@ + + + +- ++ + + + +@@ -2164,7 +2163,7 @@ + + + +- ++ + + + +@@ -2459,7 +2458,7 @@ + + + +- ++ + + + +@@ -3393,7 +3392,7 @@ + + + +- ++ + + + +@@ -3447,7 +3446,7 @@ + + + +- ++ + + + +@@ -3486,20 +3485,20 @@ + + + +- +- ++ ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + + +@@ -3558,7 +3557,7 @@ + + + +- ++ + + + +@@ -3567,7 +3566,7 @@ + + + +- ++ + + + +@@ -3653,7 +3652,7 @@ + + + +- ++ + + + +@@ -3675,12 +3674,12 @@ + + + +- ++ + + + + +- ++ + + + +@@ -3697,7 +3696,7 @@ + + + +- ++ + + + +@@ -3735,7 +3734,7 @@ + + + +- ++ + + + +@@ -3843,52 +3842,52 @@ + + + +- ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- ++ + + +- +- ++ ++ + + +- ++ + + +- ++ + + +- +- ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + + +- +- ++ ++ + + + +@@ -3896,7 +3895,7 @@ + + + +- ++ + + + +@@ -3973,7 +3972,7 @@ + + + +- ++ + + + +@@ -4010,7 +4009,7 @@ + + + +- ++ + + + +@@ -4070,7 +4069,7 @@ + + + +- ++ + + + +@@ -4103,7 +4102,7 @@ + + + +- ++ + + + +@@ -4145,7 +4144,7 @@ + + + +- ++ + + + +@@ -4817,7 +4816,7 @@ + + + +- ++ + + + +@@ -4855,7 +4854,7 @@ + + + +- ++ + + + +@@ -5175,35 +5174,35 @@ + + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + + +- ++ + + + +@@ -5261,7 +5260,7 @@ + + + +- ++ + + + +@@ -5368,100 +5367,100 @@ + + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ + + +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ + + +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + + +- ++ + + + +@@ -5480,7 +5479,7 @@ + + + +- ++ + + + +@@ -5496,7 +5495,7 @@ + + + +- ++ + + + +@@ -5642,30 +5641,30 @@ + + + +- +- +- +- ++ ++ ++ ++ + + + +- +- +- ++ ++ ++ + + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + + +- ++ + + + +@@ -5740,7 +5739,7 @@ + + + +- ++ + + + +@@ -5762,10 +5761,10 @@ + + + +- ++ + + +- ++ + + + +@@ -5818,7 +5817,7 @@ + + + +- ++ + + + +@@ -5855,7 +5854,7 @@ + + + +- ++ + + + +@@ -5976,54 +5975,54 @@ + + + +- +- +- ++ ++ ++ + + +- +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + + +- ++ + + + +@@ -6140,18 +6139,18 @@ + + + +- ++ + +- ++ + + + +- ++ + + + + +- ++ + + + +@@ -6282,8 +6281,8 @@ + + + +- +- ++ ++ + + + +@@ -6331,170 +6330,170 @@ + + + +- +- ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + + +@@ -6503,14 +6502,14 @@ + + + +- ++ + + + +- ++ + + +- ++ + + + +@@ -6726,129 +6725,129 @@ + + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ ++ + + + +- ++ + + + +@@ -6937,7 +6936,7 @@ + + + +- ++ + + + +@@ -7006,6 +7005,11 @@ + + + ++ ++ ++ ++ ++ + + + +@@ -7102,41 +7106,41 @@ + + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + + +- ++ + + + +@@ -7312,7 +7316,7 @@ + + + +- ++ + + + +@@ -7405,16 +7409,16 @@ + + + +- +- ++ ++ + + +- +- ++ ++ + + + +- ++ + + + +@@ -7427,11 +7431,6 @@ + + + +- +- +- +- +- + + + +@@ -7453,7 +7452,7 @@ + + + +- ++ + + + +@@ -7526,7 +7525,7 @@ + + + +- ++ + + + +@@ -7542,7 +7541,7 @@ + + + +- ++ + + + +@@ -7550,22 +7549,18 @@ + + + +- ++ + + +- +- +- +- +- ++ + + + +- ++ + + + +- ++ + + + +@@ -7613,42 +7608,42 @@ + + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + + +- ++ + + + +@@ -7661,7 +7656,7 @@ + + + +- ++ + + + +@@ -7698,6 +7693,11 @@ + + + ++ ++ ++ ++ ++ + + + +@@ -7740,7 +7740,7 @@ + + + +- ++ + + + +@@ -7914,11 +7914,6 @@ + + + +- +- +- +- +- + + + +@@ -7941,7 +7936,7 @@ + + + +- ++ + + + +@@ -7969,7 +7964,7 @@ + + + +- ++ + + + +@@ -7996,7 +7991,7 @@ + + + +- ++ + + + +@@ -8055,7 +8050,7 @@ + + + +- ++ + + + +@@ -8189,7 +8184,7 @@ + + + +- ++ + + + +@@ -8201,12 +8196,12 @@ + + + +- +- ++ ++ + + + +- ++ + + + +@@ -8244,7 +8239,7 @@ + + + +- ++ + + + +@@ -8619,7 +8614,7 @@ + + + +- ++ + + + +@@ -9207,13 +9202,13 @@ + + + +- ++ + + +- ++ + + +- ++ + + + +@@ -9407,13 +9402,13 @@ + + + +- ++ + + + + + +- ++ + + + +@@ -9485,7 +9480,7 @@ + + + +- ++ + + + +@@ -9500,7 +9495,7 @@ + + + +- ++ + + + +@@ -9519,7 +9514,7 @@ + + + +- ++ + + + +@@ -9579,30 +9574,30 @@ + + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + + +- ++ + + + +@@ -9630,7 +9625,7 @@ + + + +- ++ + + + +@@ -9675,27 +9670,27 @@ + + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + + +- ++ + + + +@@ -9715,7 +9710,7 @@ + + + +- ++ + + + +@@ -9880,114 +9875,114 @@ + + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + + +- ++ + + + +@@ -10005,7 +10000,7 @@ + + + +- ++ + + + +@@ -10027,7 +10022,7 @@ + + + +- ++ + + + +@@ -10689,7 +10684,7 @@ + + + +- ++ + + + +@@ -10703,7 +10698,7 @@ + + + +- ++ + + + +@@ -10759,7 +10754,7 @@ + + + +- ++ + + + +@@ -11892,8 +11887,8 @@ + + + +- +- ++ ++ + + + +@@ -11958,7 +11953,7 @@ + + + +- ++ + + + +@@ -11968,7 +11963,7 @@ + + + +- ++ + + + +@@ -11977,7 +11972,7 @@ + + + +- ++ + + + +@@ -12049,7 +12044,7 @@ + + + +- ++ + + + +@@ -12175,150 +12170,150 @@ + + + +- ++ + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + + +@@ -13346,7 +13341,7 @@ + + + +- ++ + + + +@@ -13385,7 +13380,7 @@ + + + +- ++ + + + +@@ -13444,10 +13439,10 @@ + + + +- ++ + + +- ++ + + + +@@ -14713,29 +14708,29 @@ + + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- +- ++ ++ + + + + +- +- ++ ++ + + + +@@ -14819,7 +14814,7 @@ + + + +- ++ + + + +@@ -14943,9 +14938,6 @@ + + + +- +- +- + + + +@@ -14976,7 +14968,7 @@ + + + +- ++ + + + +@@ -16463,18 +16455,18 @@ + + + +- ++ + +- ++ + +- +- ++ ++ + +- +- ++ ++ + + +- ++ + + + +@@ -16496,31 +16488,22 @@ + + + +- +- +- +- +- +- +- +- +- + +- ++ + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + + +@@ -16852,74 +16835,74 @@ + + + +- ++ + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + + +@@ -17254,10 +17237,10 @@ + + + +- ++ + + +- ++ + + + +@@ -19708,7 +19691,7 @@ + + + +- ++ + + + +@@ -19716,7 +19699,7 @@ + + + +- ++ + + + +@@ -19935,7 +19918,7 @@ + + + +- ++ + + + +@@ -20146,10 +20129,10 @@ + + + +- ++ + + +- ++ + + + +@@ -21001,7 +20984,7 @@ + + + +- ++ + + + +@@ -21074,61 +21057,61 @@ + + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + + +@@ -21278,17 +21261,17 @@ + + + +- ++ + + + +- ++ + + +- ++ + + +- ++ + + + +@@ -21531,13 +21514,13 @@ + + + +- ++ + + + + + +- ++ + + + +@@ -22021,243 +22004,243 @@ + + + +- ++ + + + + + +- ++ + + + + +- ++ + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + + + +- ++ + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- +- ++ ++ + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + + +@@ -22621,7 +22604,7 @@ + + + +- ++ + + + +@@ -22803,15 +22786,15 @@ + + + +- ++ + + + +- ++ + + + +- ++ + + + +@@ -23148,7 +23131,7 @@ + + + +- ++ + + + +@@ -23210,7 +23193,7 @@ + + + +- ++ + + + +@@ -23261,7 +23244,7 @@ + + + +- ++ + + + +@@ -23286,7 +23269,7 @@ + + + +- ++ + + + +@@ -23408,7 +23391,7 @@ + + + +- ++ + + + +@@ -23463,14 +23446,14 @@ + + + +- ++ + + + + + + +- ++ + + + +@@ -23479,7 +23462,7 @@ + + + +- ++ + + + +@@ -23499,8 +23482,8 @@ + + + +- +- ++ ++ + + + +@@ -23533,7 +23516,7 @@ + + + +- ++ + + + +@@ -23578,30 +23561,30 @@ + + + +- +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ ++ + + +- +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ ++ + + + +- ++ + + + +- ++ + + + +@@ -23756,13 +23739,13 @@ + + + +- ++ + + + + + +- ++ + + + +@@ -23897,13 +23880,13 @@ + + + +- ++ + + + + + +- ++ + + + +@@ -23947,7 +23930,7 @@ + + + +- ++ + + + +@@ -23960,7 +23943,7 @@ + + + +- ++ + + + +@@ -24010,57 +23993,57 @@ + + + +- ++ + + + +- +- +- ++ ++ ++ + + + + + + +- ++ + + + + + +- ++ + + + + + +- ++ + + + + + + +- ++ + + + + + +- ++ + + + + + +- ++ + + + + + +- ++ + + + +@@ -24068,41 +24051,41 @@ + + + +- ++ + + + + + + +- ++ + + + + + +- ++ + + + + + +- ++ + + + + +- ++ + + + + +- ++ + + + + +- ++ + + + +@@ -24115,16 +24098,16 @@ + + + +- ++ + + + +- ++ + + + + +- ++ + + + +@@ -24309,126 +24292,126 @@ + + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- ++ + + + +- ++ + + + +@@ -24567,7 +24550,7 @@ + + + +- ++ + + + +@@ -24656,7 +24639,7 @@ + + + +- ++ + + + +@@ -24933,11 +24916,18 @@ + + + +- ++ + + + + ++ ++ ++ ++ ++ ++ ++ + + + +@@ -25093,81 +25083,81 @@ + + + +- +- +- +- ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- ++ + + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + + +- ++ + + + +@@ -25250,13 +25240,13 @@ + + + +- +- +- ++ ++ ++ + + + +- ++ + + + +@@ -25305,7 +25295,7 @@ + + + +- ++ + + + +@@ -25412,21 +25402,21 @@ + + + +- ++ + +- ++ + + +- ++ + + +- +- ++ ++ + +- ++ + + +- ++ + + + +@@ -25574,76 +25564,76 @@ + + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + + +@@ -25660,7 +25650,7 @@ + + + +- ++ + + + +@@ -25740,37 +25730,37 @@ + + + +- +- +- ++ ++ ++ + + +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- ++ + + + + + +- ++ + + + +@@ -25895,7 +25885,7 @@ + + + +- ++ + + + +@@ -25905,7 +25895,7 @@ + + + +- ++ + + + +@@ -26024,7 +26014,7 @@ + + + +- ++ + + + +@@ -26032,7 +26022,7 @@ + + + +- ++ + + + +@@ -26045,7 +26035,7 @@ + + + +- ++ + + + +@@ -26078,7 +26068,7 @@ + + + +- ++ + + + +@@ -26135,7 +26125,7 @@ + + + +- ++ + + + +@@ -26189,14 +26179,14 @@ + + + +- ++ + + + + + + +- ++ + + + +@@ -26270,21 +26260,21 @@ + + + +- ++ + + + + +- ++ + + + + +- ++ + + + +- ++ + + + +@@ -26293,7 +26283,7 @@ + + + +- ++ + + + +@@ -26337,7 +26327,7 @@ + + + +- ++ + + + +@@ -26520,116 +26510,116 @@ + + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- ++ + + +- ++ + + +- +- +- ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- +- +- +- ++ ++ ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- ++ + + + +- ++ + + + +@@ -26913,31 +26903,31 @@ + + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + +- +- ++ ++ + + +- ++ + + + +- ++ + + +- ++ + + + +@@ -27067,7 +27057,7 @@ + + + +- ++ + + + +@@ -27088,7 +27078,7 @@ + + + +- ++ + + + +@@ -27195,7 +27185,7 @@ + + + +- ++ + + + +@@ -27222,7 +27212,7 @@ + + + +- ++ + + + +@@ -27372,7 +27362,7 @@ + + + +- ++ + + + +@@ -27442,44 +27432,44 @@ + + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- ++ ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- ++ + + + +- ++ + + + +@@ -27513,7 +27503,7 @@ + + + +- ++ + + + +@@ -27522,7 +27512,7 @@ + + + +- ++ + + + +@@ -27573,7 +27563,7 @@ + + + +- ++ + + + +@@ -27631,30 +27621,30 @@ + + + +- ++ + +- ++ + + + + + + +- +- ++ ++ + + + +- +- ++ ++ + + +- +- ++ ++ + + + +- ++ + + + +@@ -27699,12 +27689,12 @@ + + + +- ++ + + + + +- ++ + + + +@@ -27727,7 +27717,7 @@ + + + +- ++ + + + +@@ -27739,7 +27729,7 @@ + + + +- ++ + + + +@@ -27824,7 +27814,7 @@ + + + +- ++ + + + +@@ -27866,12 +27856,15 @@ + + + +- ++ ++ ++ ++ + + + + +- ++ + + + +@@ -28190,7 +28183,7 @@ + + + +- ++ + + + +@@ -28376,6 +28369,9 @@ + + + ++ ++ ++ + + + +@@ -28456,42 +28452,42 @@ + + + +- ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + + +- ++ + + + +@@ -28500,11 +28496,11 @@ + + + +- ++ + + + +- ++ + + + +@@ -28563,7 +28559,7 @@ + + + +- ++ + + + +@@ -28626,139 +28622,136 @@ + + + +- +- +- + + + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- ++ + + +- ++ + + +- +- ++ ++ + + +- +- ++ ++ + + +- ++ + + +- +- ++ ++ + + +- +- +- ++ ++ ++ + + +- +- ++ ++ + + + +- ++ + + + + + + +- +- +- +- ++ ++ ++ ++ + + +- +- +- +- +- ++ ++ ++ ++ ++ + + + +- ++ + + + +@@ -28955,7 +28948,7 @@ + + + +- ++ + + + +@@ -29148,7 +29141,7 @@ + + + +- ++ + + + +@@ -29179,7 +29172,7 @@ + + + +- ++ + + + +@@ -29187,10 +29180,10 @@ + + + +- ++ + + +- ++ + + + +@@ -29391,7 +29384,7 @@ + + + +- ++ + + + +@@ -29399,11 +29392,6 @@ + + + +- +- +- +- +- + + + +@@ -29415,7 +29403,7 @@ + + + +- ++ + + + +diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat +index 9e0ce81627f..67f551cf6de 100644 +--- a/Doc/data/refcounts.dat ++++ b/Doc/data/refcounts.dat +@@ -2398,9 +2398,6 @@ + PyType_GetName:PyObject*::+1: + PyType_GetName:PyTypeObject*:type:0: + +-PyType_GetModule:PyObject*::0: +-PyType_GetModule:PyTypeObject*:type:0: +- + PyType_GetModuleByDef:PyObject*::0: + PyType_GetModuleByDef:PyTypeObject*:type:0: + PyType_GetModuleByDef:PyModuleDef*:def:: +diff --git a/Doc/data/stable_abi.dat b/Doc/data/stable_abi.dat +index 923742077ea..9156c24ef16 100644 +--- a/Doc/data/stable_abi.dat ++++ b/Doc/data/stable_abi.dat +@@ -1,7 +1,7 @@ + role,name,added,ifdef_note,struct_abi_kind + macro,METH_CLASS,3.2,, + macro,METH_COEXIST,3.2,, +-macro,METH_FASTCALL,3.10,, ++macro,METH_FASTCALL,3.7,, + macro,METH_METHOD,3.7,, + macro,METH_NOARGS,3.2,, + macro,METH_O,3.2,, +diff --git a/Doc/deprecations/index.rst b/Doc/deprecations/index.rst +index f004724fac0..e3adce99565 100644 +--- a/Doc/deprecations/index.rst ++++ b/Doc/deprecations/index.rst +@@ -9,8 +9,6 @@ + + .. include:: pending-removal-in-3.17.rst + +-.. include:: pending-removal-in-3.18.rst +- + .. include:: pending-removal-in-future.rst + + C API Deprecations +diff --git a/Doc/deprecations/pending-removal-in-3.15.rst b/Doc/deprecations/pending-removal-in-3.15.rst +index 3b0ecb873ec..0c34f0593fb 100644 +--- a/Doc/deprecations/pending-removal-in-3.15.rst ++++ b/Doc/deprecations/pending-removal-in-3.15.rst +@@ -64,7 +64,7 @@ + + * :func:`~threading.RLock` will take no arguments in Python 3.15. + Passing any arguments has been deprecated since Python 3.14, +- as the Python version does not permit any arguments, ++ as the Python version does not permit any arguments, + but the C version allows any number of positional or keyword arguments, + ignoring every argument. + +diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst +index 98b29875b27..6f9dfa8616e 100644 +--- a/Doc/faq/programming.rst ++++ b/Doc/faq/programming.rst +@@ -8,11 +8,11 @@ + + .. contents:: + +-General questions ++General Questions + ================= + +-Is there a source code-level debugger with breakpoints and single-stepping? +---------------------------------------------------------------------------- ++Is there a source code level debugger with breakpoints, single-stepping, etc.? ++------------------------------------------------------------------------------ + + Yes. + +@@ -25,7 +25,8 @@ + for pdb as an example. + + The IDLE interactive development environment, which is part of the standard +-Python distribution (normally available as :mod:`idlelib`), ++Python distribution (normally available as ++`Tools/scripts/idle3 `_), + includes a graphical debugger. + + PythonWin is a Python IDE that includes a GUI debugger based on pdb. The +@@ -47,6 +48,7 @@ + They include: + + * `Wing IDE `_ ++* `Komodo IDE `_ + * `PyCharm `_ + + +@@ -55,15 +57,13 @@ + + Yes. + +-`Ruff `__, +-`Pylint `__ and +-`Pyflakes `__ do basic checking that will ++`Pylint `_ and ++`Pyflakes `_ do basic checking that will + help you catch bugs sooner. + +-Static type checkers such as `mypy `__, +-`ty `__, +-`Pyrefly `__, and +-`pytype `__ can check type hints in Python ++Static type checkers such as `Mypy `_, ++`Pyre `_, and ++`Pytype `_ can check type hints in Python + source code. + + +@@ -79,7 +79,7 @@ + Python binary to produce a single executable. + + One is to use the freeze tool, which is included in the Python source tree as +-:source:`Tools/freeze`. ++`Tools/freeze `_. + It converts Python byte code to C arrays; with a C compiler you can + embed all your modules into a new program, which is then linked with the + standard Python modules. +@@ -103,7 +103,6 @@ + * `py2app `_ (macOS only) + * `py2exe `_ (Windows only) + +- + Are there coding standards or a style guide for Python programs? + ---------------------------------------------------------------- + +@@ -111,7 +110,7 @@ + :pep:`8`. + + +-Core language ++Core Language + ============= + + .. _faq-unboundlocalerror: +@@ -144,7 +143,7 @@ + >>> foo() + Traceback (most recent call last): + ... +- UnboundLocalError: cannot access local variable 'x' where it is not associated with a value ++ UnboundLocalError: local variable 'x' referenced before assignment + + This is because when you make an assignment to a variable in a scope, that + variable becomes local to that scope and shadows any similarly named variable +@@ -209,7 +208,7 @@ + ---------------------------------------------------------------------------------- + + Assume you use a for loop to define a few different lambdas (or even plain +-functions), for example:: ++functions), e.g.:: + + >>> squares = [] + >>> for x in range(5): +@@ -228,7 +227,7 @@ + This happens because ``x`` is not local to the lambdas, but is defined in + the outer scope, and it is accessed when the lambda is called --- not when it + is defined. At the end of the loop, the value of ``x`` is ``4``, so all the +-functions now return ``4**2``, that is ``16``. You can also verify this by ++functions now return ``4**2``, i.e. ``16``. You can also verify this by + changing the value of ``x`` and see how the results of the lambdas change:: + + >>> x = 8 +@@ -299,9 +298,9 @@ + + It's good practice if you import modules in the following order: + +-1. standard library modules -- such as :mod:`sys`, :mod:`os`, :mod:`argparse`, :mod:`re` ++1. standard library modules -- e.g. :mod:`sys`, :mod:`os`, :mod:`argparse`, :mod:`re` + 2. third-party library modules (anything installed in Python's site-packages +- directory) -- such as :pypi:`dateutil`, :pypi:`requests`, :pypi:`tzdata` ++ directory) -- e.g. :mod:`!dateutil`, :mod:`!requests`, :mod:`!PIL.Image` + 3. locally developed modules + + It is sometimes necessary to move imports to a function or class to avoid +@@ -495,11 +494,11 @@ + + In other words: + +-* If we have a mutable object (such as :class:`list`, :class:`dict`, :class:`set`), +- we can use some specific operations to mutate it and all the variables ++* If we have a mutable object (:class:`list`, :class:`dict`, :class:`set`, ++ etc.), we can use some specific operations to mutate it and all the variables + that refer to it will see the change. +-* If we have an immutable object (such as :class:`str`, :class:`int`, :class:`tuple`), +- all the variables that refer to it will always see the same value, ++* If we have an immutable object (:class:`str`, :class:`int`, :class:`tuple`, ++ etc.), all the variables that refer to it will always see the same value, + but operations that transform that value into a new value always return a new + object. + +@@ -512,7 +511,7 @@ + + Remember that arguments are passed by assignment in Python. Since assignment + just creates references to objects, there's no alias between an argument name in +-the caller and callee, and consequently no call-by-reference. You can achieve the ++the caller and callee, and so no call-by-reference per se. You can achieve the + desired effect in a number of ways. + + 1) By returning a tuple of the results:: +@@ -715,8 +714,8 @@ + + "a" in ("b", "a") + +-The same is true of the various assignment operators (``=``, ``+=``, and so on). +-They are not truly operators but syntactic delimiters in assignment statements. ++The same is true of the various assignment operators (``=``, ``+=`` etc). They ++are not truly operators but syntactic delimiters in assignment statements. + + + Is there an equivalent of C's "?:" ternary operator? +@@ -869,9 +868,9 @@ + How do I convert a string to a number? + -------------------------------------- + +-For integers, use the built-in :func:`int` type constructor, for example, ``int('144') ++For integers, use the built-in :func:`int` type constructor, e.g. ``int('144') + == 144``. Similarly, :func:`float` converts to a floating-point number, +-for example, ``float('144') == 144.0``. ++e.g. ``float('144') == 144.0``. + + By default, these interpret the number as decimal, so that ``int('0144') == + 144`` holds true, and ``int('0x144')`` raises :exc:`ValueError`. ``int(string, +@@ -888,18 +887,18 @@ + directory. + + :func:`eval` also has the effect of interpreting numbers as Python expressions, +-so that, for example, ``eval('09')`` gives a syntax error because Python does not allow ++so that e.g. ``eval('09')`` gives a syntax error because Python does not allow + leading '0' in a decimal number (except '0'). + + + How do I convert a number to a string? + -------------------------------------- + +-For example, to convert the number ``144`` to the string ``'144'``, use the built-in type ++To convert, e.g., the number ``144`` to the string ``'144'``, use the built-in type + constructor :func:`str`. If you want a hexadecimal or octal representation, use + the built-in functions :func:`hex` or :func:`oct`. For fancy formatting, see +-the :ref:`f-strings` and :ref:`formatstrings` sections. +-For example, ``"{:04d}".format(144)`` yields ++the :ref:`f-strings` and :ref:`formatstrings` sections, ++e.g. ``"{:04d}".format(144)`` yields + ``'0144'`` and ``"{:.3f}".format(1.0/3.0)`` yields ``'0.333'``. + + +@@ -909,7 +908,7 @@ + You can't, because strings are immutable. In most situations, you should + simply construct a new string from the various parts you want to assemble + it from. However, if you need an object with the ability to modify in-place +-Unicode data, try using an :class:`io.StringIO` object or the :mod:`array` ++unicode data, try using an :class:`io.StringIO` object or the :mod:`array` + module:: + + >>> import io +@@ -1067,14 +1066,13 @@ + + Also see the specification in the :ref:`language reference `. + +- + Performance + =========== + + My program is too slow. How do I speed it up? + --------------------------------------------- + +-That's a tough one, in general. First, here is a list of things to ++That's a tough one, in general. First, here are a list of things to + remember before diving further: + + * Performance characteristics vary across Python implementations. This FAQ +@@ -1127,7 +1125,6 @@ + The wiki page devoted to `performance tips + `_. + +- + .. _efficient_string_concatenation: + + What is the most efficient way to concatenate many strings together? +@@ -1146,7 +1143,7 @@ + chunks.append(s) + result = ''.join(chunks) + +-(Another reasonably efficient idiom is to use :class:`io.StringIO`.) ++(another reasonably efficient idiom is to use :class:`io.StringIO`) + + To accumulate many :class:`bytes` objects, the recommended idiom is to extend + a :class:`bytearray` object using in-place concatenation (the ``+=`` operator):: +@@ -1156,7 +1153,7 @@ + result += b + + +-Sequences (tuples/lists) ++Sequences (Tuples/Lists) + ======================== + + How do I convert between tuples and lists? +@@ -1220,8 +1217,8 @@ + else: + last = mylist[i] + +-If all elements of the list may be used as set keys (that is, they are all +-:term:`hashable`) this is often faster:: ++If all elements of the list may be used as set keys (i.e. they are all ++:term:`hashable`) this is often faster :: + + mylist = list(set(mylist)) + +@@ -1229,13 +1226,13 @@ + into a list. + + +-How do you remove multiple items from a list? +---------------------------------------------- ++How do you remove multiple items from a list ++-------------------------------------------- + + As with removing duplicates, explicitly iterating in reverse with a + delete condition is one possibility. However, it is easier and faster + to use slice replacement with an implicit or explicit forward iteration. +-Here are three variations:: ++Here are three variations.:: + + mylist[:] = filter(keep_function, mylist) + mylist[:] = (x for x in mylist if keep_condition) +@@ -1257,7 +1254,7 @@ + The ``array`` module also provides methods for creating arrays of fixed types + with compact representations, but they are slower to index than lists. Also + note that `NumPy `_ +-and other third-party packages define array-like structures with ++and other third party packages define array-like structures with + various characteristics as well. + + To get Lisp-style linked lists, you can emulate *cons cells* using tuples:: +@@ -1327,7 +1324,7 @@ + How do I apply a method or function to a sequence of objects? + ------------------------------------------------------------- + +-To call a method or function and accumulate the return values in a list, ++To call a method or function and accumulate the return values is a list, + a :term:`list comprehension` is an elegant solution:: + + result = [obj.method() for obj in mylist] +@@ -1343,7 +1340,6 @@ + for obj in mylist: + function(obj) + +- + .. _faq-augmented-assignment-tuple-error: + + Why does a_tuple[i] += ['item'] raise an exception when the addition works? +@@ -1448,7 +1444,7 @@ + ---------------------------------------------------- + + Merge them into an iterator of tuples, sort the resulting list, and then pick +-out the element you want. ++out the element you want. :: + + >>> list1 = ["what", "I'm", "sorting", "by"] + >>> list2 = ["something", "else", "to", "sort"] +@@ -1508,15 +1504,14 @@ + Use the built-in function :func:`isinstance(obj, cls) `. You can + check if an object + is an instance of any of a number of classes by providing a tuple instead of a +-single class, for example, ``isinstance(obj, (class1, class2, ...))``, and can also +-check whether an object is one of Python's built-in types, for example, ++single class, e.g. ``isinstance(obj, (class1, class2, ...))``, and can also ++check whether an object is one of Python's built-in types, e.g. + ``isinstance(obj, str)`` or ``isinstance(obj, (int, float, complex))``. + + Note that :func:`isinstance` also checks for virtual inheritance from an + :term:`abstract base class`. So, the test will return ``True`` for a + registered class even if hasn't directly or indirectly inherited from it. To +-test for "true inheritance", scan the :term:`method resolution order` (MRO) of +-the class: ++test for "true inheritance", scan the :term:`MRO` of the class: + + .. testcode:: + +@@ -1579,7 +1574,7 @@ + What is delegation? + ------------------- + +-Delegation is an object-oriented technique (also called a design pattern). ++Delegation is an object oriented technique (also called a design pattern). + Let's say you have an object ``x`` and want to change the behaviour of just one + of its methods. You can create a new class that provides a new implementation + of the method you're interested in changing and delegates all other methods to +@@ -1650,7 +1645,7 @@ + + You could assign the base class to an alias and derive from the alias. Then all + you have to change is the value assigned to the alias. Incidentally, this trick +-is also handy if you want to decide dynamically (such as depending on availability ++is also handy if you want to decide dynamically (e.g. depending on availability + of resources) which base class to use. Example:: + + class Base: +@@ -1715,9 +1710,9 @@ + This answer actually applies to all methods, but the question usually comes up + first in the context of constructors. + +-In C++ you'd write: ++In C++ you'd write + +-.. code-block:: c++ ++.. code-block:: c + + class C { + C() { cout << "No arguments\n"; } +@@ -1736,7 +1731,7 @@ + + This is not entirely equivalent, but close enough in practice. + +-You could also try a variable-length argument list, for example:: ++You could also try a variable-length argument list, e.g. :: + + def __init__(self, *args): + ... +@@ -1779,7 +1774,6 @@ + The :ref:`private name mangling specifications ` + for details and special cases. + +- + My class defines __del__ but it is not called when I delete the object. + ----------------------------------------------------------------------- + +@@ -1789,7 +1783,7 @@ + decrements the object's reference count, and if this reaches zero + :meth:`!__del__` is called. + +-If your data structures contain circular links (for example, a tree where each child has ++If your data structures contain circular links (e.g. a tree where each child has + a parent reference and each parent has a list of children) the reference counts + will never go back to zero. Once in a while Python runs an algorithm to detect + such cycles, but the garbage collector might run some time after the last +@@ -1889,9 +1883,9 @@ + constants such as :class:`int` and :class:`str` which aren't guaranteed to be + singletons:: + +- >>> a = 10_000_000 +- >>> b = 5_000_000 +- >>> c = b + 5_000_000 ++ >>> a = 1000 ++ >>> b = 500 ++ >>> c = b + 500 + >>> a is c + False + +@@ -1960,9 +1954,9 @@ + + .. testcode:: + +- import datetime as dt ++ from datetime import date + +- class FirstOfMonthDate(dt.date): ++ class FirstOfMonthDate(date): + "Always choose the first day of the month" + def __new__(cls, year, month, day): + return super().__new__(cls, year, month, 1) +@@ -2005,7 +1999,7 @@ + former stores results at the instance level and the latter at the class + level. + +-The ``cached_property`` approach only works with methods that do not take ++The *cached_property* approach only works with methods that do not take + any arguments. It does not create a reference to the instance. The + cached method result will be kept only as long as the instance is alive. + +@@ -2014,7 +2008,7 @@ + instances accumulate, so too will the accumulated method results. They + can grow without bound. + +-The ``lru_cache`` approach works with methods that have :term:`hashable` ++The *lru_cache* approach works with methods that have :term:`hashable` + arguments. It creates a reference to the instance unless special + efforts are made to pass in weak references. + +@@ -2048,11 +2042,11 @@ + # Depends on the station_id, date, and units. + + The above example assumes that the *station_id* never changes. If the +-relevant instance attributes are mutable, the ``cached_property`` approach ++relevant instance attributes are mutable, the *cached_property* approach + can't be made to work because it cannot detect changes to the + attributes. + +-To make the ``lru_cache`` approach work when the *station_id* is mutable, ++To make the *lru_cache* approach work when the *station_id* is mutable, + the class needs to define the :meth:`~object.__eq__` and :meth:`~object.__hash__` + methods so that the cache can detect relevant attribute updates:: + +@@ -2098,10 +2092,10 @@ + + Unless the :envvar:`PYTHONDONTWRITEBYTECODE` environment variable is set, + creation of a .pyc file is automatic if you're importing a module and Python +-has the ability (permissions, free space, and so on) to create a ``__pycache__`` ++has the ability (permissions, free space, etc...) to create a ``__pycache__`` + subdirectory and write the compiled module to that subdirectory. + +-Running Python on a top-level script is not considered an import and no ++Running Python on a top level script is not considered an import and no + ``.pyc`` will be created. For example, if you have a top-level module + ``foo.py`` that imports another module ``xyz.py``, when you run ``foo`` (by + typing ``python foo.py`` as a shell command), a ``.pyc`` will be created for +@@ -2120,7 +2114,7 @@ + + This will write the ``.pyc`` to a ``__pycache__`` subdirectory in the same + location as ``foo.py`` (or you can override that with the optional parameter +-*cfile*). ++``cfile``). + + You can also automatically compile all files in a directory or directories using + the :mod:`compileall` module. You can do it from the shell prompt by running +@@ -2225,7 +2219,7 @@ + importlib.reload(modname) + + Warning: this technique is not 100% fool-proof. In particular, modules +-containing statements like:: ++containing statements like :: + + from modname import some_objects + +diff --git a/Doc/glossary.rst b/Doc/glossary.rst +index 07a6ee882ea..bdb44009e81 100644 +--- a/Doc/glossary.rst ++++ b/Doc/glossary.rst +@@ -129,14 +129,6 @@ + iterator's :meth:`~object.__anext__` method until it raises a + :exc:`StopAsyncIteration` exception. Introduced by :pep:`492`. + +- atomic operation +- An operation that appears to execute as a single, indivisible step: no +- other thread can observe it half-done, and its effects become visible all +- at once. Python does not guarantee that high-level statements are atomic +- (for example, ``x += 1`` performs multiple bytecode operations and is not +- atomic). Atomicity is only guaranteed where explicitly documented. See +- also :term:`race condition` and :term:`data race`. +- + attribute + A value associated with an object which is usually referenced by name + using dotted expressions. +@@ -270,22 +262,6 @@ + advanced mathematical feature. If you're not aware of a need for them, + it's almost certain you can safely ignore them. + +- concurrency +- The ability of a computer program to perform multiple tasks at the same +- time. Python provides libraries for writing programs that make use of +- different forms of concurrency. :mod:`asyncio` is a library for dealing +- with asynchronous tasks and coroutines. :mod:`threading` provides +- access to operating system threads and :mod:`multiprocessing` to +- operating system processes. Multi-core processors can execute threads and +- processes on different CPU cores at the same time (see +- :term:`parallelism`). +- +- concurrent modification +- When multiple threads modify shared data at the same time. Concurrent +- modification without proper synchronization can cause +- :term:`race conditions `, and might also trigger a +- :term:`data race `, data corruption, or both. +- + context + This term has different meanings depending on where and how it is used. + Some common meanings: +@@ -354,28 +330,6 @@ + tasks (see :mod:`asyncio`) associate each task with a context which + becomes the current context whenever the task starts or resumes execution. + +- data race +- A situation where multiple threads access the same memory location +- concurrently, at least one of the accesses is a write, and the threads +- do not use any synchronization to control their access. Data races +- lead to :term:`non-deterministic` behavior and can cause data corruption. +- Proper use of :term:`locks ` and other :term:`synchronization primitives +- ` prevents data races. Note that data races +- can only happen in native code, but that :term:`native code` might be +- exposed in a Python API. See also :term:`race condition` and +- :term:`thread-safe`. +- +- deadlock +- A situation in which two or more tasks (threads, processes, or coroutines) +- wait indefinitely for each other to release resources or complete actions, +- preventing any from making progress. For example, if thread A holds lock +- 1 and waits for lock 2, while thread B holds lock 2 and waits for lock 1, +- both threads will wait indefinitely. In Python this often arises from +- acquiring multiple locks in conflicting orders or from circular +- join/await dependencies. Deadlocks can be avoided by always acquiring +- multiple :term:`locks ` in a consistent order. See also +- :term:`lock` and :term:`reentrant`. +- + decorator + A function returning another function, usually applied as a function + transformation using the ``@wrapper`` syntax. Common examples for +@@ -665,14 +619,6 @@ + multi-threaded applications and makes it easier to use multi-core CPUs + efficiently. For more details, see :pep:`703`. + +- global state +- Data that is accessible throughout a program, such as module-level +- variables, class variables, or C static variables in :term:`extension modules +- `. In multi-threaded programs, global state shared +- between threads typically requires synchronization to avoid +- :term:`race conditions ` and +- :term:`data races `. +- + hash-based pyc + A bytecode cache file that uses the hash rather than the last-modified + time of the corresponding source file to determine its validity. See +@@ -714,9 +660,7 @@ + tuples. Such an object cannot be altered. A new object has to + be created if a different value has to be stored. They play an important + role in places where a constant hash value is needed, for example as a key +- in a dictionary. Immutable objects are inherently :term:`thread-safe` +- because their state cannot be modified after creation, eliminating concerns +- about improperly synchronized :term:`concurrent modification`. ++ in a dictionary. + + import path + A list of locations (or :term:`path entries `) that are +@@ -806,9 +750,8 @@ + + CPython does not consistently apply the requirement that an iterator + define :meth:`~iterator.__iter__`. +- And also please note that :term:`free-threaded ` +- CPython does not guarantee :term:`thread-safe` behavior of iterator +- operations. ++ And also please note that the free-threading CPython does not guarantee ++ the thread-safety of iterator operations. + + + key function +@@ -824,7 +767,7 @@ + :func:`itertools.groupby`. + + There are several ways to create a key function. For example. the +- :meth:`str.casefold` method can serve as a key function for case insensitive ++ :meth:`str.lower` method can serve as a key function for case insensitive + sorts. Alternatively, a key function can be built from a + :keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also, + :func:`operator.attrgetter`, :func:`operator.itemgetter`, and +@@ -846,11 +789,10 @@ + :keyword:`if` statements. + + In a multi-threaded environment, the LBYL approach can risk introducing a +- :term:`race condition` between "the looking" and "the leaping". For example, +- the code, ``if key in mapping: return mapping[key]`` can fail if another ++ race condition between "the looking" and "the leaping". For example, the ++ code, ``if key in mapping: return mapping[key]`` can fail if another + thread removes *key* from *mapping* after the test, but before the lookup. +- This issue can be solved with :term:`locks ` or by using the +- :term:`EAFP` approach. See also :term:`thread-safe`. ++ This issue can be solved with locks or by using the EAFP approach. + + lexical analyzer + +@@ -869,29 +811,6 @@ + clause is optional. If omitted, all elements in ``range(256)`` are + processed. + +- lock +- A :term:`synchronization primitive` that allows only one thread at a +- time to access a shared resource. A thread must acquire a lock before +- accessing the protected resource and release it afterward. If a thread +- attempts to acquire a lock that is already held by another thread, it +- will block until the lock becomes available. Python's :mod:`threading` +- module provides :class:`~threading.Lock` (a basic lock) and +- :class:`~threading.RLock` (a :term:`reentrant` lock). Locks are used +- to prevent :term:`race conditions ` and ensure +- :term:`thread-safe` access to shared data. Alternative design patterns +- to locks exist such as queues, producer/consumer patterns, and +- thread-local state. See also :term:`deadlock`, and :term:`reentrant`. +- +- lock-free +- An operation that does not acquire any :term:`lock` and uses atomic CPU +- instructions to ensure correctness. Lock-free operations can execute +- concurrently without blocking each other and cannot be blocked by +- operations that hold locks. In :term:`free-threaded ` +- Python, built-in types like :class:`dict` and :class:`list` provide +- lock-free read operations, which means other threads may observe +- intermediate states during multi-step modifications even when those +- modifications hold the :term:`per-object lock`. +- + loader + An object that loads a module. + It must define the :meth:`!exec_module` and :meth:`!create_module` methods +@@ -977,11 +896,8 @@ + See :term:`method resolution order`. + + mutable +- An :term:`object` with state that is allowed to change during the course +- of the program. In multi-threaded programs, mutable objects that are +- shared between threads require careful synchronization to avoid +- :term:`race conditions `. See also :term:`immutable`, +- :term:`thread-safe`, and :term:`concurrent modification`. ++ Mutable objects can change their value but keep their :func:`id`. See ++ also :term:`immutable`. + + named tuple + The term "named tuple" applies to any type or class that inherits from +@@ -1033,13 +949,6 @@ + + See also :term:`module`. + +- native code +- Code that is compiled to machine instructions and runs directly on the +- processor, as opposed to code that is interpreted or runs in a virtual +- machine. In the context of Python, native code typically refers to +- C, C++, Rust or Fortran code in :term:`extension modules ` +- that can be called from Python. See also :term:`extension module`. +- + nested scope + The ability to refer to a variable in an enclosing definition. For + instance, a function defined inside another function can refer to +@@ -1056,15 +965,6 @@ + properties, :meth:`~object.__getattribute__`, class methods, and static + methods. + +- non-deterministic +- Behavior where the outcome of a program can vary between executions with +- the same inputs. In multi-threaded programs, non-deterministic behavior +- often results from :term:`race conditions ` where the +- relative timing or interleaving of threads affects the result. +- Proper synchronization using :term:`locks ` and other +- :term:`synchronization primitives ` helps +- ensure deterministic behavior. +- + object + Any data with state (attributes or value) and defined behavior + (methods). Also the ultimate base class of any :term:`new-style +@@ -1086,16 +986,6 @@ + + See also :term:`regular package` and :term:`namespace package`. + +- parallelism +- Executing multiple operations at the same time (e.g. on multiple CPU +- cores). In Python builds with the +- :term:`global interpreter lock (GIL) `, only one +- thread runs Python bytecode at a time, so taking advantage of multiple +- CPU cores typically involves multiple processes +- (e.g. :mod:`multiprocessing`) or native extensions that release the GIL. +- In :term:`free-threaded ` Python, multiple Python threads +- can run Python code simultaneously on different cores. +- + parameter + A named entity in a :term:`function` (or method) definition that + specifies an :term:`argument` (or in some cases, arguments) that the +@@ -1149,16 +1039,6 @@ + `, the :class:`inspect.Parameter` class, the + :ref:`function` section, and :pep:`362`. + +- per-object lock +- A :term:`lock` associated with an individual object instance rather than +- a global lock shared across all objects. In :term:`free-threaded +- ` Python, built-in types like :class:`dict` and +- :class:`list` use per-object locks to allow concurrent operations on +- different objects while serializing operations on the same object. +- Operations that hold the per-object lock prevent other locking operations +- on the same object from proceeding, but do not block :term:`lock-free` +- operations. +- + path entry + A single location on the :term:`import path` which the :term:`path + based finder` consults to find modules for importing. +@@ -1280,18 +1160,6 @@ + >>> email.mime.text.__name__ + 'email.mime.text' + +- race condition +- A condition of a program where the behavior +- depends on the relative timing or ordering of events, particularly in +- multi-threaded programs. Race conditions can lead to +- :term:`non-deterministic` behavior and bugs that are difficult to +- reproduce. A :term:`data race` is a specific type of race condition +- involving unsynchronized access to shared memory. The :term:`LBYL` +- coding style is particularly susceptible to race conditions in +- multi-threaded code. Using :term:`locks ` and other +- :term:`synchronization primitives ` +- helps prevent race conditions. +- + reference count + The number of references to an object. When the reference count of an + object drops to zero, it is deallocated. Some objects are +@@ -1313,25 +1181,6 @@ + + See also :term:`namespace package`. + +- reentrant +- A property of a function or :term:`lock` that allows it to be called or +- acquired multiple times by the same thread without causing errors or a +- :term:`deadlock`. +- +- For functions, reentrancy means the function can be safely called again +- before a previous invocation has completed, which is important when +- functions may be called recursively or from signal handlers. Thread-unsafe +- functions may be :term:`non-deterministic` if they're called reentrantly in a +- multithreaded program. +- +- For locks, Python's :class:`threading.RLock` (reentrant lock) is +- reentrant, meaning a thread that already holds the lock can acquire it +- again without blocking. In contrast, :class:`threading.Lock` is not +- reentrant - attempting to acquire it twice from the same thread will cause +- a deadlock. +- +- See also :term:`lock` and :term:`deadlock`. +- + REPL + An acronym for the "read–eval–print loop", another name for the + :term:`interactive` interpreter shell. +@@ -1436,18 +1285,6 @@ + + See also :term:`borrowed reference`. + +- synchronization primitive +- A basic building block for coordinating (synchronizing) the execution of +- multiple threads to ensure :term:`thread-safe` access to shared resources. +- Python's :mod:`threading` module provides several synchronization primitives +- including :class:`~threading.Lock`, :class:`~threading.RLock`, +- :class:`~threading.Semaphore`, :class:`~threading.Condition`, +- :class:`~threading.Event`, and :class:`~threading.Barrier`. Additionally, +- the :mod:`queue` module provides multi-producer, multi-consumer queues +- that are especially useful in multithreaded programs. These +- primitives help prevent :term:`race conditions ` and +- coordinate thread execution. See also :term:`lock`. +- + text encoding + A string in Python is a sequence of Unicode code points (in range + ``U+0000``--``U+10FFFF``). To store or transfer a string, it needs to be +@@ -1471,19 +1308,6 @@ + See also :term:`binary file` for a file object able to read and write + :term:`bytes-like objects `. + +- thread-safe +- A module, function, or class that behaves correctly when used by multiple +- threads concurrently. Thread-safe code uses appropriate +- :term:`synchronization primitives ` like +- :term:`locks ` to protect shared mutable state, or is designed +- to avoid shared mutable state entirely. In the +- :term:`free-threaded ` build, built-in types like +- :class:`dict`, :class:`list`, and :class:`set` use internal locking +- to make many operations thread-safe, although thread safety is not +- necessarily guaranteed. Code that is not thread-safe may experience +- :term:`race conditions ` and :term:`data races ` +- when used in multi-threaded programs. +- + token + + A small unit of source code, generated by the +diff --git a/Doc/howto/descriptor.rst b/Doc/howto/descriptor.rst +index 6b2c8a7d142..ba6dd4e0505 100644 +--- a/Doc/howto/descriptor.rst ++++ b/Doc/howto/descriptor.rst +@@ -1636,7 +1636,7 @@ + class Member: + + def __init__(self, name, clsname, offset): +- 'Emulate PyMemberDef in Include/descrobject.h' ++ 'Emulate PyMemberDef in Include/structmember.h' + # Also see descr_new() in Objects/descrobject.c + self.name = name + self.clsname = clsname +diff --git a/Doc/howto/enum.rst b/Doc/howto/enum.rst +index 5260c2ca4ad..7713aede6d5 100644 +--- a/Doc/howto/enum.rst ++++ b/Doc/howto/enum.rst +@@ -105,8 +105,8 @@ + + Now we can find out what today is! Observe:: + +- >>> import datetime as dt +- >>> Weekday.from_date(dt.date.today()) # doctest: +SKIP ++ >>> from datetime import date ++ >>> Weekday.from_date(date.today()) # doctest: +SKIP + + + Of course, if you're reading this on some other day, you'll see that day instead. +@@ -965,16 +965,75 @@ + + + Finer Points +------------- ++^^^^^^^^^^^^ ++ ++Supported ``__dunder__`` names ++"""""""""""""""""""""""""""""" ++ ++:attr:`~enum.EnumType.__members__` is a read-only ordered mapping of ``member_name``:``member`` ++items. It is only available on the class. ++ ++:meth:`~object.__new__`, if specified, must create and return the enum members; it is ++also a very good idea to set the member's :attr:`~Enum._value_` appropriately. Once ++all the members are created it is no longer used. ++ ++ ++Supported ``_sunder_`` names ++"""""""""""""""""""""""""""" + +-Supported ``__dunder__`` and ``_sunder_`` names +-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ++- :attr:`~Enum._name_` -- name of the member ++- :attr:`~Enum._value_` -- value of the member; can be set in ``__new__`` ++- :meth:`~Enum._missing_` -- a lookup function used when a value is not found; ++ may be overridden ++- :attr:`~Enum._ignore_` -- a list of names, either as a :class:`list` or a ++ :class:`str`, that will not be transformed into members, and will be removed ++ from the final class ++- :meth:`~Enum._generate_next_value_` -- used to get an appropriate value for ++ an enum member; may be overridden ++- :meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing ++ member. ++- :meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an ++ existing member. See `MultiValueEnum`_ for an example. + +-The supported ``__dunder__`` and ``_sunder_`` names can be found in the :ref:`Enum API documentation `. ++ .. note:: ++ ++ For standard :class:`Enum` classes the next value chosen is the highest ++ value seen incremented by one. ++ ++ For :class:`Flag` classes the next value chosen will be the next highest ++ power-of-two. ++ ++ .. versionchanged:: 3.13 ++ Prior versions would use the last seen value instead of the highest value. ++ ++.. versionadded:: 3.6 ``_missing_``, ``_order_``, ``_generate_next_value_`` ++.. versionadded:: 3.7 ``_ignore_`` ++.. versionadded:: 3.13 ``_add_alias_``, ``_add_value_alias_`` ++ ++To help keep Python 2 / Python 3 code in sync an :attr:`~Enum._order_` attribute can ++be provided. It will be checked against the actual order of the enumeration ++and raise an error if the two do not match:: ++ ++ >>> class Color(Enum): ++ ... _order_ = 'RED GREEN BLUE' ++ ... RED = 1 ++ ... BLUE = 3 ++ ... GREEN = 2 ++ ... ++ Traceback (most recent call last): ++ ... ++ TypeError: member order does not match _order_: ++ ['RED', 'BLUE', 'GREEN'] ++ ['RED', 'GREEN', 'BLUE'] ++ ++.. note:: ++ ++ In Python 2 code the :attr:`~Enum._order_` attribute is necessary as definition ++ order is lost before it can be recorded. + + + _Private__names +-^^^^^^^^^^^^^^^ ++""""""""""""""" + + :ref:`Private names ` are not converted to enum members, + but remain normal attributes. +@@ -983,7 +1042,7 @@ + + + ``Enum`` member type +-^^^^^^^^^^^^^^^^^^^^ ++"""""""""""""""""""" + + Enum members are instances of their enum class, and are normally accessed as + ``EnumClass.member``. In certain situations, such as writing custom enum +@@ -996,7 +1055,7 @@ + + + Creating members that are mixed with other data types +-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ++""""""""""""""""""""""""""""""""""""""""""""""""""""" + + When subclassing other data types, such as :class:`int` or :class:`str`, with + an :class:`Enum`, all values after the ``=`` are passed to that data type's +@@ -1010,7 +1069,7 @@ + + + Boolean value of ``Enum`` classes and members +-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ++""""""""""""""""""""""""""""""""""""""""""""" + + Enum classes that are mixed with non-:class:`Enum` types (such as + :class:`int`, :class:`str`, etc.) are evaluated according to the mixed-in +@@ -1025,7 +1084,7 @@ + + + ``Enum`` classes with methods +-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ++""""""""""""""""""""""""""""" + + If you give your enum subclass extra methods, like the `Planet`_ + class below, those methods will show up in a :func:`dir` of the member, +@@ -1038,7 +1097,7 @@ + + + Combining members of ``Flag`` +-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ++""""""""""""""""""""""""""""" + + Iterating over a combination of :class:`Flag` members will only return the members that + are comprised of a single bit:: +@@ -1058,7 +1117,7 @@ + + + ``Flag`` and ``IntFlag`` minutia +-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ++"""""""""""""""""""""""""""""""" + + Using the following snippet for our examples:: + +@@ -1419,7 +1478,6 @@ + behaviors as well as disallowing aliases. If the only desired change is + disallowing aliases, the :func:`unique` decorator can be used instead. + +-.. _multi-value-enum: + + MultiValueEnum + ^^^^^^^^^^^^^^^^^ +@@ -1480,8 +1538,8 @@ + + An example to show the :attr:`~Enum._ignore_` attribute in use:: + +- >>> import datetime as dt +- >>> class Period(dt.timedelta, Enum): ++ >>> from datetime import timedelta ++ >>> class Period(timedelta, Enum): + ... "different lengths of time" + ... _ignore_ = 'Period i' + ... Period = vars() +diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst +index b78be3bbfbf..320dcf7eaca 100644 +--- a/Doc/howto/functional.rst ++++ b/Doc/howto/functional.rst +@@ -1042,7 +1042,7 @@ + >>> functools.reduce(operator.concat, []) + Traceback (most recent call last): + ... +- TypeError: reduce() of empty iterable with no initial value ++ TypeError: reduce() of empty sequence with no initial value + >>> functools.reduce(operator.mul, [1, 2, 3], 1) + 6 + >>> functools.reduce(operator.mul, [], 1) +diff --git a/Doc/howto/instrumentation.rst b/Doc/howto/instrumentation.rst +index 06c1ae40da5..b3db1189e5d 100644 +--- a/Doc/howto/instrumentation.rst ++++ b/Doc/howto/instrumentation.rst +@@ -341,84 +341,6 @@ + .. versionadded:: 3.8 + + +-C Entry Points +-^^^^^^^^^^^^^^ +- +-To simplify triggering of DTrace markers, Python's C API comes with a number +-of helper functions that mirror each static marker. On builds of Python without +-DTrace enabled, these do nothing. +- +-In general, it is not necessary to call these yourself, as Python will do +-it for you. +- +-.. list-table:: +- :widths: 50 25 25 +- :header-rows: 1 +- +- * * C API Function +- * Static Marker +- * Notes +- * * .. c:function:: void PyDTrace_LINE(const char *arg0, const char *arg1, int arg2) +- * :c:func:`!line` +- * +- * * .. c:function:: void PyDTrace_FUNCTION_ENTRY(const char *arg0, const char *arg1, int arg2) +- * :c:func:`!function__entry` +- * +- * * .. c:function:: void PyDTrace_FUNCTION_RETURN(const char *arg0, const char *arg1, int arg2) +- * :c:func:`!function__return` +- * +- * * .. c:function:: void PyDTrace_GC_START(int arg0) +- * :c:func:`!gc__start` +- * +- * * .. c:function:: void PyDTrace_GC_DONE(Py_ssize_t arg0) +- * :c:func:`!gc__done` +- * +- * * .. c:function:: void PyDTrace_INSTANCE_NEW_START(int arg0) +- * :c:func:`!instance__new__start` +- * Not used by Python +- * * .. c:function:: void PyDTrace_INSTANCE_NEW_DONE(int arg0) +- * :c:func:`!instance__new__done` +- * Not used by Python +- * * .. c:function:: void PyDTrace_INSTANCE_DELETE_START(int arg0) +- * :c:func:`!instance__delete__start` +- * Not used by Python +- * * .. c:function:: void PyDTrace_INSTANCE_DELETE_DONE(int arg0) +- * :c:func:`!instance__delete__done` +- * Not used by Python +- * * .. c:function:: void PyDTrace_IMPORT_FIND_LOAD_START(const char *arg0) +- * :c:func:`!import__find__load__start` +- * +- * * .. c:function:: void PyDTrace_IMPORT_FIND_LOAD_DONE(const char *arg0, int arg1) +- * :c:func:`!import__find__load__done` +- * +- * * .. c:function:: void PyDTrace_AUDIT(const char *arg0, void *arg1) +- * :c:func:`!audit` +- * +- +- +-C Probing Checks +-^^^^^^^^^^^^^^^^ +- +-.. c:function:: int PyDTrace_LINE_ENABLED(void) +-.. c:function:: int PyDTrace_FUNCTION_ENTRY_ENABLED(void) +-.. c:function:: int PyDTrace_FUNCTION_RETURN_ENABLED(void) +-.. c:function:: int PyDTrace_GC_START_ENABLED(void) +-.. c:function:: int PyDTrace_GC_DONE_ENABLED(void) +-.. c:function:: int PyDTrace_INSTANCE_NEW_START_ENABLED(void) +-.. c:function:: int PyDTrace_INSTANCE_NEW_DONE_ENABLED(void) +-.. c:function:: int PyDTrace_INSTANCE_DELETE_START_ENABLED(void) +-.. c:function:: int PyDTrace_INSTANCE_DELETE_DONE_ENABLED(void) +-.. c:function:: int PyDTrace_IMPORT_FIND_LOAD_START_ENABLED(void) +-.. c:function:: int PyDTrace_IMPORT_FIND_LOAD_DONE_ENABLED(void) +-.. c:function:: int PyDTrace_AUDIT_ENABLED(void) +- +- All calls to ``PyDTrace`` functions must be guarded by a call to one +- of these functions. This allows Python to minimize performance impact +- when probing is disabled. +- +- On builds without DTrace enabled, these functions do nothing and return +- ``0``. +- + SystemTap Tapsets + ----------------- + +diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst +index 444fec031af..c53be94a740 100644 +--- a/Doc/howto/logging-cookbook.rst ++++ b/Doc/howto/logging-cookbook.rst +@@ -229,7 +229,7 @@ + # tell the handler to use this format + console.setFormatter(formatter) + # add the handler to the root logger +- logging.getLogger().addHandler(console) ++ logging.getLogger('').addHandler(console) + + # Now, we can log to the root logger, or any other logger. First the root... + logging.info('Jackdaws love my big sphinx of quartz.') +@@ -637,7 +637,7 @@ + + import logging, logging.handlers + +- rootLogger = logging.getLogger() ++ rootLogger = logging.getLogger('') + rootLogger.setLevel(logging.DEBUG) + socketHandler = logging.handlers.SocketHandler('localhost', + logging.handlers.DEFAULT_TCP_LOGGING_PORT) +@@ -1536,10 +1536,10 @@ + for i in range(10): + executor.submit(worker_process, queue, worker_configurer) + +-Deploying web applications using Gunicorn and uWSGI ++Deploying Web applications using Gunicorn and uWSGI + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +-When deploying web applications using `Gunicorn `_ or `uWSGI ++When deploying Web applications using `Gunicorn `_ or `uWSGI + `_ (or similar), multiple worker + processes are created to handle client requests. In such environments, avoid creating + file-based handlers directly in your web application. Instead, use a +@@ -3606,6 +3606,7 @@ + + .. code-block:: python3 + ++ import datetime + import logging + import random + import sys +@@ -3840,7 +3841,7 @@ + Although :rfc:`5424` dates from 2009, most syslog servers are configured by default to + use the older :rfc:`3164`, which hails from 2001. When ``logging`` was added to Python + in 2003, it supported the earlier (and only existing) protocol at the time. Since +-RFC 5424 came out, as there has not been widespread deployment of it in syslog ++RFC5424 came out, as there has not been widespread deployment of it in syslog + servers, the :class:`~logging.handlers.SysLogHandler` functionality has not been + updated. + +@@ -3848,7 +3849,7 @@ + need to be able to log to a syslog server with support for it, you can do so with a + subclassed handler which looks something like this:: + +- import datetime as dt ++ import datetime + import logging.handlers + import re + import socket +@@ -3866,7 +3867,7 @@ + + def format(self, record): + version = 1 +- asctime = dt.datetime.fromtimestamp(record.created).isoformat() ++ asctime = datetime.datetime.fromtimestamp(record.created).isoformat() + m = self.tz_offset.match(time.strftime('%z')) + has_offset = False + if m and time.timezone: +diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst +index 3a52e7322dc..5a66df722ff 100644 +--- a/Doc/howto/logging.rst ++++ b/Doc/howto/logging.rst +@@ -28,7 +28,7 @@ + ^^^^^^^^^^^^^^^^^^^ + + You can access logging functionality by creating a logger via ``logger = +-logging.getLogger(__name__)``, and then calling the logger's :meth:`~Logger.debug`, ++getLogger(__name__)``, and then calling the logger's :meth:`~Logger.debug`, + :meth:`~Logger.info`, :meth:`~Logger.warning`, :meth:`~Logger.error` and + :meth:`~Logger.critical` methods. To determine when to use logging, and to see + which logger methods to use when, see the table below. It states, for each of a +diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst +index 786442d0cf9..031caea3cec 100644 +--- a/Doc/howto/regex.rst ++++ b/Doc/howto/regex.rst +@@ -1,7 +1,7 @@ + .. _regex-howto: + + **************************** +- Regular expression HOWTO ++ Regular Expression HOWTO + **************************** + + :Author: A.M. Kuchling +@@ -47,7 +47,7 @@ + elaborate regular expression, it will also probably be more understandable. + + +-Simple patterns ++Simple Patterns + =============== + + We'll start by learning about the simplest possible regular expressions. Since +@@ -59,7 +59,7 @@ + to almost any textbook on writing compilers. + + +-Matching characters ++Matching Characters + ------------------- + + Most letters and characters will simply match themselves. For example, the +@@ -159,7 +159,7 @@ + character". + + +-Repeating things ++Repeating Things + ---------------- + + Being able to match varying sets of characters is the first thing regular +@@ -210,7 +210,7 @@ + | | | ``[bcd]*`` is only matching | + | | | ``bc``. | + +------+-----------+---------------------------------+ +-| 7 | ``abcb`` | Try ``b`` again. This time | ++| 6 | ``abcb`` | Try ``b`` again. This time | + | | | the character at the | + | | | current position is ``'b'``, so | + | | | it succeeds. | +@@ -255,7 +255,7 @@ + to read. + + +-Using regular expressions ++Using Regular Expressions + ========================= + + Now that we've looked at some simple regular expressions, how do we actually use +@@ -264,7 +264,7 @@ + matches with them. + + +-Compiling regular expressions ++Compiling Regular Expressions + ----------------------------- + + Regular expressions are compiled into pattern objects, which have +@@ -295,7 +295,7 @@ + + .. _the-backslash-plague: + +-The backslash plague ++The Backslash Plague + -------------------- + + As stated earlier, regular expressions use the backslash character (``'\'``) to +@@ -335,7 +335,7 @@ + + In addition, special escape sequences that are valid in regular expressions, + but not valid as Python string literals, now result in a +-:exc:`SyntaxWarning` and will eventually become a :exc:`SyntaxError`, ++:exc:`DeprecationWarning` and will eventually become a :exc:`SyntaxError`, + which means the sequences will be invalid if raw string notation or escaping + the backslashes isn't used. + +@@ -351,7 +351,7 @@ + +-------------------+------------------+ + + +-Performing matches ++Performing Matches + ------------------ + + Once you have an object representing a compiled regular expression, what do you +@@ -369,10 +369,10 @@ + | | location where this RE matches. | + +------------------+-----------------------------------------------+ + | ``findall()`` | Find all substrings where the RE matches, and | +-| | return them as a list. | ++| | returns them as a list. | + +------------------+-----------------------------------------------+ + | ``finditer()`` | Find all substrings where the RE matches, and | +-| | return them as an :term:`iterator`. | ++| | returns them as an :term:`iterator`. | + +------------------+-----------------------------------------------+ + + :meth:`~re.Pattern.match` and :meth:`~re.Pattern.search` return ``None`` if no match can be found. If +@@ -473,7 +473,7 @@ + The ``r`` prefix, making the literal a raw string literal, is needed in this + example because escape sequences in a normal "cooked" string literal that are + not recognized by Python, as opposed to regular expressions, now result in a +-:exc:`SyntaxWarning` and will eventually become a :exc:`SyntaxError`. See ++:exc:`DeprecationWarning` and will eventually become a :exc:`SyntaxError`. See + :ref:`the-backslash-plague`. + + :meth:`~re.Pattern.findall` has to create the entire list before it can be returned as the +@@ -491,7 +491,7 @@ + (29, 31) + + +-Module-level functions ++Module-Level Functions + ---------------------- + + You don't have to create a pattern object and call its methods; the +@@ -518,7 +518,7 @@ + cache. + + +-Compilation flags ++Compilation Flags + ----------------- + + .. currentmodule:: re +@@ -642,7 +642,7 @@ + whitespace is in a character class or preceded by an unescaped backslash; this + lets you organize and indent the RE more clearly. This flag also lets you put + comments within a RE that will be ignored by the engine; comments are marked by +- a ``'#'`` that's neither in a character class nor preceded by an unescaped ++ a ``'#'`` that's neither in a character class or preceded by an unescaped + backslash. + + For example, here's a RE that uses :const:`re.VERBOSE`; see how much easier it +@@ -669,7 +669,7 @@ + to understand than the version using :const:`re.VERBOSE`. + + +-More pattern power ++More Pattern Power + ================== + + So far we've only covered a part of the features of regular expressions. In +@@ -679,7 +679,7 @@ + + .. _more-metacharacters: + +-More metacharacters ++More Metacharacters + ------------------- + + There are some metacharacters that we haven't covered yet. Most of them will be +@@ -872,7 +872,7 @@ + find out that they're *very* useful when performing string substitutions. + + +-Non-capturing and named groups ++Non-capturing and Named Groups + ------------------------------ + + Elaborate REs may use many groups, both to capture substrings of interest, and +@@ -976,7 +976,7 @@ + 'the the' + + +-Lookahead assertions ++Lookahead Assertions + -------------------- + + Another zero-width assertion is the lookahead assertion. Lookahead assertions +@@ -1058,7 +1058,7 @@ + ``.*[.](?!bat$|exe$)[^.]*$`` + + +-Modifying strings ++Modifying Strings + ================= + + Up to this point, we've simply performed searches against a static string. +@@ -1080,7 +1080,7 @@ + +------------------+-----------------------------------------------+ + + +-Splitting strings ++Splitting Strings + ----------------- + + The :meth:`~re.Pattern.split` method of a pattern splits a string apart +@@ -1134,7 +1134,7 @@ + ['Words', 'words, words.'] + + +-Search and replace ++Search and Replace + ------------------ + + Another common task is to find all the matches for a pattern, and replace them +@@ -1233,7 +1233,7 @@ + pattern string, e.g. ``sub("(?i)b+", "x", "bbbb BBBB")`` returns ``'x x'``. + + +-Common problems ++Common Problems + =============== + + Regular expressions are a powerful tool for some applications, but in some ways +@@ -1241,7 +1241,7 @@ + expect them to. This section will point out some of the most common pitfalls. + + +-Use string methods ++Use String Methods + ------------------ + + Sometimes using the :mod:`re` module is a mistake. If you're matching a fixed +@@ -1307,7 +1307,7 @@ + :func:`re.search` instead. + + +-Greedy versus non-greedy ++Greedy versus Non-Greedy + ------------------------ + + When repeating a regular expression, as in ``a*``, the resulting action is to +@@ -1385,9 +1385,9 @@ + ======== + + Regular expressions are a complicated topic. Did this document help you +-understand them? Were there parts that were unclear, or problems you ++understand them? Were there parts that were unclear, or Problems you + encountered that weren't covered here? If so, please send suggestions for +-improvements to the :ref:`issue tracker `. ++improvements to the author. + + The most complete book on regular expressions is almost certainly Jeffrey + Friedl's Mastering Regular Expressions, published by O'Reilly. Unfortunately, +diff --git a/Doc/includes/diff.py b/Doc/includes/diff.py +index bc4bd58ff3e..001619f5f83 100644 +--- a/Doc/includes/diff.py ++++ b/Doc/includes/diff.py +@@ -1,4 +1,4 @@ +-""" Command-line interface to difflib.py providing diffs in four formats: ++""" Command line interface to difflib.py providing diffs in four formats: + + * ndiff: lists every line and highlights interline changes. + * context: highlights clusters of changes in a before/after format. +@@ -8,11 +8,11 @@ + """ + + import sys, os, difflib, argparse +-import datetime as dt ++from datetime import datetime, timezone + + def file_mtime(path): +- t = dt.datetime.fromtimestamp(os.stat(path).st_mtime, +- dt.timezone.utc) ++ t = datetime.fromtimestamp(os.stat(path).st_mtime, ++ timezone.utc) + return t.astimezone().isoformat() + + def main(): +diff --git a/Doc/includes/tzinfo_examples.py b/Doc/includes/tzinfo_examples.py +index 762b1b62fc8..1fa6e615e46 100644 +--- a/Doc/includes/tzinfo_examples.py ++++ b/Doc/includes/tzinfo_examples.py +@@ -1,70 +1,68 @@ +-import datetime as dt ++from datetime import tzinfo, timedelta, datetime ++ ++ZERO = timedelta(0) ++HOUR = timedelta(hours=1) ++SECOND = timedelta(seconds=1) + + # A class capturing the platform's idea of local time. + # (May result in wrong values on historical times in + # timezones where UTC offset and/or the DST rules had + # changed in the past.) +-import time +- +-ZERO = dt.timedelta(0) +-HOUR = dt.timedelta(hours=1) +-SECOND = dt.timedelta(seconds=1) ++import time as _time + +-STDOFFSET = dt.timedelta(seconds=-time.timezone) +-if time.daylight: +- DSTOFFSET = dt.timedelta(seconds=-time.altzone) ++STDOFFSET = timedelta(seconds = -_time.timezone) ++if _time.daylight: ++ DSTOFFSET = timedelta(seconds = -_time.altzone) + else: + DSTOFFSET = STDOFFSET + + DSTDIFF = DSTOFFSET - STDOFFSET + ++class LocalTimezone(tzinfo): + +-class LocalTimezone(dt.tzinfo): +- +- def fromutc(self, when): +- assert when.tzinfo is self +- stamp = (when - dt.datetime(1970, 1, 1, tzinfo=self)) // SECOND +- args = time.localtime(stamp)[:6] ++ def fromutc(self, dt): ++ assert dt.tzinfo is self ++ stamp = (dt - datetime(1970, 1, 1, tzinfo=self)) // SECOND ++ args = _time.localtime(stamp)[:6] + dst_diff = DSTDIFF // SECOND + # Detect fold +- fold = (args == time.localtime(stamp - dst_diff)) +- return dt.datetime(*args, microsecond=when.microsecond, +- tzinfo=self, fold=fold) ++ fold = (args == _time.localtime(stamp - dst_diff)) ++ return datetime(*args, microsecond=dt.microsecond, ++ tzinfo=self, fold=fold) + +- def utcoffset(self, when): +- if self._isdst(when): ++ def utcoffset(self, dt): ++ if self._isdst(dt): + return DSTOFFSET + else: + return STDOFFSET + +- def dst(self, when): +- if self._isdst(when): ++ def dst(self, dt): ++ if self._isdst(dt): + return DSTDIFF + else: + return ZERO + +- def tzname(self, when): +- return time.tzname[self._isdst(when)] ++ def tzname(self, dt): ++ return _time.tzname[self._isdst(dt)] + +- def _isdst(self, when): +- tt = (when.year, when.month, when.day, +- when.hour, when.minute, when.second, +- when.weekday(), 0, 0) +- stamp = time.mktime(tt) +- tt = time.localtime(stamp) ++ def _isdst(self, dt): ++ tt = (dt.year, dt.month, dt.day, ++ dt.hour, dt.minute, dt.second, ++ dt.weekday(), 0, 0) ++ stamp = _time.mktime(tt) ++ tt = _time.localtime(stamp) + return tt.tm_isdst > 0 + +- + Local = LocalTimezone() + + + # A complete implementation of current DST rules for major US time zones. + +-def first_sunday_on_or_after(when): +- days_to_go = 6 - when.weekday() ++def first_sunday_on_or_after(dt): ++ days_to_go = 6 - dt.weekday() + if days_to_go: +- when += dt.timedelta(days_to_go) +- return when ++ dt += timedelta(days_to_go) ++ return dt + + + # US DST Rules +@@ -77,22 +75,21 @@ + # + # In the US, since 2007, DST starts at 2am (standard time) on the second + # Sunday in March, which is the first Sunday on or after Mar 8. +-DSTSTART_2007 = dt.datetime(1, 3, 8, 2) ++DSTSTART_2007 = datetime(1, 3, 8, 2) + # and ends at 2am (DST time) on the first Sunday of Nov. +-DSTEND_2007 = dt.datetime(1, 11, 1, 2) ++DSTEND_2007 = datetime(1, 11, 1, 2) + # From 1987 to 2006, DST used to start at 2am (standard time) on the first + # Sunday in April and to end at 2am (DST time) on the last + # Sunday of October, which is the first Sunday on or after Oct 25. +-DSTSTART_1987_2006 = dt.datetime(1, 4, 1, 2) +-DSTEND_1987_2006 = dt.datetime(1, 10, 25, 2) ++DSTSTART_1987_2006 = datetime(1, 4, 1, 2) ++DSTEND_1987_2006 = datetime(1, 10, 25, 2) + # From 1967 to 1986, DST used to start at 2am (standard time) on the last + # Sunday in April (the one on or after April 24) and to end at 2am (DST time) + # on the last Sunday of October, which is the first Sunday + # on or after Oct 25. +-DSTSTART_1967_1986 = dt.datetime(1, 4, 24, 2) ++DSTSTART_1967_1986 = datetime(1, 4, 24, 2) + DSTEND_1967_1986 = DSTEND_1987_2006 + +- + def us_dst_range(year): + # Find start and end times for US DST. For years before 1967, return + # start = end for no DST. +@@ -103,17 +100,17 @@ + elif 1966 < year < 1987: + dststart, dstend = DSTSTART_1967_1986, DSTEND_1967_1986 + else: +- return (dt.datetime(year, 1, 1), ) * 2 ++ return (datetime(year, 1, 1), ) * 2 + + start = first_sunday_on_or_after(dststart.replace(year=year)) + end = first_sunday_on_or_after(dstend.replace(year=year)) + return start, end + + +-class USTimeZone(dt.tzinfo): ++class USTimeZone(tzinfo): + + def __init__(self, hours, reprname, stdname, dstname): +- self.stdoffset = dt.timedelta(hours=hours) ++ self.stdoffset = timedelta(hours=hours) + self.reprname = reprname + self.stdname = stdname + self.dstname = dstname +@@ -121,45 +118,45 @@ + def __repr__(self): + return self.reprname + +- def tzname(self, when): +- if self.dst(when): ++ def tzname(self, dt): ++ if self.dst(dt): + return self.dstname + else: + return self.stdname + +- def utcoffset(self, when): +- return self.stdoffset + self.dst(when) ++ def utcoffset(self, dt): ++ return self.stdoffset + self.dst(dt) + +- def dst(self, when): +- if when is None or when.tzinfo is None: ++ def dst(self, dt): ++ if dt is None or dt.tzinfo is None: + # An exception may be sensible here, in one or both cases. + # It depends on how you want to treat them. The default + # fromutc() implementation (called by the default astimezone() +- # implementation) passes a datetime with when.tzinfo is self. ++ # implementation) passes a datetime with dt.tzinfo is self. + return ZERO +- assert when.tzinfo is self +- start, end = us_dst_range(when.year) ++ assert dt.tzinfo is self ++ start, end = us_dst_range(dt.year) + # Can't compare naive to aware objects, so strip the timezone from +- # when first. +- when = when.replace(tzinfo=None) +- if start + HOUR <= when < end - HOUR: ++ # dt first. ++ dt = dt.replace(tzinfo=None) ++ if start + HOUR <= dt < end - HOUR: + # DST is in effect. + return HOUR +- if end - HOUR <= when < end: +- # Fold (an ambiguous hour): use when.fold to disambiguate. +- return ZERO if when.fold else HOUR +- if start <= when < start + HOUR: ++ if end - HOUR <= dt < end: ++ # Fold (an ambiguous hour): use dt.fold to disambiguate. ++ return ZERO if dt.fold else HOUR ++ if start <= dt < start + HOUR: + # Gap (a non-existent hour): reverse the fold rule. +- return HOUR if when.fold else ZERO ++ return HOUR if dt.fold else ZERO + # DST is off. + return ZERO + +- def fromutc(self, when): +- assert when.tzinfo is self +- start, end = us_dst_range(when.year) ++ def fromutc(self, dt): ++ assert dt.tzinfo is self ++ start, end = us_dst_range(dt.year) + start = start.replace(tzinfo=self) + end = end.replace(tzinfo=self) +- std_time = when + self.stdoffset ++ std_time = dt + self.stdoffset + dst_time = std_time + HOUR + if end <= dst_time < end + HOUR: + # Repeated hour +diff --git a/Doc/installing/index.rst b/Doc/installing/index.rst +index c372d9f4741..3a485a43a5a 100644 +--- a/Doc/installing/index.rst ++++ b/Doc/installing/index.rst +@@ -1,14 +1,16 @@ +-.. highlight:: shell ++.. highlight:: none + + .. _installing-index: + + ************************* +-Installing Python modules ++Installing Python Modules + ************************* + ++:Email: distutils-sig@python.org ++ + As a popular open source development project, Python has an active + supporting community of contributors and users that also make their software +-available for other Python developers to use under open-source license terms. ++available for other Python developers to use under open source license terms. + + This allows Python users to share and collaborate effectively, benefiting + from the solutions others have already created to common (and sometimes +@@ -32,24 +34,34 @@ + Key terms + ========= + +-* :program:`pip` is the preferred installer program. It ++* ``pip`` is the preferred installer program. Starting with Python 3.4, it + is included by default with the Python binary installers. + * A *virtual environment* is a semi-isolated Python environment that allows + packages to be installed for use by a particular application, rather than + being installed system wide. +-* ``venv`` is the standard tool for creating virtual environments. +- It defaults to installing :program:`pip` into all created virtual environments. +-* ``virtualenv`` is a third-party alternative (and predecessor) to +- ``venv``. +-* The `Python Package Index (PyPI) `__ is a public ++* ``venv`` is the standard tool for creating virtual environments, and has ++ been part of Python since Python 3.3. Starting with Python 3.4, it ++ defaults to installing ``pip`` into all created virtual environments. ++* ``virtualenv`` is a third party alternative (and predecessor) to ++ ``venv``. It allows virtual environments to be used on versions of ++ Python prior to 3.4, which either don't provide ``venv`` at all, or ++ aren't able to automatically install ``pip`` into created environments. ++* The `Python Package Index `__ is a public + repository of open source licensed packages made available for use by + other Python users. +-* The `Python Packaging Authority ++* the `Python Packaging Authority + `__ is the group of + developers and documentation authors responsible for the maintenance and + evolution of the standard packaging tools and the associated metadata and + file format standards. They maintain a variety of tools, documentation, + and issue trackers on `GitHub `__. ++* ``distutils`` is the original build and distribution system first added to ++ the Python standard library in 1998. While direct use of ``distutils`` is ++ being phased out, it still laid the foundation for the current packaging ++ and distribution infrastructure, and it not only remains part of the ++ standard library, but its name lives on in other ways (such as the name ++ of the mailing list used to coordinate Python packaging standards ++ development). + + .. versionchanged:: 3.5 + The use of ``venv`` is now recommended for creating virtual environments. +@@ -67,7 +79,7 @@ + line. + + The following command will install the latest version of a module and its +-dependencies from PyPI:: ++dependencies from the Python Package Index:: + + python -m pip install SomePackage + +@@ -94,7 +106,7 @@ + + python -m pip install --upgrade SomePackage + +-More information and resources regarding :program:`pip` and its capabilities can be ++More information and resources regarding ``pip`` and its capabilities can be + found in the `Python Packaging User Guide `__. + + Creation of virtual environments is done through the :mod:`venv` module. +@@ -112,6 +124,19 @@ + + These are quick answers or links for some common tasks. + ++... install ``pip`` in versions of Python prior to Python 3.4? ++-------------------------------------------------------------- ++ ++Python only started bundling ``pip`` with Python 3.4. For earlier versions, ++``pip`` needs to be "bootstrapped" as described in the Python Packaging ++User Guide. ++ ++.. seealso:: ++ ++ `Python Packaging User Guide: Requirements for Installing Packages ++ `__ ++ ++ + .. installing-per-user-installation: + + ... install packages just for the current user? +@@ -125,10 +150,10 @@ + --------------------------------------- + + A number of scientific Python packages have complex binary dependencies, and +-aren't currently easy to install using :program:`pip` directly. +-It will often be easier for users to install these packages by ++aren't currently easy to install using ``pip`` directly. At this point in ++time, it will often be easier for users to install these packages by + `other means `__ +-rather than attempting to install them with :program:`pip`. ++rather than attempting to install them with ``pip``. + + .. seealso:: + +@@ -141,18 +166,22 @@ + + On Linux, macOS, and other POSIX systems, use the versioned Python commands + in combination with the ``-m`` switch to run the appropriate copy of +-:program:`pip`:: ++``pip``:: + +- python3 -m pip install SomePackage # default Python 3 +- python3.14 -m pip install SomePackage # specifically Python 3.14 ++ python2 -m pip install SomePackage # default Python 2 ++ python2.7 -m pip install SomePackage # specifically Python 2.7 ++ python3 -m pip install SomePackage # default Python 3 ++ python3.4 -m pip install SomePackage # specifically Python 3.4 + +-Appropriately versioned :program:`pip` commands may also be available. ++Appropriately versioned ``pip`` commands may also be available. + +-On Windows, use the :program:`py` Python launcher in combination with the ``-m`` ++On Windows, use the ``py`` Python launcher in combination with the ``-m`` + switch:: + +- py -3 -m pip install SomePackage # default Python 3 +- py -3.14 -m pip install SomePackage # specifically Python 3.14 ++ py -2 -m pip install SomePackage # default Python 2 ++ py -2.7 -m pip install SomePackage # specifically Python 2.7 ++ py -3 -m pip install SomePackage # default Python 3 ++ py -3.4 -m pip install SomePackage # specifically Python 3.4 + + .. other questions: + +@@ -172,38 +201,39 @@ + of the distribution. Installing into this Python installation requires + root access to the system, and may interfere with the operation of the + system package manager and other components of the system if a component +-is unexpectedly upgraded using :program:`pip`. ++is unexpectedly upgraded using ``pip``. + + On such systems, it is often better to use a virtual environment or a +-per-user installation when installing packages with :program:`pip`. ++per-user installation when installing packages with ``pip``. + + + Pip not installed + ----------------- + +-It is possible that :program:`pip` does not get installed by default. One potential fix is:: ++It is possible that ``pip`` does not get installed by default. One potential fix is:: + + python -m ensurepip --default-pip + +-There are also additional resources for `installing pip +-`__. ++There are also additional resources for `installing pip. ++`__ + + + Installing binary extensions + ---------------------------- + +-Python once relied heavily on source-based distribution, with end ++Python has typically relied heavily on source based distribution, with end + users being expected to compile extension modules from source as part of + the installation process. + +-With the introduction of the binary wheel format, and the +-ability to publish wheels through PyPI, this problem is diminishing, ++With the introduction of support for the binary ``wheel`` format, and the ++ability to publish wheels for at least Windows and macOS through the ++Python Package Index, this problem is expected to diminish over time, + as users are more regularly able to install pre-built extensions rather + than needing to build them themselves. + + Some of the solutions for installing `scientific software + `__ +-that are not yet available as pre-built wheel files may also help with ++that are not yet available as pre-built ``wheel`` files may also help with + obtaining other binary extensions without needing to build them locally. + + .. seealso:: +diff --git a/Doc/library/_thread.rst b/Doc/library/_thread.rst +index 7a2a27aa164..6a66fc4c64b 100644 +--- a/Doc/library/_thread.rst ++++ b/Doc/library/_thread.rst +@@ -36,6 +36,11 @@ + This is now a synonym of the built-in :exc:`RuntimeError`. + + ++.. data:: LockType ++ ++ This is the type of lock objects. ++ ++ + .. function:: start_new_thread(function, args[, kwargs]) + + Start a new thread and return its identifier. The thread executes the +@@ -154,63 +159,55 @@ + .. versionadded:: 3.2 + + +-.. raw:: html +- +- +- +- +- ++Lock objects have the following methods: + +-.. class:: LockType + +- This is the type of lock objects. ++.. method:: lock.acquire(blocking=True, timeout=-1) + +- Lock objects have the following methods: ++ Without any optional argument, this method acquires the lock unconditionally, if ++ necessary waiting until it is released by another thread (only one thread at a ++ time can acquire a lock --- that's their reason for existence). + +- .. method:: acquire(blocking=True, timeout=-1) ++ If the *blocking* argument is present, the action depends on its ++ value: if it is false, the lock is only acquired if it can be acquired ++ immediately without waiting, while if it is true, the lock is acquired ++ unconditionally as above. + +- Without any optional argument, this method acquires the lock unconditionally, if +- necessary waiting until it is released by another thread (only one thread at a +- time can acquire a lock --- that's their reason for existence). ++ If the floating-point *timeout* argument is present and positive, it ++ specifies the maximum wait time in seconds before returning. A negative ++ *timeout* argument specifies an unbounded wait. You cannot specify ++ a *timeout* if *blocking* is false. + +- If the *blocking* argument is present, the action depends on its +- value: if it is false, the lock is only acquired if it can be acquired +- immediately without waiting, while if it is true, the lock is acquired +- unconditionally as above. ++ The return value is ``True`` if the lock is acquired successfully, ++ ``False`` if not. + +- If the floating-point *timeout* argument is present and positive, it +- specifies the maximum wait time in seconds before returning. A negative +- *timeout* argument specifies an unbounded wait. You cannot specify +- a *timeout* if *blocking* is false. ++ .. versionchanged:: 3.2 ++ The *timeout* parameter is new. + +- The return value is ``True`` if the lock is acquired successfully, +- ``False`` if not. ++ .. versionchanged:: 3.2 ++ Lock acquires can now be interrupted by signals on POSIX. + +- .. versionchanged:: 3.2 +- The *timeout* parameter is new. + +- .. versionchanged:: 3.2 +- Lock acquires can now be interrupted by signals on POSIX. ++.. method:: lock.release() + +- .. method:: release() ++ Releases the lock. The lock must have been acquired earlier, but not ++ necessarily by the same thread. + +- Releases the lock. The lock must have been acquired earlier, but not +- necessarily by the same thread. + +- .. method:: locked() ++.. method:: lock.locked() + +- Return the status of the lock: ``True`` if it has been acquired by some thread, +- ``False`` if not. ++ Return the status of the lock: ``True`` if it has been acquired by some thread, ++ ``False`` if not. + +- In addition to these methods, lock objects can also be used via the +- :keyword:`with` statement, e.g.:: ++In addition to these methods, lock objects can also be used via the ++:keyword:`with` statement, e.g.:: + +- import _thread ++ import _thread + +- a_lock = _thread.allocate_lock() ++ a_lock = _thread.allocate_lock() + +- with a_lock: +- print("a_lock is locked while this executes") ++ with a_lock: ++ print("a_lock is locked while this executes") + + **Caveats:** + +diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst +index 5d0a13e0c8f..004e8f82cca 100644 +--- a/Doc/library/argparse.rst ++++ b/Doc/library/argparse.rst +@@ -423,8 +423,9 @@ + + .. note:: + +- Each line is treated as a single argument, so an empty line is read as an +- empty string (``''``). ++ Empty lines are treated as empty strings (``''``), which are allowed as values but ++ not as arguments. Empty lines that are read as arguments will result in an ++ "unrecognized arguments" error. + + :class:`ArgumentParser` uses :term:`filesystem encoding and error handler` + to read the file containing arguments. +@@ -612,8 +613,6 @@ + + * deprecated_ - Whether or not use of the argument is deprecated. + +- The method returns an :class:`Action` object representing the argument. +- + The following sections describe how each of these are used. + + +@@ -952,10 +951,6 @@ + >>> parser.parse_args([]) + Namespace(foo=42) + +-Because ``nargs='*'`` gathers any supplied values into a list, an absent +-positional argument yields an empty list (``[]``). Only a non-``None`` +-*default* overrides this (so ``default=None`` still gives ``[]``). +- + For required_ arguments, the ``default`` value is ignored. For example, this + applies to positional arguments with nargs_ values other than ``?`` or ``*``, + or optional arguments marked as ``required=True``. +@@ -1020,15 +1015,7 @@ + + The :func:`bool` function is not recommended as a type converter. All it does + is convert empty strings to ``False`` and non-empty strings to ``True``. +-This is usually not what is desired:: +- +- >>> parser = argparse.ArgumentParser() +- >>> _ = parser.add_argument('--verbose', type=bool) +- >>> parser.parse_args(['--verbose', 'False']) +- Namespace(verbose=True) +- +-See :class:`BooleanOptionalAction` or ``action='store_true'`` for common +-alternatives. ++This is usually not what is desired. + + In general, the ``type`` keyword is a convenience that should only be used for + simple conversions that can only raise one of the three supported exceptions. +@@ -1269,10 +1256,6 @@ + >>> parser.parse_args('--foo XXX'.split()) + Namespace(bar='XXX') + +-Multiple arguments may share the same ``dest``. By default, the value from the +-last such argument given on the command line wins. Use ``action='append'`` to +-collect values from all of them into a list instead. For conflicting *option +-strings* rather than ``dest`` names, see conflict_handler_. + + .. _deprecated: + +@@ -1590,7 +1573,7 @@ + Other utilities + --------------- + +-Subcommands ++Sub-commands + ^^^^^^^^^^^^ + + .. method:: ArgumentParser.add_subparsers(*, [title], [description], [prog], \ +@@ -1619,7 +1602,7 @@ + * *description* - description for the sub-parser group in help output, by + default ``None`` + +- * *prog* - usage information that will be displayed with subcommand help, ++ * *prog* - usage information that will be displayed with sub-command help, + by default the name of the program and any positional arguments before the + subparser argument + +@@ -1629,7 +1612,7 @@ + * action_ - the basic type of action to be taken when this argument is + encountered at the command line + +- * dest_ - name of the attribute under which subcommand name will be ++ * dest_ - name of the attribute under which sub-command name will be + stored; by default ``None`` and no value is stored + + * required_ - Whether or not a subcommand must be provided, by default +@@ -1668,11 +1651,6 @@ + present, and when the ``b`` command is specified, only the ``foo`` and + ``baz`` attributes are present. + +- If a subparser defines an argument with the same ``dest`` as the parent +- parser, the two share a single namespace attribute, so the parent's value +- won't be retained. Users should give them distinct ``dest`` values to +- keep both. +- + Similarly, when a help message is requested from a subparser, only the help + for that particular parser will be printed. The help message will not + include parent parser or sibling parser messages. (A help message for each +@@ -1840,7 +1818,7 @@ + Namespace(infile=<_io.TextIOWrapper name='' encoding='UTF-8'>) + + .. versionchanged:: 3.4 +- Added the *encoding* and *errors* parameters. ++ Added the *encodings* and *errors* parameters. + + + Argument groups +@@ -1900,9 +1878,6 @@ + Note that any arguments not in your user-defined groups will end up back + in the usual "positional arguments" and "optional arguments" sections. + +- Within each argument group, arguments are displayed in help output in the +- order in which they are added. +- + .. versionchanged:: 3.11 + Calling :meth:`add_argument_group` on an argument group is deprecated. + This feature was never supported and does not always work correctly. +@@ -2100,9 +2075,6 @@ + def convert_arg_line_to_args(self, arg_line): + return arg_line.split() + +- Note that with this override an argument can no longer contain spaces, since +- each space-separated word becomes a separate argument. +- + + Exiting methods + ^^^^^^^^^^^^^^^ +diff --git a/Doc/library/array.rst b/Doc/library/array.rst +index f4e8d8fee71..1f04f697c75 100644 +--- a/Doc/library/array.rst ++++ b/Doc/library/array.rst +@@ -9,7 +9,7 @@ + -------------- + + This module defines an object type which can compactly represent an array of +-basic values: characters, integers, floating-point numbers. Arrays are mutable :term:`sequence` ++basic values: characters, integers, floating-point numbers. Arrays are sequence + types and behave very much like lists, except that the type of objects stored in + them is constrained. The type is specified at object creation time by using a + :dfn:`type code`, which is a single character. The following type codes are +@@ -93,14 +93,12 @@ + otherwise, the initializer's iterator is passed to the :meth:`extend` method + to add initial items to the array. + +- Array objects support the ordinary :ref:`mutable ` :term:`sequence` operations of indexing, slicing, ++ Array objects support the ordinary sequence operations of indexing, slicing, + concatenation, and multiplication. When using slice assignment, the assigned + value must be an array object with the same type code; in all other cases, + :exc:`TypeError` is raised. Array objects also implement the buffer interface, + and may be used wherever :term:`bytes-like objects ` are supported. + +- Arrays are :ref:`generic ` over the type of their contents. +- + .. audit-event:: array.__new__ typecode,initializer array.array + + +@@ -114,9 +112,9 @@ + The length in bytes of one array item in the internal representation. + + +- .. method:: append(value, /) ++ .. method:: append(x) + +- Append a new item with the specified value to the end of the array. ++ Append a new item with value *x* to the end of the array. + + + .. method:: buffer_info() +@@ -146,12 +144,12 @@ + different byte order. + + +- .. method:: count(value, /) ++ .. method:: count(x) + +- Return the number of occurrences of *value* in the array. ++ Return the number of occurrences of *x* in the array. + + +- .. method:: extend(iterable, /) ++ .. method:: extend(iterable) + + Append items from *iterable* to the end of the array. If *iterable* is another + array, it must have *exactly* the same type code; if not, :exc:`TypeError` will +@@ -159,7 +157,7 @@ + must be the right type to be appended to the array. + + +- .. method:: frombytes(buffer, /) ++ .. method:: frombytes(buffer) + + Appends items from the :term:`bytes-like object`, interpreting + its content as an array of machine values (as if it had been read +@@ -169,7 +167,7 @@ + :meth:`!fromstring` is renamed to :meth:`frombytes` for clarity. + + +- .. method:: fromfile(f, n, /) ++ .. method:: fromfile(f, n) + + Read *n* items (as machine values) from the :term:`file object` *f* and append + them to the end of the array. If less than *n* items are available, +@@ -177,13 +175,13 @@ + inserted into the array. + + +- .. method:: fromlist(list, /) ++ .. method:: fromlist(list) + + Append items from the list. This is equivalent to ``for x in list: + a.append(x)`` except that if there is a type error, the array is unchanged. + + +- .. method:: fromunicode(ustr, /) ++ .. method:: fromunicode(s) + + Extends this array with data from the given Unicode string. + The array must have type code ``'u'`` or ``'w'``; otherwise a :exc:`ValueError` is raised. +@@ -191,33 +189,33 @@ + array of some other type. + + +- .. method:: index(value[, start[, stop]]) ++ .. method:: index(x[, start[, stop]]) + + Return the smallest *i* such that *i* is the index of the first occurrence of +- *value* in the array. The optional arguments *start* and *stop* can be +- specified to search for *value* within a subsection of the array. Raise +- :exc:`ValueError` if *value* is not found. ++ *x* in the array. The optional arguments *start* and *stop* can be ++ specified to search for *x* within a subsection of the array. Raise ++ :exc:`ValueError` if *x* is not found. + + .. versionchanged:: 3.10 + Added optional *start* and *stop* parameters. + + +- .. method:: insert(index, value, /) ++ .. method:: insert(i, x) + +- Insert a new item *value* in the array before position *index*. Negative ++ Insert a new item with value *x* in the array before position *i*. Negative + values are treated as being relative to the end of the array. + + +- .. method:: pop(index=-1, /) ++ .. method:: pop([i]) + + Removes the item with the index *i* from the array and returns it. The optional + argument defaults to ``-1``, so that by default the last item is removed and + returned. + + +- .. method:: remove(value, /) ++ .. method:: remove(x) + +- Remove the first occurrence of *value* from the array. ++ Remove the first occurrence of *x* from the array. + + + .. method:: clear() +@@ -242,7 +240,7 @@ + :meth:`!tostring` is renamed to :meth:`tobytes` for clarity. + + +- .. method:: tofile(f, /) ++ .. method:: tofile(f) + + Write all items (as machine values) to the :term:`file object` *f*. + +diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst +index 3e1d9fde3fc..ec6a4a82d6f 100644 +--- a/Doc/library/ast.rst ++++ b/Doc/library/ast.rst +@@ -134,14 +134,6 @@ + Simple indices are represented by their value, extended slices are + represented as tuples. + +-.. versionchanged:: 3.13 +- +- AST node constructors were changed to provide sensible defaults for omitted +- fields: optional fields now default to ``None``, list fields default to an +- empty list, and fields of type :class:`!ast.expr_context` default to +- :class:`Load() `. Previously, omitted attributes would not exist on constructed +- nodes (accessing them raised :exc:`AttributeError`). +- + .. deprecated:: 3.8 + + Old classes :class:`!ast.Num`, :class:`!ast.Str`, :class:`!ast.Bytes`, +@@ -268,25 +260,18 @@ + Literals + ^^^^^^^^ + +-.. class:: Constant(value, kind) ++.. class:: Constant(value) + + A constant value. The ``value`` attribute of the ``Constant`` literal contains the + Python object it represents. The values represented can be instances of :class:`str`, + :class:`bytes`, :class:`int`, :class:`float`, :class:`complex`, and :class:`bool`, + and the constants :data:`None` and :data:`Ellipsis`. + +- The ``kind`` attribute is an optional string. For string literals with a +- ``u`` prefix, ``kind`` is set to ``'u'``. For all other +- constants, ``kind`` is ``None``. +- + .. doctest:: + + >>> print(ast.dump(ast.parse('123', mode='eval'), indent=4)) + Expression( + body=Constant(value=123)) +- >>> print(ast.dump(ast.parse("u'hello'", mode='eval'), indent=4)) +- Expression( +- body=Constant(value='hello', kind='u')) + + + .. class:: FormattedValue(value, conversion, format_spec) +diff --git a/Doc/library/asyncio-dev.rst b/Doc/library/asyncio-dev.rst +index 4a94cbe1d2e..3b43dc7c7ba 100644 +--- a/Doc/library/asyncio-dev.rst ++++ b/Doc/library/asyncio-dev.rst +@@ -246,225 +246,3 @@ + File "../t.py", line 4, in bug + raise Exception("not consumed") + Exception: not consumed +- +- +-Asynchronous generators best practices +-====================================== +- +-Writing correct and efficient asyncio code requires awareness of certain pitfalls. +-This section outlines essential best practices that can save you hours of debugging. +- +- +-Close asynchronous generators explicitly +----------------------------------------- +- +-It is recommended to manually close the +-:term:`asynchronous generator `. If a generator +-exits early - for example, due to an exception raised in the body of +-an ``async for`` loop - its asynchronous cleanup code may run in an +-unexpected context. This can occur after the tasks it depends on have completed, +-or during the event loop shutdown when the async-generator's garbage collection +-hook is called. +- +-To avoid this, explicitly close the generator by calling its +-:meth:`~agen.aclose` method, or use the :func:`contextlib.aclosing` +-context manager:: +- +- import asyncio +- import contextlib +- +- async def gen(): +- yield 1 +- yield 2 +- +- async def func(): +- async with contextlib.aclosing(gen()) as g: +- async for x in g: +- break # Don't iterate until the end +- +- asyncio.run(func()) +- +-As noted above, the cleanup code for these asynchronous generators is deferred. +-The following example demonstrates that the finalization of an asynchronous +-generator can occur in an unexpected order:: +- +- import asyncio +- work_done = False +- +- async def cursor(): +- try: +- yield 1 +- finally: +- assert work_done +- +- async def rows(): +- global work_done +- try: +- yield 2 +- finally: +- await asyncio.sleep(0.1) # immitate some async work +- work_done = True +- +- +- async def main(): +- async for c in cursor(): +- async for r in rows(): +- break +- break +- +- asyncio.run(main()) +- +-For this example, we get the following output:: +- +- unhandled exception during asyncio.run() shutdown +- task: ()> exception=AssertionError()> +- Traceback (most recent call last): +- File "example.py", line 6, in cursor +- yield 1 +- asyncio.exceptions.CancelledError +- +- During handling of the above exception, another exception occurred: +- +- Traceback (most recent call last): +- File "example.py", line 8, in cursor +- assert work_done +- ^^^^^^^^^ +- AssertionError +- +-The ``cursor()`` asynchronous generator was finalized before the ``rows`` +-generator - an unexpected behavior. +- +-The example can be fixed by explicitly closing the +-``cursor`` and ``rows`` async-generators:: +- +- async def main(): +- async with contextlib.aclosing(cursor()) as cursor_gen: +- async for c in cursor_gen: +- async with contextlib.aclosing(rows()) as rows_gen: +- async for r in rows_gen: +- break +- break +- +- +-Create asynchronous generators only when the event loop is running +------------------------------------------------------------------- +- +-It is recommended to create +-:term:`asynchronous generators ` only after +-the event loop has been created. +- +-To ensure that asynchronous generators close reliably, the event loop uses the +-:func:`sys.set_asyncgen_hooks` function to register callback functions. These +-callbacks update the list of running asynchronous generators to keep it in a +-consistent state. +- +-When the :meth:`loop.shutdown_asyncgens() ` +-function is called, the running generators are stopped gracefully and the +-list is cleared. +- +-The asynchronous generator invokes the corresponding system hook during its +-first iteration. At the same time, the generator records that the hook has +-been called and does not call it again. +- +-Therefore, if iteration begins before the event loop is created, +-the event loop will not be able to add the generator to its list of active +-generators because the hooks are set after the generator attempts to call them. +-Consequently, the event loop will not be able to terminate the generator +-if necessary. +- +-Consider the following example:: +- +- import asyncio +- +- async def agenfn(): +- try: +- yield 10 +- finally: +- await asyncio.sleep(0) +- +- +- with asyncio.Runner() as runner: +- agen = agenfn() +- print(runner.run(anext(agen))) +- del agen +- +-Output:: +- +- 10 +- Exception ignored while closing generator : +- Traceback (most recent call last): +- File "example.py", line 13, in +- del agen +- ^^^^ +- RuntimeError: async generator ignored GeneratorExit +- +-This example can be fixed as follows:: +- +- import asyncio +- +- async def agenfn(): +- try: +- yield 10 +- finally: +- await asyncio.sleep(0) +- +- async def main(): +- agen = agenfn() +- print(await anext(agen)) +- del agen +- +- asyncio.run(main()) +- +- +-Avoid concurrent iteration and closure of the same generator +------------------------------------------------------------- +- +-Async generators may be reentered while another +-:meth:`~agen.__anext__` / :meth:`~agen.athrow` / :meth:`~agen.aclose` call is in +-progress. This may lead to an inconsistent state of the async generator and can +-cause errors. +- +-Let's consider the following example:: +- +- import asyncio +- +- async def consumer(): +- for idx in range(100): +- await asyncio.sleep(0) +- message = yield idx +- print('received', message) +- +- async def amain(): +- agenerator = consumer() +- await agenerator.asend(None) +- +- fa = asyncio.create_task(agenerator.asend('A')) +- fb = asyncio.create_task(agenerator.asend('B')) +- await fa +- await fb +- +- asyncio.run(amain()) +- +-Output:: +- +- received A +- Traceback (most recent call last): +- File "test.py", line 38, in +- asyncio.run(amain()) +- ~~~~~~~~~~~^^^^^^^^^ +- File "Lib/asyncio/runners.py", line 204, in run +- return runner.run(main) +- ~~~~~~~~~~^^^^^^ +- File "Lib/asyncio/runners.py", line 127, in run +- return self._loop.run_until_complete(task) +- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^ +- File "Lib/asyncio/base_events.py", line 719, in run_until_complete +- return future.result() +- ~~~~~~~~~~~~~^^ +- File "test.py", line 36, in amain +- await fb +- RuntimeError: anext(): asynchronous generator is already running +- +- +-Therefore, it is recommended to avoid using asynchronous generators in parallel +-tasks or across multiple event loops. +diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst +index 6fdbfce54d0..bb423d3aaa9 100644 +--- a/Doc/library/asyncio-eventloop.rst ++++ b/Doc/library/asyncio-eventloop.rst +@@ -4,7 +4,7 @@ + .. _asyncio-event-loop: + + ========== +-Event loop ++Event Loop + ========== + + **Source code:** :source:`Lib/asyncio/events.py`, +@@ -99,7 +99,7 @@ + + .. _asyncio-event-loop-methods: + +-Event loop methods ++Event Loop Methods + ================== + + Event loops have **low-level** APIs for the following: +@@ -291,9 +291,8 @@ + are called is undefined. + + The optional positional *args* will be passed to the callback when +- it is called. Use :func:`functools.partial` +- :ref:`to pass keyword arguments ` to +- *callback*. ++ it is called. If you want the callback to be called with keyword ++ arguments use :func:`functools.partial`. + + An optional keyword-only *context* argument allows specifying a + custom :class:`contextvars.Context` for the *callback* to run in. +@@ -355,7 +354,7 @@ + The :func:`asyncio.sleep` function. + + +-Creating futures and tasks ++Creating Futures and Tasks + ^^^^^^^^^^^^^^^^^^^^^^^^^^ + + .. method:: loop.create_future() +@@ -946,7 +945,7 @@ + .. versionadded:: 3.7 + + +-TLS upgrade ++TLS Upgrade + ^^^^^^^^^^^ + + .. method:: loop.start_tls(transport, protocol, \ +@@ -1019,8 +1018,8 @@ + .. method:: loop.add_writer(fd, callback, *args) + + Start monitoring the *fd* file descriptor for write availability and +- invoke *callback* with the specified arguments *args* once *fd* is +- available for writing. ++ invoke *callback* with the specified arguments once *fd* is available for ++ writing. + + Any preexisting callback registered for *fd* is cancelled and replaced by + *callback*. +@@ -1293,8 +1292,7 @@ + + .. method:: loop.add_signal_handler(signum, callback, *args) + +- Set *callback* as the handler for the *signum* signal, +- passing *args* as positional arguments. ++ Set *callback* as the handler for the *signum* signal. + + The callback will be invoked by *loop*, along with other queued callbacks + and runnable coroutines of that event loop. Unlike signal handlers +@@ -1329,8 +1327,7 @@ + + .. awaitablemethod:: loop.run_in_executor(executor, func, *args) + +- Arrange for *func* to be called in the specified executor +- passing *args* as positional arguments. ++ Arrange for *func* to be called in the specified executor. + + The *executor* argument should be an :class:`concurrent.futures.Executor` + instance. The default executor is used if *executor* is ``None``. +@@ -1408,7 +1405,7 @@ + :class:`~concurrent.futures.ThreadPoolExecutor`. + + +-Error handling API ++Error Handling API + ^^^^^^^^^^^^^^^^^^ + + Allows customizing how exceptions are handled in the event loop. +@@ -1511,7 +1508,7 @@ + The :ref:`debug mode of asyncio `. + + +-Running subprocesses ++Running Subprocesses + ^^^^^^^^^^^^^^^^^^^^ + + Methods described in this subsections are low-level. In regular +@@ -1649,7 +1646,7 @@ + are going to be used to construct shell commands. + + +-Callback handles ++Callback Handles + ================ + + .. class:: Handle +@@ -1692,7 +1689,7 @@ + .. versionadded:: 3.7 + + +-Server objects ++Server Objects + ============== + + Server objects are created by :meth:`loop.create_server`, +@@ -1835,7 +1832,7 @@ + .. _asyncio-event-loops: + .. _asyncio-event-loop-implementations: + +-Event loop implementations ++Event Loop Implementations + ========================== + + asyncio ships with two different event loop implementations: +@@ -1949,10 +1946,10 @@ + after 5 seconds, and then stops the event loop:: + + import asyncio +- import datetime as dt ++ import datetime + + def display_date(end_time, loop): +- print(dt.datetime.now()) ++ print(datetime.datetime.now()) + if (loop.time() + 1.0) < end_time: + loop.call_later(1, display_date, end_time, loop) + else: +@@ -2033,7 +2030,7 @@ + Set signal handlers for SIGINT and SIGTERM + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +-(This ``signal`` example only works on Unix.) ++(This ``signals`` example only works on Unix.) + + Register handlers for signals :const:`~signal.SIGINT` and :const:`~signal.SIGTERM` + using the :meth:`loop.add_signal_handler` method:: +diff --git a/Doc/library/asyncio-future.rst b/Doc/library/asyncio-future.rst +index cab9f6513b1..1a08afc0222 100644 +--- a/Doc/library/asyncio-future.rst ++++ b/Doc/library/asyncio-future.rst +@@ -100,8 +100,6 @@ + implementations can inject their own optimized implementations + of a Future object. + +- Futures are :ref:`generic ` over the type of their results. +- + .. versionchanged:: 3.7 + Added support for the :mod:`contextvars` module. + +@@ -197,10 +195,6 @@ + Otherwise, change the Future's state to *cancelled*, + schedule the callbacks, and return ``True``. + +- The optional string argument *msg* is passed as the argument to the +- :exc:`CancelledError` exception raised when a cancelled Future +- is awaited. +- + .. versionchanged:: 3.9 + Added the *msg* parameter. + +diff --git a/Doc/library/asyncio-protocol.rst b/Doc/library/asyncio-protocol.rst +index 58f77feb311..5208f14c94a 100644 +--- a/Doc/library/asyncio-protocol.rst ++++ b/Doc/library/asyncio-protocol.rst +@@ -1037,7 +1037,7 @@ + # low-level APIs. + loop = asyncio.get_running_loop() + +- code = 'import datetime as dt; print(dt.datetime.now())' ++ code = 'import datetime; print(datetime.datetime.now())' + exit_future = asyncio.Future(loop=loop) + + # Create the subprocess controlled by DateProtocol; +diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst +index a9735ae8065..d481a1921d5 100644 +--- a/Doc/library/asyncio-queue.rst ++++ b/Doc/library/asyncio-queue.rst +@@ -107,7 +107,7 @@ + The queue can no longer grow. + Future calls to :meth:`~Queue.put` raise :exc:`QueueShutDown`. + Currently blocked callers of :meth:`~Queue.put` will be unblocked +- and will raise :exc:`QueueShutDown` in the formerly awaiting task. ++ and will raise :exc:`QueueShutDown` in the formerly blocked thread. + + If *immediate* is false (the default), the queue can be wound + down normally with :meth:`~Queue.get` calls to extract tasks +diff --git a/Doc/library/asyncio-subprocess.rst b/Doc/library/asyncio-subprocess.rst +index b57ee2a302d..7ac9aa724ce 100644 +--- a/Doc/library/asyncio-subprocess.rst ++++ b/Doc/library/asyncio-subprocess.rst +@@ -311,16 +311,8 @@ + + A ``None`` value indicates that the process has not terminated yet. + +- For processes created with :func:`~asyncio.create_subprocess_exec`, a negative +- value ``-N`` indicates that the child was terminated by signal ``N`` +- (POSIX only). +- +- For processes created with :func:`~asyncio.create_subprocess_shell`, the +- return code reflects the exit status of the shell itself (e.g. ``/bin/sh``), +- which may map signals to codes such as ``128+N``. See the +- documentation of the shell (for example, the Bash manual's Exit Status) +- for details. +- ++ A negative value ``-N`` indicates that the child was terminated ++ by signal ``N`` (POSIX only). + + + .. _asyncio-subprocess-threads: +@@ -371,7 +363,7 @@ + import sys + + async def get_date(): +- code = 'import datetime as dt; print(dt.datetime.now())' ++ code = 'import datetime; print(datetime.datetime.now())' + + # Create the subprocess; redirect the standard output + # into a pipe. +diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst +index 63bb4bae9bd..740f692d6a2 100644 +--- a/Doc/library/asyncio-task.rst ++++ b/Doc/library/asyncio-task.rst +@@ -2,7 +2,7 @@ + + + ==================== +-Coroutines and tasks ++Coroutines and Tasks + ==================== + + This section outlines high-level asyncio APIs to work with coroutines +@@ -231,7 +231,7 @@ + is :meth:`loop.run_in_executor`. + + +-Creating tasks ++Creating Tasks + ============== + + **Source code:** :source:`Lib/asyncio/tasks.py` +@@ -291,7 +291,7 @@ + Added the *context* parameter. + + +-Task cancellation ++Task Cancellation + ================= + + Tasks can easily and safely be cancelled. +@@ -315,7 +315,7 @@ + + .. _taskgroups: + +-Task groups ++Task Groups + =========== + + Task groups combine a task creation API with a convenient +@@ -414,7 +414,7 @@ + Improved handling of simultaneous internal and external cancellations + and correct preservation of cancellation counts. + +-Terminating a task group ++Terminating a Task Group + ------------------------ + + While terminating a task group is not natively supported by the standard +@@ -485,13 +485,13 @@ + for 5 seconds:: + + import asyncio +- import datetime as dt ++ import datetime + + async def display_date(): + loop = asyncio.get_running_loop() + end_time = loop.time() + 5.0 + while True: +- print(dt.datetime.now()) ++ print(datetime.datetime.now()) + if (loop.time() + 1.0) >= end_time: + break + await asyncio.sleep(1) +@@ -506,7 +506,7 @@ + Raises :exc:`ValueError` if *delay* is :data:`~math.nan`. + + +-Running tasks concurrently ++Running Tasks Concurrently + ========================== + + .. awaitablefunction:: gather(*aws, return_exceptions=False) +@@ -544,7 +544,7 @@ + provides stronger safety guarantees than *gather* for scheduling a nesting of subtasks: + if a task (or a subtask, a task scheduled by a task) + raises an exception, *TaskGroup* will, while *gather* will not, +- cancel the remaining scheduled tasks. ++ cancel the remaining scheduled tasks). + + .. _asyncio_example_gather: + +@@ -608,7 +608,7 @@ + + .. _eager-task-factory: + +-Eager task factory ++Eager Task Factory + ================== + + .. function:: eager_task_factory(loop, coro, *, name=None, context=None) +@@ -651,7 +651,7 @@ + .. versionadded:: 3.12 + + +-Shielding from cancellation ++Shielding From Cancellation + =========================== + + .. awaitablefunction:: shield(aw) +@@ -758,9 +758,6 @@ + An :ref:`asynchronous context manager ` + for cancelling overdue coroutines. + +- Prefer using :func:`asyncio.timeout` or :func:`asyncio.timeout_at` +- rather than instantiating :class:`!Timeout` directly. +- + ``when`` should be an absolute time at which the context should time out, + as measured by the event loop's clock: + +@@ -881,7 +878,7 @@ + Raises :exc:`TimeoutError` instead of :exc:`asyncio.TimeoutError`. + + +-Waiting primitives ++Waiting Primitives + ================== + + .. function:: wait(aws, *, timeout=None, return_when=ALL_COMPLETED) +@@ -1001,7 +998,7 @@ + or as a plain :term:`iterator` (previously it was only a plain iterator). + + +-Running in threads ++Running in Threads + ================== + + .. function:: to_thread(func, /, *args, **kwargs) +@@ -1061,7 +1058,7 @@ + .. versionadded:: 3.9 + + +-Scheduling from other threads ++Scheduling From Other Threads + ============================= + + .. function:: run_coroutine_threadsafe(coro, loop) +@@ -1140,7 +1137,7 @@ + + .. _asyncio-task-obj: + +-Task object ++Task Object + =========== + + .. class:: Task(coro, *, loop=None, name=None, context=None, eager_start=False) +@@ -1190,9 +1187,6 @@ + blocks. If the coroutine returns or raises without blocking, the task + will be finished eagerly and will skip scheduling to the event loop. + +- Tasks are :ref:`generic ` over the return type of their wrapped +- coroutines. +- + .. versionchanged:: 3.7 + Added support for the :mod:`contextvars` module. + +diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst +index 0248fa2f45f..529a7242443 100644 +--- a/Doc/library/base64.rst ++++ b/Doc/library/base64.rst +@@ -16,10 +16,8 @@ + This module provides functions for encoding binary data to printable + ASCII characters and decoding such encodings back to binary data. + This includes the :ref:`encodings specified in ` +-:rfc:`4648` (Base64, Base32 and Base16), the :ref:`Base85 encoding +-` specified in `PDF 2.0 +-`_, and non-standard variants +-of Base85 used elsewhere. ++:rfc:`4648` (Base64, Base32 and Base16) ++and the non-standard :ref:`Base85 encodings `. + + There are two interfaces provided by this module. The modern interface + supports encoding :term:`bytes-like objects ` to ASCII +@@ -191,28 +189,19 @@ + Base85 Encodings + ----------------- + +-Base85 encoding is a family of algorithms which represent four bytes +-using five ASCII characters. Originally implemented in the Unix +-``btoa(1)`` utility, a version of it was later adopted by Adobe in the +-PostScript language and is standardized in PDF 2.0 (ISO 32000-2). +-This version, in both its ``btoa`` and PDF variants, is implemented by +-:func:`a85encode`. ++Base85 encoding is not formally specified but rather a de facto standard, ++thus different systems perform the encoding differently. + +-A separate version, using a different output character set, was +-defined as an April Fool's joke in :rfc:`1924` but is now used by Git +-and other software. This version is implemented by :func:`b85encode`. ++The :func:`a85encode` and :func:`b85encode` functions in this module are two implementations of ++the de facto standard. You should call the function with the Base85 ++implementation used by the software you intend to work with. + +-Finally, a third version, using yet another output character set +-designed for safe inclusion in programming language strings, is +-defined by ZeroMQ and implemented here by :func:`z85encode`. ++The two functions present in this module differ in how they handle the following: + +-The functions present in this module differ in how they handle the following: +- +-* Whether to include and expect enclosing ``<~`` and ``~>`` markers. +-* Whether to fold the input into multiple lines. +-* The set of ASCII characters used for encoding. +-* Compact encodings of sequences of spaces and null bytes. +-* The encoding of zero-padding bytes applied to the input. ++* Whether to include enclosing ``<~`` and ``~>`` markers ++* Whether to include newline characters ++* The set of ASCII characters used for encoding ++* Handling of null bytes + + Refer to the documentation of the individual functions for more information. + +@@ -223,22 +212,17 @@ + + *foldspaces* is an optional flag that uses the special short sequence 'y' + instead of 4 consecutive spaces (ASCII 0x20) as supported by 'btoa'. This +- feature is not supported by the standard encoding used in PDF. ++ feature is not supported by the "standard" Ascii85 encoding. + + *wrapcol* controls whether the output should have newline (``b'\n'``) + characters added to it. If this is non-zero, each output line will be + at most this many characters long, excluding the trailing newline. + +- *pad* controls whether zero-padding applied to the end of the input +- is fully retained in the output encoding, as done by ``btoa``, +- producing an exact multiple of 5 bytes of output. This is not part +- of the standard encoding used in PDF, as it does not preserve the +- length of the data. ++ *pad* controls whether the input is padded to a multiple of 4 ++ before encoding. Note that the ``btoa`` implementation always pads. + +- *adobe* controls whether the encoded byte sequence is framed with +- ``<~`` and ``~>``, as in a PostScript base-85 string literal. Note +- that while ASCII85Decode streams in PDF documents *must* be +- terminated with ``~>``, they *must not* use a leading ``<~``. ++ *adobe* controls whether the encoded byte sequence is framed with ``<~`` ++ and ``~>``, which is used by the Adobe implementation. + + .. versionadded:: 3.4 + +@@ -250,14 +234,13 @@ + + *foldspaces* is a flag that specifies whether the 'y' short sequence + should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20). +- This feature is not supported by the standard Ascii85 encoding used in +- PDF and PostScript. ++ This feature is not supported by the "standard" Ascii85 encoding. + +- *adobe* controls whether the ``<~`` and ``~>`` markers are +- present. While the leading ``<~`` is not required, the input must +- end with ``~>``, or a :exc:`ValueError` is raised. ++ *adobe* controls whether the input sequence is in Adobe Ascii85 format ++ (i.e. is framed with <~ and ~>). + +- *ignorechars* should be a byte string containing characters to ignore ++ *ignorechars* should be a :term:`bytes-like object` or ASCII string ++ containing characters to ignore + from the input. This should only contain whitespace characters, and by + default contains all whitespace characters in ASCII. + +@@ -269,11 +252,8 @@ + Encode the :term:`bytes-like object` *b* using base85 (as used in e.g. + git-style binary diffs) and return the encoded :class:`bytes`. + +- The input is padded with ``b'\0'`` so its length is a multiple of 4 +- bytes before encoding. If *pad* is true, all the resulting +- characters are retained in the output, which will always be a +- multiple of 5 bytes, and thus the length of the data may not be +- preserved on decoding. ++ If *pad* is true, the input is padded with ``b'\0'`` so its length is a ++ multiple of 4 bytes before encoding. + + .. versionadded:: 3.4 + +@@ -281,7 +261,8 @@ + .. function:: b85decode(b) + + Decode the base85-encoded :term:`bytes-like object` or ASCII string *b* and +- return the decoded :class:`bytes`. ++ return the decoded :class:`bytes`. Padding is implicitly removed, if ++ necessary. + + .. versionadded:: 3.4 + +@@ -289,12 +270,8 @@ + .. function:: z85encode(s) + + Encode the :term:`bytes-like object` *s* using Z85 (as used in ZeroMQ) +- and return the encoded :class:`bytes`. +- +- The `ZeroMQ specification `_ +- requires the length of Z85-encoded data to be a multiple of 5 +- bytes. To produce compliant data frames, you must pad the input +- data to this function to a multiple of 4 bytes. ++ and return the encoded :class:`bytes`. See `Z85 specification ++ `_ for more information. + + .. versionadded:: 3.13 + +@@ -302,7 +279,8 @@ + .. function:: z85decode(s) + + Decode the Z85-encoded :term:`bytes-like object` or ASCII string *s* and +- return the decoded :class:`bytes`. ++ return the decoded :class:`bytes`. See `Z85 specification ++ `_ for more information. + + .. versionadded:: 3.13 + +@@ -375,11 +353,3 @@ + Section 5.2, "Base64 Content-Transfer-Encoding," provides the definition of the + base64 encoding. + +- `ISO 32000-2 Portable document format - Part 2: PDF 2.0 `_ +- Section 7.4.3, "ASCII85Decode Filter," provides the definition +- of the Ascii85 encoding used in PDF and PostScript, including +- the output character set and the details of data length preservation +- using zero-padding and partial output groups. +- +- `ZeroMQ RFC 32/Z85 `_ +- The "Formal Specification" section provides the character set used in Z85. +diff --git a/Doc/library/bdb.rst b/Doc/library/bdb.rst +index b377b90557c..85df7914a9a 100644 +--- a/Doc/library/bdb.rst ++++ b/Doc/library/bdb.rst +@@ -213,7 +213,7 @@ + Normally derived classes don't override the following methods, but they may + if they want to redefine the definition of stopping and breakpoints. + +- .. method:: is_skipped_module(module_name) ++ .. method:: is_skipped_line(module_name) + + Return ``True`` if *module_name* matches any skip pattern. + +diff --git a/Doc/library/bisect.rst b/Doc/library/bisect.rst +index 5914f5cb91f..d5ec4212c1f 100644 +--- a/Doc/library/bisect.rst ++++ b/Doc/library/bisect.rst +@@ -203,9 +203,9 @@ + based on a set of ordered numeric breakpoints: 90 and up is an 'A', 80 to 89 is + a 'B', and so on:: + +- >>> def grade(score): +- ... i = bisect([60, 70, 80, 90], score) +- ... return "FDCBA"[i] ++ >>> def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'): ++ ... i = bisect(breakpoints, score) ++ ... return grades[i] + ... + >>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]] + ['F', 'A', 'C', 'C', 'B', 'A', 'A'] +diff --git a/Doc/library/calendar.rst b/Doc/library/calendar.rst +index 7e276b94f98..086bfcf2e3a 100644 +--- a/Doc/library/calendar.rst ++++ b/Doc/library/calendar.rst +@@ -56,13 +56,13 @@ + + .. method:: setfirstweekday(firstweekday) + +- Set the first weekday to *firstweekday*, passed as an :class:`int` (0--6). ++ Set the first weekday to *firstweekday*, passed as an :class:`int` (0--6) + + Identical to setting the :attr:`~Calendar.firstweekday` property. + + .. method:: iterweekdays() + +- Return an iterator for the weekday numbers that will be used for one ++ Return an iterator for the week day numbers that will be used for one + week. The first value from the iterator will be the same as the value of + the :attr:`~Calendar.firstweekday` property. + +@@ -88,7 +88,7 @@ + Return an iterator for the month *month* in the year *year* similar to + :meth:`itermonthdates`, but not restricted by the :class:`datetime.date` + range. Days returned will be tuples consisting of a day of the month +- number and a weekday number. ++ number and a week day number. + + + .. method:: itermonthdays3(year, month) +@@ -400,7 +400,7 @@ + + .. function:: monthrange(year, month) + +- Returns weekday of first day of the month and number of days in month, for the ++ Returns weekday of first day of the month and number of days in month, for the + specified *year* and *month*. + + +@@ -438,7 +438,7 @@ + An unrelated but handy function that takes a time tuple such as returned by + the :func:`~time.gmtime` function in the :mod:`time` module, and returns the + corresponding Unix timestamp value, assuming an epoch of 1970, and the POSIX +- encoding. In fact, :func:`time.gmtime` and :func:`timegm` are each other's ++ encoding. In fact, :func:`time.gmtime` and :func:`timegm` are each others' + inverse. + + +@@ -539,14 +539,9 @@ + + .. exception:: IllegalMonthError(month) + +- A subclass of :exc:`ValueError` and :exc:`IndexError`, ++ A subclass of :exc:`ValueError`, + raised when the given month number is outside of the range 1-12 (inclusive). + +- .. versionchanged:: 3.12 +- :exc:`IllegalMonthError` is now also a subclass of +- :exc:`ValueError`. New code should avoid catching +- :exc:`IndexError`. +- + .. attribute:: month + + The invalid month number. +diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst +index 8f3a4768c5e..bbc67ead2ba 100644 +--- a/Doc/library/codecs.rst ++++ b/Doc/library/codecs.rst +@@ -1144,7 +1144,7 @@ + +-----------------+--------------------------------+--------------------------------+ + | cp857 | 857, IBM857 | Turkish | + +-----------------+--------------------------------+--------------------------------+ +-| cp858 | 858, IBM00858 | Western Europe | ++| cp858 | 858, IBM858 | Western Europe | + +-----------------+--------------------------------+--------------------------------+ + | cp860 | 860, IBM860 | Portuguese | + +-----------------+--------------------------------+--------------------------------+ +@@ -1181,7 +1181,7 @@ + | | | | + | | | .. versionadded:: 3.4 | + +-----------------+--------------------------------+--------------------------------+ +-| cp1140 | IBM01140 | Western Europe | ++| cp1140 | ibm1140 | Western Europe | + +-----------------+--------------------------------+--------------------------------+ + | cp1250 | windows-1250 | Central and Eastern Europe | + +-----------------+--------------------------------+--------------------------------+ +diff --git a/Doc/library/collections.abc.rst b/Doc/library/collections.abc.rst +index 213c79cc414..e6daccb91f2 100644 +--- a/Doc/library/collections.abc.rst ++++ b/Doc/library/collections.abc.rst +@@ -459,7 +459,7 @@ + The :class:`Set` mixin provides a :meth:`!_hash` method to compute a hash value + for the set; however, :meth:`~object.__hash__` is not defined because not all sets + are :term:`hashable` or immutable. To add set hashability using mixins, +- inherit from both :class:`Set` and :class:`Hashable`, then define ++ inherit from both :meth:`Set` and :meth:`Hashable`, then define + ``__hash__ = Set._hash``. + + .. seealso:: +diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst +index cfae8104062..fdd31799bd9 100644 +--- a/Doc/library/collections.rst ++++ b/Doc/library/collections.rst +@@ -240,9 +240,7 @@ + [('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631), + ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)] + +-.. class:: Counter(**kwargs) +- Counter(iterable, /, **kwargs) +- Counter(mapping, /, **kwargs) ++.. class:: Counter([iterable-or-mapping]) + + A :class:`Counter` is a :class:`dict` subclass for counting :term:`hashable` objects. + It is a collection where elements are stored as dictionary keys +@@ -292,7 +290,7 @@ + >>> sorted(c.elements()) + ['a', 'a', 'a', 'a', 'b', 'b'] + +- .. method:: most_common(n=None) ++ .. method:: most_common([n]) + + Return a list of the *n* most common elements and their counts from the + most common to the least. If *n* is omitted or ``None``, +@@ -302,9 +300,7 @@ + >>> Counter('abracadabra').most_common(3) + [('a', 5), ('b', 2), ('r', 2)] + +- .. method:: subtract(**kwargs) +- subtract(iterable, /, **kwargs) +- subtract(mapping, /, **kwargs) ++ .. method:: subtract([iterable-or-mapping]) + + Elements are subtracted from an *iterable* or from another *mapping* + (or counter). Like :meth:`dict.update` but subtracts counts instead +@@ -335,9 +331,7 @@ + + This class method is not implemented for :class:`Counter` objects. + +- .. method:: update(**kwargs) +- update(iterable, /, **kwargs) +- update(mapping, /, **kwargs) ++ .. method:: update([iterable-or-mapping]) + + Elements are counted from an *iterable* or added-in from another + *mapping* (or counter). Like :meth:`dict.update` but adds counts +@@ -480,19 +474,17 @@ + Unix. They are also useful for tracking transactions and other pools of data + where only the most recent activity is of interest. + +- Deques are :ref:`generic ` over the type of their contents. +- + + Deque objects support the following methods: + +- .. method:: append(item, /) ++ .. method:: append(x) + +- Add *item* to the right side of the deque. ++ Add *x* to the right side of the deque. + + +- .. method:: appendleft(item, /) ++ .. method:: appendleft(x) + +- Add *item* to the left side of the deque. ++ Add *x* to the left side of the deque. + + + .. method:: clear() +@@ -507,38 +499,38 @@ + .. versionadded:: 3.5 + + +- .. method:: count(value, /) ++ .. method:: count(x) + +- Count the number of deque elements equal to *value*. ++ Count the number of deque elements equal to *x*. + + .. versionadded:: 3.2 + + +- .. method:: extend(iterable, /) ++ .. method:: extend(iterable) + + Extend the right side of the deque by appending elements from the iterable + argument. + + +- .. method:: extendleft(iterable, /) ++ .. method:: extendleft(iterable) + + Extend the left side of the deque by appending elements from *iterable*. + Note, the series of left appends results in reversing the order of + elements in the iterable argument. + + +- .. method:: index(value[, start[, stop]]) ++ .. method:: index(x[, start[, stop]]) + +- Return the position of *value* in the deque (at or after index *start* ++ Return the position of *x* in the deque (at or after index *start* + and before index *stop*). Returns the first match or raises + :exc:`ValueError` if not found. + + .. versionadded:: 3.5 + + +- .. method:: insert(index, value, /) ++ .. method:: insert(i, x) + +- Insert *value* into the deque at position *index*. ++ Insert *x* into the deque at position *i*. + + If the insertion would cause a bounded deque to grow beyond *maxlen*, + an :exc:`IndexError` is raised. +@@ -558,7 +550,7 @@ + elements are present, raises an :exc:`IndexError`. + + +- .. method:: remove(value, /) ++ .. method:: remove(value) + + Remove the first occurrence of *value*. If not found, raises a + :exc:`ValueError`. +@@ -571,7 +563,7 @@ + .. versionadded:: 3.2 + + +- .. method:: rotate(n=1, /) ++ .. method:: rotate(n=1) + + Rotate the deque *n* steps to the right. If *n* is negative, rotate + to the left. +@@ -723,9 +715,7 @@ + :class:`defaultdict` objects + ---------------------------- + +-.. class:: defaultdict(default_factory=None, /, **kwargs) +- defaultdict(default_factory, mapping, /, **kwargs) +- defaultdict(default_factory, iterable, /, **kwargs) ++.. class:: defaultdict(default_factory=None, /, [...]) + + Return a new dictionary-like object. :class:`defaultdict` is a subclass of the + built-in :class:`dict` class. It overrides one method and adds one writable +@@ -737,14 +727,11 @@ + as if they were passed to the :class:`dict` constructor, including keyword + arguments. + +- :class:`!defaultdict`\s are :ref:`generic ` over two types, +- signifying (respectively) the types of the dictionary's keys and values. +- + + :class:`defaultdict` objects support the following method in addition to the + standard :class:`dict` operations: + +- .. method:: __missing__(key, /) ++ .. method:: __missing__(key) + + If the :attr:`default_factory` attribute is ``None``, this raises a + :exc:`KeyError` exception with the *key* as argument. +@@ -950,7 +937,7 @@ + three additional methods and two attributes. To prevent conflicts with + field names, the method and attribute names start with an underscore. + +-.. classmethod:: somenamedtuple._make(iterable, /) ++.. classmethod:: somenamedtuple._make(iterable) + + Class method that makes a new instance from an existing sequence or iterable. + +@@ -1147,9 +1134,7 @@ + * Until Python 3.8, :class:`dict` lacked a :meth:`~object.__reversed__` method. + + +-.. class:: OrderedDict(**kwargs) +- OrderedDict(mapping, /, **kwargs) +- OrderedDict(iterable, /, **kwargs) ++.. class:: OrderedDict([items]) + + Return an instance of a :class:`dict` subclass that has methods + specialized for rearranging dictionary order. +@@ -1229,7 +1214,7 @@ + .. testcode:: + + from collections import OrderedDict +- from time import monotonic ++ from time import time + + class TimeBoundedLRU: + "LRU Cache that invalidates and refreshes old entries." +@@ -1244,10 +1229,10 @@ + if args in self.cache: + self.cache.move_to_end(args) + timestamp, result = self.cache[args] +- if monotonic() - timestamp <= self.maxage: ++ if time() - timestamp <= self.maxage: + return result + result = self.func(*args) +- self.cache[args] = monotonic(), result ++ self.cache[args] = time(), result + if len(self.cache) > self.maxsize: + self.cache.popitem(last=False) + return result +@@ -1330,17 +1315,16 @@ + to work with because the underlying dictionary is accessible as an + attribute. + +-.. class:: UserDict(**kwargs) +- UserDict(mapping, /, **kwargs) +- UserDict(iterable, /, **kwargs) ++.. class:: UserDict([initialdata]) + + Class that simulates a dictionary. The instance's contents are kept in a + regular dictionary, which is accessible via the :attr:`data` attribute of +- :class:`!UserDict` instances. If arguments are provided, they are used to +- initialize :attr:`data`, like a regular dictionary. ++ :class:`UserDict` instances. If *initialdata* is provided, :attr:`data` is ++ initialized with its contents; note that a reference to *initialdata* will not ++ be kept, allowing it to be used for other purposes. + + In addition to supporting the methods and operations of mappings, +- :class:`!UserDict` instances provide the following attribute: ++ :class:`UserDict` instances provide the following attribute: + + .. attribute:: data + +diff --git a/Doc/library/concurrent.futures.rst b/Doc/library/concurrent.futures.rst +index 86d3a9566d9..bf98bf23f01 100644 +--- a/Doc/library/concurrent.futures.rst ++++ b/Doc/library/concurrent.futures.rst +@@ -19,11 +19,6 @@ + :class:`ProcessPoolExecutor`. Both implement the same interface, which is + defined by the abstract :class:`Executor` class. + +-:class:`concurrent.futures.Future` must not be confused with +-:class:`asyncio.Future`, which is designed for use with :mod:`asyncio` +-tasks and coroutines. See the :doc:`asyncio's Future ` +-documentation for a detailed comparison of the two. +- + .. include:: ../includes/wasm-notavail.rst + + Executor Objects +@@ -147,9 +142,7 @@ + print(f.result()) + + executor = ThreadPoolExecutor(max_workers=1) +- future = executor.submit(wait_on_future) +- # Note: calling future.result() would also cause a deadlock because +- # the single worker thread is already waiting for wait_on_future(). ++ executor.submit(wait_on_future) + + + .. class:: ThreadPoolExecutor(max_workers=None, thread_name_prefix='', initializer=None, initargs=()) +@@ -285,11 +278,6 @@ + default in absence of a *mp_context* parameter. This feature is incompatible + with the "fork" start method. + +- .. note:: +- Bugs have been reported when using the *max_tasks_per_child* feature that +- can result in the :class:`ProcessPoolExecutor` hanging in some +- circumstances. Follow its eventual resolution in :gh:`115634`. +- + .. versionchanged:: 3.3 + When one of the worker processes terminates abruptly, a + :exc:`~concurrent.futures.process.BrokenProcessPool` error is now raised. +diff --git a/Doc/library/constants.rst b/Doc/library/constants.rst +index 6aa703ec259..7d17eb8a62a 100644 +--- a/Doc/library/constants.rst ++++ b/Doc/library/constants.rst +@@ -22,7 +22,7 @@ + An object frequently used to represent the absence of a value, as when + default arguments are not passed to a function. Assignments to ``None`` + are illegal and raise a :exc:`SyntaxError`. +- ``None`` is the sole instance of the :class:`~types.NoneType` type. ++ ``None`` is the sole instance of the :data:`~types.NoneType` type. + + + .. data:: NotImplemented +@@ -33,7 +33,7 @@ + the other type; may be returned by the in-place binary special methods + (e.g. :meth:`~object.__imul__`, :meth:`~object.__iand__`, etc.) for the same purpose. + It should not be evaluated in a boolean context. +- :data:`!NotImplemented` is the sole instance of the :class:`types.NotImplementedType` type. ++ :data:`!NotImplemented` is the sole instance of the :data:`types.NotImplementedType` type. + + .. note:: + +@@ -65,7 +65,7 @@ + The same as the ellipsis literal "``...``", an object frequently used to + indicate that something is omitted. Assignment to ``Ellipsis`` is possible, but + assignment to ``...`` raises a :exc:`SyntaxError`. +- ``Ellipsis`` is the sole instance of the :class:`types.EllipsisType` type. ++ ``Ellipsis`` is the sole instance of the :data:`types.EllipsisType` type. + + + .. data:: __debug__ +diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst +index 537c38cc76c..176be4ff333 100644 +--- a/Doc/library/contextlib.rst ++++ b/Doc/library/contextlib.rst +@@ -21,9 +21,9 @@ + .. class:: AbstractContextManager + + An :term:`abstract base class` for classes that implement +- :meth:`~object.__enter__` and :meth:`~object.__exit__`. A default +- implementation for :meth:`~object.__enter__` is provided which returns +- ``self`` while :meth:`~object.__exit__` is an abstract method which by default ++ :meth:`object.__enter__` and :meth:`object.__exit__`. A default ++ implementation for :meth:`object.__enter__` is provided which returns ++ ``self`` while :meth:`object.__exit__` is an abstract method which by default + returns ``None``. See also the definition of :ref:`typecontextmanager`. + + .. versionadded:: 3.6 +@@ -32,9 +32,9 @@ + .. class:: AbstractAsyncContextManager + + An :term:`abstract base class` for classes that implement +- :meth:`~object.__aenter__` and :meth:`~object.__aexit__`. A default +- implementation for :meth:`~object.__aenter__` is provided which returns +- ``self`` while :meth:`~object.__aexit__` is an abstract method which by default ++ :meth:`object.__aenter__` and :meth:`object.__aexit__`. A default ++ implementation for :meth:`object.__aenter__` is provided which returns ++ ``self`` while :meth:`object.__aexit__` is an abstract method which by default + returns ``None``. See also the definition of + :ref:`async-context-managers`. + +@@ -228,7 +228,7 @@ + + .. function:: nullcontext(enter_result=None) + +- Return a context manager that returns *enter_result* from :meth:`~object.__enter__`, but ++ Return a context manager that returns *enter_result* from ``__enter__``, but + otherwise does nothing. It is intended to be used as a stand-in for an + optional context manager, for example:: + +@@ -335,7 +335,7 @@ + For example, the output of :func:`help` normally is sent to *sys.stdout*. + You can capture that output in a string by redirecting the output to an + :class:`io.StringIO` object. The replacement stream is returned from the +- :meth:`~object.__enter__` method and so is available as the target of the ++ ``__enter__`` method and so is available as the target of the + :keyword:`with` statement:: + + with redirect_stdout(io.StringIO()) as f: +@@ -396,8 +396,7 @@ + A base class that enables a context manager to also be used as a decorator. + + Context managers inheriting from ``ContextDecorator`` have to implement +- :meth:`~object.__enter__` and :meth:`~object.__exit__` as normal. +- ``__exit__`` retains its optional ++ ``__enter__`` and ``__exit__`` as normal. ``__exit__`` retains its optional + exception handling even when used as a decorator. + + ``ContextDecorator`` is used by :func:`contextmanager`, so you get this +@@ -698,9 +697,9 @@ + Catching exceptions from ``__enter__`` methods + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +-It is occasionally desirable to catch exceptions from an :meth:`~object.__enter__` ++It is occasionally desirable to catch exceptions from an ``__enter__`` + method implementation, *without* inadvertently catching exceptions from +-the :keyword:`with` statement body or the context manager's :meth:`~object.__exit__` ++the :keyword:`with` statement body or the context manager's ``__exit__`` + method. By using :class:`ExitStack` the steps in the context management + protocol can be separated slightly in order to allow this:: + +diff --git a/Doc/library/contextvars.rst b/Doc/library/contextvars.rst +index c5d22240e57..2b1fb9fdd29 100644 +--- a/Doc/library/contextvars.rst ++++ b/Doc/library/contextvars.rst +@@ -44,9 +44,6 @@ + references to context variables which prevents context variables + from being properly garbage collected. + +- :class:`!ContextVar`\s are :ref:`generic ` over the type of +- their contained value. +- + .. attribute:: ContextVar.name + + The name of the variable. This is a read-only property. +@@ -96,18 +93,13 @@ + # After the reset call the var has no value again, so + # var.get() would raise a LookupError. + +- The same *token* cannot be used twice. +- + + .. class:: Token + + *Token* objects are returned by the :meth:`ContextVar.set` method. + They can be passed to the :meth:`ContextVar.reset` method to revert + the value of the variable to what it was before the corresponding +- *set*. A single token cannot reset a context variable more than once. +- +- Tokens are :ref:`generic ` over the same type as the +- :class:`ContextVar` which created them. ++ *set*. + + .. attribute:: Token.var + +diff --git a/Doc/library/copy.rst b/Doc/library/copy.rst +index 9a0772de509..210ad718800 100644 +--- a/Doc/library/copy.rst ++++ b/Doc/library/copy.rst +@@ -72,13 +72,9 @@ + classes (shallow and deeply), by returning the original object unchanged; this + is compatible with the way these are treated by the :mod:`pickle` module. + +-Shallow copies of many collections can be made using the corresponding +-:meth:`!copy` method (such as :meth:`list.copy`, :meth:`dict.copy` or +-:meth:`set.copy`), and of sequences (such as lists or bytearrays) by making +-a slice of the entire sequence (``sequence[:]``). +-However, these methods and slicing can create an instance of the base type +-when copying an instance of a subclass, whereas :func:`copy.copy` normally +-returns an instance of the same type. ++Shallow copies of dictionaries can be made using :meth:`dict.copy`, and ++of lists by assigning a slice of the entire list, for example, ++``copied_list = original_list[:]``. + + .. index:: pair: module; pickle + +diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst +index 29cf2afd33e..911e7cb2668 100644 +--- a/Doc/library/ctypes.rst ++++ b/Doc/library/ctypes.rst +@@ -14,14 +14,6 @@ + data types, and allows calling functions in DLLs or shared libraries. It can be + used to wrap these libraries in pure Python. + +-.. warning:: +- +- :mod:`!ctypes` provides low-level access to native libraries and the +- process's memory, bypassing Python's safety mechanisms and allowing +- execution of arbitrary native code. +- Incorrect use can corrupt data and objects, reveal sensitive information, +- cause crashes, or otherwise compromise the running process. +- + + .. _ctypes-ctypes-tutorial: + +@@ -198,8 +190,10 @@ + OSError: exception: access violation reading 0x00000020 + >>> + +-The :mod:`faulthandler` module can help debug crashes, +-such as segmentation faults produced by erroneous C library calls. ++There are, however, enough ways to crash Python with :mod:`ctypes`, so you ++should be careful anyway. The :mod:`faulthandler` module can be helpful in ++debugging crashes (e.g. from segmentation faults produced by erroneous C library ++calls). + + ``None``, integers, bytes objects and (unicode) strings are the only native + Python objects that can directly be used as parameters in these function calls. +@@ -1341,9 +1335,6 @@ + (``/sbin/ldconfig``, ``gcc``, ``objdump`` and ``ld``) to find the library file. + It returns the filename of the library file. + +-Note that if the output of these programs does not correspond to the dynamic +-linker used by Python, the result of this function may be misleading. +- + .. versionchanged:: 3.6 + On Linux, the value of the environment variable ``LD_LIBRARY_PATH`` is used + when searching for libraries, if a library cannot be found by any other means. +@@ -2046,8 +2037,6 @@ + + The exact functionality is system dependent. + +- See :ref:`ctypes-finding-shared-libraries` for complete documentation. +- + + .. function:: find_msvcrt() + :module: ctypes.util +@@ -2695,8 +2684,6 @@ + subscript and slice accesses; for slice reads, the resulting object is + *not* itself an :class:`Array`. + +- Arrays are :ref:`generic ` over the type of their elements. +- + + .. attribute:: _length_ + +diff --git a/Doc/library/curses.rst b/Doc/library/curses.rst +index a81534e1dfd..35fa4c415f3 100644 +--- a/Doc/library/curses.rst ++++ b/Doc/library/curses.rst +@@ -4,6 +4,7 @@ + .. module:: curses + :synopsis: An interface to the curses library, providing portable + terminal handling. ++ :platform: Unix + + .. sectionauthor:: Moshe Zadka + .. sectionauthor:: Eric Raymond +@@ -22,8 +23,6 @@ + + .. include:: ../includes/wasm-mobile-notavail.rst + +-.. availability:: Unix. +- + .. note:: + + Whenever the documentation mentions a *character* it can be specified +diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst +index c163516eae9..43efb739a77 100644 +--- a/Doc/library/dataclasses.rst ++++ b/Doc/library/dataclasses.rst +@@ -492,8 +492,7 @@ + .. function:: is_dataclass(obj) + + Return ``True`` if its parameter is a dataclass (including subclasses of a +- dataclass, but not including :ref:`generic aliases `) +- or an instance of one, otherwise return ``False``. ++ dataclass) or an instance of one, otherwise return ``False``. + + If you need to know if a class is an instance of a dataclass (and + not a dataclass itself), then add a further check for ``not +diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst +index 617a2113210..99a979038ad 100644 +--- a/Doc/library/datetime.rst ++++ b/Doc/library/datetime.rst +@@ -65,7 +65,7 @@ + + For applications requiring aware objects, :class:`.datetime` and :class:`.time` + objects have an optional time zone information attribute, :attr:`!tzinfo`, that +-can be set to an instance of a subclass of the abstract :class:`!tzinfo` class. ++can be set to an instance of a subclass of the abstract :class:`tzinfo` class. + These :class:`tzinfo` objects capture information about the offset from UTC + time, the time zone name, and whether daylight saving time is in effect. + +@@ -229,8 +229,8 @@ + *days*, *seconds* and *microseconds* are "merged" and normalized into those + three resulting attributes:: + +- >>> import datetime as dt +- >>> delta = dt.timedelta( ++ >>> from datetime import timedelta ++ >>> delta = timedelta( + ... days=50, + ... seconds=27, + ... microseconds=10, +@@ -243,12 +243,6 @@ + >>> delta + datetime.timedelta(days=64, seconds=29156, microseconds=10) + +- .. tip:: +- ``import datetime as dt`` instead of ``import datetime`` or +- ``from datetime import datetime`` to avoid confusion between the module +- and the class. See `How I Import Python’s datetime Module +- `__. +- + If any argument is a float and there are fractional microseconds, + the fractional microseconds left over from all arguments are + combined and their sum is rounded to the nearest microsecond using +@@ -262,8 +256,8 @@ + Note that normalization of negative values may be surprising at first. For + example:: + +- >>> import datetime as dt +- >>> d = dt.timedelta(microseconds=-1) ++ >>> from datetime import timedelta ++ >>> d = timedelta(microseconds=-1) + >>> (d.days, d.seconds, d.microseconds) + (-1, 86399, 999999) + +@@ -325,8 +319,8 @@ + + .. doctest:: + +- >>> import datetime as dt +- >>> duration = dt.timedelta(seconds=11235813) ++ >>> from datetime import timedelta ++ >>> duration = timedelta(seconds=11235813) + >>> duration.days, duration.seconds + (130, 3813) + >>> duration.total_seconds() +@@ -438,9 +432,9 @@ + + .. versionchanged:: 3.2 + Floor division and true division of a :class:`timedelta` object by another +- :class:`!timedelta` object are now supported, as are remainder operations and ++ :class:`timedelta` object are now supported, as are remainder operations and + the :func:`divmod` function. True division and multiplication of a +- :class:`!timedelta` object by a :class:`float` object are now supported. ++ :class:`timedelta` object by a :class:`float` object are now supported. + + :class:`timedelta` objects support equality and order comparisons. + +@@ -466,10 +460,10 @@ + An additional example of normalization:: + + >>> # Components of another_year add up to exactly 365 days +- >>> import datetime as dt +- >>> year = dt.timedelta(days=365) +- >>> another_year = dt.timedelta(weeks=40, days=84, hours=23, +- ... minutes=50, seconds=600) ++ >>> from datetime import timedelta ++ >>> year = timedelta(days=365) ++ >>> another_year = timedelta(weeks=40, days=84, hours=23, ++ ... minutes=50, seconds=600) + >>> year == another_year + True + >>> year.total_seconds() +@@ -477,8 +471,8 @@ + + Examples of :class:`timedelta` arithmetic:: + +- >>> import datetime as dt +- >>> year = dt.timedelta(days=365) ++ >>> from datetime import timedelta ++ >>> year = timedelta(days=365) + >>> ten_years = 10 * year + >>> ten_years + datetime.timedelta(days=3650) +@@ -565,12 +559,12 @@ + + Examples:: + +- >>> import datetime as dt +- >>> dt.date.fromisoformat('2019-12-04') ++ >>> from datetime import date ++ >>> date.fromisoformat('2019-12-04') + datetime.date(2019, 12, 4) +- >>> dt.date.fromisoformat('20191204') ++ >>> date.fromisoformat('20191204') + datetime.date(2019, 12, 4) +- >>> dt.date.fromisoformat('2021-W01-1') ++ >>> date.fromisoformat('2021-W01-1') + datetime.date(2021, 1, 4) + + .. versionadded:: 3.7 +@@ -670,7 +664,7 @@ + In other words, ``date1 < date2`` if and only if ``date1.toordinal() < + date2.toordinal()``. + +- Order comparison between a :class:`date` object that is not also a ++ Order comparison between a :class:`!date` object that is not also a + :class:`.datetime` instance and a :class:`!datetime` object raises + :exc:`TypeError`. + +@@ -693,8 +687,8 @@ + + Example:: + +- >>> import datetime as dt +- >>> d = dt.date(2002, 12, 31) ++ >>> from datetime import date ++ >>> d = date(2002, 12, 31) + >>> d.replace(day=26) + datetime.date(2002, 12, 26) + +@@ -752,10 +746,10 @@ + For example, 2004 begins on a Thursday, so the first week of ISO year 2004 + begins on Monday, 29 Dec 2003 and ends on Sunday, 4 Jan 2004:: + +- >>> import datetime as dt +- >>> dt.date(2003, 12, 29).isocalendar() ++ >>> from datetime import date ++ >>> date(2003, 12, 29).isocalendar() + datetime.IsoCalendarDate(year=2004, week=1, weekday=1) +- >>> dt.date(2004, 1, 4).isocalendar() ++ >>> date(2004, 1, 4).isocalendar() + datetime.IsoCalendarDate(year=2004, week=1, weekday=7) + + .. versionchanged:: 3.9 +@@ -765,8 +759,8 @@ + + Return a string representing the date in ISO 8601 format, ``YYYY-MM-DD``:: + +- >>> import datetime as dt +- >>> dt.date(2002, 12, 4).isoformat() ++ >>> from datetime import date ++ >>> date(2002, 12, 4).isoformat() + '2002-12-04' + + .. method:: date.__str__() +@@ -778,8 +772,8 @@ + + Return a string representing the date:: + +- >>> import datetime as dt +- >>> dt.date(2002, 12, 4).ctime() ++ >>> from datetime import date ++ >>> date(2002, 12, 4).ctime() + 'Wed Dec 4 00:00:00 2002' + + ``d.ctime()`` is equivalent to:: +@@ -811,13 +805,13 @@ + Example of counting days to an event:: + + >>> import time +- >>> import datetime as dt +- >>> today = dt.date.today() ++ >>> from datetime import date ++ >>> today = date.today() + >>> today + datetime.date(2007, 12, 5) +- >>> today == dt.date.fromtimestamp(time.time()) ++ >>> today == date.fromtimestamp(time.time()) + True +- >>> my_birthday = dt.date(today.year, 6, 24) ++ >>> my_birthday = date(today.year, 6, 24) + >>> if my_birthday < today: + ... my_birthday = my_birthday.replace(year=today.year + 1) + ... +@@ -831,8 +825,8 @@ + + .. doctest:: + +- >>> import datetime as dt +- >>> d = dt.date.fromordinal(730920) # 730920th day after 1. 1. 0001 ++ >>> from datetime import date ++ >>> d = date.fromordinal(730920) # 730920th day after 1. 1. 0001 + >>> d + datetime.date(2002, 3, 11) + +@@ -883,7 +877,7 @@ + + Like a :class:`date` object, :class:`.datetime` assumes the current Gregorian + calendar extended in both directions; like a :class:`.time` object, +-:class:`!datetime` assumes there are exactly 3600\*24 seconds in every day. ++:class:`.datetime` assumes there are exactly 3600\*24 seconds in every day. + + Constructor: + +@@ -1049,7 +1043,7 @@ + are equal to the given :class:`.time` object's. If the *tzinfo* + argument is provided, its value is used to set the :attr:`.tzinfo` attribute + of the result, otherwise the :attr:`~.time.tzinfo` attribute of the *time* argument +- is used. If the *date* argument is a :class:`!datetime` object, its time components ++ is used. If the *date* argument is a :class:`.datetime` object, its time components + and :attr:`.tzinfo` attributes are ignored. + + For any :class:`.datetime` object ``d``, +@@ -1075,24 +1069,24 @@ + + Examples:: + +- >>> import datetime as dt +- >>> dt.datetime.fromisoformat('2011-11-04') ++ >>> from datetime import datetime ++ >>> datetime.fromisoformat('2011-11-04') + datetime.datetime(2011, 11, 4, 0, 0) +- >>> dt.datetime.fromisoformat('20111104') ++ >>> datetime.fromisoformat('20111104') + datetime.datetime(2011, 11, 4, 0, 0) +- >>> dt.datetime.fromisoformat('2011-11-04T00:05:23') ++ >>> datetime.fromisoformat('2011-11-04T00:05:23') + datetime.datetime(2011, 11, 4, 0, 5, 23) +- >>> dt.datetime.fromisoformat('2011-11-04T00:05:23Z') ++ >>> datetime.fromisoformat('2011-11-04T00:05:23Z') + datetime.datetime(2011, 11, 4, 0, 5, 23, tzinfo=datetime.timezone.utc) +- >>> dt.datetime.fromisoformat('20111104T000523') ++ >>> datetime.fromisoformat('20111104T000523') + datetime.datetime(2011, 11, 4, 0, 5, 23) +- >>> dt.datetime.fromisoformat('2011-W01-2T00:05:23.283') ++ >>> datetime.fromisoformat('2011-W01-2T00:05:23.283') + datetime.datetime(2011, 1, 4, 0, 5, 23, 283000) +- >>> dt.datetime.fromisoformat('2011-11-04 00:05:23.283') ++ >>> datetime.fromisoformat('2011-11-04 00:05:23.283') + datetime.datetime(2011, 11, 4, 0, 5, 23, 283000) +- >>> dt.datetime.fromisoformat('2011-11-04 00:05:23.283+00:00') ++ >>> datetime.fromisoformat('2011-11-04 00:05:23.283+00:00') + datetime.datetime(2011, 11, 4, 0, 5, 23, 283000, tzinfo=datetime.timezone.utc) +- >>> dt.datetime.fromisoformat('2011-11-04T00:05:23+04:00') # doctest: +NORMALIZE_WHITESPACE ++ >>> datetime.fromisoformat('2011-11-04T00:05:23+04:00') # doctest: +NORMALIZE_WHITESPACE + datetime.datetime(2011, 11, 4, 0, 5, 23, + tzinfo=datetime.timezone(datetime.timedelta(seconds=14400))) + +@@ -1138,9 +1132,9 @@ + + .. doctest:: + +- >>> import datetime as dt ++ >>> from datetime import datetime + >>> date_string = "02/29" +- >>> when = dt.datetime.strptime(f"{date_string};1984", "%m/%d;%Y") # Avoids leap year bug. ++ >>> when = datetime.strptime(f"{date_string};1984", "%m/%d;%Y") # Avoids leap year bug. + >>> when.strftime("%B %d") # doctest: +SKIP + 'February 29' + +@@ -1253,7 +1247,7 @@ + datetime, and no time zone adjustments are done even if the input is aware. + + (3) +- Subtraction of a :class:`.datetime` from a :class:`!datetime` is defined only if ++ Subtraction of a :class:`.datetime` from a :class:`.datetime` is defined only if + both operands are naive, or if both are aware. If one is aware and the other is + naive, :exc:`TypeError` is raised. + +@@ -1271,7 +1265,7 @@ + :class:`.datetime` objects are equal if they represent the same date + and time, taking into account the time zone. + +- Naive and aware :class:`.datetime` objects are never equal. ++ Naive and aware :class:`!datetime` objects are never equal. + + If both comparands are aware, and have the same :attr:`!tzinfo` attribute, + the :attr:`!tzinfo` and :attr:`~.datetime.fold` attributes are ignored and +@@ -1279,7 +1273,7 @@ + If both comparands are aware and have different :attr:`~.datetime.tzinfo` + attributes, the comparison acts as comparands were first converted to UTC + datetimes except that the implementation never overflows. +- :class:`.datetime` instances in a repeated interval are never equal to ++ :class:`!datetime` instances in a repeated interval are never equal to + :class:`!datetime` instances in other time zone. + + (5) +@@ -1476,7 +1470,7 @@ + + Naive :class:`.datetime` instances are assumed to represent local + time and this method relies on the platform C :c:func:`mktime` +- function to perform the conversion. Since :class:`!datetime` ++ function to perform the conversion. Since :class:`.datetime` + supports wider range of values than :c:func:`mktime` on many + platforms, this method may raise :exc:`OverflowError` or :exc:`OSError` + for times far in the past or far in the future. +@@ -1541,24 +1535,24 @@ + + Examples:: + +- >>> import datetime as dt +- >>> dt.datetime(2019, 5, 18, 15, 17, 8, 132263).isoformat() ++ >>> from datetime import datetime, timezone ++ >>> datetime(2019, 5, 18, 15, 17, 8, 132263).isoformat() + '2019-05-18T15:17:08.132263' +- >>> dt.datetime(2019, 5, 18, 15, 17, tzinfo=dt.timezone.utc).isoformat() ++ >>> datetime(2019, 5, 18, 15, 17, tzinfo=timezone.utc).isoformat() + '2019-05-18T15:17:00+00:00' + + The optional argument *sep* (default ``'T'``) is a one-character separator, + placed between the date and time portions of the result. For example:: + +- >>> import datetime as dt +- >>> class TZ(dt.tzinfo): ++ >>> from datetime import tzinfo, timedelta, datetime ++ >>> class TZ(tzinfo): + ... """A time zone with an arbitrary, constant -06:39 offset.""" +- ... def utcoffset(self, when): +- ... return dt.timedelta(hours=-6, minutes=-39) ++ ... def utcoffset(self, dt): ++ ... return timedelta(hours=-6, minutes=-39) + ... +- >>> dt.datetime(2002, 12, 25, tzinfo=TZ()).isoformat(' ') ++ >>> datetime(2002, 12, 25, tzinfo=TZ()).isoformat(' ') + '2002-12-25 00:00:00-06:39' +- >>> dt.datetime(2009, 11, 27, microsecond=100, tzinfo=TZ()).isoformat() ++ >>> datetime(2009, 11, 27, microsecond=100, tzinfo=TZ()).isoformat() + '2009-11-27T00:00:00.000100-06:39' + + The optional argument *timespec* specifies the number of additional +@@ -1582,11 +1576,11 @@ + :exc:`ValueError` will be raised on an invalid *timespec* argument:: + + +- >>> import datetime as dt +- >>> dt.datetime.now().isoformat(timespec='minutes') # doctest: +SKIP ++ >>> from datetime import datetime ++ >>> datetime.now().isoformat(timespec='minutes') # doctest: +SKIP + '2002-12-25T00:00' +- >>> my_datetime = dt.datetime(2015, 1, 1, 12, 30, 59, 0) +- >>> my_datetime.isoformat(timespec='microseconds') ++ >>> dt = datetime(2015, 1, 1, 12, 30, 59, 0) ++ >>> dt.isoformat(timespec='microseconds') + '2015-01-01T12:30:59.000000' + + .. versionchanged:: 3.6 +@@ -1603,8 +1597,8 @@ + + Return a string representing the date and time:: + +- >>> import datetime as dt +- >>> dt.datetime(2002, 12, 4, 20, 30, 40).ctime() ++ >>> from datetime import datetime ++ >>> datetime(2002, 12, 4, 20, 30, 40).ctime() + 'Wed Dec 4 20:30:40 2002' + + The output string will *not* include time zone information, regardless +@@ -1641,27 +1635,27 @@ + + .. doctest:: + +- >>> import datetime as dt ++ >>> from datetime import datetime, date, time, timezone + + >>> # Using datetime.combine() +- >>> d = dt.date(2005, 7, 14) +- >>> t = dt.time(12, 30) +- >>> dt.datetime.combine(d, t) ++ >>> d = date(2005, 7, 14) ++ >>> t = time(12, 30) ++ >>> datetime.combine(d, t) + datetime.datetime(2005, 7, 14, 12, 30) + + >>> # Using datetime.now() +- >>> dt.datetime.now() # doctest: +SKIP ++ >>> datetime.now() # doctest: +SKIP + datetime.datetime(2007, 12, 6, 16, 29, 43, 79043) # GMT +1 +- >>> dt.datetime.now(dt.timezone.utc) # doctest: +SKIP ++ >>> datetime.now(timezone.utc) # doctest: +SKIP + datetime.datetime(2007, 12, 6, 15, 29, 43, 79060, tzinfo=datetime.timezone.utc) + + >>> # Using datetime.strptime() +- >>> my_datetime = dt.datetime.strptime("21/11/06 16:30", "%d/%m/%y %H:%M") +- >>> my_datetime ++ >>> dt = datetime.strptime("21/11/06 16:30", "%d/%m/%y %H:%M") ++ >>> dt + datetime.datetime(2006, 11, 21, 16, 30) + + >>> # Using datetime.timetuple() to get tuple of all attributes +- >>> tt = my_datetime.timetuple() ++ >>> tt = dt.timetuple() + >>> for it in tt: # doctest: +SKIP + ... print(it) + ... +@@ -1676,7 +1670,7 @@ + -1 # dst - method tzinfo.dst() returned None + + >>> # Date in ISO format +- >>> ic = my_datetime.isocalendar() ++ >>> ic = dt.isocalendar() + >>> for it in ic: # doctest: +SKIP + ... print(it) + ... +@@ -1685,55 +1679,55 @@ + 2 # ISO weekday + + >>> # Formatting a datetime +- >>> my_datetime.strftime("%A, %d. %B %Y %I:%M%p") ++ >>> dt.strftime("%A, %d. %B %Y %I:%M%p") + 'Tuesday, 21. November 2006 04:30PM' +- >>> 'The {1} is {0:%d}, the {2} is {0:%B}, the {3} is {0:%I:%M%p}.'.format(my_datetime, "day", "month", "time") ++ >>> 'The {1} is {0:%d}, the {2} is {0:%B}, the {3} is {0:%I:%M%p}.'.format(dt, "day", "month", "time") + 'The day is 21, the month is November, the time is 04:30PM.' + + The example below defines a :class:`tzinfo` subclass capturing time zone + information for Kabul, Afghanistan, which used +4 UTC until 1945 + and then +4:30 UTC thereafter:: + +- import datetime as dt ++ from datetime import timedelta, datetime, tzinfo, timezone + +- class KabulTz(dt.tzinfo): ++ class KabulTz(tzinfo): + # Kabul used +4 until 1945, when they moved to +4:30 +- UTC_MOVE_DATE = dt.datetime(1944, 12, 31, 20, tzinfo=dt.timezone.utc) ++ UTC_MOVE_DATE = datetime(1944, 12, 31, 20, tzinfo=timezone.utc) + +- def utcoffset(self, when): +- if when.year < 1945: +- return dt.timedelta(hours=4) +- elif (1945, 1, 1, 0, 0) <= when.timetuple()[:5] < (1945, 1, 1, 0, 30): ++ def utcoffset(self, dt): ++ if dt.year < 1945: ++ return timedelta(hours=4) ++ elif (1945, 1, 1, 0, 0) <= dt.timetuple()[:5] < (1945, 1, 1, 0, 30): + # An ambiguous ("imaginary") half-hour range representing + # a 'fold' in time due to the shift from +4 to +4:30. +- # If when falls in the imaginary range, use fold to decide how +- # to resolve. See PEP 495. +- return dt.timedelta(hours=4, minutes=(30 if when.fold else 0)) ++ # If dt falls in the imaginary range, use fold to decide how ++ # to resolve. See PEP495. ++ return timedelta(hours=4, minutes=(30 if dt.fold else 0)) + else: +- return dt.timedelta(hours=4, minutes=30) ++ return timedelta(hours=4, minutes=30) + +- def fromutc(self, when): ++ def fromutc(self, dt): + # Follow same validations as in datetime.tzinfo +- if not isinstance(when, dt.datetime): ++ if not isinstance(dt, datetime): + raise TypeError("fromutc() requires a datetime argument") +- if when.tzinfo is not self: +- raise ValueError("when.tzinfo is not self") ++ if dt.tzinfo is not self: ++ raise ValueError("dt.tzinfo is not self") + + # A custom implementation is required for fromutc as + # the input to this function is a datetime with utc values + # but with a tzinfo set to self. + # See datetime.astimezone or fromtimestamp. +- if when.replace(tzinfo=dt.timezone.utc) >= self.UTC_MOVE_DATE: +- return when + dt.timedelta(hours=4, minutes=30) ++ if dt.replace(tzinfo=timezone.utc) >= self.UTC_MOVE_DATE: ++ return dt + timedelta(hours=4, minutes=30) + else: +- return when + dt.timedelta(hours=4) ++ return dt + timedelta(hours=4) + +- def dst(self, when): ++ def dst(self, dt): + # Kabul does not observe daylight saving time. +- return dt.timedelta(0) ++ return timedelta(0) + +- def tzname(self, when): +- if when >= self.UTC_MOVE_DATE: ++ def tzname(self, dt): ++ if dt >= self.UTC_MOVE_DATE: + return "+04:30" + return "+04" + +@@ -1742,17 +1736,17 @@ + >>> tz1 = KabulTz() + + >>> # Datetime before the change +- >>> dt1 = dt.datetime(1900, 11, 21, 16, 30, tzinfo=tz1) ++ >>> dt1 = datetime(1900, 11, 21, 16, 30, tzinfo=tz1) + >>> print(dt1.utcoffset()) + 4:00:00 + + >>> # Datetime after the change +- >>> dt2 = dt.datetime(2006, 6, 14, 13, 0, tzinfo=tz1) ++ >>> dt2 = datetime(2006, 6, 14, 13, 0, tzinfo=tz1) + >>> print(dt2.utcoffset()) + 4:30:00 + + >>> # Convert datetime to another time zone +- >>> dt3 = dt2.astimezone(dt.timezone.utc) ++ >>> dt3 = dt2.astimezone(timezone.utc) + >>> dt3 + datetime.datetime(2006, 6, 14, 8, 30, tzinfo=datetime.timezone.utc) + >>> dt2 +@@ -1885,22 +1879,22 @@ + + .. doctest:: + +- >>> import datetime as dt +- >>> dt.time.fromisoformat('04:23:01') ++ >>> from datetime import time ++ >>> time.fromisoformat('04:23:01') + datetime.time(4, 23, 1) +- >>> dt.time.fromisoformat('T04:23:01') ++ >>> time.fromisoformat('T04:23:01') + datetime.time(4, 23, 1) +- >>> dt.time.fromisoformat('T042301') ++ >>> time.fromisoformat('T042301') + datetime.time(4, 23, 1) +- >>> dt.time.fromisoformat('04:23:01.000384') ++ >>> time.fromisoformat('04:23:01.000384') + datetime.time(4, 23, 1, 384) +- >>> dt.time.fromisoformat('04:23:01,000384') ++ >>> time.fromisoformat('04:23:01,000384') + datetime.time(4, 23, 1, 384) +- >>> dt.time.fromisoformat('04:23:01+04:00') ++ >>> time.fromisoformat('04:23:01+04:00') + datetime.time(4, 23, 1, tzinfo=datetime.timezone(datetime.timedelta(seconds=14400))) +- >>> dt.time.fromisoformat('04:23:01Z') ++ >>> time.fromisoformat('04:23:01Z') + datetime.time(4, 23, 1, tzinfo=datetime.timezone.utc) +- >>> dt.time.fromisoformat('04:23:01+00:00') ++ >>> time.fromisoformat('04:23:01+00:00') + datetime.time(4, 23, 1, tzinfo=datetime.timezone.utc) + + +@@ -1917,7 +1911,7 @@ + + Return a new :class:`.time` with the same values, but with specified + parameters updated. Note that ``tzinfo=None`` can be specified to create a +- naive :class:`!time` from an aware :class:`!time`, without conversion of the ++ naive :class:`.time` from an aware :class:`.time`, without conversion of the + time data. + + :class:`.time` objects are also supported by generic function +@@ -1958,13 +1952,13 @@ + + Example:: + +- >>> import datetime as dt +- >>> dt.time(hour=12, minute=34, second=56, microsecond=123456).isoformat(timespec='minutes') ++ >>> from datetime import time ++ >>> time(hour=12, minute=34, second=56, microsecond=123456).isoformat(timespec='minutes') + '12:34' +- >>> my_time = dt.time(hour=12, minute=34, second=56, microsecond=0) +- >>> my_time.isoformat(timespec='microseconds') ++ >>> dt = time(hour=12, minute=34, second=56, microsecond=0) ++ >>> dt.isoformat(timespec='microseconds') + '12:34:56.000000' +- >>> my_time.isoformat(timespec='auto') ++ >>> dt.isoformat(timespec='auto') + '12:34:56' + + .. versionchanged:: 3.6 +@@ -2020,18 +2014,18 @@ + + Examples of working with a :class:`.time` object:: + +- >>> import datetime as dt +- >>> class TZ1(dt.tzinfo): +- ... def utcoffset(self, when): +- ... return dt.timedelta(hours=1) +- ... def dst(self, when): +- ... return dt.timedelta(0) +- ... def tzname(self, when): ++ >>> from datetime import time, tzinfo, timedelta ++ >>> class TZ1(tzinfo): ++ ... def utcoffset(self, dt): ++ ... return timedelta(hours=1) ++ ... def dst(self, dt): ++ ... return timedelta(0) ++ ... def tzname(self,dt): + ... return "+01:00" + ... def __repr__(self): + ... return f"{self.__class__.__name__}()" + ... +- >>> t = dt.time(12, 10, 30, tzinfo=TZ1()) ++ >>> t = time(12, 10, 30, tzinfo=TZ1()) + >>> t + datetime.time(12, 10, 30, tzinfo=TZ1()) + >>> t.isoformat() +@@ -2059,14 +2053,14 @@ + + An instance of (a concrete subclass of) :class:`tzinfo` can be passed to the + constructors for :class:`.datetime` and :class:`.time` objects. The latter objects +- view their attributes as being in local time, and the :class:`!tzinfo` object ++ view their attributes as being in local time, and the :class:`tzinfo` object + supports methods revealing offset of local time from UTC, the name of the time + zone, and DST offset, all relative to a date or time object passed to them. + + You need to derive a concrete subclass, and (at least) + supply implementations of the standard :class:`tzinfo` methods needed by the + :class:`.datetime` methods you use. The :mod:`!datetime` module provides +- :class:`timezone`, a simple concrete subclass of :class:`!tzinfo` which can ++ :class:`timezone`, a simple concrete subclass of :class:`tzinfo` which can + represent time zones with fixed offset from UTC such as UTC itself or North + American EST and EDT. + +@@ -2129,35 +2123,31 @@ + ``tz.utcoffset(dt) - tz.dst(dt)`` + + must return the same result for every :class:`.datetime` *dt* with ``dt.tzinfo == +- tz``. For sane :class:`!tzinfo` subclasses, this expression yields the time ++ tz``. For sane :class:`tzinfo` subclasses, this expression yields the time + zone's "standard offset", which should not depend on the date or the time, but + only on geographic location. The implementation of :meth:`datetime.astimezone` + relies on this, but cannot detect violations; it's the programmer's +- responsibility to ensure it. If a :class:`!tzinfo` subclass cannot guarantee ++ responsibility to ensure it. If a :class:`tzinfo` subclass cannot guarantee + this, it may be able to override the default implementation of + :meth:`tzinfo.fromutc` to work correctly with :meth:`~.datetime.astimezone` regardless. + + Most implementations of :meth:`dst` will probably look like one of these two:: + +- import datetime as dt +- +- def dst(self, when): ++ def dst(self, dt): + # a fixed-offset class: doesn't account for DST +- return dt.timedelta(0) ++ return timedelta(0) + + or:: + +- import datetime as dt +- +- def dst(self, when): ++ def dst(self, dt): + # Code to set dston and dstoff to the time zone's DST +- # transition times based on the input when.year, and expressed ++ # transition times based on the input dt.year, and expressed + # in standard local time. + +- if dston <= when.replace(tzinfo=None) < dstoff: +- return dt.timedelta(hours=1) ++ if dston <= dt.replace(tzinfo=None) < dstoff: ++ return timedelta(hours=1) + else: +- return dt.timedelta(0) ++ return timedelta(0) + + The default implementation of :meth:`dst` raises :exc:`NotImplementedError`. + +@@ -2174,17 +2164,17 @@ + valid replies. Return ``None`` if a string name isn't known. Note that this is + a method rather than a fixed string primarily because some :class:`tzinfo` + subclasses will wish to return different names depending on the specific value +- of *dt* passed, especially if the :class:`!tzinfo` class is accounting for ++ of *dt* passed, especially if the :class:`tzinfo` class is accounting for + daylight time. + + The default implementation of :meth:`tzname` raises :exc:`NotImplementedError`. + + + These methods are called by a :class:`.datetime` or :class:`.time` object, in +-response to their methods of the same names. A :class:`!datetime` object passes +-itself as the argument, and a :class:`!time` object passes ``None`` as the ++response to their methods of the same names. A :class:`.datetime` object passes ++itself as the argument, and a :class:`.time` object passes ``None`` as the + argument. A :class:`tzinfo` subclass's methods should therefore be prepared to +-accept a *dt* argument of ``None``, or of class :class:`!datetime`. ++accept a *dt* argument of ``None``, or of class :class:`.datetime`. + + When ``None`` is passed, it's up to the class designer to decide the best + response. For example, returning ``None`` is appropriate if the class wishes to +@@ -2192,10 +2182,10 @@ + may be more useful for ``utcoffset(None)`` to return the standard UTC offset, as + there is no other convention for discovering the standard offset. + +-When a :class:`.datetime` object is passed in response to a :class:`!datetime` ++When a :class:`.datetime` object is passed in response to a :class:`.datetime` + method, ``dt.tzinfo`` is the same object as *self*. :class:`tzinfo` methods can +-rely on this, unless user code calls :class:`!tzinfo` methods directly. The +-intent is that the :class:`!tzinfo` methods interpret *dt* as being in local ++rely on this, unless user code calls :class:`tzinfo` methods directly. The ++intent is that the :class:`tzinfo` methods interpret *dt* as being in local + time, and not need worry about objects in other time zones. + + There is one more :class:`tzinfo` method that a subclass may wish to override: +@@ -2223,22 +2213,20 @@ + Skipping code for error cases, the default :meth:`fromutc` implementation acts + like:: + +- import datetime as dt +- +- def fromutc(self, when): +- # raise ValueError error if when.tzinfo is not self +- dtoff = when.utcoffset() +- dtdst = when.dst() ++ def fromutc(self, dt): ++ # raise ValueError error if dt.tzinfo is not self ++ dtoff = dt.utcoffset() ++ dtdst = dt.dst() + # raise ValueError if dtoff is None or dtdst is None + delta = dtoff - dtdst # this is self's standard offset + if delta: +- when += delta # convert to standard local time +- dtdst = when.dst() ++ dt += delta # convert to standard local time ++ dtdst = dt.dst() + # raise ValueError if dtdst is None + if dtdst: +- return when + dtdst ++ return dt + dtdst + else: +- return when ++ return dt + + In the following :download:`tzinfo_examples.py + <../includes/tzinfo_examples.py>` file there are some examples of +@@ -2265,9 +2253,9 @@ + ``astimezone(Eastern)`` won't deliver a result with ``hour == 2`` on the day DST + begins. For example, at the Spring forward transition of 2016, we get:: + +- >>> import datetime as dt ++ >>> from datetime import datetime, timezone + >>> from tzinfo_examples import HOUR, Eastern +- >>> u0 = dt.datetime(2016, 3, 13, 5, tzinfo=dt.timezone.utc) ++ >>> u0 = datetime(2016, 3, 13, 5, tzinfo=timezone.utc) + >>> for i in range(4): + ... u = u0 + i*HOUR + ... t = u.astimezone(Eastern) +@@ -2290,9 +2278,7 @@ + have the :attr:`~.datetime.fold` attribute set to 0 and the later times have it set to 1. + For example, at the Fall back transition of 2016, we get:: + +- >>> import datetime as dt +- >>> from tzinfo_examples import HOUR, Eastern +- >>> u0 = dt.datetime(2016, 11, 6, 4, tzinfo=dt.timezone.utc) ++ >>> u0 = datetime(2016, 11, 6, 4, tzinfo=timezone.utc) + >>> for i in range(4): + ... u = u0 + i*HOUR + ... t = u.astimezone(Eastern) +@@ -2309,7 +2295,7 @@ + Applications that can't bear wall-time ambiguities should explicitly check the + value of the :attr:`~.datetime.fold` attribute or avoid using hybrid + :class:`tzinfo` subclasses; there are no ambiguities when using :class:`timezone`, +-or any other fixed-offset :class:`!tzinfo` subclass (such as a class representing ++or any other fixed-offset :class:`tzinfo` subclass (such as a class representing + only EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)). + + .. seealso:: +@@ -2442,9 +2428,8 @@ + + These methods accept format codes that can be used to parse and format dates:: + +- >>> import datetime as dt +- >>> dt.datetime.strptime('31/01/22 23:59:59.999999', +- ... '%d/%m/%y %H:%M:%S.%f') ++ >>> datetime.strptime('31/01/22 23:59:59.999999', ++ ... '%d/%m/%y %H:%M:%S.%f') + datetime.datetime(2022, 1, 31, 23, 59, 59, 999999) + >>> _.strftime('%a %d %b %Y, %I:%M%p') + 'Mon 31 Jan 2022, 11:59PM' +@@ -2604,46 +2589,7 @@ + + For the :meth:`.datetime.strptime` class method, the default value is + ``1900-01-01T00:00:00.000``: any components not specified in the format string +-will be pulled from the default value. +- +-.. note:: +- Format strings without separators can be ambiguous for parsing. For +- example, with ``%Y%m%d``, the string ``2026111`` may be parsed either as +- ``2026-11-01`` or as ``2026-01-11``. +- Use separators to ensure the input is parsed as intended. +- +-.. note:: +- When used to parse partial dates lacking a year, :meth:`.datetime.strptime` +- will raise when encountering February 29 because the default year of 1900 is +- *not* a leap year. Always add a default leap year to partial date strings +- before parsing. +- +- +-.. testsetup:: +- +- # doctest seems to turn the warning into an error which makes it +- # show up and require matching and prevents the actual interesting +- # exception from being raised. +- # Manually apply the catch_warnings context manager +- import warnings +- catch_warnings = warnings.catch_warnings() +- catch_warnings.__enter__() +- warnings.simplefilter("ignore") +- +-.. testcleanup:: +- +- catch_warnings.__exit__() +- +-.. doctest:: +- +- >>> import datetime as dt +- >>> value = "2/29" +- >>> dt.datetime.strptime(value, "%m/%d") +- Traceback (most recent call last): +- ... +- ValueError: day 29 must be in range 1..28 for month 2 in year 1900 +- >>> dt.datetime.strptime(f"1904 {value}", "%Y %m/%d") +- datetime.datetime(1904, 2, 29, 0, 0) ++will be pulled from the default value. [#]_ + + Using ``datetime.strptime(date_string, format)`` is equivalent to:: + +@@ -2774,12 +2720,12 @@ + include a year in the format. If the value you need to parse lacks a year, + append an explicit dummy leap year. Otherwise your code will raise an + exception when it encounters leap day because the default year used by the +- parser (1900) is not a leap year. Users run into that bug every leap year. ++ parser is not a leap year. Users run into this bug every four years... + + .. doctest:: + + >>> month_day = "02/29" +- >>> dt.datetime.strptime(f"{month_day};1984", "%m/%d;%Y") # No leap year bug. ++ >>> datetime.strptime(f"{month_day};1984", "%m/%d;%Y") # No leap year bug. + datetime.datetime(1984, 2, 29, 0, 0) + + .. deprecated-removed:: 3.13 3.15 +@@ -2790,7 +2736,7 @@ + + .. rubric:: Footnotes + +-.. [#] If, that is, we ignore the effects of relativity. ++.. [#] If, that is, we ignore the effects of Relativity + + .. [#] This matches the definition of the "proleptic Gregorian" calendar in + Dershowitz and Reingold's book *Calendrical Calculations*, +@@ -2801,3 +2747,5 @@ + .. [#] See R. H. van Gent's `guide to the mathematics of the ISO 8601 calendar + `_ + for a good explanation. ++ ++.. [#] Passing ``datetime.strptime('Feb 29', '%b %d')`` will fail since 1900 is not a leap year. +diff --git a/Doc/library/dbm.rst b/Doc/library/dbm.rst +index ddfe73a86b7..628232cb631 100644 +--- a/Doc/library/dbm.rst ++++ b/Doc/library/dbm.rst +@@ -155,6 +155,7 @@ + --------------------------------------------- + + .. module:: dbm.sqlite3 ++ :platform: All + :synopsis: SQLite backend for dbm + + .. versionadded:: 3.13 +@@ -205,6 +206,7 @@ + --------------------------------------- + + .. module:: dbm.gnu ++ :platform: Unix + :synopsis: GNU database manager + + **Source code:** :source:`Lib/dbm/gnu.py` +@@ -222,8 +224,6 @@ + + .. include:: ../includes/wasm-mobile-notavail.rst + +-.. availability:: Unix. +- + .. exception:: error + + Raised on :mod:`dbm.gnu`-specific errors, such as I/O errors. :exc:`KeyError` is +@@ -325,6 +325,7 @@ + ---------------------------------------- + + .. module:: dbm.ndbm ++ :platform: Unix + :synopsis: The New Database Manager + + **Source code:** :source:`Lib/dbm/ndbm.py` +@@ -350,8 +351,6 @@ + + .. include:: ../includes/wasm-mobile-notavail.rst + +-.. availability:: Unix. +- + .. exception:: error + + Raised on :mod:`dbm.ndbm`-specific errors, such as I/O errors. :exc:`KeyError` is raised +diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst +index 01c00604251..18cd20124fb 100644 +--- a/Doc/library/decimal.rst ++++ b/Doc/library/decimal.rst +@@ -34,12 +34,10 @@ + decimal floating-point arithmetic. It offers several advantages over the + :class:`float` datatype: + +-* Decimal "is based on a `floating-point model +- `__ which was designed +- with people in mind, and necessarily has a paramount guiding principle -- +- computers must provide an arithmetic that works in the same way as the +- arithmetic that people learn at school." -- excerpt from the decimal +- arithmetic specification. ++* Decimal "is based on a floating-point model which was designed with people ++ in mind, and necessarily has a paramount guiding principle -- computers must ++ provide an arithmetic that works in the same way as the arithmetic that ++ people learn at school." -- excerpt from the decimal arithmetic specification. + + * Decimal numbers can be represented exactly. In contrast, numbers like + ``1.1`` and ``2.2`` do not have exact representations in binary +@@ -240,26 +238,6 @@ + >>> c % a + Decimal('0.77') + +-Decimals can be formatted (with :func:`format` built-in or :ref:`f-strings`) in +-fixed-point or scientific notation, using the same formatting syntax (see +-:ref:`formatspec`) as builtin :class:`float` type: +- +-.. doctest:: +- +- >>> format(Decimal('2.675'), "f") +- '2.675' +- >>> format(Decimal('2.675'), ".2f") +- '2.68' +- >>> f"{Decimal('2.675'):.2f}" +- '2.68' +- >>> format(Decimal('2.675'), ".2e") +- '2.68e+0' +- >>> with localcontext() as ctx: +- ... ctx.rounding = ROUND_DOWN +- ... print(format(Decimal('2.675'), ".2f")) +- ... +- 2.67 +- + And some mathematical functions are also available to Decimal: + + >>> getcontext().prec = 28 +diff --git a/Doc/library/dialog.rst b/Doc/library/dialog.rst +index 17f1eb42c16..e0693e8eb6e 100644 +--- a/Doc/library/dialog.rst ++++ b/Doc/library/dialog.rst +@@ -5,6 +5,7 @@ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + .. module:: tkinter.simpledialog ++ :platform: Tk + :synopsis: Simple dialog windows + + **Source code:** :source:`Lib/tkinter/simpledialog.py` +@@ -42,6 +43,7 @@ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + .. module:: tkinter.filedialog ++ :platform: Tk + :synopsis: Dialog classes for file selection + + **Source code:** :source:`Lib/tkinter/filedialog.py` +@@ -206,6 +208,7 @@ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + .. module:: tkinter.commondialog ++ :platform: Tk + :synopsis: Tkinter base class for dialogs + + **Source code:** :source:`Lib/tkinter/commondialog.py` +diff --git a/Doc/library/difflib.rst b/Doc/library/difflib.rst +index 85357008b6e..fcd240e7e82 100644 +--- a/Doc/library/difflib.rst ++++ b/Doc/library/difflib.rst +@@ -358,7 +358,7 @@ + + .. _sequence-matcher: + +-SequenceMatcher objects ++SequenceMatcher Objects + ----------------------- + + The :class:`SequenceMatcher` class has this constructor: +@@ -586,7 +586,7 @@ + + .. _sequencematcher-examples: + +-SequenceMatcher examples ++SequenceMatcher Examples + ------------------------ + + This example compares two strings, considering blanks to be "junk": +@@ -637,7 +637,7 @@ + + .. _differ-objects: + +-Differ objects ++Differ Objects + -------------- + + Note that :class:`Differ`\ -generated deltas make no claim to be **minimal** +@@ -686,7 +686,7 @@ + + .. _differ-examples: + +-Differ example ++Differ Example + -------------- + + This example compares two texts. First we set up the texts, sequences of +diff --git a/Doc/library/dis.rst b/Doc/library/dis.rst +index 091e67fc544..67bfd14fa8d 100644 +--- a/Doc/library/dis.rst ++++ b/Doc/library/dis.rst +@@ -716,7 +716,7 @@ + end = STACK.pop() + start = STACK.pop() + container = STACK.pop() +- value = STACK.pop() ++ values = STACK.pop() + container[start:end] = value + + .. versionadded:: 3.12 +diff --git a/Doc/library/email.headerregistry.rst b/Doc/library/email.headerregistry.rst +index c4570b16c3c..ff8b601fe3d 100644 +--- a/Doc/library/email.headerregistry.rst ++++ b/Doc/library/email.headerregistry.rst +@@ -96,10 +96,9 @@ + ``kwds`` is a dictionary containing one pre-initialized key, ``defects``. + ``defects`` is an empty list. The parse method should append any detected + defects to this list. On return, the ``kwds`` dictionary *must* contain +- values for at least the keys ``decoded``, ``defects`` and ``parse_tree``. +- ``decoded`` should be the string value for the header (that is, the header +- value fully decoded to unicode). ``parse_tree`` is set to the parse tree obtained +- from parsing the header. The parse method should assume that *string* may ++ values for at least the keys ``decoded`` and ``defects``. ``decoded`` ++ should be the string value for the header (that is, the header value fully ++ decoded to unicode). The parse method should assume that *string* may + contain content-transfer-encoded parts, but should correctly handle all valid + unicode characters as well so that it can parse un-encoded header values. + +diff --git a/Doc/library/email.message.rst b/Doc/library/email.message.rst +index 0aa8e632c2c..71d6e321f38 100644 +--- a/Doc/library/email.message.rst ++++ b/Doc/library/email.message.rst +@@ -57,7 +57,7 @@ + :class:`~email.policy.default` policy, which follows the rules of the email + RFCs except for line endings (instead of the RFC mandated ``\r\n``, it uses + the Python standard ``\n`` line endings). For more information see the +- :mod:`~email.policy` documentation. [2]_ ++ :mod:`~email.policy` documentation. + + .. method:: as_string(unixfrom=False, maxheaderlen=None, policy=None) + +@@ -749,9 +749,3 @@ + .. [1] Originally added in 3.4 as a :term:`provisional module `. Docs for legacy message class moved to + :ref:`compat32_message`. +- +-.. [2] The :class:`EmailMessage` class requires a policy that provides a +- ``content_manager`` attribute for content management methods like +- ``set_content()`` and ``get_content()`` to work. The legacy +- :const:`~email.policy.compat32` policy does not support these methods +- and should not be used with :class:`EmailMessage`. +diff --git a/Doc/library/email.parser.rst b/Doc/library/email.parser.rst +index 703feaf7e04..6a70714dc3e 100644 +--- a/Doc/library/email.parser.rst ++++ b/Doc/library/email.parser.rst +@@ -155,7 +155,7 @@ + + Read all the data from the binary file-like object *fp*, parse the + resulting bytes, and return the message object. *fp* must support +- both the :meth:`~io.IOBase.readline` and the :meth:`~io.BufferedIOBase.read` ++ both the :meth:`~io.IOBase.readline` and the :meth:`~io.IOBase.read` + methods. + + The bytes contained in *fp* must be formatted as a block of :rfc:`5322` +diff --git a/Doc/library/email.policy.rst b/Doc/library/email.policy.rst +index 1ff3e2c3f8d..6b997ee784f 100644 +--- a/Doc/library/email.policy.rst ++++ b/Doc/library/email.policy.rst +@@ -662,13 +662,6 @@ + An instance of :class:`Compat32`, providing backward compatibility with the + behavior of the email package in Python 3.2. + +- .. note:: +- +- The :const:`compat32` policy should not be used as a policy for +- :class:`~email.message.EmailMessage` objects, and should only be used +- to serialize messages that were created using the :const:`compat32` +- policy. +- + + .. rubric:: Footnotes + +diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst +index b5b44458d63..faf8f88934a 100644 +--- a/Doc/library/enum.rst ++++ b/Doc/library/enum.rst +@@ -61,7 +61,7 @@ + + --------------- + +-Module contents ++Module Contents + --------------- + + :class:`EnumType` +@@ -153,12 +153,6 @@ + + Return a list of all power-of-two integers contained in a flag. + +- :func:`enum.bin` +- +- Like built-in :func:`bin`, except negative values are represented in +- two's complement, and the leading bit always indicates sign +- (``0`` implies positive, ``1`` implies negative). +- + + .. versionadded:: 3.6 ``Flag``, ``IntFlag``, ``auto`` + .. versionadded:: 3.11 ``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, ``member``, ``nonmember``, ``global_enum``, ``show_flag_values`` +@@ -166,7 +160,7 @@ + + --------------- + +-Data types ++Data Types + ---------- + + +@@ -245,7 +239,7 @@ + + .. method:: EnumType.__len__(cls) + +- Returns the number of members in *cls*:: ++ Returns the number of member in *cls*:: + + >>> len(Color) + 3 +@@ -307,28 +301,6 @@ + No longer used, kept for backward compatibility. + (class attribute, removed during class creation). + +- The :attr:`~Enum._order_` attribute can be provided to help keep Python 2 / Python 3 code in sync. +- It will be checked against the actual order of the enumeration and raise an error if the two do not match:: +- +- >>> class Color(Enum): +- ... _order_ = 'RED GREEN BLUE' +- ... RED = 1 +- ... BLUE = 3 +- ... GREEN = 2 +- ... +- Traceback (most recent call last): +- ... +- TypeError: member order does not match _order_: +- ['RED', 'BLUE', 'GREEN'] +- ['RED', 'GREEN', 'BLUE'] +- +- .. note:: +- +- In Python 2 code the :attr:`~Enum._order_` attribute is necessary as definition +- order is lost before it can be recorded. +- +- .. versionadded:: 3.6 +- + .. attribute:: Enum._ignore_ + + ``_ignore_`` is only used during creation and is removed from the +@@ -338,15 +310,13 @@ + names will also be removed from the completed enumeration. See + :ref:`TimePeriod ` for an example. + +- .. versionadded:: 3.7 +- + .. method:: Enum.__dir__(self) + + Returns ``['__class__', '__doc__', '__module__', 'name', 'value']`` and + any public methods defined on *self.__class__*:: + + >>> from enum import Enum +- >>> import datetime as dt ++ >>> from datetime import date + >>> class Weekday(Enum): + ... MONDAY = 1 + ... TUESDAY = 2 +@@ -357,7 +327,7 @@ + ... SUNDAY = 7 + ... @classmethod + ... def today(cls): +- ... print(f'today is {cls(dt.date.today().isoweekday()).name}') ++ ... print('today is %s' % cls(date.today().isoweekday()).name) + ... + >>> dir(Weekday.SATURDAY) + ['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value'] +@@ -370,16 +340,7 @@ + :last_values: A list of the previous values. + + A *staticmethod* that is used to determine the next value returned by +- :class:`auto`. +- +- .. note:: +- For standard :class:`Enum` classes the next value chosen is the highest +- value seen incremented by one. +- +- For :class:`Flag` classes the next value chosen will be the next highest +- power-of-two. +- +- This method may be overridden, e.g.:: ++ :class:`auto`:: + + >>> from enum import auto, Enum + >>> class PowersOfThree(Enum): +@@ -392,10 +353,6 @@ + >>> PowersOfThree.SECOND.value + 9 + +- .. versionadded:: 3.6 +- .. versionchanged:: 3.13 +- Prior versions would use the last seen value instead of the highest value. +- + .. method:: Enum.__init__(self, *args, **kwds) + + By default, does nothing. If multiple values are given in the member +@@ -434,8 +391,6 @@ + >>> Build('deBUG') + + +- .. versionadded:: 3.6 +- + .. method:: Enum.__new__(cls, *args, **kwds) + + By default, doesn't exist. If specified, either in the enum class +@@ -529,8 +484,7 @@ + >>> Color(42) + + +- | Raises a :exc:`ValueError` if the value is already linked with a different member. +- | See :ref:`multi-value-enum` for an example. ++ Raises a :exc:`ValueError` if the value is already linked with a different member. + + .. versionadded:: 3.13 + +@@ -929,8 +883,6 @@ + + --------------- + +-.. _enum-dunder-sunder: +- + Supported ``__dunder__`` names + """""""""""""""""""""""""""""" + +@@ -938,7 +890,7 @@ + items. It is only available on the class. + + :meth:`~Enum.__new__`, if specified, must create and return the enum members; +-it is also a very good idea to set the member's :attr:`~Enum._value_` appropriately. ++it is also a very good idea to set the member's :attr:`!_value_` appropriately. + Once all the members are created it is no longer used. + + +@@ -954,10 +906,17 @@ + from the final class + - :attr:`~Enum._order_` -- no longer used, kept for backward + compatibility (class attribute, removed during class creation) +- + - :meth:`~Enum._generate_next_value_` -- used to get an appropriate value for + an enum member; may be overridden + ++ .. note:: ++ ++ For standard :class:`Enum` classes the next value chosen is the highest ++ value seen incremented by one. ++ ++ For :class:`Flag` classes the next value chosen will be the next highest ++ power-of-two. ++ + - :meth:`~Enum._add_alias_` -- adds a new name as an alias to an existing + member. + - :meth:`~Enum._add_value_alias_` -- adds a new value as an alias to an +@@ -975,7 +934,7 @@ + + --------------- + +-Utilities and decorators ++Utilities and Decorators + ------------------------ + + .. class:: auto +@@ -988,13 +947,12 @@ + the member's name. Care must be taken if mixing *auto()* with manually + specified values. + +- *auto* instances are only resolved when at the top level of an assignment, either by +- itself or as part of a tuple: ++ *auto* instances are only resolved when at the top level of an assignment: + + * ``FIRST = auto()`` will work (auto() is replaced with ``1``); + * ``SECOND = auto(), -2`` will work (auto is replaced with ``2``, so ``2, -2`` is + used to create the ``SECOND`` enum member; +- * ``THREE = [auto(), -3]`` will *not* work (``[, -3]`` is used to ++ * ``THREE = [auto(), -3]`` will *not* work (``, -3`` is used to + create the ``THREE`` enum member) + + .. versionchanged:: 3.11.1 +@@ -1075,19 +1033,6 @@ + + .. versionadded:: 3.11 + +-.. function:: bin(num, max_bits=None) +- +- Like built-in :func:`bin`, except negative values are represented in +- two's complement, and the leading bit always indicates sign +- (``0`` implies positive, ``1`` implies negative). +- +- >>> import enum +- >>> enum.bin(10) +- '0b0 1010' +- >>> enum.bin(~10) # ~10 is -11 +- '0b1 0101' +- +- .. versionadded:: 3.11 + + --------------- + +diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst +index df80bfaceca..59043886dab 100644 +--- a/Doc/library/exceptions.rst ++++ b/Doc/library/exceptions.rst +@@ -221,7 +221,7 @@ + .. exception:: EOFError + + Raised when the :func:`input` function hits an end-of-file condition (EOF) +- without reading any data. (Note: the :meth:`io.TextIOBase.read` and ++ without reading any data. (Note: the :meth:`!io.IOBase.read` and + :meth:`io.IOBase.readline` methods return an empty string when they hit EOF.) + + +@@ -725,8 +725,8 @@ + + .. attribute:: characters_written + +- An integer containing the number of **bytes** written to the stream +- before it blocked. This attribute is available when using the ++ An integer containing the number of characters written to the stream ++ before it blocked. This attribute is available when using the + buffered I/O classes from the :mod:`io` module. + + .. exception:: ChildProcessError +@@ -961,15 +961,6 @@ + raises a :exc:`TypeError` if any contained exception is not an + :exc:`Exception` subclass. + +- Exception groups are :ref:`generic ` over the type of their +- contained exceptions. +- +- .. impl-detail:: +- +- The ``excs`` parameter may be any sequence, but lists and tuples are +- specifically processed more efficiently here. For optimal performance, +- pass a tuple as ``excs``. +- + .. attribute:: message + + The ``msg`` argument to the constructor. This is a read-only attribute. +diff --git a/Doc/library/fcntl.rst b/Doc/library/fcntl.rst +index 856fa355634..3dcfe3b87f9 100644 +--- a/Doc/library/fcntl.rst ++++ b/Doc/library/fcntl.rst +@@ -2,6 +2,7 @@ + ========================================================== + + .. module:: fcntl ++ :platform: Unix + :synopsis: The fcntl() and ioctl() system calls. + + .. sectionauthor:: Jaap Vermeulen +diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst +index 39f6fc7bb3e..04b5dc5bf82 100644 +--- a/Doc/library/functions.rst ++++ b/Doc/library/functions.rst +@@ -138,8 +138,6 @@ + >>> f'{14:#b}', f'{14:b}' + ('0b1110', '1110') + +- See also :func:`enum.bin` to represent negative values as twos-complement. +- + See also :func:`format` for more information. + + +@@ -336,8 +334,8 @@ + ``__debug__`` is true), ``1`` (asserts are removed, ``__debug__`` is false) + or ``2`` (docstrings are removed too). + +- This function raises :exc:`SyntaxError` or :exc:`ValueError` if the compiled +- source is invalid. ++ This function raises :exc:`SyntaxError` if the compiled source is invalid, ++ and :exc:`ValueError` if the source contains null bytes. + + If you want to parse Python code into its AST representation, see + :func:`ast.parse`. +@@ -591,19 +589,18 @@ + .. warning:: + + This function executes arbitrary code. Calling it with +- untrusted user-supplied input will lead to security vulnerabilities. ++ user-supplied input may lead to security vulnerabilities. + +- The *source* argument is parsed and evaluated as a Python expression ++ The *expression* argument is parsed and evaluated as a Python expression + (technically speaking, a condition list) using the *globals* and *locals* + mappings as global and local namespace. If the *globals* dictionary is + present and does not contain a value for the key ``__builtins__``, a + reference to the dictionary of the built-in module :mod:`builtins` is +- inserted under that key before *source* is parsed. +- Overriding ``__builtins__`` can be used to restrict or change the available +- names, but this is **not** a security mechanism: the executed code can +- still access all builtins. +- If the *locals* mapping is omitted it defaults to the +- *globals* dictionary. If both mappings are omitted, the source is ++ inserted under that key before *expression* is parsed. That way you can ++ control what builtins are available to the executed code by inserting your ++ own ``__builtins__`` dictionary into *globals* before passing it to ++ :func:`eval`. If the *locals* mapping is omitted it defaults to the ++ *globals* dictionary. If both mappings are omitted, the expression is + executed with the *globals* and *locals* in the environment where + :func:`eval` is called. Note, *eval()* will only have access to the + :term:`nested scopes ` (non-locals) in the enclosing +@@ -629,7 +626,7 @@ + If the given source is a string, then leading and trailing spaces and tabs + are stripped. + +- See :func:`ast.literal_eval` for a function to evaluate strings ++ See :func:`ast.literal_eval` for a function that can safely evaluate strings + with expressions containing only literals. + + .. audit-event:: exec code_object eval +@@ -653,7 +650,7 @@ + .. warning:: + + This function executes arbitrary code. Calling it with +- untrusted user-supplied input will lead to security vulnerabilities. ++ user-supplied input may lead to security vulnerabilities. + + This function supports dynamic execution of Python code. *source* must be + either a string or a code object. If it is a string, the string is parsed as +@@ -684,10 +681,9 @@ + + If the *globals* dictionary does not contain a value for the key + ``__builtins__``, a reference to the dictionary of the built-in module +- :mod:`builtins` is inserted under that key. +- Overriding ``__builtins__`` can be used to restrict or change the available +- names, but this is **not** a security mechanism: the executed code can +- still access all builtins. ++ :mod:`builtins` is inserted under that key. That way you can control what ++ builtins are available to the executed code by inserting your own ++ ``__builtins__`` dictionary into *globals* before passing it to :func:`exec`. + + The *closure* argument specifies a closure--a tuple of cellvars. + It's only valid when the *object* is a code object containing +diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst +index bcd9b4bbc86..5dc09d0472d 100644 +--- a/Doc/library/functools.rst ++++ b/Doc/library/functools.rst +@@ -190,7 +190,7 @@ + + Note, type specificity applies only to the function's immediate arguments + rather than their contents. The scalar arguments, ``Decimal(42)`` and +- ``Fraction(42)`` are treated as distinct calls with distinct results. ++ ``Fraction(42)`` are be treated as distinct calls with distinct results. + In contrast, the tuple arguments ``('answer', Decimal(42))`` and + ``('answer', Fraction(42))`` are treated as equivalent. + +diff --git a/Doc/library/gettext.rst b/Doc/library/gettext.rst +index 31575655bfd..d0de83907eb 100644 +--- a/Doc/library/gettext.rst ++++ b/Doc/library/gettext.rst +@@ -54,19 +54,19 @@ + + + .. index:: single: _ (underscore); gettext +-.. function:: gettext(message, /) ++.. function:: gettext(message) + + Return the localized translation of *message*, based on the current global + domain, language, and locale directory. This function is usually aliased as + :func:`!_` in the local namespace (see examples below). + + +-.. function:: dgettext(domain, message, /) ++.. function:: dgettext(domain, message) + + Like :func:`.gettext`, but look the message up in the specified *domain*. + + +-.. function:: ngettext(singular, plural, n, /) ++.. function:: ngettext(singular, plural, n) + + Like :func:`.gettext`, but consider plural forms. If a translation is found, + apply the plural formula to *n*, and return the resulting message (some +@@ -81,15 +81,15 @@ + formulas for a variety of languages. + + +-.. function:: dngettext(domain, singular, plural, n, /) ++.. function:: dngettext(domain, singular, plural, n) + + Like :func:`ngettext`, but look the message up in the specified *domain*. + + +-.. function:: pgettext(context, message, /) +-.. function:: dpgettext(domain, context, message, /) +-.. function:: npgettext(context, singular, plural, n, /) +-.. function:: dnpgettext(domain, context, singular, plural, n, /) ++.. function:: pgettext(context, message) ++.. function:: dpgettext(domain, context, message) ++.. function:: npgettext(context, singular, plural, n) ++.. function:: dnpgettext(domain, context, singular, plural, n) + + Similar to the corresponding functions without the ``p`` in the prefix (that + is, :func:`gettext`, :func:`dgettext`, :func:`ngettext`, :func:`dngettext`), +@@ -226,20 +226,20 @@ + translation for a given message. + + +- .. method:: gettext(message, /) ++ .. method:: gettext(message) + + If a fallback has been set, forward :meth:`!gettext` to the fallback. + Otherwise, return *message*. Overridden in derived classes. + + +- .. method:: ngettext(singular, plural, n, /) ++ .. method:: ngettext(singular, plural, n) + + If a fallback has been set, forward :meth:`!ngettext` to the fallback. + Otherwise, return *singular* if *n* is 1; return *plural* otherwise. + Overridden in derived classes. + + +- .. method:: pgettext(context, message, /) ++ .. method:: pgettext(context, message) + + If a fallback has been set, forward :meth:`pgettext` to the fallback. + Otherwise, return the translated message. Overridden in derived classes. +@@ -247,7 +247,7 @@ + .. versionadded:: 3.8 + + +- .. method:: npgettext(context, singular, plural, n, /) ++ .. method:: npgettext(context, singular, plural, n) + + If a fallback has been set, forward :meth:`npgettext` to the fallback. + Otherwise, return the translated message. Overridden in derived classes. +@@ -325,7 +325,7 @@ + + The following methods are overridden from the base class implementation: + +- .. method:: gettext(message, /) ++ .. method:: gettext(message) + + Look up the *message* id in the catalog and return the corresponding message + string, as a Unicode string. If there is no entry in the catalog for the +@@ -334,7 +334,7 @@ + *message* id is returned. + + +- .. method:: ngettext(singular, plural, n, /) ++ .. method:: ngettext(singular, plural, n) + + Do a plural-forms lookup of a message id. *singular* is used as the message id + for purposes of lookup in the catalog, while *n* is used to determine which +@@ -355,7 +355,7 @@ + n) % {'num': n} + + +- .. method:: pgettext(context, message, /) ++ .. method:: pgettext(context, message) + + Look up the *context* and *message* id in the catalog and return the + corresponding message string, as a Unicode string. If there is no +@@ -366,7 +366,7 @@ + .. versionadded:: 3.8 + + +- .. method:: npgettext(context, singular, plural, n, /) ++ .. method:: npgettext(context, singular, plural, n) + + Do a plural-forms lookup of a message id. *singular* is used as the + message id for purposes of lookup in the catalog, while *n* is used to +diff --git a/Doc/library/glob.rst b/Doc/library/glob.rst +index 9ce031b0133..7580c564494 100644 +--- a/Doc/library/glob.rst ++++ b/Doc/library/glob.rst +@@ -83,11 +83,6 @@ + This function may return duplicate path names if *pathname* + contains multiple "``**``" patterns and *recursive* is true. + +- .. note:: +- Any :exc:`OSError` exceptions raised from scanning the filesystem are +- suppressed. This includes :exc:`PermissionError` when accessing +- directories without read permission. +- + .. versionchanged:: 3.5 + Support for recursive globs using "``**``". + +@@ -111,11 +106,6 @@ + This function may return duplicate path names if *pathname* + contains multiple "``**``" patterns and *recursive* is true. + +- .. note:: +- Any :exc:`OSError` exceptions raised from scanning the filesystem are +- suppressed. This includes :exc:`PermissionError` when accessing +- directories without read permission. +- + .. versionchanged:: 3.5 + Support for recursive globs using "``**``". + +diff --git a/Doc/library/grp.rst b/Doc/library/grp.rst +index f436970e791..d1c7f22a209 100644 +--- a/Doc/library/grp.rst ++++ b/Doc/library/grp.rst +@@ -2,6 +2,7 @@ + ================================== + + .. module:: grp ++ :platform: Unix + :synopsis: The group database (getgrnam() and friends). + + -------------- +diff --git a/Doc/library/html.parser.rst b/Doc/library/html.parser.rst +index a673fd3df91..3f075bb8cba 100644 +--- a/Doc/library/html.parser.rst ++++ b/Doc/library/html.parser.rst +@@ -141,7 +141,7 @@ + argument is a list of ``(name, value)`` pairs containing the attributes found + inside the tag's ``<>`` brackets. The *name* will be translated to lower case, + and quotes in the *value* have been removed, and character and entity references +- have been replaced. For empty attributes, *value* is ``None``. ++ have been replaced. + + For instance, for the tag ````, this method + would be called as ``handle_starttag('a', [('href', 'https://www.cwi.nl/')])``. +@@ -317,18 +317,6 @@ + Data : alert("hello! ☺"); + End tag : script + +-Attribute names are converted to lowercase, quotes from attribute values removed, +-and ``None`` is returned as *value* for empty attributes (such as ``checked``): +- +-.. doctest:: +- +- >>> parser.feed("") +- Start tag: input +- attr: ('type', 'checkbox') +- attr: ('checked', None) +- attr: ('required', '') +- attr: ('disabled', 'disabled') +- + Parsing comments: + + .. doctest:: +diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst +index 14c67a0600f..75aa818ab9f 100644 +--- a/Doc/library/http.client.rst ++++ b/Doc/library/http.client.rst +@@ -311,12 +311,6 @@ + :class:`str` or bytes-like object that is not also a file as the + body representation. + +- .. note:: +- +- Note that you must have read the whole response or call :meth:`close` +- if :meth:`getresponse` raised an non-:exc:`ConnectionError` exception +- before you can send a new request to the server. +- + .. versionchanged:: 3.2 + *body* can now be an iterable. + +@@ -332,15 +326,16 @@ + Should be called after a request is sent to get the response from the server. + Returns an :class:`HTTPResponse` instance. + ++ .. note:: ++ ++ Note that you must have read the whole response before you can send a new ++ request to the server. ++ + .. versionchanged:: 3.5 + If a :exc:`ConnectionError` or subclass is raised, the + :class:`HTTPConnection` object will be ready to reconnect when + a new request is sent. + +- Note that this does not apply to :exc:`OSError`\s raised by the underlying +- socket. Instead the caller is responsible to call :meth:`close` on the +- existing connection. +- + + .. method:: HTTPConnection.set_debuglevel(level) + +diff --git a/Doc/library/http.cookies.rst b/Doc/library/http.cookies.rst +index ecf865b195c..845c2df5c53 100644 +--- a/Doc/library/http.cookies.rst ++++ b/Doc/library/http.cookies.rst +@@ -275,9 +275,9 @@ + Set-Cookie: chips=ahoy + Set-Cookie: vienna=finger + >>> C = cookies.SimpleCookie() +- >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=;";') ++ >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";') + >>> print(C) +- Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=;" ++ Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;" + >>> C = cookies.SimpleCookie() + >>> C["oreo"] = "doublestuff" + >>> C["oreo"]["path"] = "/" +diff --git a/Doc/library/http.server.rst b/Doc/library/http.server.rst +index 4eadf28d3ef..351500174f6 100644 +--- a/Doc/library/http.server.rst ++++ b/Doc/library/http.server.rst +@@ -59,7 +59,7 @@ + + This class is used to handle the HTTP requests that arrive at the server. By + itself, it cannot respond to any actual HTTP requests; it must be subclassed +- to handle each request method (for example, ``'GET'`` or ``'POST'``). ++ to handle each request method (e.g. GET or POST). + :class:`BaseHTTPRequestHandler` provides a number of class and instance + variables, and methods for use by subclasses. + +@@ -201,7 +201,7 @@ + request header it responds back with a ``100 Continue`` followed by ``200 + OK`` headers. + This method can be overridden to raise an error if the server does not +- want the client to continue. For example, the server can choose to send ``417 ++ want the client to continue. For e.g. server can choose to send ``417 + Expectation Failed`` as a response header and ``return False``. + + .. versionadded:: 3.2 +@@ -247,8 +247,6 @@ + specifying its value. Note that, after the send_header calls are done, + :meth:`end_headers` MUST BE called in order to complete the operation. + +- This method does not reject input containing CRLF sequences. +- + .. versionchanged:: 3.2 + Headers are stored in an internal buffer. + +@@ -259,8 +257,6 @@ + buffered and sent directly the output stream.If the *message* is not + specified, the HTTP message corresponding the response *code* is sent. + +- This method does not reject *message* containing CRLF sequences. +- + .. versionadded:: 3.2 + + .. method:: end_headers() +@@ -478,9 +474,7 @@ + + :mod:`http.server` can also be invoked directly using the :option:`-m` + switch of the interpreter. The following example illustrates how to serve +-files relative to the current directory: +- +-.. code-block:: bash ++files relative to the current directory:: + + python -m http.server [OPTIONS] [port] + +@@ -491,9 +485,7 @@ + .. option:: port + + The server listens to port 8000 by default. The default can be overridden +- by passing the desired port number as an argument: +- +- .. code-block:: bash ++ by passing the desired port number as an argument:: + + python -m http.server 9000 + +@@ -502,9 +494,7 @@ + Specifies a specific address to which it should bind. Both IPv4 and IPv6 + addresses are supported. By default, the server binds itself to all + interfaces. For example, the following command causes the server to bind +- to localhost only: +- +- .. code-block:: bash ++ to localhost only:: + + python -m http.server --bind 127.0.0.1 + +@@ -517,9 +507,7 @@ + + Specifies a directory to which it should serve the files. By default, + the server uses the current directory. For example, the following command +- uses a specific directory: +- +- .. code-block:: bash ++ uses a specific directory:: + + python -m http.server --directory /tmp/ + +@@ -529,9 +517,7 @@ + + Specifies the HTTP version to which the server is conformant. By default, + the server is conformant to HTTP/1.0. For example, the following command +- runs an HTTP/1.1 conformant server: +- +- .. code-block:: bash ++ runs an HTTP/1.1 conformant server:: + + python -m http.server --protocol HTTP/1.1 + +@@ -540,9 +526,7 @@ + .. option:: --cgi + + :class:`CGIHTTPRequestHandler` can be enabled in the command line by passing +- the ``--cgi`` option: +- +- .. code-block:: bash ++ the ``--cgi`` option:: + + python -m http.server --cgi + +@@ -569,11 +553,6 @@ + requests, this makes it possible for files outside of the specified directory + to be served. + +-Methods :meth:`BaseHTTPRequestHandler.send_header` and +-:meth:`BaseHTTPRequestHandler.send_response_only` assume sanitized input +-and do not perform input validation such as checking for the presence of CRLF +-sequences. Untrusted input may result in HTTP Header injection attacks. +- + Earlier versions of Python did not scrub control characters from the + log messages emitted to stderr from ``python -m http.server`` or the + default :class:`BaseHTTPRequestHandler` ``.log_message`` +diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst +index 417c0ef6cab..9e87704c286 100644 +--- a/Doc/library/idle.rst ++++ b/Doc/library/idle.rst +@@ -37,11 +37,6 @@ + + * configuration, browsers, and other dialogs + +-The IDLE application is implemented in the :mod:`idlelib` package. +- +-This is an optional module. If it is missing from your copy of CPython, look for documentation from your distributor (that is, whoever provided Python to you). +-If you are the distributor, see Requirements for optional modules. +- + Menus + ----- + +@@ -159,7 +154,7 @@ + + Show Completions + Open a scrollable list allowing selection of existing names. See +- :ref:`Completions ` in the Editing and Navigation section below. ++ :ref:`Completions ` in the Editing and navigation section below. + + Expand Word + Expand a prefix you have typed to match a full word in the same window; +@@ -168,7 +163,7 @@ + Show Call Tip + After an unclosed parenthesis for a function, open a small window with + function parameter hints. See :ref:`Calltips ` in the +- Editing and Navigation section below. ++ Editing and navigation section below. + + Show Surrounding Parens + Highlight the surrounding parenthesis. +@@ -179,9 +174,9 @@ + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + Format Paragraph +- Rewrap the text block containing the text insert cursor. +- Avoid code lines. See :ref:`Format block` in the +- Editing and Navigation section below. ++ Reformat the current blank-line-delimited paragraph in comment block or ++ multiline string or selected line in a string. All lines in the ++ paragraph will be formatted to less than N columns, where N defaults to 72. + + Indent Region + Shift selected lines right by the indent width (default 4 spaces). +@@ -567,20 +562,6 @@ + One might want to run a file after writing import statements, after + adding function definitions, or after opening an existing file. + +-.. _format-block: +- +-Format block +-^^^^^^^^^^^^ +- +-Reformat Paragraph rewraps a block ('paragraph') of contiguous equally +-indented non-blank comments, a similar block of text within a multiline +-string, or a selected subset of either. +-If needed, add a blank line to separate string from code. +-Partial lines in a selection expand to complete lines. +-The resulting lines have the same indent as before +-but have maximum total length of N columns (characters). +-Change the default N of 72 on the Window tab of IDLE Settings. +- + .. _code-context: + + Code Context +diff --git a/Doc/library/importlib.resources.abc.rst b/Doc/library/importlib.resources.abc.rst +index 45979c56912..8253a33f591 100644 +--- a/Doc/library/importlib.resources.abc.rst ++++ b/Doc/library/importlib.resources.abc.rst +@@ -63,14 +63,11 @@ + If the resource does not concretely exist on the file system, + raise :exc:`FileNotFoundError`. + +- .. method:: is_resource(path) ++ .. method:: is_resource(name) + :abstractmethod: + +- Returns ``True`` if the named *path* is considered a resource. +- :exc:`FileNotFoundError` is raised if *path* does not exist. +- +- .. versionchanged:: 3.10 +- The argument *name* was renamed to *path*. ++ Returns ``True`` if the named *name* is considered a resource. ++ :exc:`FileNotFoundError` is raised if *name* does not exist. + + .. method:: contents() + :abstractmethod: +diff --git a/Doc/library/importlib.resources.rst b/Doc/library/importlib.resources.rst +index 1acbab1e57f..7a11f4fe069 100644 +--- a/Doc/library/importlib.resources.rst ++++ b/Doc/library/importlib.resources.rst +@@ -31,12 +31,6 @@ + for example, a package and its resources can be imported from a zip file using + :py:mod:`zipimport`. + +-.. warning:: +- +- :mod:`importlib.resources` follows the same security model as the built-in +- :func:`open` function. Passing untrusted inputs to the functions +- in this module is unsafe. +- + .. note:: + + This module provides functionality similar to `pkg_resources +@@ -245,6 +239,7 @@ + + .. versionchanged:: 3.13 + Multiple *path_names* are accepted. ++ *encoding* and *errors* must be given as keyword arguments. + + + .. function:: is_resource(anchor, *path_names) +diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst +index 3e0df312f1c..a741223d115 100644 +--- a/Doc/library/inspect.rst ++++ b/Doc/library/inspect.rst +@@ -242,9 +242,6 @@ + +-----------------+-------------------+---------------------------+ + | | ag_running | is the generator running? | + +-----------------+-------------------+---------------------------+ +-| | ag_suspended | is the generator | +-| | | suspended? | +-+-----------------+-------------------+---------------------------+ + | | ag_code | code | + +-----------------+-------------------+---------------------------+ + | coroutine | __name__ | name | +@@ -258,9 +255,6 @@ + +-----------------+-------------------+---------------------------+ + | | cr_running | is the coroutine running? | + +-----------------+-------------------+---------------------------+ +-| | cr_suspended | is the coroutine | +-| | | suspended? | +-+-----------------+-------------------+---------------------------+ + | | cr_code | code | + +-----------------+-------------------+---------------------------+ + | | cr_origin | where coroutine was | +@@ -294,19 +288,6 @@ + + Add ``__builtins__`` attribute to functions. + +-.. versionchanged:: 3.11 +- +- Add ``gi_suspended`` attribute to generators. +- +-.. versionchanged:: 3.11 +- +- Add ``cr_suspended`` attribute to coroutines. +- +-.. versionchanged:: 3.12 +- +- Add ``ag_suspended`` attribute to async generators. +- +- + .. function:: getmembers(object[, predicate]) + + Return all the members of an object in a list of ``(name, value)`` +@@ -365,9 +346,6 @@ + Return ``True`` if the object is a class, whether built-in or created in Python + code. + +- This function returns ``False`` for :ref:`generic aliases ` of classes, +- such as ``list[int]``. +- + + .. function:: ismethod(object) + +@@ -486,7 +464,7 @@ + + .. versionchanged:: 3.13 + Functions wrapped in :func:`functools.partialmethod` now return ``True`` +- if the wrapped function is a :term:`asynchronous generator` function. ++ if the wrapped function is a :term:`coroutine function`. + + .. function:: isasyncgen(object) + +@@ -1515,11 +1493,10 @@ + may be called. + + For cases where you want passive introspection, like documentation tools, this +-can be inconvenient. :func:`getattr_static` has a similar signature as :func:`getattr` ++can be inconvenient. :func:`getattr_static` has the same signature as :func:`getattr` + but avoids executing code when it fetches attributes. + +-.. function:: getattr_static(obj, attr) +- getattr_static(obj, attr, default) ++.. function:: getattr_static(obj, attr, default=None) + + Retrieve attributes without triggering dynamic lookup via the + descriptor protocol, :meth:`~object.__getattr__` +diff --git a/Doc/library/io.rst b/Doc/library/io.rst +index 21420b3ca57..a090cbb70e8 100644 +--- a/Doc/library/io.rst ++++ b/Doc/library/io.rst +@@ -46,7 +46,6 @@ + Operations that used to raise :exc:`IOError` now raise :exc:`OSError`, since + :exc:`IOError` is now an alias of :exc:`OSError`. + +-.. _text-io: + + Text I/O + ^^^^^^^^ +@@ -68,7 +67,6 @@ + The text stream API is described in detail in the documentation of + :class:`TextIOBase`. + +-.. _binary-io: + + Binary I/O + ^^^^^^^^^^ +@@ -107,13 +105,6 @@ + + The raw stream API is described in detail in the docs of :class:`RawIOBase`. + +-.. warning:: +- Raw I/O is a low-level interface and methods generally must have their return +- values checked and be explicitly retried to ensure an operation completes. +- For instance :meth:`~RawIOBase.write` returns the number of bytes written +- which may be less than the number of bytes provided (a partial write). +- High-level I/O objects like :ref:`binary-io` and :ref:`text-io` implement +- retry behavior. + + .. _io-text-encoding: + +@@ -489,11 +480,8 @@ + + Read up to *size* bytes from the object and return them. As a convenience, + if *size* is unspecified or -1, all bytes until EOF are returned. +- +- Attempts to make only one system call but will retry if interrupted and +- the signal handler does not raise an exception (see :pep:`475` for the +- rationale). This means fewer than *size* bytes may be returned if the +- operating system call returns fewer than *size* bytes. ++ Otherwise, only one system call is ever made. Fewer than *size* bytes may ++ be returned if the operating system call returns fewer than *size* bytes. + + If 0 bytes are returned, and *size* was not 0, this indicates end of file. + If the object is in non-blocking mode and no bytes are available, +@@ -507,19 +495,13 @@ + Read and return all the bytes from the stream until EOF, using multiple + calls to the stream if necessary. + +- If ``0`` bytes are returned this indicates end of file. If the object is in +- non-blocking mode and the underlying :meth:`read` returns ``None`` +- indicating no bytes are available, ``None`` is returned. +- + .. method:: readinto(b, /) + + Read bytes into a pre-allocated, writable + :term:`bytes-like object` *b*, and return the + number of bytes read. For example, *b* might be a :class:`bytearray`. +- +- If ``0`` is returned and ``len(b)`` is not ``0``, this indicates end of file. If +- the object is in non-blocking mode and no bytes are available, ``None`` is +- returned. ++ If the object is in non-blocking mode and no bytes ++ are available, ``None`` is returned. + + .. method:: write(b, /) + +@@ -533,13 +515,6 @@ + this method returns, so the implementation should only access *b* + during the method call. + +- .. warning:: +- +- This function does not ensure all bytes are written or an exception is +- thrown. Callers may implement that behavior by checking the return +- value and, if it is less than the length of *b*, looping with additional +- write calls until all unwritten bytes are written. High-level I/O +- objects like :ref:`binary-io` and :ref:`text-io` implement retry behavior. + + .. class:: BufferedIOBase + +@@ -668,11 +643,7 @@ + .. class:: FileIO(name, mode='r', closefd=True, opener=None) + + A raw binary stream representing an OS-level file containing bytes data. It +- inherits from :class:`RawIOBase` and implements its low-level access design. +- This means :meth:`~RawIOBase.write` does not guarantee all bytes are written +- and :meth:`~RawIOBase.read` may read less bytes than requested even when more +- bytes may be present in the underlying file. To get "write all" and +- "read at least" behavior, use :ref:`binary-io`. ++ inherits from :class:`RawIOBase`. + + The *name* can be one of two things: + +@@ -692,6 +663,10 @@ + implies writing, so this mode behaves in a similar way to ``'w'``. Add a + ``'+'`` to the mode to allow simultaneous reading and writing. + ++ The :meth:`~RawIOBase.read` (when called with a positive argument), ++ :meth:`~RawIOBase.readinto` and :meth:`~RawIOBase.write` methods on this ++ class will only make one system call. ++ + A custom opener can be used by passing a callable as *opener*. The underlying + file descriptor for the file object is then obtained by calling *opener* with + (*name*, *flags*). *opener* must return an open file descriptor (passing +@@ -703,13 +678,6 @@ + See the :func:`open` built-in function for examples on using the *opener* + parameter. + +- .. warning:: +- :class:`FileIO` is a low-level I/O object and members, such as +- :meth:`~RawIOBase.read` and :meth:`~RawIOBase.write`, need to have their +- return values checked explicitly in a retry loop to implement "write all" +- and "read at least" behavior. High-level I/O objects :ref:`binary-io` and +- :ref:`text-io` implement retry behavior. +- + .. versionchanged:: 3.3 + The *opener* parameter was added. + The ``'x'`` mode was added. +@@ -856,9 +824,9 @@ + + .. class:: BufferedRandom(raw, buffer_size=DEFAULT_BUFFER_SIZE) + +- A buffered binary stream implementing :class:`BufferedIOBase` interfaces +- providing higher-level access to a seekable :class:`RawIOBase` raw binary +- stream. ++ A buffered binary stream providing higher-level access to a seekable ++ :class:`RawIOBase` raw binary stream. It inherits from :class:`BufferedReader` ++ and :class:`BufferedWriter`. + + The constructor creates a reader and writer for a seekable raw stream, given + in the first argument. If the *buffer_size* is omitted it defaults to +diff --git a/Doc/library/ipaddress.rst b/Doc/library/ipaddress.rst +index e00e1b2cea4..ed5fffa42bc 100644 +--- a/Doc/library/ipaddress.rst ++++ b/Doc/library/ipaddress.rst +@@ -361,9 +361,9 @@ + + .. attribute:: ipv4_mapped + +- For addresses that appear to be IPv4 mapped addresses in the range +- ``::FFFF:0:0/96`` as defined by :RFC:`4291`, this property reports the +- embedded IPv4 address. For any other address, this property will be ``None``. ++ For addresses that appear to be IPv4 mapped addresses (starting with ++ ``::FFFF/96``), this property will report the embedded IPv4 address. ++ For any other address, this property will be ``None``. + + .. attribute:: scope_id + +diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst +index 47c5326d137..d07003ac2bb 100644 +--- a/Doc/library/itertools.rst ++++ b/Doc/library/itertools.rst +@@ -47,7 +47,7 @@ + Iterator Arguments Results Example + ============================ ============================ ================================================= ============================================================= + :func:`accumulate` p [,func] p0, p0+p1, p0+p1+p2, ... ``accumulate([1,2,3,4,5]) → 1 3 6 10 15`` +-:func:`batched` p, n (p0, p1, ..., p_n-1), ... ``batched('ABCDEFG', n=3) → ABC DEF G`` ++:func:`batched` p, n (p0, p1, ..., p_n-1), ... ``batched('ABCDEFG', n=2) → AB CD EF G`` + :func:`chain` p, q, ... p0, p1, ... plast, q0, q1, ... ``chain('ABC', 'DEF') → A B C D E F`` + :func:`chain.from_iterable` iterable p0, p1, ... plast, q0, q1, ... ``chain.from_iterable(['ABC', 'DEF']) → A B C D E F`` + :func:`compress` data, selectors (d[0] if s[0]), (d[1] if s[1]), ... ``compress('ABCDEF', [1,0,1,0,1,1]) → A C E F`` +@@ -181,7 +181,7 @@ + Roughly equivalent to:: + + def batched(iterable, n, *, strict=False): +- # batched('ABCDEFG', 3) → ABC DEF G ++ # batched('ABCDEFG', 2) → AB CD EF G + if n < 1: + raise ValueError('n must be at least one') + iterator = iter(iterable) +@@ -842,7 +842,7 @@ + from contextlib import suppress + from functools import reduce + from math import comb, prod, sumprod, isqrt +- from operator import itemgetter, getitem, mul, neg, truediv ++ from operator import itemgetter, getitem, mul, neg + + def take(n, iterable): + "Return first n items of the iterable as a list." +@@ -853,10 +853,9 @@ + # prepend(1, [2, 3, 4]) → 1 2 3 4 + return chain([value], iterable) + +- def running_mean(iterable): +- "Yield the average of all values seen so far." +- # running_mean([8.5, 9.5, 7.5, 6.5]) → 8.5 9.0 8.5 8.0 +- return map(truediv, accumulate(iterable), count(1)) ++ def tabulate(function, start=0): ++ "Return function(0), function(1), ..." ++ return map(function, count(start)) + + def repeatfunc(function, times=None, *args): + "Repeat calls to a function with specified arguments." +@@ -934,10 +933,10 @@ + yield element + + def unique(iterable, key=None, reverse=False): +- "Yield unique elements in sorted order. Supports unhashable inputs." +- # unique([[1, 2], [3, 4], [1, 2]]) → [1, 2] [3, 4] +- sequenced = sorted(iterable, key=key, reverse=reverse) +- return unique_justseen(sequenced, key=key) ++ "Yield unique elements in sorted order. Supports unhashable inputs." ++ # unique([[1, 2], [3, 4], [1, 2]]) → [1, 2] [3, 4] ++ sequenced = sorted(iterable, key=key, reverse=reverse) ++ return unique_justseen(sequenced, key=key) + + def sliding_window(iterable, n): + "Collect data into overlapping fixed-length chunks or blocks." +@@ -1211,8 +1210,8 @@ + [(0, 'a'), (1, 'b'), (2, 'c')] + + +- >>> list(running_mean([8.5, 9.5, 7.5, 6.5])) +- [8.5, 9.0, 8.5, 8.0] ++ >>> list(islice(tabulate(lambda x: 2*x), 4)) ++ [0, 2, 4, 6] + + + >>> for _ in loops(5): +@@ -1749,10 +1748,6 @@ + + # Old recipes and their tests which are guaranteed to continue to work. + +- def tabulate(function, start=0): +- "Return function(0), function(1), ..." +- return map(function, count(start)) +- + def old_sumprod_recipe(vec1, vec2): + "Compute a sum of products." + return sum(starmap(operator.mul, zip(vec1, vec2, strict=True))) +@@ -1832,10 +1827,6 @@ + .. doctest:: + :hide: + +- >>> list(islice(tabulate(lambda x: 2*x), 4)) +- [0, 2, 4, 6] +- +- + >>> dotproduct([1,2,3], [4,5,6]) + 32 + +diff --git a/Doc/library/json.rst b/Doc/library/json.rst +index 2a86d2cae6b..e83eefe351c 100644 +--- a/Doc/library/json.rst ++++ b/Doc/library/json.rst +@@ -214,7 +214,7 @@ + a string (such as ``"\t"``) is used to indent each level. + If zero, negative, or ``""`` (the empty string), + only newlines are inserted. +- If ``None`` (the default), no newlines are inserted. ++ If ``None`` (the default), the most compact representation is used. + :type indent: int | str | None + + :param separators: +diff --git a/Doc/library/locale.rst b/Doc/library/locale.rst +index 14a8ec725ec..b591863181d 100644 +--- a/Doc/library/locale.rst ++++ b/Doc/library/locale.rst +@@ -48,19 +48,8 @@ + If *locale* is omitted or ``None``, the current setting for *category* is + returned. + +- Example:: +- +- >>> import locale +- >>> loc = locale.setlocale(locale.LC_ALL) # get current locale +- # use German locale; name and availability varies with platform +- >>> locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8') +- >>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut +- >>> locale.setlocale(locale.LC_ALL, '') # use user's preferred locale +- >>> locale.setlocale(locale.LC_ALL, 'C') # use default (C) locale +- >>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale +- + :func:`setlocale` is not thread-safe on most systems. Applications typically +- start with a call of:: ++ start with a call of :: + + import locale + locale.setlocale(locale.LC_ALL, '') +@@ -575,6 +564,18 @@ + :func:`localeconv`. + + ++Example:: ++ ++ >>> import locale ++ >>> loc = locale.getlocale() # get current locale ++ # use German locale; name might vary with platform ++ >>> locale.setlocale(locale.LC_ALL, 'de_DE') ++ >>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut ++ >>> locale.setlocale(locale.LC_ALL, '') # use user's preferred locale ++ >>> locale.setlocale(locale.LC_ALL, 'C') # use default (C) locale ++ >>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale ++ ++ + Background, details, hints, tips and caveats + -------------------------------------------- + +diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst +index 6b7d858c182..c8552befbbf 100644 +--- a/Doc/library/logging.rst ++++ b/Doc/library/logging.rst +@@ -1011,11 +1011,6 @@ + | exc_info | You shouldn't need to | Exception tuple (à la ``sys.exc_info``) or, | + | | format this yourself. | if no exception has occurred, ``None``. | + +----------------+-------------------------+-----------------------------------------------+ +-| exc_text | You shouldn't need to | Exception information formatted as a string. | +-| | format this yourself. | This is set when :meth:`Formatter.format` is | +-| | | invoked, or ``None`` if no exception has | +-| | | occurred. | +-+----------------+-------------------------+-----------------------------------------------+ + | filename | ``%(filename)s`` | Filename portion of ``pathname``. | + +----------------+-------------------------+-----------------------------------------------+ + | funcName | ``%(funcName)s`` | Name of function containing the logging call. | +diff --git a/Doc/library/mailbox.rst b/Doc/library/mailbox.rst +index ed135bf02cb..62e289573c0 100644 +--- a/Doc/library/mailbox.rst ++++ b/Doc/library/mailbox.rst +@@ -1025,7 +1025,7 @@ + .. method:: remove_flag(flag) + + Unset the flag(s) specified by *flag* without changing other flags. To +- remove more than one flag at a time, *flag* may be a string of more than ++ remove more than one flag at a time, *flag* maybe a string of more than + one character. If "info" contains experimental information rather than + flags, the current "info" is not modified. + +@@ -1190,7 +1190,7 @@ + .. method:: remove_flag(flag) + + Unset the flag(s) specified by *flag* without changing other flags. To +- remove more than one flag at a time, *flag* may be a string of more than ++ remove more than one flag at a time, *flag* maybe a string of more than + one character. + + When an :class:`!mboxMessage` instance is created based upon a +@@ -1562,7 +1562,7 @@ + .. method:: remove_flag(flag) + + Unset the flag(s) specified by *flag* without changing other flags. To +- remove more than one flag at a time, *flag* may be a string of more than ++ remove more than one flag at a time, *flag* maybe a string of more than + one character. + + When an :class:`!MMDFMessage` instance is created based upon a +@@ -1641,7 +1641,7 @@ + + .. exception:: Error() + +- The base class for all other module-specific exceptions. ++ The based class for all other module-specific exceptions. + + + .. exception:: NoSuchMailboxError() +@@ -1661,7 +1661,7 @@ + + Raised when some mailbox-related condition beyond the control of the program + causes it to be unable to proceed, such as when failing to acquire a lock that +- another program already holds, or when a uniquely generated file name ++ another program already holds a lock, or when a uniquely generated file name + already exists. + + +diff --git a/Doc/library/math.rst b/Doc/library/math.rst +index ebf0ea3901b..46d61388f79 100644 +--- a/Doc/library/math.rst ++++ b/Doc/library/math.rst +@@ -321,12 +321,10 @@ + + .. function:: frexp(x) + +- Return the mantissa and exponent of *x* as the pair ``(m, e)``. +- If *x* is a finite nonzero number, then *m* is a float with +- ``0.5 <= abs(m) < 1.0`` and an integer *e* is such that +- ``x == m * 2**e`` exactly. Else, return ``(x, 0)``. +- This is used to "pick apart" the internal representation of +- a float in a portable way. ++ Return the mantissa and exponent of *x* as the pair ``(m, e)``. *m* is a float ++ and *e* is an integer such that ``x == m * 2**e`` exactly. If *x* is zero, ++ returns ``(0.0, 0)``, otherwise ``0.5 <= abs(m) < 1``. This is used to "pick ++ apart" the internal representation of a float in a portable way. + + Note that :func:`frexp` has a different call/return pattern + than its C equivalents: it takes a single argument and return a pair of +diff --git a/Doc/library/msvcrt.rst b/Doc/library/msvcrt.rst +index 79069c136c2..a2c5e375d2c 100644 +--- a/Doc/library/msvcrt.rst ++++ b/Doc/library/msvcrt.rst +@@ -2,6 +2,7 @@ + =========================================================== + + .. module:: msvcrt ++ :platform: Windows + :synopsis: Miscellaneous useful routines from the MS VC++ runtime. + + .. sectionauthor:: Fred L. Drake, Jr. +diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst +index b8dc7341ba8..898ab663a6e 100644 +--- a/Doc/library/multiprocessing.rst ++++ b/Doc/library/multiprocessing.rst +@@ -100,10 +100,10 @@ + For an explanation of why the ``if __name__ == '__main__'`` part is + necessary, see :ref:`multiprocessing-programming`. + +-The arguments to :class:`Process` usually need to be picklable so they can be +-passed to the child process. If you tried typing the above example directly +-into a REPL it could lead to an :exc:`AttributeError` in the child process +-trying to locate the *f* function in the ``__main__`` module. ++The arguments to :class:`Process` usually need to be unpickleable from within ++the child process. If you tried typing the above example directly into a REPL it ++could lead to an :exc:`AttributeError` in the child process trying to locate the ++*f* function in the ``__main__`` module. + + + .. _multiprocessing-start-methods: +@@ -507,21 +507,6 @@ + The :mod:`multiprocessing` package mostly replicates the API of the + :mod:`threading` module. + +-.. _global-start-method: +- +-Global start method +-^^^^^^^^^^^^^^^^^^^ +- +-Python supports several ways to create and initialize a process. +-The global start method sets the default mechanism for creating a process. +- +-Several multiprocessing functions and methods that may also instantiate +-certain objects will implicitly set the global start method to the system's default, +-if it hasn’t been set already. The global start method can only be set once. +-If you need to change the start method from the system default, you must +-proactively set the global start method before calling functions or methods, +-or creating these objects. +- + + :class:`Process` and exceptions + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +@@ -892,15 +877,11 @@ + locks/semaphores. When a process first puts an item on the queue a feeder + thread is started which transfers objects from a buffer into the pipe. + +- Instantiating this class may set the global start method. See +- :ref:`global-start-method` for more details. +- + The usual :exc:`queue.Empty` and :exc:`queue.Full` exceptions from the + standard library's :mod:`queue` module are raised to signal timeouts. + + :class:`Queue` implements all the methods of :class:`queue.Queue` except for +- :meth:`~queue.Queue.task_done`, :meth:`~queue.Queue.join`, and +- :meth:`~queue.Queue.shutdown`. ++ :meth:`~queue.Queue.task_done` and :meth:`~queue.Queue.join`. + + .. method:: qsize() + +@@ -1011,9 +992,6 @@ + + It is a simplified :class:`Queue` type, very close to a locked :class:`Pipe`. + +- Instantiating this class may set the global start method. See +- :ref:`global-start-method` for more details. +- + .. method:: close() + + Close the queue: release internal resources. +@@ -1044,9 +1022,6 @@ + :class:`JoinableQueue`, a :class:`Queue` subclass, is a queue which + additionally has :meth:`task_done` and :meth:`join` methods. + +- Instantiating this class may set the global start method. See +- :ref:`global-start-method` for more details. +- + .. method:: task_done() + + Indicate that a formerly enqueued task is complete. Used by queue +@@ -1159,8 +1134,8 @@ + :mod:`multiprocessing` module. + + If *method* is ``None`` then the default context is returned. Note that if +- the global start method has not been set, this will set it to the system default +- See :ref:`global-start-method` for more details. ++ the global start method has not been set, this will set it to the ++ default method. + Otherwise *method* should be ``'fork'``, ``'spawn'``, + ``'forkserver'``. :exc:`ValueError` is raised if the specified + start method is not available. See :ref:`multiprocessing-start-methods`. +@@ -1171,9 +1146,10 @@ + + Return the name of start method used for starting processes. + +- If the global start method is not set and *allow_none* is ``False``, the global start +- method is set to the default, and its name is returned. See +- :ref:`global-start-method` for more details. ++ If the global start method has not been set and *allow_none* is ++ ``False``, then the start method is set to the default and the name ++ is returned. If the start method has not been set and *allow_none* is ++ ``True`` then ``None`` is returned. + + The return value can be ``'fork'``, ``'spawn'``, ``'forkserver'`` + or ``None``. See :ref:`multiprocessing-start-methods`. +@@ -1190,7 +1166,7 @@ + + Set the path of the Python interpreter to use when starting a child process. + (By default :data:`sys.executable` is used). Embedders will probably need to +- do something like :: ++ do some thing like :: + + set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe')) + +@@ -1293,12 +1269,12 @@ + Note that multiple connection objects may be polled at once by + using :func:`multiprocessing.connection.wait`. + +- .. method:: send_bytes(buf[, offset[, size]]) ++ .. method:: send_bytes(buffer[, offset[, size]]) + + Send byte data from a :term:`bytes-like object` as a complete message. + +- If *offset* is given then data is read from that position in *buf*. If +- *size* is given then that many bytes will be read from *buf*. Very large ++ If *offset* is given then data is read from that position in *buffer*. If ++ *size* is given then that many bytes will be read from buffer. Very large + buffers (approximately 32 MiB+, though it depends on the OS) may raise a + :exc:`ValueError` exception + +@@ -1318,18 +1294,18 @@ + alias of :exc:`OSError`. + + +- .. method:: recv_bytes_into(buf[, offset]) ++ .. method:: recv_bytes_into(buffer[, offset]) + +- Read into *buf* a complete message of byte data sent from the other end ++ Read into *buffer* a complete message of byte data sent from the other end + of the connection and return the number of bytes in the message. Blocks + until there is something to receive. Raises + :exc:`EOFError` if there is nothing left to receive and the other end was + closed. + +- *buf* must be a writable :term:`bytes-like object`. If ++ *buffer* must be a writable :term:`bytes-like object`. If + *offset* is given then the message will be written into the buffer from + that position. Offset must be a non-negative integer less than the +- length of *buf* (in bytes). ++ length of *buffer* (in bytes). + + If the buffer is too short then a :exc:`BufferTooShort` exception is + raised and the complete message is available as ``e.args[0]`` where ``e`` +@@ -1400,9 +1376,6 @@ + + A barrier object: a clone of :class:`threading.Barrier`. + +- Instantiating this class may set the global start method. See +- :ref:`global-start-method` for more details. +- + .. versionadded:: 3.3 + + .. class:: BoundedSemaphore([value]) +@@ -1410,9 +1383,6 @@ + A bounded semaphore object: a close analog of + :class:`threading.BoundedSemaphore`. + +- Instantiating this class may set the global start method. See +- :ref:`global-start-method` for more details. +- + A solitary difference from its close analog exists: its ``acquire`` method's + first argument is named *block*, as is consistent with :meth:`Lock.acquire`. + +@@ -1427,9 +1397,6 @@ + If *lock* is specified then it should be a :class:`Lock` or :class:`RLock` + object from :mod:`multiprocessing`. + +- Instantiating this class may set the global start method. See +- :ref:`global-start-method` for more details. +- + .. versionchanged:: 3.3 + The :meth:`~threading.Condition.wait_for` method was added. + +@@ -1437,8 +1404,6 @@ + + A clone of :class:`threading.Event`. + +- Instantiating this class may set the global start method. See +- :ref:`global-start-method` for more details. + + .. class:: Lock() + +@@ -1454,9 +1419,6 @@ + instance of ``multiprocessing.synchronize.Lock`` initialized with a + default context. + +- Instantiating this class may set the global start method. See +- :ref:`global-start-method` for more details. +- + :class:`Lock` supports the :term:`context manager` protocol and thus may be + used in :keyword:`with` statements. + +@@ -1507,9 +1469,6 @@ + instance of ``multiprocessing.synchronize.RLock`` initialized with a + default context. + +- Instantiating this class may set the global start method. See +- :ref:`global-start-method` for more details. +- + :class:`RLock` supports the :term:`context manager` protocol and thus may be + used in :keyword:`with` statements. + +@@ -1562,9 +1521,6 @@ + + A semaphore object: a close analog of :class:`threading.Semaphore`. + +- Instantiating this class may set the global start method. See +- :ref:`global-start-method` for more details. +- + A solitary difference from its close analog exists: its ``acquire`` method's + first argument is named *block*, as is consistent with :meth:`Lock.acquire`. + +@@ -1625,14 +1581,11 @@ + value is actually a synchronized wrapper for the array. + + *typecode_or_type* determines the type of the elements of the returned array: +- it is either a :ref:`ctypes type ` or a one +- character typecode of the kind used by the :mod:`array` module with the +- exception of ``'w'``, which is not supported. In addition, the ``'c'`` +- typecode is an alias for :class:`ctypes.c_char`. If *size_or_initializer* +- is an integer, then it determines the length of the array, and the array +- will be initially zeroed. Otherwise, *size_or_initializer* is a sequence +- which is used to initialize the array and whose length determines the length +- of the array. ++ it is either a ctypes type or a one character typecode of the kind used by ++ the :mod:`array` module. If *size_or_initializer* is an integer, then it ++ determines the length of the array, and the array will be initially zeroed. ++ Otherwise, *size_or_initializer* is a sequence which is used to initialize ++ the array and whose length determines the length of the array. + + If *lock* is ``True`` (the default) then a new lock object is created to + synchronize access to the value. If *lock* is a :class:`Lock` or +@@ -1644,10 +1597,7 @@ + Note that *lock* is a keyword only argument. + + Note that an array of :data:`ctypes.c_char` has *value* and *raw* +- attributes which can both be used to store and retrieve byte strings. +- While *raw* allows interaction with a :class:`bytes` object the full size of +- the array, reading *value* will terminate after a null byte, like most +- programming languages handle strings. ++ attributes which allow one to use it to store and retrieve strings. + + + The :mod:`multiprocessing.sharedctypes` module +@@ -1699,7 +1649,7 @@ + attributes which allow one to use it to store and retrieve strings -- see + documentation for :mod:`ctypes`. + +-.. function:: Array(typecode_or_type, size_or_initializer, *, lock=True, ctx=None) ++.. function:: Array(typecode_or_type, size_or_initializer, *, lock=True) + + The same as :func:`RawArray` except that depending on the value of *lock* a + process-safe synchronization wrapper may be returned instead of a raw ctypes +@@ -1713,13 +1663,9 @@ + automatically protected by a lock, so it will not necessarily be + "process-safe". + +- *ctx* is a context object, or ``None`` (use the current context). If ``None``, +- calling this may set the global start method. See +- :ref:`global-start-method` for more details. +- +- Note that *lock* and *ctx* are keyword-only parameters. ++ Note that *lock* is a keyword-only argument. + +-.. function:: Value(typecode_or_type, *args, lock=True, ctx=None) ++.. function:: Value(typecode_or_type, *args, lock=True) + + The same as :func:`RawValue` except that depending on the value of *lock* a + process-safe synchronization wrapper may be returned instead of a raw ctypes +@@ -1732,27 +1678,19 @@ + automatically protected by a lock, so it will not necessarily be + "process-safe". + +- *ctx* is a context object, or ``None`` (use the current context). If ``None``, +- calling this may set the global start method. See +- :ref:`global-start-method` for more details. +- +- Note that *lock* and *ctx* are keyword-only parameters. ++ Note that *lock* is a keyword-only argument. + + .. function:: copy(obj) + + Return a ctypes object allocated from shared memory which is a copy of the + ctypes object *obj*. + +-.. function:: synchronized(obj, lock=None, ctx=None) ++.. function:: synchronized(obj[, lock]) + + Return a process-safe wrapper object for a ctypes object which uses *lock* to + synchronize access. If *lock* is ``None`` (the default) then a + :class:`multiprocessing.RLock` object is created automatically. + +- *ctx* is a context object, or ``None`` (use the current context). If ``None``, +- calling this may set the global start method. See +- :ref:`global-start-method` for more details. +- + A synchronized wrapper will have two methods in addition to those of the + object it wraps: :meth:`get_obj` returns the wrapped object and + :meth:`get_lock` returns the lock object used for synchronization. +@@ -1870,9 +1808,8 @@ + *serializer* must be ``'pickle'`` (use :mod:`pickle` serialization) or + ``'xmlrpclib'`` (use :mod:`xmlrpc.client` serialization). + +- *ctx* is a context object, or ``None`` (use the current context). If ``None``, +- calling this may set the global start method. See +- :ref:`global-start-method` for more details. ++ *ctx* is a context object, or ``None`` (use the current context). See the ++ :func:`get_context` function. + + *shutdown_timeout* is a timeout in seconds used to wait until the process + used by the manager completes in the :meth:`shutdown` method. If the +@@ -2356,9 +2293,7 @@ + the worker processes. Usually a pool is created using the + function :func:`multiprocessing.Pool` or the :meth:`Pool` method + of a context object. In both cases *context* is set +- appropriately. If ``None``, calling this function will have the side effect +- of setting the current global start method if it has not been set already. +- See the :func:`get_context` function. ++ appropriately. + + Note that the methods of the pool object should only be called by + the process which created the pool. +@@ -2389,7 +2324,7 @@ + duration of the Pool's work queue. A frequent pattern found in other + systems (such as Apache, mod_wsgi, etc) to free resources held by + workers is to allow a worker within a pool to complete only a set +- amount of work before exiting, being cleaned up and a new ++ amount of work before being exiting, being cleaned up and a new + process spawned to replace the old one. The *maxtasksperchild* + argument to the :class:`Pool` exposes this ability to the end user. + +@@ -2832,16 +2767,6 @@ + + Suitable authentication keys can also be generated by using :func:`os.urandom`. + +-This authentication protects :class:`Listener` and :func:`Client` connections, +-which are reachable by address. It is not applied to the anonymous pipes +-created by :func:`~multiprocessing.Pipe` or used internally by +-:class:`~multiprocessing.Queue`. +-:mod:`multiprocessing` treats all local processes running as the same user as +-trusted; on most operating systems such processes can access each other's pipe +-file descriptors regardless. Applications that require isolation between +-processes of the same user must arrange it at the operating-system level -- +-for example, by running workers under a different user account or in a sandbox. +- + + Logging + ^^^^^^^ +diff --git a/Doc/library/operator.rst b/Doc/library/operator.rst +index 9f291309a75..a9a6026af40 100644 +--- a/Doc/library/operator.rst ++++ b/Doc/library/operator.rst +@@ -98,7 +98,7 @@ + .. function:: and_(a, b) + __and__(a, b) + +- Return ``a & b``. ++ Return the bitwise and of *a* and *b*. + + + .. function:: floordiv(a, b) +@@ -122,13 +122,13 @@ + __inv__(obj) + __invert__(obj) + +- Return ``~obj``. ++ Return the bitwise inverse of the number *obj*. This is equivalent to ``~obj``. + + + .. function:: lshift(a, b) + __lshift__(a, b) + +- Return ``a << b``. ++ Return *a* shifted left by *b*. + + + .. function:: mod(a, b) +@@ -140,7 +140,7 @@ + .. function:: mul(a, b) + __mul__(a, b) + +- Return ``a * b``. ++ Return ``a * b``, for *a* and *b* numbers. + + + .. function:: matmul(a, b) +@@ -160,25 +160,25 @@ + .. function:: or_(a, b) + __or__(a, b) + +- Return ``a | b``. ++ Return the bitwise or of *a* and *b*. + + + .. function:: pos(obj) + __pos__(obj) + +- Return ``+obj``. ++ Return *obj* positive (``+obj``). + + + .. function:: pow(a, b) + __pow__(a, b) + +- Return ``a ** b``. ++ Return ``a ** b``, for *a* and *b* numbers. + + + .. function:: rshift(a, b) + __rshift__(a, b) + +- Return ``a >> b``. ++ Return *a* shifted right by *b*. + + + .. function:: sub(a, b) +@@ -197,7 +197,7 @@ + .. function:: xor(a, b) + __xor__(a, b) + +- Return ``a ^ b``. ++ Return the bitwise exclusive or of *a* and *b*. + + + Operations which work with sequences (some of them with mappings too) include: +@@ -391,18 +391,13 @@ + +-----------------------+-------------------------+---------------------------------------+ + | Division | ``a // b`` | ``floordiv(a, b)`` | + +-----------------------+-------------------------+---------------------------------------+ +-| Bitwise And, or | ``a & b`` | ``and_(a, b)`` | +-| Intersection | | | ++| Bitwise And | ``a & b`` | ``and_(a, b)`` | + +-----------------------+-------------------------+---------------------------------------+ +-| Bitwise Exclusive Or, | ``a ^ b`` | ``xor(a, b)`` | +-| or Symmetric | | | +-| Difference | | | ++| Bitwise Exclusive Or | ``a ^ b`` | ``xor(a, b)`` | + +-----------------------+-------------------------+---------------------------------------+ +-| Bitwise Inversion, or | ``~ a`` | ``invert(a)`` | +-| Complement | | | ++| Bitwise Inversion | ``~ a`` | ``invert(a)`` | + +-----------------------+-------------------------+---------------------------------------+ +-| Bitwise Or, or | ``a | b`` | ``or_(a, b)`` | +-| Union | | | ++| Bitwise Or | ``a | b`` | ``or_(a, b)`` | + +-----------------------+-------------------------+---------------------------------------+ + | Exponentiation | ``a ** b`` | ``pow(a, b)`` | + +-----------------------+-------------------------+---------------------------------------+ +diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst +index b9cfc527338..e8a9de5cadb 100644 +--- a/Doc/library/os.path.rst ++++ b/Doc/library/os.path.rst +@@ -57,9 +57,8 @@ + .. function:: abspath(path) + + Return a normalized absolutized version of the pathname *path*. On most +- platforms, this is equivalent to calling ``normpath(join(os.getcwd(), path))``. +- +- .. seealso:: :func:`os.path.join` and :func:`os.path.normpath`. ++ platforms, this is equivalent to calling the function :func:`normpath` as ++ follows: ``normpath(join(os.getcwd(), path))``. + + .. versionchanged:: 3.6 + Accepts a :term:`path-like object`. +@@ -97,17 +96,15 @@ + + .. function:: commonprefix(list, /) + +- Return the longest string prefix (taken character-by-character) that is a +- prefix of all strings in *list*. If *list* is empty, return the empty string ++ Return the longest path prefix (taken character-by-character) that is a ++ prefix of all paths in *list*. If *list* is empty, return the empty string + (``''``). + +- .. warning:: ++ .. note:: + + This function may return invalid paths because it works a +- character at a time. +- If you need a **common path prefix**, then the algorithm +- implemented in this function is not secure. Use +- :func:`commonpath` for finding a common path prefix. ++ character at a time. To obtain a valid path, see ++ :func:`commonpath`. + + :: + +@@ -246,8 +243,6 @@ + begins with a slash, on Windows that it begins with two (back)slashes, or a + drive letter, colon, and (back)slash together. + +- .. seealso:: :func:`abspath` +- + .. versionchanged:: 3.6 + Accepts a :term:`path-like object`. + +@@ -362,28 +357,14 @@ + concatenation of *path* and all members of *\*paths*, with exactly one + directory separator following each non-empty part, except the last. That is, + the result will only end in a separator if the last part is either empty or +- ends in a separator. +- +- If a segment is an absolute path (which on Windows requires both a drive and +- a root), then all previous segments are ignored and joining continues from the +- absolute path segment. On Linux, for example:: +- +- >>> os.path.join('/home/foo', 'bar') +- '/home/foo/bar' +- >>> os.path.join('/home/foo', '/home/bar') +- '/home/bar' ++ ends in a separator. If a segment is an absolute path (which on Windows ++ requires both a drive and a root), then all previous segments are ignored and ++ joining continues from the absolute path segment. + + On Windows, the drive is not reset when a rooted path segment (e.g., + ``r'\foo'``) is encountered. If a segment is on a different drive or is an +- absolute path, all previous segments are ignored and the drive is reset. For +- example:: +- +- >>> os.path.join('c:\\', 'foo') +- 'c:\\foo' +- >>> os.path.join('c:\\foo', 'd:\\bar') +- 'd:\\bar' +- +- Note that since there is a current directory for each drive, ++ absolute path, all previous segments are ignored and the drive is reset. Note ++ that since there is a current directory for each drive, + ``os.path.join("c:", "foo")`` represents a path relative to the current + directory on drive :file:`C:` (:file:`c:foo`), not :file:`c:\\foo`. + +@@ -537,8 +518,8 @@ + *path* is empty, both *head* and *tail* are empty. Trailing slashes are + stripped from *head* unless it is the root (one or more slashes only). In + all cases, ``join(head, tail)`` returns a path to the same location as *path* +- (but the strings may differ). Also see the functions :func:`join`, +- :func:`dirname` and :func:`basename`. ++ (but the strings may differ). Also see the functions :func:`dirname` and ++ :func:`basename`. + + .. versionchanged:: 3.6 + Accepts a :term:`path-like object`. +diff --git a/Doc/library/os.rst b/Doc/library/os.rst +index 7b5cc4be5c0..df8c2e582de 100644 +--- a/Doc/library/os.rst ++++ b/Doc/library/os.rst +@@ -1271,8 +1271,8 @@ + + This function is intended for low-level I/O. For normal usage, use the + built-in function :func:`open`, which returns a :term:`file object` with +- :meth:`~io.BufferedIOBase.read` and :meth:`~io.BufferedIOBase.write` methods. +- To wrap a file descriptor in a file object, use :func:`fdopen`. ++ :meth:`~file.read` and :meth:`~file.write` methods (and many more). To ++ wrap a file descriptor in a file object, use :func:`fdopen`. + + .. versionchanged:: 3.3 + Added the *dir_fd* parameter. +@@ -1626,7 +1626,7 @@ + descriptor as returned by :func:`os.open` or :func:`pipe`. To read a + "file object" returned by the built-in function :func:`open` or by + :func:`popen` or :func:`fdopen`, or :data:`sys.stdin`, use its +- :meth:`~io.TextIOBase.read` or :meth:`~io.IOBase.readline` methods. ++ :meth:`~file.read` or :meth:`~file.readline` methods. + + .. versionchanged:: 3.5 + If the system call is interrupted and the signal handler does not raise an +@@ -1815,7 +1815,7 @@ + descriptor as returned by :func:`os.open` or :func:`pipe`. To write a "file + object" returned by the built-in function :func:`open` or by :func:`popen` or + :func:`fdopen`, or :data:`sys.stdout` or :data:`sys.stderr`, use its +- :meth:`~io.TextIOBase.write` method. ++ :meth:`~file.write` method. + + .. versionchanged:: 3.5 + If the system call is interrupted and the signal handler does not raise an +@@ -1889,8 +1889,7 @@ + created by Python are non-inheritable by default. + + On UNIX, non-inheritable file descriptors are closed in child processes at the +-execution of a new program, other file descriptors are inherited. Note that +-non-inheritable file descriptors are still *inherited* by child processes on :func:`os.fork`. ++execution of a new program, other file descriptors are inherited. + + On Windows, non-inheritable handles and file descriptors are closed in child + processes, except for standard streams (file descriptors 0, 1 and 2: stdin, stdout +@@ -2864,9 +2863,6 @@ + To be directly usable as a :term:`path-like object`, ``os.DirEntry`` + implements the :class:`PathLike` interface. + +- :class:`!DirEntry` objects are :ref:`generic ` over the type of the +- path (:class:`str` or :class:`bytes`). +- + Attributes and methods on a ``os.DirEntry`` instance are as follows: + + .. attribute:: name +@@ -3810,7 +3806,7 @@ + import os + + # semaphore with start value '1' +- fd = os.eventfd(1, os.EFD_SEMAPHORE | os.EFD_CLOEXEC) ++ fd = os.eventfd(1, os.EFD_SEMAPHORE | os.EFC_CLOEXEC) + try: + # acquire semaphore + v = os.eventfd_read(fd) +@@ -3919,7 +3915,7 @@ + except it includes any time that the system is suspended. + + The file descriptor's behaviour can be modified by specifying a *flags* value. +- Any of the following variables may be used, combined using bitwise OR ++ Any of the following variables may used, combined using bitwise OR + (the ``|`` operator): + + - :const:`TFD_NONBLOCK` +@@ -3951,7 +3947,7 @@ + *fd* must be a valid timer file descriptor. + + The timer's behaviour can be modified by specifying a *flags* value. +- Any of the following variables may be used, combined using bitwise OR ++ Any of the following variables may used, combined using bitwise OR + (the ``|`` operator): + + - :const:`TFD_TIMER_ABSTIME` +@@ -4020,7 +4016,7 @@ + + Return a two-item tuple of floats (``next_expiration``, ``interval``). + +- ``next_expiration`` denotes the relative time until the timer next fires, ++ ``next_expiration`` denotes the relative time until next the timer next fires, + regardless of if the :const:`TFD_TIMER_ABSTIME` flag is set. + + ``interval`` denotes the timer's interval. +@@ -4256,7 +4252,7 @@ + The current process is replaced immediately. Open file objects and + descriptors are not flushed, so if there may be data buffered + on these open files, you should flush them using +- :func:`~io.IOBase.flush` or :func:`os.fsync` before calling an ++ :func:`sys.stdout.flush` or :func:`os.fsync` before calling an + :func:`exec\* ` function. + + The "l" and "v" variants of the :func:`exec\* ` functions differ in how +@@ -5527,7 +5523,7 @@ + + .. versionchanged:: 3.13 + If :option:`-X cpu_count <-X>` is given or :envvar:`PYTHON_CPU_COUNT` is set, +- :func:`cpu_count` returns the override value *n*. ++ :func:`cpu_count` returns the overridden value *n*. + + + .. function:: getloadavg() +@@ -5549,7 +5545,7 @@ + in the **system**. + + If :option:`-X cpu_count <-X>` is given or :envvar:`PYTHON_CPU_COUNT` is set, +- :func:`process_cpu_count` returns the override value *n*. ++ :func:`process_cpu_count` returns the overridden value *n*. + + See also the :func:`sched_getaffinity` function. + +diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst +index 11ff4c4bbd4..59a72a95559 100644 +--- a/Doc/library/pathlib.rst ++++ b/Doc/library/pathlib.rst +@@ -1287,10 +1287,6 @@ + PosixPath('setup.py'), + PosixPath('test_pathlib.py')] + +- .. note:: +- The paths are returned in no particular order. +- If you need a specific order, sort the results. +- + .. seealso:: + :ref:`pathlib-pattern-language` documentation. + +@@ -1303,11 +1299,6 @@ + ``False``, this method follows symlinks except when expanding "``**``" + wildcards. Set *recurse_symlinks* to ``True`` to always follow symlinks. + +- .. note:: +- Any :exc:`OSError` exceptions raised from scanning the filesystem are +- suppressed. This includes :exc:`PermissionError` when accessing +- directories without read permission. +- + .. audit-event:: pathlib.Path.glob self,pattern pathlib.Path.glob + + .. versionchanged:: 3.12 +@@ -1330,15 +1321,6 @@ + Glob the given relative *pattern* recursively. This is like calling + :func:`Path.glob` with "``**/``" added in front of the *pattern*. + +- .. note:: +- The paths are returned in no particular order. +- If you need a specific order, sort the results. +- +- .. note:: +- Any :exc:`OSError` exceptions raised from scanning the filesystem are +- suppressed. This includes :exc:`PermissionError` when accessing +- directories without read permission. +- + .. seealso:: + :ref:`pathlib-pattern-language` and :meth:`Path.glob` documentation. + +diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst +index fd2b5ceffa0..bacc4b9c59d 100644 +--- a/Doc/library/pickle.rst ++++ b/Doc/library/pickle.rst +@@ -56,10 +56,23 @@ + + The :mod:`pickle` module differs from :mod:`marshal` in several significant ways: + ++* The :mod:`pickle` module keeps track of the objects it has already serialized, ++ so that later references to the same object won't be serialized again. ++ :mod:`marshal` doesn't do this. ++ ++ This has implications both for recursive objects and object sharing. Recursive ++ objects are objects that contain references to themselves. These are not ++ handled by marshal, and in fact, attempting to marshal recursive objects will ++ crash your Python interpreter. Object sharing happens when there are multiple ++ references to the same object in different places in the object hierarchy being ++ serialized. :mod:`pickle` stores such objects only once, and ensures that all ++ other references point to the master copy. Shared objects remain shared, which ++ can be very important for mutable objects. ++ + * :mod:`marshal` cannot be used to serialize user-defined classes and their + instances. :mod:`pickle` can save and restore class instances transparently, + however the class definition must be importable and live in the same module as +- when the object was pickled. ++ when the object was stored. + + * The :mod:`marshal` serialization format is not guaranteed to be portable + across Python versions. Because its primary job in life is to support +@@ -503,7 +516,7 @@ + + * classes accessible from the top level of a module; + +-* instances of such classes for which the result of calling :meth:`~object.__getstate__` ++* instances of such classes whose the result of calling :meth:`~object.__getstate__` + is picklable (see section :ref:`pickle-inst` for details). + + Attempts to pickle unpicklable objects will raise the :exc:`PicklingError` +@@ -572,7 +585,7 @@ + + .. method:: object.__getnewargs_ex__() + +- In protocols 2 and newer, classes that implement the ++ In protocols 2 and newer, classes that implements the + :meth:`__getnewargs_ex__` method can dictate the values passed to the + :meth:`__new__` method upon unpickling. The method must return a pair + ``(args, kwargs)`` where *args* is a tuple of positional arguments +@@ -680,10 +693,7 @@ + If a string is returned, the string should be interpreted as the name of a + global variable. It should be the object's local name relative to its + module; the pickle module searches the module namespace to determine the +- object's module: for a given ``obj`` to be pickled, the ``__module__`` +- attribute is looked up on ``obj`` directly, which falls back to a lookup +- on the type of ``obj`` if no ``__module__`` instance attribute is set. +- This behaviour is typically useful for singletons. ++ object's module. This behaviour is typically useful for singletons. + + When a tuple is returned, it must be between two and six items long. + Optional items can either be omitted, or ``None`` can be provided as their +diff --git a/Doc/library/pkgutil.rst b/Doc/library/pkgutil.rst +index c791ad5de26..b17a317244d 100644 +--- a/Doc/library/pkgutil.rst ++++ b/Doc/library/pkgutil.rst +@@ -191,48 +191,24 @@ + :meth:`get_data ` API. The + *package* argument should be the name of a package, in standard module format + (``foo.bar``). The *resource* argument should be in the form of a relative +- filename, using ``/`` as the path separator. ++ filename, using ``/`` as the path separator. The parent directory name ++ ``..`` is not allowed, and nor is a rooted name (starting with a ``/``). + + The function returns a binary string that is the contents of the specified + resource. + +- This function uses the :term:`loader` method +- :func:`~importlib.abc.FileLoader.get_data` +- to support modules installed in the filesystem, but also in zip files, +- databases, or elsewhere. +- + For packages located in the filesystem, which have already been imported, + this is the rough equivalent of:: + + d = os.path.dirname(sys.modules[package].__file__) + data = open(os.path.join(d, resource), 'rb').read() + +- Like the :func:`open` function, :func:`!get_data` can follow parent +- directories (``../``) and absolute paths (starting with ``/`` or ``C:/``, +- for example). +- It can open compilation/installation artifacts like ``.py`` and ``.pyc`` +- files or files with :func:`reserved filenames `. +- To be compatible with non-filesystem loaders, avoid using these features. +- +- .. warning:: +- +- This function is intended for trusted input. +- It does not verify that *resource* "belongs" to *package*. +- +- If you use a user-provided *resource* path, consider verifying it. +- For example, require an alphanumeric filename with a known extension, or +- install and check a list of known resources. +- + If the package cannot be located or loaded, or it uses a :term:`loader` + which does not support :meth:`get_data `, + then ``None`` is returned. In particular, the :term:`loader` for + :term:`namespace packages ` does not support + :meth:`get_data `. + +- .. seealso:: +- +- The :mod:`importlib.resources` module provides structured access to +- module resources. + + .. function:: resolve_name(name) + +diff --git a/Doc/library/plistlib.rst b/Doc/library/plistlib.rst +index 41802ada7e1..415c4b45c4f 100644 +--- a/Doc/library/plistlib.rst ++++ b/Doc/library/plistlib.rst +@@ -184,7 +184,7 @@ + + Generating a plist:: + +- import datetime as dt ++ import datetime + import plistlib + + pl = dict( +@@ -200,7 +200,7 @@ + ), + someData = b"", + someMoreData = b"" * 10, +- aDate = dt.datetime.now() ++ aDate = datetime.datetime.now() + ) + print(plistlib.dumps(pl).decode()) + +diff --git a/Doc/library/posix.rst b/Doc/library/posix.rst +index 84d757df6bd..14ab3e91e8a 100644 +--- a/Doc/library/posix.rst ++++ b/Doc/library/posix.rst +@@ -2,6 +2,7 @@ + ==================================================== + + .. module:: posix ++ :platform: Unix + :synopsis: The most common POSIX system calls (normally used via module os). + + -------------- +diff --git a/Doc/library/pty.rst b/Doc/library/pty.rst +index 70404174999..1a44bb13a84 100644 +--- a/Doc/library/pty.rst ++++ b/Doc/library/pty.rst +@@ -2,6 +2,7 @@ + ========================================= + + .. module:: pty ++ :platform: Unix + :synopsis: Pseudo-Terminal Handling for Unix. + + .. moduleauthor:: Steen Lumholt +diff --git a/Doc/library/pwd.rst b/Doc/library/pwd.rst +index 7691fed2c7c..e1ff3291213 100644 +--- a/Doc/library/pwd.rst ++++ b/Doc/library/pwd.rst +@@ -2,6 +2,7 @@ + ===================================== + + .. module:: pwd ++ :platform: Unix + :synopsis: The password database (getpwnam() and friends). + + -------------- +diff --git a/Doc/library/pydoc.rst b/Doc/library/pydoc.rst +index a59793c2515..e8f153ee1b3 100644 +--- a/Doc/library/pydoc.rst ++++ b/Doc/library/pydoc.rst +@@ -71,11 +71,6 @@ + documentation at ``http://localhost:1234/`` in your preferred web browser. + Specifying ``0`` as the port number will select an arbitrary unused port. + +-.. warning:: +- +- The :mod:`!pydoc` HTTP server is intended for local use during +- development and is not suitable for production use. +- + :program:`python -m pydoc -n ` will start the server listening at the given + hostname. By default the hostname is 'localhost' but if you want the server to + be reached from other machines, you may want to change the host name that the +diff --git a/Doc/library/pyexpat.rst b/Doc/library/pyexpat.rst +index ea8e3eca52d..c46870a90a2 100644 +--- a/Doc/library/pyexpat.rst ++++ b/Doc/library/pyexpat.rst +@@ -238,71 +238,16 @@ + .. versionadded:: 3.13 + + +-:class:`!xmlparser` objects have the following methods to tune protections +-against some common XML vulnerabilities. +- +-.. method:: xmlparser.SetBillionLaughsAttackProtectionActivationThreshold(threshold, /) +- +- Sets the number of output bytes needed to activate protection against +- `billion laughs`_ attacks. +- +- The number of output bytes includes amplification from entity expansion +- and reading DTD files. +- +- Parser objects usually have a protection activation threshold of 8 MiB, +- but the actual default value depends on the underlying Expat library. +- +- An :exc:`ExpatError` is raised if this method is called on a +- |xml-non-root-parser| parser. +- The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset` +- should not be used as they may have no special meaning. +- +- .. note:: +- +- Activation thresholds below 4 MiB are known to break support for DITA 1.3 +- payload and are hence not recommended. +- +- .. versionadded:: 3.13.14 +- +-.. method:: xmlparser.SetBillionLaughsAttackProtectionMaximumAmplification(max_factor, /) +- +- Sets the maximum tolerated amplification factor for protection against +- `billion laughs`_ attacks. +- +- The amplification factor is calculated as ``(direct + indirect) / direct`` +- while parsing, where ``direct`` is the number of bytes read from +- the primary document in parsing and ``indirect`` is the number of +- bytes added by expanding entities and reading of external DTD files. +- +- The *max_factor* value must be a non-NaN :class:`float` value greater than +- or equal to 1.0. Peak amplifications of factor 15,000 for the entire payload +- and of factor 30,000 in the middle of parsing have been observed with small +- benign files in practice. In particular, the activation threshold should be +- carefully chosen to avoid false positives. +- +- Parser objects usually have a maximum amplification factor of 100, +- but the actual default value depends on the underlying Expat library. +- +- An :exc:`ExpatError` is raised if this method is called on a +- |xml-non-root-parser| parser or if *max_factor* is outside the valid range. +- The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset` +- should not be used as they may have no special meaning. +- +- .. note:: +- +- The maximum amplification factor is only considered if the threshold +- that can be adjusted by :meth:`.SetBillionLaughsAttackProtectionActivationThreshold` +- is exceeded. +- +- .. versionadded:: 3.13.14 ++:class:`!xmlparser` objects have the following methods to mitigate some ++common XML vulnerabilities. + + .. method:: xmlparser.SetAllocTrackerActivationThreshold(threshold, /) + + Sets the number of allocated bytes of dynamic memory needed to activate + protection against disproportionate use of RAM. + +- Parser objects usually have an allocation activation threshold of 64 MiB, +- but the actual default value depends on the underlying Expat library. ++ By default, parser objects have an allocation activation threshold of 64 MiB, ++ or equivalently 67,108,864 bytes. + + An :exc:`ExpatError` is raised if this method is called on a + |xml-non-root-parser| parser. +@@ -326,8 +271,7 @@ + near the start of parsing even with benign files in practice. In particular, + the activation threshold should be carefully chosen to avoid false positives. + +- Parser objects usually have a maximum amplification factor of 100, +- but the actual default value depends on the underlying Expat library. ++ By default, parser objects have a maximum amplification factor of 100.0. + + An :exc:`ExpatError` is raised if this method is called on a + |xml-non-root-parser| parser or if *max_factor* is outside the valid range. +@@ -465,7 +409,7 @@ + ...``). The *doctypeName* is provided exactly as presented. The *systemId* and + *publicId* parameters give the system and public identifiers if specified, or + ``None`` if omitted. *has_internal_subset* will be true if the document +- contains an internal document declaration subset. This requires Expat version ++ contains and internal document declaration subset. This requires Expat version + 1.2 or newer. + + +@@ -1068,6 +1012,4 @@ + not. See https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl + and https://www.iana.org/assignments/character-sets/character-sets.xhtml. + +- +-.. _billion laughs: https://en.wikipedia.org/wiki/Billion_laughs_attack + .. |xml-non-root-parser| replace:: :ref:`non-root ` +diff --git a/Doc/library/queue.rst b/Doc/library/queue.rst +index c126f31c945..1b75582f0cf 100644 +--- a/Doc/library/queue.rst ++++ b/Doc/library/queue.rst +@@ -76,8 +76,6 @@ + Constructor for an unbounded :abbr:`FIFO (first-in, first-out)` queue. + Simple queues lack advanced functionality such as task tracking. + +- Simple queues are :ref:`generic ` over the type of their items. +- + .. versionadded:: 3.7 + + +diff --git a/Doc/library/random.rst b/Doc/library/random.rst +index fdc14cd04e2..b1120b3a4d8 100644 +--- a/Doc/library/random.rst ++++ b/Doc/library/random.rst +@@ -78,7 +78,7 @@ + instead of the system time (see the :func:`os.urandom` function for details + on availability). + +- If *a* is an int, its absolute value is used directly. ++ If *a* is an int, it is used directly. + + With version 2 (the default), a :class:`str`, :class:`bytes`, or :class:`bytearray` + object gets converted to an :class:`int` and all of its bits are used. +@@ -633,12 +633,11 @@ + from the combinatoric iterators in the :mod:`itertools` module: + + .. testcode:: +- + import random + +- def random_product(*iterables, repeat=1): +- "Random selection from itertools.product(*iterables, repeat=repeat)" +- pools = tuple(map(tuple, iterables)) * repeat ++ def random_product(*args, repeat=1): ++ "Random selection from itertools.product(*args, **kwds)" ++ pools = [tuple(pool) for pool in args] * repeat + return tuple(map(random.choice, pools)) + + def random_permutation(iterable, r=None): +@@ -662,91 +661,6 @@ + indices = sorted(random.choices(range(n), k=r)) + return tuple(pool[i] for i in indices) + +- def random_derangement(iterable): +- "Choose a permutation where no element stays in its original position." +- seq = tuple(iterable) +- if len(seq) < 2: +- if not seq: +- return () +- raise IndexError('No derangments to choose from') +- perm = list(range(len(seq))) +- start = tuple(perm) +- while True: +- random.shuffle(perm) +- if all(p != q for p, q in zip(start, perm)): +- return tuple([seq[i] for i in perm]) +- +-.. doctest:: +- :hide: +- +- >>> import random +- +- +- >>> random.seed(8675309) +- >>> random_product('ABCDEFG', repeat=5) +- ('D', 'B', 'E', 'F', 'E') +- +- +- >>> random.seed(8675309) +- >>> random_permutation('ABCDEFG') +- ('D', 'B', 'E', 'C', 'G', 'A', 'F') +- >>> random_permutation('ABCDEFG', 5) +- ('A', 'G', 'D', 'C', 'B') +- +- +- >>> random.seed(8675309) +- >>> random_combination('ABCDEFG', 7) +- ('A', 'B', 'C', 'D', 'E', 'F', 'G') +- >>> random_combination('ABCDEFG', 6) +- ('A', 'B', 'C', 'D', 'F', 'G') +- >>> random_combination('ABCDEFG', 5) +- ('A', 'B', 'C', 'E', 'F') +- >>> random_combination('ABCDEFG', 4) +- ('B', 'C', 'D', 'G') +- >>> random_combination('ABCDEFG', 3) +- ('B', 'E', 'G') +- >>> random_combination('ABCDEFG', 2) +- ('E', 'G') +- >>> random_combination('ABCDEFG', 1) +- ('C',) +- >>> random_combination('ABCDEFG', 0) +- () +- +- +- >>> random.seed(8675309) +- >>> random_combination_with_replacement('ABCDEFG', 7) +- ('B', 'C', 'D', 'E', 'E', 'E', 'G') +- >>> random_combination_with_replacement('ABCDEFG', 3) +- ('A', 'B', 'E') +- >>> random_combination_with_replacement('ABCDEFG', 2) +- ('A', 'G') +- >>> random_combination_with_replacement('ABCDEFG', 1) +- ('E',) +- >>> random_combination_with_replacement('ABCDEFG', 0) +- () +- +- +- >>> random.seed(8675309) +- >>> random_derangement('') +- () +- >>> random_derangement('A') +- Traceback (most recent call last): +- ... +- IndexError: No derangments to choose from +- >>> random_derangement('AB') +- ('B', 'A') +- >>> random_derangement('ABC') +- ('C', 'A', 'B') +- >>> random_derangement('ABCD') +- ('B', 'A', 'D', 'C') +- >>> random_derangement('ABCDE') +- ('B', 'C', 'A', 'E', 'D') +- >>> # Identical inputs treated as distinct +- >>> identical = 20 +- >>> random_derangement((10, identical, 30, identical)) +- (20, 30, 10, 20) +- +- + The default :func:`.random` returns multiples of 2⁻⁵³ in the range + *0.0 ≤ x < 1.0*. All such numbers are evenly spaced and are exactly + representable as Python floats. However, many other representable +diff --git a/Doc/library/re.rst b/Doc/library/re.rst +index 5c7aadb03da..7a43723e119 100644 +--- a/Doc/library/re.rst ++++ b/Doc/library/re.rst +@@ -1238,9 +1238,6 @@ + + Compiled regular expression object returned by :func:`re.compile`. + +- Patterns are :ref:`generic ` over the type of string they handle +- (:class:`str` or :class:`bytes`). +- + .. versionchanged:: 3.9 + :py:class:`re.Pattern` supports ``[]`` to indicate a Unicode (str) or bytes pattern. + See :ref:`types-genericalias`. +@@ -1384,9 +1381,6 @@ + + Match object returned by successful ``match``\ es and ``search``\ es. + +- Matches are :ref:`generic ` over the type of string which was +- matched (:class:`str` or :class:`bytes`). +- + .. versionchanged:: 3.9 + :py:class:`re.Match` supports ``[]`` to indicate a Unicode (str) or bytes match. + See :ref:`types-genericalias`. +@@ -1410,10 +1404,10 @@ + result is a single string; if there are multiple arguments, the result is a + tuple with one item per argument. Without arguments, *group1* defaults to zero + (the whole match is returned). If a *groupN* argument is zero, the corresponding +- return value is the entire matching string; if it is a positive integer, it is +- the string matching the corresponding parenthesized group. If a group number is +- negative or larger than the number of groups defined in the pattern, an +- :exc:`IndexError` exception is raised. If a group is contained in a ++ return value is the entire matching string; if it is in the inclusive range ++ [1..99], it is the string matching the corresponding parenthesized group. If a ++ group number is negative or larger than the number of groups defined in the ++ pattern, an :exc:`IndexError` exception is raised. If a group is contained in a + part of the pattern that did not match, the corresponding result is ``None``. + If a group is contained in a part of the pattern that matched multiple times, + the last match is returned. :: +@@ -1886,7 +1880,7 @@ + + class Token(NamedTuple): + type: str +- value: int | float | str ++ value: str + line: int + column: int + +diff --git a/Doc/library/readline.rst b/Doc/library/readline.rst +index 1ece65d03ab..f297bdeec91 100644 +--- a/Doc/library/readline.rst ++++ b/Doc/library/readline.rst +@@ -2,6 +2,7 @@ + =========================================== + + .. module:: readline ++ :platform: Unix + :synopsis: GNU readline support for Python. + + .. sectionauthor:: Skip Montanaro +@@ -25,8 +26,6 @@ + + .. include:: ../includes/wasm-mobile-notavail.rst + +-.. availability:: Unix. +- + .. note:: + + The underlying Readline library API may be implemented by +@@ -373,9 +372,3 @@ + def save_history(self, histfile): + readline.set_history_length(1000) + readline.write_history_file(histfile) +- +-.. note:: +- +- The new :term:`REPL` introduced in version 3.13 doesn't support readline. +- However, readline can still be used by setting the :envvar:`PYTHON_BASIC_REPL` +- environment variable. +diff --git a/Doc/library/resource.rst b/Doc/library/resource.rst +index 357686da00c..512f0852dd5 100644 +--- a/Doc/library/resource.rst ++++ b/Doc/library/resource.rst +@@ -2,6 +2,7 @@ + =============================================== + + .. module:: resource ++ :platform: Unix + :synopsis: An interface to provide resource usage information on the current process. + + .. moduleauthor:: Jeremy Hylton +@@ -302,9 +303,9 @@ + print(getrusage(RUSAGE_SELF)) + + The fields of the return value each describe how a particular system resource +- has been used, e.g. amount of time spent running in user mode or number of times ++ has been used, e.g. amount of time spent running is user mode or number of times + the process was swapped out of main memory. Some values are dependent on the +- clock tick interval, e.g. the amount of memory the process is using. ++ clock tick internal, e.g. the amount of memory the process is using. + + For backward compatibility, the return value is also accessible as a tuple of 16 + elements. +diff --git a/Doc/library/sched.rst b/Doc/library/sched.rst +index 44858c2c987..517dbe8c321 100644 +--- a/Doc/library/sched.rst ++++ b/Doc/library/sched.rst +@@ -119,11 +119,9 @@ + function passed to the constructor) for the next event, then execute it and so + on until there are no more scheduled events. + +- If *blocking* is false, immediately executes all events in the queue which have +- a time value less than or equal to the current *timefunc* value (if any) and +- returns the difference between the current *timefunc* value and the time value +- of the next scheduled event in the scheduler's event queue. If the queue is +- empty, returns ``None``. ++ If *blocking* is false executes the scheduled events due to expire soonest ++ (if any) and then return the deadline of the next scheduled call in the ++ scheduler (if any). + + Either *action* or *delayfunc* can raise an exception. In either case, the + scheduler will maintain a consistent state and propagate the exception. If an +diff --git a/Doc/library/secrets.rst b/Doc/library/secrets.rst +index fadfc60fe93..75dafc54d40 100644 +--- a/Doc/library/secrets.rst ++++ b/Doc/library/secrets.rst +@@ -62,44 +62,39 @@ + tokens, suitable for applications such as password resets, + hard-to-guess URLs, and similar. + +-.. function:: token_bytes(nbytes=None) ++.. function:: token_bytes([nbytes=None]) + + Return a random byte string containing *nbytes* number of bytes. +- +- If *nbytes* is not specified or ``None``, :const:`DEFAULT_ENTROPY` +- is used instead. ++ If *nbytes* is ``None`` or not supplied, a reasonable default is ++ used. + + .. doctest:: + +- >>> token_bytes(16) # doctest: +SKIP ++ >>> token_bytes(16) #doctest:+SKIP + b'\xebr\x17D*t\xae\xd4\xe3S\xb6\xe2\xebP1\x8b' + + +-.. function:: token_hex(nbytes=None) ++.. function:: token_hex([nbytes=None]) + + Return a random text string, in hexadecimal. The string has *nbytes* +- random bytes, each byte converted to two hex digits. +- +- If *nbytes* is not specified or ``None``, :const:`DEFAULT_ENTROPY` +- is used instead. ++ random bytes, each byte converted to two hex digits. If *nbytes* is ++ ``None`` or not supplied, a reasonable default is used. + + .. doctest:: + +- >>> token_hex(16) # doctest: +SKIP ++ >>> token_hex(16) #doctest:+SKIP + 'f9bf78b9a18ce6d46a0cd2b0b86df9da' + +-.. function:: token_urlsafe(nbytes=None) ++.. function:: token_urlsafe([nbytes=None]) + + Return a random URL-safe text string, containing *nbytes* random + bytes. The text is Base64 encoded, so on average each byte results +- in approximately 1.3 characters. +- +- If *nbytes* is not specified or ``None``, :const:`DEFAULT_ENTROPY` +- is used instead. ++ in approximately 1.3 characters. If *nbytes* is ``None`` or not ++ supplied, a reasonable default is used. + + .. doctest:: + +- >>> token_urlsafe(16) # doctest: +SKIP ++ >>> token_urlsafe(16) #doctest:+SKIP + 'Drmhze6EPcv0fN_81Bj-nA' + + +@@ -120,13 +115,11 @@ + as the number of bytes of randomness to use. + + Otherwise, if no argument is provided, or if the argument is ``None``, +-the ``token_*`` functions use :const:`DEFAULT_ENTROPY` instead. ++the ``token_*`` functions will use a reasonable default instead. + +-.. data:: DEFAULT_ENTROPY +- +- Default number of bytes of randomness used by the ``token_*`` functions. ++.. note:: + +- The exact value is subject to change at any time, including during ++ That default is subject to change at any time, including during + maintenance releases. + + +diff --git a/Doc/library/select.rst b/Doc/library/select.rst +index 26fa014c495..2e3db8ebb32 100644 +--- a/Doc/library/select.rst ++++ b/Doc/library/select.rst +@@ -37,7 +37,7 @@ + + .. function:: devpoll() + +- Returns a ``/dev/poll`` ++ (Only supported on Solaris and derivatives.) Returns a ``/dev/poll`` + polling object; see section :ref:`devpoll-objects` below for the + methods supported by devpoll objects. + +@@ -54,11 +54,9 @@ + .. versionchanged:: 3.4 + The new file descriptor is now non-inheritable. + +- .. availability:: Solaris. +- + .. function:: epoll(sizehint=-1, flags=0) + +- Return an edge polling object, ++ (Only supported on Linux 2.5.44 and newer.) Return an edge polling object, + which can be used as Edge or Level Triggered interface for I/O + events. + +@@ -91,22 +89,18 @@ + The *flags* parameter. ``select.EPOLL_CLOEXEC`` is used by default now. + Use :func:`os.set_inheritable` to make the file descriptor inheritable. + +- .. availability:: Linux >= 2.5.44. +- + + .. function:: poll() + +- Returns a polling object, which ++ (Not supported by all operating systems.) Returns a polling object, which + supports registering and unregistering file descriptors, and then polling them + for I/O events; see section :ref:`poll-objects` below for the methods supported + by polling objects. + +- .. availability:: Unix. +- + + .. function:: kqueue() + +- Returns a kernel queue object; see section ++ (Only supported on BSD.) Returns a kernel queue object; see section + :ref:`kqueue-objects` below for the methods supported by kqueue objects. + + The new file descriptor is :ref:`non-inheritable `. +@@ -114,16 +108,12 @@ + .. versionchanged:: 3.4 + The new file descriptor is now non-inheritable. + +- .. availability:: BSD, macOS. +- + + .. function:: kevent(ident, filter=KQ_FILTER_READ, flags=KQ_EV_ADD, fflags=0, data=0, udata=0) + +- Returns a kernel event object; see section ++ (Only supported on BSD.) Returns a kernel event object; see section + :ref:`kevent-objects` below for the methods supported by kevent objects. + +- .. availability:: BSD, macOS. +- + + .. function:: select(rlist, wlist, xlist, timeout=None) + +@@ -181,7 +171,7 @@ + The minimum number of bytes which can be written without blocking to a pipe + when the pipe has been reported as ready for writing by :func:`~select.select`, + :func:`!poll` or another interface in this module. This doesn't apply +- to other kinds of file-like objects such as sockets. ++ to other kind of file-like objects such as sockets. + + This value is guaranteed by POSIX to be at least 512. + +@@ -192,7 +182,7 @@ + + .. _devpoll-objects: + +-``/dev/poll`` polling objects ++``/dev/poll`` Polling Objects + ----------------------------- + + Solaris and derivatives have ``/dev/poll``. While :c:func:`!select` is +@@ -233,7 +223,7 @@ + implement :meth:`!fileno`, so they can also be used as the argument. + + *eventmask* is an optional bitmask describing the type of events you want to +- check for. The constants are the same as with :c:func:`!poll` ++ check for. The constants are the same that with :c:func:`!poll` + object. The default value is a combination of the constants :const:`POLLIN`, + :const:`POLLPRI`, and :const:`POLLOUT`. + +@@ -248,7 +238,7 @@ + .. method:: devpoll.modify(fd[, eventmask]) + + This method does an :meth:`unregister` followed by a +- :meth:`register`. It is (a bit) more efficient than doing the same ++ :meth:`register`. It is (a bit) more efficient that doing the same + explicitly. + + +@@ -284,50 +274,50 @@ + + .. _epoll-objects: + +-Edge and level trigger polling (epoll) objects ++Edge and Level Trigger Polling (epoll) Objects + ---------------------------------------------- + + https://linux.die.net/man/4/epoll + +- The *eventmask* is a bit mask using the following constants: +- +- +-------------------------+------------------------------------------------+ +- | Constant | Meaning | +- +=========================+================================================+ +- | :const:`EPOLLIN` | Available for read. | +- +-------------------------+------------------------------------------------+ +- | :const:`EPOLLOUT` | Available for write. | +- +-------------------------+------------------------------------------------+ +- | :const:`EPOLLPRI` | Urgent data for read. | +- +-------------------------+------------------------------------------------+ +- | :const:`EPOLLERR` | Error condition happened on the associated fd. | +- +-------------------------+------------------------------------------------+ +- | :const:`EPOLLHUP` | Hang up happened on the associated fd. | +- +-------------------------+------------------------------------------------+ +- | :const:`EPOLLET` | Set Edge Trigger behavior, the default is | +- | | Level Trigger behavior. | +- +-------------------------+------------------------------------------------+ +- | :const:`EPOLLONESHOT` | Set one-shot behavior. After one event is | +- | | pulled out, the fd is internally disabled. | +- +-------------------------+------------------------------------------------+ +- | :const:`EPOLLEXCLUSIVE` | Wake only one epoll object when the | +- | | associated fd has an event. The default (if | +- | | this flag is not set) is to wake all epoll | +- | | objects polling on an fd. | +- +-------------------------+------------------------------------------------+ +- | :const:`EPOLLRDHUP` | Stream socket peer closed connection or shut | +- | | down writing half of connection. | +- +-------------------------+------------------------------------------------+ +- | :const:`EPOLLRDNORM` | Equivalent to :const:`EPOLLIN` | +- +-------------------------+------------------------------------------------+ +- | :const:`EPOLLRDBAND` | Priority data band can be read. | +- +-------------------------+------------------------------------------------+ +- | :const:`EPOLLWRNORM` | Equivalent to :const:`EPOLLOUT`. | +- +-------------------------+------------------------------------------------+ +- | :const:`EPOLLWRBAND` | Priority data may be written. | +- +-------------------------+------------------------------------------------+ +- | :const:`EPOLLMSG` | Ignored. | +- +-------------------------+------------------------------------------------+ ++ *eventmask* ++ ++ +-------------------------+-----------------------------------------------+ ++ | Constant | Meaning | ++ +=========================+===============================================+ ++ | :const:`EPOLLIN` | Available for read | ++ +-------------------------+-----------------------------------------------+ ++ | :const:`EPOLLOUT` | Available for write | ++ +-------------------------+-----------------------------------------------+ ++ | :const:`EPOLLPRI` | Urgent data for read | ++ +-------------------------+-----------------------------------------------+ ++ | :const:`EPOLLERR` | Error condition happened on the assoc. fd | ++ +-------------------------+-----------------------------------------------+ ++ | :const:`EPOLLHUP` | Hang up happened on the assoc. fd | ++ +-------------------------+-----------------------------------------------+ ++ | :const:`EPOLLET` | Set Edge Trigger behavior, the default is | ++ | | Level Trigger behavior | ++ +-------------------------+-----------------------------------------------+ ++ | :const:`EPOLLONESHOT` | Set one-shot behavior. After one event is | ++ | | pulled out, the fd is internally disabled | ++ +-------------------------+-----------------------------------------------+ ++ | :const:`EPOLLEXCLUSIVE` | Wake only one epoll object when the | ++ | | associated fd has an event. The default (if | ++ | | this flag is not set) is to wake all epoll | ++ | | objects polling on a fd. | ++ +-------------------------+-----------------------------------------------+ ++ | :const:`EPOLLRDHUP` | Stream socket peer closed connection or shut | ++ | | down writing half of connection. | ++ +-------------------------+-----------------------------------------------+ ++ | :const:`EPOLLRDNORM` | Equivalent to :const:`EPOLLIN` | ++ +-------------------------+-----------------------------------------------+ ++ | :const:`EPOLLRDBAND` | Priority data band can be read. | ++ +-------------------------+-----------------------------------------------+ ++ | :const:`EPOLLWRNORM` | Equivalent to :const:`EPOLLOUT` | ++ +-------------------------+-----------------------------------------------+ ++ | :const:`EPOLLWRBAND` | Priority data may be written. | ++ +-------------------------+-----------------------------------------------+ ++ | :const:`EPOLLMSG` | Ignored. | ++ +-------------------------+-----------------------------------------------+ + + .. versionadded:: 3.6 + :const:`EPOLLEXCLUSIVE` was added. It's only supported by Linux Kernel 4.5 +@@ -355,12 +345,12 @@ + + .. method:: epoll.register(fd[, eventmask]) + +- Register a file descriptor *fd* with the epoll object. ++ Register a fd descriptor with the epoll object. + + + .. method:: epoll.modify(fd, eventmask) + +- Modify a registered file descriptor *fd*. ++ Modify a registered file descriptor. + + + .. method:: epoll.unregister(fd) +@@ -384,7 +374,7 @@ + + .. _poll-objects: + +-Polling objects ++Polling Objects + --------------- + + The :c:func:`!poll` system call, supported on most Unix systems, provides better +@@ -409,24 +399,24 @@ + :const:`POLLPRI`, and :const:`POLLOUT`, described in the table below. If not + specified, the default value used will check for all 3 types of events. + +- +-------------------+-------------------------------------------+ +- | Constant | Meaning | +- +===================+===========================================+ +- | :const:`POLLIN` | There is data to read. | +- +-------------------+-------------------------------------------+ +- | :const:`POLLPRI` | There is urgent data to read. | +- +-------------------+-------------------------------------------+ +- | :const:`POLLOUT` | Ready for output: writing will not block. | +- +-------------------+-------------------------------------------+ +- | :const:`POLLERR` | Error condition of some sort. | +- +-------------------+-------------------------------------------+ +- | :const:`POLLHUP` | Hung up. | +- +-------------------+-------------------------------------------+ +- | :const:`POLLRDHUP`| Stream socket peer closed connection, or | +- | | shut down writing half of connection. | +- +-------------------+-------------------------------------------+ +- | :const:`POLLNVAL` | Invalid request: descriptor not open. | +- +-------------------+-------------------------------------------+ ++ +-------------------+------------------------------------------+ ++ | Constant | Meaning | ++ +===================+==========================================+ ++ | :const:`POLLIN` | There is data to read | ++ +-------------------+------------------------------------------+ ++ | :const:`POLLPRI` | There is urgent data to read | ++ +-------------------+------------------------------------------+ ++ | :const:`POLLOUT` | Ready for output: writing will not block | ++ +-------------------+------------------------------------------+ ++ | :const:`POLLERR` | Error condition of some sort | ++ +-------------------+------------------------------------------+ ++ | :const:`POLLHUP` | Hung up | ++ +-------------------+------------------------------------------+ ++ | :const:`POLLRDHUP`| Stream socket peer closed connection, or | ++ | | shut down writing half of connection | ++ +-------------------+------------------------------------------+ ++ | :const:`POLLNVAL` | Invalid request: descriptor not open | ++ +-------------------+------------------------------------------+ + + Registering a file descriptor that's already registered is not an error, and has + the same effect as registering the descriptor exactly once. +@@ -472,7 +462,7 @@ + + .. _kqueue-objects: + +-Kqueue objects ++Kqueue Objects + -------------- + + .. method:: kqueue.close() +@@ -513,7 +503,7 @@ + + .. _kevent-objects: + +-Kevent objects ++Kevent Objects + -------------- + + https://man.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2 +@@ -533,66 +523,66 @@ + | Constant | Meaning | + +===========================+=============================================+ + | :const:`KQ_FILTER_READ` | Takes a descriptor and returns whenever | +- | | there is data available to read. | ++ | | there is data available to read | + +---------------------------+---------------------------------------------+ + | :const:`KQ_FILTER_WRITE` | Takes a descriptor and returns whenever | +- | | there is data available to write. | ++ | | there is data available to write | + +---------------------------+---------------------------------------------+ +- | :const:`KQ_FILTER_AIO` | AIO requests. | ++ | :const:`KQ_FILTER_AIO` | AIO requests | + +---------------------------+---------------------------------------------+ + | :const:`KQ_FILTER_VNODE` | Returns when one or more of the requested | +- | | events watched in *fflag* occurs. | ++ | | events watched in *fflag* occurs | + +---------------------------+---------------------------------------------+ +- | :const:`KQ_FILTER_PROC` | Watch for events on a process ID. | ++ | :const:`KQ_FILTER_PROC` | Watch for events on a process id | + +---------------------------+---------------------------------------------+ + | :const:`KQ_FILTER_NETDEV` | Watch for events on a network device | +- | | (not available on macOS). | ++ | | [not available on macOS] | + +---------------------------+---------------------------------------------+ + | :const:`KQ_FILTER_SIGNAL` | Returns whenever the watched signal is | +- | | delivered to the process. | ++ | | delivered to the process | + +---------------------------+---------------------------------------------+ +- | :const:`KQ_FILTER_TIMER` | Establishes an arbitrary timer. | ++ | :const:`KQ_FILTER_TIMER` | Establishes an arbitrary timer | + +---------------------------+---------------------------------------------+ + + .. attribute:: kevent.flags + + Filter action. + +- +---------------------------+----------------------------------------------+ +- | Constant | Meaning | +- +===========================+==============================================+ +- | :const:`KQ_EV_ADD` | Adds or modifies an event. | +- +---------------------------+----------------------------------------------+ +- | :const:`KQ_EV_DELETE` | Removes an event from the queue. | +- +---------------------------+----------------------------------------------+ +- | :const:`KQ_EV_ENABLE` | Permits control() to return the event. | +- +---------------------------+----------------------------------------------+ +- | :const:`KQ_EV_DISABLE` | Disables event. | +- +---------------------------+----------------------------------------------+ +- | :const:`KQ_EV_ONESHOT` | Removes event after first occurrence. | +- +---------------------------+----------------------------------------------+ +- | :const:`KQ_EV_CLEAR` | Reset the state after an event is retrieved. | +- +---------------------------+----------------------------------------------+ +- | :const:`KQ_EV_SYSFLAGS` | Internal event. | +- +---------------------------+----------------------------------------------+ +- | :const:`KQ_EV_FLAG1` | Internal event. | +- +---------------------------+----------------------------------------------+ +- | :const:`KQ_EV_EOF` | Filter-specific EOF condition. | +- +---------------------------+----------------------------------------------+ +- | :const:`KQ_EV_ERROR` | See return values. | +- +---------------------------+----------------------------------------------+ ++ +---------------------------+---------------------------------------------+ ++ | Constant | Meaning | ++ +===========================+=============================================+ ++ | :const:`KQ_EV_ADD` | Adds or modifies an event | ++ +---------------------------+---------------------------------------------+ ++ | :const:`KQ_EV_DELETE` | Removes an event from the queue | ++ +---------------------------+---------------------------------------------+ ++ | :const:`KQ_EV_ENABLE` | Permitscontrol() to returns the event | ++ +---------------------------+---------------------------------------------+ ++ | :const:`KQ_EV_DISABLE` | Disablesevent | ++ +---------------------------+---------------------------------------------+ ++ | :const:`KQ_EV_ONESHOT` | Removes event after first occurrence | ++ +---------------------------+---------------------------------------------+ ++ | :const:`KQ_EV_CLEAR` | Reset the state after an event is retrieved | ++ +---------------------------+---------------------------------------------+ ++ | :const:`KQ_EV_SYSFLAGS` | internal event | ++ +---------------------------+---------------------------------------------+ ++ | :const:`KQ_EV_FLAG1` | internal event | ++ +---------------------------+---------------------------------------------+ ++ | :const:`KQ_EV_EOF` | Filter specific EOF condition | ++ +---------------------------+---------------------------------------------+ ++ | :const:`KQ_EV_ERROR` | See return values | ++ +---------------------------+---------------------------------------------+ + + + .. attribute:: kevent.fflags + +- Filter-specific flags. ++ Filter specific flags. + + :const:`KQ_FILTER_READ` and :const:`KQ_FILTER_WRITE` filter flags: + + +----------------------------+--------------------------------------------+ + | Constant | Meaning | + +============================+============================================+ +- | :const:`KQ_NOTE_LOWAT` | Low water mark of a socket buffer. | ++ | :const:`KQ_NOTE_LOWAT` | low water mark of a socket buffer | + +----------------------------+--------------------------------------------+ + + :const:`KQ_FILTER_VNODE` filter flags: +@@ -600,19 +590,19 @@ + +----------------------------+--------------------------------------------+ + | Constant | Meaning | + +============================+============================================+ +- | :const:`KQ_NOTE_DELETE` | *unlink()* was called. | ++ | :const:`KQ_NOTE_DELETE` | *unlink()* was called | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_WRITE` | A write occurred. | ++ | :const:`KQ_NOTE_WRITE` | a write occurred | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_EXTEND` | The file was extended. | ++ | :const:`KQ_NOTE_EXTEND` | the file was extended | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_ATTRIB` | An attribute was changed. | ++ | :const:`KQ_NOTE_ATTRIB` | an attribute was changed | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_LINK` | The link count has changed. | ++ | :const:`KQ_NOTE_LINK` | the link count has changed | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_RENAME` | The file was renamed. | ++ | :const:`KQ_NOTE_RENAME` | the file was renamed | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_REVOKE` | Access to the file was revoked. | ++ | :const:`KQ_NOTE_REVOKE` | access to the file was revoked | + +----------------------------+--------------------------------------------+ + + :const:`KQ_FILTER_PROC` filter flags: +@@ -620,22 +610,22 @@ + +----------------------------+--------------------------------------------+ + | Constant | Meaning | + +============================+============================================+ +- | :const:`KQ_NOTE_EXIT` | The process has exited. | ++ | :const:`KQ_NOTE_EXIT` | the process has exited | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_FORK` | The process has called *fork()*. | ++ | :const:`KQ_NOTE_FORK` | the process has called *fork()* | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_EXEC` | The process has executed a new process. | ++ | :const:`KQ_NOTE_EXEC` | the process has executed a new process | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_PCTRLMASK` | Internal filter flag. | ++ | :const:`KQ_NOTE_PCTRLMASK` | internal filter flag | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_PDATAMASK` | Internal filter flag. | ++ | :const:`KQ_NOTE_PDATAMASK` | internal filter flag | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_TRACK` | Follow a process across *fork()*. | ++ | :const:`KQ_NOTE_TRACK` | follow a process across *fork()* | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_CHILD` | Returned on the child process for | +- | | *NOTE_TRACK*. | ++ | :const:`KQ_NOTE_CHILD` | returned on the child process for | ++ | | *NOTE_TRACK* | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_TRACKERR` | Unable to attach to a child. | ++ | :const:`KQ_NOTE_TRACKERR` | unable to attach to a child | + +----------------------------+--------------------------------------------+ + + :const:`KQ_FILTER_NETDEV` filter flags (not available on macOS): +@@ -643,19 +633,19 @@ + +----------------------------+--------------------------------------------+ + | Constant | Meaning | + +============================+============================================+ +- | :const:`KQ_NOTE_LINKUP` | Link is up. | ++ | :const:`KQ_NOTE_LINKUP` | link is up | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_LINKDOWN` | Link is down. | ++ | :const:`KQ_NOTE_LINKDOWN` | link is down | + +----------------------------+--------------------------------------------+ +- | :const:`KQ_NOTE_LINKINV` | Link state is invalid. | ++ | :const:`KQ_NOTE_LINKINV` | link state is invalid | + +----------------------------+--------------------------------------------+ + + + .. attribute:: kevent.data + +- Filter-specific data. ++ Filter specific data. + + + .. attribute:: kevent.udata + +- User-defined value. ++ User defined value. +diff --git a/Doc/library/selectors.rst b/Doc/library/selectors.rst +index 2d523a9d2ea..ee556f1f3ce 100644 +--- a/Doc/library/selectors.rst ++++ b/Doc/library/selectors.rst +@@ -54,7 +54,7 @@ + + + In the following, *events* is a bitwise mask indicating which I/O events should +-be waited for on a given file object. It can be a combination of the module's ++be waited for on a given file object. It can be a combination of the modules + constants below: + + +-----------------------+-----------------------------------------------+ +diff --git a/Doc/library/shelve.rst b/Doc/library/shelve.rst +index 274eae4ceff..6e74a59b82b 100644 +--- a/Doc/library/shelve.rst ++++ b/Doc/library/shelve.rst +@@ -65,7 +65,7 @@ + to load a shelf from an untrusted source. Like with pickle, loading a shelf + can execute arbitrary code. + +-Shelf objects support most of the methods and operations supported by dictionaries ++Shelf objects support most of methods and operations supported by dictionaries + (except copying, constructors and operators ``|`` and ``|=``). This eases the + transition from dictionary based scripts to those requiring persistent storage. + +diff --git a/Doc/library/shlex.rst b/Doc/library/shlex.rst +index 81ccaa62b4c..a96f0864dc1 100644 +--- a/Doc/library/shlex.rst ++++ b/Doc/library/shlex.rst +@@ -343,7 +343,7 @@ + Parsing Rules + ------------- + +-When operating in non-POSIX mode, :class:`~shlex.shlex` will try to obey the ++When operating in non-POSIX mode, :class:`~shlex.shlex` will try to obey to the + following rules. + + * Quote characters are not recognized within words (``Do"Not"Separate`` is +@@ -366,7 +366,7 @@ + + * It's not possible to parse empty strings, even if quoted. + +-When operating in POSIX mode, :class:`~shlex.shlex` will try to obey the ++When operating in POSIX mode, :class:`~shlex.shlex` will try to obey to the + following parsing rules. + + * Quotes are stripped out, and do not separate words (``"Do"Not"Separate"`` is +@@ -382,7 +382,7 @@ + * Enclosing characters in quotes which are part of + :attr:`~shlex.escapedquotes` (e.g. ``'"'``) preserves the literal value + of all characters within the quotes, with the exception of the characters +- mentioned in :attr:`~shlex.escape`. The escape characters retain their ++ mentioned in :attr:`~shlex.escape`. The escape characters retain its + special meaning only when followed by the quote in use, or the escape + character itself. Otherwise the escape character will be considered a + normal character. +diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst +index 704820e3e1b..3c4a3ed0cbd 100644 +--- a/Doc/library/shutil.rst ++++ b/Doc/library/shutil.rst +@@ -381,14 +381,10 @@ + If *dst* already exists but is not a directory, it may be overwritten + depending on :func:`os.rename` semantics. + +- :func:`os.rename` is preferably used internally when *src* and the destination are on +- the same filesystem. In case :func:`os.rename` fails due to :exc:`OSError` +- (e.g. the user has write permission to the destination file but not to its parent +- directory), this method falls back to using *copy_function*, in which case +- *src* is copied to the destination using *copy_function* and then removed. +- +- In case of symlinks, a new symlink pointing to the target of *src* will be +- created in or as the destination, and *src* will be removed. ++ If the destination is on the current filesystem, then :func:`os.rename` is ++ used. Otherwise, *src* is copied to the destination using *copy_function* ++ and then removed. In case of symlinks, a new symlink pointing to the target ++ of *src* will be created as the destination and *src* will be removed. + + If *copy_function* is given, it must be a callable that takes two arguments, + *src* and the destination, and will be used to copy *src* to the destination +@@ -538,7 +534,7 @@ + :func:`shutil.copyfileobj` is used. + + If the fast-copy operation fails and no data was written in the destination +-file then shutil will silently fall back to less efficient ++file then shutil will silently fallback on using less efficient + :func:`copyfileobj` function internally. + + .. versionchanged:: 3.8 +@@ -677,7 +673,7 @@ + + Register an archiver for the format *name*. + +- *function* is the callable that will be used to create archives. The callable ++ *function* is the callable that will be used to unpack archives. The callable + will receive the *base_name* of the file to create, followed by the + *base_dir* (which defaults to :data:`os.curdir`) to start archiving from. + Further arguments are passed as keyword arguments: *owner*, *group*, +@@ -732,8 +728,8 @@ + + Never extract archives from untrusted sources without prior inspection. + It is possible that files are created outside of the path specified in +- the *extract_dir* argument, for example, members that have absolute filenames +- or filenames with ".." components. ++ the *extract_dir* argument, e.g. members that have absolute filenames ++ starting with "/" or filenames with two dots "..". + + .. versionchanged:: 3.7 + Accepts a :term:`path-like object` for *filename* and *extract_dir*. +diff --git a/Doc/library/signal.rst b/Doc/library/signal.rst +index 60e63f773a4..1a2a555f5c0 100644 +--- a/Doc/library/signal.rst ++++ b/Doc/library/signal.rst +@@ -36,7 +36,7 @@ + A Python signal handler does not get executed inside the low-level (C) signal + handler. Instead, the low-level signal handler sets a flag which tells the + :term:`virtual machine` to execute the corresponding Python signal handler +-at a later point (for example, at the next :term:`bytecode` instruction). ++at a later point(for example at the next :term:`bytecode` instruction). + This has consequences: + + * It makes little sense to catch synchronous errors like :const:`SIGFPE` or +@@ -68,11 +68,6 @@ + + Besides, only the main thread of the main interpreter is allowed to set a new signal handler. + +-.. warning:: +- +- Synchronization primitives such as :class:`threading.Lock` should not be used +- within signal handlers. Doing so can lead to unexpected deadlocks. +- + + Module contents + --------------- +@@ -97,13 +92,13 @@ + + .. class:: Handlers + +- :class:`enum.IntEnum` collection of the constants :const:`SIG_DFL` and :const:`SIG_IGN`. ++ :class:`enum.IntEnum` collection the constants :const:`SIG_DFL` and :const:`SIG_IGN`. + + .. versionadded:: 3.5 + + .. class:: Sigmasks + +- :class:`enum.IntEnum` collection of the constants :const:`SIG_BLOCK`, :const:`SIG_UNBLOCK` and :const:`SIG_SETMASK`. ++ :class:`enum.IntEnum` collection the constants :const:`SIG_BLOCK`, :const:`SIG_UNBLOCK` and :const:`SIG_SETMASK`. + + .. availability:: Unix. + +@@ -230,8 +225,6 @@ + + Stop executing (cannot be caught or ignored). + +- .. availability:: Unix. +- + .. data:: SIGSTKFLT + + Stack fault on coprocessor. The Linux kernel does not raise this signal: it +diff --git a/Doc/library/site.rst b/Doc/library/site.rst +index f8b51bc86eb..484c3f8af58 100644 +--- a/Doc/library/site.rst ++++ b/Doc/library/site.rst +@@ -132,7 +132,7 @@ + It is typically created by a system administrator in the site-packages + directory. If this import fails with an :exc:`ImportError` or its subclass + exception, and the exception's :attr:`~ImportError.name` +-attribute equals ``'sitecustomize'``, ++attribute equals to ``'sitecustomize'``, + it is silently ignored. If Python is started without output streams available, as + with :file:`pythonw.exe` on Windows (which is used by default to start IDLE), + attempted output from :mod:`sitecustomize` is ignored. Any other exception +@@ -149,7 +149,7 @@ + user site-packages directory (see below), which is part of ``sys.path`` unless + disabled by :option:`-s`. If this import fails with an :exc:`ImportError` or + its subclass exception, and the exception's :attr:`~ImportError.name` +-attribute equals ``'usercustomize'``, it is silently ignored. ++attribute equals to ``'usercustomize'``, it is silently ignored. + + Note that for some non-Unix systems, ``sys.prefix`` and ``sys.exec_prefix`` are + empty, and the path manipulations are skipped; however the import of +@@ -165,7 +165,7 @@ + On systems that support :mod:`readline`, this module will also import and + configure the :mod:`rlcompleter` module, if Python is started in + :ref:`interactive mode ` and without the :option:`-S` option. +-The default behavior is to enable tab completion and to use ++The default behavior is enable tab-completion and to use + :file:`~/.python_history` as the history save file. To disable it, delete (or + override) the :data:`sys.__interactivehook__` attribute in your + :mod:`sitecustomize` or :mod:`usercustomize` module or your +diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst +index 10525c90aa9..c5a3de52090 100644 +--- a/Doc/library/smtplib.rst ++++ b/Doc/library/smtplib.rst +@@ -440,11 +440,9 @@ + Send mail. The required arguments are an :rfc:`822` from-address string, a list + of :rfc:`822` to-address strings (a bare string will be treated as a list with 1 + address), and a message string. The caller may pass a list of ESMTP options +- (such as ``"8bitmime"``) to be used in ``MAIL FROM`` commands as *mail_options*. ++ (such as ``8bitmime``) to be used in ``MAIL FROM`` commands as *mail_options*. + ESMTP options (such as ``DSN`` commands) that should be used with all ``RCPT`` +- commands can be passed as *rcpt_options*. Each option should be passed as a string +- containing the full text of the option, including any potential key +- (for instance, ``"NOTIFY=SUCCESS,FAILURE"``). (If you need to use different ESMTP ++ commands can be passed as *rcpt_options*. (If you need to use different ESMTP + options to different recipients you have to use the low-level methods such as + :meth:`!mail`, :meth:`!rcpt` and :meth:`!data` to send the message.) + +diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst +index 7d88e3d0660..cac619ea394 100644 +--- a/Doc/library/socket.rst ++++ b/Doc/library/socket.rst +@@ -39,8 +39,6 @@ + A TLS/SSL wrapper for socket objects. + + +-.. _socket-addresses: +- + Socket families + --------------- + +@@ -120,10 +118,10 @@ + ``'can0'``. The network interface name ``''`` can be used to receive packets + from all network interfaces of this family. + +- - :const:`CAN_ISOTP` protocol requires a tuple ``(interface, rx_addr, tx_addr)`` ++ - :const:`CAN_ISOTP` protocol require a tuple ``(interface, rx_addr, tx_addr)`` + where both additional parameters are unsigned long integer that represent a + CAN identifier (standard or extended). +- - :const:`CAN_J1939` protocol requires a tuple ``(interface, name, pgn, addr)`` ++ - :const:`CAN_J1939` protocol require a tuple ``(interface, name, pgn, addr)`` + where additional parameters are 64-bit unsigned integer representing the + ECU name, a 32-bit unsigned integer representing the Parameter Group Number + (PGN), and an 8-bit integer representing the address. +@@ -790,7 +788,7 @@ + + Build a pair of connected socket objects using the given address family, socket + type, and protocol number. Address family, socket type, and protocol number are +- as for the :func:`~socket.socket` function. The default family is :const:`AF_UNIX` ++ as for the :func:`~socket.socket` function above. The default family is :const:`AF_UNIX` + if defined on the platform; otherwise, the default is :const:`AF_INET`. + + The newly created sockets are :ref:`non-inheritable `. +@@ -886,8 +884,8 @@ + + Duplicate the file descriptor *fd* (an integer as returned by a file object's + :meth:`~io.IOBase.fileno` method) and build a socket object from the result. Address +- family, socket type and protocol number are as for the :func:`~socket.socket` function. +- The file descriptor should refer to a socket, but this is not checked --- ++ family, socket type and protocol number are as for the :func:`~socket.socket` function ++ above. The file descriptor should refer to a socket, but this is not checked --- + subsequent operations on the object may fail if the file descriptor is invalid. + This function is rarely needed, but can be used to get or set socket options on + a socket passed to a program as standard input or output (such as a server +@@ -924,7 +922,7 @@ + .. function:: close(fd) + + Close a socket file descriptor. This is like :func:`os.close`, but for +- sockets. On some platforms (most notably Windows) :func:`os.close` ++ sockets. On some platforms (most noticeable Windows) :func:`os.close` + does not work for socket file descriptors. + + .. versionadded:: 3.7 +@@ -1442,8 +1440,8 @@ + + .. method:: socket.bind(address) + +- Bind the socket to *address*. The socket must not already be bound. The format +- of *address* depends on the address family --- see :ref:`socket-addresses`. ++ Bind the socket to *address*. The socket must not already be bound. (The format ++ of *address* depends on the address family --- see above.) + + .. audit-event:: socket.bind self,address socket.socket.bind + +@@ -1476,11 +1474,11 @@ + + .. method:: socket.connect(address) + +- Connect to a remote socket at *address*. The format of *address* depends on the +- address family --- see :ref:`socket-addresses`. ++ Connect to a remote socket at *address*. (The format of *address* depends on the ++ address family --- see above.) + + If the connection is interrupted by a signal, the method waits until the +- connection completes, or raises a :exc:`TimeoutError` on timeout, if the ++ connection completes, or raise a :exc:`TimeoutError` on timeout, if the + signal handler doesn't raise an exception and the socket is blocking or has + a timeout. For non-blocking sockets, the method raises an + :exc:`InterruptedError` exception if the connection is interrupted by a +@@ -1552,16 +1550,16 @@ + .. method:: socket.getpeername() + + Return the remote address to which the socket is connected. This is useful to +- find out the port number of a remote IPv4/v6 socket, for instance. The format +- of the address returned depends on the address family --- see :ref:`socket-addresses`. +- On some systems this function is not supported. ++ find out the port number of a remote IPv4/v6 socket, for instance. (The format ++ of the address returned depends on the address family --- see above.) On some ++ systems this function is not supported. + + + .. method:: socket.getsockname() + + Return the socket's own address. This is useful to find out the port number of +- an IPv4/v6 socket, for instance. The format of the address returned depends on +- the address family --- see :ref:`socket-addresses`. ++ an IPv4/v6 socket, for instance. (The format of the address returned depends on ++ the address family --- see above.) + + + .. method:: socket.getsockopt(level, optname[, buflen]) +@@ -1672,8 +1670,7 @@ + where *bytes* is a bytes object representing the data received and *address* is the + address of the socket sending the data. See the Unix manual page + :manpage:`recv(2)` for the meaning of the optional argument *flags*; it defaults +- to zero. The format of *address* depends on the address family --- see +- :ref:`socket-addresses`. ++ to zero. (The format of *address* depends on the address family --- see above.) + + .. versionchanged:: 3.5 + If the system call is interrupted and the signal handler does not raise +@@ -1803,8 +1800,8 @@ + new bytestring. The return value is a pair ``(nbytes, address)`` where *nbytes* is + the number of bytes received and *address* is the address of the socket sending + the data. See the Unix manual page :manpage:`recv(2)` for the meaning of the +- optional argument *flags*; it defaults to zero. The format of *address* +- depends on the address family --- see :ref:`socket-addresses`. ++ optional argument *flags*; it defaults to zero. (The format of *address* ++ depends on the address family --- see above.) + + + .. method:: socket.recv_into(buffer[, nbytes[, flags]]) +@@ -1819,7 +1816,7 @@ + .. method:: socket.send(bytes[, flags]) + + Send data to the socket. The socket must be connected to a remote socket. The +- optional *flags* argument has the same meaning as for :meth:`recv`. ++ optional *flags* argument has the same meaning as for :meth:`recv` above. + Returns the number of bytes sent. Applications are responsible for checking that + all data has been sent; if only some of the data was transmitted, the + application needs to attempt delivery of the remaining data. For further +@@ -1834,7 +1831,7 @@ + .. method:: socket.sendall(bytes[, flags]) + + Send data to the socket. The socket must be connected to a remote socket. The +- optional *flags* argument has the same meaning as for :meth:`recv`. ++ optional *flags* argument has the same meaning as for :meth:`recv` above. + Unlike :meth:`send`, this method continues to send data from *bytes* until + either all data has been sent or an error occurs. ``None`` is returned on + success. On error, an exception is raised, and there is no way to determine how +@@ -1855,9 +1852,9 @@ + + Send data to the socket. The socket should not be connected to a remote socket, + since the destination socket is specified by *address*. The optional *flags* +- argument has the same meaning as for :meth:`recv`. Return the number of +- bytes sent. The format of *address* depends on the address family --- see +- :ref:`socket-addresses`. ++ argument has the same meaning as for :meth:`recv` above. Return the number of ++ bytes sent. (The format of *address* depends on the address family --- see ++ above.) + + .. audit-event:: socket.sendto self,address socket.socket.sendto + +@@ -1984,11 +1981,11 @@ + Set the value of the given socket option (see the Unix manual page + :manpage:`setsockopt(2)`). The needed symbolic constants are defined in this + module (:ref:`!SO_\* etc. `). The value can be an integer, +- ``None`` or a :term:`bytes-like object` representing a buffer. In the latter ++ ``None`` or a :term:`bytes-like object` representing a buffer. In the later + case it is up to the caller to ensure that the bytestring contains the + proper bits (see the optional built-in module :mod:`struct` for a way to + encode C structures as bytestrings). When *value* is set to ``None``, +- *optlen* argument is required. It's equivalent to calling :c:func:`setsockopt` C ++ *optlen* argument is required. It's equivalent to call :c:func:`setsockopt` C + function with ``optval=NULL`` and ``optlen=optlen``. + + .. versionchanged:: 3.5 +diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst +index 96817ff03cb..39da468f142 100644 +--- a/Doc/library/sqlite3.rst ++++ b/Doc/library/sqlite3.rst +@@ -55,7 +55,7 @@ + PEP written by Marc-André Lemburg. + + +-.. We use the following practices for SQL code: ++.. We use the following practises for SQL code: + - UPPERCASE for keywords + - snake_case for schema + - single quotes for string literals +@@ -289,7 +289,7 @@ + Set it to any combination (using ``|``, bitwise or) of + :const:`PARSE_DECLTYPES` and :const:`PARSE_COLNAMES` + to enable this. +- Column names take precedence over declared types if both flags are set. ++ Column names takes precedence over declared types if both flags are set. + By default (``0``), type detection is disabled. + + :param isolation_level: +@@ -1436,9 +1436,6 @@ + + See :ref:`sqlite3-howto-row-factory` for more details. + +- .. versionchanged:: 3.13.14 +- Deleting the ``row_factory`` attribute is no longer allowed. +- + .. attribute:: text_factory + + A :term:`callable` that accepts a :class:`bytes` parameter +@@ -1448,9 +1445,6 @@ + + See :ref:`sqlite3-howto-encoding` for more details. + +- .. versionchanged:: 3.13.14 +- Deleting the ``text_factory`` attribute is no longer allowed. +- + .. attribute:: total_changes + + Return the total number of database rows that have been modified, inserted, or +@@ -1734,9 +1728,6 @@ + + See :ref:`sqlite3-howto-row-factory` for more details. + +- .. versionchanged:: 3.13.14 +- Deleting the ``row_factory`` attribute is no longer allowed. +- + + .. The sqlite3.Row example used to be a how-to. It has now been incorporated + into the Row reference. We keep the anchor here in order not to break +@@ -2313,7 +2304,7 @@ + + .. testcode:: + +- import datetime as dt ++ import datetime + import sqlite3 + + def adapt_date_iso(val): +@@ -2328,21 +2319,21 @@ + """Adapt datetime.datetime to Unix timestamp.""" + return int(val.timestamp()) + +- sqlite3.register_adapter(dt.date, adapt_date_iso) +- sqlite3.register_adapter(dt.datetime, adapt_datetime_iso) +- sqlite3.register_adapter(dt.datetime, adapt_datetime_epoch) ++ sqlite3.register_adapter(datetime.date, adapt_date_iso) ++ sqlite3.register_adapter(datetime.datetime, adapt_datetime_iso) ++ sqlite3.register_adapter(datetime.datetime, adapt_datetime_epoch) + + def convert_date(val): + """Convert ISO 8601 date to datetime.date object.""" +- return dt.date.fromisoformat(val.decode()) ++ return datetime.date.fromisoformat(val.decode()) + + def convert_datetime(val): + """Convert ISO 8601 datetime to datetime.datetime object.""" +- return dt.datetime.fromisoformat(val.decode()) ++ return datetime.datetime.fromisoformat(val.decode()) + + def convert_timestamp(val): + """Convert Unix epoch timestamp to datetime.datetime object.""" +- return dt.datetime.fromtimestamp(int(val)) ++ return datetime.datetime.fromtimestamp(int(val)) + + sqlite3.register_converter("date", convert_date) + sqlite3.register_converter("datetime", convert_datetime) +@@ -2351,17 +2342,17 @@ + .. testcode:: + :hide: + +- when = dt.datetime(2019, 5, 18, 15, 17, 8, 123456) ++ dt = datetime.datetime(2019, 5, 18, 15, 17, 8, 123456) + +- assert adapt_date_iso(when.date()) == "2019-05-18" +- assert convert_date(b"2019-05-18") == when.date() ++ assert adapt_date_iso(dt.date()) == "2019-05-18" ++ assert convert_date(b"2019-05-18") == dt.date() + +- assert adapt_datetime_iso(when) == "2019-05-18T15:17:08.123456" +- assert convert_datetime(b"2019-05-18T15:17:08.123456") == when ++ assert adapt_datetime_iso(dt) == "2019-05-18T15:17:08.123456" ++ assert convert_datetime(b"2019-05-18T15:17:08.123456") == dt + + # Using current time as fromtimestamp() returns local date/time. + # Dropping microseconds as adapt_datetime_epoch truncates fractional second part. +- now = dt.datetime.now().replace(microsecond=0) ++ now = datetime.datetime.now().replace(microsecond=0) + current_timestamp = int(now.timestamp()) + + assert adapt_datetime_epoch(now) == current_timestamp +diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst +index 601b2b44320..431c2a360ca 100644 +--- a/Doc/library/ssl.rst ++++ b/Doc/library/ssl.rst +@@ -69,7 +69,7 @@ + Use of deprecated constants and functions result in deprecation warnings. + + +-Functions, constants, and exceptions ++Functions, Constants, and Exceptions + ------------------------------------ + + +@@ -358,7 +358,7 @@ + + .. function:: cert_time_to_seconds(cert_time) + +- Return the time in seconds since the epoch, given the ``cert_time`` ++ Return the time in seconds since the Epoch, given the ``cert_time`` + string representing the "notBefore" or "notAfter" date from a + certificate in ``"%b %d %H:%M:%S %Y %Z"`` strptime format (C + locale). +@@ -368,12 +368,12 @@ + .. doctest:: newcontext + + >>> import ssl +- >>> import datetime as dt + >>> timestamp = ssl.cert_time_to_seconds("Jan 5 09:34:43 2018 GMT") + >>> timestamp # doctest: +SKIP + 1515144883 +- >>> print(dt.datetime.fromtimestamp(timestamp, dt.UTC)) # doctest: +SKIP +- 2018-01-05 09:34:43+00:00 ++ >>> from datetime import datetime ++ >>> print(datetime.utcfromtimestamp(timestamp)) # doctest: +SKIP ++ 2018-01-05 09:34:43 + + "notBefore" or "notAfter" dates must use GMT (:rfc:`5280`). + +@@ -1043,7 +1043,7 @@ + :attr:`TLSVersion.TLSv1_3` are deprecated. + + +-SSL sockets ++SSL Sockets + ----------- + + .. class:: SSLSocket(socket.socket) +@@ -1091,7 +1091,7 @@ + :meth:`SSLContext.wrap_socket` to wrap a socket. + + .. versionchanged:: 3.7 +- :class:`SSLSocket` instances must be created with ++ :class:`SSLSocket` instances must to created with + :meth:`~SSLContext.wrap_socket`. In earlier versions, it was possible + to create instances directly. This was never documented or officially + supported. +@@ -1404,7 +1404,7 @@ + .. versionadded:: 3.6 + + +-SSL contexts ++SSL Contexts + ------------ + + .. versionadded:: 3.2 +@@ -1943,7 +1943,7 @@ + :attr:`~SSLContext.minimum_version` and + :attr:`SSLContext.options` all affect the supported SSL + and TLS versions of the context. The implementation does not prevent +- invalid combinations. For example a context with ++ invalid combination. For example a context with + :attr:`OP_NO_TLSv1_2` in :attr:`~SSLContext.options` and + :attr:`~SSLContext.maximum_version` set to :attr:`TLSVersion.TLSv1_2` + will not be able to establish a TLS 1.2 connection. +@@ -2520,7 +2520,7 @@ + as well. + + +-Memory BIO support ++Memory BIO Support + ------------------ + + .. versionadded:: 3.5 +@@ -2746,11 +2746,11 @@ + :: + + >>> client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) +- >>> client_context.minimum_version = ssl.TLSVersion.TLSv1_2 ++ >>> client_context.minimum_version = ssl.TLSVersion.TLSv1_3 + >>> client_context.maximum_version = ssl.TLSVersion.TLSv1_3 + + +-The SSL client context created above will only allow TLSv1.2 and TLSv1.3 (if ++The SSL context created above will only allow TLSv1.3 and later (if + supported by your system) connections to a server. :const:`PROTOCOL_TLS_CLIENT` + implies certificate validation and hostname checks by default. You have to + load certificates into the context. +diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst +index 6b498343763..f7ac7da43b5 100644 +--- a/Doc/library/stdtypes.rst ++++ b/Doc/library/stdtypes.rst +@@ -164,7 +164,7 @@ + pair: object; numeric + pair: objects; comparing + +-Unless stated otherwise, objects of different types never compare equal. ++Objects of different types, except different numeric types, never compare equal. + The ``==`` operator is always defined but for some object types (for example, + class objects) is equivalent to :keyword:`is`. The ``<``, ``<=``, ``>`` and ``>=`` + operators are only defined where they make sense; for example, they raise a +@@ -1049,14 +1049,11 @@ + still ``0``. + + (4) +- The slice of *s* from *i* to *j* is defined as the sequence of items with +- index *k* such that ``i <= k < j``. +- +- * If *i* is omitted or ``None``, use ``0``. +- * If *j* is omitted or ``None``, use ``len(s)``. +- * If *i* or *j* is less than ``-len(s)``, use ``0``. +- * If *i* or *j* is greater than ``len(s)``, use ``len(s)``. +- * If *i* is greater than or equal to *j*, the slice is empty. ++ The slice of *s* from *i* to *j* is defined as the sequence of items with index ++ *k* such that ``i <= k < j``. If *i* or *j* is greater than ``len(s)``, use ++ ``len(s)``. If *i* is omitted or ``None``, use ``0``. If *j* is omitted or ++ ``None``, use ``len(s)``. If *i* is greater than or equal to *j*, the slice is ++ empty. + + (5) + The slice of *s* from *i* to *j* with step *k* is defined as the sequence of +@@ -1111,13 +1108,13 @@ + + Return the total number of occurrences of *value* in *sequence*. + +-.. method:: list.index(value[, start[, stop]]) +- range.index(value[, start[, stop]]) +- tuple.index(value[, start[, stop]]) ++.. method:: list.index(value[, start[, stop]) ++ range.index(value[, start[, stop]) ++ tuple.index(value[, start[, stop]) + :no-contents-entry: + :no-index-entry: + :no-typesetting: +-.. method:: sequence.index(value[, start[, stop]]) ++.. method:: sequence.index(value[, start[, stop]) + + Return the index of the first occurrence of *value* in *sequence*. + +@@ -1234,7 +1231,7 @@ + :no-typesetting: + .. method:: sequence.append(value, /) + +- Append *value* to the end of the sequence. ++ Append *value* to the end of the sequence + This is equivalent to writing ``seq[len(seq):len(seq)] = [value]``. + + .. method:: bytearray.clear() +@@ -1351,8 +1348,6 @@ + Many other operations also produce lists, including the :func:`sorted` + built-in. + +- Lists are :ref:`generic ` over the types of their items. +- + Lists implement all of the :ref:`common ` and + :ref:`mutable ` sequence operations. Lists also provide the + following additional method: +@@ -1439,10 +1434,6 @@ + Tuples implement all of the :ref:`common ` sequence + operations. + +- Tuples are :ref:`generic ` over the types of their contents. +- For more information, refer to +- :ref:`the typing documentation on annotating tuples `. +- + For heterogeneous collections of data where access by name is clearer than + access by index, :func:`collections.namedtuple` may be a more appropriate + choice than a simple tuple object. +@@ -1715,14 +1706,6 @@ + lowercase letter ``'ß'`` is equivalent to ``"ss"``. Since it is already + lowercase, :meth:`lower` would do nothing to ``'ß'``; :meth:`casefold` + converts it to ``"ss"``. +- For example: +- +- .. doctest:: +- +- >>> 'straße'.lower() +- 'straße' +- >>> 'straße'.casefold() +- 'strasse' + + The casefolding algorithm is + `described in section 3.13 'Default Case Folding' of the Unicode Standard +@@ -1924,20 +1907,7 @@ + .. method:: str.index(sub[, start[, end]]) + + Like :meth:`~str.find`, but raise :exc:`ValueError` when the substring is +- not found. For example: +- +- .. doctest:: +- +- >>> 'spam, spam, spam'.index('spam') +- 0 +- >>> 'spam, spam, spam'.index('eggs') +- Traceback (most recent call last): +- File "", line 1, in +- 'spam, spam, spam'.index('eggs') +- ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ +- ValueError: substring not found +- +- See also :meth:`rindex`. ++ not found. + + + .. method:: str.isalnum() +@@ -1945,18 +1915,7 @@ + Return ``True`` if all characters in the string are alphanumeric and there is at + least one character, ``False`` otherwise. A character ``c`` is alphanumeric if one + of the following returns ``True``: ``c.isalpha()``, ``c.isdecimal()``, +- ``c.isdigit()``, or ``c.isnumeric()``. For example: +- +- .. doctest:: +- +- >>> 'abc123'.isalnum() +- True +- >>> 'abc123!@#'.isalnum() +- False +- >>> ''.isalnum() +- False +- >>> ' '.isalnum() +- False ++ ``c.isdigit()``, or ``c.isnumeric()``. + + + .. method:: str.isalpha() +@@ -2023,25 +1982,9 @@ + character, ``False`` otherwise. Digits include decimal characters and digits that need + special handling, such as the compatibility superscript digits. + This covers digits which cannot be used to form numbers in base 10, +- like the `Kharosthi numbers `__. +- Formally, a digit is a character that has the ++ like the Kharosthi numbers. Formally, a digit is a character that has the + property value Numeric_Type=Digit or Numeric_Type=Decimal. + +- For example: +- +- .. doctest:: +- +- >>> '0123456789'.isdigit() +- True +- >>> '٠١٢٣٤٥٦٧٨٩'.isdigit() # Arabic-Indic digits zero to nine +- True +- >>> '⅕'.isdigit() # Vulgar fraction one fifth +- False +- >>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric() +- (False, True, True) +- +- See also :meth:`isdecimal` and :meth:`isnumeric`. +- + + .. method:: str.isidentifier() + +@@ -2076,20 +2019,6 @@ + that have the Unicode numeric value property, e.g. U+2155, + VULGAR FRACTION ONE FIFTH. Formally, numeric characters are those with the property + value Numeric_Type=Digit, Numeric_Type=Decimal or Numeric_Type=Numeric. +- For example: +- +- .. doctest:: +- +- >>> '0123456789'.isnumeric() +- True +- >>> '٠١٢٣٤٥٦٧٨٩'.isnumeric() # Arabic-Indic digits zero to nine +- True +- >>> '⅕'.isnumeric() # Vulgar fraction one fifth +- True +- >>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric() +- (False, True, True) +- +- See also :meth:`isdecimal` and :meth:`isdigit`. + + + .. method:: str.isprintable() +@@ -2108,43 +2037,17 @@ + Nonprintable characters are those in group Separator or Other (Z or C), + except the ASCII space. + +- For example: +- +- .. doctest:: +- +- >>> ''.isprintable(), ' '.isprintable() +- (True, True) +- >>> '\t'.isprintable(), '\n'.isprintable() +- (False, False) +- +- See also :meth:`isspace`. +- + + .. method:: str.isspace() + + Return ``True`` if there are only whitespace characters in the string and there is + at least one character, ``False`` otherwise. + +- For example: +- +- .. doctest:: +- +- >>> ''.isspace() +- False +- >>> ' '.isspace() +- True +- >>> '\t\n'.isspace() # TAB and BREAK LINE +- True +- >>> '\u3000'.isspace() # IDEOGRAPHIC SPACE +- True +- + A character is *whitespace* if in the Unicode character database + (see :mod:`unicodedata`), either its general category is ``Zs`` + ("Separator, space"), or its bidirectional class is one of ``WS``, + ``B``, or ``S``. + +- See also :meth:`isprintable`. +- + + .. method:: str.istitle() + +@@ -2207,29 +2110,11 @@ + done using the specified *fillchar* (default is an ASCII space). The + original string is returned if *width* is less than or equal to ``len(s)``. + +- For example: +- +- .. doctest:: +- +- >>> 'Python'.ljust(10) +- 'Python ' +- >>> 'Python'.ljust(10, '.') +- 'Python....' +- >>> 'Monty Python'.ljust(10, '.') +- 'Monty Python' +- +- See also :meth:`rjust`. +- + + .. method:: str.lower() + + Return a copy of the string with all the cased characters [4]_ converted to +- lowercase. For example: +- +- .. doctest:: +- +- >>> 'Lower Method Example'.lower() +- 'lower method example' ++ lowercase. + + The lowercasing algorithm used is + `described in section 3.13 'Default Case Folding' of the Unicode Standard +@@ -2280,27 +2165,12 @@ + after the separator. If the separator is not found, return a 3-tuple containing + the string itself, followed by two empty strings. + +- For example: +- +- .. doctest:: +- +- >>> 'Monty Python'.partition(' ') +- ('Monty', ' ', 'Python') +- >>> "Monty Python's Flying Circus".partition(' ') +- ('Monty', ' ', "Python's Flying Circus") +- >>> 'Monty Python'.partition('-') +- ('Monty Python', '', '') +- +- See also :meth:`rpartition`. +- + + .. method:: str.removeprefix(prefix, /) + + If the string starts with the *prefix* string, return + ``string[len(prefix):]``. Otherwise, return a copy of the original +- string: +- +- .. doctest:: ++ string:: + + >>> 'TestHook'.removeprefix('Test') + 'Hook' +@@ -2309,16 +2179,12 @@ + + .. versionadded:: 3.9 + +- See also :meth:`removesuffix` and :meth:`startswith`. +- + + .. method:: str.removesuffix(suffix, /) + + If the string ends with the *suffix* string and that *suffix* is not empty, + return ``string[:-len(suffix)]``. Otherwise, return a copy of the +- original string: +- +- .. doctest:: ++ original string:: + + >>> 'MiscTests'.removesuffix('Tests') + 'Misc' +@@ -2327,22 +2193,12 @@ + + .. versionadded:: 3.9 + +- See also :meth:`removeprefix` and :meth:`endswith`. +- + + .. method:: str.replace(old, new, /, count=-1) + + Return a copy of the string with all occurrences of substring *old* replaced by + *new*. If *count* is given, only the first *count* occurrences are replaced. + If *count* is not specified or ``-1``, then all occurrences are replaced. +- For example: +- +- .. doctest:: +- +- >>> 'spam, spam, spam'.replace('spam', 'eggs') +- 'eggs, eggs, eggs' +- >>> 'spam, spam, spam'.replace('spam', 'eggs', 1) +- 'eggs, spam, spam' + + .. versionchanged:: 3.13 + *count* is now supported as a keyword argument. +@@ -2353,36 +2209,12 @@ + Return the highest index in the string where substring *sub* is found, such + that *sub* is contained within ``s[start:end]``. Optional arguments *start* + and *end* are interpreted as in slice notation. Return ``-1`` on failure. +- For example: +- +- .. doctest:: +- +- >>> 'spam, spam, spam'.rfind('sp') +- 12 +- >>> 'spam, spam, spam'.rfind('sp', 0, 10) +- 6 +- +- See also :meth:`find` and :meth:`rindex`. + + + .. method:: str.rindex(sub[, start[, end]]) + + Like :meth:`rfind` but raises :exc:`ValueError` when the substring *sub* is not + found. +- For example: +- +- .. doctest:: +- +- >>> 'spam, spam, spam'.rindex('spam') +- 12 +- >>> 'spam, spam, spam'.rindex('eggs') +- Traceback (most recent call last): +- File "", line 1, in +- 'spam, spam, spam'.rindex('eggs') +- ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ +- ValueError: substring not found +- +- See also :meth:`index` and :meth:`find`. + + + .. method:: str.rjust(width, fillchar=' ', /) +@@ -2391,19 +2223,6 @@ + done using the specified *fillchar* (default is an ASCII space). The + original string is returned if *width* is less than or equal to ``len(s)``. + +- For example: +- +- .. doctest:: +- +- >>> 'Python'.rjust(10) +- ' Python' +- >>> 'Python'.rjust(10, '.') +- '....Python' +- >>> 'Monty Python'.rjust(10, '.') +- 'Monty Python' +- +- See also :meth:`ljust` and :meth:`zfill`. +- + + .. method:: str.rpartition(sep, /) + +@@ -2412,19 +2231,6 @@ + after the separator. If the separator is not found, return a 3-tuple containing + two empty strings, followed by the string itself. + +- For example: +- +- .. doctest:: +- +- >>> 'Monty Python'.rpartition(' ') +- ('Monty', ' ', 'Python') +- >>> "Monty Python's Flying Circus".rpartition(' ') +- ("Monty Python's Flying", ' ', 'Circus') +- >>> 'Monty Python'.rpartition('-') +- ('', '', 'Monty Python') +- +- See also :meth:`partition`. +- + + .. method:: str.rsplit(sep=None, maxsplit=-1) + +@@ -2440,17 +2246,14 @@ + Return a copy of the string with trailing characters removed. The *chars* + argument is a string specifying the set of characters to be removed. If omitted + or ``None``, the *chars* argument defaults to removing whitespace. The *chars* +- argument is not a suffix; rather, all combinations of its values are stripped. +- For example: +- +- .. doctest:: ++ argument is not a suffix; rather, all combinations of its values are stripped:: + + >>> ' spacious '.rstrip() + ' spacious' + >>> 'mississippi'.rstrip('ipz') + 'mississ' + +- See :meth:`removesuffix` for a method that will remove a single suffix ++ See :meth:`str.removesuffix` for a method that will remove a single suffix + string rather than all of a set of characters. For example:: + + >>> 'Monty Python'.rstrip(' Python') +@@ -2458,9 +2261,6 @@ + >>> 'Monty Python'.removesuffix(' Python') + 'Monty' + +- See also :meth:`strip`. +- +- + .. method:: str.split(sep=None, maxsplit=-1) + + Return a list of the words in the string, using *sep* as the delimiter +@@ -2476,9 +2276,7 @@ + :func:`re.split`). Splitting an empty string with a specified separator + returns ``['']``. + +- For example: +- +- .. doctest:: ++ For example:: + + >>> '1,2,3'.split(',') + ['1', '2', '3'] +@@ -2496,9 +2294,7 @@ + string or a string consisting of just whitespace with a ``None`` separator + returns ``[]``. + +- For example: +- +- .. doctest:: ++ For example:: + + >>> '1 2 3'.split() + ['1', '2', '3'] +@@ -2510,9 +2306,7 @@ + If *sep* is not specified or is ``None`` and *maxsplit* is ``0``, only + leading runs of consecutive whitespace are considered. + +- For example: +- +- .. doctest:: ++ For example:: + + >>> "".split(None, 0) + [] +@@ -2521,7 +2315,7 @@ + >>> " foo ".split(maxsplit=0) + ['foo '] + +- See also :meth:`join` and :meth:`rsplit`. ++ See also :meth:`join`. + + + .. index:: +@@ -2597,19 +2391,6 @@ + test string beginning at that position. With optional *end*, stop comparing + string at that position. + +- For example: +- +- .. doctest:: +- +- >>> 'Python'.startswith('Py') +- True +- >>> 'a tuple of prefixes'.startswith(('at', 'a')) +- True +- >>> 'Python is amazing'.startswith('is', 7) +- True +- +- See also :meth:`endswith` and :meth:`removeprefix`. +- + + .. method:: str.strip(chars=None, /) + +@@ -2617,13 +2398,7 @@ + The *chars* argument is a string specifying the set of characters to be removed. + If omitted or ``None``, the *chars* argument defaults to removing whitespace. + The *chars* argument is not a prefix or suffix; rather, all combinations of its +- values are stripped. +- +- Whitespace characters are defined by :meth:`str.isspace`. +- +- For example: +- +- .. doctest:: ++ values are stripped:: + + >>> ' spacious '.strip() + 'spacious' +@@ -2634,37 +2409,18 @@ + from the string. Characters are removed from the leading end until + reaching a string character that is not contained in the set of + characters in *chars*. A similar action takes place on the trailing end. +- +- For example: +- +- .. doctest:: ++ For example:: + + >>> comment_string = '#....... Section 3.2.1 Issue #32 .......' + >>> comment_string.strip('.#! ') + 'Section 3.2.1 Issue #32' + +- See also :meth:`rstrip`. +- + + .. method:: str.swapcase() + + Return a copy of the string with uppercase characters converted to lowercase and +- vice versa. For example: +- +- .. doctest:: +- +- >>> 'Hello World'.swapcase() +- 'hELLO wORLD' +- +- Note that it is not necessarily true that ``s.swapcase().swapcase() == s``. +- For example: +- +- .. doctest:: +- +- >>> 'straße'.swapcase().swapcase() +- 'strasse' +- +- See also :meth:`str.lower` and :meth:`str.upper`. ++ vice versa. Note that it is not necessarily true that ++ ``s.swapcase().swapcase() == s``. + + + .. method:: str.title() +@@ -2742,17 +2498,13 @@ + than before. The original string is returned if *width* is less than + or equal to ``len(s)``. + +- For example: +- +- .. doctest:: ++ For example:: + + >>> "42".zfill(5) + '00042' + >>> "-42".zfill(5) + '-0042' + +- See also :meth:`rjust`. +- + + .. index:: + single: ! formatted string literal +@@ -3055,10 +2807,6 @@ + | | character in the result. | | + +------------+-----------------------------------------------------+-------+ + +-For floating-point formats, the result should be correctly rounded to a given +-precision ``p`` of digits after the decimal point. The rounding mode matches +-that of the :func:`round` builtin. +- + Notes: + + (1) +@@ -4854,174 +4602,165 @@ + objects. If *iterable* is not specified, a new empty set is + returned. + +-Sets can be created by several means: ++ Sets can be created by several means: + +-* Use a comma-separated list of elements within braces: ``{'jack', 'sjoerd'}`` +-* Use a set comprehension: ``{c for c in 'abracadabra' if c not in 'abc'}`` +-* Use the type constructor: ``set()``, ``set('foobar')``, ``set(['a', 'b', 'foo'])`` ++ * Use a comma-separated list of elements within braces: ``{'jack', 'sjoerd'}`` ++ * Use a set comprehension: ``{c for c in 'abracadabra' if c not in 'abc'}`` ++ * Use the type constructor: ``set()``, ``set('foobar')``, ``set(['a', 'b', 'foo'])`` + +-Instances of :class:`set` and :class:`frozenset` provide the following +-operations: ++ Instances of :class:`set` and :class:`frozenset` provide the following ++ operations: + +-.. describe:: len(s) ++ .. describe:: len(s) + +- Return the number of elements in set *s* (cardinality of *s*). ++ Return the number of elements in set *s* (cardinality of *s*). + +-.. describe:: x in s ++ .. describe:: x in s + +- Test *x* for membership in *s*. ++ Test *x* for membership in *s*. + +-.. describe:: x not in s ++ .. describe:: x not in s + +- Test *x* for non-membership in *s*. ++ Test *x* for non-membership in *s*. + +-.. method:: frozenset.isdisjoint(other, /) +- set.isdisjoint(other, /) ++ .. method:: isdisjoint(other, /) + +- Return ``True`` if the set has no elements in common with *other*. Sets are +- disjoint if and only if their intersection is the empty set. ++ Return ``True`` if the set has no elements in common with *other*. Sets are ++ disjoint if and only if their intersection is the empty set. + +-.. method:: frozenset.issubset(other, /) +- set.issubset(other, /) +-.. describe:: set <= other ++ .. method:: issubset(other, /) ++ set <= other + +- Test whether every element in the set is in *other*. ++ Test whether every element in the set is in *other*. + +-.. describe:: set < other ++ .. method:: set < other + +- Test whether the set is a proper subset of *other*, that is, +- ``set <= other and set != other``. ++ Test whether the set is a proper subset of *other*, that is, ++ ``set <= other and set != other``. + +-.. method:: frozenset.issuperset(other, /) +- set.issuperset(other, /) +-.. describe:: set >= other ++ .. method:: issuperset(other, /) ++ set >= other + +- Test whether every element in *other* is in the set. ++ Test whether every element in *other* is in the set. + +-.. describe:: set > other ++ .. method:: set > other + +- Test whether the set is a proper superset of *other*, that is, ``set >= +- other and set != other``. ++ Test whether the set is a proper superset of *other*, that is, ``set >= ++ other and set != other``. + +-.. method:: frozenset.union(*others) +- set.union(*others) +-.. describe:: set | other | ... ++ .. method:: union(*others) ++ set | other | ... + +- Return a new set with elements from the set and all others. ++ Return a new set with elements from the set and all others. + +-.. method:: frozenset.intersection(*others) +- set.intersection(*others) +-.. describe:: set & other & ... ++ .. method:: intersection(*others) ++ set & other & ... + +- Return a new set with elements common to the set and all others. ++ Return a new set with elements common to the set and all others. + +-.. method:: frozenset.difference(*others) +- set.difference(*others) +-.. describe:: set - other - ... ++ .. method:: difference(*others) ++ set - other - ... + +- Return a new set with elements in the set that are not in the others. ++ Return a new set with elements in the set that are not in the others. + +-.. method:: frozenset.symmetric_difference(other, /) +- set.symmetric_difference(other, /) +-.. describe:: set ^ other ++ .. method:: symmetric_difference(other, /) ++ set ^ other + +- Return a new set with elements in either the set or *other* but not both. ++ Return a new set with elements in either the set or *other* but not both. + +-.. method:: frozenset.copy() +- set.copy() ++ .. method:: copy() + +- Return a shallow copy of the set. ++ Return a shallow copy of the set. + + +-Note, the non-operator versions of :meth:`~frozenset.union`, +-:meth:`~frozenset.intersection`, :meth:`~frozenset.difference`, :meth:`~frozenset.symmetric_difference`, :meth:`~frozenset.issubset`, and +-:meth:`~frozenset.issuperset` methods will accept any iterable as an argument. In +-contrast, their operator based counterparts require their arguments to be +-sets. This precludes error-prone constructions like ``set('abc') & 'cbs'`` +-in favor of the more readable ``set('abc').intersection('cbs')``. ++ Note, the non-operator versions of :meth:`union`, :meth:`intersection`, ++ :meth:`difference`, :meth:`symmetric_difference`, :meth:`issubset`, and ++ :meth:`issuperset` methods will accept any iterable as an argument. In ++ contrast, their operator based counterparts require their arguments to be ++ sets. This precludes error-prone constructions like ``set('abc') & 'cbs'`` ++ in favor of the more readable ``set('abc').intersection('cbs')``. + +-Both :class:`set` and :class:`frozenset` support set to set comparisons. Two +-sets are equal if and only if every element of each set is contained in the +-other (each is a subset of the other). A set is less than another set if and +-only if the first set is a proper subset of the second set (is a subset, but +-is not equal). A set is greater than another set if and only if the first set +-is a proper superset of the second set (is a superset, but is not equal). ++ Both :class:`set` and :class:`frozenset` support set to set comparisons. Two ++ sets are equal if and only if every element of each set is contained in the ++ other (each is a subset of the other). A set is less than another set if and ++ only if the first set is a proper subset of the second set (is a subset, but ++ is not equal). A set is greater than another set if and only if the first set ++ is a proper superset of the second set (is a superset, but is not equal). + +-Instances of :class:`set` are compared to instances of :class:`frozenset` +-based on their members. For example, ``set('abc') == frozenset('abc')`` +-returns ``True`` and so does ``set('abc') in set([frozenset('abc')])``. ++ Instances of :class:`set` are compared to instances of :class:`frozenset` ++ based on their members. For example, ``set('abc') == frozenset('abc')`` ++ returns ``True`` and so does ``set('abc') in set([frozenset('abc')])``. + +-The subset and equality comparisons do not generalize to a total ordering +-function. For example, any two nonempty disjoint sets are not equal and are not +-subsets of each other, so *all* of the following return ``False``: ``ab``. ++ The subset and equality comparisons do not generalize to a total ordering ++ function. For example, any two nonempty disjoint sets are not equal and are not ++ subsets of each other, so *all* of the following return ``False``: ``ab``. + +-Since sets only define partial ordering (subset relationships), the output of +-the :meth:`list.sort` method is undefined for lists of sets. ++ Since sets only define partial ordering (subset relationships), the output of ++ the :meth:`list.sort` method is undefined for lists of sets. + +-Set elements, like dictionary keys, must be :term:`hashable`. ++ Set elements, like dictionary keys, must be :term:`hashable`. + +-Binary operations that mix :class:`set` instances with :class:`frozenset` +-return the type of the first operand. For example: ``frozenset('ab') | +-set('bc')`` returns an instance of :class:`frozenset`. ++ Binary operations that mix :class:`set` instances with :class:`frozenset` ++ return the type of the first operand. For example: ``frozenset('ab') | ++ set('bc')`` returns an instance of :class:`frozenset`. + +-The following table lists operations available for :class:`set` that do not +-apply to immutable instances of :class:`frozenset`: ++ The following table lists operations available for :class:`set` that do not ++ apply to immutable instances of :class:`frozenset`: + +-.. method:: set.update(*others) +-.. describe:: set |= other | ... ++ .. method:: update(*others) ++ set |= other | ... + +- Update the set, adding elements from all others. ++ Update the set, adding elements from all others. + +-.. method:: set.intersection_update(*others) +-.. describe:: set &= other & ... ++ .. method:: intersection_update(*others) ++ set &= other & ... + +- Update the set, keeping only elements found in it and all others. ++ Update the set, keeping only elements found in it and all others. + +-.. method:: set.difference_update(*others) +-.. describe:: set -= other | ... ++ .. method:: difference_update(*others) ++ set -= other | ... + +- Update the set, removing elements found in others. ++ Update the set, removing elements found in others. + +-.. method:: set.symmetric_difference_update(other, /) +-.. describe:: set ^= other ++ .. method:: symmetric_difference_update(other, /) ++ set ^= other + +- Update the set, keeping only elements found in either set, but not in both. ++ Update the set, keeping only elements found in either set, but not in both. + +-.. method:: set.add(elem, /) ++ .. method:: add(elem, /) + +- Add element *elem* to the set. ++ Add element *elem* to the set. + +-.. method:: set.remove(elem, /) ++ .. method:: remove(elem, /) + +- Remove element *elem* from the set. Raises :exc:`KeyError` if *elem* is +- not contained in the set. ++ Remove element *elem* from the set. Raises :exc:`KeyError` if *elem* is ++ not contained in the set. + +-.. method:: set.discard(elem, /) ++ .. method:: discard(elem, /) + +- Remove element *elem* from the set if it is present. ++ Remove element *elem* from the set if it is present. + +-.. method:: set.pop() ++ .. method:: pop() + +- Remove and return an arbitrary element from the set. Raises +- :exc:`KeyError` if the set is empty. ++ Remove and return an arbitrary element from the set. Raises ++ :exc:`KeyError` if the set is empty. + +-.. method:: set.clear() ++ .. method:: clear() + +- Remove all elements from the set. ++ Remove all elements from the set. + + +-Note, the non-operator versions of the :meth:`~set.update`, +-:meth:`~set.intersection_update`, :meth:`~set.difference_update`, and +-:meth:`~set.symmetric_difference_update` methods will accept any iterable as an +-argument. ++ Note, the non-operator versions of the :meth:`update`, ++ :meth:`intersection_update`, :meth:`difference_update`, and ++ :meth:`symmetric_difference_update` methods will accept any iterable as an ++ argument. + +-Note, the *elem* argument to the :meth:`~object.__contains__`, +-:meth:`~set.remove`, and +-:meth:`~set.discard` methods may be a set. To support searching for an equivalent +-frozenset, a temporary one is created from *elem*. ++ Note, the *elem* argument to the :meth:`~object.__contains__`, ++ :meth:`remove`, and ++ :meth:`discard` methods may be a set. To support searching for an equivalent ++ frozenset, a temporary one is created from *elem*. + +-Sets and frozensets are :ref:`generic ` over the type of their elements. + + .. _typesmapping: + +@@ -5079,6 +4818,9 @@ + being added is already present, the value from the keyword argument + replaces the value from the positional argument. + ++ Providing keyword arguments as in the first example only works for keys that ++ are valid Python identifiers. Otherwise, any valid keys can be used. ++ + Dictionaries compare equal if and only if they have the same ``(key, + value)`` pairs (regardless of ordering). Order comparisons ('<', '<=', '>=', '>') raise + :exc:`TypeError`. To illustrate dictionary creation and equality, +@@ -5119,9 +4861,6 @@ + Dictionary order is guaranteed to be insertion order. This behavior was + an implementation detail of CPython from 3.6. + +- Dictionaries are :ref:`generic ` over two types, signifying +- (respectively) the types of the dictionary's keys and values. +- + These are the operations that dictionaries support (and therefore, custom + mapping types should support too): + +@@ -5467,11 +5206,9 @@ + Returning a true value from this method will cause the :keyword:`with` statement + to suppress the exception and continue execution with the statement immediately + following the :keyword:`!with` statement. Otherwise the exception continues +- propagating after this method has finished executing. +- +- If this method raises an exception while handling an earlier exception from the +- :keyword:`with` block, the new exception is raised, and the original exception +- is stored in its :attr:`~BaseException.__context__` attribute. ++ propagating after this method has finished executing. Exceptions that occur ++ during execution of this method will replace any exception that occurred in the ++ body of the :keyword:`!with` statement. + + The exception passed in should never be reraised explicitly - instead, this + method should return a false value to indicate that the method completed +@@ -5560,8 +5297,7 @@ + + ``GenericAlias`` objects are instances of the class + :class:`types.GenericAlias`, which can also be used to create ``GenericAlias`` +-objects directly. Specializations of user-defined :ref:`generic classes ` +-may not be instances of :class:`types.GenericAlias`, but they provide similar functionality. ++objects directly. + + .. describe:: T[X, Y, ...] + +@@ -5610,15 +5346,6 @@ + >>> type(l) + + +- +-Instances of ``GenericAlias`` are not classes at runtime, even though they behave like classes (they can be instantiated and subclassed):: +- +- >>> import inspect +- >>> inspect.isclass(list[int]) +- False +- +-This is true for :ref:`user-defined generics ` also. +- + Calling :func:`repr` or :func:`str` on a generic shows the parameterized type:: + + >>> repr(list[int]) +diff --git a/Doc/library/string.rst b/Doc/library/string.rst +index b7b92ecb14f..e0ecb3799ea 100644 +--- a/Doc/library/string.rst ++++ b/Doc/library/string.rst +@@ -82,7 +82,7 @@ + + .. _string-formatting: + +-Custom string formatting ++Custom String Formatting + ------------------------ + + The built-in string class provides the ability to do complex variable +@@ -190,7 +190,7 @@ + + .. _formatstrings: + +-Format string syntax ++Format String Syntax + -------------------- + + The :meth:`str.format` method and the :class:`Formatter` class share the same +@@ -299,7 +299,7 @@ + + .. _formatspec: + +-Format specification mini-language ++Format Specification Mini-Language + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + "Format specifications" are used within replacement fields contained within a +@@ -457,9 +457,7 @@ + | | this option is not supported. | + +---------+----------------------------------------------------------+ + +-For a locale-aware separator, use the ``'n'`` +-:ref:`float presentation type ` or +-:ref:`integer presentation type ` instead. ++For a locale aware separator, use the ``'n'`` presentation type instead. + + .. versionchanged:: 3.1 + Added the ``','`` option (see also :pep:`378`). +@@ -510,14 +508,9 @@ + | | In case ``'#'`` is specified, the prefix ``'0x'`` will | + | | be upper-cased to ``'0X'`` as well. | + +---------+----------------------------------------------------------+ +- | ``'n'`` | .. _n-format-integer: | +- | | | +- | | Number. This is the same as ``'d'``, except that it uses | ++ | ``'n'`` | Number. This is the same as ``'d'``, except that it uses | + | | the current locale setting to insert the appropriate | +- | | digit group separators. Note that the default locale is | +- | | not the system locale. Depending on your use case, you | +- | | may wish to set :const:`~locale.LC_NUMERIC` with | +- | | :func:`locale.setlocale` before using ``'n'``. | ++ | | digit group separators. | + +---------+----------------------------------------------------------+ + | None | The same as ``'d'``. | + +---------+----------------------------------------------------------+ +@@ -543,9 +536,6 @@ + | | :class:`float`, and shows all coefficient digits | + | | for :class:`~decimal.Decimal`. If ``p=0``, the decimal | + | | point is omitted unless the ``#`` option is used. | +- | | | +- | | For :class:`float`, the exponent always contains at | +- | | least two digits, and is zero if the value is zero. | + +---------+----------------------------------------------------------+ + | ``'E'`` | Scientific notation. Same as ``'e'`` except it uses | + | | an upper case 'E' as the separator character. | +@@ -600,15 +590,10 @@ + | | ``'E'`` if the number gets too large. The | + | | representations of infinity and NaN are uppercased, too. | + +---------+----------------------------------------------------------+ +- | ``'n'`` | .. _n-format-float: | +- | | | +- | | Number. This is the same as ``'g'``, except that it uses | ++ | ``'n'`` | Number. This is the same as ``'g'``, except that it uses | + | | the current locale setting to insert the appropriate | +- | | digit group separators for the integral part of a | +- | | number. Note that the default locale is not the system | +- | | locale. Depending on your use case, you may wish to set | +- | | :const:`~locale.LC_NUMERIC` with | +- | | :func:`locale.setlocale` before using ``'n'``. | ++ | | digit group separators | ++ | | for the integral part of a number. | + +---------+----------------------------------------------------------+ + | ``'%'`` | Percentage. Multiplies the number by 100 and displays | + | | in fixed (``'f'``) format, followed by a percent sign. | +@@ -755,8 +740,8 @@ + + Using type-specific formatting:: + +- >>> import datetime as dt +- >>> d = dt.datetime(2010, 7, 4, 12, 15, 58) ++ >>> import datetime ++ >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58) + >>> '{:%Y-%m-%d %H:%M:%S}'.format(d) + '2010-07-04 12:15:58' + +diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst +index 56930274914..4769affdf1d 100644 +--- a/Doc/library/struct.rst ++++ b/Doc/library/struct.rst +@@ -227,34 +227,34 @@ + +--------+--------------------------+--------------------+----------------+------------+ + | ``c`` | :c:expr:`char` | bytes of length 1 | 1 | | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``b`` | :c:expr:`signed char` | int | 1 | \(2) | ++| ``b`` | :c:expr:`signed char` | integer | 1 | \(1), \(2) | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``B`` | :c:expr:`unsigned char` | int | 1 | \(2) | ++| ``B`` | :c:expr:`unsigned char` | integer | 1 | \(2) | + +--------+--------------------------+--------------------+----------------+------------+ + | ``?`` | :c:expr:`_Bool` | bool | 1 | \(1) | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``h`` | :c:expr:`short` | int | 2 | \(2) | ++| ``h`` | :c:expr:`short` | integer | 2 | \(2) | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``H`` | :c:expr:`unsigned short` | int | 2 | \(2) | ++| ``H`` | :c:expr:`unsigned short` | integer | 2 | \(2) | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``i`` | :c:expr:`int` | int | 4 | \(2) | ++| ``i`` | :c:expr:`int` | integer | 4 | \(2) | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``I`` | :c:expr:`unsigned int` | int | 4 | \(2) | ++| ``I`` | :c:expr:`unsigned int` | integer | 4 | \(2) | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``l`` | :c:expr:`long` | int | 4 | \(2) | ++| ``l`` | :c:expr:`long` | integer | 4 | \(2) | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``L`` | :c:expr:`unsigned long` | int | 4 | \(2) | ++| ``L`` | :c:expr:`unsigned long` | integer | 4 | \(2) | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``q`` | :c:expr:`long long` | int | 8 | \(2) | ++| ``q`` | :c:expr:`long long` | integer | 8 | \(2) | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``Q`` | :c:expr:`unsigned long | int | 8 | \(2) | ++| ``Q`` | :c:expr:`unsigned long | integer | 8 | \(2) | + | | long` | | | | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``n`` | :c:type:`ssize_t` | int | | \(2), \(3) | ++| ``n`` | :c:type:`ssize_t` | integer | | \(3) | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``N`` | :c:type:`size_t` | int | | \(2), \(3) | ++| ``N`` | :c:type:`size_t` | integer | | \(3) | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``e`` | :c:expr:`_Float16` | float | 2 | \(4), \(6) | ++| ``e`` | \(6) | float | 2 | \(4) | + +--------+--------------------------+--------------------+----------------+------------+ + | ``f`` | :c:expr:`float` | float | 4 | \(4) | + +--------+--------------------------+--------------------+----------------+------------+ +@@ -264,7 +264,7 @@ + +--------+--------------------------+--------------------+----------------+------------+ + | ``p`` | :c:expr:`char[]` | bytes | | \(8) | + +--------+--------------------------+--------------------+----------------+------------+ +-| ``P`` | :c:expr:`void \*` | int | | \(2), \(5) | ++| ``P`` | :c:expr:`void \*` | integer | | \(5) | + +--------+--------------------------+--------------------+----------------+------------+ + + .. versionchanged:: 3.3 +@@ -315,9 +315,7 @@ + revision of the `IEEE 754 standard `_. It has a sign + bit, a 5-bit exponent and 11-bit precision (with 10 bits explicitly stored), + and can represent numbers between approximately ``6.1e-05`` and ``6.5e+04`` +- at full precision. This type is not widely supported by C compilers: +- it's available as :c:expr:`_Float16` type, if the compiler supports the Annex H +- of the C23 standard. On a ++ at full precision. This type is not widely supported by C compilers: on a + typical machine, an unsigned short can be used for storage, but not for math + operations. See the Wikipedia page on the `half-precision floating-point + format `_ for more information. +@@ -329,31 +327,27 @@ + The ``'p'`` format character encodes a "Pascal string", meaning a short + variable-length string stored in a *fixed number of bytes*, given by the count. + The first byte stored is the length of the string, or 255, whichever is +- smaller. The bytes of the string follow. If the byte string passed in to ++ smaller. The bytes of the string follow. If the string passed in to + :func:`pack` is too long (longer than the count minus 1), only the leading +- ``count-1`` bytes of the string are stored. If the byte string is shorter than ++ ``count-1`` bytes of the string are stored. If the string is shorter than + ``count-1``, it is padded with null bytes so that exactly count bytes in all + are used. Note that for :func:`unpack`, the ``'p'`` format character consumes +- ``count`` bytes, but that the :class:`!bytes` object returned can never contain more than 255 ++ ``count`` bytes, but that the string returned can never contain more than 255 + bytes. +- When packing, arguments of types :class:`bytes` and :class:`bytearray` +- are accepted. + + (9) + For the ``'s'`` format character, the count is interpreted as the length of the +- byte string, not a repeat count like for the other format characters; for example, ++ bytes, not a repeat count like for the other format characters; for example, + ``'10s'`` means a single 10-byte string mapping to or from a single + Python byte string, while ``'10c'`` means 10 + separate one byte character elements (e.g., ``cccccccccc``) mapping + to or from ten different Python byte objects. (See :ref:`struct-examples` + for a concrete demonstration of the difference.) +- If a count is not given, it defaults to 1. For packing, the byte string is ++ If a count is not given, it defaults to 1. For packing, the string is + truncated or padded with null bytes as appropriate to make it fit. For +- unpacking, the resulting :class:`!bytes` object always has exactly the specified number +- of bytes. As a special case, ``'0s'`` means a single, empty byte string (while ++ unpacking, the resulting bytes object always has exactly the specified number ++ of bytes. As a special case, ``'0s'`` means a single, empty string (while + ``'0c'`` means 0 characters). +- When packing, arguments of types :class:`bytes` and :class:`bytearray` +- are accepted. + + A format character may be preceded by an integral repeat count. For example, + the format string ``'4h'`` means exactly the same as ``'hhhh'``. +diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst +index 0dbfcdbf730..f6d9a6133fa 100644 +--- a/Doc/library/subprocess.rst ++++ b/Doc/library/subprocess.rst +@@ -630,12 +630,6 @@ + the value in ``pw_uid`` will be used. If the value is an integer, it will + be passed verbatim. (POSIX only) + +- .. note:: +- +- Specifying *user* will not drop existing supplementary group memberships! +- The caller must also pass ``extra_groups=()`` to reduce the group membership +- of the child process for security purposes. +- + .. availability:: POSIX + .. versionadded:: 3.9 + +@@ -958,11 +952,6 @@ + A negative value ``-N`` indicates that the child was terminated by signal + ``N`` (POSIX only). + +- When ``shell=True``, the return code reflects the exit status of the shell +- itself (e.g. ``/bin/sh``), which may map signals to codes such as +- ``128+N``. See the documentation of the shell (for example, the Bash +- manual's Exit Status) for details. +- + + Windows Popen Helpers + --------------------- +diff --git a/Doc/library/sys.monitoring.rst b/Doc/library/sys.monitoring.rst +index ee031bfc4aa..f8b0350ad3c 100644 +--- a/Doc/library/sys.monitoring.rst ++++ b/Doc/library/sys.monitoring.rst +@@ -10,10 +10,10 @@ + + .. note:: + +- :mod:`!sys.monitoring` is a namespace within the :mod:`sys` module, +- not an independent module, and ``import sys.monitoring`` would fail +- with a :exc:`ModuleNotFoundError`. Instead, simply ``import sys`` +- and then use ``sys.monitoring``. ++ :mod:`sys.monitoring` is a namespace within the :mod:`sys` module, ++ not an independent module, so there is no need to ++ ``import sys.monitoring``, simply ``import sys`` and then use ++ ``sys.monitoring``. + + + This namespace provides access to the functions and constants necessary to +diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst +index 52ca502012b..efdf3f59e35 100644 +--- a/Doc/library/sys.rst ++++ b/Doc/library/sys.rst +@@ -508,7 +508,7 @@ + in the range 0--127, and produce undefined results otherwise. Some systems + have a convention for assigning specific meanings to specific exit codes, but + these are generally underdeveloped; Unix programs generally use 2 for command +- line syntax errors and 1 for all other kinds of errors. If another type of ++ line syntax errors and 1 for all other kind of errors. If another type of + object is passed, ``None`` is equivalent to passing zero, and any other + object is printed to :data:`stderr` and results in an exit code of 1. In + particular, ``sys.exit("some error message")`` is a quick way to exit a +diff --git a/Doc/library/syslog.rst b/Doc/library/syslog.rst +index b6bf0124095..548898a37bc 100644 +--- a/Doc/library/syslog.rst ++++ b/Doc/library/syslog.rst +@@ -2,6 +2,7 @@ + =============================================== + + .. module:: syslog ++ :platform: Unix + :synopsis: An interface to the Unix syslog library routines. + + -------------- +diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst +index 9d26f47820b..f0a81a093b4 100644 +--- a/Doc/library/tempfile.rst ++++ b/Doc/library/tempfile.rst +@@ -225,9 +225,8 @@ + properly implements the :const:`os.O_EXCL` flag for :func:`os.open`. The + file is readable and writable only by the creating user ID. If the + platform uses permission bits to indicate whether a file is executable, +- the file is executable by no one. +- +- The file descriptor is :ref:`not inherited by child processes `. ++ the file is executable by no one. The file descriptor is not inherited ++ by child processes. + + Unlike :func:`TemporaryFile`, the user of :func:`mkstemp` is responsible + for deleting the temporary file when done with it. +diff --git a/Doc/library/termios.rst b/Doc/library/termios.rst +index 64245bf0d62..0c6f3059fe7 100644 +--- a/Doc/library/termios.rst ++++ b/Doc/library/termios.rst +@@ -2,6 +2,7 @@ + =========================================== + + .. module:: termios ++ :platform: Unix + :synopsis: POSIX style tty control. + + .. index:: +diff --git a/Doc/library/test.rst b/Doc/library/test.rst +index a17838a73cd..04d28aee0f8 100644 +--- a/Doc/library/test.rst ++++ b/Doc/library/test.rst +@@ -468,12 +468,6 @@ + tests. + + +-.. function:: get_resource_value(resource) +- +- Return the value specified for *resource* (as :samp:`-u {resource}={value}`). +- Return ``None`` if *resource* is disabled or no value is specified. +- +- + .. function:: python_is_optimized() + + Return ``True`` if Python was not built with ``-O0`` or ``-Og``. +diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst +index 08d2d89f43d..7471f9bf507 100644 +--- a/Doc/library/threading.rst ++++ b/Doc/library/threading.rst +@@ -512,7 +512,7 @@ + This constructor should always be called with keyword arguments. Arguments + are: + +- *group* must be ``None`` as it is reserved for future extension when a ++ *group* should be ``None``; reserved for future extension when a + :class:`!ThreadGroup` class is implemented. + + *target* is the callable object to be invoked by the :meth:`run` method. +diff --git a/Doc/library/tkinter.colorchooser.rst b/Doc/library/tkinter.colorchooser.rst +index edb02d60d2d..df2b324fd5d 100644 +--- a/Doc/library/tkinter.colorchooser.rst ++++ b/Doc/library/tkinter.colorchooser.rst +@@ -2,6 +2,7 @@ + ====================================================== + + .. module:: tkinter.colorchooser ++ :platform: Tk + :synopsis: Color choosing dialog + + **Source code:** :source:`Lib/tkinter/colorchooser.py` +diff --git a/Doc/library/tkinter.dnd.rst b/Doc/library/tkinter.dnd.rst +index 5cbfe8a37bd..62298d96c26 100644 +--- a/Doc/library/tkinter.dnd.rst ++++ b/Doc/library/tkinter.dnd.rst +@@ -2,6 +2,7 @@ + ============================================= + + .. module:: tkinter.dnd ++ :platform: Tk + :synopsis: Tkinter drag-and-drop interface + + **Source code:** :source:`Lib/tkinter/dnd.py` +diff --git a/Doc/library/tkinter.font.rst b/Doc/library/tkinter.font.rst +index 3b99eb58d0f..ed01bd5f483 100644 +--- a/Doc/library/tkinter.font.rst ++++ b/Doc/library/tkinter.font.rst +@@ -2,6 +2,7 @@ + ============================================= + + .. module:: tkinter.font ++ :platform: Tk + :synopsis: Tkinter font-wrapping class + + **Source code:** :source:`Lib/tkinter/font.py` +diff --git a/Doc/library/tkinter.messagebox.rst b/Doc/library/tkinter.messagebox.rst +index e2676bafad2..0dc9632ca73 100644 +--- a/Doc/library/tkinter.messagebox.rst ++++ b/Doc/library/tkinter.messagebox.rst +@@ -2,6 +2,7 @@ + ====================================================== + + .. module:: tkinter.messagebox ++ :platform: Tk + :synopsis: Various types of alert dialogs + + **Source code:** :source:`Lib/tkinter/messagebox.py` +diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst +index 86395b7365e..22e08c45d01 100644 +--- a/Doc/library/tkinter.rst ++++ b/Doc/library/tkinter.rst +@@ -175,12 +175,12 @@ + .. attribute:: master + + The widget object that contains this widget. For :class:`Tk`, the +- :attr:`!master` is :const:`None` because it is the main window. The terms ++ *master* is :const:`None` because it is the main window. The terms + *master* and *parent* are similar and sometimes used interchangeably + as argument names; however, calling :meth:`winfo_parent` returns a +- string of the widget name whereas :attr:`!master` returns the object. ++ string of the widget name whereas :attr:`master` returns the object. + *parent*/*child* reflects the tree-like relationship while +- *master* (or *container*)/*content* reflects the container structure. ++ *master*/*slave* reflects the container structure. + + .. attribute:: children + +@@ -636,15 +636,15 @@ + .. index:: single: packing (widgets) + + The packer is one of Tk's geometry-management mechanisms. Geometry managers +-are used to specify the relative positioning of widgets within their container. +-In contrast to the more cumbersome *placer* (which is ++are used to specify the relative positioning of widgets within their container - ++their mutual *master*. In contrast to the more cumbersome *placer* (which is + used less commonly, and we do not cover here), the packer takes qualitative + relationship specification - *above*, *to the left of*, *filling*, etc - and + works everything out to determine the exact placement coordinates for you. + +-The size of any container widget is determined by the size of the "content widgets" +-inside. The packer is used to control where content widgets appear inside the +-container into which they are packed. You can pack widgets into frames, and frames ++The size of any *master* widget is determined by the size of the "slave widgets" ++inside. The packer is used to control where slave widgets appear inside the ++master into which they are packed. You can pack widgets into frames, and frames + into other frames, in order to achieve the kind of layout you desire. + Additionally, the arrangement is dynamically adjusted to accommodate incremental + changes to the configuration, once it is packed. +@@ -671,7 +671,7 @@ + see the man pages and page 183 of John Ousterhout's book. + + anchor +- Anchor type. Denotes where the packer is to place each content in its parcel. ++ Anchor type. Denotes where the packer is to place each slave in its parcel. + + expand + Boolean, ``0`` or ``1``. +@@ -680,10 +680,10 @@ + Legal values: ``'x'``, ``'y'``, ``'both'``, ``'none'``. + + ipadx and ipady +- A distance - designating internal padding on each side of the content. ++ A distance - designating internal padding on each side of the slave widget. + + padx and pady +- A distance - designating external padding on each side of the content. ++ A distance - designating external padding on each side of the slave widget. + + side + Legal values are: ``'left'``, ``'right'``, ``'top'``, ``'bottom'``. +@@ -756,8 +756,8 @@ + directly. + + To get at the toplevel window that contains a given widget, you can often just +-refer to the widget's :attr:`master`. Of course if the widget has been packed inside of +-a frame, the :attr:`!master` won't represent a toplevel window. To get at the toplevel ++refer to the widget's master. Of course if the widget has been packed inside of ++a frame, the master won't represent a toplevel window. To get at the toplevel + window that contains an arbitrary widget, you can call the :meth:`_root` method. + This method begins with an underscore to denote the fact that this function is + part of the implementation, and not an interface to Tk functionality. +diff --git a/Doc/library/tkinter.scrolledtext.rst b/Doc/library/tkinter.scrolledtext.rst +index 9c755026c7d..763e24929d7 100644 +--- a/Doc/library/tkinter.scrolledtext.rst ++++ b/Doc/library/tkinter.scrolledtext.rst +@@ -2,6 +2,7 @@ + ===================================================== + + .. module:: tkinter.scrolledtext ++ :platform: Tk + :synopsis: Text widget with a vertical scroll bar. + + .. sectionauthor:: Fred L. Drake, Jr. +diff --git a/Doc/library/tomllib.rst b/Doc/library/tomllib.rst +index 77555c0e484..521a7a17fb3 100644 +--- a/Doc/library/tomllib.rst ++++ b/Doc/library/tomllib.rst +@@ -17,13 +17,6 @@ + Language, `https://toml.io `_). This module does not + support writing TOML. + +-.. warning:: +- +- Be cautious when parsing data from untrusted sources. +- A malicious TOML string may cause the decoder to consume considerable +- CPU and memory resources. +- Limiting the size of data to be parsed is recommended. +- + .. seealso:: + + The :pypi:`Tomli-W package ` +diff --git a/Doc/library/trace.rst b/Doc/library/trace.rst +index b73710fd6c0..cae94ea08e1 100644 +--- a/Doc/library/trace.rst ++++ b/Doc/library/trace.rst +@@ -43,7 +43,7 @@ + Display the version of the module and exit. + + .. versionadded:: 3.8 +- Added ``--module`` option that allows running an executable module. ++ Added ``--module`` option that allows to run an executable module. + + Main options + ^^^^^^^^^^^^ +diff --git a/Doc/library/traceback.rst b/Doc/library/traceback.rst +index 44b85c3e82f..291c2f1ce75 100644 +--- a/Doc/library/traceback.rst ++++ b/Doc/library/traceback.rst +@@ -143,7 +143,9 @@ + :ref:`traceback object ` *tb*. It is useful + for alternate formatting of stack traces. The optional *limit* argument has + the same meaning as for :func:`print_tb`. A "pre-processed" stack trace +- entry is a :class:`FrameSummary` object with attributes representing the ++ entry is a :class:`FrameSummary` object containing attributes ++ :attr:`~FrameSummary.filename`, :attr:`~FrameSummary.lineno`, ++ :attr:`~FrameSummary.name`, and :attr:`~FrameSummary.line` representing the + information that is usually printed for a stack trace. + + +@@ -175,7 +177,7 @@ + .. function:: format_exception_only(exc, /[, value], *, show_group=False) + + Format the exception part of a traceback using an exception value such as +- given by :data:`sys.last_exc`. The return value is a list of strings, each ++ given by :data:`sys.last_value`. The return value is a list of strings, each + ending in a newline. The list contains the exception's message, which is + normally a single string; however, for :exc:`SyntaxError` exceptions, it + contains several lines that (when printed) display detailed information +@@ -336,7 +338,7 @@ + + .. attribute:: exc_type + +- The class of the original exception. ++ The class of the original traceback. + + .. deprecated:: 3.13 + +@@ -380,7 +382,7 @@ + + For syntax errors - the compiler error message. + +- .. classmethod:: from_exception(exc, *, limit=None, lookup_lines=True, capture_locals=False, compact=False, max_group_width=15, max_group_depth=10) ++ .. classmethod:: from_exception(exc, *, limit=None, lookup_lines=True, capture_locals=False) + + Capture an exception for later rendering. *limit*, *lookup_lines* and + *capture_locals* are as for the :class:`StackSummary` class. +diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst +index f6b6fad8559..2370d927292 100644 +--- a/Doc/library/tracemalloc.rst ++++ b/Doc/library/tracemalloc.rst +@@ -589,7 +589,7 @@ + + If *cumulative* is ``True``, cumulate size and count of memory blocks of + all frames of the traceback of a trace, not only the most recent frame. +- The cumulative mode can only be used with *key_type* equal to ++ The cumulative mode can only be used with *key_type* equals to + ``'filename'`` and ``'lineno'``. + + The result is sorted from the biggest to the smallest by: +@@ -720,10 +720,11 @@ + When a snapshot is taken, tracebacks of traces are limited to + :func:`get_traceback_limit` frames. See the :func:`take_snapshot` function. + The original number of frames of the traceback is stored in the +- :attr:`Traceback.total_nframe` attribute. That allows one to know if a traceback ++ :attr:`Traceback.total_nframe` attribute. That allows to know if a traceback + has been truncated by the traceback limit. + +- The :attr:`Trace.traceback` attribute is a :class:`Traceback` instance. ++ The :attr:`Trace.traceback` attribute is an instance of :class:`Traceback` ++ instance. + + .. versionchanged:: 3.7 + Frames are now sorted from the oldest to the most recent, instead of most recent to oldest. +diff --git a/Doc/library/tty.rst b/Doc/library/tty.rst +index 5d22508f294..37778bf20bd 100644 +--- a/Doc/library/tty.rst ++++ b/Doc/library/tty.rst +@@ -2,6 +2,7 @@ + ========================================== + + .. module:: tty ++ :platform: Unix + :synopsis: Utility functions that perform common terminal control operations. + + .. moduleauthor:: Steen Lumholt +diff --git a/Doc/library/types.rst b/Doc/library/types.rst +index 252fbb51679..439e119461f 100644 +--- a/Doc/library/types.rst ++++ b/Doc/library/types.rst +@@ -143,7 +143,7 @@ + + Standard names are defined for the following types: + +-.. class:: NoneType ++.. data:: NoneType + + The type of :data:`None`. + +@@ -233,7 +233,7 @@ + .. versionadded:: 3.7 + + +-.. class:: NotImplementedType ++.. data:: NotImplementedType + + The type of :data:`NotImplemented`. + +@@ -273,7 +273,7 @@ + creating :class:`!ModuleType` instances which ensures the various + attributes are set appropriately. + +-.. class:: EllipsisType ++.. data:: EllipsisType + + The type of :data:`Ellipsis`. + +@@ -360,10 +360,6 @@ + entries, which means that when the mapping changes, the view reflects these + changes. + +- :class:`!MappingProxyType`\s are :ref:`generic ` over two types, +- signifying (respectively) the types of the underlying mapping's keys and +- values. +- + .. versionadded:: 3.3 + + .. versionchanged:: 3.9 +diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst +index b3cde1aca8f..febabb5bb6d 100644 +--- a/Doc/library/typing.rst ++++ b/Doc/library/typing.rst +@@ -719,8 +719,8 @@ + ==================== + + A special kind of type is :data:`Any`. A static type checker will treat +-every type as assignable to :data:`Any` and :data:`Any` as assignable to +-every type. ++every type as being compatible with :data:`Any` and :data:`Any` as being ++compatible with every type. + + This means that it is possible to perform any operation or method call on a + value of type :data:`Any` and assign it to any variable:: +@@ -785,7 +785,7 @@ + hash_a(42) + hash_a("foo") + +- # Passes type checking, since Any is assignable to all types ++ # Passes type checking, since Any is compatible with all types + hash_b(42) + hash_b("foo") + +@@ -813,7 +813,7 @@ + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[int]: ... + +-:pep:`544` solves this problem by allowing users to write ++:pep:`544` allows to solve this problem by allowing users to write + the above code without explicit base classes in the class definition, + allowing ``Bucket`` to be implicitly considered a subtype of both ``Sized`` + and ``Iterable[int]`` by static type checkers. This is known as +@@ -851,8 +851,8 @@ + + Special type indicating an unconstrained type. + +- * Every type is assignable to :data:`Any`. +- * :data:`Any` is assignable to every type. ++ * Every type is compatible with :data:`Any`. ++ * :data:`Any` is compatible with every type. + + .. versionchanged:: 3.11 + :data:`Any` can now be used as a base class. This can be useful for +@@ -1166,8 +1166,7 @@ + or transforms parameters of another + callable. Usage is in the form + ``Concatenate[Arg1Type, Arg2Type, ..., ParamSpecVariable]``. ``Concatenate`` +- is valid when used in :ref:`Callable ` type hints +- and when instantiating user-defined generic classes with :class:`ParamSpec` parameters. ++ is currently only valid when used as the first argument to a :ref:`Callable `. + The last parameter to ``Concatenate`` must be a :class:`ParamSpec` or + ellipsis (``...``). + +@@ -1284,10 +1283,10 @@ + + :data:`ClassVar` accepts only types and cannot be further subscribed. + +- :data:`ClassVar` is not a class itself, and cannot ++ :data:`ClassVar` is not a class itself, and should not + be used with :func:`isinstance` or :func:`issubclass`. + :data:`ClassVar` does not change Python runtime behavior, but +- it can be used by static type checkers. For example, a type checker ++ it can be used by third-party type checkers. For example, a type checker + might flag the following code as an error:: + + enterprise_d = Starship(3000) +@@ -1357,7 +1356,7 @@ + + def mutate_movie(m: Movie) -> None: + m["year"] = 1999 # allowed +- m["title"] = "The Matrix" # type checker error ++ m["title"] = "The Matrix" # typechecker error + + There is no runtime checking for this property. + +@@ -2163,8 +2162,8 @@ + * :data:`Concatenate` + * :ref:`annotating-callables` + +-.. class:: ParamSpecArgs +- ParamSpecKwargs ++.. data:: ParamSpecArgs ++ ParamSpecKwargs + + Arguments and keyword arguments attributes of a :class:`ParamSpec`. The + ``P.args`` attribute of a ``ParamSpec`` is an instance of ``ParamSpecArgs``, +@@ -2283,9 +2282,9 @@ + + Fields with a default value must come after any fields without a default. + +- The types for each field name can be retrieved by calling +- :func:`inspect.get_annotations` on the resulting class. (The field names +- are in the ``_fields`` attribute and the default values are in the ++ The resulting class has an extra attribute ``__annotations__`` giving a ++ dict that maps the field names to the field types. (The field names are in ++ the ``_fields`` attribute and the default values are in the + ``_field_defaults`` attribute, both of which are part of the :func:`~collections.namedtuple` + API.) + +@@ -2331,10 +2330,6 @@ + Removed the ``_field_types`` attribute in favor of the more + standard ``__annotations__`` attribute which has the same information. + +- .. versionchanged:: 3.9 +- ``NamedTuple`` is now a function rather than a class. +- It can still be used as a class base, as described above. +- + .. versionchanged:: 3.11 + Added support for generic namedtuples. + +@@ -2355,7 +2350,7 @@ + + Helper class to create low-overhead :ref:`distinct types `. + +- A ``NewType`` is considered a distinct type by a type checker. At runtime, ++ A ``NewType`` is considered a distinct type by a typechecker. At runtime, + however, calling a ``NewType`` returns its argument unchanged. + + Usage:: +@@ -2430,7 +2425,7 @@ + Mark a protocol class as a runtime protocol. + + Such a protocol can be used with :func:`isinstance` and :func:`issubclass`. +- This allows a simple-minded structural check, very similar to "one-trick ponies" ++ This allows a simple-minded structural check, very similar to "one trick ponies" + in :mod:`collections.abc` such as :class:`~collections.abc.Iterable`. For example:: + + @runtime_checkable +@@ -2490,7 +2485,7 @@ + .. class:: TypedDict(dict) + + Special construct to add type hints to a dictionary. +- At runtime ":class:`!TypedDict` instances" are simply :class:`dicts `. ++ At runtime it is a plain :class:`dict`. + + ``TypedDict`` declares a dictionary type that expects all of its + instances to have a certain set of keys, where each key is +@@ -2621,7 +2616,7 @@ + key: T + group: list[T] + +- A ``TypedDict`` can be introspected via :func:`inspect.get_annotations` ++ A ``TypedDict`` can be introspected via annotations dicts + (see :ref:`annotations-howto` for more information on annotations best practices), + :attr:`__total__`, :attr:`__required_keys__`, and :attr:`__optional_keys__`. + +@@ -2664,7 +2659,7 @@ + + For backwards compatibility with Python 3.10 and below, + it is also possible to use inheritance to declare both required and +- non-required keys in the same ``TypedDict``. This is done by declaring a ++ non-required keys in the same ``TypedDict`` . This is done by declaring a + ``TypedDict`` with one value for the ``total`` argument and then + inheriting from it in another ``TypedDict`` with a different value for + ``total``: +@@ -2713,10 +2708,6 @@ + + .. versionadded:: 3.8 + +- .. versionchanged:: 3.9 +- ``TypedDict`` is now a function rather than a class. +- It can still be used as a class base, as described above. +- + .. versionchanged:: 3.11 + Added support for marking individual keys as :data:`Required` or :data:`NotRequired`. + See :pep:`655`. +@@ -2746,34 +2737,34 @@ + + .. class:: SupportsAbs + +- A protocol with one abstract method ``__abs__`` that is covariant ++ An ABC with one abstract method ``__abs__`` that is covariant + in its return type. + + .. class:: SupportsBytes + +- A protocol with one abstract method ``__bytes__``. ++ An ABC with one abstract method ``__bytes__``. + + .. class:: SupportsComplex + +- A protocol with one abstract method ``__complex__``. ++ An ABC with one abstract method ``__complex__``. + + .. class:: SupportsFloat + +- A protocol with one abstract method ``__float__``. ++ An ABC with one abstract method ``__float__``. + + .. class:: SupportsIndex + +- A protocol with one abstract method ``__index__``. ++ An ABC with one abstract method ``__index__``. + + .. versionadded:: 3.8 + + .. class:: SupportsInt + +- A protocol with one abstract method ``__int__``. ++ An ABC with one abstract method ``__int__``. + + .. class:: SupportsRound + +- A protocol with one abstract method ``__round__`` ++ An ABC with one abstract method ``__round__`` + that is covariant in its return type. + + ABCs for working with IO +@@ -3340,27 +3331,14 @@ + + Determine if a type is a :class:`Protocol`. + +- For example: +- +- .. testcode:: ++ For example:: + + class P(Protocol): + def a(self) -> str: ... + b: int + +- assert is_protocol(P) +- assert not is_protocol(int) +- +- This function only returns true for ``Protocol`` classes, not for +- :ref:`generic aliases ` of them: +- +- .. testcode:: +- +- class GenericP[T](Protocol): +- def a(self) -> T: ... +- b: int +- +- assert not is_protocol(GenericP[int]) ++ is_protocol(P) # => True ++ is_protocol(int) # => False + + .. versionadded:: 3.13 + +@@ -3383,17 +3361,6 @@ + # not a typed dict itself + assert not is_typeddict(TypedDict) + +- This function only returns true for ``TypedDict`` classes, not for +- :ref:`generic aliases ` of them: +- +- .. testcode:: +- +- class GenericFilm[T](TypedDict): +- title: str +- year: T +- +- assert not is_typeddict(GenericFilm[int]) +- + .. versionadded:: 3.10 + + .. class:: ForwardRef +@@ -3432,7 +3399,7 @@ + + .. data:: TYPE_CHECKING + +- A special constant that is assumed to be ``True`` by static ++ A special constant that is assumed to be ``True`` by 3rd party static + type checkers. It is ``False`` at runtime. + + Usage:: +diff --git a/Doc/library/unittest.mock-examples.rst b/Doc/library/unittest.mock-examples.rst +index 176b1b6903a..6af4298d44f 100644 +--- a/Doc/library/unittest.mock-examples.rst ++++ b/Doc/library/unittest.mock-examples.rst +@@ -26,7 +26,7 @@ + Using Mock + ---------- + +-Mock patching methods ++Mock Patching Methods + ~~~~~~~~~~~~~~~~~~~~~ + + Common uses for :class:`Mock` objects include: +@@ -72,7 +72,7 @@ + + + +-Mock for method calls on an object ++Mock for Method Calls on an Object + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + In the last example we patched a method directly on an object to check that it +@@ -102,7 +102,7 @@ + will raise a failure exception. + + +-Mocking classes ++Mocking Classes + ~~~~~~~~~~~~~~~ + + A common use case is to mock out classes instantiated by your code under test. +@@ -140,7 +140,7 @@ + + + +-Tracking all calls ++Tracking all Calls + ~~~~~~~~~~~~~~~~~~ + + Often you want to track more than a single call to a method. The +@@ -177,7 +177,7 @@ + True + + +-Setting return values and attributes ++Setting Return Values and Attributes + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Setting the return values on a mock object is trivially easy: +@@ -318,7 +318,7 @@ + >>> mock_instance.__aexit__.assert_awaited_once() + + +-Creating a mock from an existing object ++Creating a Mock from an Existing Object + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + One problem with over use of mocking is that it couples your tests to the +@@ -385,7 +385,7 @@ + assert file2.read() == "default" + + +-Patch decorators ++Patch Decorators + ---------------- + + .. note:: +@@ -519,7 +519,7 @@ + + .. _further-examples: + +-Further examples ++Further Examples + ---------------- + + +@@ -615,13 +615,13 @@ + a real date. When the mock date class is called a real date will be + constructed and returned by ``side_effect``. :: + +- >>> import datetime as dt ++ >>> from datetime import date + >>> with patch('mymodule.date') as mock_date: +- ... mock_date.today.return_value = dt.date(2010, 10, 8) +- ... mock_date.side_effect = lambda *args, **kw: dt.date(*args, **kw) ++ ... mock_date.today.return_value = date(2010, 10, 8) ++ ... mock_date.side_effect = lambda *args, **kw: date(*args, **kw) + ... +- ... assert mymodule.date.today() == dt.date(2010, 10, 8) +- ... assert mymodule.date(2009, 6, 8) == dt.date(2009, 6, 8) ++ ... assert mymodule.date.today() == date(2010, 10, 8) ++ ... assert mymodule.date(2009, 6, 8) == date(2009, 6, 8) + + Note that we don't patch :class:`datetime.date` globally, we patch ``date`` in the + module that *uses* it. See :ref:`where to patch `. +@@ -639,7 +639,7 @@ + `_. + + +-Mocking a generator method ++Mocking a Generator Method + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + + A Python generator is a function or method that uses the :keyword:`yield` statement +@@ -740,7 +740,7 @@ + >>> MyTest('test_foo').run() + + +-Mocking unbound methods ++Mocking Unbound Methods + ~~~~~~~~~~~~~~~~~~~~~~~ + + Sometimes a test needs to patch an *unbound method*, which means patching the +@@ -938,7 +938,7 @@ + children of a ``CopyingMock`` will also have the type ``CopyingMock``. + + +-Nesting patches ++Nesting Patches + ~~~~~~~~~~~~~~~ + + Using patch as a context manager is nice, but if you do multiple patches you +diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst +index 1a02066ff99..22316e25c5a 100644 +--- a/Doc/library/unittest.rst ++++ b/Doc/library/unittest.rst +@@ -1211,9 +1211,9 @@ + | :meth:`assertNotRegex(s, r) | ``not r.search(s)`` | 3.2 | + | ` | | | + +---------------------------------------+--------------------------------+--------------+ +- | :meth:`assertCountEqual(a, b) | *a* contains the same elements | 3.2 | +- | ` | as *b*, regardless of their | | +- | | order. | | ++ | :meth:`assertCountEqual(a, b) | *a* and *b* have the same | 3.2 | ++ | ` | elements in the same number, | | ++ | | regardless of their order. | | + +---------------------------------------+--------------------------------+--------------+ + + +diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst +index 499e7f53226..69daa381013 100644 +--- a/Doc/library/urllib.parse.rst ++++ b/Doc/library/urllib.parse.rst +@@ -50,12 +50,11 @@ + The URL parsing functions focus on splitting a URL string into its components, + or on combining URL components into a URL string. + +-.. function:: urlsplit(urlstring, scheme=None, allow_fragments=True) ++.. function:: urlparse(urlstring, scheme='', allow_fragments=True) + +- Parse a URL into five components, returning a 5-item :term:`named tuple` +- :class:`SplitResult` or :class:`SplitResultBytes`. +- This corresponds to the general structure of a URL: +- ``scheme://netloc/path?query#fragment``. ++ Parse a URL into six components, returning a 6-item :term:`named tuple`. This ++ corresponds to the general structure of a URL: ++ ``scheme://netloc/path;parameters?query#fragment``. + Each tuple item is a string, possibly empty. The components are not broken up + into smaller parts (for example, the network location is a single string), and % + escapes are not expanded. The delimiters as shown above are not part of the +@@ -65,15 +64,15 @@ + .. doctest:: + :options: +NORMALIZE_WHITESPACE + +- >>> from urllib.parse import urlsplit +- >>> urlsplit("scheme://netloc/path?query#fragment") +- SplitResult(scheme='scheme', netloc='netloc', path='/path', ++ >>> from urllib.parse import urlparse ++ >>> urlparse("scheme://netloc/path;parameters?query#fragment") ++ ParseResult(scheme='scheme', netloc='netloc', path='/path;parameters', params='', + query='query', fragment='fragment') +- >>> o = urlsplit("http://docs.python.org:80/3/library/urllib.parse.html?" ++ >>> o = urlparse("http://docs.python.org:80/3/library/urllib.parse.html?" + ... "highlight=params#url-parsing") + >>> o +- SplitResult(scheme='http', netloc='docs.python.org:80', +- path='/3/library/urllib.parse.html', ++ ParseResult(scheme='http', netloc='docs.python.org:80', ++ path='/3/library/urllib.parse.html', params='', + query='highlight=params', fragment='url-parsing') + >>> o.scheme + 'http' +@@ -86,7 +85,7 @@ + >>> o._replace(fragment="").geturl() + 'http://docs.python.org:80/3/library/urllib.parse.html?highlight=params' + +- Following the syntax specifications in :rfc:`1808`, :func:`!urlsplit` recognizes ++ Following the syntax specifications in :rfc:`1808`, urlparse recognizes + a netloc only if it is properly introduced by '//'. Otherwise the + input is presumed to be a relative URL and thus to start with + a path component. +@@ -94,15 +93,15 @@ + .. doctest:: + :options: +NORMALIZE_WHITESPACE + +- >>> from urllib.parse import urlsplit +- >>> urlsplit('//www.cwi.nl:80/%7Eguido/Python.html') +- SplitResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html', +- query='', fragment='') +- >>> urlsplit('www.cwi.nl/%7Eguido/Python.html') +- SplitResult(scheme='', netloc='', path='www.cwi.nl/%7Eguido/Python.html', +- query='', fragment='') +- >>> urlsplit('help/Python.html') +- SplitResult(scheme='', netloc='', path='help/Python.html', ++ >>> from urllib.parse import urlparse ++ >>> urlparse('//www.cwi.nl:80/%7Eguido/Python.html') ++ ParseResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html', ++ params='', query='', fragment='') ++ >>> urlparse('www.cwi.nl/%7Eguido/Python.html') ++ ParseResult(scheme='', netloc='', path='www.cwi.nl/%7Eguido/Python.html', ++ params='', query='', fragment='') ++ >>> urlparse('help/Python.html') ++ ParseResult(scheme='', netloc='', path='help/Python.html', params='', + query='', fragment='') + + The *scheme* argument gives the default addressing scheme, to be +@@ -127,9 +126,12 @@ + +------------------+-------+-------------------------+------------------------+ + | :attr:`path` | 2 | Hierarchical path | empty string | + +------------------+-------+-------------------------+------------------------+ +- | :attr:`query` | 3 | Query component | empty string | ++ | :attr:`params` | 3 | Parameters for last | empty string | ++ | | | path element | | ++ +------------------+-------+-------------------------+------------------------+ ++ | :attr:`query` | 4 | Query component | empty string | + +------------------+-------+-------------------------+------------------------+ +- | :attr:`fragment` | 4 | Fragment identifier | empty string | ++ | :attr:`fragment` | 5 | Fragment identifier | empty string | + +------------------+-------+-------------------------+------------------------+ + | :attr:`username` | | User name | :const:`None` | + +------------------+-------+-------------------------+------------------------+ +@@ -153,30 +155,26 @@ + ``#``, ``@``, or ``:`` will raise a :exc:`ValueError`. If the URL is + decomposed before parsing, no error will be raised. + +- Following some of the `WHATWG spec`_ that updates :rfc:`3986`, leading C0 +- control and space characters are stripped from the URL. ``\n``, +- ``\r`` and tab ``\t`` characters are removed from the URL at any position. +- + As is the case with all named tuples, the subclass has a few additional methods + and attributes that are particularly useful. One such method is :meth:`_replace`. +- The :meth:`_replace` method will return a new :class:`SplitResult` object +- replacing specified fields with new values. ++ The :meth:`_replace` method will return a new ParseResult object replacing specified ++ fields with new values. + + .. doctest:: + :options: +NORMALIZE_WHITESPACE + +- >>> from urllib.parse import urlsplit +- >>> u = urlsplit('//www.cwi.nl:80/%7Eguido/Python.html') ++ >>> from urllib.parse import urlparse ++ >>> u = urlparse('//www.cwi.nl:80/%7Eguido/Python.html') + >>> u +- SplitResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html', +- query='', fragment='') ++ ParseResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html', ++ params='', query='', fragment='') + >>> u._replace(scheme='http') +- SplitResult(scheme='http', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html', +- query='', fragment='') ++ ParseResult(scheme='http', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html', ++ params='', query='', fragment='') + + .. warning:: + +- :func:`urlsplit` does not perform validation. See :ref:`URL parsing ++ :func:`urlparse` does not perform validation. See :ref:`URL parsing + security ` for details. + + .. versionchanged:: 3.2 +@@ -195,14 +193,6 @@ + Characters that affect netloc parsing under NFKC normalization will + now raise :exc:`ValueError`. + +- .. versionchanged:: 3.10 +- ASCII newline and tab characters are stripped from the URL. +- +- .. versionchanged:: 3.12 +- Leading WHATWG C0 control and space characters are stripped from the URL. +- +-.. _WHATWG spec: https://url.spec.whatwg.org/#concept-basic-url-parser +- + + .. function:: parse_qs(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace', max_num_fields=None, separator='&') + +@@ -293,35 +283,93 @@ + separator key, with ``&`` as the default separator. + + +-.. function:: urlunsplit(parts) ++.. function:: urlunparse(parts) + +- Construct a URL from a tuple as returned by ``urlsplit()``. The *parts* +- argument can be any five-item iterable. This may result in a slightly ++ Construct a URL from a tuple as returned by ``urlparse()``. The *parts* ++ argument can be any six-item iterable. This may result in a slightly + different, but equivalent URL, if the URL that was parsed originally had + unnecessary delimiters (for example, a ``?`` with an empty query; the RFC + states that these are equivalent). + + +-.. function:: urlparse(urlstring, scheme=None, allow_fragments=True) ++.. function:: urlsplit(urlstring, scheme='', allow_fragments=True) + +- This is similar to :func:`urlsplit`, but additionally splits the *path* +- component on *path* and *params*. +- This function returns a 6-item :term:`named tuple` :class:`ParseResult` +- or :class:`ParseResultBytes`. +- Its items are the same as for the :func:`!urlsplit` result, except that +- *params* is inserted at index 3, between *path* and *query*. ++ This is similar to :func:`urlparse`, but does not split the params from the URL. ++ This should generally be used instead of :func:`urlparse` if the more recent URL ++ syntax allowing parameters to be applied to each segment of the *path* portion ++ of the URL (see :rfc:`2396`) is wanted. A separate function is needed to ++ separate the path segments and parameters. This function returns a 5-item ++ :term:`named tuple`:: + +- This function is based on obsoleted :rfc:`1738` and :rfc:`1808`, which +- listed *params* as the main URL component. +- The more recent URL syntax allows parameters to be applied to each segment +- of the *path* portion of the URL (see :rfc:`3986`). +- :func:`urlsplit` should generally be used instead of :func:`urlparse`. +- A separate function is needed to separate the path segments and parameters. ++ (addressing scheme, network location, path, query, fragment identifier). + +-.. function:: urlunparse(parts) ++ The return value is a :term:`named tuple`, its items can be accessed by index ++ or as named attributes: ++ ++ +------------------+-------+-------------------------+----------------------+ ++ | Attribute | Index | Value | Value if not present | ++ +==================+=======+=========================+======================+ ++ | :attr:`scheme` | 0 | URL scheme specifier | *scheme* parameter | ++ +------------------+-------+-------------------------+----------------------+ ++ | :attr:`netloc` | 1 | Network location part | empty string | ++ +------------------+-------+-------------------------+----------------------+ ++ | :attr:`path` | 2 | Hierarchical path | empty string | ++ +------------------+-------+-------------------------+----------------------+ ++ | :attr:`query` | 3 | Query component | empty string | ++ +------------------+-------+-------------------------+----------------------+ ++ | :attr:`fragment` | 4 | Fragment identifier | empty string | ++ +------------------+-------+-------------------------+----------------------+ ++ | :attr:`username` | | User name | :const:`None` | ++ +------------------+-------+-------------------------+----------------------+ ++ | :attr:`password` | | Password | :const:`None` | ++ +------------------+-------+-------------------------+----------------------+ ++ | :attr:`hostname` | | Host name (lower case) | :const:`None` | ++ +------------------+-------+-------------------------+----------------------+ ++ | :attr:`port` | | Port number as integer, | :const:`None` | ++ | | | if present | | ++ +------------------+-------+-------------------------+----------------------+ ++ ++ Reading the :attr:`port` attribute will raise a :exc:`ValueError` if ++ an invalid port is specified in the URL. See section ++ :ref:`urlparse-result-object` for more information on the result object. ++ ++ Unmatched square brackets in the :attr:`netloc` attribute will raise a ++ :exc:`ValueError`. ++ ++ Characters in the :attr:`netloc` attribute that decompose under NFKC ++ normalization (as used by the IDNA encoding) into any of ``/``, ``?``, ++ ``#``, ``@``, or ``:`` will raise a :exc:`ValueError`. If the URL is ++ decomposed before parsing, no error will be raised. ++ ++ Following some of the `WHATWG spec`_ that updates RFC 3986, leading C0 ++ control and space characters are stripped from the URL. ``\n``, ++ ``\r`` and tab ``\t`` characters are removed from the URL at any position. ++ ++ .. warning:: ++ ++ :func:`urlsplit` does not perform validation. See :ref:`URL parsing ++ security ` for details. ++ ++ .. versionchanged:: 3.6 ++ Out-of-range port numbers now raise :exc:`ValueError`, instead of ++ returning :const:`None`. ++ ++ .. versionchanged:: 3.8 ++ Characters that affect netloc parsing under NFKC normalization will ++ now raise :exc:`ValueError`. ++ ++ .. versionchanged:: 3.10 ++ ASCII newline and tab characters are stripped from the URL. ++ ++ .. versionchanged:: 3.12 ++ Leading WHATWG C0 control and space characters are stripped from the URL. ++ ++.. _WHATWG spec: https://url.spec.whatwg.org/#concept-basic-url-parser ++ ++.. function:: urlunsplit(parts) + +- Combine the elements of a tuple as returned by :func:`urlparse` into a +- complete URL as a string. The *parts* argument can be any six-item ++ Combine the elements of a tuple as returned by :func:`urlsplit` into a ++ complete URL as a string. The *parts* argument can be any five-item + iterable. This may result in a slightly different, but equivalent URL, if the + URL that was parsed originally had unnecessary delimiters (for example, a ? + with an empty query; the RFC states that these are equivalent). +@@ -339,7 +387,7 @@ + 'http://www.cwi.nl/%7Eguido/FAQ.html' + + The *allow_fragments* argument has the same meaning and default as for +- :func:`urlsplit`. ++ :func:`urlparse`. + + .. note:: + +@@ -479,7 +527,7 @@ + Structured Parse Results + ------------------------ + +-The result objects from the :func:`urlsplit`, :func:`urlparse` and ++The result objects from the :func:`urlparse`, :func:`urlsplit` and + :func:`urldefrag` functions are subclasses of the :class:`tuple` type. + These subclasses add the attributes listed in the documentation for + those functions, the encoding and decoding support described in the +diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst +index 945c96892f5..04f5466c1a2 100644 +--- a/Doc/library/urllib.request.rst ++++ b/Doc/library/urllib.request.rst +@@ -1007,7 +1007,7 @@ + *headers* should be the error headers. + + *host* is either an authority (e.g. ``"python.org"``) or a URL containing an +- authority component (e.g. ``"https://python.org/"``). In either case, the ++ authority component (e.g. ``"http://python.org/"``). In either case, the + authority must not contain a userinfo component (so, ``"python.org"`` and + ``"python.org:80"`` are fine, ``"joe:password@python.org"`` is not). + +@@ -1203,14 +1203,10 @@ + it:: + + >>> import urllib.request +- >>> with urllib.request.urlopen('https://www.python.org/') as f: +- ... # The response may be compressed (for example, 'gzip'). +- ... print(f.headers.get('Content-Encoding')) +- ... data = f.read() +- ... if f.headers.get('Content-Encoding') == 'gzip': +- ... import gzip +- ... data = gzip.decompress(data) +- ... print(data[:300].decode('utf-8', errors='replace')) ++ >>> with urllib.request.urlopen('http://www.python.org/') as f: ++ ... print(f.read(300)) ++ ... ++ b'\n\n\n ++ >> import urllib.request +- >>> f = urllib.request.urlopen('https://www.python.org/') ++ >>> f = urllib.request.urlopen('http://www.python.org/') + >>> try: +- ... enc = f.headers.get('Content-Encoding') +- ... data = f.read() +- ... if enc == 'gzip': +- ... import gzip +- ... data = gzip.decompress(data) +- ... print(data[:100].decode('utf-8', errors='replace')) ++ ... print(f.read(100).decode('utf-8')) + ... finally: + ... f.close() ++ ... ++ ++ ++ + +- """ % (output_encoded,) ++ """ % (self.OutputString(attrs).replace('"', r'\"')) + + def OutputString(self, attrs=None): + # Build up our result +@@ -522,10 +486,7 @@ + result = [] + items = sorted(self.items()) + for key, value in items: +- value_output = value.output(attrs, header) +- if _has_control_character(value_output): +- raise CookieError("Control characters are not allowed in cookies") +- result.append(value_output) ++ result.append(value.output(attrs, header)) + return sep.join(result) + + __str__ = output +diff --git a/Lib/idlelib/News3.txt b/Lib/idlelib/News3.txt +index 10ed90cd6b5..daff5bf0038 100644 +--- a/Lib/idlelib/News3.txt ++++ b/Lib/idlelib/News3.txt +@@ -4,9 +4,6 @@ + ========================= + + +-gh-143774: Better explain the operation of Format / Format Paragraph. +-Patch by Terry J. Reedy. +- + gh-129873: Simplify displaying the IDLE doc by only copying the text + section of idle.html to idlelib/help.html. Patch by Stan Ulbrych. + +diff --git a/Lib/idlelib/config-main.def b/Lib/idlelib/config-main.def +index 54bdce34af3..28ae94161d5 100644 +--- a/Lib/idlelib/config-main.def ++++ b/Lib/idlelib/config-main.def +@@ -34,8 +34,9 @@ + # relevant settings from the default file. + # + # Additional help sources are listed in the [HelpFiles] section below +-# and should be viewable by a web browser. These sources will be listed +-# on the Help menu. The pattern, and two examples, are: ++# and should be viewable by a web browser (or the Windows Help viewer in ++# the case of .chm files). These sources will be listed on the Help ++# menu. The pattern, and two examples, are: + # + # + # 1 = IDLE;C:/Programs/Python36/Lib/idlelib/help.html +diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py +index 3128934763a..83112d85575 100644 +--- a/Lib/idlelib/editor.py ++++ b/Lib/idlelib/editor.py +@@ -35,6 +35,19 @@ + TK_TABWIDTH_DEFAULT = 8 + darwin = sys.platform == 'darwin' + ++def _sphinx_version(): ++ "Format sys.version_info to produce the Sphinx version string used to install the chm docs" ++ major, minor, micro, level, serial = sys.version_info ++ # TODO remove unneeded function since .chm no longer installed ++ release = f'{major}{minor}' ++ release += f'{micro}' ++ if level == 'candidate': ++ release += f'rc{serial}' ++ elif level != 'final': ++ release += f'{level[0]}{serial}' ++ return release ++ ++ + class EditorWindow: + from idlelib.percolator import Percolator + from idlelib.colorizer import ColorDelegator, color_config +diff --git a/Lib/idlelib/help.html b/Lib/idlelib/help.html +index 3394cc34b09..fc618ab727d 100644 +--- a/Lib/idlelib/help.html ++++ b/Lib/idlelib/help.html +@@ -16,9 +16,6 @@ + of global and local namespaces

+
  • configuration, browsers, and other dialogs

  • + +-

    The IDLE application is implemented in the idlelib package.

    +-

    This is an optional module. If it is missing from your copy of CPython, look for documentation from your distributor (that is, whoever provided Python to you). +-If you are the distributor, see Requirements for optional modules.

    +