From 35f60bcd9c7d86a7cb47f4ad9335430b96d5b81f Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 11 Nov 2026 16:50:41 -0600 Subject: [PATCH 01/11] PYTHON-6178 Grow the BSON fuzz corpus from nightly harvests The nightly fuzz run seeds from a committed fuzz/corpus/ directory and, after a green run, harvests its coverage-increasing inputs into an automated [Fuzz Corpus] PR, so later nights build on prior discoveries instead of restarting from the spec seeds. Harvest dedupes by content digest and caps growth at 50 units per run and 64 KiB per unit, overridable from Evergreen; nothing new means no PR. Crashing inputs fail the task before harvest runs, keeping reproducers on the fuzz/regression/ triage flow. --- .evergreen/generated_configs/tasks.yml | 11 ++ .evergreen/scripts/create-fuzz-corpus-pr.sh | 131 ++++++++++++++ .evergreen/scripts/generate_config.py | 14 +- .evergreen/scripts/harvest-fuzz-corpus.sh | 26 +++ .evergreen/scripts/setup_tests.py | 19 ++ CONTRIBUTING.md | 2 + fuzz/README.md | 28 +++ fuzz/corpus/.gitkeep | 0 fuzz/harvest_corpus.py | 190 ++++++++++++++++++++ pyproject.toml | 10 +- test/test_fuzz_harvest.py | 135 ++++++++++++++ 11 files changed, 564 insertions(+), 2 deletions(-) create mode 100755 .evergreen/scripts/create-fuzz-corpus-pr.sh create mode 100755 .evergreen/scripts/harvest-fuzz-corpus.sh create mode 100644 fuzz/corpus/.gitkeep create mode 100755 fuzz/harvest_corpus.py create mode 100644 test/test_fuzz_harvest.py diff --git a/.evergreen/generated_configs/tasks.yml b/.evergreen/generated_configs/tasks.yml index 2bcc195224..ee72594f1c 100644 --- a/.evergreen/generated_configs/tasks.yml +++ b/.evergreen/generated_configs/tasks.yml @@ -213,6 +213,17 @@ tasks: TEST_NAME: fuzz SUB_TEST_NAME: fuzz UV_PYTHON: "3.13" + - command: subprocess.exec + params: + binary: bash + args: + - .evergreen/scripts/harvest-fuzz-corpus.sh + working_dir: src + include_expansions_in_env: + - is_patch + - FUZZ_CORPUS_MAX_UNITS + - FUZZ_CORPUS_MAX_UNIT_BYTES + type: test tags: [fuzz, fuzz-nightly] # Getdata tests diff --git a/.evergreen/scripts/create-fuzz-corpus-pr.sh b/.evergreen/scripts/create-fuzz-corpus-pr.sh new file mode 100755 index 0000000000..b2b630f7ab --- /dev/null +++ b/.evergreen/scripts/create-fuzz-corpus-pr.sh @@ -0,0 +1,131 @@ +#!/usr/bin/env bash +set -eu + +# Args: 1 = harvested units directory, 2 = harvest summary markdown. +harvest_dir="$1" +summary_file="$2" + +# Default to the drivers-evergreen-tools submodule when unset; a +# caller-provided DRIVERS_TOOLS wins, as in the other consumers. +tools="$(realpath -s "${DRIVERS_TOOLS:-./drivers-evergreen-tools}")" +pushd $tools/.evergreen/github_app || exit + +owner="mongodb" +repo="mongo-python-driver" + +# Bootstrap the app. +echo "bootstrapping" +source utils.sh +bootstrap drivers/comment-bot + +# Run the app. +source ./secrets-export.sh + +# Get a github access token for the git checkout. +echo "Getting github token..." + +token=$(bash ./get-access-token.sh $repo $owner) +if [ -z "${token}" ]; then + echo "Failed to get github access token!" + popd || exit + exit 1 +fi +echo "Getting github token... done." +popd || exit + +# Make the git checkout and create a new branch. +echo "Creating the git checkout..." +branch="fuzz-corpus-"$(date '+%m-%d-%Y') + +git remote set-url origin https://x-access-token:${token}@github.com/$owner/$repo.git +# -B resets the branch if a reused checkout already has it, keeping reruns idempotent. +git checkout -B "$branch" "origin/main" + +# Attribute the commit to the bot user; fall back to the host identity. +bot_login="mongodb-drivers-pr-bot[bot]" +bot_id=$(curl -gsm 10 "https://api.github.com/users/${bot_login}" | jq -r '.id // empty' || true) +if [ -n "$bot_id" ]; then + git config user.name "$bot_login" + git config user.email "${bot_id}+${bot_login}@users.noreply.github.com" +fi + +mkdir -p fuzz/corpus +cp "$harvest_dir"/* fuzz/corpus/ +git add fuzz/corpus + +if git diff --cached --quiet && git diff --quiet --ignore-submodules=dirty; then + echo "No new corpus units to commit; skipping PR creation." + exit 0 +fi + +git commit -m "PYTHON-6178 Grow the BSON fuzz corpus ($(date '+%m-%d-%Y'))" +echo "Creating the git checkout... done." + +# Date-stamped branch: force-push makes same-day reruns idempotent; retry +# absorbs GitHub's intermittent 403s on the receive-pack endpoint. +push_ok=false +for _attempt in 1 2 3; do + if git push --force origin $branch; then + push_ok=true + break + fi + if [ "$_attempt" -lt 3 ]; then + echo "Push attempt ${_attempt} failed; retrying in 30s..." + sleep 30 + fi +done +if [ "$push_ok" != true ]; then + echo "Failed to push $branch after 3 attempts!" >&2 + exit 1 +fi + +# Build the payload as a file so the body content is always properly +# JSON-escaped, rather than interpolated into the command line as text. +payload_file=$(mktemp) +trap 'rm -f "$payload_file"' EXIT +jq -n \ + --arg title "[Fuzz Corpus] $(date '+%m-%d-%Y')" \ + --arg head "${branch}" \ + --rawfile body "$summary_file" \ + '{title: $title, body: $body, head: $head, base: "main"}' > "$payload_file" + +# Reuse an open PR for this branch (same-day rerun) instead of duplicating it. +existing_pr_json=$(curl -gs \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $token" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + --url "https://api.github.com/repos/$owner/$repo/pulls?head=$owner:$branch&state=open") +existing_pr_url=$(echo "$existing_pr_json" | jq -r '.[0].html_url // empty') +if [ -n "$existing_pr_url" ]; then + existing_pr_number=$(echo "$existing_pr_json" | jq -r '.[0].number // empty') + if ! curl -sfX PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $token" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -d "{\"title\": \"[Fuzz Corpus] $(date '+%m-%d-%Y')\", \"body\": $(jq -Rs . < "$summary_file")}" \ + --url "https://api.github.com/repos/$owner/$repo/pulls/${existing_pr_number}" > /dev/null + then + echo "Failed to update PR summary!" >&2 + exit 1 + fi + echo "$existing_pr_url" + echo "Creating the PR... done. (PR already existed; branch and summary were updated)" + exit 0 +fi + +resp=$(curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $token" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -d "@${payload_file}" \ + --url https://api.github.com/repos/$owner/$repo/pulls) + +pr_url=$(echo "$resp" | jq -r '.html_url // empty') +if [ -z "$pr_url" ]; then + echo "Failed to create PR! API response:" + echo "$resp" | jq . + exit 1 +fi +echo "$pr_url" +echo "Creating the PR... done." diff --git a/.evergreen/scripts/generate_config.py b/.evergreen/scripts/generate_config.py index 3b45e52971..9877d253f3 100644 --- a/.evergreen/scripts/generate_config.py +++ b/.evergreen/scripts/generate_config.py @@ -957,7 +957,19 @@ def create_fuzz_tasks(): tags = ["fuzz", "fuzz-nightly"] test_vars = dict(TEST_NAME="fuzz", SUB_TEST_NAME="fuzz", UV_PYTHON="3.13") test_func = FunctionCall(func="run tests", vars=test_vars) - tasks.append(EvgTask(name="fuzz", tags=tags, commands=[test_func])) + # PYTHON-6178: while the scratch corpus still exists, harvest the new + # coverage-increasing inputs and open an automated PR growing + # fuzz/corpus/. Runs only when the targets finished green, so crashing + # inputs never reach the corpus. + harvest_cmd = get_subprocess_exec( + args=[".evergreen/scripts/harvest-fuzz-corpus.sh"], + include_expansions_in_env=[ + "is_patch", + "FUZZ_CORPUS_MAX_UNITS", + "FUZZ_CORPUS_MAX_UNIT_BYTES", + ], + ) + tasks.append(EvgTask(name="fuzz", tags=tags, commands=[test_func, harvest_cmd])) return tasks diff --git a/.evergreen/scripts/harvest-fuzz-corpus.sh b/.evergreen/scripts/harvest-fuzz-corpus.sh new file mode 100755 index 0000000000..a10b2f866b --- /dev/null +++ b/.evergreen/scripts/harvest-fuzz-corpus.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# PYTHON-6178: harvest coverage-increasing inputs from the nightly fuzz +# run and open an automated PR growing fuzz/corpus/. Runs as the last +# command of the Evergreen nightly "fuzz" task, after the targets have +# finished and while the scratch corpus still exists. +set -eu + +# Never open corpus PRs from patch builds; the nightly variant only. +if [ "${is_patch:-}" = "true" ]; then + echo "Patch build; skipping fuzz corpus harvest." + exit 0 +fi + +# Same environment as just.sh: venv on PATH for a modern Python. +. "$(dirname "${BASH_SOURCE:-$0}")/setup-dev-env.sh" + +# Harvest the new units. No new units means a quiet night: no commit, no +# PR (and the GitHub secrets flow is never touched). +uv run --no-sync python fuzz/harvest_corpus.py +if [ -z "$(ls -A fuzz-scratch/harvest 2>/dev/null || true)" ]; then + echo "No new fuzz corpus units; nothing to do." + exit 0 +fi + +bash .evergreen/scripts/create-fuzz-corpus-pr.sh \ + fuzz-scratch/harvest fuzz-scratch/harvest-summary.md diff --git a/.evergreen/scripts/setup_tests.py b/.evergreen/scripts/setup_tests.py index c12599cbc0..68ddc9eea6 100644 --- a/.evergreen/scripts/setup_tests.py +++ b/.evergreen/scripts/setup_tests.py @@ -1,6 +1,7 @@ from __future__ import annotations import base64 +import hashlib import os import platform import shutil @@ -547,6 +548,24 @@ def handle_test_env() -> None: with zipfile.ZipFile(zip_path) as zf: zf.extractall(corpus_dir) zip_path.unlink() + if sub_test_name == "fuzz": + # PYTHON-6178 Also seed from the committed corpus of previously + # harvested inputs, so the nightly builds on prior discoveries + # instead of the spec seeds alone. Regression runs (PRs) keep + # running only the reproducers and the spec seed corpus. + committed_dir = ROOT / "fuzz" / "corpus" + if committed_dir.is_dir(): + for path in sorted(committed_dir.iterdir()): + if path.name.startswith("."): + continue + shutil.copyfile(path, corpus_dir / path.name) + # Manifest of every input this run starts from; harvest_corpus.py + # treats these digests as already-known, so only units the fuzzer + # discovered during the run get harvested. + with open(scratch_dir / "baseline.txt", "w", encoding="utf-8") as fp: + for path in sorted(corpus_dir.iterdir()): + if path.is_file(): + fp.write(hashlib.sha256(path.read_bytes()).hexdigest() + "\n") write_env("FUZZ_CORPUS_DIR", str(corpus_dir)) if test_name == "sanitizer": diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6bf693bdef..c03e0d812a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -457,6 +457,8 @@ wheels (CPython 3.12-3.14). - Time-boxed fuzzing (runs daily on Evergreen): `just setup-tests fuzz fuzz` then `just run-tests`. Set `FUZZ_MAX_TIME` (seconds, default 300) to change the per-target budget. +- Nightly fuzzing harvests coverage-increasing inputs into `fuzz/corpus/` + via an automated PR (PYTHON-6178); see [fuzz/README.md](fuzz/README.md). ## Testing time-dependent operations diff --git a/fuzz/README.md b/fuzz/README.md index 8069c0586c..d356650f16 100644 --- a/fuzz/README.md +++ b/fuzz/README.md @@ -95,6 +95,32 @@ after the corpus directory. The `Failed to find function __sanitizer_*` startup warnings are benign libFuzzer symbol probes on uninstrumented runs; native ASan-instrumented fuzzing is tracked separately (PYTHON-6169). +### Harvested corpus (nightly) + +The nightly run seeds from the spec seed corpus plus every unit in +`corpus/`, and libFuzzer writes each coverage-increasing ("interesting") +input it discovers back into its corpus directory. After the targets +finish, the `fuzz` task harvests those new units into `corpus/` and opens +an automated "[Fuzz Corpus]" PR against main (PYTHON-6178). Later nights +build on prior discoveries instead of restarting from the spec seeds. + +Growth is bounded by per-unit and per-run caps, overridable on Evergreen: + +- `FUZZ_CORPUS_MAX_UNIT_BYTES` (default 65536): skip units larger than this. +- `FUZZ_CORPUS_MAX_UNITS` (default 50): keep at most this many new units + per run, smallest first. + +Units over a cap are discarded, not deferred: they are never persisted, so +the fuzzer may re-derive them on later nights. A run that finds nothing new +opens no PR. The harvest deduplicates against `main` only, so while a +`[Fuzz Corpus]` PR is open, later nights can re-harvest its still-pending +units and the PRs overlap until one merges (digest-named files keep that +conflict-free). Crashing inputs are excluded: +they land in `fuzz-scratch/` as `crash-*` artifacts and follow the +`regression/` triage flow above. Corpus entries are fuzzer-generated +inputs, not code: skim the PR for size and for inputs that look like a +bug rather than a plain coverage gain before merging. + ## Coverage report Measure which lines the seed corpus reaches: @@ -113,9 +139,11 @@ gives atheris a graceful exit so coverage.py can flush its report. ``` build_corpus.py Seed corpus builder (mirrors the Go driver's build-oss-fuzz-corpus) +harvest_corpus.py Nightly harvest of new coverage-increasing inputs (PYTHON-6178) fuzz_decode.py Fuzz target: bson.decode() fuzz_decode_all.py Fuzz target: bson.decode_all() fuzz_is_valid.py Fuzz target: bson.is_valid() fuzz_shared.py Code shared by the fuzz targets +corpus/ Harvested coverage-increasing inputs; grown by automated nightly PRs regression/ Known bug reproducers; run with the seed corpus on PRs ``` diff --git a/fuzz/corpus/.gitkeep b/fuzz/corpus/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/fuzz/harvest_corpus.py b/fuzz/harvest_corpus.py new file mode 100755 index 0000000000..fd58c67c4a --- /dev/null +++ b/fuzz/harvest_corpus.py @@ -0,0 +1,190 @@ +#!/usr/bin/env python3 +""" +Harvest coverage-increasing inputs from a finished fuzzing run (PYTHON-6178). + +Compares the scratch corpus directory (where libFuzzer writes each new +"interesting" input) against the baseline manifest written by +setup_tests.py and the committed fuzz/corpus/ contents, copies the new +units into an output directory named by their SHA-256 digests, and writes +a Markdown summary for the automated corpus PR body. + +Pure stdlib: this runs on the Evergreen nightly host after the fuzz +targets finish, and its unit tests must run everywhere (no atheris, no +bson). + +Usage: python harvest_corpus.py [--corpus-dir DIR] [--baseline FILE] +""" + +from __future__ import annotations + +import argparse +import os +import shutil +from hashlib import sha256 +from pathlib import Path + +DEFAULT_CORPUS_DIR = "fuzz-scratch/corpus" +DEFAULT_EXISTING = "fuzz/corpus" +DEFAULT_OUT = "fuzz-scratch/harvest" +DEFAULT_SUMMARY = "fuzz-scratch/harvest-summary.md" +# Growth caps keep a runaway run from flooding the repository; both are +# overridable from Evergreen. Defaults chosen in PYTHON-6178: small inputs +# carry the most coverage per committed byte. +DEFAULT_MAX_UNITS = 50 +DEFAULT_MAX_UNIT_BYTES = 64 * 1024 + + +def digest_of(path: Path) -> str: + """The SHA-256 hex digest of a file's contents.""" + digest = sha256() + with open(path, "rb") as fp: + for chunk in iter(lambda: fp.read(1024 * 1024), b""): + digest.update(chunk) + return digest.hexdigest() + + +def digest_set(directory: Path) -> set[str]: + """Content digests of every file in directory, skipping dotfiles.""" + if not directory.is_dir(): + return set() + return { + digest_of(path) + for path in sorted(directory.iterdir()) + if path.is_file() and not path.name.startswith(".") + } + + +def read_baseline(path: Path) -> set[str]: + """Read digests from a baseline manifest (one hex digest per line).""" + if not path.is_file(): + return set() + with open(path, encoding="utf-8") as fp: + return {line.strip() for line in fp if line.strip()} + + +def run( + corpus_dir: Path, + baseline: Path, + existing: Path, + out: Path, + summary: Path, + max_units: int, + max_unit_bytes: int, +) -> int: + """Copy the new units into out/ and write the PR summary. + + Returns the number of units harvested; zero means the run found + nothing new and the PR step can no-op. + """ + known = read_baseline(baseline) | digest_set(existing) + + # Sorted (size, digest, path): the size key prefers the smallest + # inputs when the per-run cap bites. + candidates: list[tuple[int, str, Path]] = [] + oversize = 0 + for path in sorted(corpus_dir.iterdir()): + if path.name.startswith(".") or not path.is_file(): + continue + digest = digest_of(path) + if digest in known: + continue + size = path.stat().st_size + if size > max_unit_bytes: + oversize += 1 + continue + candidates.append((size, digest, path)) + candidates.sort() + + kept = candidates[:max_units] + over_cap = len(candidates) - len(kept) + if out.exists(): + shutil.rmtree(out) + out.mkdir(parents=True) + for _, digest, path in kept: + shutil.copyfile(path, out / digest) + + write_summary(summary, kept, oversize, over_cap, max_units, max_unit_bytes) + print( + f"Harvested {len(kept)} new units " + f"({oversize} oversize skipped, {over_cap} over the per-run cap)." + ) + return len(kept) + + +def write_summary( + path: Path, + kept: list[tuple[int, str, Path]], + oversize: int, + over_cap: int, + max_units: int, + max_unit_bytes: int, +) -> None: + """Write the Markdown harvest summary used as the automated PR body.""" + lines = [ + "Harvested coverage-increasing inputs from last night's BSON fuzz run.", + "", + f"- New units added: **{len(kept)}**", + f"- Units skipped over the per-unit cap ({max_unit_bytes} bytes): {oversize}", + f"- Units dropped over the per-run cap ({max_units}): {over_cap}", + "", + "These are fuzzer-generated inputs, not reviewed code. Before merging, " + "skim them for size and for inputs that look like a bug rather than a " + "plain coverage gain; anything crashing belongs in `fuzz/regression/`.", + ] + if kept: + lines.extend(["", "Largest units added:"]) + for size, digest, _ in sorted(kept, reverse=True)[:5]: + lines.append(f"- `{digest[:16]}` ({size} bytes)") + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text("\n".join(lines) + "\n", encoding="utf-8") + + +def main() -> None: + parser = argparse.ArgumentParser( + description="Harvest new coverage-increasing inputs from a fuzz run." + ) + parser.add_argument( + "--corpus-dir", + default=os.environ.get("FUZZ_CORPUS_DIR", DEFAULT_CORPUS_DIR), + ) + parser.add_argument( + "--baseline", + default=None, + help="Digest manifest; defaults to baseline.txt next to the corpus dir.", + ) + parser.add_argument("--existing", default=DEFAULT_EXISTING) + parser.add_argument("--out", default=DEFAULT_OUT) + parser.add_argument("--summary", default=DEFAULT_SUMMARY) + parser.add_argument( + "--max-units", + type=int, + default=int(os.environ.get("FUZZ_CORPUS_MAX_UNITS", DEFAULT_MAX_UNITS)), + ) + parser.add_argument( + "--max-unit-bytes", + type=int, + default=int(os.environ.get("FUZZ_CORPUS_MAX_UNIT_BYTES", DEFAULT_MAX_UNIT_BYTES)), + ) + args = parser.parse_args() + # Negative or zero caps are operator error (e.g. a mis-set Evergreen + # expansion): fail with an actionable message rather than a nonsense + # keep-set like "all but the last N". + if args.max_units < 1: + parser.error("--max-units must be at least 1") + if args.max_unit_bytes < 1: + parser.error("--max-unit-bytes must be at least 1") + corpus_dir = Path(args.corpus_dir) + baseline = Path(args.baseline) if args.baseline else corpus_dir.parent / "baseline.txt" + run( + corpus_dir=corpus_dir, + baseline=baseline, + existing=Path(args.existing), + out=Path(args.out), + summary=Path(args.summary), + max_units=args.max_units, + max_unit_bytes=args.max_unit_bytes, + ) + + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml index ae29fdaf8e..e945755403 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -192,7 +192,15 @@ disable_error_code = ["unused-coroutine", "no-redef"] [tool.ruff] line-length = 100 -extend-exclude = ["drivers-evergreen-tools"] +extend-exclude = [ + "drivers-evergreen-tools", + # Temporary (PYTHON-6178): ruff's markdown formatter strips doctest + # "... " continuation lines that the blacken-docs hook re-adds, so the + # two disagree on README.md and CONTRIBUTING.md. Keep ruff format away + # from them until the formatters agree. + "README.md", + "CONTRIBUTING.md", +] [tool.ruff.lint] extend-select = [ diff --git a/test/test_fuzz_harvest.py b/test/test_fuzz_harvest.py new file mode 100644 index 0000000000..00df47de0c --- /dev/null +++ b/test/test_fuzz_harvest.py @@ -0,0 +1,135 @@ +"""Tests for fuzz/harvest_corpus.py (PYTHON-6178).""" + +from __future__ import annotations + +import sys +from hashlib import sha256 +from pathlib import Path + +import pytest + +sys.path.insert(0, str(Path(__file__).parent.parent / "fuzz")) + +import harvest_corpus + + +def write_unit(directory: Path, data: bytes) -> Path: + """Write a unit named by its content digest, like libFuzzer does.""" + path = directory / sha256(data).hexdigest() + path.write_bytes(data) + return path + + +@pytest.fixture +def dirs(tmp_path: Path) -> dict[str, Path]: + corpus = tmp_path / "corpus" + corpus.mkdir() + return { + "corpus": corpus, + "baseline": tmp_path / "baseline.txt", + "existing": tmp_path / "committed", + "out": tmp_path / "harvest", + "summary": tmp_path / "summary.md", + } + + +def harvest(dirs: dict[str, Path], max_units: int = 50, max_unit_bytes: int = 65536) -> int: + return harvest_corpus.run( + corpus_dir=dirs["corpus"], + baseline=dirs["baseline"], + existing=dirs["existing"], + out=dirs["out"], + summary=dirs["summary"], + max_units=max_units, + max_unit_bytes=max_unit_bytes, + ) + + +def test_harvests_new_units(dirs: dict[str, Path]) -> None: + write_unit(dirs["corpus"], b"new-unit") + + count = harvest(dirs) + + assert count == 1 + harvested = list(dirs["out"].iterdir()) + assert [p.name for p in harvested] == [sha256(b"new-unit").hexdigest()] + assert harvested[0].read_bytes() == b"new-unit" + + +def test_skips_baseline_units(dirs: dict[str, Path]) -> None: + write_unit(dirs["corpus"], b"seeded") + dirs["baseline"].write_text(sha256(b"seeded").hexdigest() + "\n") + + assert harvest(dirs) == 0 + assert list(dirs["out"].iterdir()) == [] + + +def test_skips_committed_units(dirs: dict[str, Path]) -> None: + dirs["existing"].mkdir() + write_unit(dirs["existing"], b"already-committed") + write_unit(dirs["corpus"], b"already-committed") + + assert harvest(dirs) == 0 + + +def test_skips_oversize_units(dirs: dict[str, Path]) -> None: + write_unit(dirs["corpus"], b"x" * 100) + write_unit(dirs["corpus"], b"y" * 50) + + assert harvest(dirs, max_unit_bytes=99) == 1 + assert len(list(dirs["out"].iterdir())) == 1 + assert "per-unit cap" in dirs["summary"].read_text() + + +def test_per_run_cap_prefers_smallest(dirs: dict[str, Path]) -> None: + write_unit(dirs["corpus"], b"a" * 30) + write_unit(dirs["corpus"], b"b" * 10) + write_unit(dirs["corpus"], b"c" * 20) + + assert harvest(dirs, max_units=2) == 2 + assert {p.read_bytes() for p in dirs["out"].iterdir()} == {b"b" * 10, b"c" * 20} + assert "per-run cap (2)" in dirs["summary"].read_text() + + +def test_no_new_units_writes_summary_and_empty_out(dirs: dict[str, Path]) -> None: + assert harvest(dirs) == 0 + assert list(dirs["out"].iterdir()) == [] + assert dirs["summary"].is_file() + + +def test_rejects_nonpositive_max_units(monkeypatch, capsys, dirs: dict[str, Path]) -> None: + """A cap of 0 or fewer is operator error; fail with an actionable message.""" + monkeypatch.setenv("FUZZ_CORPUS_MAX_UNITS", "0") + _argv(monkeypatch, dirs) + with pytest.raises(SystemExit): + harvest_corpus.main() + assert "--max-units must be at least 1" in capsys.readouterr().err + + +def test_rejects_nonpositive_max_unit_bytes(monkeypatch, capsys, dirs: dict[str, Path]) -> None: + monkeypatch.setenv("FUZZ_CORPUS_MAX_UNIT_BYTES", "-1") + _argv(monkeypatch, dirs) + with pytest.raises(SystemExit): + harvest_corpus.main() + assert "--max-unit-bytes must be at least 1" in capsys.readouterr().err + + +def _argv(monkeypatch, dirs: dict[str, Path]) -> None: + """Point main()'s argparse at the fixture directories.""" + monkeypatch.setattr( + sys, + "argv", + [ + "harvest_corpus.py", + "--corpus-dir", + str(dirs["corpus"]), + "--baseline", + str(dirs["baseline"]), + "--existing", + str(dirs["existing"]), + "--out", + str(dirs["out"]), + "--summary", + str(dirs["summary"]), + ], + ) From 577c2712846cfbe8cac3b50b5712772c228691c1 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 12 Nov 2026 07:30:18 -0600 Subject: [PATCH 02/11] cleanup and address review --- .evergreen/generated_configs/tasks.yml | 3 + .evergreen/generated_configs/variants.yml | 9 +- .evergreen/scripts/create-fuzz-corpus-pr.sh | 128 +++----------------- .evergreen/scripts/create-spec-pr.sh | 127 +++---------------- .evergreen/scripts/generate_config.py | 24 +++- .evergreen/scripts/test_generate_config.py | 24 ++++ 6 files changed, 75 insertions(+), 240 deletions(-) diff --git a/.evergreen/generated_configs/tasks.yml b/.evergreen/generated_configs/tasks.yml index ee72594f1c..7c120d0179 100644 --- a/.evergreen/generated_configs/tasks.yml +++ b/.evergreen/generated_configs/tasks.yml @@ -223,6 +223,9 @@ tasks: - is_patch - FUZZ_CORPUS_MAX_UNITS - FUZZ_CORPUS_MAX_UNIT_BYTES + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_SESSION_TOKEN type: test tags: [fuzz, fuzz-nightly] diff --git a/.evergreen/generated_configs/variants.yml b/.evergreen/generated_configs/variants.yml index d2b382a28b..e6892c7d77 100644 --- a/.evergreen/generated_configs/variants.yml +++ b/.evergreen/generated_configs/variants.yml @@ -313,20 +313,15 @@ buildvariants: AUTH: auth # Fuzz tests - - name: fuzz-regression-rhel8 - tasks: - - name: .fuzz-regression - display_name: Fuzz Regression RHEL8 - run_on: - - rhel8.10-small - tags: [pr] - name: fuzz-rhel8 tasks: + - name: .fuzz-regression - name: .fuzz-nightly display_name: Fuzz RHEL8 run_on: - rhel8.10-small batchtime: 1440 + tags: [pr] # Green framework tests - name: green-gevent-rhel8 diff --git a/.evergreen/scripts/create-fuzz-corpus-pr.sh b/.evergreen/scripts/create-fuzz-corpus-pr.sh index b2b630f7ab..3c10d52dc7 100755 --- a/.evergreen/scripts/create-fuzz-corpus-pr.sh +++ b/.evergreen/scripts/create-fuzz-corpus-pr.sh @@ -1,131 +1,31 @@ #!/usr/bin/env bash set -eu -# Args: 1 = harvested units directory, 2 = harvest summary markdown. +# Open (or update) the automated pull request that grows fuzz/corpus/ +# with freshly harvested units. Arguments: 1 = harvested units directory, +# 2 = harvest summary markdown to use as the PR body. + harvest_dir="$1" summary_file="$2" +today="$(date '+%m-%d-%Y')" -# Default to the drivers-evergreen-tools submodule when unset; a -# caller-provided DRIVERS_TOOLS wins, as in the other consumers. -tools="$(realpath -s "${DRIVERS_TOOLS:-./drivers-evergreen-tools}")" -pushd $tools/.evergreen/github_app || exit - -owner="mongodb" -repo="mongo-python-driver" - -# Bootstrap the app. -echo "bootstrapping" -source utils.sh -bootstrap drivers/comment-bot - -# Run the app. -source ./secrets-export.sh - -# Get a github access token for the git checkout. -echo "Getting github token..." +# Shared github-app authentication, git branch and PR plumbing. +# shellcheck disable=SC1091 +. "$(dirname "${BASH_SOURCE[0]}")/github-pr-lib.sh" -token=$(bash ./get-access-token.sh $repo $owner) -if [ -z "${token}" ]; then - echo "Failed to get github access token!" - popd || exit - exit 1 -fi -echo "Getting github token... done." -popd || exit +acquire_github_token -# Make the git checkout and create a new branch. echo "Creating the git checkout..." -branch="fuzz-corpus-"$(date '+%m-%d-%Y') - -git remote set-url origin https://x-access-token:${token}@github.com/$owner/$repo.git -# -B resets the branch if a reused checkout already has it, keeping reruns idempotent. -git checkout -B "$branch" "origin/main" - -# Attribute the commit to the bot user; fall back to the host identity. -bot_login="mongodb-drivers-pr-bot[bot]" -bot_id=$(curl -gsm 10 "https://api.github.com/users/${bot_login}" | jq -r '.id // empty' || true) -if [ -n "$bot_id" ]; then - git config user.name "$bot_login" - git config user.email "${bot_id}+${bot_login}@users.noreply.github.com" -fi +branch="fuzz-corpus-${today}" +prepare_bot_branch "$branch" mkdir -p fuzz/corpus cp "$harvest_dir"/* fuzz/corpus/ -git add fuzz/corpus - -if git diff --cached --quiet && git diff --quiet --ignore-submodules=dirty; then +if ! stage_and_commit "PYTHON-6178 Grow the BSON fuzz corpus (${today})" fuzz/corpus; then echo "No new corpus units to commit; skipping PR creation." exit 0 fi - -git commit -m "PYTHON-6178 Grow the BSON fuzz corpus ($(date '+%m-%d-%Y'))" echo "Creating the git checkout... done." -# Date-stamped branch: force-push makes same-day reruns idempotent; retry -# absorbs GitHub's intermittent 403s on the receive-pack endpoint. -push_ok=false -for _attempt in 1 2 3; do - if git push --force origin $branch; then - push_ok=true - break - fi - if [ "$_attempt" -lt 3 ]; then - echo "Push attempt ${_attempt} failed; retrying in 30s..." - sleep 30 - fi -done -if [ "$push_ok" != true ]; then - echo "Failed to push $branch after 3 attempts!" >&2 - exit 1 -fi - -# Build the payload as a file so the body content is always properly -# JSON-escaped, rather than interpolated into the command line as text. -payload_file=$(mktemp) -trap 'rm -f "$payload_file"' EXIT -jq -n \ - --arg title "[Fuzz Corpus] $(date '+%m-%d-%Y')" \ - --arg head "${branch}" \ - --rawfile body "$summary_file" \ - '{title: $title, body: $body, head: $head, base: "main"}' > "$payload_file" - -# Reuse an open PR for this branch (same-day rerun) instead of duplicating it. -existing_pr_json=$(curl -gs \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $token" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - --url "https://api.github.com/repos/$owner/$repo/pulls?head=$owner:$branch&state=open") -existing_pr_url=$(echo "$existing_pr_json" | jq -r '.[0].html_url // empty') -if [ -n "$existing_pr_url" ]; then - existing_pr_number=$(echo "$existing_pr_json" | jq -r '.[0].number // empty') - if ! curl -sfX PATCH \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $token" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -d "{\"title\": \"[Fuzz Corpus] $(date '+%m-%d-%Y')\", \"body\": $(jq -Rs . < "$summary_file")}" \ - --url "https://api.github.com/repos/$owner/$repo/pulls/${existing_pr_number}" > /dev/null - then - echo "Failed to update PR summary!" >&2 - exit 1 - fi - echo "$existing_pr_url" - echo "Creating the PR... done. (PR already existed; branch and summary were updated)" - exit 0 -fi - -resp=$(curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $token" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -d "@${payload_file}" \ - --url https://api.github.com/repos/$owner/$repo/pulls) - -pr_url=$(echo "$resp" | jq -r '.html_url // empty') -if [ -z "$pr_url" ]; then - echo "Failed to create PR! API response:" - echo "$resp" | jq . - exit 1 -fi -echo "$pr_url" -echo "Creating the PR... done." +push_branch "$branch" +create_or_update_pr "$branch" "[Fuzz Corpus] ${today}" "$summary_file" diff --git a/.evergreen/scripts/create-spec-pr.sh b/.evergreen/scripts/create-spec-pr.sh index fb2dea1640..8cc55a2d84 100755 --- a/.evergreen/scripts/create-spec-pr.sh +++ b/.evergreen/scripts/create-spec-pr.sh @@ -1,127 +1,28 @@ #!/usr/bin/env bash set -eu -# Default to the drivers-evergreen-tools submodule when unset; a -# caller-provided DRIVERS_TOOLS wins, as in the other consumers. -tools="$(realpath -s "${DRIVERS_TOOLS:-./drivers-evergreen-tools}")" -pushd $tools/.evergreen/github_app || exit +# Open (or update) the automated pull request resyncing the spec tests. +# Arguments: 1 = resync summary text to use as the PR body. -owner="mongodb" -repo="mongo-python-driver" +summary_file="$1" +today="$(date '+%m-%d-%Y')" -# Bootstrap the app. -echo "bootstrapping" -source utils.sh -bootstrap drivers/comment-bot +# Shared github-app authentication, git branch and PR plumbing. +# shellcheck disable=SC1091 +. "$(dirname "${BASH_SOURCE[0]}")/github-pr-lib.sh" -# Run the app. -source ./secrets-export.sh +acquire_github_token -# Get a github access token for the git checkout. -echo "Getting github token..." - -token=$(bash ./get-access-token.sh $repo $owner) -if [ -z "${token}" ]; then - echo "Failed to get github access token!" - popd || exit - exit 1 -fi -echo "Getting github token... done." -popd || exit - -# Make the git checkout and create a new branch. echo "Creating the git checkout..." -branch="spec-resync-"$(date '+%m-%d-%Y') - -git remote set-url origin https://x-access-token:${token}@github.com/$owner/$repo.git -# -B resets the branch if a reused checkout already has it, keeping reruns idempotent. -git checkout -B "$branch" "origin/main" +branch="spec-resync-${today}" +prepare_bot_branch "$branch" -# Attribute the commit to the bot user; fall back to the host identity. -bot_login="mongodb-drivers-pr-bot[bot]" -bot_id=$(curl -gsm 10 "https://api.github.com/users/${bot_login}" | jq -r '.id // empty' || true) -if [ -n "$bot_id" ]; then - git config user.name "$bot_login" - git config user.email "${bot_id}+${bot_login}@users.noreply.github.com" -fi - -git add ./test - -if git diff --cached --quiet && git diff --quiet --ignore-submodules=dirty; then +if ! stage_and_commit "resyncing specs ${today}" ./test; then echo "No spec changes to commit; skipping PR creation." - cat "$1" + cat "$summary_file" exit 0 fi - -git commit -am "resyncing specs $(date '+%m-%d-%Y')" echo "Creating the git checkout... done." -# Date-stamped branch: force-push makes same-day reruns idempotent; retry -# absorbs GitHub's intermittent 403s on the receive-pack endpoint. -push_ok=false -for _attempt in 1 2 3; do - if git push --force origin $branch; then - push_ok=true - break - fi - if [ "$_attempt" -lt 3 ]; then - echo "Push attempt ${_attempt} failed; retrying in 30s..." - sleep 30 - fi -done -if [ "$push_ok" != true ]; then - echo "Failed to push $branch after 3 attempts!" >&2 - exit 1 -fi - -# Build the payload as a file so the body content is always properly -# JSON-escaped, rather than interpolated into the command line as text. -payload_file=$(mktemp) -trap 'rm -f "$payload_file"' EXIT -jq -n \ - --arg title "[Spec Resync] $(date '+%m-%d-%Y')" \ - --arg head "${branch}" \ - --rawfile body "$1" \ - '{title: $title, body: $body, head: $head, base: "main"}' > "$payload_file" - -# Reuse an open PR for this branch (same-day rerun) instead of duplicating it. -existing_pr_json=$(curl -gs \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $token" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - --url "https://api.github.com/repos/$owner/$repo/pulls?head=$owner:$branch&state=open") -existing_pr_url=$(echo "$existing_pr_json" | jq -r '.[0].html_url // empty') -if [ -n "$existing_pr_url" ]; then - existing_pr_number=$(echo "$existing_pr_json" | jq -r '.[0].number // empty') - if ! curl -sfX PATCH \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $token" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -d "{\"title\": \"[Spec Resync] $(date '+%m-%d-%Y')\", \"body\": $(jq -Rs . < "$1")}" \ - --url "https://api.github.com/repos/$owner/$repo/pulls/${existing_pr_number}" > /dev/null - then - echo "Failed to update PR summary!" >&2 - exit 1 - fi - echo "$existing_pr_url" - echo "Creating the PR... done. (PR already existed; branch and summary were updated)" - rm -rf $tools - exit 0 -fi - -resp=$(curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $token" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -d "@${payload_file}" \ - --url https://api.github.com/repos/$owner/$repo/pulls) - -pr_url=$(echo "$resp" | jq -r '.html_url // empty') -if [ -z "$pr_url" ]; then - echo "Failed to create PR! API response:" - echo "$resp" | jq . - exit 1 -fi -echo "$pr_url" -echo "Creating the PR... done." +push_branch "$branch" +create_or_update_pr "$branch" "[Spec Resync] ${today}" "$summary_file" diff --git a/.evergreen/scripts/generate_config.py b/.evergreen/scripts/generate_config.py index 9877d253f3..a273af021a 100644 --- a/.evergreen/scripts/generate_config.py +++ b/.evergreen/scripts/generate_config.py @@ -517,14 +517,20 @@ def create_doctests_variants(): def create_fuzz_variants(): + # One variant for both fuzz flows: the regression reproducers run on + # every PR (pr-tagged task), the time-boxed fuzzing runs nightly. The + # host needs CPython, which the rhel8 toolchain provides. host = HOSTS["rhel8"] - # Regression test on every PR. - name = get_variant_name("Fuzz Regression", host) - pr_variant = create_variant([".fuzz-regression"], name, host=host, tags=["pr"]) - # Fuzzing requires CPython on Linux/macOS; use a pinned CPython on RHEL8. name = get_variant_name("Fuzz", host) - nightly = create_variant([".fuzz-nightly"], name, host=host, batchtime=BATCHTIME_DAY) - return [pr_variant, nightly] + return [ + create_variant( + [".fuzz-regression", ".fuzz-nightly"], + name, + host=host, + batchtime=BATCHTIME_DAY, + tags=["pr"], + ) + ] def create_sanitizer_variants() -> list[BuildVariant]: @@ -967,6 +973,12 @@ def create_fuzz_tasks(): "is_patch", "FUZZ_CORPUS_MAX_UNITS", "FUZZ_CORPUS_MAX_UNIT_BYTES", + # The harvest bootstraps the comment-bot github app, whose + # secrets live in AWS Secrets Manager; pass the assumed-role + # credentials as resync_specs and backport-pr also do. + "AWS_ACCESS_KEY_ID", + "AWS_SECRET_ACCESS_KEY", + "AWS_SESSION_TOKEN", ], ) tasks.append(EvgTask(name="fuzz", tags=tags, commands=[test_func, harvest_cmd])) diff --git a/.evergreen/scripts/test_generate_config.py b/.evergreen/scripts/test_generate_config.py index 51b67da1d5..4336d4dcb4 100644 --- a/.evergreen/scripts/test_generate_config.py +++ b/.evergreen/scripts/test_generate_config.py @@ -282,6 +282,30 @@ def test_non_standard_cov_tasks_have_no_cov_companions(): assert companion in no_cov, f"missing no-cov companion for {task.name}" +def test_fuzz_task_wiring(): + """One fuzz variant serving both flows: the pr-tagged regression task + runs on every PR, the untagged nightly task (which also harvests the + corpus) never runs in a patch build.""" + tasks = [task for task in all_tasks() if "fuzz" in (task.tags or [])] + assert [task.name for task in tasks if "pr" in (task.tags or [])] == ["fuzz-regression"] + assert [task.name for task in tasks if "pr" not in (task.tags or [])] == ["fuzz"] + variants = generate_config.create_fuzz_variants() + assert len(variants) == 1 + variant = variants[0] + for task in tasks: + assert variant_selects(variant, task) + assert "pr" in (variant.tags or []) + assert variant.batchtime == generate_config_utils.BATCHTIME_DAY + # The harvest subprocess bootstraps the comment-bot github app, whose + # secrets live in AWS Secrets Manager: it needs the assumed-role + # credentials (as resync_specs and backport-pr also pass them). + nightly = tasks[1] + harvest = nightly.commands[-1] + env_vars = harvest.params["include_expansions_in_env"] + for var in ("AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"): + assert var in env_vars, f"harvest subprocess missing {var}" + + def test_sanitizer_task_wiring(): """PYTHON-6048: one pr-tagged sanitizer task, selected by exactly one variant that pins MAX_VERSION and runs on a large host for ASan's memory From 042704fbef4278def433a39186e48a480ab0f9b1 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 12 Nov 2026 07:30:38 -0600 Subject: [PATCH 03/11] add pr script --- .evergreen/scripts/github-pr-lib.sh | 167 ++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100755 .evergreen/scripts/github-pr-lib.sh diff --git a/.evergreen/scripts/github-pr-lib.sh b/.evergreen/scripts/github-pr-lib.sh new file mode 100755 index 0000000000..e2b2d87de4 --- /dev/null +++ b/.evergreen/scripts/github-pr-lib.sh @@ -0,0 +1,167 @@ +#!/usr/bin/env bash +# Shared plumbing for the automated PR workflows (spec resync and fuzz +# corpus growth): github-app authentication, branch preparation, force +# pushing with retries, and create-or-update against the GitHub API. +# +# Source this file from a wrapper script run from the repository root +# (where the drivers-evergreen-tools submodule lives); it is not meant to +# be executed directly. Defines OWNER, REPO and the functions below; +# requires curl, jq and git. + +OWNER="mongodb" +REPO="mongo-python-driver" + +# Authenticate with the github app in drivers-evergreen-tools and set +# GITHUB_TOKEN. Exits the caller if no token can be obtained. +acquire_github_token() { + # Default to the drivers-evergreen-tools submodule when unset; a + # caller-provided DRIVERS_TOOLS wins, as in the other consumers. + local tools + tools="$(realpath -s "${DRIVERS_TOOLS:-./drivers-evergreen-tools}")" + pushd "$tools/.evergreen/github_app" || exit + + # Bootstrap the app. + echo "bootstrapping" + # shellcheck disable=SC1091 + source utils.sh + bootstrap drivers/comment-bot + + # Run the app. + # shellcheck disable=SC1091 + source ./secrets-export.sh + + # Get a github access token for the git checkout. + echo "Getting github token..." + + GITHUB_TOKEN=$(bash ./get-access-token.sh "$REPO" "$OWNER") + if [ -z "${GITHUB_TOKEN}" ]; then + echo "Failed to get github access token!" + popd || exit + exit 1 + fi + echo "Getting github token... done." + popd || exit +} + +# Prepare the git checkout: point origin at the repo with token auth, +# check out fresh from origin/main (-B resets a reused checkout, +# keeping reruns idempotent), and attribute commits to the drivers PR bot +# when its GitHub id is resolvable. +prepare_bot_branch() { + local branch="$1" + + git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${OWNER}/${REPO}.git" + git checkout -B "$branch" "origin/main" + + local bot_login="mongodb-drivers-pr-bot[bot]" bot_id + bot_id=$(curl -gsm 10 "https://api.github.com/users/${bot_login}" | jq -r '.id // empty' || true) + if [ -n "$bot_id" ]; then + git config user.name "$bot_login" + git config user.email "${bot_id}+${bot_login}@users.noreply.github.com" + fi +} + +# Stage the given paths and commit them. Arguments: the commit message, +# then the paths to stage. Returns 1 when the tree was already clean, so +# the caller can skip PR creation. Git failures exit the caller: errexit +# is suspended while this function runs in an "if" condition, so every +# fallible command is guarded explicitly. +stage_and_commit() { + local message="$1" + shift + + git add "$@" || exit + if git diff --cached --quiet && git diff --quiet --ignore-submodules=dirty; then + return 1 + fi + git commit -m "$message" || exit +} + +# Push to origin. Force-pushing makes same-day reruns of a +# date-stamped branch idempotent; the retries absorb GitHub's +# intermittent 403s on the receive-pack endpoint. Exits the caller after +# 3 failed attempts. +push_branch() { + local branch="$1" + + local push_ok=false + local attempt + for attempt in 1 2 3; do + if git push --force origin "$branch"; then + push_ok=true + break + fi + if [ "$attempt" -lt 3 ]; then + echo "Push attempt ${attempt} failed; retrying in 30s..." + sleep 30 + fi + done + if [ "$push_ok" != true ]; then + echo "Failed to push $branch after 3 attempts!" + exit 1 + fi +} + +# Create a PR from , or, when an open PR is already attached to +# that branch (a same-day rerun), update its title and body instead. +# Arguments: the branch name, the PR title, and the path to a file with +# the PR body. Echoes the PR url and exits the caller if GitHub rejects +# the request. +create_or_update_pr() { + local branch="$1" title="$2" summary_file="$3" + + # Build the payload as a file so the body content is always properly + # JSON-escaped, rather than interpolated into the command line as text. + # Not local: the EXIT trap below must still see it after this function + # returns. + payload_file=$(mktemp) + trap 'rm -f "$payload_file"' EXIT + jq -n \ + --arg title "$title" \ + --arg head "${branch}" \ + --rawfile body "$summary_file" \ + '{title: $title, body: $body, head: $head, base: "main"}' > "$payload_file" + + # Reuse an open PR for this branch (same-day rerun) instead of duplicating it. + local existing_pr_json existing_pr_url existing_pr_number + existing_pr_json=$(curl -gs \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + --url "https://api.github.com/repos/$OWNER/$REPO/pulls?head=$OWNER:$branch&state=open") + existing_pr_url=$(echo "$existing_pr_json" | jq -r '.[0].html_url // empty') + if [ -n "$existing_pr_url" ]; then + existing_pr_number=$(echo "$existing_pr_json" | jq -r '.[0].number // empty') + if ! curl -sfX PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -d "$(jq -n --arg title "$title" --rawfile body "$summary_file" '{title: $title, body: $body}')" \ + --url "https://api.github.com/repos/$OWNER/$REPO/pulls/${existing_pr_number}" > /dev/null + then + echo "Failed to update PR summary!" + exit 1 + fi + echo "$existing_pr_url" + echo "Creating the PR... done. (PR already existed; branch and summary were updated)" + return 0 + fi + + local resp pr_url + resp=$(curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -d "@${payload_file}" \ + --url "https://api.github.com/repos/$OWNER/$REPO/pulls") + + pr_url=$(echo "$resp" | jq -r '.html_url // empty') + if [ -z "$pr_url" ]; then + echo "Failed to create PR! API response:" + echo "$resp" | jq . + exit 1 + fi + echo "$pr_url" + echo "Creating the PR... done." +} From 5a97ce1dd4b9aa9392f18535af385890f68829ac Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 12 Nov 2026 07:34:30 -0600 Subject: [PATCH 04/11] rename script --- .evergreen/scripts/create-fuzz-corpus-pr.sh | 2 +- .evergreen/scripts/create-spec-pr.sh | 2 +- .evergreen/scripts/{github-pr-lib.sh => github-pr-util.sh} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename .evergreen/scripts/{github-pr-lib.sh => github-pr-util.sh} (100%) diff --git a/.evergreen/scripts/create-fuzz-corpus-pr.sh b/.evergreen/scripts/create-fuzz-corpus-pr.sh index 3c10d52dc7..7bf337702e 100755 --- a/.evergreen/scripts/create-fuzz-corpus-pr.sh +++ b/.evergreen/scripts/create-fuzz-corpus-pr.sh @@ -11,7 +11,7 @@ today="$(date '+%m-%d-%Y')" # Shared github-app authentication, git branch and PR plumbing. # shellcheck disable=SC1091 -. "$(dirname "${BASH_SOURCE[0]}")/github-pr-lib.sh" +. "$(dirname "${BASH_SOURCE[0]}")/github-pr-util.sh" acquire_github_token diff --git a/.evergreen/scripts/create-spec-pr.sh b/.evergreen/scripts/create-spec-pr.sh index 8cc55a2d84..80e31d0fe2 100755 --- a/.evergreen/scripts/create-spec-pr.sh +++ b/.evergreen/scripts/create-spec-pr.sh @@ -9,7 +9,7 @@ today="$(date '+%m-%d-%Y')" # Shared github-app authentication, git branch and PR plumbing. # shellcheck disable=SC1091 -. "$(dirname "${BASH_SOURCE[0]}")/github-pr-lib.sh" +. "$(dirname "${BASH_SOURCE[0]}")/github-pr-util.sh" acquire_github_token diff --git a/.evergreen/scripts/github-pr-lib.sh b/.evergreen/scripts/github-pr-util.sh similarity index 100% rename from .evergreen/scripts/github-pr-lib.sh rename to .evergreen/scripts/github-pr-util.sh From 7ed2b7367291d2278b0228cb85049fad2de22e56 Mon Sep 17 00:00:00 2001 From: t Date: Thu, 12 Nov 2026 07:49:32 -0600 Subject: [PATCH 05/11] address review --- .evergreen/scripts/create-spec-pr.sh | 4 +++- .evergreen/scripts/generate_config.py | 6 +++--- .evergreen/scripts/harvest-fuzz-corpus.sh | 18 ++++++++++++++++++ fuzz/README.md | 6 ++++-- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.evergreen/scripts/create-spec-pr.sh b/.evergreen/scripts/create-spec-pr.sh index 80e31d0fe2..51561ef29f 100755 --- a/.evergreen/scripts/create-spec-pr.sh +++ b/.evergreen/scripts/create-spec-pr.sh @@ -17,7 +17,9 @@ echo "Creating the git checkout..." branch="spec-resync-${today}" prepare_bot_branch "$branch" -if ! stage_and_commit "resyncing specs ${today}" ./test; then +# The spec sync also updates the vendored public suffix list (cp_psl in +# resync-specs.sh), a tracked file outside test/. +if ! stage_and_commit "resyncing specs ${today}" ./test pymongo/public_suffix_list.dat; then echo "No spec changes to commit; skipping PR creation." cat "$summary_file" exit 0 diff --git a/.evergreen/scripts/generate_config.py b/.evergreen/scripts/generate_config.py index a273af021a..ec955a08ea 100644 --- a/.evergreen/scripts/generate_config.py +++ b/.evergreen/scripts/generate_config.py @@ -964,9 +964,9 @@ def create_fuzz_tasks(): test_vars = dict(TEST_NAME="fuzz", SUB_TEST_NAME="fuzz", UV_PYTHON="3.13") test_func = FunctionCall(func="run tests", vars=test_vars) # PYTHON-6178: while the scratch corpus still exists, harvest the new - # coverage-increasing inputs and open an automated PR growing - # fuzz/corpus/. Runs only when the targets finished green, so crashing - # inputs never reach the corpus. + # coverage-increasing inputs, replay them through every target so a + # unit that fails one is never published, and open an automated PR + # growing fuzz/corpus/. harvest_cmd = get_subprocess_exec( args=[".evergreen/scripts/harvest-fuzz-corpus.sh"], include_expansions_in_env=[ diff --git a/.evergreen/scripts/harvest-fuzz-corpus.sh b/.evergreen/scripts/harvest-fuzz-corpus.sh index a10b2f866b..b7220cb3fe 100755 --- a/.evergreen/scripts/harvest-fuzz-corpus.sh +++ b/.evergreen/scripts/harvest-fuzz-corpus.sh @@ -22,5 +22,23 @@ if [ -z "$(ls -A fuzz-scratch/harvest 2>/dev/null || true)" ]; then exit 0 fi +# Replay the harvested units through every target before publishing. +# The targets ran sequentially over one shared corpus, so a unit found +# by a later target never ran through the earlier ones, and publishing +# it could break the regression run of every later PR. Each input runs +# exactly once, as in the regression sub-test; a replay failure leaves +# the unit in fuzz-scratch/ for triage and fails the task instead of +# opening a PR. +replay=(fuzz-scratch/harvest/*) +for target in fuzz_decode fuzz_decode_all fuzz_is_valid; do + echo "Replaying harvested units against ${target}..." + if ! uv run --no-sync python "fuzz/${target}.py" "${replay[@]}" \ + -artifact_prefix="$PWD/fuzz-scratch/" -atheris_runs="${#replay[@]}" + then + echo "Harvested unit fails ${target}; no corpus PR." >&2 + exit 1 + fi +done + bash .evergreen/scripts/create-fuzz-corpus-pr.sh \ fuzz-scratch/harvest fuzz-scratch/harvest-summary.md diff --git a/fuzz/README.md b/fuzz/README.md index d356650f16..1695e88040 100644 --- a/fuzz/README.md +++ b/fuzz/README.md @@ -100,8 +100,10 @@ native ASan-instrumented fuzzing is tracked separately (PYTHON-6169). The nightly run seeds from the spec seed corpus plus every unit in `corpus/`, and libFuzzer writes each coverage-increasing ("interesting") input it discovers back into its corpus directory. After the targets -finish, the `fuzz` task harvests those new units into `corpus/` and opens -an automated "[Fuzz Corpus]" PR against main (PYTHON-6178). Later nights +finish, the `fuzz` task harvests those new units, replays them through +every target once so a unit that fails any target is never published (it +stays in `fuzz-scratch/` for triage), and opens an automated +"[Fuzz Corpus]" PR against main (PYTHON-6178). Later nights build on prior discoveries instead of restarting from the spec seeds. Growth is bounded by per-unit and per-run caps, overridable on Evergreen: From a5973bbf514851974a5341e50b2fddc61e25245e Mon Sep 17 00:00:00 2001 From: t Date: Thu, 12 Nov 2026 10:53:38 -0600 Subject: [PATCH 06/11] remove workaround --- .codecov.yml | 11 - .evergreen/combine-coverage.sh | 16 - .evergreen/config.yml | 84 - .evergreen/generated_configs/functions.yml | 347 - .evergreen/generated_configs/tasks.yml | 5687 --------- .evergreen/generated_configs/variants.yml | 754 -- .evergreen/just.sh | 5 - .evergreen/remove-unimplemented-tests.sh | 55 - .evergreen/resync-specs.sh | 288 - .evergreen/run-mongodb-aws-ecs-test.sh | 35 - .evergreen/run-mongodb-oidc-test.sh | 17 - .evergreen/run-tests.sh | 38 - .evergreen/scripts/__init__.py | 0 .evergreen/scripts/check-import-time.sh | 41 - .evergreen/scripts/cleanup.sh | 19 - .evergreen/scripts/configure-env.sh | 142 - .evergreen/scripts/create-fuzz-corpus-pr.sh | 31 - .evergreen/scripts/create-spec-pr.sh | 30 - .evergreen/scripts/dispatch.sh | 46 - .../scripts/download-and-merge-coverage.sh | 4 - .evergreen/scripts/generate-config.sh | 9 - .evergreen/scripts/generate_config.py | 1545 --- .evergreen/scripts/generate_config_utils.py | 357 - .evergreen/scripts/github-pr-util.sh | 167 - .evergreen/scripts/harvest-fuzz-corpus.sh | 44 - .evergreen/scripts/install-dependencies.sh | 94 - .evergreen/scripts/kms_tester.py | 141 - .evergreen/scripts/mod_wsgi.sh | 263 - .evergreen/scripts/mod_wsgi_matrix.py | 29 - .evergreen/scripts/mod_wsgi_tester.py | 312 - .evergreen/scripts/oidc_tester.py | 119 - .evergreen/scripts/perf-submission-setup.sh | 15 - .evergreen/scripts/perf-submission.sh | 25 - .evergreen/scripts/resync-all-specs.sh | 48 - .evergreen/scripts/resync_all_specs.py | 159 - .evergreen/scripts/run-getdata.sh | 33 - .evergreen/scripts/run-server.sh | 13 - .evergreen/scripts/run_server.py | 79 - .evergreen/scripts/run_tests.py | 272 - .evergreen/scripts/setup-dev-env.sh | 119 - .evergreen/scripts/setup-system.sh | 55 - .evergreen/scripts/setup-tests.sh | 26 - .evergreen/scripts/setup-uv-python.sh | 131 - .evergreen/scripts/setup_tests.py | 627 - .evergreen/scripts/setup_uv.py | 176 - .evergreen/scripts/stop-server.sh | 18 - .evergreen/scripts/teardown-tests.sh | 24 - .evergreen/scripts/teardown_tests.py | 58 - .evergreen/scripts/test_generate_config.py | 329 - .evergreen/scripts/upload-codecov.sh | 57 - .evergreen/scripts/upload-coverage-report.sh | 4 - .evergreen/scripts/utils.py | 342 - .evergreen/setup-spawn-host.sh | 18 - .evergreen/spec-patch/PYTHON-3712.patch | 15 - .evergreen/spec-patch/PYTHON-4918.patch | 24 - .evergreen/spec-patch/PYTHON-5052.patch | 440 - .evergreen/spec-patch/PYTHON-5445.patch | 26 - .evergreen/spec-patch/PYTHON-5493.patch | 50 - .evergreen/spec-patch/PYTHON-5559.patch | 815 -- .evergreen/spec-patch/PYTHON-5759.patch | 460 - .evergreen/spec-patch/PYTHON-5993.patch | 94 - .../spec-patch/permanent/PYTHON-2673.patch | 65 - .../spec-patch/permanent/PYTHON-4261.patch | 62 - .evergreen/sync-spawn-host.sh | 20 - .git-blame-ignore-revs | 12 - .github/CODEOWNERS | 1 - .github/actions/mod-wsgi-versions/action.yml | 23 - .github/copilot-instructions.md | 48 - .github/dependabot.yml | 47 - .github/pull_request_template.md | 35 - .github/reviewers.txt | 5 - .github/workflows/codeql.yml | 50 - .github/workflows/create-release-branch.yml | 77 - .github/workflows/dist.yml | 153 - .github/workflows/release-python.yml | 111 - .github/workflows/sbom.yml | 105 - .github/workflows/test-mod-wsgi.yml | 181 - .github/workflows/test-python.yml | 290 - .github/workflows/uv-lock-update.yml | 42 - .github/workflows/zizmor.yml | 21 - .github/zizmor.yml | 7 - .gitignore | 58 - .gitmodules | 3 - .pre-commit-config.yaml | 131 - .readthedocs.yaml | 24 - AGENTS.md | 50 - CLAUDE.md | 1 - CODING-STANDARDS.md | 204 - CONTRIBUTING.md | 692 -- LICENSE | 201 - README.md | 219 - THIRD-PARTY-NOTICES | 98 - _setup.py | 148 - bson/__init__.py | 1513 --- bson/_cbsonmodule.c | 3723 ------ bson/_cbsonmodule.h | 183 - bson/_helpers.py | 47 - bson/binary.py | 669 - bson/bson-endian.h | 233 - bson/buffer.c | 170 - bson/buffer.h | 51 - bson/code.py | 102 - bson/codec_options.py | 490 - bson/datetime_ms.py | 181 - bson/dbref.py | 137 - bson/decimal128.py | 361 - bson/errors.py | 50 - bson/int64.py | 40 - bson/json_util.py | 1148 -- bson/max_key.py | 57 - bson/min_key.py | 57 - bson/objectid.py | 262 - bson/py.typed | 2 - bson/raw_bson.py | 227 - bson/regex.py | 135 - bson/son.py | 223 - bson/time64.c | 781 -- bson/time64.h | 67 - bson/time64_config.h | 78 - bson/time64_limits.h | 95 - bson/timestamp.py | 124 - bson/typings.py | 33 - bson/tz_util.py | 56 - doc/Makefile | 20 - doc/__init__.py | 0 doc/_templates/layout.html | 18 - doc/api/bson/binary.rst | 35 - doc/api/bson/code.rst | 9 - doc/api/bson/codec_options.rst | 6 - doc/api/bson/datetime_ms.rst | 6 - doc/api/bson/dbref.rst | 6 - doc/api/bson/decimal128.rst | 4 - doc/api/bson/errors.rst | 6 - doc/api/bson/index.rst | 29 - doc/api/bson/int64.rst | 7 - doc/api/bson/json_util.rst | 7 - doc/api/bson/max_key.rst | 5 - doc/api/bson/min_key.rst | 5 - doc/api/bson/objectid.rst | 27 - doc/api/bson/raw_bson.rst | 5 - doc/api/bson/regex.rst | 7 - doc/api/bson/son.rst | 6 - doc/api/bson/timestamp.rst | 5 - doc/api/bson/tz_util.rst | 6 - doc/api/gridfs/asynchronous/grid_file.rst | 19 - doc/api/gridfs/asynchronous/index.rst | 14 - doc/api/gridfs/errors.rst | 6 - doc/api/gridfs/grid_file.rst | 19 - doc/api/gridfs/index.rst | 15 - doc/api/index.rst | 17 - .../pymongo/asynchronous/change_stream.rst | 7 - .../pymongo/asynchronous/client_session.rst | 7 - doc/api/pymongo/asynchronous/collection.rst | 62 - .../pymongo/asynchronous/command_cursor.rst | 8 - doc/api/pymongo/asynchronous/cursor.rst | 19 - doc/api/pymongo/asynchronous/database.rst | 27 - doc/api/pymongo/asynchronous/index.rst | 23 - doc/api/pymongo/asynchronous/mongo_client.rst | 41 - doc/api/pymongo/auth_oidc.rst | 5 - doc/api/pymongo/change_stream.rst | 6 - doc/api/pymongo/client_options.rst | 7 - doc/api/pymongo/client_session.rst | 6 - doc/api/pymongo/collation.rst | 19 - doc/api/pymongo/collection.rst | 73 - doc/api/pymongo/command_cursor.rst | 7 - doc/api/pymongo/cursor.rst | 28 - doc/api/pymongo/database.rst | 28 - doc/api/pymongo/driver_info.rst | 6 - doc/api/pymongo/encryption.rst | 5 - doc/api/pymongo/encryption_options.rst | 6 - doc/api/pymongo/errors.rst | 6 - doc/api/pymongo/event_loggers.rst | 7 - doc/api/pymongo/index.rst | 62 - doc/api/pymongo/mongo_client.rst | 40 - doc/api/pymongo/monitoring.rst | 99 - doc/api/pymongo/operations.rst | 6 - doc/api/pymongo/pool.rst | 7 - doc/api/pymongo/read_concern.rst | 7 - doc/api/pymongo/read_preferences.rst | 31 - doc/api/pymongo/results.rst | 7 - doc/api/pymongo/server_api.rst | 11 - doc/api/pymongo/server_description.rst | 9 - doc/api/pymongo/topology_description.rst | 9 - doc/api/pymongo/uri_parser.rst | 6 - doc/api/pymongo/write_concern.rst | 6 - doc/changelog.rst | 4804 ------- doc/conf.py | 222 - doc/contributors.rst | 113 - doc/index.rst | 71 - doc/make.bat | 35 - doc/migrate-to-pymongo4.rst | 995 -- doc/pydoctheme/static/pydoctheme.css | 178 - doc/pydoctheme/theme.conf | 24 - doc/static/periodic-executor-refs.dot | 17 - doc/static/periodic-executor-refs.png | Bin 39586 -> 0 bytes doc/static/sidebar.js | 193 - drivers-evergreen-tools | 1 - fuzz/README.md | 151 - fuzz/build_corpus.py | 194 - fuzz/corpus/.gitkeep | 0 fuzz/fuzz_decode.py | 78 - fuzz/fuzz_decode_all.py | 87 - fuzz/fuzz_is_valid.py | 60 - fuzz/fuzz_shared.py | 72 - fuzz/harvest_corpus.py | 190 - fuzz/regression/decode__binary_subtype_255 | Bin 29 -> 0 bytes fuzz/regression/decode__boolean_no_terminator | Bin 8 -> 0 bytes .../decode__decimal128_noncanonical | Bin 24 -> 0 bytes .../decode__regex_flags_invalid_utf8 | Bin 15 -> 0 bytes fuzz/regression/decode__regex_flags_repr | Bin 15 -> 0 bytes fuzz/regression/decode__regex_no_terminator | Bin 8 -> 0 bytes gridfs/__init__.py | 55 - gridfs/asynchronous/__init__.py | 43 - gridfs/asynchronous/grid_file.py | 2034 --- gridfs/errors.py | 35 - gridfs/grid_file.py | 19 - gridfs/grid_file_shared.py | 166 - gridfs/py.typed | 2 - gridfs/synchronous/__init__.py | 43 - gridfs/synchronous/grid_file.py | 2014 --- hatch_build.py | 37 - integration_tests/README.md | 42 - integration_tests/run.sh | 11 - integration_tests/test_uv_loop.py | 27 - justfile | 160 - mypy_test.ini | 15 - pymongo/__init__.py | 181 - pymongo/_asyncio_lock.py | 318 - pymongo/_azure_helpers.py | 59 - pymongo/_client_bulk_shared.py | 233 - pymongo/_cmessagemodule.c | 1049 -- pymongo/_csot.py | 173 - pymongo/_gcp_helpers.py | 41 - pymongo/_kms_connect_shared.py | 492 - pymongo/_op_id.py | 54 - pymongo/_psl.py | 92 - pymongo/_telemetry.py | 777 -- pymongo/_version.py | 43 - pymongo/asynchronous/__init__.py | 0 pymongo/asynchronous/_kms_connect.py | 145 - pymongo/asynchronous/aggregation.py | 256 - pymongo/asynchronous/auth.py | 377 - pymongo/asynchronous/auth_aws.py | 100 - pymongo/asynchronous/auth_oidc.py | 231 - pymongo/asynchronous/bulk.py | 450 - pymongo/asynchronous/change_stream.py | 308 - pymongo/asynchronous/client_bulk.py | 500 - pymongo/asynchronous/client_session.py | 625 - pymongo/asynchronous/collection.py | 3673 ------ pymongo/asynchronous/command_cursor.py | 259 - pymongo/asynchronous/command_runner.py | 458 - pymongo/asynchronous/cursor.py | 457 - pymongo/asynchronous/cursor_base.py | 227 - pymongo/asynchronous/database.py | 1473 --- pymongo/asynchronous/encryption.py | 1193 -- pymongo/asynchronous/helpers.py | 97 - pymongo/asynchronous/mongo_client.py | 3114 ----- pymongo/asynchronous/monitor.py | 507 - pymongo/asynchronous/pool.py | 1027 -- pymongo/asynchronous/server.py | 100 - pymongo/asynchronous/settings.py | 90 - pymongo/asynchronous/srv_resolver.py | 212 - pymongo/asynchronous/topology.py | 723 -- pymongo/asynchronous/uri_parser.py | 209 - pymongo/auth.py | 23 - pymongo/auth_oidc.py | 24 - pymongo/auth_oidc_shared.py | 225 - pymongo/auth_shared.py | 347 - pymongo/bulk_shared.py | 299 - pymongo/change_stream.py | 23 - pymongo/change_stream_shared.py | 254 - pymongo/client_options.py | 376 - pymongo/client_session.py | 23 - pymongo/client_session_shared.py | 778 -- pymongo/collation.py | 232 - pymongo/collection.py | 26 - pymongo/command_cursor.py | 23 - pymongo/common.py | 1197 -- pymongo/compression_support.py | 231 - pymongo/cursor.py | 24 - pymongo/cursor_shared.py | 1110 -- pymongo/daemon.py | 152 - pymongo/database.py | 23 - pymongo/database_shared.py | 36 - pymongo/driver_info.py | 52 - pymongo/encryption.py | 23 - pymongo/encryption_options.py | 417 - pymongo/encryption_shared.py | 160 - pymongo/errors.py | 442 - pymongo/event_loggers.py | 225 - pymongo/hello.py | 229 - pymongo/helpers_shared.py | 406 - pymongo/lock.py | 90 - pymongo/logger.py | 193 - pymongo/max_staleness_selectors.py | 124 - pymongo/message.py | 1459 --- pymongo/mongo_client.py | 23 - pymongo/mongo_client_shared.py | 243 - pymongo/monitoring.py | 1851 --- pymongo/network_layer.py | 786 -- pymongo/ocsp_cache.py | 131 - pymongo/ocsp_support.py | 441 - pymongo/operations.py | 831 -- pymongo/periodic_executor.py | 336 - pymongo/pool.py | 23 - pymongo/pool_options.py | 653 - pymongo/pool_shared.py | 1033 -- pymongo/public_suffix_list.dat | 10334 ---------------- pymongo/py.typed | 2 - pymongo/pyopenssl_context.py | 412 - pymongo/read_concern.py | 82 - pymongo/read_preferences.py | 637 - pymongo/response.py | 122 - pymongo/results.py | 366 - pymongo/saslprep.py | 117 - pymongo/server_api.py | 177 - pymongo/server_description.py | 305 - pymongo/server_selectors.py | 176 - pymongo/server_type.py | 34 - pymongo/settings_shared.py | 190 - pymongo/socket_checker.py | 103 - pymongo/ssl_context.py | 43 - pymongo/ssl_support.py | 168 - pymongo/synchronous/__init__.py | 0 pymongo/synchronous/_kms_connect.py | 145 - pymongo/synchronous/aggregation.py | 254 - pymongo/synchronous/auth.py | 373 - pymongo/synchronous/auth_aws.py | 100 - pymongo/synchronous/auth_oidc.py | 229 - pymongo/synchronous/bulk.py | 448 - pymongo/synchronous/change_stream.py | 308 - pymongo/synchronous/client_bulk.py | 498 - pymongo/synchronous/client_session.py | 620 - pymongo/synchronous/collection.py | 3658 ------ pymongo/synchronous/command_cursor.py | 255 - pymongo/synchronous/command_runner.py | 458 - pymongo/synchronous/cursor.py | 453 - pymongo/synchronous/cursor_base.py | 227 - pymongo/synchronous/database.py | 1470 --- pymongo/synchronous/encryption.py | 1186 -- pymongo/synchronous/helpers.py | 97 - pymongo/synchronous/mongo_client.py | 3100 ----- pymongo/synchronous/monitor.py | 505 - pymongo/synchronous/pool.py | 1025 -- pymongo/synchronous/server.py | 100 - pymongo/synchronous/settings.py | 90 - pymongo/synchronous/srv_resolver.py | 212 - pymongo/synchronous/topology.py | 721 -- pymongo/synchronous/uri_parser.py | 209 - pymongo/topology_description.py | 717 -- pymongo/topology_shared.py | 346 - pymongo/typings.py | 86 - pymongo/uri_parser.py | 45 - pymongo/uri_parser_shared.py | 636 - pymongo/write_concern.py | 147 - pyproject.toml | 320 - requirements.txt | 1 - requirements/aws.txt | 1 - requirements/docs.txt | 6 - requirements/encryption.txt | 3 - requirements/gssapi.txt | 2 - requirements/mod_wsgi.txt | 3 - requirements/ocsp.txt | 14 - requirements/snappy.txt | 1 - requirements/test.txt | 3 - requirements/zstd.txt | 1 - sbom.json | 202 - setup.py | 8 - strict_pyrightconfig.json | 1 - test/__init__.py | 1325 -- test/asynchronous/__init__.py | 1341 -- test/asynchronous/conftest.py | 27 - test/asynchronous/helpers.py | 170 - test/asynchronous/pymongo_mocks.py | 253 - test/asynchronous/qcheck.py | 255 - test/asynchronous/test_async_cancellation.py | 131 - .../test_async_contextvars_reset.py | 45 - test/asynchronous/test_async_loop_safety.py | 37 - .../asynchronous/test_async_loop_unblocked.py | 57 - test/asynchronous/test_async_network_layer.py | 404 - test/asynchronous/test_auth.py | 748 -- test/asynchronous/test_auth_oidc.py | 1215 -- test/asynchronous/test_auth_spec.py | 116 - test/asynchronous/test_bulk.py | 1121 -- test/asynchronous/test_causal_consistency.py | 34 - test/asynchronous/test_change_stream.py | 1142 -- test/asynchronous/test_client.py | 3279 ----- test/asynchronous/test_client_backpressure.py | 384 - test/asynchronous/test_client_bulk_write.py | 685 - test/asynchronous/test_client_context.py | 55 - test/asynchronous/test_client_metadata.py | 364 - test/asynchronous/test_collation.py | 283 - test/asynchronous/test_collection.py | 2282 ---- .../test_collection_management.py | 34 - test/asynchronous/test_command_logging.py | 38 - test/asynchronous/test_command_monitoring.py | 39 - test/asynchronous/test_comment.py | 159 - test/asynchronous/test_common.py | 186 - test/asynchronous/test_concurrency.py | 63 - test/asynchronous/test_connection_logging.py | 39 - .../test_connection_monitoring.py | 490 - ...nnections_survive_primary_stepdown_spec.py | 138 - test/asynchronous/test_create_entities.py | 134 - test/asynchronous/test_crud_unified.py | 34 - test/asynchronous/test_csot.py | 108 - test/asynchronous/test_cursor.py | 1872 --- test/asynchronous/test_custom_types.py | 986 -- test/asynchronous/test_database.py | 739 -- .../test_discovery_and_monitoring.py | 842 -- test/asynchronous/test_dns.py | 453 - test/asynchronous/test_encryption.py | 3848 ------ test/asynchronous/test_examples.py | 1447 --- test/asynchronous/test_grid_file.py | 878 -- test/asynchronous/test_gridfs.py | 608 - test/asynchronous/test_gridfs_bucket.py | 628 - test/asynchronous/test_gridfs_spec.py | 34 - test/asynchronous/test_handshake_unified.py | 32 - .../asynchronous/test_heartbeat_monitoring.py | 99 - test/asynchronous/test_hello_latched.py | 82 - test/asynchronous/test_index_management.py | 398 - .../test_json_util_integration.py | 32 - test/asynchronous/test_kms_connect_prose.py | 218 - test/asynchronous/test_load_balancer.py | 198 - test/asynchronous/test_locks.py | 455 - test/asynchronous/test_logger.py | 172 - test/asynchronous/test_max_staleness.py | 150 - .../test_mongos_load_balancing.py | 199 - test/asynchronous/test_monitor.py | 129 - test/asynchronous/test_monitoring.py | 1279 -- test/asynchronous/test_on_demand_csfle.py | 113 - test/asynchronous/test_operation_id_retry.py | 303 - test/asynchronous/test_periodic_executor.py | 351 - test/asynchronous/test_pooling.py | 961 -- test/asynchronous/test_raw_bson.py | 156 - test/asynchronous/test_read_concern.py | 119 - test/asynchronous/test_read_preferences.py | 737 -- .../test_read_write_concern_spec.py | 351 - test/asynchronous/test_retryable_reads.py | 525 - .../test_retryable_reads_unified.py | 41 - test/asynchronous/test_retryable_writes.py | 912 -- .../test_retryable_writes_unified.py | 36 - test/asynchronous/test_run_command.py | 36 - .../asynchronous/test_sdam_monitoring_spec.py | 371 - test/asynchronous/test_server_selection.py | 249 - .../test_server_selection_in_window.py | 207 - .../test_server_selection_logging.py | 40 - .../asynchronous/test_server_selection_rtt.py | 77 - test/asynchronous/test_session.py | 1349 -- test/asynchronous/test_sessions_unified.py | 34 - test/asynchronous/test_sfp.py | 113 - test/asynchronous/test_srv_polling.py | 487 - test/asynchronous/test_ssl.py | 952 -- test/asynchronous/test_streaming_protocol.py | 231 - test/asynchronous/test_subinterpreters.py | 279 - test/asynchronous/test_transactions.py | 732 -- .../asynchronous/test_transactions_unified.py | 44 - test/asynchronous/test_unified_format.py | 93 - .../test_versioned_api_integration.py | 78 - test/asynchronous/unified_format.py | 1718 --- test/asynchronous/utils.py | 296 - test/asynchronous/utils_selection_tests.py | 230 - test/asynchronous/utils_spec_runner.py | 195 - test/atlas/test_connection.py | 114 - test/auth/legacy/connection-string.json | 651 - test/auth/unified/mongodb-oidc-no-retry.json | 428 - test/auth_aws/test_auth_aws.py | 214 - test/bson_binary_vector/float32.json | 65 - test/bson_binary_vector/int8.json | 57 - test/bson_binary_vector/packed_bit.json | 83 - test/bson_corpus/array.json | 49 - test/bson_corpus/binary.json | 153 - test/bson_corpus/boolean.json | 27 - test/bson_corpus/code.json | 67 - test/bson_corpus/code_w_scope.json | 78 - test/bson_corpus/datetime.json | 43 - test/bson_corpus/dbpointer.json | 56 - test/bson_corpus/dbref.json | 66 - test/bson_corpus/decimal128-1.json | 341 - test/bson_corpus/decimal128-2.json | 793 -- test/bson_corpus/decimal128-3.json | 1771 --- test/bson_corpus/decimal128-4.json | 165 - test/bson_corpus/decimal128-5.json | 402 - test/bson_corpus/decimal128-6.json | 131 - test/bson_corpus/decimal128-7.json | 327 - test/bson_corpus/document.json | 60 - test/bson_corpus/double.json | 87 - test/bson_corpus/int32.json | 43 - test/bson_corpus/int64.json | 43 - test/bson_corpus/maxkey.json | 12 - test/bson_corpus/minkey.json | 12 - test/bson_corpus/multi-type-deprecated.json | 15 - test/bson_corpus/multi-type.json | 11 - test/bson_corpus/null.json | 12 - test/bson_corpus/oid.json | 28 - test/bson_corpus/regex.json | 65 - test/bson_corpus/string.json | 72 - test/bson_corpus/symbol.json | 80 - test/bson_corpus/timestamp.json | 34 - test/bson_corpus/top.json | 266 - test/bson_corpus/undefined.json | 15 - .../causal-consistency-clientBulkWrite.json | 151 - .../causal-consistency-write-commands.json | 1396 --- test/certificates/ca.pem | 21 - test/certificates/client.pem | 48 - test/certificates/crl.pem | 13 - test/certificates/password_protected.pem | 51 - test/certificates/server.pem | 49 - test/certificates/trusted-ca.pem | 82 - .../unified/change-streams-clusterTime.json | 81 - .../change-streams-disambiguatedPaths.json | 272 - .../unified/change-streams-errors.json | 246 - .../unified/change-streams-nsType.json | 104 - .../change-streams-pre_and_post_images.json | 827 -- .../change-streams-resume-allowlist.json | 2348 ---- .../change-streams-resume-errorLabels.json | 2130 ---- .../change-streams-showExpandedEvents.json | 516 - .../unified/change-streams.json | 1805 --- .../backpressure-connection-checkin.json | 111 - .../backpressure-retry-loop.json | 4553 ------- .../backpressure-retry-max-attempts.json | 2569 ---- test/client-backpressure/getMore-retried.json | 253 - .../corpus/corpus-encrypted.json | 9515 -------------- .../corpus/corpus-key-aws.json | 33 - .../corpus/corpus-key-azure.json | 33 - .../corpus/corpus-key-gcp.json | 35 - .../corpus/corpus-key-kmip.json | 32 - .../corpus/corpus-key-local.json | 31 - .../corpus/corpus-schema.json | 6335 ---------- .../client-side-encryption/corpus/corpus.json | 8619 ------------- .../custom/azure-dek.json | 33 - .../custom/azure-gcp-schema.json | 31 - .../custom/gcp-dek.json | 35 - .../custom/key-document-local.json | 18 - .../client-side-encryption/custom/schema.json | 17 - .../etc/data/encryptedFields-c10.json | 30 - .../encryptedFields-prefix-suffix-ci-di.json | 40 - .../data/encryptedFields-prefix-suffix.json | 44 - .../data/encryptedFields-substring-ci-di.json | 31 - .../etc/data/encryptedFields-substring.json | 33 - .../etc/data/encryptedFields.json | 30 - .../etc/data/keys/key1-document.json | 30 - .../etc/data/keys/key1-id.json | 6 - .../etc/data/keys/key2-document.json | 30 - .../etc/data/keys/key2-id.json | 6 - .../etc/data/lookup/key-doc.json | 30 - .../etc/data/lookup/schema-csfle.json | 19 - .../etc/data/lookup/schema-csfle2.json | 19 - .../etc/data/lookup/schema-non-csfle.json | 3 - .../etc/data/lookup/schema-qe.json | 20 - .../etc/data/lookup/schema-qe2.json | 20 - .../etc/data/range-encryptedFields-Date.json | 36 - ...ge-encryptedFields-DecimalNoPrecision.json | 26 - ...ange-encryptedFields-DecimalPrecision.json | 35 - ...nge-encryptedFields-DoubleNoPrecision.json | 26 - ...range-encryptedFields-DoublePrecision.json | 35 - .../etc/data/range-encryptedFields-Int.json | 32 - .../etc/data/range-encryptedFields-Long.json | 32 - .../external/external-key.json | 31 - .../external/external-schema.json | 19 - .../limits/limits-doc.json | 102 - .../limits/limits-encryptedFields.json | 14 - .../limits/limits-key.json | 31 - .../limits/limits-qe-doc.json | 3 - .../limits/limits-schema.json | 1405 --- .../spec/legacy/aggregate.json | 390 - .../spec/legacy/awsTemporary.json | 225 - .../spec/legacy/azureKMS.json | 235 - .../spec/legacy/badQueries.json | 1446 --- .../spec/legacy/badSchema.json | 254 - .../spec/legacy/basic.json | 350 - .../spec/legacy/bulk.json | 333 - .../spec/legacy/bypassAutoEncryption.json | 402 - .../spec/legacy/bypassedCommand.json | 107 - .../spec/legacy/count.json | 229 - .../spec/legacy/countDocuments.json | 241 - .../spec/legacy/create-and-createIndexes.json | 115 - .../spec/legacy/delete.json | 340 - .../spec/legacy/distinct.json | 276 - .../spec/legacy/explain.json | 239 - .../spec/legacy/find.json | 408 - .../spec/legacy/findOneAndDelete.json | 221 - .../spec/legacy/findOneAndReplace.json | 227 - .../spec/legacy/findOneAndUpdate.json | 231 - .../legacy/fle2v2-BypassQueryAnalysis.json | 261 - .../spec/legacy/fle2v2-Compact.json | 233 - .../fle2v2-CreateCollection-OldServer.json | 94 - .../spec/legacy/fle2v2-CreateCollection.json | 1758 --- .../legacy/fle2v2-DecryptExistingData.json | 149 - .../spec/legacy/fle2v2-Delete.json | 284 - ...EncryptedFields-vs-EncryptedFieldsMap.json | 212 - .../fle2v2-EncryptedFields-vs-jsonSchema.json | 300 - .../fle2v2-EncryptedFieldsMap-defaults.json | 105 - .../spec/legacy/fle2v2-FindOneAndUpdate.json | 560 - .../legacy/fle2v2-InsertFind-Indexed.json | 296 - .../legacy/fle2v2-InsertFind-Unindexed.json | 248 - .../spec/legacy/fle2v2-MissingKey.json | 116 - .../spec/legacy/fle2v2-NoEncryption.json | 87 - .../spec/legacy/fle2v2-Rangev2-Compact.json | 289 - .../legacy/fle2v2-Rangev2-Date-Aggregate.json | 508 - .../fle2v2-Rangev2-Date-Correctness.json | 1842 --- .../legacy/fle2v2-Rangev2-Date-Delete.json | 442 - .../fle2v2-Rangev2-Date-FindOneAndUpdate.json | 514 - .../fle2v2-Rangev2-Date-InsertFind.json | 499 - .../legacy/fle2v2-Rangev2-Date-Update.json | 516 - .../fle2v2-Rangev2-Decimal-Aggregate.json | 1902 --- .../fle2v2-Rangev2-Decimal-Correctness.json | 1158 -- .../legacy/fle2v2-Rangev2-Decimal-Delete.json | 1116 -- ...e2v2-Rangev2-Decimal-FindOneAndUpdate.json | 1906 --- .../fle2v2-Rangev2-Decimal-InsertFind.json | 1893 --- .../legacy/fle2v2-Rangev2-Decimal-Update.json | 1910 --- ...v2-Rangev2-DecimalPrecision-Aggregate.json | 584 - ...-Rangev2-DecimalPrecision-Correctness.json | 1650 --- ...le2v2-Rangev2-DecimalPrecision-Delete.json | 476 - ...ev2-DecimalPrecision-FindOneAndUpdate.json | 588 - ...2-Rangev2-DecimalPrecision-InsertFind.json | 571 - ...le2v2-Rangev2-DecimalPrecision-Update.json | 588 - .../spec/legacy/fle2v2-Rangev2-Defaults.json | 381 - .../fle2v2-Rangev2-Double-Aggregate.json | 1132 -- .../fle2v2-Rangev2-Double-Correctness.json | 1160 -- .../legacy/fle2v2-Rangev2-Double-Delete.json | 732 -- ...le2v2-Rangev2-Double-FindOneAndUpdate.json | 1136 -- .../fle2v2-Rangev2-Double-InsertFind.json | 1123 -- .../legacy/fle2v2-Rangev2-Double-Update.json | 1140 -- ...2v2-Rangev2-DoublePrecision-Aggregate.json | 580 - ...2-Rangev2-DoublePrecision-Correctness.json | 1650 --- ...fle2v2-Rangev2-DoublePrecision-Delete.json | 474 - ...gev2-DoublePrecision-FindOneAndUpdate.json | 584 - ...v2-Rangev2-DoublePrecision-InsertFind.json | 571 - ...fle2v2-Rangev2-DoublePrecision-Update.json | 588 - .../legacy/fle2v2-Rangev2-Int-Aggregate.json | 484 - .../fle2v2-Rangev2-Int-Correctness.json | 1644 --- .../legacy/fle2v2-Rangev2-Int-Delete.json | 420 - .../fle2v2-Rangev2-Int-FindOneAndUpdate.json | 488 - .../legacy/fle2v2-Rangev2-Int-InsertFind.json | 475 - .../legacy/fle2v2-Rangev2-Int-Update.json | 492 - .../legacy/fle2v2-Rangev2-Long-Aggregate.json | 484 - .../fle2v2-Rangev2-Long-Correctness.json | 1644 --- .../legacy/fle2v2-Rangev2-Long-Delete.json | 420 - .../fle2v2-Rangev2-Long-FindOneAndUpdate.json | 488 - .../fle2v2-Rangev2-Long-InsertFind.json | 475 - .../legacy/fle2v2-Rangev2-Long-Update.json | 492 - .../spec/legacy/fle2v2-Rangev2-WrongType.json | 163 - .../spec/legacy/fle2v2-Update.json | 570 - ...v2-validatorAndPartialFieldExpression.json | 503 - .../spec/legacy/gcpKMS.json | 237 - .../spec/legacy/getMore.json | 266 - .../spec/legacy/insert.json | 344 - .../spec/legacy/keyAltName.json | 228 - .../spec/legacy/keyCache.json | 270 - .../spec/legacy/kmipKMS.json | 362 - .../spec/legacy/localKMS.json | 191 - .../spec/legacy/localSchema.json | 258 - .../spec/legacy/malformedCiphertext.json | 321 - .../spec/legacy/missingKey.json | 179 - .../spec/legacy/namedKMS.json | 197 - .../spec/legacy/noSchema.json | 67 - .../spec/legacy/replaceOne.json | 239 - .../spec/legacy/timeoutMS.json | 200 - .../spec/legacy/types.json | 1646 --- .../spec/legacy/unsupportedCommand.json | 152 - .../spec/legacy/updateMany.json | 307 - .../spec/legacy/updateOne.json | 465 - .../validatorAndPartialFieldExpression.json | 642 - ...-Text-cleanupStructuredEncryptionData.json | 219 - ...-Text-compactStructuredEncryptionData.json | 261 - .../spec/unified/QE-Text-prefix.json | 338 - .../spec/unified/QE-Text-substring.json | 467 - .../spec/unified/QE-Text-suffix.json | 338 - .../spec/unified/addKeyAltName.json | 609 - .../spec/unified/aggregate.json | 433 - .../spec/unified/awsTemporary.json | 313 - .../spec/unified/azureKMS.json | 293 - .../spec/unified/badQueries.json | 1393 --- .../spec/unified/badSchema.json | 393 - .../spec/unified/basic.json | 431 - .../spec/unified/bulk.json | 407 - .../spec/unified/bypassAutoEncryption.json | 403 - .../spec/unified/bypassedCommand.json | 147 - .../spec/unified/count.json | 293 - .../spec/unified/countDocuments.json | 296 - .../unified/create-and-createIndexes.json | 121 - .../createDataKey-kms_providers-invalid.json | 119 - .../spec/unified/createDataKey.json | 775 -- .../spec/unified/delete.json | 396 - .../spec/unified/deleteKey.json | 557 - .../spec/unified/distinct.json | 325 - .../spec/unified/explain.json | 293 - .../spec/unified/find.json | 458 - .../spec/unified/findOneAndDelete.json | 276 - .../spec/unified/findOneAndReplace.json | 282 - .../spec/unified/findOneAndUpdate.json | 286 - .../unified/fle2v2-BypassQueryAnalysis.json | 324 - .../spec/unified/fle2v2-Compact.json | 312 - .../fle2v2-CreateCollection-OldServer.json | 127 - .../spec/unified/fle2v2-CreateCollection.json | 1748 --- .../unified/fle2v2-DecryptExistingData.json | 186 - .../spec/unified/fle2v2-Delete.json | 326 - ...EncryptedFields-vs-EncryptedFieldsMap.json | 258 - .../fle2v2-EncryptedFields-vs-jsonSchema.json | 367 - .../fle2v2-EncryptedFieldsMap-defaults.json | 139 - .../spec/unified/fle2v2-FindOneAndUpdate.json | 622 - .../unified/fle2v2-InsertFind-Indexed.json | 361 - .../unified/fle2v2-InsertFind-Unindexed.json | 301 - .../unified/fle2v2-InsertFind-keyAltName.json | 485 - .../spec/unified/fle2v2-MissingKey.json | 137 - .../spec/unified/fle2v2-NoEncryption.json | 123 - .../spec/unified/fle2v2-Rangev2-Compact.json | 358 - .../fle2v2-Rangev2-Date-Aggregate.json | 574 - .../fle2v2-Rangev2-Date-Correctness.json | 1610 --- .../unified/fle2v2-Rangev2-Date-Delete.json | 505 - .../fle2v2-Rangev2-Date-FindOneAndUpdate.json | 577 - .../fle2v2-Rangev2-Date-InsertFind.json | 562 - .../unified/fle2v2-Rangev2-Date-Update.json | 581 - .../fle2v2-Rangev2-Decimal-Aggregate.json | 1965 --- .../fle2v2-Rangev2-Decimal-Correctness.json | 1016 -- .../fle2v2-Rangev2-Decimal-Delete.json | 1179 -- ...e2v2-Rangev2-Decimal-FindOneAndUpdate.json | 1969 --- .../fle2v2-Rangev2-Decimal-InsertFind.json | 1956 --- .../fle2v2-Rangev2-Decimal-Update.json | 1975 --- ...v2-Rangev2-DecimalPrecision-Aggregate.json | 647 - ...-Rangev2-DecimalPrecision-Correctness.json | 1418 --- ...le2v2-Rangev2-DecimalPrecision-Delete.json | 539 - ...ev2-DecimalPrecision-FindOneAndUpdate.json | 651 - ...2-Rangev2-DecimalPrecision-InsertFind.json | 634 - ...le2v2-Rangev2-DecimalPrecision-Update.json | 653 - .../spec/unified/fle2v2-Rangev2-Defaults.json | 444 - .../fle2v2-Rangev2-Double-Aggregate.json | 1195 -- .../fle2v2-Rangev2-Double-Correctness.json | 1018 -- .../unified/fle2v2-Rangev2-Double-Delete.json | 795 -- ...le2v2-Rangev2-Double-FindOneAndUpdate.json | 1199 -- .../fle2v2-Rangev2-Double-InsertFind.json | 1186 -- .../unified/fle2v2-Rangev2-Double-Update.json | 1205 -- ...2v2-Rangev2-DoublePrecision-Aggregate.json | 643 - ...2-Rangev2-DoublePrecision-Correctness.json | 1418 --- ...fle2v2-Rangev2-DoublePrecision-Delete.json | 537 - ...gev2-DoublePrecision-FindOneAndUpdate.json | 647 - ...v2-Rangev2-DoublePrecision-InsertFind.json | 634 - ...fle2v2-Rangev2-DoublePrecision-Update.json | 653 - .../unified/fle2v2-Rangev2-Int-Aggregate.json | 547 - .../fle2v2-Rangev2-Int-Correctness.json | 1412 --- .../unified/fle2v2-Rangev2-Int-Delete.json | 483 - .../fle2v2-Rangev2-Int-FindOneAndUpdate.json | 551 - .../fle2v2-Rangev2-Int-InsertFind.json | 538 - .../unified/fle2v2-Rangev2-Int-Update.json | 557 - .../fle2v2-Rangev2-Long-Aggregate.json | 547 - .../fle2v2-Rangev2-Long-Correctness.json | 1412 --- .../unified/fle2v2-Rangev2-Long-Delete.json | 483 - .../fle2v2-Rangev2-Long-FindOneAndUpdate.json | 551 - .../fle2v2-Rangev2-Long-InsertFind.json | 538 - .../unified/fle2v2-Rangev2-Long-Update.json | 557 - .../unified/fle2v2-Rangev2-WrongType.json | 204 - .../spec/unified/fle2v2-Update.json | 633 - ...v2-validatorAndPartialFieldExpression.json | 304 - .../spec/unified/gcpKMS.json | 292 - .../spec/unified/getKey.json | 319 - .../spec/unified/getKeyByAltName.json | 289 - .../spec/unified/getKeys.json | 260 - .../spec/unified/getMore.json | 321 - .../spec/unified/insert.json | 421 - .../spec/unified/keyAltName.json | 299 - .../spec/unified/keyCache.json | 198 - .../spec/unified/kmipKMS.json | 415 - .../spec/unified/localKMS.json | 261 - .../spec/unified/localSchema.json | 337 - .../spec/unified/malformedCiphertext.json | 241 - .../spec/unified/missingKey.json | 233 - .../spec/unified/namedKMS-createDataKey.json | 396 - .../spec/unified/namedKMS-explicit.json | 130 - .../unified/namedKMS-rewrapManyDataKey.json | 1385 --- .../spec/unified/namedKMS.json | 241 - .../spec/unified/noSchema.json | 115 - .../spec/unified/removeKeyAltName.json | 672 - .../spec/unified/replaceOne.json | 316 - .../rewrapManyDataKey-decrypt_failure.json | 162 - .../rewrapManyDataKey-encrypt_failure.json | 250 - .../spec/unified/rewrapManyDataKey.json | 1922 --- .../spec/unified/timeoutMS.json | 270 - .../spec/unified/types.json | 2262 ---- .../spec/unified/unsupportedCommand.json | 200 - .../spec/unified/updateMany.json | 376 - .../spec/unified/updateOne.json | 538 - .../validatorAndPartialFieldExpression.json | 323 - .../clustered-indexes.json | 291 - .../createCollection-pre_and_post_images.json | 92 - .../timeseries-collection.json | 320 - test/command_logging/command.json | 543 - .../command_logging/driver-connection-id.json | 146 - .../no-handshake-messages.json | 94 - .../no-heartbeat-messages.json | 91 - test/command_logging/operation-id.json | 198 - test/command_logging/redacted-commands.json | 1063 -- .../command_logging/server-connection-id.json | 131 - test/command_logging/service-id.json | 207 - .../command_logging/unacknowledged-write.json | 151 - test/command_monitoring/bulkWrite.json | 154 - test/command_monitoring/command.json | 83 - test/command_monitoring/deleteMany.json | 162 - test/command_monitoring/deleteOne.json | 162 - test/command_monitoring/find.json | 558 - test/command_monitoring/insertMany.json | 148 - test/command_monitoring/insertOne.json | 144 - .../command_monitoring/redacted-commands.json | 559 - .../server-connection-id.json | 101 - .../unacknowledged-client-bulkWrite.json | 225 - .../unacknowledgedBulkWrite.json | 117 - test/command_monitoring/updateMany.json | 188 - test/command_monitoring/updateOne.json | 260 - .../command_monitoring/writeConcernError.json | 155 - test/conftest.py | 26 - .../connection-logging.json | 523 - .../connection-pool-options.json | 302 - .../connection-must-have-id.json | 52 - .../connection-must-order-ids.json | 52 - .../pool-checkin-destroy-closed.json | 50 - .../pool-checkin-destroy-stale.json | 50 - .../pool-checkin-make-available.json | 47 - test/connection_monitoring/pool-checkin.json | 34 - .../pool-checkout-connection.json | 40 - ...kout-custom-maxConnecting-is-enforced.json | 83 - .../pool-checkout-error-closed.json | 70 - ...ol-checkout-maxConnecting-is-enforced.json | 110 - .../pool-checkout-maxConnecting-timeout.json | 106 - ...-minPoolSize-connection-maxConnecting.json | 90 - .../pool-checkout-multiple.json | 70 - .../pool-checkout-no-idle.json | 68 - .../pool-checkout-no-stale.json | 73 - ...out-returned-connection-maxConnecting.json | 118 - .../pool-clear-clears-waitqueue.json | 105 - ...lear-interrupting-pending-connections.json | 79 - .../pool-clear-min-size.json | 68 - .../pool-clear-paused.json | 32 - .../pool-clear-ready.json | 72 - ...e-run-interruptInUseConnections-false.json | 81 - .../pool-close-destroy-conns.json | 52 - test/connection_monitoring/pool-close.json | 21 - .../pool-create-max-size.json | 133 - .../pool-create-min-size-error.json | 66 - .../pool-create-min-size.json | 66 - .../pool-create-with-options.json | 32 - test/connection_monitoring/pool-create.json | 19 - .../pool-ready-ready.json | 39 - test/connection_monitoring/pool-ready.json | 59 - .../wait-queue-timeout.json | 77 - test/connection_string/test/invalid-uris.json | 283 - test/connection_string/test/valid-auth.json | 312 - .../test/valid-db-with-dotted-name.json | 100 - .../test/valid-host_identifiers.json | 154 - .../connection_string/test/valid-options.json | 62 - .../test/valid-unix_socket-absolute.json | 266 - .../test/valid-unix_socket-relative.json | 286 - .../test/valid-warnings.json | 115 - test/crud/unified/aggregate-allowdiskuse.json | 155 - test/crud/unified/aggregate-collation.json | 73 - test/crud/unified/aggregate-let.json | 376 - .../aggregate-merge-errorResponse.json | 90 - test/crud/unified/aggregate-merge.json | 497 - .../unified/aggregate-out-readConcern.json | 407 - test/crud/unified/aggregate-out.json | 143 - .../aggregate-write-readPreference.json | 391 - test/crud/unified/aggregate.json | 615 - test/crud/unified/bulkWrite-arrayFilters.json | 364 - test/crud/unified/bulkWrite-collation.json | 254 - test/crud/unified/bulkWrite-comment.json | 519 - .../bulkWrite-delete-hint-serverError.json | 252 - test/crud/unified/bulkWrite-delete-hint.json | 247 - ...kWrite-deleteMany-hint-unacknowledged.json | 269 - .../unified/bulkWrite-deleteMany-let.json | 200 - ...lkWrite-deleteOne-hint-unacknowledged.json | 265 - .../crud/unified/bulkWrite-deleteOne-let.json | 200 - .../crud/unified/bulkWrite-errorResponse.json | 88 - .../bulkWrite-insertOne-dots_and_dollars.json | 374 - ...bulkWrite-replaceOne-dots_and_dollars.json | 380 - ...kWrite-replaceOne-hint-unacknowledged.json | 211 - .../unified/bulkWrite-replaceOne-let.json | 226 - .../unified/bulkWrite-replaceOne-sort.json | 239 - test/crud/unified/bulkWrite-update-hint.json | 445 - .../unified/bulkWrite-update-validation.json | 210 - ...bulkWrite-updateMany-dots_and_dollars.json | 452 - ...kWrite-updateMany-hint-unacknowledged.json | 219 - .../unified/bulkWrite-updateMany-let.json | 243 - .../bulkWrite-updateMany-pipeline.json | 148 - .../bulkWrite-updateOne-dots_and_dollars.json | 460 - ...lkWrite-updateOne-hint-unacknowledged.json | 219 - .../crud/unified/bulkWrite-updateOne-let.json | 247 - .../unified/bulkWrite-updateOne-pipeline.json | 156 - .../unified/bulkWrite-updateOne-sort.json | 255 - test/crud/unified/bulkWrite.json | 829 -- .../unified/bypassDocumentValidation.json | 493 - .../client-bulkWrite-delete-options.json | 268 - .../client-bulkWrite-errorResponse.json | 69 - .../crud/unified/client-bulkWrite-errors.json | 513 - .../client-bulkWrite-mixed-namespaces.json | 315 - .../unified/client-bulkWrite-options.json | 716 -- .../unified/client-bulkWrite-ordered.json | 291 - .../client-bulkWrite-partialResults.json | 540 - .../client-bulkWrite-replaceOne-sort.json | 163 - .../unified/client-bulkWrite-results.json | 833 -- .../client-bulkWrite-update-options.json | 949 -- .../client-bulkWrite-update-pipeline.json | 258 - .../client-bulkWrite-update-validation.json | 216 - .../client-bulkWrite-updateOne-sort.json | 167 - test/crud/unified/count-collation.json | 83 - test/crud/unified/count-empty.json | 71 - test/crud/unified/count.json | 148 - test/crud/unified/countDocuments-comment.json | 208 - test/crud/unified/create-null-ids.json | 253 - .../db-aggregate-write-readPreference.json | 395 - test/crud/unified/db-aggregate.json | 107 - test/crud/unified/deleteMany-collation.json | 86 - test/crud/unified/deleteMany-comment.json | 245 - .../unified/deleteMany-hint-serverError.json | 190 - .../deleteMany-hint-unacknowledged.json | 245 - test/crud/unified/deleteMany-hint.json | 173 - test/crud/unified/deleteMany-let.json | 201 - test/crud/unified/deleteMany.json | 115 - test/crud/unified/deleteOne-collation.json | 90 - test/crud/unified/deleteOne-comment.json | 243 - .../crud/unified/deleteOne-errorResponse.json | 82 - .../unified/deleteOne-hint-serverError.json | 170 - .../deleteOne-hint-unacknowledged.json | 241 - test/crud/unified/deleteOne-hint.json | 161 - test/crud/unified/deleteOne-let.json | 191 - test/crud/unified/deleteOne.json | 136 - test/crud/unified/distinct-collation.json | 69 - test/crud/unified/distinct-comment.json | 186 - test/crud/unified/distinct-hint.json | 139 - test/crud/unified/distinct.json | 86 - .../estimatedDocumentCount-comment.json | 170 - test/crud/unified/estimatedDocumentCount.json | 357 - .../find-allowdiskuse-serverError.json | 100 - test/crud/unified/find-allowdiskuse.json | 120 - test/crud/unified/find-collation.json | 69 - test/crud/unified/find-comment.json | 403 - test/crud/unified/find-let.json | 148 - test/crud/unified/find.json | 304 - test/crud/unified/findOne.json | 158 - .../unified/findOneAndDelete-collation.json | 98 - .../unified/findOneAndDelete-comment.json | 211 - .../findOneAndDelete-hint-serverError.json | 162 - .../findOneAndDelete-hint-unacknowledged.json | 225 - test/crud/unified/findOneAndDelete-hint.json | 155 - test/crud/unified/findOneAndDelete-let.json | 180 - test/crud/unified/findOneAndDelete.json | 171 - .../unified/findOneAndReplace-collation.json | 97 - .../unified/findOneAndReplace-comment.json | 234 - .../findOneAndReplace-dots_and_dollars.json | 304 - .../findOneAndReplace-hint-serverError.json | 172 - ...findOneAndReplace-hint-unacknowledged.json | 248 - test/crud/unified/findOneAndReplace-hint.json | 173 - test/crud/unified/findOneAndReplace-let.json | 197 - .../unified/findOneAndReplace-upsert.json | 254 - test/crud/unified/findOneAndReplace.json | 332 - .../findOneAndUpdate-arrayFilters.json | 251 - .../unified/findOneAndUpdate-collation.json | 106 - .../unified/findOneAndUpdate-comment.json | 228 - .../findOneAndUpdate-dots_and_dollars.json | 380 - .../findOneAndUpdate-errorResponse.json | 132 - .../findOneAndUpdate-hint-serverError.json | 180 - .../findOneAndUpdate-hint-unacknowledged.json | 253 - test/crud/unified/findOneAndUpdate-hint.json | 181 - test/crud/unified/findOneAndUpdate-let.json | 217 - .../unified/findOneAndUpdate-pipeline.json | 130 - test/crud/unified/findOneAndUpdate.json | 448 - test/crud/unified/insertMany-comment.json | 226 - .../unified/insertMany-dots_and_dollars.json | 338 - test/crud/unified/insertMany.json | 205 - test/crud/unified/insertOne-comment.json | 220 - .../unified/insertOne-dots_and_dollars.json | 562 - .../crud/unified/insertOne-errorResponse.json | 82 - test/crud/unified/insertOne.json | 77 - test/crud/unified/replaceOne-collation.json | 92 - test/crud/unified/replaceOne-comment.json | 248 - .../unified/replaceOne-dots_and_dollars.json | 427 - .../replaceOne-hint-unacknowledged.json | 199 - test/crud/unified/replaceOne-hint.json | 203 - test/crud/unified/replaceOne-let.json | 219 - test/crud/unified/replaceOne-sort.json | 232 - test/crud/unified/replaceOne-validation.json | 82 - test/crud/unified/replaceOne.json | 259 - .../crud/unified/updateMany-arrayFilters.json | 233 - test/crud/unified/updateMany-collation.json | 101 - test/crud/unified/updateMany-comment.json | 254 - .../unified/updateMany-dots_and_dollars.json | 404 - .../updateMany-hint-unacknowledged.json | 207 - test/crud/unified/updateMany-hint.json | 219 - test/crud/unified/updateMany-let.json | 249 - test/crud/unified/updateMany-pipeline.json | 142 - test/crud/unified/updateMany-validation.json | 98 - test/crud/unified/updateMany.json | 236 - test/crud/unified/updateOne-arrayFilters.json | 453 - test/crud/unified/updateOne-collation.json | 93 - test/crud/unified/updateOne-comment.json | 260 - .../unified/updateOne-dots_and_dollars.json | 412 - .../crud/unified/updateOne-errorResponse.json | 87 - .../updateOne-hint-unacknowledged.json | 207 - test/crud/unified/updateOne-hint.json | 211 - test/crud/unified/updateOne-let.json | 227 - test/crud/unified/updateOne-pipeline.json | 150 - test/crud/unified/updateOne-sort.json | 240 - test/crud/unified/updateOne-validation.json | 80 - test/crud/unified/updateOne.json | 216 - test/csot/bulkWrite.json | 160 - test/csot/change-streams.json | 613 - test/csot/close-cursors.json | 239 - test/csot/command-execution.json | 399 - test/csot/convenient-transactions.json | 316 - test/csot/cursors.json | 113 - test/csot/deprecated-options.json | 7222 ----------- test/csot/error-transformations.json | 182 - test/csot/global-timeoutMS.json | 5906 --------- test/csot/gridfs-advanced.json | 385 - test/csot/gridfs-delete.json | 285 - test/csot/gridfs-download.json | 359 - test/csot/gridfs-find.json | 183 - test/csot/gridfs-upload.json | 409 - test/csot/legacy-timeouts.json | 379 - test/csot/non-tailable-cursors.json | 543 - test/csot/override-operation-timeoutMS.json | 3650 ------ test/csot/retryability-legacy-timeouts.json | 3087 ----- test/csot/retryability-timeoutMS.json | 5720 --------- test/csot/runCursorCommand.json | 587 - test/csot/sessions-inherit-timeoutMS.json | 334 - ...sessions-override-operation-timeoutMS.json | 336 - test/csot/sessions-override-timeoutMS.json | 332 - test/csot/tailable-awaitData.json | 632 - test/csot/tailable-non-awaitData.json | 312 - test/csot/waitQueueTimeout.json | 176 - test/data_lake/unified/aggregate.json | 84 - .../unified/estimatedDocumentCount.json | 56 - test/data_lake/unified/find.json | 96 - test/data_lake/unified/getMore.json | 95 - test/data_lake/unified/listCollections.json | 48 - test/data_lake/unified/listDatabases.json | 41 - test/data_lake/unified/runCommand.json | 54 - .../errors/error_handling_handshake.json | 121 - .../errors/non-stale-network-error.json | 80 - .../non-stale-network-timeout-error.json | 88 - ...Version-greater-InterruptedAtShutdown.json | 100 - ...eater-InterruptedDueToReplStateChange.json | 100 - ...ologyVersion-greater-LegacyNotPrimary.json | 100 - ...rsion-greater-NotPrimaryNoSecondaryOk.json | 100 - ...Version-greater-NotPrimaryOrSecondary.json | 100 - ...ogyVersion-greater-NotWritablePrimary.json | 100 - ...ogyVersion-greater-PrimarySteppedDown.json | 100 - ...ogyVersion-greater-ShutdownInProgress.json | 100 - ...Version-missing-InterruptedAtShutdown.json | 85 - ...ssing-InterruptedDueToReplStateChange.json | 85 - ...ologyVersion-missing-LegacyNotPrimary.json | 85 - ...rsion-missing-NotPrimaryNoSecondaryOk.json | 85 - ...Version-missing-NotPrimaryOrSecondary.json | 85 - ...ogyVersion-missing-NotWritablePrimary.json | 85 - ...ogyVersion-missing-PrimarySteppedDown.json | 85 - ...ogyVersion-missing-ShutdownInProgress.json | 85 - ...ccessId-changed-InterruptedAtShutdown.json | 100 - ...anged-InterruptedDueToReplStateChange.json | 100 - ...n-proccessId-changed-LegacyNotPrimary.json | 100 - ...essId-changed-NotPrimaryNoSecondaryOk.json | 100 - ...ccessId-changed-NotPrimaryOrSecondary.json | 100 - ...proccessId-changed-NotWritablePrimary.json | 100 - ...proccessId-changed-PrimarySteppedDown.json | 100 - ...proccessId-changed-ShutdownInProgress.json | 100 - .../errors/post-42-InterruptedAtShutdown.json | 70 - ...st-42-InterruptedDueToReplStateChange.json | 70 - .../errors/post-42-LegacyNotPrimary.json | 70 - .../post-42-NotPrimaryNoSecondaryOk.json | 70 - .../errors/post-42-NotPrimaryOrSecondary.json | 70 - .../errors/post-42-NotWritablePrimary.json | 70 - .../errors/post-42-PrimarySteppedDown.json | 70 - .../errors/post-42-ShutdownInProgress.json | 70 - .../errors/prefer-error-code.json | 131 - ...tale-generation-InterruptedAtShutdown.json | 176 - ...ation-InterruptedDueToReplStateChange.json | 176 - ...le-generation-NotPrimaryNoSecondaryOk.json | 176 - ...tale-generation-NotPrimaryOrSecondary.json | 176 - .../stale-generation-NotWritablePrimary.json | 176 - .../stale-generation-PrimarySteppedDown.json | 176 - .../stale-generation-ShutdownInProgress.json | 176 - ...dshakeCompletes-InterruptedAtShutdown.json | 176 - ...letes-InterruptedDueToReplStateChange.json | 176 - ...erHandshakeCompletes-LegacyNotPrimary.json | 176 - ...hakeCompletes-NotPrimaryNoSecondaryOk.json | 176 - ...dshakeCompletes-NotPrimaryOrSecondary.json | 176 - ...HandshakeCompletes-NotWritablePrimary.json | 176 - ...HandshakeCompletes-PrimarySteppedDown.json | 176 - ...HandshakeCompletes-ShutdownInProgress.json | 176 - ...ation-afterHandshakeCompletes-network.json | 163 - ...ation-afterHandshakeCompletes-timeout.json | 163 - ...dshakeCompletes-InterruptedAtShutdown.json | 176 - ...letes-InterruptedDueToReplStateChange.json | 176 - ...reHandshakeCompletes-LegacyNotPrimary.json | 176 - ...hakeCompletes-NotPrimaryNoSecondaryOk.json | 176 - ...dshakeCompletes-NotPrimaryOrSecondary.json | 176 - ...HandshakeCompletes-NotWritablePrimary.json | 176 - ...HandshakeCompletes-PrimarySteppedDown.json | 176 - ...HandshakeCompletes-ShutdownInProgress.json | 176 - ...tion-beforeHandshakeCompletes-network.json | 163 - ...tion-beforeHandshakeCompletes-timeout.json | 163 - ...topologyVersion-InterruptedAtShutdown.json | 147 - ...rsion-InterruptedDueToReplStateChange.json | 147 - ...tale-topologyVersion-LegacyNotPrimary.json | 147 - ...pologyVersion-NotPrimaryNoSecondaryOk.json | 147 - ...topologyVersion-NotPrimaryOrSecondary.json | 147 - ...le-topologyVersion-NotWritablePrimary.json | 147 - ...le-topologyVersion-PrimarySteppedDown.json | 147 - ...le-topologyVersion-ShutdownInProgress.json | 147 - .../errors/write_errors_ignored.json | 98 - .../load-balanced/discover_load_balancer.json | 28 - .../rs/compatible.json | 57 - .../rs/compatible_unknown.json | 40 - .../rs/disaggregated_storage_setversion.json | 167 - .../rs/discover_arbiters.json | 42 - .../rs/discover_arbiters_replicaset.json | 42 - .../rs/discover_ghost.json | 32 - .../rs/discover_ghost_replicaset.json | 36 - .../rs/discover_hidden.json | 46 - .../rs/discover_hidden_replicaset.json | 46 - .../rs/discover_passives.json | 80 - .../rs/discover_passives_replicaset.json | 80 - .../rs/discover_primary.json | 40 - .../rs/discover_primary_replicaset.json | 40 - .../rs/discover_rsother.json | 45 - .../rs/discover_rsother_replicaset.json | 66 - .../rs/discover_secondary.json | 41 - .../rs/discover_secondary_replicaset.json | 41 - .../rs/discovery.json | 179 - .../rs/electionId_precedence_setVersion.json | 92 - .../rs/equal_electionids.json | 73 - .../rs/hosts_differ_from_seeds.json | 35 - .../rs/incompatible_arbiter.json | 56 - .../rs/incompatible_ghost.json | 51 - .../rs/incompatible_other.json | 56 - .../rs/ls_timeout.json | 279 - ...h_unchanged_setversion_and_electionid.json | 227 - .../rs/member_reconfig.json | 69 - .../rs/member_standalone.json | 60 - .../migration_from_disaggregated_storage.json | 167 - .../migration_to_disaggregated_storage.json | 119 - .../rs/new_primary.json | 75 - .../rs/new_primary_new_electionid.json | 149 - .../rs/new_primary_new_setversion.json | 149 - .../rs/new_primary_wrong_set_name.json | 69 - .../rs/non_rs_member.json | 30 - .../rs/normalize_case.json | 49 - .../rs/normalize_case_me.json | 95 - .../rs/null_election_id-pre-6.0.json | 203 - .../rs/null_election_id.json | 209 - .../rs/primary_becomes_ghost.json | 61 - .../rs/primary_becomes_mongos.json | 56 - .../rs/primary_becomes_standalone.json | 53 - .../rs/primary_changes_set_name.json | 59 - .../rs/primary_disconnect.json | 54 - .../rs/primary_disconnect_electionid.json | 237 - .../rs/primary_disconnect_setversion.json | 237 - ...int_from_secondary_with_mismatched_me.json | 68 - .../rs/primary_mismatched_me.json | 41 - .../rs/primary_mismatched_me_not_removed.json | 79 - .../rs/primary_reports_new_member.json | 155 - .../primary_to_no_primary_mismatched_me.json | 76 - .../rs/primary_wrong_set_name.json | 30 - .../discovery_and_monitoring/rs/repeated.json | 144 - .../rs/replicaset_rsnp.json | 26 - .../rs/response_from_removed.json | 66 - .../rs/sec_not_auth.json | 56 - .../rs/secondary_ignore_ok_0-pre-6.0.json | 83 - .../rs/secondary_ignore_ok_0.json | 83 - .../rs/secondary_ipv6_literal.json | 38 - .../rs/secondary_mismatched_me.json | 41 - .../rs/secondary_wrong_set_name.json | 31 - ...secondary_wrong_set_name_with_primary.json | 71 - .../rs/set_version_can_rollback.json | 147 - ...tversion_equal_max_without_electionid.json | 84 - ...on_greaterthan_max_without_electionid.json | 85 - ...setversion_without_electionid-pre-6.0.json | 85 - .../rs/setversion_without_electionid.json | 84 - .../rs/stepdown_change_set_name.json | 60 - test/discovery_and_monitoring/rs/too_new.json | 57 - test/discovery_and_monitoring/rs/too_old.json | 57 - .../rs/topology_version_equal.json | 101 - .../rs/topology_version_greater.json | 259 - .../rs/topology_version_less.json | 97 - .../rs/unexpected_mongos.json | 27 - ...setversion_without_electionid-pre-6.0.json | 140 - .../rs/use_setversion_without_electionid.json | 146 - .../rs/wrong_set_name.json | 37 - .../sharded/compatible.json | 48 - .../sharded/discover_single_mongos.json | 31 - .../sharded/ls_timeout_mongos.json | 91 - .../sharded/mongos_disconnect.json | 100 - .../sharded/multiple_mongoses.json | 47 - .../sharded/non_mongos_removed.json | 46 - .../sharded/normalize_uri_case.json | 24 - .../sharded/too_new.json | 48 - .../sharded/too_old.json | 46 - .../single/compatible.json | 32 - .../single/direct_connection_external_ip.json | 35 - .../single/direct_connection_mongos.json | 32 - .../single/direct_connection_replicaset.json | 32 - .../single/direct_connection_rsarbiter.json | 37 - .../single/direct_connection_rsprimary.json | 36 - .../single/direct_connection_rssecondary.json | 37 - .../single/direct_connection_standalone.json | 31 - .../direct_connection_unavailable_seed.json | 25 - .../direct_connection_wrong_set_name.json | 65 - .../single/discover_standalone.json | 31 - .../single/discover_unavailable_seed.json | 25 - .../single/ls_timeout_standalone.json | 32 - .../single/not_ok_response.json | 41 - .../single/standalone_removed.json | 31 - .../single/standalone_using_legacy_hello.json | 30 - .../single/too_new.json | 32 - .../single/too_old.json | 30 - .../single/too_old_then_upgraded.json | 56 - .../unified/auth-error.json | 230 - .../unified/auth-misc-command-error.json | 230 - .../unified/auth-network-error.json | 230 - .../unified/auth-network-timeout-error.json | 233 - .../unified/auth-shutdown-error.json | 230 - .../unified/cancel-server-check.json | 201 - .../unified/connectTimeoutMS.json | 221 - .../unified/find-network-error.json | 234 - .../unified/find-network-timeout-error.json | 199 - .../unified/find-shutdown-error.json | 251 - .../unified/hello-command-error.json | 376 - .../unified/hello-network-error.json | 346 - .../unified/hello-timeout.json | 514 - .../unified/insert-network-error.json | 246 - .../unified/insert-shutdown-error.json | 250 - .../unified/interruptInUse-pool-clear.json | 591 - ...ed-emit-topology-changed-before-close.json | 88 - .../unified/logging-loadbalanced.json | 166 - .../unified/logging-replicaset.json | 610 - .../unified/logging-sharded.json | 494 - .../unified/logging-standalone.json | 519 - .../unified/minPoolSize-error.json | 178 - .../unified/pool-cleared-error.json | 373 - .../rediscover-quickly-after-step-down.json | 242 - ...et-emit-topology-changed-before-close.json | 89 - .../unified/serverMonitoringMode.json | 511 - ...ed-emit-topology-changed-before-close.json | 108 - ...ne-emit-topology-changed-before-close.json | 97 - test/gridfs/delete.json | 739 -- test/gridfs/deleteByName.json | 230 - test/gridfs/download.json | 540 - test/gridfs/downloadByName.json | 315 - test/gridfs/queries-use-eq.json | 528 - test/gridfs/rename.json | 179 - test/gridfs/renameByName.json | 313 - test/gridfs/upload-disableMD5.json | 172 - test/gridfs/upload.json | 547 - .../unified/metadata-not-propagated.json | 101 - test/helpers.py | 170 - test/helpers_shared.py | 271 - test/index_management/createSearchIndex.json | 136 - .../index_management/createSearchIndexes.json | 172 - test/index_management/dropSearchIndex.json | 74 - test/index_management/listSearchIndexes.json | 156 - .../searchIndexIgnoresReadWriteConcern.json | 252 - test/index_management/updateSearchIndex.json | 76 - test/lambda/README.md | 17 - test/lambda/build_internal.sh | 5 - test/lambda/events/event.json | 62 - test/lambda/mongodb/Makefile | 4 - test/lambda/mongodb/__init__.py | 0 test/lambda/mongodb/app.py | 169 - test/lambda/run.sh | 5 - test/lambda/template.yaml | 49 - test/load_balancer/cursors.json | 1271 -- test/load_balancer/event-monitoring.json | 184 - .../lb-connection-establishment.json | 58 - .../non-lb-connection-establishment.json | 92 - test/load_balancer/sdam-error-handling.json | 514 - test/load_balancer/server-selection.json | 82 - test/load_balancer/transactions.json | 1665 --- test/load_balancer/wait-queue-timeouts.json | 153 - .../DefaultNoMaxStaleness.json | 74 - .../ReplicaSetNoPrimary/LastUpdateTime.json | 88 - .../MaxStalenessTooSmall.json | 20 - .../ReplicaSetNoPrimary/Nearest.json | 88 - .../ReplicaSetNoPrimary/Nearest2.json | 88 - .../ReplicaSetNoPrimary/NoKnownServers.json | 21 - .../OneKnownTwoUnavailable.json | 60 - .../ReplicaSetNoPrimary/PrimaryPreferred.json | 64 - .../PrimaryPreferred_tags.json | 84 - .../ReplicaSetNoPrimary/Secondary.json | 111 - .../SecondaryPreferred.json | 63 - .../SecondaryPreferred_tags.json | 111 - .../ReplicaSetNoPrimary/ZeroMaxStaleness.json | 36 - .../DefaultNoMaxStaleness.json | 74 - .../ReplicaSetWithPrimary/LastUpdateTime.json | 88 - .../ReplicaSetWithPrimary/LongHeartbeat.json | 76 - .../ReplicaSetWithPrimary/LongHeartbeat2.json | 37 - .../MaxStalenessTooSmall.json | 37 - .../MaxStalenessWithModePrimary.json | 35 - .../ReplicaSetWithPrimary/Nearest.json | 88 - .../ReplicaSetWithPrimary/Nearest2.json | 88 - .../ReplicaSetWithPrimary/Nearest_tags.json | 84 - .../PrimaryPreferred.json | 64 - .../SecondaryPreferred.json | 63 - .../SecondaryPreferred_tags.json | 138 - .../SecondaryPreferred_tags2.json | 96 - .../ReplicaSetWithPrimary/Secondary_tags.json | 138 - .../Secondary_tags2.json | 96 - .../ZeroMaxStaleness.json | 36 - .../Sharded/SmallMaxStaleness.json | 76 - .../Single/SmallMaxStaleness.json | 52 - .../Unknown/SmallMaxStaleness.json | 19 - test/mockupdb/operations.py | 127 - test/mockupdb/test_auth_recovering_member.py | 65 - test/mockupdb/test_cluster_time.py | 161 - test/mockupdb/test_cursor.py | 101 - test/mockupdb/test_cursor_namespace.py | 159 - test/mockupdb/test_getmore_sharded.py | 77 - test/mockupdb/test_handshake.py | 325 - test/mockupdb/test_initial_ismaster.py | 60 - test/mockupdb/test_list_indexes.py | 60 - test/mockupdb/test_max_staleness.py | 75 - test/mockupdb/test_mixed_version_sharded.py | 101 - .../mockupdb/test_mongos_command_read_mode.py | 141 - .../test_network_disconnect_primary.py | 100 - test/mockupdb/test_op_msg.py | 335 - test/mockupdb/test_op_msg_read_preference.py | 208 - test/mockupdb/test_query_read_pref_sharded.py | 90 - test/mockupdb/test_reset_and_request_check.py | 171 - test/mockupdb/test_rsghost.py | 71 - test/mockupdb/test_slave_okay_rs.py | 101 - test/mockupdb/test_slave_okay_sharded.py | 111 - test/mockupdb/test_slave_okay_single.py | 108 - test/mockupdb/test_standalone_shard.py | 69 - test/mod_wsgi_test/README.rst | 120 - test/mod_wsgi_test/apache24ubuntu.conf | 47 - test/mod_wsgi_test/httpd24fedora.conf | 58 - test/mod_wsgi_test/mod_wsgi_test.conf | 30 - test/mod_wsgi_test/mod_wsgi_test.py | 114 - .../mod_wsgi_test/mod_wsgi_test_embedded.conf | 28 - test/mod_wsgi_test/test_client.py | 183 - test/mypy_fails/insert_many_dict.py | 8 - test/mypy_fails/insert_one_list.py | 8 - test/mypy_fails/raw_bson_document.py | 15 - test/mypy_fails/typedict_client.py | 20 - test/performance/async_perf_test.py | 495 - test/performance/perf_test.py | 728 -- test/pymongo_mocks.py | 252 - test/pytest_conf.py | 15 - test/qcheck.py | 255 - .../connection-string/read-concern.json | 47 - .../connection-string/write-concern.json | 118 - .../document/read-concern.json | 66 - .../document/write-concern.json | 174 - .../operation/default-write-concern-2.6.json | 636 - .../operation/default-write-concern-3.2.json | 164 - .../operation/default-write-concern-3.4.json | 278 - .../operation/default-write-concern-4.2.json | 125 - .../write-concern-errors/aggregate.json | 135 - .../write-concern-errors/bulkWrite.json | 74 - .../client-bulkWrite.json | 70 - .../client-side-encryption.json | 284 - .../write-concern-errors/crud.json | 322 - .../db-coll-management.json | 201 - .../write-concern-errors/findAndModify.json | 156 - .../write-concern-errors/gridfs.json | 291 - .../index-management.json | 161 - .../write-concern-errors/mapReduce.json | 90 - .../unified/aggregate-merge.json | 143 - .../unified/aggregate-serverErrors.json | 1430 --- test/retryable_reads/unified/aggregate.json | 527 - ...angeStreams-client.watch-serverErrors.json | 959 -- .../unified/changeStreams-client.watch.json | 294 - ...ngeStreams-db.coll.watch-serverErrors.json | 944 -- .../unified/changeStreams-db.coll.watch.json | 314 - .../changeStreams-db.watch-serverErrors.json | 930 -- .../unified/changeStreams-db.watch.json | 303 - .../unified/count-serverErrors.json | 808 -- test/retryable_reads/unified/count.json | 286 - .../unified/countDocuments-serverErrors.json | 1133 -- .../unified/countDocuments.json | 364 - .../unified/distinct-serverErrors.json | 1060 -- test/retryable_reads/unified/distinct.json | 352 - .../estimatedDocumentCount-serverErrors.json | 768 -- .../unified/estimatedDocumentCount.json | 273 - .../unified/exceededTimeLimit.json | 147 - .../unified/find-serverErrors.json | 1184 -- test/retryable_reads/unified/find.json | 498 - .../unified/findOne-serverErrors.json | 954 -- test/retryable_reads/unified/findOne.json | 330 - .../unified/gridfs-download-serverErrors.json | 1142 -- .../unified/gridfs-download.json | 379 - .../gridfs-downloadByName-serverErrors.json | 1016 -- .../unified/gridfs-downloadByName.json | 347 - .../unified/handshakeError.json | 3114 ----- .../listCollectionNames-serverErrors.json | 710 -- .../unified/listCollectionNames.json | 243 - .../listCollectionObjects-serverErrors.json | 710 -- .../unified/listCollectionObjects.json | 243 - .../unified/listCollections-serverErrors.json | 710 -- .../unified/listCollections.json | 243 - .../listDatabaseNames-serverErrors.json | 696 -- .../unified/listDatabaseNames.json | 229 - .../listDatabaseObjects-serverErrors.json | 696 -- .../unified/listDatabaseObjects.json | 229 - .../unified/listDatabases-serverErrors.json | 696 -- .../unified/listDatabases.json | 229 - .../unified/listIndexNames-serverErrors.json | 749 -- .../unified/listIndexNames.json | 263 - .../unified/listIndexes-serverErrors.json | 749 -- test/retryable_reads/unified/listIndexes.json | 263 - test/retryable_reads/unified/mapReduce.json | 284 - .../readConcernMajorityNotAvailableYet.json | 147 - .../unified/aggregate-out-merge.json | 149 - .../unified/bulkWrite-errorLabels.json | 416 - .../unified/bulkWrite-serverErrors.json | 285 - test/retryable_writes/unified/bulkWrite.json | 1083 -- .../client-bulkWrite-clientErrors.json | 351 - .../client-bulkWrite-serverErrors.json | 882 -- test/retryable_writes/unified/deleteMany.json | 96 - .../unified/deleteOne-errorLabels.json | 266 - .../unified/deleteOne-serverErrors.json | 114 - test/retryable_writes/unified/deleteOne.json | 218 - .../unified/findOneAndDelete-errorLabels.json | 289 - .../findOneAndDelete-serverErrors.json | 119 - .../unified/findOneAndDelete.json | 235 - .../findOneAndReplace-errorLabels.json | 301 - .../findOneAndReplace-serverErrors.json | 119 - .../unified/findOneAndReplace.json | 243 - .../unified/findOneAndUpdate-errorLabels.json | 305 - .../findOneAndUpdate-serverErrors.json | 120 - .../unified/findOneAndUpdate.json | 245 - .../unified/handshakeError.json | 2038 --- .../unified/insertMany-errorLabels.json | 335 - .../unified/insertMany-serverErrors.json | 114 - test/retryable_writes/unified/insertMany.json | 290 - .../unified/insertOne-errorLabels.json | 1127 -- .../insertOne-noWritesPerformedError.json | 90 - .../unified/insertOne-serverErrors.json | 864 -- test/retryable_writes/unified/insertOne.json | 245 - .../unified/replaceOne-errorLabels.json | 300 - .../unified/replaceOne-serverErrors.json | 118 - test/retryable_writes/unified/replaceOne.json | 242 - .../unified/unacknowledged-write-concern.json | 77 - test/retryable_writes/unified/updateMany.json | 112 - .../unified/updateOne-errorLabels.json | 304 - .../unified/updateOne-serverErrors.json | 119 - test/retryable_writes/unified/updateOne.json | 424 - test/run_command/unified/runCommand.json | 634 - .../run_command/unified/runCursorCommand.json | 877 -- .../discovered_standalone.json | 105 - test/sdam_monitoring/load_balancer.json | 93 - .../replica_set_with_no_primary.json | 151 - .../replica_set_with_primary.json | 150 - .../replica_set_with_removal.json | 161 - .../sdam_monitoring/required_replica_set.json | 152 - test/sdam_monitoring/standalone.json | 105 - ...ne_suppress_equal_description_changes.json | 115 - .../in_window/equilibrium.json | 46 - .../in_window/many-choices.json | 106 - .../in_window/one-least-two-tied.json | 46 - .../in_window/rs-equilibrium.json | 46 - .../in_window/rs-three-choices.json | 46 - .../in_window/three-choices.json | 46 - .../in_window/two-choices.json | 36 - .../server_selection/in_window/two-least.json | 46 - test/server_selection/rtt/first_value.json | 5 - .../rtt/first_value_zero.json | 5 - test/server_selection/rtt/value_test_1.json | 5 - test/server_selection/rtt/value_test_2.json | 5 - test/server_selection/rtt/value_test_3.json | 5 - test/server_selection/rtt/value_test_4.json | 5 - test/server_selection/rtt/value_test_5.json | 5 - .../LoadBalanced/read/Nearest.json | 35 - .../LoadBalanced/read/Primary.json | 30 - .../LoadBalanced/read/PrimaryPreferred.json | 35 - .../LoadBalanced/read/Secondary.json | 35 - .../LoadBalanced/read/SecondaryPreferred.json | 35 - .../LoadBalanced/write/Nearest.json | 35 - .../LoadBalanced/write/Primary.json | 30 - .../LoadBalanced/write/PrimaryPreferred.json | 35 - .../LoadBalanced/write/Secondary.json | 35 - .../write/SecondaryPreferred.json | 35 - .../read/DeprioritizedNearest.json | 62 - .../DeprioritizedNearestOnlyMatchingTags.json | 62 - .../read/DeprioritizedPrimary.json | 39 - .../read/DeprioritizedPrimaryPreferred.json | 62 - ...tizedPrimaryPreferredOnlyMatchingTags.json | 62 - .../read/DeprioritizedSecondary.json | 62 - ...eprioritizedSecondaryOnlyMatchingTags.json | 62 - .../read/DeprioritizedSecondaryPreferred.json | 62 - ...zedSecondaryPreferredOnlyMatchingTags.json | 62 - .../ReplicaSetNoPrimary/read/Nearest.json | 60 - .../read/Nearest_multiple.json | 68 - .../read/Nearest_non_matching.json | 34 - .../read/PossiblePrimary.json | 21 - .../read/PossiblePrimaryNearest.json | 21 - .../ReplicaSetNoPrimary/read/Primary.json | 29 - .../read/PrimaryPreferred.json | 58 - .../read/PrimaryPreferred_non_matching.json | 34 - .../ReplicaSetNoPrimary/read/Secondary.json | 60 - .../read/SecondaryPreferred.json | 60 - .../read/SecondaryPreferred_non_matching.json | 34 - .../read/Secondary_multi_tags.json | 60 - .../read/Secondary_multi_tags2.json | 60 - .../read/Secondary_non_matching.json | 34 - .../write/SecondaryPreferred.json | 34 - .../DeprioritizedAllPrimaryPreferred.json | 84 - .../DeprioritizedAllSecondaryPreferred.json | 100 - .../read/DeprioritizedNearest.json | 78 - .../DeprioritizedNearestOnlyMatchingTags.json | 70 - .../read/DeprioritizedNearestStateChange.json | 78 - .../read/DeprioritizedPrimary.json | 65 - .../read/DeprioritizedPrimaryPreferred.json | 84 - ...tizedPrimaryPreferredOnlyMatchingTags.json | 70 - .../read/DeprioritizedSecondary.json | 86 - ...eprioritizedSecondaryOnlyMatchingTags.json | 70 - .../read/DeprioritizedSecondaryPreferred.json | 78 - ...zedSecondaryPreferredOnlyMatchingTags.json | 70 - .../ReplicaSetWithPrimary/read/Nearest.json | 76 - .../read/Nearest_multiple.json | 84 - .../read/Nearest_non_matching.json | 42 - .../ReplicaSetWithPrimary/read/Primary.json | 55 - .../read/PrimaryPreferred.json | 58 - .../read/PrimaryPreferred_non_matching.json | 60 - .../ReplicaSetWithPrimary/read/Secondary.json | 68 - .../read/SecondaryPreferred.json | 68 - .../read/SecondaryPreferred_empty_tags.json | 41 - .../read/SecondaryPreferred_non_matching.json | 60 - .../read/SecondaryPreferred_tags.json | 52 - .../read/Secondary_non_matching.json | 42 - .../DeprioritizedSecondaryPreferred.json | 70 - .../write/SecondaryPreferred.json | 60 - .../Sharded/read/DeprioritizedNearest.json | 47 - .../Sharded/read/DeprioritizedPrimary.json | 42 - .../read/DeprioritizedPrimaryPreferred.json | 47 - .../Sharded/read/DeprioritizedSecondary.json | 47 - .../read/DeprioritizedSecondaryPreferred.json | 47 - .../Sharded/read/Nearest.json | 45 - .../Sharded/read/Primary.json | 40 - .../Sharded/read/PrimaryPreferred.json | 45 - .../Sharded/read/Secondary.json | 45 - .../Sharded/read/SecondaryPreferred.json | 45 - .../Sharded/write/DeprioritizedNearest.json | 47 - .../Sharded/write/DeprioritizedPrimary.json | 42 - .../write/DeprioritizedPrimaryPreferred.json | 47 - .../Sharded/write/DeprioritizedSecondary.json | 47 - .../DeprioritizedSecondaryPreferred.json | 47 - .../Sharded/write/Nearest.json | 45 - .../Sharded/write/Primary.json | 40 - .../Sharded/write/PrimaryPreferred.json | 45 - .../Sharded/write/Secondary.json | 45 - .../Sharded/write/SecondaryPreferred.json | 45 - .../Single/read/Deprioritized.json | 54 - .../Single/read/SecondaryPreferred.json | 44 - .../Single/write/Deprioritized.json | 54 - .../Single/write/SecondaryPreferred.json | 44 - .../Unknown/read/SecondaryPreferred.json | 17 - .../server_selection/Unknown/read/ghost.json | 18 - .../Unknown/write/SecondaryPreferred.json | 17 - .../server_selection/Unknown/write/ghost.json | 18 - .../load-balanced.json | 107 - .../operation-id.json | 418 - .../server_selection_logging/replica-set.json | 228 - test/server_selection_logging/sharded.json | 237 - test/server_selection_logging/standalone.json | 235 - .../driver-sessions-dirty-session-errors.json | 976 -- .../driver-sessions-server-support.json | 256 - ...t-sessions-default-causal-consistency.json | 318 - ...t-sessions-not-supported-client-error.json | 128 - ...t-sessions-not-supported-server-error.json | 187 - .../snapshot-sessions-unsupported-ops.json | 493 - test/sessions/snapshot-sessions.json | 993 -- test/sigstop_sigcont.py | 95 - .../loadBalanced-directConnection.json | 15 - .../loadBalanced-no-results.json | 7 - .../loadBalanced-replicaSet-errors.json | 7 - .../loadBalanced-true-multiple-hosts.json | 7 - .../load-balanced/loadBalanced-true-txt.json | 14 - ...-conflicts_with_loadBalanced-true-txt.json | 7 - ...osts-conflicts_with_loadBalanced-true.json | 7 - .../load-balanced/srvMaxHosts-zero-txt.json | 15 - .../load-balanced/srvMaxHosts-zero.json | 15 - .../dbname-with-commas-escaped.json | 19 - .../replica-set/dbname-with-commas.json | 19 - .../replica-set/direct-connection-false.json | 16 - .../replica-set/direct-connection-true.json | 7 - .../replica-set/encoded-userinfo-and-db.json | 22 - .../identical-hostnames-valid-four-parts.json | 8 - ...identical-hostnames-valid-three-parts.json | 8 - .../replica-set/loadBalanced-false-txt.json | 16 - .../replica-set/longer-parent-in-return.json | 17 - .../replica-set/misformatted-option.json | 7 - test/srv_seedlist/replica-set/no-results.json | 7 - .../replica-set/not-enough-parts.json | 7 - .../replica-set/one-result-default-port.json | 16 - .../one-txt-record-multiple-strings.json | 16 - .../replica-set/one-txt-record.json | 17 - .../replica-set/parent-part-mismatch1.json | 7 - .../replica-set/parent-part-mismatch2.json | 7 - .../replica-set/parent-part-mismatch3.json | 7 - .../replica-set/parent-part-mismatch4.json | 7 - .../replica-set/parent-part-mismatch5.json | 7 - .../returned-parent-too-short.json | 7 - .../replica-set/returned-parent-wrong.json | 7 - .../replica-set/srv-service-name.json | 17 - ...rvAllowedHostsSuffix-case-insensitive.json | 10 - .../srvAllowedHostsSuffix-mismatch.json | 6 - .../srvAllowedHostsSuffix-period-only.json | 6 - ...owedHostsSuffix-psl-not-public-suffix.json | 16 - ...sSuffix-psl-public-suffix-capitalized.json | 6 - ...vAllowedHostsSuffix-psl-public-suffix.json | 6 - .../srvAllowedHostsSuffix-tld-only.json | 6 - .../srvAllowedHostsSuffix-trailing-dot.json | 10 - .../srvAllowedHostsSuffix-with_dot.json | 10 - ...rvAllowedHostsSuffix-without_dot_fail.json | 6 - ...rvAllowedHostsSuffix-without_dot_pass.json | 10 - ...axHosts-conflicts_with_replicaSet-txt.json | 7 - ...srvMaxHosts-conflicts_with_replicaSet.json | 7 - .../srvMaxHosts-equal_to_srv_records.json | 18 - .../srvMaxHosts-greater_than_srv_records.json | 17 - .../srvMaxHosts-less_than_srv_records.json | 14 - .../replica-set/srvMaxHosts-zero-txt.json | 18 - .../replica-set/srvMaxHosts-zero.json | 18 - .../replica-set/two-results-default-port.json | 17 - .../two-results-nonstandard-port.json | 17 - .../replica-set/two-txt-records.json | 7 - .../txt-record-not-allowed-option.json | 7 - ...txt-record-with-overridden-ssl-option.json | 17 - ...txt-record-with-overridden-uri-option.json | 17 - .../txt-record-with-unallowed-option.json | 7 - .../replica-set/uri-with-admin-database.json | 20 - .../replica-set/uri-with-auth.json | 22 - .../replica-set/uri-with-port.json | 7 - .../replica-set/uri-with-two-hosts.json | 7 - .../uri-with-uppercase-hostname.json | 16 - .../srvMaxHosts-equal_to_srv_records.json | 17 - .../srvMaxHosts-greater_than_srv_records.json | 16 - .../srvMaxHosts-less_than_srv_records.json | 10 - .../sharded/srvMaxHosts-zero.json | 16 - test/test_auth.py | 740 -- test/test_auth_oidc.py | 1215 -- test/test_auth_spec.py | 114 - test/test_azure_helpers.py | 169 - test/test_binary.py | 476 - test/test_bson.py | 2086 ---- test/test_bson_binary_vector.py | 122 - test/test_bson_corpus.py | 233 - test/test_bulk.py | 1115 -- test/test_causal_consistency.py | 34 - test/test_change_stream.py | 1122 -- test/test_client.py | 3230 ----- test/test_client_backpressure.py | 382 - test/test_client_bulk_write.py | 681 - test/test_client_context.py | 55 - test/test_client_metadata.py | 364 - test/test_code.py | 107 - test/test_collation.py | 283 - test/test_collection.py | 2260 ---- test/test_collection_management.py | 34 - test/test_command_logging.py | 38 - test/test_command_monitoring.py | 39 - test/test_comment.py | 159 - test/test_common.py | 184 - test/test_compression_support.py | 332 - test/test_connection_logging.py | 39 - test/test_connection_monitoring.py | 488 - ...nnections_survive_primary_stepdown_spec.py | 138 - test/test_create_entities.py | 134 - test/test_crud_unified.py | 34 - test/test_crud_v1.py | 130 - test/test_csot.py | 108 - test/test_cursor.py | 1863 --- test/test_custom_types.py | 980 -- test/test_daemon.py | 185 - test/test_database.py | 730 -- test/test_dbref.py | 237 - test/test_decimal128.py | 80 - test/test_default_exports.py | 245 - test/test_discovery_and_monitoring.py | 837 -- test/test_dns.py | 449 - test/test_encryption.py | 3826 ------ test/test_errors.py | 99 - test/test_event_loggers.py | 374 - test/test_examples.py | 1441 --- test/test_fork.py | 104 - test/test_fuzz_harvest.py | 135 - test/test_gcp_helpers.py | 116 - test/test_grid_file.py | 876 -- test/test_gridfs.py | 598 - test/test_gridfs_bucket.py | 592 - test/test_gridfs_spec.py | 34 - test/test_handshake_unified.py | 32 - test/test_heartbeat_monitoring.py | 97 - test/test_hello_latched.py | 82 - test/test_index_management.py | 396 - test/test_json_util.py | 664 - test/test_json_util_integration.py | 32 - test/test_kms_connect.py | 1236 -- test/test_kms_connect_prose.py | 216 - test/test_load_balancer.py | 198 - test/test_logger.py | 171 - test/test_max_staleness.py | 150 - test/test_message.py | 471 - test/test_mongos_load_balancing.py | 199 - test/test_monitor.py | 125 - test/test_monitoring.py | 1277 -- test/test_network_layer.py | 120 - test/test_objectid.py | 212 - test/test_ocsp_cache.py | 138 - test/test_ocsp_support.py | 826 -- test/test_on_demand_csfle.py | 113 - test/test_operation_id_retry.py | 299 - test/test_operations.py | 80 - test/test_periodic_executor.py | 349 - test/test_pooling.py | 959 -- test/test_pymongo.py | 43 - test/test_pyopenssl_context.py | 312 - test/test_raw_bson.py | 156 - test/test_raw_bson_shared.py | 325 - test/test_read_concern.py | 117 - test/test_read_preferences.py | 713 -- test/test_read_write_concern_spec.py | 347 - test/test_replica_set_reconfig.py | 186 - test/test_results.py | 160 - test/test_retryable_reads.py | 523 - test/test_retryable_reads_unified.py | 41 - test/test_retryable_writes.py | 906 -- test/test_retryable_writes_unified.py | 36 - test/test_run_command.py | 36 - test/test_saslprep.py | 43 - test/test_sdam_monitoring_spec.py | 371 - test/test_server.py | 38 - test/test_server_description.py | 208 - test/test_server_selection.py | 245 - test/test_server_selection_in_window.py | 207 - test/test_server_selection_logging.py | 40 - test/test_server_selection_rtt.py | 76 - test/test_session.py | 1341 -- test/test_sessions_unified.py | 34 - test/test_sfp.py | 113 - test/test_son.py | 192 - test/test_srv_polling.py | 487 - test/test_ssl.py | 941 -- test/test_ssl_support.py | 97 - test/test_streaming_protocol.py | 231 - test/test_subinterpreters.py | 279 - test/test_threads.py | 165 - test/test_timestamp.py | 86 - test/test_topology.py | 912 -- test/test_transactions.py | 720 -- test/test_transactions_unified.py | 44 - test/test_typing.py | 641 - test/test_typing_strict.py | 41 - test/test_unified_format.py | 93 - test/test_uri_parser.py | 747 -- test/test_uri_spec.py | 233 - test/test_versioned_api.py | 69 - test/test_versioned_api_integration.py | 74 - test/test_write_concern.py | 86 - .../unified/callback-aborts.json | 346 - .../unified/callback-commits.json | 425 - .../unified/callback-retry.json | 472 - .../unified/commit-retry-errorLabels.json | 231 - .../unified/commit-retry.json | 552 - .../commit-transienttransactionerror-4.2.json | 294 - .../commit-transienttransactionerror.json | 996 -- .../unified/commit-writeconcernerror.json | 812 -- .../unified/commit.json | 398 - .../unified/transaction-options.json | 819 -- test/transactions/unified/abort.json | 828 -- .../unified/backpressure-retryable-abort.json | 342 - .../backpressure-retryable-commit.json | 359 - .../unified/backpressure-retryable-reads.json | 313 - .../backpressure-retryable-writes.json | 439 - test/transactions/unified/bulk.json | 652 - .../unified/causal-consistency.json | 426 - .../unified/client-bulkWrite.json | 593 - test/transactions/unified/commit.json | 1250 -- test/transactions/unified/count.json | 177 - .../unified/create-collection.json | 282 - test/transactions/unified/create-index.json | 313 - test/transactions/unified/delete.json | 425 - .../do-not-retry-read-in-transaction.json | 115 - .../unified/error-labels-blockConnection.json | 241 - .../unified/error-labels-errorLabels.json | 423 - test/transactions/unified/error-labels.json | 2263 ---- test/transactions/unified/errors-client.json | 142 - test/transactions/unified/errors.json | 285 - .../unified/findOneAndDelete.json | 317 - .../unified/findOneAndReplace.json | 356 - .../unified/findOneAndUpdate.json | 546 - test/transactions/unified/insert.json | 895 -- test/transactions/unified/isolation.json | 281 - .../transactions/unified/mongos-pin-auto.json | 5474 -------- .../mongos-recovery-token-errorLabels.json | 211 - .../unified/mongos-recovery-token.json | 568 - test/transactions/unified/mongos-unpin.json | 450 - test/transactions/unified/pin-mongos.json | 1466 --- test/transactions/unified/read-concern.json | 1924 --- test/transactions/unified/read-pref.json | 728 -- test/transactions/unified/reads.json | 706 -- .../unified/retryable-abort-errorLabels.json | 2436 ---- .../unified/retryable-abort-handshake.json | 204 - .../transactions/unified/retryable-abort.json | 600 - .../unified/retryable-commit-errorLabels.json | 2564 ---- .../unified/retryable-commit-handshake.json | 211 - .../unified/retryable-commit.json | 868 -- .../unified/retryable-writes.json | 472 - test/transactions/unified/run-command.json | 421 - .../unified/transaction-options-repl.json | 267 - .../unified/transaction-options.json | 2081 ---- test/transactions/unified/update.json | 565 - test/transactions/unified/write-concern.json | 1588 --- test/unicode/test_utf8.py | 32 - ...ntEncryptionOpts-additionalProperties.json | 30 - ...ncryptionOpts-keyVaultClient-required.json | 23 - ...entEncryptionOpts-keyVaultClient-type.json | 29 - ...yptionOpts-keyVaultNamespace-required.json | 28 - ...EncryptionOpts-keyVaultNamespace-type.json | 29 - ...pts-kmsProviders-additionalProperties.json | 29 - ...kmsProviders-aws-additionalProperties.json | 31 - ...tEncryptionOpts-kmsProviders-aws-type.json | 29 - ...sProviders-azure-additionalProperties.json | 31 - ...ncryptionOpts-kmsProviders-azure-type.json | 29 - ...kmsProviders-gcp-additionalProperties.json | 31 - ...tEncryptionOpts-kmsProviders-gcp-type.json | 29 - ...cryptionOpts-kmsProviders-invalidName.json | 29 - ...msProviders-kmip-additionalProperties.json | 31 - ...EncryptionOpts-kmsProviders-kmip-type.json | 29 - ...sProviders-local-additionalProperties.json | 31 - ...ncryptionOpts-kmsProviders-local-type.json | 29 - ...tEncryptionOpts-kmsProviders-required.json | 26 - ...lientEncryptionOpts-kmsProviders-type.json | 27 - ...cryptionOpts-tlsOptions_not_supported.json | 30 - .../collectionData-additionalProperties.json | 39 - ...ollectionData-collectionName-required.json | 37 - .../collectionData-collectionName-type.json | 38 - .../collectionData-createOptions-type.json | 39 - .../collectionData-databaseName-required.json | 37 - .../collectionData-databaseName-type.json | 38 - .../collectionData-documents-items.json | 40 - .../collectionData-documents-required.json | 37 - .../collectionData-documents-type.json | 38 - ...rDatabaseOptions-additionalProperties.json | 27 - ...ionOrDatabaseOptions-readConcern-type.json | 27 - ...OrDatabaseOptions-readPreference-type.json | 27 - ...ctionOrDatabaseOptions-timeoutMS-type.json | 27 - ...onOrDatabaseOptions-writeConcern-type.json | 27 - .../invalid/createEntities-items.json | 13 - .../invalid/createEntities-minItems.json | 11 - .../invalid/createEntities-type.json | 11 - .../invalid/description-required.json | 9 - .../invalid/entity-additionalProperties.json | 15 - .../entity-bucket-additionalProperties.json | 31 - .../entity-bucket-bucketOptions-type.json | 31 - .../entity-bucket-database-required.json | 29 - .../invalid/entity-bucket-database-type.json | 30 - .../invalid/entity-bucket-id-required.json | 29 - .../invalid/entity-bucket-id-type.json | 30 - .../entity-client-additionalProperties.json | 18 - .../invalid/entity-client-id-required.json | 15 - .../invalid/entity-client-id-type.json | 17 - ...t-ignoreCommandMonitoringEvents-items.json | 20 - ...gnoreCommandMonitoringEvents-minItems.json | 18 - ...nt-ignoreCommandMonitoringEvents-type.json | 18 - .../entity-client-observeEvents-enum.json | 20 - .../entity-client-observeEvents-items.json | 20 - .../entity-client-observeEvents-minItems.json | 18 - .../entity-client-observeEvents-type.json | 18 - ...ient-observeLogMessages-minProperties.json | 18 - ...ient-observeLogMessages-property-type.json | 20 - ...ent-observeLogMessages-property-value.json | 20 - ...entity-client-observeLogMessages-type.json | 18 - ...-client-observeSensitiveCommands-type.json | 18 - ...ient-serverApi-deprecationErrors-type.json | 21 - .../entity-client-serverApi-strict-type.json | 21 - .../invalid/entity-client-serverApi-type.json | 18 - ...ity-client-serverApi-version-required.json | 18 - .../entity-client-serverApi-version-type.json | 20 - .../entity-client-uriOptions-type.json | 18 - ...ntity-client-useMultipleMongoses-type.json | 18 - ...clientEncryption-additionalProperties.json | 30 - ...ryption-clientEncryptionOpts-required.json | 17 - ...tEncryption-clientEncryptionOpts-type.json | 18 - .../entity-clientEncryption-id-required.json | 28 - .../entity-clientEncryption-id-type.json | 29 - ...ntity-collection-additionalProperties.json | 32 - ...ty-collection-collectionName-required.json | 30 - ...entity-collection-collectionName-type.json | 31 - ...ity-collection-collectionOptions-type.json | 32 - .../entity-collection-database-required.json | 30 - .../entity-collection-database-type.json | 31 - .../entity-collection-id-required.json | 30 - .../invalid/entity-collection-id-type.json | 31 - .../entity-database-additionalProperties.json | 25 - .../entity-database-client-required.json | 23 - .../invalid/entity-database-client-type.json | 24 - ...entity-database-databaseName-required.json | 23 - .../entity-database-databaseName-type.json | 24 - .../entity-database-databaseOptions-type.json | 25 - .../invalid/entity-database-id-required.json | 23 - .../invalid/entity-database-id-type.json | 24 - .../invalid/entity-maxProperties.json | 22 - .../invalid/entity-minProperties.json | 13 - .../entity-session-additionalProperties.json | 24 - .../entity-session-client-required.json | 22 - .../invalid/entity-session-client-type.json | 23 - .../invalid/entity-session-id-required.json | 22 - .../invalid/entity-session-id-type.json | 23 - .../entity-session-sessionOptions-type.json | 24 - .../entity-stream-additionalProperties.json | 19 - .../entity-stream-hexBytes-pattern.json | 18 - .../entity-stream-hexBytes-required.json | 17 - .../invalid/entity-stream-hexBytes-type.json | 18 - .../invalid/entity-stream-id-required.json | 17 - .../invalid/entity-stream-id-type.json | 18 - .../entity-thread-additionalProperties.json | 18 - .../invalid/entity-thread-id-required.json | 15 - .../invalid/entity-thread-id-type.json | 17 - ...ectionCheckOutFailedEvent-reason-type.json | 23 - ...kOutStartedEvent-additionalProperties.json | 23 - ...onCheckedInEvent-additionalProperties.json | 23 - ...nCheckedOutEvent-additionalProperties.json | 23 - ...ent-connectionClosedEvent-reason-type.json | 23 - ...tionCreatedEvent-additionalProperties.json | 23 - ...ectionReadyEvent-additionalProperties.json | 23 - ...nt-poolClearedEvent-hasServiceId-type.json | 23 - ...dEvent-interruptInUseConnections-type.json | 23 - ...-poolClosedEvent-additionalProperties.json | 23 - ...poolCreatedEvent-additionalProperties.json | 23 - ...t-poolReadyEvent-additionalProperties.json | 23 - ...ctedCommandEvent-additionalProperties.json | 27 - ...t-commandFailedEvent-commandName-type.json | 29 - ...-commandFailedEvent-databaseName-type.json | 29 - ...ailedEvent-hasServerConnectionId-type.json | 29 - ...-commandFailedEvent-hasServiceId-type.json | 29 - ...mandStartedEvent-additionalProperties.json | 29 - ...vent-commandStartedEvent-command-type.json | 29 - ...-commandStartedEvent-commandName-type.json | 29 - ...commandStartedEvent-databaseName-type.json | 29 - ...artedEvent-hasServerConnectionId-type.json | 29 - ...commandStartedEvent-hasServiceId-type.json | 29 - ...ommandSucceededEvent-commandName-type.json | 29 - ...mmandSucceededEvent-databaseName-type.json | 29 - ...eededEvent-hasServerConnectionId-type.json | 29 - ...mmandSucceededEvent-hasServiceId-type.json | 29 - ...vent-commandSucceededEvent-reply-type.json | 29 - .../expectedCommandEvent-maxProperties.json | 28 - .../expectedCommandEvent-minProperties.json | 25 - .../expectedError-additionalProperties.json | 25 - .../invalid/expectedError-errorCode-type.json | 25 - .../expectedError-errorCodeName-type.json | 25 - .../expectedError-errorContains-type.json | 25 - ...xpectedError-errorLabelsContain-items.json | 27 - ...ctedError-errorLabelsContain-minItems.json | 25 - ...expectedError-errorLabelsContain-type.json | 25 - .../expectedError-errorLabelsOmit-items.json | 27 - ...xpectedError-errorLabelsOmit-minItems.json | 25 - .../expectedError-errorLabelsOmit-type.json | 25 - .../expectedError-errorResponse-type.json | 25 - .../expectedError-isClientError-type.json | 25 - .../invalid/expectedError-isError-const.json | 25 - .../invalid/expectedError-isError-type.json | 25 - .../expectedError-isTimeoutError-type.json | 25 - .../invalid/expectedError-minProperties.json | 23 - ...dEventsForClient-additionalProperties.json | 24 - ...pectedEventsForClient-client-required.json | 22 - .../expectedEventsForClient-client-type.json | 23 - ...xpectedEventsForClient-eventType-enum.json | 24 - ...xpectedEventsForClient-eventType-type.json | 24 - .../expectedEventsForClient-events-items.json | 25 - ...pectedEventsForClient-events-required.json | 22 - .../expectedEventsForClient-events-type.json | 23 - ...-events_conflicts_with_cmap_eventType.json | 28 - ...ents_conflicts_with_command_eventType.json | 28 - ...ents_conflicts_with_default_eventType.json | 27 - ...ventsForClient-ignoreExtraEvents-type.json | 24 - ...pectedLogMessage-additionalProperties.json | 24 - .../expectedLogMessage-component-enum.json | 29 - ...expectedLogMessage-component-required.json | 28 - .../expectedLogMessage-component-type.json | 29 - .../expectedLogMessage-data-required.json | 28 - .../invalid/expectedLogMessage-data-type.json | 29 - ...ctedLogMessage-failureIsRedacted-type.json | 30 - .../expectedLogMessage-level-enum.json | 29 - .../expectedLogMessage-level-required.json | 28 - .../expectedLogMessage-level-type.json | 29 - ...essagesForClient-additionalProperties.json | 24 - ...dLogMessagesForClient-client-required.json | 22 - ...ectedLogMessagesForClient-client-type.json | 23 - ...gesForClient-ignoreExtraMessages-type.json | 24 - ...essagesForClient-ignoreMessages-items.json | 26 - ...MessagesForClient-ignoreMessages-type.json | 24 - ...edLogMessagesForClient-messages-items.json | 25 - ...ogMessagesForClient-messages-required.json | 22 - ...tedLogMessagesForClient-messages-type.json | 23 - ...tionChangedEvent-additionalProperties.json | 23 - ...erverDescription-additionalProperties.json | 25 - ...ngedEvent-serverDescription-type-enum.json | 25 - ...ngedEvent-serverDescription-type-type.json | 25 - ...tionChangedEvent-additionalProperties.json | 23 - .../invalid/initialData-items.json | 13 - .../invalid/initialData-minItems.json | 11 - .../invalid/initialData-type.json | 11 - .../operation-additionalProperties.json | 23 - .../invalid/operation-arguments-type.json | 23 - ...pectError-conflicts_with_expectResult.json | 26 - ...ror-conflicts_with_saveResultAsEntity.json | 26 - .../invalid/operation-expectError-type.json | 23 - .../invalid/operation-expectEvents-type.json | 23 - ...ltAndError-conflicts_with_expectError.json | 19 - ...tAndError-conflicts_with_expectResult.json | 17 - ...ror-conflicts_with_saveResultAsEntity.json | 17 - .../invalid/operation-name-required.json | 21 - .../invalid/operation-name-type.json | 22 - .../invalid/operation-object-required.json | 21 - .../invalid/operation-object-type.json | 22 - .../operation-saveResultAsEntity-type.json | 23 - ...runOnRequirement-additionalProperties.json | 16 - .../invalid/runOnRequirement-auth-type.json | 15 - .../runOnRequirement-authMechanism-type.json | 15 - ...csfle-minLibmongocryptVersion-pattern.json | 17 - ...nt-csfle-minLibmongocryptVersion-type.json | 17 - .../invalid/runOnRequirement-csfle-type.json | 15 - ...nRequirement-maxServerVersion-pattern.json | 15 - ...unOnRequirement-maxServerVersion-type.json | 15 - .../runOnRequirement-minProperties.json | 13 - ...nRequirement-minServerVersion-pattern.json | 15 - ...unOnRequirement-minServerVersion-type.json | 15 - .../runOnRequirement-serverless-enum.json | 15 - .../runOnRequirement-serverless-type.json | 15 - .../runOnRequirement-topologies-enum.json | 17 - .../runOnRequirement-topologies-items.json | 17 - .../runOnRequirement-topologies-minItems.json | 15 - .../runOnRequirement-topologies-type.json | 15 - .../invalid/runOnRequirements-items.json | 13 - .../invalid/runOnRequirements-minItems.json | 11 - .../invalid/runOnRequirements-type.json | 11 - .../invalid/schemaVersion-pattern.json | 10 - .../invalid/schemaVersion-required.json | 9 - .../invalid/schemaVersion-type.json | 10 - .../invalid/test-additionalProperties.json | 11 - .../invalid/test-description-required.json | 9 - .../invalid/test-description-type.json | 10 - .../invalid/test-expectEvents-items.json | 13 - .../invalid/test-expectEvents-minItems.json | 11 - .../invalid/test-expectEvents-type.json | 11 - .../invalid/test-expectLogMessages-items.json | 13 - .../test-expectLogMessages-minItems.json | 11 - .../invalid/test-expectLogMessages-type.json | 11 - .../invalid/test-operations-items.json | 12 - .../invalid/test-operations-required.json | 9 - .../invalid/test-operations-type.json | 10 - .../invalid/test-outcome-items.json | 13 - .../invalid/test-outcome-minItems.json | 11 - .../invalid/test-outcome-type.json | 11 - .../invalid/test-runOnRequirements-items.json | 13 - .../test-runOnRequirements-minItems.json | 11 - .../invalid/test-runOnRequirements-type.json | 11 - .../invalid/test-skipReason-type.json | 11 - .../invalid/tests-items.json | 7 - .../invalid/tests-minItems.json | 5 - .../invalid/tests-required.json | 4 - .../invalid/tests-type.json | 5 - .../assertNumberConnectionsCheckedOut.json | 63 - .../entity-bucket-database-undefined.json | 18 - .../entity-client-apiVersion-unsupported.json | 20 - .../entity-collection-database-undefined.json | 19 - .../entity-database-client-undefined.json | 19 - .../entity-findCursor-malformed.json | 44 - .../valid-fail/entity-findCursor.json | 52 - .../entity-session-client-undefined.json | 18 - .../ignoreResultAndError-malformed.json | 48 - .../valid-fail/ignoreResultAndError.json | 59 - ...Providers-missing_aws_kms_credentials.json | 36 - ...oviders-missing_azure_kms_credentials.json | 36 - ...Providers-missing_gcp_kms_credentials.json | 36 - .../valid-fail/kmsProviders-no_kms.json | 32 - .../valid-fail/operation-failure.json | 56 - .../valid-fail/operation-unsupported.json | 22 - .../valid-fail/operator-matchAsDocument.json | 205 - .../valid-fail/operator-matchAsRoot.json | 67 - .../returnDocument-enum-invalid.json | 66 - .../valid-fail/schemaVersion-unsupported.json | 10 - .../assertNumberConnectionsCheckedOut.json | 27 - .../collectionData-createOptions.json | 79 - .../valid-pass/createEntities-operation.json | 74 - .../valid-pass/entity-client-cmap-events.json | 71 - .../valid-pass/entity-commandCursor.json | 278 - .../valid-pass/entity-cursor-iterateOnce.json | 111 - .../valid-pass/entity-find-cursor.json | 191 - .../expectedError-errorResponse.json | 70 - .../expectedError-isClientError.json | 74 - .../expectedEventsForClient-eventType.json | 126 - ...ctedEventsForClient-ignoreExtraEvents.json | 151 - ...lient-topologyDescriptionChangedEvent.json | 68 - .../valid-pass/ignoreResultAndError.json | 59 - ...kmsProviders-explicit_kms_credentials.json | 52 - ...Providers-mixed_kms_credential_fields.json | 54 - ...Providers-placeholder_kms_credentials.json | 70 - .../kmsProviders-unconfigured_kms.json | 39 - .../valid-pass/observeSensitiveCommands.json | 706 -- .../valid-pass/operation-empty_array.json | 10 - .../valid-pass/operator-lte.json | 88 - .../valid-pass/operator-matchAsDocument.json | 124 - .../valid-pass/operator-matchAsRoot.json | 151 - .../operator-type-number_alias.json | 174 - .../valid-pass/poc-change-streams.json | 455 - .../valid-pass/poc-command-monitoring.json | 223 - .../valid-pass/poc-crud.json | 450 - .../valid-pass/poc-gridfs.json | 301 - .../valid-pass/poc-queryable-encryption.json | 193 - .../valid-pass/poc-retryable-reads.json | 433 - .../valid-pass/poc-retryable-writes.json | 491 - .../valid-pass/poc-sessions.json | 466 - .../poc-transactions-convenient-api.json | 505 - .../poc-transactions-mongos-pin-auto.json | 409 - .../valid-pass/poc-transactions.json | 323 - test/unified_format.py | 1703 --- test/unified_format_shared.py | 699 -- test/uri_options/auth-options.json | 33 - test/uri_options/ca.pem | 1 - test/uri_options/cert.pem | 1 - .../client-backpressure-options.json | 66 - test/uri_options/client.pem | 1 - test/uri_options/compression-options.json | 59 - test/uri_options/concern-options.json | 67 - test/uri_options/connection-options.json | 273 - test/uri_options/connection-pool-options.json | 76 - test/uri_options/read-preference-options.json | 82 - test/uri_options/sdam-options.json | 46 - test/uri_options/single-threaded-options.json | 24 - test/uri_options/srv-options.json | 125 - test/uri_options/tls-options.json | 640 - test/utils.py | 296 - test/utils_selection_tests.py | 230 - test/utils_selection_tests_shared.py | 101 - test/utils_shared.py | 842 -- test/utils_spec_runner.py | 195 - test/version.py | 35 - .../crud-api-version-1-strict.json | 1109 -- test/versioned-api/crud-api-version-1.json | 1182 -- ...ommand-helper-no-api-version-declared.json | 127 - .../test-commands-deprecation-errors.json | 74 - .../test-commands-strict-mode.json | 75 - test/versioned-api/transaction-handling.json | 348 - tools/README.rst | 3 - tools/clean.py | 29 - tools/compare_import_time.py | 37 - tools/ensure_future_annotations_import.py | 41 - tools/fail_if_no_c.py | 48 - tools/generate_sbom_requirements.py | 75 - tools/ocsptest.py | 62 - tools/synchro.py | 448 - tools/test_synchro.py | 42 - uv.lock | 2480 ---- 2151 files changed, 634375 deletions(-) delete mode 100644 .codecov.yml delete mode 100755 .evergreen/combine-coverage.sh delete mode 100644 .evergreen/config.yml delete mode 100644 .evergreen/generated_configs/functions.yml delete mode 100644 .evergreen/generated_configs/tasks.yml delete mode 100644 .evergreen/generated_configs/variants.yml delete mode 100755 .evergreen/just.sh delete mode 100755 .evergreen/remove-unimplemented-tests.sh delete mode 100755 .evergreen/resync-specs.sh delete mode 100755 .evergreen/run-mongodb-aws-ecs-test.sh delete mode 100755 .evergreen/run-mongodb-oidc-test.sh delete mode 100755 .evergreen/run-tests.sh delete mode 100644 .evergreen/scripts/__init__.py delete mode 100755 .evergreen/scripts/check-import-time.sh delete mode 100755 .evergreen/scripts/cleanup.sh delete mode 100755 .evergreen/scripts/configure-env.sh delete mode 100755 .evergreen/scripts/create-fuzz-corpus-pr.sh delete mode 100755 .evergreen/scripts/create-spec-pr.sh delete mode 100755 .evergreen/scripts/dispatch.sh delete mode 100755 .evergreen/scripts/download-and-merge-coverage.sh delete mode 100755 .evergreen/scripts/generate-config.sh delete mode 100644 .evergreen/scripts/generate_config.py delete mode 100644 .evergreen/scripts/generate_config_utils.py delete mode 100755 .evergreen/scripts/github-pr-util.sh delete mode 100755 .evergreen/scripts/harvest-fuzz-corpus.sh delete mode 100755 .evergreen/scripts/install-dependencies.sh delete mode 100644 .evergreen/scripts/kms_tester.py delete mode 100755 .evergreen/scripts/mod_wsgi.sh delete mode 100644 .evergreen/scripts/mod_wsgi_matrix.py delete mode 100644 .evergreen/scripts/mod_wsgi_tester.py delete mode 100644 .evergreen/scripts/oidc_tester.py delete mode 100755 .evergreen/scripts/perf-submission-setup.sh delete mode 100755 .evergreen/scripts/perf-submission.sh delete mode 100755 .evergreen/scripts/resync-all-specs.sh delete mode 100644 .evergreen/scripts/resync_all_specs.py delete mode 100755 .evergreen/scripts/run-getdata.sh delete mode 100755 .evergreen/scripts/run-server.sh delete mode 100644 .evergreen/scripts/run_server.py delete mode 100644 .evergreen/scripts/run_tests.py delete mode 100755 .evergreen/scripts/setup-dev-env.sh delete mode 100755 .evergreen/scripts/setup-system.sh delete mode 100755 .evergreen/scripts/setup-tests.sh delete mode 100755 .evergreen/scripts/setup-uv-python.sh delete mode 100644 .evergreen/scripts/setup_tests.py delete mode 100755 .evergreen/scripts/setup_uv.py delete mode 100755 .evergreen/scripts/stop-server.sh delete mode 100755 .evergreen/scripts/teardown-tests.sh delete mode 100644 .evergreen/scripts/teardown_tests.py delete mode 100644 .evergreen/scripts/test_generate_config.py delete mode 100755 .evergreen/scripts/upload-codecov.sh delete mode 100755 .evergreen/scripts/upload-coverage-report.sh delete mode 100644 .evergreen/scripts/utils.py delete mode 100755 .evergreen/setup-spawn-host.sh delete mode 100644 .evergreen/spec-patch/PYTHON-3712.patch delete mode 100644 .evergreen/spec-patch/PYTHON-4918.patch delete mode 100644 .evergreen/spec-patch/PYTHON-5052.patch delete mode 100644 .evergreen/spec-patch/PYTHON-5445.patch delete mode 100644 .evergreen/spec-patch/PYTHON-5493.patch delete mode 100644 .evergreen/spec-patch/PYTHON-5559.patch delete mode 100644 .evergreen/spec-patch/PYTHON-5759.patch delete mode 100644 .evergreen/spec-patch/PYTHON-5993.patch delete mode 100644 .evergreen/spec-patch/permanent/PYTHON-2673.patch delete mode 100644 .evergreen/spec-patch/permanent/PYTHON-4261.patch delete mode 100755 .evergreen/sync-spawn-host.sh delete mode 100644 .git-blame-ignore-revs delete mode 100644 .github/CODEOWNERS delete mode 100644 .github/actions/mod-wsgi-versions/action.yml delete mode 100644 .github/copilot-instructions.md delete mode 100644 .github/dependabot.yml delete mode 100644 .github/pull_request_template.md delete mode 100644 .github/reviewers.txt delete mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/create-release-branch.yml delete mode 100644 .github/workflows/dist.yml delete mode 100644 .github/workflows/release-python.yml delete mode 100644 .github/workflows/sbom.yml delete mode 100644 .github/workflows/test-mod-wsgi.yml delete mode 100644 .github/workflows/test-python.yml delete mode 100644 .github/workflows/uv-lock-update.yml delete mode 100644 .github/workflows/zizmor.yml delete mode 100644 .github/zizmor.yml delete mode 100644 .gitignore delete mode 100644 .gitmodules delete mode 100644 .pre-commit-config.yaml delete mode 100644 .readthedocs.yaml delete mode 100644 AGENTS.md delete mode 100644 CLAUDE.md delete mode 100644 CODING-STANDARDS.md delete mode 100644 CONTRIBUTING.md delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100644 THIRD-PARTY-NOTICES delete mode 100644 _setup.py delete mode 100644 bson/__init__.py delete mode 100644 bson/_cbsonmodule.c delete mode 100644 bson/_cbsonmodule.h delete mode 100644 bson/_helpers.py delete mode 100644 bson/binary.py delete mode 100644 bson/bson-endian.h delete mode 100644 bson/buffer.c delete mode 100644 bson/buffer.h delete mode 100644 bson/code.py delete mode 100644 bson/codec_options.py delete mode 100644 bson/datetime_ms.py delete mode 100644 bson/dbref.py delete mode 100644 bson/decimal128.py delete mode 100644 bson/errors.py delete mode 100644 bson/int64.py delete mode 100644 bson/json_util.py delete mode 100644 bson/max_key.py delete mode 100644 bson/min_key.py delete mode 100644 bson/objectid.py delete mode 100644 bson/py.typed delete mode 100644 bson/raw_bson.py delete mode 100644 bson/regex.py delete mode 100644 bson/son.py delete mode 100644 bson/time64.c delete mode 100644 bson/time64.h delete mode 100644 bson/time64_config.h delete mode 100644 bson/time64_limits.h delete mode 100644 bson/timestamp.py delete mode 100644 bson/typings.py delete mode 100644 bson/tz_util.py delete mode 100644 doc/Makefile delete mode 100644 doc/__init__.py delete mode 100644 doc/_templates/layout.html delete mode 100644 doc/api/bson/binary.rst delete mode 100644 doc/api/bson/code.rst delete mode 100644 doc/api/bson/codec_options.rst delete mode 100644 doc/api/bson/datetime_ms.rst delete mode 100644 doc/api/bson/dbref.rst delete mode 100644 doc/api/bson/decimal128.rst delete mode 100644 doc/api/bson/errors.rst delete mode 100644 doc/api/bson/index.rst delete mode 100644 doc/api/bson/int64.rst delete mode 100644 doc/api/bson/json_util.rst delete mode 100644 doc/api/bson/max_key.rst delete mode 100644 doc/api/bson/min_key.rst delete mode 100644 doc/api/bson/objectid.rst delete mode 100644 doc/api/bson/raw_bson.rst delete mode 100644 doc/api/bson/regex.rst delete mode 100644 doc/api/bson/son.rst delete mode 100644 doc/api/bson/timestamp.rst delete mode 100644 doc/api/bson/tz_util.rst delete mode 100644 doc/api/gridfs/asynchronous/grid_file.rst delete mode 100644 doc/api/gridfs/asynchronous/index.rst delete mode 100644 doc/api/gridfs/errors.rst delete mode 100644 doc/api/gridfs/grid_file.rst delete mode 100644 doc/api/gridfs/index.rst delete mode 100644 doc/api/index.rst delete mode 100644 doc/api/pymongo/asynchronous/change_stream.rst delete mode 100644 doc/api/pymongo/asynchronous/client_session.rst delete mode 100644 doc/api/pymongo/asynchronous/collection.rst delete mode 100644 doc/api/pymongo/asynchronous/command_cursor.rst delete mode 100644 doc/api/pymongo/asynchronous/cursor.rst delete mode 100644 doc/api/pymongo/asynchronous/database.rst delete mode 100644 doc/api/pymongo/asynchronous/index.rst delete mode 100644 doc/api/pymongo/asynchronous/mongo_client.rst delete mode 100644 doc/api/pymongo/auth_oidc.rst delete mode 100644 doc/api/pymongo/change_stream.rst delete mode 100644 doc/api/pymongo/client_options.rst delete mode 100644 doc/api/pymongo/client_session.rst delete mode 100644 doc/api/pymongo/collation.rst delete mode 100644 doc/api/pymongo/collection.rst delete mode 100644 doc/api/pymongo/command_cursor.rst delete mode 100644 doc/api/pymongo/cursor.rst delete mode 100644 doc/api/pymongo/database.rst delete mode 100644 doc/api/pymongo/driver_info.rst delete mode 100644 doc/api/pymongo/encryption.rst delete mode 100644 doc/api/pymongo/encryption_options.rst delete mode 100644 doc/api/pymongo/errors.rst delete mode 100644 doc/api/pymongo/event_loggers.rst delete mode 100644 doc/api/pymongo/index.rst delete mode 100644 doc/api/pymongo/mongo_client.rst delete mode 100644 doc/api/pymongo/monitoring.rst delete mode 100644 doc/api/pymongo/operations.rst delete mode 100644 doc/api/pymongo/pool.rst delete mode 100644 doc/api/pymongo/read_concern.rst delete mode 100644 doc/api/pymongo/read_preferences.rst delete mode 100644 doc/api/pymongo/results.rst delete mode 100644 doc/api/pymongo/server_api.rst delete mode 100644 doc/api/pymongo/server_description.rst delete mode 100644 doc/api/pymongo/topology_description.rst delete mode 100644 doc/api/pymongo/uri_parser.rst delete mode 100644 doc/api/pymongo/write_concern.rst delete mode 100644 doc/changelog.rst delete mode 100644 doc/conf.py delete mode 100644 doc/contributors.rst delete mode 100644 doc/index.rst delete mode 100644 doc/make.bat delete mode 100644 doc/migrate-to-pymongo4.rst delete mode 100644 doc/pydoctheme/static/pydoctheme.css delete mode 100644 doc/pydoctheme/theme.conf delete mode 100644 doc/static/periodic-executor-refs.dot delete mode 100644 doc/static/periodic-executor-refs.png delete mode 100644 doc/static/sidebar.js delete mode 160000 drivers-evergreen-tools delete mode 100644 fuzz/README.md delete mode 100755 fuzz/build_corpus.py delete mode 100644 fuzz/corpus/.gitkeep delete mode 100755 fuzz/fuzz_decode.py delete mode 100755 fuzz/fuzz_decode_all.py delete mode 100755 fuzz/fuzz_is_valid.py delete mode 100755 fuzz/fuzz_shared.py delete mode 100755 fuzz/harvest_corpus.py delete mode 100644 fuzz/regression/decode__binary_subtype_255 delete mode 100644 fuzz/regression/decode__boolean_no_terminator delete mode 100644 fuzz/regression/decode__decimal128_noncanonical delete mode 100644 fuzz/regression/decode__regex_flags_invalid_utf8 delete mode 100644 fuzz/regression/decode__regex_flags_repr delete mode 100644 fuzz/regression/decode__regex_no_terminator delete mode 100644 gridfs/__init__.py delete mode 100644 gridfs/asynchronous/__init__.py delete mode 100644 gridfs/asynchronous/grid_file.py delete mode 100644 gridfs/errors.py delete mode 100644 gridfs/grid_file.py delete mode 100644 gridfs/grid_file_shared.py delete mode 100644 gridfs/py.typed delete mode 100644 gridfs/synchronous/__init__.py delete mode 100644 gridfs/synchronous/grid_file.py delete mode 100644 hatch_build.py delete mode 100644 integration_tests/README.md delete mode 100755 integration_tests/run.sh delete mode 100644 integration_tests/test_uv_loop.py delete mode 100644 justfile delete mode 100644 mypy_test.ini delete mode 100644 pymongo/__init__.py delete mode 100644 pymongo/_asyncio_lock.py delete mode 100644 pymongo/_azure_helpers.py delete mode 100644 pymongo/_client_bulk_shared.py delete mode 100644 pymongo/_cmessagemodule.c delete mode 100644 pymongo/_csot.py delete mode 100644 pymongo/_gcp_helpers.py delete mode 100644 pymongo/_kms_connect_shared.py delete mode 100644 pymongo/_op_id.py delete mode 100644 pymongo/_psl.py delete mode 100644 pymongo/_telemetry.py delete mode 100644 pymongo/_version.py delete mode 100644 pymongo/asynchronous/__init__.py delete mode 100644 pymongo/asynchronous/_kms_connect.py delete mode 100644 pymongo/asynchronous/aggregation.py delete mode 100644 pymongo/asynchronous/auth.py delete mode 100644 pymongo/asynchronous/auth_aws.py delete mode 100644 pymongo/asynchronous/auth_oidc.py delete mode 100644 pymongo/asynchronous/bulk.py delete mode 100644 pymongo/asynchronous/change_stream.py delete mode 100644 pymongo/asynchronous/client_bulk.py delete mode 100644 pymongo/asynchronous/client_session.py delete mode 100644 pymongo/asynchronous/collection.py delete mode 100644 pymongo/asynchronous/command_cursor.py delete mode 100644 pymongo/asynchronous/command_runner.py delete mode 100644 pymongo/asynchronous/cursor.py delete mode 100644 pymongo/asynchronous/cursor_base.py delete mode 100644 pymongo/asynchronous/database.py delete mode 100644 pymongo/asynchronous/encryption.py delete mode 100644 pymongo/asynchronous/helpers.py delete mode 100644 pymongo/asynchronous/mongo_client.py delete mode 100644 pymongo/asynchronous/monitor.py delete mode 100644 pymongo/asynchronous/pool.py delete mode 100644 pymongo/asynchronous/server.py delete mode 100644 pymongo/asynchronous/settings.py delete mode 100644 pymongo/asynchronous/srv_resolver.py delete mode 100644 pymongo/asynchronous/topology.py delete mode 100644 pymongo/asynchronous/uri_parser.py delete mode 100644 pymongo/auth.py delete mode 100644 pymongo/auth_oidc.py delete mode 100644 pymongo/auth_oidc_shared.py delete mode 100644 pymongo/auth_shared.py delete mode 100644 pymongo/bulk_shared.py delete mode 100644 pymongo/change_stream.py delete mode 100644 pymongo/change_stream_shared.py delete mode 100644 pymongo/client_options.py delete mode 100644 pymongo/client_session.py delete mode 100644 pymongo/client_session_shared.py delete mode 100644 pymongo/collation.py delete mode 100644 pymongo/collection.py delete mode 100644 pymongo/command_cursor.py delete mode 100644 pymongo/common.py delete mode 100644 pymongo/compression_support.py delete mode 100644 pymongo/cursor.py delete mode 100644 pymongo/cursor_shared.py delete mode 100644 pymongo/daemon.py delete mode 100644 pymongo/database.py delete mode 100644 pymongo/database_shared.py delete mode 100644 pymongo/driver_info.py delete mode 100644 pymongo/encryption.py delete mode 100644 pymongo/encryption_options.py delete mode 100644 pymongo/encryption_shared.py delete mode 100644 pymongo/errors.py delete mode 100644 pymongo/event_loggers.py delete mode 100644 pymongo/hello.py delete mode 100644 pymongo/helpers_shared.py delete mode 100644 pymongo/lock.py delete mode 100644 pymongo/logger.py delete mode 100644 pymongo/max_staleness_selectors.py delete mode 100644 pymongo/message.py delete mode 100644 pymongo/mongo_client.py delete mode 100644 pymongo/mongo_client_shared.py delete mode 100644 pymongo/monitoring.py delete mode 100644 pymongo/network_layer.py delete mode 100644 pymongo/ocsp_cache.py delete mode 100644 pymongo/ocsp_support.py delete mode 100644 pymongo/operations.py delete mode 100644 pymongo/periodic_executor.py delete mode 100644 pymongo/pool.py delete mode 100644 pymongo/pool_options.py delete mode 100644 pymongo/pool_shared.py delete mode 100644 pymongo/public_suffix_list.dat delete mode 100644 pymongo/py.typed delete mode 100644 pymongo/pyopenssl_context.py delete mode 100644 pymongo/read_concern.py delete mode 100644 pymongo/read_preferences.py delete mode 100644 pymongo/response.py delete mode 100644 pymongo/results.py delete mode 100644 pymongo/saslprep.py delete mode 100644 pymongo/server_api.py delete mode 100644 pymongo/server_description.py delete mode 100644 pymongo/server_selectors.py delete mode 100644 pymongo/server_type.py delete mode 100644 pymongo/settings_shared.py delete mode 100644 pymongo/socket_checker.py delete mode 100644 pymongo/ssl_context.py delete mode 100644 pymongo/ssl_support.py delete mode 100644 pymongo/synchronous/__init__.py delete mode 100644 pymongo/synchronous/_kms_connect.py delete mode 100644 pymongo/synchronous/aggregation.py delete mode 100644 pymongo/synchronous/auth.py delete mode 100644 pymongo/synchronous/auth_aws.py delete mode 100644 pymongo/synchronous/auth_oidc.py delete mode 100644 pymongo/synchronous/bulk.py delete mode 100644 pymongo/synchronous/change_stream.py delete mode 100644 pymongo/synchronous/client_bulk.py delete mode 100644 pymongo/synchronous/client_session.py delete mode 100644 pymongo/synchronous/collection.py delete mode 100644 pymongo/synchronous/command_cursor.py delete mode 100644 pymongo/synchronous/command_runner.py delete mode 100644 pymongo/synchronous/cursor.py delete mode 100644 pymongo/synchronous/cursor_base.py delete mode 100644 pymongo/synchronous/database.py delete mode 100644 pymongo/synchronous/encryption.py delete mode 100644 pymongo/synchronous/helpers.py delete mode 100644 pymongo/synchronous/mongo_client.py delete mode 100644 pymongo/synchronous/monitor.py delete mode 100644 pymongo/synchronous/pool.py delete mode 100644 pymongo/synchronous/server.py delete mode 100644 pymongo/synchronous/settings.py delete mode 100644 pymongo/synchronous/srv_resolver.py delete mode 100644 pymongo/synchronous/topology.py delete mode 100644 pymongo/synchronous/uri_parser.py delete mode 100644 pymongo/topology_description.py delete mode 100644 pymongo/topology_shared.py delete mode 100644 pymongo/typings.py delete mode 100644 pymongo/uri_parser.py delete mode 100644 pymongo/uri_parser_shared.py delete mode 100644 pymongo/write_concern.py delete mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 requirements/aws.txt delete mode 100644 requirements/docs.txt delete mode 100644 requirements/encryption.txt delete mode 100644 requirements/gssapi.txt delete mode 100644 requirements/mod_wsgi.txt delete mode 100644 requirements/ocsp.txt delete mode 100644 requirements/snappy.txt delete mode 100644 requirements/test.txt delete mode 100644 requirements/zstd.txt delete mode 100644 sbom.json delete mode 100644 setup.py delete mode 100644 strict_pyrightconfig.json delete mode 100644 test/__init__.py delete mode 100644 test/asynchronous/__init__.py delete mode 100644 test/asynchronous/conftest.py delete mode 100644 test/asynchronous/helpers.py delete mode 100644 test/asynchronous/pymongo_mocks.py delete mode 100644 test/asynchronous/qcheck.py delete mode 100644 test/asynchronous/test_async_cancellation.py delete mode 100644 test/asynchronous/test_async_contextvars_reset.py delete mode 100644 test/asynchronous/test_async_loop_safety.py delete mode 100644 test/asynchronous/test_async_loop_unblocked.py delete mode 100644 test/asynchronous/test_async_network_layer.py delete mode 100644 test/asynchronous/test_auth.py delete mode 100644 test/asynchronous/test_auth_oidc.py delete mode 100644 test/asynchronous/test_auth_spec.py delete mode 100644 test/asynchronous/test_bulk.py delete mode 100644 test/asynchronous/test_causal_consistency.py delete mode 100644 test/asynchronous/test_change_stream.py delete mode 100644 test/asynchronous/test_client.py delete mode 100644 test/asynchronous/test_client_backpressure.py delete mode 100644 test/asynchronous/test_client_bulk_write.py delete mode 100644 test/asynchronous/test_client_context.py delete mode 100644 test/asynchronous/test_client_metadata.py delete mode 100644 test/asynchronous/test_collation.py delete mode 100644 test/asynchronous/test_collection.py delete mode 100644 test/asynchronous/test_collection_management.py delete mode 100644 test/asynchronous/test_command_logging.py delete mode 100644 test/asynchronous/test_command_monitoring.py delete mode 100644 test/asynchronous/test_comment.py delete mode 100644 test/asynchronous/test_common.py delete mode 100644 test/asynchronous/test_concurrency.py delete mode 100644 test/asynchronous/test_connection_logging.py delete mode 100644 test/asynchronous/test_connection_monitoring.py delete mode 100644 test/asynchronous/test_connections_survive_primary_stepdown_spec.py delete mode 100644 test/asynchronous/test_create_entities.py delete mode 100644 test/asynchronous/test_crud_unified.py delete mode 100644 test/asynchronous/test_csot.py delete mode 100644 test/asynchronous/test_cursor.py delete mode 100644 test/asynchronous/test_custom_types.py delete mode 100644 test/asynchronous/test_database.py delete mode 100644 test/asynchronous/test_discovery_and_monitoring.py delete mode 100644 test/asynchronous/test_dns.py delete mode 100644 test/asynchronous/test_encryption.py delete mode 100644 test/asynchronous/test_examples.py delete mode 100644 test/asynchronous/test_grid_file.py delete mode 100644 test/asynchronous/test_gridfs.py delete mode 100644 test/asynchronous/test_gridfs_bucket.py delete mode 100644 test/asynchronous/test_gridfs_spec.py delete mode 100644 test/asynchronous/test_handshake_unified.py delete mode 100644 test/asynchronous/test_heartbeat_monitoring.py delete mode 100644 test/asynchronous/test_hello_latched.py delete mode 100644 test/asynchronous/test_index_management.py delete mode 100644 test/asynchronous/test_json_util_integration.py delete mode 100644 test/asynchronous/test_kms_connect_prose.py delete mode 100644 test/asynchronous/test_load_balancer.py delete mode 100644 test/asynchronous/test_locks.py delete mode 100644 test/asynchronous/test_logger.py delete mode 100644 test/asynchronous/test_max_staleness.py delete mode 100644 test/asynchronous/test_mongos_load_balancing.py delete mode 100644 test/asynchronous/test_monitor.py delete mode 100644 test/asynchronous/test_monitoring.py delete mode 100644 test/asynchronous/test_on_demand_csfle.py delete mode 100644 test/asynchronous/test_operation_id_retry.py delete mode 100644 test/asynchronous/test_periodic_executor.py delete mode 100644 test/asynchronous/test_pooling.py delete mode 100644 test/asynchronous/test_raw_bson.py delete mode 100644 test/asynchronous/test_read_concern.py delete mode 100644 test/asynchronous/test_read_preferences.py delete mode 100644 test/asynchronous/test_read_write_concern_spec.py delete mode 100644 test/asynchronous/test_retryable_reads.py delete mode 100644 test/asynchronous/test_retryable_reads_unified.py delete mode 100644 test/asynchronous/test_retryable_writes.py delete mode 100644 test/asynchronous/test_retryable_writes_unified.py delete mode 100644 test/asynchronous/test_run_command.py delete mode 100644 test/asynchronous/test_sdam_monitoring_spec.py delete mode 100644 test/asynchronous/test_server_selection.py delete mode 100644 test/asynchronous/test_server_selection_in_window.py delete mode 100644 test/asynchronous/test_server_selection_logging.py delete mode 100644 test/asynchronous/test_server_selection_rtt.py delete mode 100644 test/asynchronous/test_session.py delete mode 100644 test/asynchronous/test_sessions_unified.py delete mode 100644 test/asynchronous/test_sfp.py delete mode 100644 test/asynchronous/test_srv_polling.py delete mode 100644 test/asynchronous/test_ssl.py delete mode 100644 test/asynchronous/test_streaming_protocol.py delete mode 100644 test/asynchronous/test_subinterpreters.py delete mode 100644 test/asynchronous/test_transactions.py delete mode 100644 test/asynchronous/test_transactions_unified.py delete mode 100644 test/asynchronous/test_unified_format.py delete mode 100644 test/asynchronous/test_versioned_api_integration.py delete mode 100644 test/asynchronous/unified_format.py delete mode 100644 test/asynchronous/utils.py delete mode 100644 test/asynchronous/utils_selection_tests.py delete mode 100644 test/asynchronous/utils_spec_runner.py delete mode 100644 test/atlas/test_connection.py delete mode 100644 test/auth/legacy/connection-string.json delete mode 100644 test/auth/unified/mongodb-oidc-no-retry.json delete mode 100644 test/auth_aws/test_auth_aws.py delete mode 100644 test/bson_binary_vector/float32.json delete mode 100644 test/bson_binary_vector/int8.json delete mode 100644 test/bson_binary_vector/packed_bit.json delete mode 100644 test/bson_corpus/array.json delete mode 100644 test/bson_corpus/binary.json delete mode 100644 test/bson_corpus/boolean.json delete mode 100644 test/bson_corpus/code.json delete mode 100644 test/bson_corpus/code_w_scope.json delete mode 100644 test/bson_corpus/datetime.json delete mode 100644 test/bson_corpus/dbpointer.json delete mode 100644 test/bson_corpus/dbref.json delete mode 100644 test/bson_corpus/decimal128-1.json delete mode 100644 test/bson_corpus/decimal128-2.json delete mode 100644 test/bson_corpus/decimal128-3.json delete mode 100644 test/bson_corpus/decimal128-4.json delete mode 100644 test/bson_corpus/decimal128-5.json delete mode 100644 test/bson_corpus/decimal128-6.json delete mode 100644 test/bson_corpus/decimal128-7.json delete mode 100644 test/bson_corpus/document.json delete mode 100644 test/bson_corpus/double.json delete mode 100644 test/bson_corpus/int32.json delete mode 100644 test/bson_corpus/int64.json delete mode 100644 test/bson_corpus/maxkey.json delete mode 100644 test/bson_corpus/minkey.json delete mode 100644 test/bson_corpus/multi-type-deprecated.json delete mode 100644 test/bson_corpus/multi-type.json delete mode 100644 test/bson_corpus/null.json delete mode 100644 test/bson_corpus/oid.json delete mode 100644 test/bson_corpus/regex.json delete mode 100644 test/bson_corpus/string.json delete mode 100644 test/bson_corpus/symbol.json delete mode 100644 test/bson_corpus/timestamp.json delete mode 100644 test/bson_corpus/top.json delete mode 100644 test/bson_corpus/undefined.json delete mode 100644 test/causal_consistency/causal-consistency-clientBulkWrite.json delete mode 100644 test/causal_consistency/causal-consistency-write-commands.json delete mode 100644 test/certificates/ca.pem delete mode 100644 test/certificates/client.pem delete mode 100644 test/certificates/crl.pem delete mode 100644 test/certificates/password_protected.pem delete mode 100644 test/certificates/server.pem delete mode 100644 test/certificates/trusted-ca.pem delete mode 100644 test/change_streams/unified/change-streams-clusterTime.json delete mode 100644 test/change_streams/unified/change-streams-disambiguatedPaths.json delete mode 100644 test/change_streams/unified/change-streams-errors.json delete mode 100644 test/change_streams/unified/change-streams-nsType.json delete mode 100644 test/change_streams/unified/change-streams-pre_and_post_images.json delete mode 100644 test/change_streams/unified/change-streams-resume-allowlist.json delete mode 100644 test/change_streams/unified/change-streams-resume-errorLabels.json delete mode 100644 test/change_streams/unified/change-streams-showExpandedEvents.json delete mode 100644 test/change_streams/unified/change-streams.json delete mode 100644 test/client-backpressure/backpressure-connection-checkin.json delete mode 100644 test/client-backpressure/backpressure-retry-loop.json delete mode 100644 test/client-backpressure/backpressure-retry-max-attempts.json delete mode 100644 test/client-backpressure/getMore-retried.json delete mode 100644 test/client-side-encryption/corpus/corpus-encrypted.json delete mode 100644 test/client-side-encryption/corpus/corpus-key-aws.json delete mode 100644 test/client-side-encryption/corpus/corpus-key-azure.json delete mode 100644 test/client-side-encryption/corpus/corpus-key-gcp.json delete mode 100644 test/client-side-encryption/corpus/corpus-key-kmip.json delete mode 100644 test/client-side-encryption/corpus/corpus-key-local.json delete mode 100644 test/client-side-encryption/corpus/corpus-schema.json delete mode 100644 test/client-side-encryption/corpus/corpus.json delete mode 100644 test/client-side-encryption/custom/azure-dek.json delete mode 100644 test/client-side-encryption/custom/azure-gcp-schema.json delete mode 100644 test/client-side-encryption/custom/gcp-dek.json delete mode 100644 test/client-side-encryption/custom/key-document-local.json delete mode 100644 test/client-side-encryption/custom/schema.json delete mode 100644 test/client-side-encryption/etc/data/encryptedFields-c10.json delete mode 100644 test/client-side-encryption/etc/data/encryptedFields-prefix-suffix-ci-di.json delete mode 100644 test/client-side-encryption/etc/data/encryptedFields-prefix-suffix.json delete mode 100644 test/client-side-encryption/etc/data/encryptedFields-substring-ci-di.json delete mode 100644 test/client-side-encryption/etc/data/encryptedFields-substring.json delete mode 100644 test/client-side-encryption/etc/data/encryptedFields.json delete mode 100644 test/client-side-encryption/etc/data/keys/key1-document.json delete mode 100644 test/client-side-encryption/etc/data/keys/key1-id.json delete mode 100644 test/client-side-encryption/etc/data/keys/key2-document.json delete mode 100644 test/client-side-encryption/etc/data/keys/key2-id.json delete mode 100644 test/client-side-encryption/etc/data/lookup/key-doc.json delete mode 100644 test/client-side-encryption/etc/data/lookup/schema-csfle.json delete mode 100644 test/client-side-encryption/etc/data/lookup/schema-csfle2.json delete mode 100644 test/client-side-encryption/etc/data/lookup/schema-non-csfle.json delete mode 100644 test/client-side-encryption/etc/data/lookup/schema-qe.json delete mode 100644 test/client-side-encryption/etc/data/lookup/schema-qe2.json delete mode 100644 test/client-side-encryption/etc/data/range-encryptedFields-Date.json delete mode 100644 test/client-side-encryption/etc/data/range-encryptedFields-DecimalNoPrecision.json delete mode 100644 test/client-side-encryption/etc/data/range-encryptedFields-DecimalPrecision.json delete mode 100644 test/client-side-encryption/etc/data/range-encryptedFields-DoubleNoPrecision.json delete mode 100644 test/client-side-encryption/etc/data/range-encryptedFields-DoublePrecision.json delete mode 100644 test/client-side-encryption/etc/data/range-encryptedFields-Int.json delete mode 100644 test/client-side-encryption/etc/data/range-encryptedFields-Long.json delete mode 100644 test/client-side-encryption/external/external-key.json delete mode 100644 test/client-side-encryption/external/external-schema.json delete mode 100644 test/client-side-encryption/limits/limits-doc.json delete mode 100644 test/client-side-encryption/limits/limits-encryptedFields.json delete mode 100644 test/client-side-encryption/limits/limits-key.json delete mode 100644 test/client-side-encryption/limits/limits-qe-doc.json delete mode 100644 test/client-side-encryption/limits/limits-schema.json delete mode 100644 test/client-side-encryption/spec/legacy/aggregate.json delete mode 100644 test/client-side-encryption/spec/legacy/awsTemporary.json delete mode 100644 test/client-side-encryption/spec/legacy/azureKMS.json delete mode 100644 test/client-side-encryption/spec/legacy/badQueries.json delete mode 100644 test/client-side-encryption/spec/legacy/badSchema.json delete mode 100644 test/client-side-encryption/spec/legacy/basic.json delete mode 100644 test/client-side-encryption/spec/legacy/bulk.json delete mode 100644 test/client-side-encryption/spec/legacy/bypassAutoEncryption.json delete mode 100644 test/client-side-encryption/spec/legacy/bypassedCommand.json delete mode 100644 test/client-side-encryption/spec/legacy/count.json delete mode 100644 test/client-side-encryption/spec/legacy/countDocuments.json delete mode 100644 test/client-side-encryption/spec/legacy/create-and-createIndexes.json delete mode 100644 test/client-side-encryption/spec/legacy/delete.json delete mode 100644 test/client-side-encryption/spec/legacy/distinct.json delete mode 100644 test/client-side-encryption/spec/legacy/explain.json delete mode 100644 test/client-side-encryption/spec/legacy/find.json delete mode 100644 test/client-side-encryption/spec/legacy/findOneAndDelete.json delete mode 100644 test/client-side-encryption/spec/legacy/findOneAndReplace.json delete mode 100644 test/client-side-encryption/spec/legacy/findOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-BypassQueryAnalysis.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Compact.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-CreateCollection-OldServer.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-CreateCollection.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-DecryptExistingData.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Delete.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-EncryptedFields-vs-EncryptedFieldsMap.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-EncryptedFields-vs-jsonSchema.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-EncryptedFieldsMap-defaults.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-InsertFind-Indexed.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-InsertFind-Unindexed.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-MissingKey.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-NoEncryption.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Compact.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Date-Aggregate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Date-Correctness.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Date-Delete.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Date-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Date-InsertFind.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Date-Update.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Decimal-Aggregate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Decimal-Correctness.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Decimal-Delete.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Decimal-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Decimal-InsertFind.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Decimal-Update.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-DecimalPrecision-Aggregate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-DecimalPrecision-Correctness.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-DecimalPrecision-Delete.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-DecimalPrecision-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-DecimalPrecision-InsertFind.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-DecimalPrecision-Update.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Defaults.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Double-Aggregate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Double-Correctness.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Double-Delete.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Double-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Double-InsertFind.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Double-Update.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-DoublePrecision-Aggregate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-DoublePrecision-Correctness.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-DoublePrecision-Delete.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-DoublePrecision-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-DoublePrecision-InsertFind.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-DoublePrecision-Update.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Int-Aggregate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Int-Correctness.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Int-Delete.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Int-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Int-InsertFind.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Int-Update.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Long-Aggregate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Long-Correctness.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Long-Delete.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Long-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Long-InsertFind.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-Long-Update.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Rangev2-WrongType.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-Update.json delete mode 100644 test/client-side-encryption/spec/legacy/fle2v2-validatorAndPartialFieldExpression.json delete mode 100644 test/client-side-encryption/spec/legacy/gcpKMS.json delete mode 100644 test/client-side-encryption/spec/legacy/getMore.json delete mode 100644 test/client-side-encryption/spec/legacy/insert.json delete mode 100644 test/client-side-encryption/spec/legacy/keyAltName.json delete mode 100644 test/client-side-encryption/spec/legacy/keyCache.json delete mode 100644 test/client-side-encryption/spec/legacy/kmipKMS.json delete mode 100644 test/client-side-encryption/spec/legacy/localKMS.json delete mode 100644 test/client-side-encryption/spec/legacy/localSchema.json delete mode 100644 test/client-side-encryption/spec/legacy/malformedCiphertext.json delete mode 100644 test/client-side-encryption/spec/legacy/missingKey.json delete mode 100644 test/client-side-encryption/spec/legacy/namedKMS.json delete mode 100644 test/client-side-encryption/spec/legacy/noSchema.json delete mode 100644 test/client-side-encryption/spec/legacy/replaceOne.json delete mode 100644 test/client-side-encryption/spec/legacy/timeoutMS.json delete mode 100644 test/client-side-encryption/spec/legacy/types.json delete mode 100644 test/client-side-encryption/spec/legacy/unsupportedCommand.json delete mode 100644 test/client-side-encryption/spec/legacy/updateMany.json delete mode 100644 test/client-side-encryption/spec/legacy/updateOne.json delete mode 100644 test/client-side-encryption/spec/legacy/validatorAndPartialFieldExpression.json delete mode 100644 test/client-side-encryption/spec/unified/QE-Text-cleanupStructuredEncryptionData.json delete mode 100644 test/client-side-encryption/spec/unified/QE-Text-compactStructuredEncryptionData.json delete mode 100644 test/client-side-encryption/spec/unified/QE-Text-prefix.json delete mode 100644 test/client-side-encryption/spec/unified/QE-Text-substring.json delete mode 100644 test/client-side-encryption/spec/unified/QE-Text-suffix.json delete mode 100644 test/client-side-encryption/spec/unified/addKeyAltName.json delete mode 100644 test/client-side-encryption/spec/unified/aggregate.json delete mode 100644 test/client-side-encryption/spec/unified/awsTemporary.json delete mode 100644 test/client-side-encryption/spec/unified/azureKMS.json delete mode 100644 test/client-side-encryption/spec/unified/badQueries.json delete mode 100644 test/client-side-encryption/spec/unified/badSchema.json delete mode 100644 test/client-side-encryption/spec/unified/basic.json delete mode 100644 test/client-side-encryption/spec/unified/bulk.json delete mode 100644 test/client-side-encryption/spec/unified/bypassAutoEncryption.json delete mode 100644 test/client-side-encryption/spec/unified/bypassedCommand.json delete mode 100644 test/client-side-encryption/spec/unified/count.json delete mode 100644 test/client-side-encryption/spec/unified/countDocuments.json delete mode 100644 test/client-side-encryption/spec/unified/create-and-createIndexes.json delete mode 100644 test/client-side-encryption/spec/unified/createDataKey-kms_providers-invalid.json delete mode 100644 test/client-side-encryption/spec/unified/createDataKey.json delete mode 100644 test/client-side-encryption/spec/unified/delete.json delete mode 100644 test/client-side-encryption/spec/unified/deleteKey.json delete mode 100644 test/client-side-encryption/spec/unified/distinct.json delete mode 100644 test/client-side-encryption/spec/unified/explain.json delete mode 100644 test/client-side-encryption/spec/unified/find.json delete mode 100644 test/client-side-encryption/spec/unified/findOneAndDelete.json delete mode 100644 test/client-side-encryption/spec/unified/findOneAndReplace.json delete mode 100644 test/client-side-encryption/spec/unified/findOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-BypassQueryAnalysis.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Compact.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-CreateCollection-OldServer.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-CreateCollection.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-DecryptExistingData.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Delete.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-EncryptedFields-vs-EncryptedFieldsMap.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-EncryptedFields-vs-jsonSchema.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-EncryptedFieldsMap-defaults.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-InsertFind-Indexed.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-InsertFind-Unindexed.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-InsertFind-keyAltName.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-MissingKey.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-NoEncryption.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Compact.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Date-Aggregate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Date-Correctness.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Date-Delete.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Date-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Date-InsertFind.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Date-Update.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Decimal-Aggregate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Decimal-Correctness.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Decimal-Delete.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Decimal-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Decimal-InsertFind.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Decimal-Update.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-DecimalPrecision-Aggregate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-DecimalPrecision-Correctness.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-DecimalPrecision-Delete.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-DecimalPrecision-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-DecimalPrecision-InsertFind.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-DecimalPrecision-Update.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Defaults.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Double-Aggregate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Double-Correctness.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Double-Delete.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Double-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Double-InsertFind.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Double-Update.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-DoublePrecision-Aggregate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-DoublePrecision-Correctness.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-DoublePrecision-Delete.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-DoublePrecision-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-DoublePrecision-InsertFind.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-DoublePrecision-Update.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Int-Aggregate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Int-Correctness.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Int-Delete.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Int-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Int-InsertFind.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Int-Update.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Long-Aggregate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Long-Correctness.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Long-Delete.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Long-FindOneAndUpdate.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Long-InsertFind.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-Long-Update.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Rangev2-WrongType.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-Update.json delete mode 100644 test/client-side-encryption/spec/unified/fle2v2-validatorAndPartialFieldExpression.json delete mode 100644 test/client-side-encryption/spec/unified/gcpKMS.json delete mode 100644 test/client-side-encryption/spec/unified/getKey.json delete mode 100644 test/client-side-encryption/spec/unified/getKeyByAltName.json delete mode 100644 test/client-side-encryption/spec/unified/getKeys.json delete mode 100644 test/client-side-encryption/spec/unified/getMore.json delete mode 100644 test/client-side-encryption/spec/unified/insert.json delete mode 100644 test/client-side-encryption/spec/unified/keyAltName.json delete mode 100644 test/client-side-encryption/spec/unified/keyCache.json delete mode 100644 test/client-side-encryption/spec/unified/kmipKMS.json delete mode 100644 test/client-side-encryption/spec/unified/localKMS.json delete mode 100644 test/client-side-encryption/spec/unified/localSchema.json delete mode 100644 test/client-side-encryption/spec/unified/malformedCiphertext.json delete mode 100644 test/client-side-encryption/spec/unified/missingKey.json delete mode 100644 test/client-side-encryption/spec/unified/namedKMS-createDataKey.json delete mode 100644 test/client-side-encryption/spec/unified/namedKMS-explicit.json delete mode 100644 test/client-side-encryption/spec/unified/namedKMS-rewrapManyDataKey.json delete mode 100644 test/client-side-encryption/spec/unified/namedKMS.json delete mode 100644 test/client-side-encryption/spec/unified/noSchema.json delete mode 100644 test/client-side-encryption/spec/unified/removeKeyAltName.json delete mode 100644 test/client-side-encryption/spec/unified/replaceOne.json delete mode 100644 test/client-side-encryption/spec/unified/rewrapManyDataKey-decrypt_failure.json delete mode 100644 test/client-side-encryption/spec/unified/rewrapManyDataKey-encrypt_failure.json delete mode 100644 test/client-side-encryption/spec/unified/rewrapManyDataKey.json delete mode 100644 test/client-side-encryption/spec/unified/timeoutMS.json delete mode 100644 test/client-side-encryption/spec/unified/types.json delete mode 100644 test/client-side-encryption/spec/unified/unsupportedCommand.json delete mode 100644 test/client-side-encryption/spec/unified/updateMany.json delete mode 100644 test/client-side-encryption/spec/unified/updateOne.json delete mode 100644 test/client-side-encryption/spec/unified/validatorAndPartialFieldExpression.json delete mode 100644 test/collection_management/clustered-indexes.json delete mode 100644 test/collection_management/createCollection-pre_and_post_images.json delete mode 100644 test/collection_management/timeseries-collection.json delete mode 100644 test/command_logging/command.json delete mode 100644 test/command_logging/driver-connection-id.json delete mode 100644 test/command_logging/no-handshake-messages.json delete mode 100644 test/command_logging/no-heartbeat-messages.json delete mode 100644 test/command_logging/operation-id.json delete mode 100644 test/command_logging/redacted-commands.json delete mode 100644 test/command_logging/server-connection-id.json delete mode 100644 test/command_logging/service-id.json delete mode 100644 test/command_logging/unacknowledged-write.json delete mode 100644 test/command_monitoring/bulkWrite.json delete mode 100644 test/command_monitoring/command.json delete mode 100644 test/command_monitoring/deleteMany.json delete mode 100644 test/command_monitoring/deleteOne.json delete mode 100644 test/command_monitoring/find.json delete mode 100644 test/command_monitoring/insertMany.json delete mode 100644 test/command_monitoring/insertOne.json delete mode 100644 test/command_monitoring/redacted-commands.json delete mode 100644 test/command_monitoring/server-connection-id.json delete mode 100644 test/command_monitoring/unacknowledged-client-bulkWrite.json delete mode 100644 test/command_monitoring/unacknowledgedBulkWrite.json delete mode 100644 test/command_monitoring/updateMany.json delete mode 100644 test/command_monitoring/updateOne.json delete mode 100644 test/command_monitoring/writeConcernError.json delete mode 100644 test/conftest.py delete mode 100644 test/connection_logging/connection-logging.json delete mode 100644 test/connection_logging/connection-pool-options.json delete mode 100644 test/connection_monitoring/connection-must-have-id.json delete mode 100644 test/connection_monitoring/connection-must-order-ids.json delete mode 100644 test/connection_monitoring/pool-checkin-destroy-closed.json delete mode 100644 test/connection_monitoring/pool-checkin-destroy-stale.json delete mode 100644 test/connection_monitoring/pool-checkin-make-available.json delete mode 100644 test/connection_monitoring/pool-checkin.json delete mode 100644 test/connection_monitoring/pool-checkout-connection.json delete mode 100644 test/connection_monitoring/pool-checkout-custom-maxConnecting-is-enforced.json delete mode 100644 test/connection_monitoring/pool-checkout-error-closed.json delete mode 100644 test/connection_monitoring/pool-checkout-maxConnecting-is-enforced.json delete mode 100644 test/connection_monitoring/pool-checkout-maxConnecting-timeout.json delete mode 100644 test/connection_monitoring/pool-checkout-minPoolSize-connection-maxConnecting.json delete mode 100644 test/connection_monitoring/pool-checkout-multiple.json delete mode 100644 test/connection_monitoring/pool-checkout-no-idle.json delete mode 100644 test/connection_monitoring/pool-checkout-no-stale.json delete mode 100644 test/connection_monitoring/pool-checkout-returned-connection-maxConnecting.json delete mode 100644 test/connection_monitoring/pool-clear-clears-waitqueue.json delete mode 100644 test/connection_monitoring/pool-clear-interrupting-pending-connections.json delete mode 100644 test/connection_monitoring/pool-clear-min-size.json delete mode 100644 test/connection_monitoring/pool-clear-paused.json delete mode 100644 test/connection_monitoring/pool-clear-ready.json delete mode 100644 test/connection_monitoring/pool-clear-schedule-run-interruptInUseConnections-false.json delete mode 100644 test/connection_monitoring/pool-close-destroy-conns.json delete mode 100644 test/connection_monitoring/pool-close.json delete mode 100644 test/connection_monitoring/pool-create-max-size.json delete mode 100644 test/connection_monitoring/pool-create-min-size-error.json delete mode 100644 test/connection_monitoring/pool-create-min-size.json delete mode 100644 test/connection_monitoring/pool-create-with-options.json delete mode 100644 test/connection_monitoring/pool-create.json delete mode 100644 test/connection_monitoring/pool-ready-ready.json delete mode 100644 test/connection_monitoring/pool-ready.json delete mode 100644 test/connection_monitoring/wait-queue-timeout.json delete mode 100644 test/connection_string/test/invalid-uris.json delete mode 100644 test/connection_string/test/valid-auth.json delete mode 100644 test/connection_string/test/valid-db-with-dotted-name.json delete mode 100644 test/connection_string/test/valid-host_identifiers.json delete mode 100644 test/connection_string/test/valid-options.json delete mode 100644 test/connection_string/test/valid-unix_socket-absolute.json delete mode 100644 test/connection_string/test/valid-unix_socket-relative.json delete mode 100644 test/connection_string/test/valid-warnings.json delete mode 100644 test/crud/unified/aggregate-allowdiskuse.json delete mode 100644 test/crud/unified/aggregate-collation.json delete mode 100644 test/crud/unified/aggregate-let.json delete mode 100644 test/crud/unified/aggregate-merge-errorResponse.json delete mode 100644 test/crud/unified/aggregate-merge.json delete mode 100644 test/crud/unified/aggregate-out-readConcern.json delete mode 100644 test/crud/unified/aggregate-out.json delete mode 100644 test/crud/unified/aggregate-write-readPreference.json delete mode 100644 test/crud/unified/aggregate.json delete mode 100644 test/crud/unified/bulkWrite-arrayFilters.json delete mode 100644 test/crud/unified/bulkWrite-collation.json delete mode 100644 test/crud/unified/bulkWrite-comment.json delete mode 100644 test/crud/unified/bulkWrite-delete-hint-serverError.json delete mode 100644 test/crud/unified/bulkWrite-delete-hint.json delete mode 100644 test/crud/unified/bulkWrite-deleteMany-hint-unacknowledged.json delete mode 100644 test/crud/unified/bulkWrite-deleteMany-let.json delete mode 100644 test/crud/unified/bulkWrite-deleteOne-hint-unacknowledged.json delete mode 100644 test/crud/unified/bulkWrite-deleteOne-let.json delete mode 100644 test/crud/unified/bulkWrite-errorResponse.json delete mode 100644 test/crud/unified/bulkWrite-insertOne-dots_and_dollars.json delete mode 100644 test/crud/unified/bulkWrite-replaceOne-dots_and_dollars.json delete mode 100644 test/crud/unified/bulkWrite-replaceOne-hint-unacknowledged.json delete mode 100644 test/crud/unified/bulkWrite-replaceOne-let.json delete mode 100644 test/crud/unified/bulkWrite-replaceOne-sort.json delete mode 100644 test/crud/unified/bulkWrite-update-hint.json delete mode 100644 test/crud/unified/bulkWrite-update-validation.json delete mode 100644 test/crud/unified/bulkWrite-updateMany-dots_and_dollars.json delete mode 100644 test/crud/unified/bulkWrite-updateMany-hint-unacknowledged.json delete mode 100644 test/crud/unified/bulkWrite-updateMany-let.json delete mode 100644 test/crud/unified/bulkWrite-updateMany-pipeline.json delete mode 100644 test/crud/unified/bulkWrite-updateOne-dots_and_dollars.json delete mode 100644 test/crud/unified/bulkWrite-updateOne-hint-unacknowledged.json delete mode 100644 test/crud/unified/bulkWrite-updateOne-let.json delete mode 100644 test/crud/unified/bulkWrite-updateOne-pipeline.json delete mode 100644 test/crud/unified/bulkWrite-updateOne-sort.json delete mode 100644 test/crud/unified/bulkWrite.json delete mode 100644 test/crud/unified/bypassDocumentValidation.json delete mode 100644 test/crud/unified/client-bulkWrite-delete-options.json delete mode 100644 test/crud/unified/client-bulkWrite-errorResponse.json delete mode 100644 test/crud/unified/client-bulkWrite-errors.json delete mode 100644 test/crud/unified/client-bulkWrite-mixed-namespaces.json delete mode 100644 test/crud/unified/client-bulkWrite-options.json delete mode 100644 test/crud/unified/client-bulkWrite-ordered.json delete mode 100644 test/crud/unified/client-bulkWrite-partialResults.json delete mode 100644 test/crud/unified/client-bulkWrite-replaceOne-sort.json delete mode 100644 test/crud/unified/client-bulkWrite-results.json delete mode 100644 test/crud/unified/client-bulkWrite-update-options.json delete mode 100644 test/crud/unified/client-bulkWrite-update-pipeline.json delete mode 100644 test/crud/unified/client-bulkWrite-update-validation.json delete mode 100644 test/crud/unified/client-bulkWrite-updateOne-sort.json delete mode 100644 test/crud/unified/count-collation.json delete mode 100644 test/crud/unified/count-empty.json delete mode 100644 test/crud/unified/count.json delete mode 100644 test/crud/unified/countDocuments-comment.json delete mode 100644 test/crud/unified/create-null-ids.json delete mode 100644 test/crud/unified/db-aggregate-write-readPreference.json delete mode 100644 test/crud/unified/db-aggregate.json delete mode 100644 test/crud/unified/deleteMany-collation.json delete mode 100644 test/crud/unified/deleteMany-comment.json delete mode 100644 test/crud/unified/deleteMany-hint-serverError.json delete mode 100644 test/crud/unified/deleteMany-hint-unacknowledged.json delete mode 100644 test/crud/unified/deleteMany-hint.json delete mode 100644 test/crud/unified/deleteMany-let.json delete mode 100644 test/crud/unified/deleteMany.json delete mode 100644 test/crud/unified/deleteOne-collation.json delete mode 100644 test/crud/unified/deleteOne-comment.json delete mode 100644 test/crud/unified/deleteOne-errorResponse.json delete mode 100644 test/crud/unified/deleteOne-hint-serverError.json delete mode 100644 test/crud/unified/deleteOne-hint-unacknowledged.json delete mode 100644 test/crud/unified/deleteOne-hint.json delete mode 100644 test/crud/unified/deleteOne-let.json delete mode 100644 test/crud/unified/deleteOne.json delete mode 100644 test/crud/unified/distinct-collation.json delete mode 100644 test/crud/unified/distinct-comment.json delete mode 100644 test/crud/unified/distinct-hint.json delete mode 100644 test/crud/unified/distinct.json delete mode 100644 test/crud/unified/estimatedDocumentCount-comment.json delete mode 100644 test/crud/unified/estimatedDocumentCount.json delete mode 100644 test/crud/unified/find-allowdiskuse-serverError.json delete mode 100644 test/crud/unified/find-allowdiskuse.json delete mode 100644 test/crud/unified/find-collation.json delete mode 100644 test/crud/unified/find-comment.json delete mode 100644 test/crud/unified/find-let.json delete mode 100644 test/crud/unified/find.json delete mode 100644 test/crud/unified/findOne.json delete mode 100644 test/crud/unified/findOneAndDelete-collation.json delete mode 100644 test/crud/unified/findOneAndDelete-comment.json delete mode 100644 test/crud/unified/findOneAndDelete-hint-serverError.json delete mode 100644 test/crud/unified/findOneAndDelete-hint-unacknowledged.json delete mode 100644 test/crud/unified/findOneAndDelete-hint.json delete mode 100644 test/crud/unified/findOneAndDelete-let.json delete mode 100644 test/crud/unified/findOneAndDelete.json delete mode 100644 test/crud/unified/findOneAndReplace-collation.json delete mode 100644 test/crud/unified/findOneAndReplace-comment.json delete mode 100644 test/crud/unified/findOneAndReplace-dots_and_dollars.json delete mode 100644 test/crud/unified/findOneAndReplace-hint-serverError.json delete mode 100644 test/crud/unified/findOneAndReplace-hint-unacknowledged.json delete mode 100644 test/crud/unified/findOneAndReplace-hint.json delete mode 100644 test/crud/unified/findOneAndReplace-let.json delete mode 100644 test/crud/unified/findOneAndReplace-upsert.json delete mode 100644 test/crud/unified/findOneAndReplace.json delete mode 100644 test/crud/unified/findOneAndUpdate-arrayFilters.json delete mode 100644 test/crud/unified/findOneAndUpdate-collation.json delete mode 100644 test/crud/unified/findOneAndUpdate-comment.json delete mode 100644 test/crud/unified/findOneAndUpdate-dots_and_dollars.json delete mode 100644 test/crud/unified/findOneAndUpdate-errorResponse.json delete mode 100644 test/crud/unified/findOneAndUpdate-hint-serverError.json delete mode 100644 test/crud/unified/findOneAndUpdate-hint-unacknowledged.json delete mode 100644 test/crud/unified/findOneAndUpdate-hint.json delete mode 100644 test/crud/unified/findOneAndUpdate-let.json delete mode 100644 test/crud/unified/findOneAndUpdate-pipeline.json delete mode 100644 test/crud/unified/findOneAndUpdate.json delete mode 100644 test/crud/unified/insertMany-comment.json delete mode 100644 test/crud/unified/insertMany-dots_and_dollars.json delete mode 100644 test/crud/unified/insertMany.json delete mode 100644 test/crud/unified/insertOne-comment.json delete mode 100644 test/crud/unified/insertOne-dots_and_dollars.json delete mode 100644 test/crud/unified/insertOne-errorResponse.json delete mode 100644 test/crud/unified/insertOne.json delete mode 100644 test/crud/unified/replaceOne-collation.json delete mode 100644 test/crud/unified/replaceOne-comment.json delete mode 100644 test/crud/unified/replaceOne-dots_and_dollars.json delete mode 100644 test/crud/unified/replaceOne-hint-unacknowledged.json delete mode 100644 test/crud/unified/replaceOne-hint.json delete mode 100644 test/crud/unified/replaceOne-let.json delete mode 100644 test/crud/unified/replaceOne-sort.json delete mode 100644 test/crud/unified/replaceOne-validation.json delete mode 100644 test/crud/unified/replaceOne.json delete mode 100644 test/crud/unified/updateMany-arrayFilters.json delete mode 100644 test/crud/unified/updateMany-collation.json delete mode 100644 test/crud/unified/updateMany-comment.json delete mode 100644 test/crud/unified/updateMany-dots_and_dollars.json delete mode 100644 test/crud/unified/updateMany-hint-unacknowledged.json delete mode 100644 test/crud/unified/updateMany-hint.json delete mode 100644 test/crud/unified/updateMany-let.json delete mode 100644 test/crud/unified/updateMany-pipeline.json delete mode 100644 test/crud/unified/updateMany-validation.json delete mode 100644 test/crud/unified/updateMany.json delete mode 100644 test/crud/unified/updateOne-arrayFilters.json delete mode 100644 test/crud/unified/updateOne-collation.json delete mode 100644 test/crud/unified/updateOne-comment.json delete mode 100644 test/crud/unified/updateOne-dots_and_dollars.json delete mode 100644 test/crud/unified/updateOne-errorResponse.json delete mode 100644 test/crud/unified/updateOne-hint-unacknowledged.json delete mode 100644 test/crud/unified/updateOne-hint.json delete mode 100644 test/crud/unified/updateOne-let.json delete mode 100644 test/crud/unified/updateOne-pipeline.json delete mode 100644 test/crud/unified/updateOne-sort.json delete mode 100644 test/crud/unified/updateOne-validation.json delete mode 100644 test/crud/unified/updateOne.json delete mode 100644 test/csot/bulkWrite.json delete mode 100644 test/csot/change-streams.json delete mode 100644 test/csot/close-cursors.json delete mode 100644 test/csot/command-execution.json delete mode 100644 test/csot/convenient-transactions.json delete mode 100644 test/csot/cursors.json delete mode 100644 test/csot/deprecated-options.json delete mode 100644 test/csot/error-transformations.json delete mode 100644 test/csot/global-timeoutMS.json delete mode 100644 test/csot/gridfs-advanced.json delete mode 100644 test/csot/gridfs-delete.json delete mode 100644 test/csot/gridfs-download.json delete mode 100644 test/csot/gridfs-find.json delete mode 100644 test/csot/gridfs-upload.json delete mode 100644 test/csot/legacy-timeouts.json delete mode 100644 test/csot/non-tailable-cursors.json delete mode 100644 test/csot/override-operation-timeoutMS.json delete mode 100644 test/csot/retryability-legacy-timeouts.json delete mode 100644 test/csot/retryability-timeoutMS.json delete mode 100644 test/csot/runCursorCommand.json delete mode 100644 test/csot/sessions-inherit-timeoutMS.json delete mode 100644 test/csot/sessions-override-operation-timeoutMS.json delete mode 100644 test/csot/sessions-override-timeoutMS.json delete mode 100644 test/csot/tailable-awaitData.json delete mode 100644 test/csot/tailable-non-awaitData.json delete mode 100644 test/csot/waitQueueTimeout.json delete mode 100644 test/data_lake/unified/aggregate.json delete mode 100644 test/data_lake/unified/estimatedDocumentCount.json delete mode 100644 test/data_lake/unified/find.json delete mode 100644 test/data_lake/unified/getMore.json delete mode 100644 test/data_lake/unified/listCollections.json delete mode 100644 test/data_lake/unified/listDatabases.json delete mode 100644 test/data_lake/unified/runCommand.json delete mode 100644 test/discovery_and_monitoring/errors/error_handling_handshake.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-network-error.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-network-timeout-error.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-greater-InterruptedAtShutdown.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-greater-InterruptedDueToReplStateChange.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-greater-LegacyNotPrimary.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-greater-NotPrimaryNoSecondaryOk.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-greater-NotPrimaryOrSecondary.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-greater-NotWritablePrimary.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-greater-PrimarySteppedDown.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-greater-ShutdownInProgress.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-missing-InterruptedAtShutdown.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-missing-InterruptedDueToReplStateChange.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-missing-LegacyNotPrimary.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-missing-NotPrimaryNoSecondaryOk.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-missing-NotPrimaryOrSecondary.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-missing-NotWritablePrimary.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-missing-PrimarySteppedDown.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-missing-ShutdownInProgress.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-proccessId-changed-InterruptedAtShutdown.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-proccessId-changed-InterruptedDueToReplStateChange.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-proccessId-changed-LegacyNotPrimary.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-proccessId-changed-NotPrimaryNoSecondaryOk.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-proccessId-changed-NotPrimaryOrSecondary.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-proccessId-changed-NotWritablePrimary.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-proccessId-changed-PrimarySteppedDown.json delete mode 100644 test/discovery_and_monitoring/errors/non-stale-topologyVersion-proccessId-changed-ShutdownInProgress.json delete mode 100644 test/discovery_and_monitoring/errors/post-42-InterruptedAtShutdown.json delete mode 100644 test/discovery_and_monitoring/errors/post-42-InterruptedDueToReplStateChange.json delete mode 100644 test/discovery_and_monitoring/errors/post-42-LegacyNotPrimary.json delete mode 100644 test/discovery_and_monitoring/errors/post-42-NotPrimaryNoSecondaryOk.json delete mode 100644 test/discovery_and_monitoring/errors/post-42-NotPrimaryOrSecondary.json delete mode 100644 test/discovery_and_monitoring/errors/post-42-NotWritablePrimary.json delete mode 100644 test/discovery_and_monitoring/errors/post-42-PrimarySteppedDown.json delete mode 100644 test/discovery_and_monitoring/errors/post-42-ShutdownInProgress.json delete mode 100644 test/discovery_and_monitoring/errors/prefer-error-code.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-InterruptedAtShutdown.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-InterruptedDueToReplStateChange.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-NotPrimaryNoSecondaryOk.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-NotPrimaryOrSecondary.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-NotWritablePrimary.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-PrimarySteppedDown.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-ShutdownInProgress.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-afterHandshakeCompletes-InterruptedAtShutdown.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-afterHandshakeCompletes-InterruptedDueToReplStateChange.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-afterHandshakeCompletes-LegacyNotPrimary.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-afterHandshakeCompletes-NotPrimaryNoSecondaryOk.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-afterHandshakeCompletes-NotPrimaryOrSecondary.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-afterHandshakeCompletes-NotWritablePrimary.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-afterHandshakeCompletes-PrimarySteppedDown.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-afterHandshakeCompletes-ShutdownInProgress.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-afterHandshakeCompletes-network.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-afterHandshakeCompletes-timeout.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-beforeHandshakeCompletes-InterruptedAtShutdown.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-beforeHandshakeCompletes-InterruptedDueToReplStateChange.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-beforeHandshakeCompletes-LegacyNotPrimary.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-beforeHandshakeCompletes-NotPrimaryNoSecondaryOk.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-beforeHandshakeCompletes-NotPrimaryOrSecondary.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-beforeHandshakeCompletes-NotWritablePrimary.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-beforeHandshakeCompletes-PrimarySteppedDown.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-beforeHandshakeCompletes-ShutdownInProgress.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-beforeHandshakeCompletes-network.json delete mode 100644 test/discovery_and_monitoring/errors/stale-generation-beforeHandshakeCompletes-timeout.json delete mode 100644 test/discovery_and_monitoring/errors/stale-topologyVersion-InterruptedAtShutdown.json delete mode 100644 test/discovery_and_monitoring/errors/stale-topologyVersion-InterruptedDueToReplStateChange.json delete mode 100644 test/discovery_and_monitoring/errors/stale-topologyVersion-LegacyNotPrimary.json delete mode 100644 test/discovery_and_monitoring/errors/stale-topologyVersion-NotPrimaryNoSecondaryOk.json delete mode 100644 test/discovery_and_monitoring/errors/stale-topologyVersion-NotPrimaryOrSecondary.json delete mode 100644 test/discovery_and_monitoring/errors/stale-topologyVersion-NotWritablePrimary.json delete mode 100644 test/discovery_and_monitoring/errors/stale-topologyVersion-PrimarySteppedDown.json delete mode 100644 test/discovery_and_monitoring/errors/stale-topologyVersion-ShutdownInProgress.json delete mode 100644 test/discovery_and_monitoring/errors/write_errors_ignored.json delete mode 100644 test/discovery_and_monitoring/load-balanced/discover_load_balancer.json delete mode 100644 test/discovery_and_monitoring/rs/compatible.json delete mode 100644 test/discovery_and_monitoring/rs/compatible_unknown.json delete mode 100644 test/discovery_and_monitoring/rs/disaggregated_storage_setversion.json delete mode 100644 test/discovery_and_monitoring/rs/discover_arbiters.json delete mode 100644 test/discovery_and_monitoring/rs/discover_arbiters_replicaset.json delete mode 100644 test/discovery_and_monitoring/rs/discover_ghost.json delete mode 100644 test/discovery_and_monitoring/rs/discover_ghost_replicaset.json delete mode 100644 test/discovery_and_monitoring/rs/discover_hidden.json delete mode 100644 test/discovery_and_monitoring/rs/discover_hidden_replicaset.json delete mode 100644 test/discovery_and_monitoring/rs/discover_passives.json delete mode 100644 test/discovery_and_monitoring/rs/discover_passives_replicaset.json delete mode 100644 test/discovery_and_monitoring/rs/discover_primary.json delete mode 100644 test/discovery_and_monitoring/rs/discover_primary_replicaset.json delete mode 100644 test/discovery_and_monitoring/rs/discover_rsother.json delete mode 100644 test/discovery_and_monitoring/rs/discover_rsother_replicaset.json delete mode 100644 test/discovery_and_monitoring/rs/discover_secondary.json delete mode 100644 test/discovery_and_monitoring/rs/discover_secondary_replicaset.json delete mode 100644 test/discovery_and_monitoring/rs/discovery.json delete mode 100644 test/discovery_and_monitoring/rs/electionId_precedence_setVersion.json delete mode 100644 test/discovery_and_monitoring/rs/equal_electionids.json delete mode 100644 test/discovery_and_monitoring/rs/hosts_differ_from_seeds.json delete mode 100644 test/discovery_and_monitoring/rs/incompatible_arbiter.json delete mode 100644 test/discovery_and_monitoring/rs/incompatible_ghost.json delete mode 100644 test/discovery_and_monitoring/rs/incompatible_other.json delete mode 100644 test/discovery_and_monitoring/rs/ls_timeout.json delete mode 100644 test/discovery_and_monitoring/rs/member_list_update_with_unchanged_setversion_and_electionid.json delete mode 100644 test/discovery_and_monitoring/rs/member_reconfig.json delete mode 100644 test/discovery_and_monitoring/rs/member_standalone.json delete mode 100644 test/discovery_and_monitoring/rs/migration_from_disaggregated_storage.json delete mode 100644 test/discovery_and_monitoring/rs/migration_to_disaggregated_storage.json delete mode 100644 test/discovery_and_monitoring/rs/new_primary.json delete mode 100644 test/discovery_and_monitoring/rs/new_primary_new_electionid.json delete mode 100644 test/discovery_and_monitoring/rs/new_primary_new_setversion.json delete mode 100644 test/discovery_and_monitoring/rs/new_primary_wrong_set_name.json delete mode 100644 test/discovery_and_monitoring/rs/non_rs_member.json delete mode 100644 test/discovery_and_monitoring/rs/normalize_case.json delete mode 100644 test/discovery_and_monitoring/rs/normalize_case_me.json delete mode 100644 test/discovery_and_monitoring/rs/null_election_id-pre-6.0.json delete mode 100644 test/discovery_and_monitoring/rs/null_election_id.json delete mode 100644 test/discovery_and_monitoring/rs/primary_becomes_ghost.json delete mode 100644 test/discovery_and_monitoring/rs/primary_becomes_mongos.json delete mode 100644 test/discovery_and_monitoring/rs/primary_becomes_standalone.json delete mode 100644 test/discovery_and_monitoring/rs/primary_changes_set_name.json delete mode 100644 test/discovery_and_monitoring/rs/primary_disconnect.json delete mode 100644 test/discovery_and_monitoring/rs/primary_disconnect_electionid.json delete mode 100644 test/discovery_and_monitoring/rs/primary_disconnect_setversion.json delete mode 100644 test/discovery_and_monitoring/rs/primary_hint_from_secondary_with_mismatched_me.json delete mode 100644 test/discovery_and_monitoring/rs/primary_mismatched_me.json delete mode 100644 test/discovery_and_monitoring/rs/primary_mismatched_me_not_removed.json delete mode 100644 test/discovery_and_monitoring/rs/primary_reports_new_member.json delete mode 100644 test/discovery_and_monitoring/rs/primary_to_no_primary_mismatched_me.json delete mode 100644 test/discovery_and_monitoring/rs/primary_wrong_set_name.json delete mode 100644 test/discovery_and_monitoring/rs/repeated.json delete mode 100644 test/discovery_and_monitoring/rs/replicaset_rsnp.json delete mode 100644 test/discovery_and_monitoring/rs/response_from_removed.json delete mode 100644 test/discovery_and_monitoring/rs/sec_not_auth.json delete mode 100644 test/discovery_and_monitoring/rs/secondary_ignore_ok_0-pre-6.0.json delete mode 100644 test/discovery_and_monitoring/rs/secondary_ignore_ok_0.json delete mode 100644 test/discovery_and_monitoring/rs/secondary_ipv6_literal.json delete mode 100644 test/discovery_and_monitoring/rs/secondary_mismatched_me.json delete mode 100644 test/discovery_and_monitoring/rs/secondary_wrong_set_name.json delete mode 100644 test/discovery_and_monitoring/rs/secondary_wrong_set_name_with_primary.json delete mode 100644 test/discovery_and_monitoring/rs/set_version_can_rollback.json delete mode 100644 test/discovery_and_monitoring/rs/setversion_equal_max_without_electionid.json delete mode 100644 test/discovery_and_monitoring/rs/setversion_greaterthan_max_without_electionid.json delete mode 100644 test/discovery_and_monitoring/rs/setversion_without_electionid-pre-6.0.json delete mode 100644 test/discovery_and_monitoring/rs/setversion_without_electionid.json delete mode 100644 test/discovery_and_monitoring/rs/stepdown_change_set_name.json delete mode 100644 test/discovery_and_monitoring/rs/too_new.json delete mode 100644 test/discovery_and_monitoring/rs/too_old.json delete mode 100644 test/discovery_and_monitoring/rs/topology_version_equal.json delete mode 100644 test/discovery_and_monitoring/rs/topology_version_greater.json delete mode 100644 test/discovery_and_monitoring/rs/topology_version_less.json delete mode 100644 test/discovery_and_monitoring/rs/unexpected_mongos.json delete mode 100644 test/discovery_and_monitoring/rs/use_setversion_without_electionid-pre-6.0.json delete mode 100644 test/discovery_and_monitoring/rs/use_setversion_without_electionid.json delete mode 100644 test/discovery_and_monitoring/rs/wrong_set_name.json delete mode 100644 test/discovery_and_monitoring/sharded/compatible.json delete mode 100644 test/discovery_and_monitoring/sharded/discover_single_mongos.json delete mode 100644 test/discovery_and_monitoring/sharded/ls_timeout_mongos.json delete mode 100644 test/discovery_and_monitoring/sharded/mongos_disconnect.json delete mode 100644 test/discovery_and_monitoring/sharded/multiple_mongoses.json delete mode 100644 test/discovery_and_monitoring/sharded/non_mongos_removed.json delete mode 100644 test/discovery_and_monitoring/sharded/normalize_uri_case.json delete mode 100644 test/discovery_and_monitoring/sharded/too_new.json delete mode 100644 test/discovery_and_monitoring/sharded/too_old.json delete mode 100644 test/discovery_and_monitoring/single/compatible.json delete mode 100644 test/discovery_and_monitoring/single/direct_connection_external_ip.json delete mode 100644 test/discovery_and_monitoring/single/direct_connection_mongos.json delete mode 100644 test/discovery_and_monitoring/single/direct_connection_replicaset.json delete mode 100644 test/discovery_and_monitoring/single/direct_connection_rsarbiter.json delete mode 100644 test/discovery_and_monitoring/single/direct_connection_rsprimary.json delete mode 100644 test/discovery_and_monitoring/single/direct_connection_rssecondary.json delete mode 100644 test/discovery_and_monitoring/single/direct_connection_standalone.json delete mode 100644 test/discovery_and_monitoring/single/direct_connection_unavailable_seed.json delete mode 100644 test/discovery_and_monitoring/single/direct_connection_wrong_set_name.json delete mode 100644 test/discovery_and_monitoring/single/discover_standalone.json delete mode 100644 test/discovery_and_monitoring/single/discover_unavailable_seed.json delete mode 100644 test/discovery_and_monitoring/single/ls_timeout_standalone.json delete mode 100644 test/discovery_and_monitoring/single/not_ok_response.json delete mode 100644 test/discovery_and_monitoring/single/standalone_removed.json delete mode 100644 test/discovery_and_monitoring/single/standalone_using_legacy_hello.json delete mode 100644 test/discovery_and_monitoring/single/too_new.json delete mode 100644 test/discovery_and_monitoring/single/too_old.json delete mode 100644 test/discovery_and_monitoring/single/too_old_then_upgraded.json delete mode 100644 test/discovery_and_monitoring/unified/auth-error.json delete mode 100644 test/discovery_and_monitoring/unified/auth-misc-command-error.json delete mode 100644 test/discovery_and_monitoring/unified/auth-network-error.json delete mode 100644 test/discovery_and_monitoring/unified/auth-network-timeout-error.json delete mode 100644 test/discovery_and_monitoring/unified/auth-shutdown-error.json delete mode 100644 test/discovery_and_monitoring/unified/cancel-server-check.json delete mode 100644 test/discovery_and_monitoring/unified/connectTimeoutMS.json delete mode 100644 test/discovery_and_monitoring/unified/find-network-error.json delete mode 100644 test/discovery_and_monitoring/unified/find-network-timeout-error.json delete mode 100644 test/discovery_and_monitoring/unified/find-shutdown-error.json delete mode 100644 test/discovery_and_monitoring/unified/hello-command-error.json delete mode 100644 test/discovery_and_monitoring/unified/hello-network-error.json delete mode 100644 test/discovery_and_monitoring/unified/hello-timeout.json delete mode 100644 test/discovery_and_monitoring/unified/insert-network-error.json delete mode 100644 test/discovery_and_monitoring/unified/insert-shutdown-error.json delete mode 100644 test/discovery_and_monitoring/unified/interruptInUse-pool-clear.json delete mode 100644 test/discovery_and_monitoring/unified/loadbalanced-emit-topology-changed-before-close.json delete mode 100644 test/discovery_and_monitoring/unified/logging-loadbalanced.json delete mode 100644 test/discovery_and_monitoring/unified/logging-replicaset.json delete mode 100644 test/discovery_and_monitoring/unified/logging-sharded.json delete mode 100644 test/discovery_and_monitoring/unified/logging-standalone.json delete mode 100644 test/discovery_and_monitoring/unified/minPoolSize-error.json delete mode 100644 test/discovery_and_monitoring/unified/pool-cleared-error.json delete mode 100644 test/discovery_and_monitoring/unified/rediscover-quickly-after-step-down.json delete mode 100644 test/discovery_and_monitoring/unified/replicaset-emit-topology-changed-before-close.json delete mode 100644 test/discovery_and_monitoring/unified/serverMonitoringMode.json delete mode 100644 test/discovery_and_monitoring/unified/sharded-emit-topology-changed-before-close.json delete mode 100644 test/discovery_and_monitoring/unified/standalone-emit-topology-changed-before-close.json delete mode 100644 test/gridfs/delete.json delete mode 100644 test/gridfs/deleteByName.json delete mode 100644 test/gridfs/download.json delete mode 100644 test/gridfs/downloadByName.json delete mode 100644 test/gridfs/queries-use-eq.json delete mode 100644 test/gridfs/rename.json delete mode 100644 test/gridfs/renameByName.json delete mode 100644 test/gridfs/upload-disableMD5.json delete mode 100644 test/gridfs/upload.json delete mode 100644 test/handshake/unified/metadata-not-propagated.json delete mode 100644 test/helpers.py delete mode 100644 test/helpers_shared.py delete mode 100644 test/index_management/createSearchIndex.json delete mode 100644 test/index_management/createSearchIndexes.json delete mode 100644 test/index_management/dropSearchIndex.json delete mode 100644 test/index_management/listSearchIndexes.json delete mode 100644 test/index_management/searchIndexIgnoresReadWriteConcern.json delete mode 100644 test/index_management/updateSearchIndex.json delete mode 100644 test/lambda/README.md delete mode 100755 test/lambda/build_internal.sh delete mode 100644 test/lambda/events/event.json delete mode 100644 test/lambda/mongodb/Makefile delete mode 100644 test/lambda/mongodb/__init__.py delete mode 100644 test/lambda/mongodb/app.py delete mode 100755 test/lambda/run.sh delete mode 100644 test/lambda/template.yaml delete mode 100644 test/load_balancer/cursors.json delete mode 100644 test/load_balancer/event-monitoring.json delete mode 100644 test/load_balancer/lb-connection-establishment.json delete mode 100644 test/load_balancer/non-lb-connection-establishment.json delete mode 100644 test/load_balancer/sdam-error-handling.json delete mode 100644 test/load_balancer/server-selection.json delete mode 100644 test/load_balancer/transactions.json delete mode 100644 test/load_balancer/wait-queue-timeouts.json delete mode 100644 test/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.json delete mode 100644 test/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.json delete mode 100644 test/max_staleness/ReplicaSetNoPrimary/MaxStalenessTooSmall.json delete mode 100644 test/max_staleness/ReplicaSetNoPrimary/Nearest.json delete mode 100644 test/max_staleness/ReplicaSetNoPrimary/Nearest2.json delete mode 100644 test/max_staleness/ReplicaSetNoPrimary/NoKnownServers.json delete mode 100644 test/max_staleness/ReplicaSetNoPrimary/OneKnownTwoUnavailable.json delete mode 100644 test/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.json delete mode 100644 test/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.json delete mode 100644 test/max_staleness/ReplicaSetNoPrimary/Secondary.json delete mode 100644 test/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.json delete mode 100644 test/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.json delete mode 100644 test/max_staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/DefaultNoMaxStaleness.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/LongHeartbeat.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/LongHeartbeat2.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/Nearest.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/Nearest2.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/Nearest_tags.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/Secondary_tags.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.json delete mode 100644 test/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.json delete mode 100644 test/max_staleness/Sharded/SmallMaxStaleness.json delete mode 100644 test/max_staleness/Single/SmallMaxStaleness.json delete mode 100644 test/max_staleness/Unknown/SmallMaxStaleness.json delete mode 100644 test/mockupdb/operations.py delete mode 100644 test/mockupdb/test_auth_recovering_member.py delete mode 100644 test/mockupdb/test_cluster_time.py delete mode 100644 test/mockupdb/test_cursor.py delete mode 100644 test/mockupdb/test_cursor_namespace.py delete mode 100644 test/mockupdb/test_getmore_sharded.py delete mode 100644 test/mockupdb/test_handshake.py delete mode 100644 test/mockupdb/test_initial_ismaster.py delete mode 100644 test/mockupdb/test_list_indexes.py delete mode 100644 test/mockupdb/test_max_staleness.py delete mode 100644 test/mockupdb/test_mixed_version_sharded.py delete mode 100644 test/mockupdb/test_mongos_command_read_mode.py delete mode 100644 test/mockupdb/test_network_disconnect_primary.py delete mode 100644 test/mockupdb/test_op_msg.py delete mode 100644 test/mockupdb/test_op_msg_read_preference.py delete mode 100644 test/mockupdb/test_query_read_pref_sharded.py delete mode 100644 test/mockupdb/test_reset_and_request_check.py delete mode 100644 test/mockupdb/test_rsghost.py delete mode 100644 test/mockupdb/test_slave_okay_rs.py delete mode 100644 test/mockupdb/test_slave_okay_sharded.py delete mode 100644 test/mockupdb/test_slave_okay_single.py delete mode 100644 test/mockupdb/test_standalone_shard.py delete mode 100644 test/mod_wsgi_test/README.rst delete mode 100644 test/mod_wsgi_test/apache24ubuntu.conf delete mode 100644 test/mod_wsgi_test/httpd24fedora.conf delete mode 100644 test/mod_wsgi_test/mod_wsgi_test.conf delete mode 100644 test/mod_wsgi_test/mod_wsgi_test.py delete mode 100644 test/mod_wsgi_test/mod_wsgi_test_embedded.conf delete mode 100644 test/mod_wsgi_test/test_client.py delete mode 100644 test/mypy_fails/insert_many_dict.py delete mode 100644 test/mypy_fails/insert_one_list.py delete mode 100644 test/mypy_fails/raw_bson_document.py delete mode 100644 test/mypy_fails/typedict_client.py delete mode 100644 test/performance/async_perf_test.py delete mode 100644 test/performance/perf_test.py delete mode 100644 test/pymongo_mocks.py delete mode 100644 test/pytest_conf.py delete mode 100644 test/qcheck.py delete mode 100644 test/read_write_concern/connection-string/read-concern.json delete mode 100644 test/read_write_concern/connection-string/write-concern.json delete mode 100644 test/read_write_concern/document/read-concern.json delete mode 100644 test/read_write_concern/document/write-concern.json delete mode 100644 test/read_write_concern/operation/default-write-concern-2.6.json delete mode 100644 test/read_write_concern/operation/default-write-concern-3.2.json delete mode 100644 test/read_write_concern/operation/default-write-concern-3.4.json delete mode 100644 test/read_write_concern/operation/default-write-concern-4.2.json delete mode 100644 test/read_write_concern/write-concern-errors/aggregate.json delete mode 100644 test/read_write_concern/write-concern-errors/bulkWrite.json delete mode 100644 test/read_write_concern/write-concern-errors/client-bulkWrite.json delete mode 100644 test/read_write_concern/write-concern-errors/client-side-encryption.json delete mode 100644 test/read_write_concern/write-concern-errors/crud.json delete mode 100644 test/read_write_concern/write-concern-errors/db-coll-management.json delete mode 100644 test/read_write_concern/write-concern-errors/findAndModify.json delete mode 100644 test/read_write_concern/write-concern-errors/gridfs.json delete mode 100644 test/read_write_concern/write-concern-errors/index-management.json delete mode 100644 test/read_write_concern/write-concern-errors/mapReduce.json delete mode 100644 test/retryable_reads/unified/aggregate-merge.json delete mode 100644 test/retryable_reads/unified/aggregate-serverErrors.json delete mode 100644 test/retryable_reads/unified/aggregate.json delete mode 100644 test/retryable_reads/unified/changeStreams-client.watch-serverErrors.json delete mode 100644 test/retryable_reads/unified/changeStreams-client.watch.json delete mode 100644 test/retryable_reads/unified/changeStreams-db.coll.watch-serverErrors.json delete mode 100644 test/retryable_reads/unified/changeStreams-db.coll.watch.json delete mode 100644 test/retryable_reads/unified/changeStreams-db.watch-serverErrors.json delete mode 100644 test/retryable_reads/unified/changeStreams-db.watch.json delete mode 100644 test/retryable_reads/unified/count-serverErrors.json delete mode 100644 test/retryable_reads/unified/count.json delete mode 100644 test/retryable_reads/unified/countDocuments-serverErrors.json delete mode 100644 test/retryable_reads/unified/countDocuments.json delete mode 100644 test/retryable_reads/unified/distinct-serverErrors.json delete mode 100644 test/retryable_reads/unified/distinct.json delete mode 100644 test/retryable_reads/unified/estimatedDocumentCount-serverErrors.json delete mode 100644 test/retryable_reads/unified/estimatedDocumentCount.json delete mode 100644 test/retryable_reads/unified/exceededTimeLimit.json delete mode 100644 test/retryable_reads/unified/find-serverErrors.json delete mode 100644 test/retryable_reads/unified/find.json delete mode 100644 test/retryable_reads/unified/findOne-serverErrors.json delete mode 100644 test/retryable_reads/unified/findOne.json delete mode 100644 test/retryable_reads/unified/gridfs-download-serverErrors.json delete mode 100644 test/retryable_reads/unified/gridfs-download.json delete mode 100644 test/retryable_reads/unified/gridfs-downloadByName-serverErrors.json delete mode 100644 test/retryable_reads/unified/gridfs-downloadByName.json delete mode 100644 test/retryable_reads/unified/handshakeError.json delete mode 100644 test/retryable_reads/unified/listCollectionNames-serverErrors.json delete mode 100644 test/retryable_reads/unified/listCollectionNames.json delete mode 100644 test/retryable_reads/unified/listCollectionObjects-serverErrors.json delete mode 100644 test/retryable_reads/unified/listCollectionObjects.json delete mode 100644 test/retryable_reads/unified/listCollections-serverErrors.json delete mode 100644 test/retryable_reads/unified/listCollections.json delete mode 100644 test/retryable_reads/unified/listDatabaseNames-serverErrors.json delete mode 100644 test/retryable_reads/unified/listDatabaseNames.json delete mode 100644 test/retryable_reads/unified/listDatabaseObjects-serverErrors.json delete mode 100644 test/retryable_reads/unified/listDatabaseObjects.json delete mode 100644 test/retryable_reads/unified/listDatabases-serverErrors.json delete mode 100644 test/retryable_reads/unified/listDatabases.json delete mode 100644 test/retryable_reads/unified/listIndexNames-serverErrors.json delete mode 100644 test/retryable_reads/unified/listIndexNames.json delete mode 100644 test/retryable_reads/unified/listIndexes-serverErrors.json delete mode 100644 test/retryable_reads/unified/listIndexes.json delete mode 100644 test/retryable_reads/unified/mapReduce.json delete mode 100644 test/retryable_reads/unified/readConcernMajorityNotAvailableYet.json delete mode 100644 test/retryable_writes/unified/aggregate-out-merge.json delete mode 100644 test/retryable_writes/unified/bulkWrite-errorLabels.json delete mode 100644 test/retryable_writes/unified/bulkWrite-serverErrors.json delete mode 100644 test/retryable_writes/unified/bulkWrite.json delete mode 100644 test/retryable_writes/unified/client-bulkWrite-clientErrors.json delete mode 100644 test/retryable_writes/unified/client-bulkWrite-serverErrors.json delete mode 100644 test/retryable_writes/unified/deleteMany.json delete mode 100644 test/retryable_writes/unified/deleteOne-errorLabels.json delete mode 100644 test/retryable_writes/unified/deleteOne-serverErrors.json delete mode 100644 test/retryable_writes/unified/deleteOne.json delete mode 100644 test/retryable_writes/unified/findOneAndDelete-errorLabels.json delete mode 100644 test/retryable_writes/unified/findOneAndDelete-serverErrors.json delete mode 100644 test/retryable_writes/unified/findOneAndDelete.json delete mode 100644 test/retryable_writes/unified/findOneAndReplace-errorLabels.json delete mode 100644 test/retryable_writes/unified/findOneAndReplace-serverErrors.json delete mode 100644 test/retryable_writes/unified/findOneAndReplace.json delete mode 100644 test/retryable_writes/unified/findOneAndUpdate-errorLabels.json delete mode 100644 test/retryable_writes/unified/findOneAndUpdate-serverErrors.json delete mode 100644 test/retryable_writes/unified/findOneAndUpdate.json delete mode 100644 test/retryable_writes/unified/handshakeError.json delete mode 100644 test/retryable_writes/unified/insertMany-errorLabels.json delete mode 100644 test/retryable_writes/unified/insertMany-serverErrors.json delete mode 100644 test/retryable_writes/unified/insertMany.json delete mode 100644 test/retryable_writes/unified/insertOne-errorLabels.json delete mode 100644 test/retryable_writes/unified/insertOne-noWritesPerformedError.json delete mode 100644 test/retryable_writes/unified/insertOne-serverErrors.json delete mode 100644 test/retryable_writes/unified/insertOne.json delete mode 100644 test/retryable_writes/unified/replaceOne-errorLabels.json delete mode 100644 test/retryable_writes/unified/replaceOne-serverErrors.json delete mode 100644 test/retryable_writes/unified/replaceOne.json delete mode 100644 test/retryable_writes/unified/unacknowledged-write-concern.json delete mode 100644 test/retryable_writes/unified/updateMany.json delete mode 100644 test/retryable_writes/unified/updateOne-errorLabels.json delete mode 100644 test/retryable_writes/unified/updateOne-serverErrors.json delete mode 100644 test/retryable_writes/unified/updateOne.json delete mode 100644 test/run_command/unified/runCommand.json delete mode 100644 test/run_command/unified/runCursorCommand.json delete mode 100644 test/sdam_monitoring/discovered_standalone.json delete mode 100644 test/sdam_monitoring/load_balancer.json delete mode 100644 test/sdam_monitoring/replica_set_with_no_primary.json delete mode 100644 test/sdam_monitoring/replica_set_with_primary.json delete mode 100644 test/sdam_monitoring/replica_set_with_removal.json delete mode 100644 test/sdam_monitoring/required_replica_set.json delete mode 100644 test/sdam_monitoring/standalone.json delete mode 100644 test/sdam_monitoring/standalone_suppress_equal_description_changes.json delete mode 100644 test/server_selection/in_window/equilibrium.json delete mode 100644 test/server_selection/in_window/many-choices.json delete mode 100644 test/server_selection/in_window/one-least-two-tied.json delete mode 100644 test/server_selection/in_window/rs-equilibrium.json delete mode 100644 test/server_selection/in_window/rs-three-choices.json delete mode 100644 test/server_selection/in_window/three-choices.json delete mode 100644 test/server_selection/in_window/two-choices.json delete mode 100644 test/server_selection/in_window/two-least.json delete mode 100644 test/server_selection/rtt/first_value.json delete mode 100644 test/server_selection/rtt/first_value_zero.json delete mode 100644 test/server_selection/rtt/value_test_1.json delete mode 100644 test/server_selection/rtt/value_test_2.json delete mode 100644 test/server_selection/rtt/value_test_3.json delete mode 100644 test/server_selection/rtt/value_test_4.json delete mode 100644 test/server_selection/rtt/value_test_5.json delete mode 100644 test/server_selection/server_selection/LoadBalanced/read/Nearest.json delete mode 100644 test/server_selection/server_selection/LoadBalanced/read/Primary.json delete mode 100644 test/server_selection/server_selection/LoadBalanced/read/PrimaryPreferred.json delete mode 100644 test/server_selection/server_selection/LoadBalanced/read/Secondary.json delete mode 100644 test/server_selection/server_selection/LoadBalanced/read/SecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/LoadBalanced/write/Nearest.json delete mode 100644 test/server_selection/server_selection/LoadBalanced/write/Primary.json delete mode 100644 test/server_selection/server_selection/LoadBalanced/write/PrimaryPreferred.json delete mode 100644 test/server_selection/server_selection/LoadBalanced/write/Secondary.json delete mode 100644 test/server_selection/server_selection/LoadBalanced/write/SecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/DeprioritizedNearest.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/DeprioritizedNearestOnlyMatchingTags.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimary.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimaryPreferred.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimaryPreferredOnlyMatchingTags.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondary.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondaryOnlyMatchingTags.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondaryPreferredOnlyMatchingTags.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/Nearest.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/Nearest_multiple.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/Nearest_non_matching.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/PossiblePrimary.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/PossiblePrimaryNearest.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/Primary.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/PrimaryPreferred.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/PrimaryPreferred_non_matching.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/Secondary.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/SecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/SecondaryPreferred_non_matching.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/Secondary_multi_tags.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/Secondary_multi_tags2.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/read/Secondary_non_matching.json delete mode 100644 test/server_selection/server_selection/ReplicaSetNoPrimary/write/SecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllPrimaryPreferred.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllSecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/DeprioritizedNearest.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/DeprioritizedNearestOnlyMatchingTags.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/DeprioritizedNearestStateChange.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimary.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimaryPreferred.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimaryPreferredOnlyMatchingTags.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondary.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondaryOnlyMatchingTags.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondaryPreferredOnlyMatchingTags.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/Nearest.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/Nearest_multiple.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/Nearest_non_matching.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/Primary.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/PrimaryPreferred.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/PrimaryPreferred_non_matching.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/Secondary.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/SecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/SecondaryPreferred_empty_tags.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/SecondaryPreferred_non_matching.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/SecondaryPreferred_tags.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/read/Secondary_non_matching.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/write/DeprioritizedSecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/ReplicaSetWithPrimary/write/SecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/Sharded/read/DeprioritizedNearest.json delete mode 100644 test/server_selection/server_selection/Sharded/read/DeprioritizedPrimary.json delete mode 100644 test/server_selection/server_selection/Sharded/read/DeprioritizedPrimaryPreferred.json delete mode 100644 test/server_selection/server_selection/Sharded/read/DeprioritizedSecondary.json delete mode 100644 test/server_selection/server_selection/Sharded/read/DeprioritizedSecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/Sharded/read/Nearest.json delete mode 100644 test/server_selection/server_selection/Sharded/read/Primary.json delete mode 100644 test/server_selection/server_selection/Sharded/read/PrimaryPreferred.json delete mode 100644 test/server_selection/server_selection/Sharded/read/Secondary.json delete mode 100644 test/server_selection/server_selection/Sharded/read/SecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/Sharded/write/DeprioritizedNearest.json delete mode 100644 test/server_selection/server_selection/Sharded/write/DeprioritizedPrimary.json delete mode 100644 test/server_selection/server_selection/Sharded/write/DeprioritizedPrimaryPreferred.json delete mode 100644 test/server_selection/server_selection/Sharded/write/DeprioritizedSecondary.json delete mode 100644 test/server_selection/server_selection/Sharded/write/DeprioritizedSecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/Sharded/write/Nearest.json delete mode 100644 test/server_selection/server_selection/Sharded/write/Primary.json delete mode 100644 test/server_selection/server_selection/Sharded/write/PrimaryPreferred.json delete mode 100644 test/server_selection/server_selection/Sharded/write/Secondary.json delete mode 100644 test/server_selection/server_selection/Sharded/write/SecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/Single/read/Deprioritized.json delete mode 100644 test/server_selection/server_selection/Single/read/SecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/Single/write/Deprioritized.json delete mode 100644 test/server_selection/server_selection/Single/write/SecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/Unknown/read/SecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/Unknown/read/ghost.json delete mode 100644 test/server_selection/server_selection/Unknown/write/SecondaryPreferred.json delete mode 100644 test/server_selection/server_selection/Unknown/write/ghost.json delete mode 100644 test/server_selection_logging/load-balanced.json delete mode 100644 test/server_selection_logging/operation-id.json delete mode 100644 test/server_selection_logging/replica-set.json delete mode 100644 test/server_selection_logging/sharded.json delete mode 100644 test/server_selection_logging/standalone.json delete mode 100644 test/sessions/driver-sessions-dirty-session-errors.json delete mode 100644 test/sessions/driver-sessions-server-support.json delete mode 100644 test/sessions/implicit-sessions-default-causal-consistency.json delete mode 100644 test/sessions/snapshot-sessions-not-supported-client-error.json delete mode 100644 test/sessions/snapshot-sessions-not-supported-server-error.json delete mode 100644 test/sessions/snapshot-sessions-unsupported-ops.json delete mode 100644 test/sessions/snapshot-sessions.json delete mode 100644 test/sigstop_sigcont.py delete mode 100644 test/srv_seedlist/load-balanced/loadBalanced-directConnection.json delete mode 100644 test/srv_seedlist/load-balanced/loadBalanced-no-results.json delete mode 100644 test/srv_seedlist/load-balanced/loadBalanced-replicaSet-errors.json delete mode 100644 test/srv_seedlist/load-balanced/loadBalanced-true-multiple-hosts.json delete mode 100644 test/srv_seedlist/load-balanced/loadBalanced-true-txt.json delete mode 100644 test/srv_seedlist/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true-txt.json delete mode 100644 test/srv_seedlist/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true.json delete mode 100644 test/srv_seedlist/load-balanced/srvMaxHosts-zero-txt.json delete mode 100644 test/srv_seedlist/load-balanced/srvMaxHosts-zero.json delete mode 100644 test/srv_seedlist/replica-set/dbname-with-commas-escaped.json delete mode 100644 test/srv_seedlist/replica-set/dbname-with-commas.json delete mode 100644 test/srv_seedlist/replica-set/direct-connection-false.json delete mode 100644 test/srv_seedlist/replica-set/direct-connection-true.json delete mode 100644 test/srv_seedlist/replica-set/encoded-userinfo-and-db.json delete mode 100644 test/srv_seedlist/replica-set/identical-hostnames-valid-four-parts.json delete mode 100644 test/srv_seedlist/replica-set/identical-hostnames-valid-three-parts.json delete mode 100644 test/srv_seedlist/replica-set/loadBalanced-false-txt.json delete mode 100644 test/srv_seedlist/replica-set/longer-parent-in-return.json delete mode 100644 test/srv_seedlist/replica-set/misformatted-option.json delete mode 100644 test/srv_seedlist/replica-set/no-results.json delete mode 100644 test/srv_seedlist/replica-set/not-enough-parts.json delete mode 100644 test/srv_seedlist/replica-set/one-result-default-port.json delete mode 100644 test/srv_seedlist/replica-set/one-txt-record-multiple-strings.json delete mode 100644 test/srv_seedlist/replica-set/one-txt-record.json delete mode 100644 test/srv_seedlist/replica-set/parent-part-mismatch1.json delete mode 100644 test/srv_seedlist/replica-set/parent-part-mismatch2.json delete mode 100644 test/srv_seedlist/replica-set/parent-part-mismatch3.json delete mode 100644 test/srv_seedlist/replica-set/parent-part-mismatch4.json delete mode 100644 test/srv_seedlist/replica-set/parent-part-mismatch5.json delete mode 100644 test/srv_seedlist/replica-set/returned-parent-too-short.json delete mode 100644 test/srv_seedlist/replica-set/returned-parent-wrong.json delete mode 100644 test/srv_seedlist/replica-set/srv-service-name.json delete mode 100644 test/srv_seedlist/replica-set/srvAllowedHostsSuffix-case-insensitive.json delete mode 100644 test/srv_seedlist/replica-set/srvAllowedHostsSuffix-mismatch.json delete mode 100644 test/srv_seedlist/replica-set/srvAllowedHostsSuffix-period-only.json delete mode 100644 test/srv_seedlist/replica-set/srvAllowedHostsSuffix-psl-not-public-suffix.json delete mode 100644 test/srv_seedlist/replica-set/srvAllowedHostsSuffix-psl-public-suffix-capitalized.json delete mode 100644 test/srv_seedlist/replica-set/srvAllowedHostsSuffix-psl-public-suffix.json delete mode 100644 test/srv_seedlist/replica-set/srvAllowedHostsSuffix-tld-only.json delete mode 100644 test/srv_seedlist/replica-set/srvAllowedHostsSuffix-trailing-dot.json delete mode 100644 test/srv_seedlist/replica-set/srvAllowedHostsSuffix-with_dot.json delete mode 100644 test/srv_seedlist/replica-set/srvAllowedHostsSuffix-without_dot_fail.json delete mode 100644 test/srv_seedlist/replica-set/srvAllowedHostsSuffix-without_dot_pass.json delete mode 100644 test/srv_seedlist/replica-set/srvMaxHosts-conflicts_with_replicaSet-txt.json delete mode 100644 test/srv_seedlist/replica-set/srvMaxHosts-conflicts_with_replicaSet.json delete mode 100644 test/srv_seedlist/replica-set/srvMaxHosts-equal_to_srv_records.json delete mode 100644 test/srv_seedlist/replica-set/srvMaxHosts-greater_than_srv_records.json delete mode 100644 test/srv_seedlist/replica-set/srvMaxHosts-less_than_srv_records.json delete mode 100644 test/srv_seedlist/replica-set/srvMaxHosts-zero-txt.json delete mode 100644 test/srv_seedlist/replica-set/srvMaxHosts-zero.json delete mode 100644 test/srv_seedlist/replica-set/two-results-default-port.json delete mode 100644 test/srv_seedlist/replica-set/two-results-nonstandard-port.json delete mode 100644 test/srv_seedlist/replica-set/two-txt-records.json delete mode 100644 test/srv_seedlist/replica-set/txt-record-not-allowed-option.json delete mode 100644 test/srv_seedlist/replica-set/txt-record-with-overridden-ssl-option.json delete mode 100644 test/srv_seedlist/replica-set/txt-record-with-overridden-uri-option.json delete mode 100644 test/srv_seedlist/replica-set/txt-record-with-unallowed-option.json delete mode 100644 test/srv_seedlist/replica-set/uri-with-admin-database.json delete mode 100644 test/srv_seedlist/replica-set/uri-with-auth.json delete mode 100644 test/srv_seedlist/replica-set/uri-with-port.json delete mode 100644 test/srv_seedlist/replica-set/uri-with-two-hosts.json delete mode 100644 test/srv_seedlist/replica-set/uri-with-uppercase-hostname.json delete mode 100644 test/srv_seedlist/sharded/srvMaxHosts-equal_to_srv_records.json delete mode 100644 test/srv_seedlist/sharded/srvMaxHosts-greater_than_srv_records.json delete mode 100644 test/srv_seedlist/sharded/srvMaxHosts-less_than_srv_records.json delete mode 100644 test/srv_seedlist/sharded/srvMaxHosts-zero.json delete mode 100644 test/test_auth.py delete mode 100644 test/test_auth_oidc.py delete mode 100644 test/test_auth_spec.py delete mode 100644 test/test_azure_helpers.py delete mode 100644 test/test_binary.py delete mode 100644 test/test_bson.py delete mode 100644 test/test_bson_binary_vector.py delete mode 100644 test/test_bson_corpus.py delete mode 100644 test/test_bulk.py delete mode 100644 test/test_causal_consistency.py delete mode 100644 test/test_change_stream.py delete mode 100644 test/test_client.py delete mode 100644 test/test_client_backpressure.py delete mode 100644 test/test_client_bulk_write.py delete mode 100644 test/test_client_context.py delete mode 100644 test/test_client_metadata.py delete mode 100644 test/test_code.py delete mode 100644 test/test_collation.py delete mode 100644 test/test_collection.py delete mode 100644 test/test_collection_management.py delete mode 100644 test/test_command_logging.py delete mode 100644 test/test_command_monitoring.py delete mode 100644 test/test_comment.py delete mode 100644 test/test_common.py delete mode 100644 test/test_compression_support.py delete mode 100644 test/test_connection_logging.py delete mode 100644 test/test_connection_monitoring.py delete mode 100644 test/test_connections_survive_primary_stepdown_spec.py delete mode 100644 test/test_create_entities.py delete mode 100644 test/test_crud_unified.py delete mode 100644 test/test_crud_v1.py delete mode 100644 test/test_csot.py delete mode 100644 test/test_cursor.py delete mode 100644 test/test_custom_types.py delete mode 100644 test/test_daemon.py delete mode 100644 test/test_database.py delete mode 100644 test/test_dbref.py delete mode 100644 test/test_decimal128.py delete mode 100644 test/test_default_exports.py delete mode 100644 test/test_discovery_and_monitoring.py delete mode 100644 test/test_dns.py delete mode 100644 test/test_encryption.py delete mode 100644 test/test_errors.py delete mode 100644 test/test_event_loggers.py delete mode 100644 test/test_examples.py delete mode 100644 test/test_fork.py delete mode 100644 test/test_fuzz_harvest.py delete mode 100644 test/test_gcp_helpers.py delete mode 100644 test/test_grid_file.py delete mode 100644 test/test_gridfs.py delete mode 100644 test/test_gridfs_bucket.py delete mode 100644 test/test_gridfs_spec.py delete mode 100644 test/test_handshake_unified.py delete mode 100644 test/test_heartbeat_monitoring.py delete mode 100644 test/test_hello_latched.py delete mode 100644 test/test_index_management.py delete mode 100644 test/test_json_util.py delete mode 100644 test/test_json_util_integration.py delete mode 100644 test/test_kms_connect.py delete mode 100644 test/test_kms_connect_prose.py delete mode 100644 test/test_load_balancer.py delete mode 100644 test/test_logger.py delete mode 100644 test/test_max_staleness.py delete mode 100644 test/test_message.py delete mode 100644 test/test_mongos_load_balancing.py delete mode 100644 test/test_monitor.py delete mode 100644 test/test_monitoring.py delete mode 100644 test/test_network_layer.py delete mode 100644 test/test_objectid.py delete mode 100644 test/test_ocsp_cache.py delete mode 100644 test/test_ocsp_support.py delete mode 100644 test/test_on_demand_csfle.py delete mode 100644 test/test_operation_id_retry.py delete mode 100644 test/test_operations.py delete mode 100644 test/test_periodic_executor.py delete mode 100644 test/test_pooling.py delete mode 100644 test/test_pymongo.py delete mode 100644 test/test_pyopenssl_context.py delete mode 100644 test/test_raw_bson.py delete mode 100644 test/test_raw_bson_shared.py delete mode 100644 test/test_read_concern.py delete mode 100644 test/test_read_preferences.py delete mode 100644 test/test_read_write_concern_spec.py delete mode 100644 test/test_replica_set_reconfig.py delete mode 100644 test/test_results.py delete mode 100644 test/test_retryable_reads.py delete mode 100644 test/test_retryable_reads_unified.py delete mode 100644 test/test_retryable_writes.py delete mode 100644 test/test_retryable_writes_unified.py delete mode 100644 test/test_run_command.py delete mode 100644 test/test_saslprep.py delete mode 100644 test/test_sdam_monitoring_spec.py delete mode 100644 test/test_server.py delete mode 100644 test/test_server_description.py delete mode 100644 test/test_server_selection.py delete mode 100644 test/test_server_selection_in_window.py delete mode 100644 test/test_server_selection_logging.py delete mode 100644 test/test_server_selection_rtt.py delete mode 100644 test/test_session.py delete mode 100644 test/test_sessions_unified.py delete mode 100644 test/test_sfp.py delete mode 100644 test/test_son.py delete mode 100644 test/test_srv_polling.py delete mode 100644 test/test_ssl.py delete mode 100644 test/test_ssl_support.py delete mode 100644 test/test_streaming_protocol.py delete mode 100644 test/test_subinterpreters.py delete mode 100644 test/test_threads.py delete mode 100644 test/test_timestamp.py delete mode 100644 test/test_topology.py delete mode 100644 test/test_transactions.py delete mode 100644 test/test_transactions_unified.py delete mode 100644 test/test_typing.py delete mode 100644 test/test_typing_strict.py delete mode 100644 test/test_unified_format.py delete mode 100644 test/test_uri_parser.py delete mode 100644 test/test_uri_spec.py delete mode 100644 test/test_versioned_api.py delete mode 100644 test/test_versioned_api_integration.py delete mode 100644 test/test_write_concern.py delete mode 100644 test/transactions-convenient-api/unified/callback-aborts.json delete mode 100644 test/transactions-convenient-api/unified/callback-commits.json delete mode 100644 test/transactions-convenient-api/unified/callback-retry.json delete mode 100644 test/transactions-convenient-api/unified/commit-retry-errorLabels.json delete mode 100644 test/transactions-convenient-api/unified/commit-retry.json delete mode 100644 test/transactions-convenient-api/unified/commit-transienttransactionerror-4.2.json delete mode 100644 test/transactions-convenient-api/unified/commit-transienttransactionerror.json delete mode 100644 test/transactions-convenient-api/unified/commit-writeconcernerror.json delete mode 100644 test/transactions-convenient-api/unified/commit.json delete mode 100644 test/transactions-convenient-api/unified/transaction-options.json delete mode 100644 test/transactions/unified/abort.json delete mode 100644 test/transactions/unified/backpressure-retryable-abort.json delete mode 100644 test/transactions/unified/backpressure-retryable-commit.json delete mode 100644 test/transactions/unified/backpressure-retryable-reads.json delete mode 100644 test/transactions/unified/backpressure-retryable-writes.json delete mode 100644 test/transactions/unified/bulk.json delete mode 100644 test/transactions/unified/causal-consistency.json delete mode 100644 test/transactions/unified/client-bulkWrite.json delete mode 100644 test/transactions/unified/commit.json delete mode 100644 test/transactions/unified/count.json delete mode 100644 test/transactions/unified/create-collection.json delete mode 100644 test/transactions/unified/create-index.json delete mode 100644 test/transactions/unified/delete.json delete mode 100644 test/transactions/unified/do-not-retry-read-in-transaction.json delete mode 100644 test/transactions/unified/error-labels-blockConnection.json delete mode 100644 test/transactions/unified/error-labels-errorLabels.json delete mode 100644 test/transactions/unified/error-labels.json delete mode 100644 test/transactions/unified/errors-client.json delete mode 100644 test/transactions/unified/errors.json delete mode 100644 test/transactions/unified/findOneAndDelete.json delete mode 100644 test/transactions/unified/findOneAndReplace.json delete mode 100644 test/transactions/unified/findOneAndUpdate.json delete mode 100644 test/transactions/unified/insert.json delete mode 100644 test/transactions/unified/isolation.json delete mode 100644 test/transactions/unified/mongos-pin-auto.json delete mode 100644 test/transactions/unified/mongos-recovery-token-errorLabels.json delete mode 100644 test/transactions/unified/mongos-recovery-token.json delete mode 100644 test/transactions/unified/mongos-unpin.json delete mode 100644 test/transactions/unified/pin-mongos.json delete mode 100644 test/transactions/unified/read-concern.json delete mode 100644 test/transactions/unified/read-pref.json delete mode 100644 test/transactions/unified/reads.json delete mode 100644 test/transactions/unified/retryable-abort-errorLabels.json delete mode 100644 test/transactions/unified/retryable-abort-handshake.json delete mode 100644 test/transactions/unified/retryable-abort.json delete mode 100644 test/transactions/unified/retryable-commit-errorLabels.json delete mode 100644 test/transactions/unified/retryable-commit-handshake.json delete mode 100644 test/transactions/unified/retryable-commit.json delete mode 100644 test/transactions/unified/retryable-writes.json delete mode 100644 test/transactions/unified/run-command.json delete mode 100644 test/transactions/unified/transaction-options-repl.json delete mode 100644 test/transactions/unified/transaction-options.json delete mode 100644 test/transactions/unified/update.json delete mode 100644 test/transactions/unified/write-concern.json delete mode 100644 test/unicode/test_utf8.py delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-keyVaultClient-required.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-keyVaultClient-type.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-keyVaultNamespace-required.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-keyVaultNamespace-type.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-aws-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-aws-type.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-azure-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-azure-type.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-gcp-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-gcp-type.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-invalidName.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-kmip-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-kmip-type.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-local-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-local-type.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-required.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-type.json delete mode 100644 test/unified-test-format/invalid/clientEncryptionOpts-tlsOptions_not_supported.json delete mode 100644 test/unified-test-format/invalid/collectionData-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/collectionData-collectionName-required.json delete mode 100644 test/unified-test-format/invalid/collectionData-collectionName-type.json delete mode 100644 test/unified-test-format/invalid/collectionData-createOptions-type.json delete mode 100644 test/unified-test-format/invalid/collectionData-databaseName-required.json delete mode 100644 test/unified-test-format/invalid/collectionData-databaseName-type.json delete mode 100644 test/unified-test-format/invalid/collectionData-documents-items.json delete mode 100644 test/unified-test-format/invalid/collectionData-documents-required.json delete mode 100644 test/unified-test-format/invalid/collectionData-documents-type.json delete mode 100644 test/unified-test-format/invalid/collectionOrDatabaseOptions-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/collectionOrDatabaseOptions-readConcern-type.json delete mode 100644 test/unified-test-format/invalid/collectionOrDatabaseOptions-readPreference-type.json delete mode 100644 test/unified-test-format/invalid/collectionOrDatabaseOptions-timeoutMS-type.json delete mode 100644 test/unified-test-format/invalid/collectionOrDatabaseOptions-writeConcern-type.json delete mode 100644 test/unified-test-format/invalid/createEntities-items.json delete mode 100644 test/unified-test-format/invalid/createEntities-minItems.json delete mode 100644 test/unified-test-format/invalid/createEntities-type.json delete mode 100644 test/unified-test-format/invalid/description-required.json delete mode 100644 test/unified-test-format/invalid/entity-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/entity-bucket-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/entity-bucket-bucketOptions-type.json delete mode 100644 test/unified-test-format/invalid/entity-bucket-database-required.json delete mode 100644 test/unified-test-format/invalid/entity-bucket-database-type.json delete mode 100644 test/unified-test-format/invalid/entity-bucket-id-required.json delete mode 100644 test/unified-test-format/invalid/entity-bucket-id-type.json delete mode 100644 test/unified-test-format/invalid/entity-client-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/entity-client-id-required.json delete mode 100644 test/unified-test-format/invalid/entity-client-id-type.json delete mode 100644 test/unified-test-format/invalid/entity-client-ignoreCommandMonitoringEvents-items.json delete mode 100644 test/unified-test-format/invalid/entity-client-ignoreCommandMonitoringEvents-minItems.json delete mode 100644 test/unified-test-format/invalid/entity-client-ignoreCommandMonitoringEvents-type.json delete mode 100644 test/unified-test-format/invalid/entity-client-observeEvents-enum.json delete mode 100644 test/unified-test-format/invalid/entity-client-observeEvents-items.json delete mode 100644 test/unified-test-format/invalid/entity-client-observeEvents-minItems.json delete mode 100644 test/unified-test-format/invalid/entity-client-observeEvents-type.json delete mode 100644 test/unified-test-format/invalid/entity-client-observeLogMessages-minProperties.json delete mode 100644 test/unified-test-format/invalid/entity-client-observeLogMessages-property-type.json delete mode 100644 test/unified-test-format/invalid/entity-client-observeLogMessages-property-value.json delete mode 100644 test/unified-test-format/invalid/entity-client-observeLogMessages-type.json delete mode 100644 test/unified-test-format/invalid/entity-client-observeSensitiveCommands-type.json delete mode 100644 test/unified-test-format/invalid/entity-client-serverApi-deprecationErrors-type.json delete mode 100644 test/unified-test-format/invalid/entity-client-serverApi-strict-type.json delete mode 100644 test/unified-test-format/invalid/entity-client-serverApi-type.json delete mode 100644 test/unified-test-format/invalid/entity-client-serverApi-version-required.json delete mode 100644 test/unified-test-format/invalid/entity-client-serverApi-version-type.json delete mode 100644 test/unified-test-format/invalid/entity-client-uriOptions-type.json delete mode 100644 test/unified-test-format/invalid/entity-client-useMultipleMongoses-type.json delete mode 100644 test/unified-test-format/invalid/entity-clientEncryption-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/entity-clientEncryption-clientEncryptionOpts-required.json delete mode 100644 test/unified-test-format/invalid/entity-clientEncryption-clientEncryptionOpts-type.json delete mode 100644 test/unified-test-format/invalid/entity-clientEncryption-id-required.json delete mode 100644 test/unified-test-format/invalid/entity-clientEncryption-id-type.json delete mode 100644 test/unified-test-format/invalid/entity-collection-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/entity-collection-collectionName-required.json delete mode 100644 test/unified-test-format/invalid/entity-collection-collectionName-type.json delete mode 100644 test/unified-test-format/invalid/entity-collection-collectionOptions-type.json delete mode 100644 test/unified-test-format/invalid/entity-collection-database-required.json delete mode 100644 test/unified-test-format/invalid/entity-collection-database-type.json delete mode 100644 test/unified-test-format/invalid/entity-collection-id-required.json delete mode 100644 test/unified-test-format/invalid/entity-collection-id-type.json delete mode 100644 test/unified-test-format/invalid/entity-database-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/entity-database-client-required.json delete mode 100644 test/unified-test-format/invalid/entity-database-client-type.json delete mode 100644 test/unified-test-format/invalid/entity-database-databaseName-required.json delete mode 100644 test/unified-test-format/invalid/entity-database-databaseName-type.json delete mode 100644 test/unified-test-format/invalid/entity-database-databaseOptions-type.json delete mode 100644 test/unified-test-format/invalid/entity-database-id-required.json delete mode 100644 test/unified-test-format/invalid/entity-database-id-type.json delete mode 100644 test/unified-test-format/invalid/entity-maxProperties.json delete mode 100644 test/unified-test-format/invalid/entity-minProperties.json delete mode 100644 test/unified-test-format/invalid/entity-session-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/entity-session-client-required.json delete mode 100644 test/unified-test-format/invalid/entity-session-client-type.json delete mode 100644 test/unified-test-format/invalid/entity-session-id-required.json delete mode 100644 test/unified-test-format/invalid/entity-session-id-type.json delete mode 100644 test/unified-test-format/invalid/entity-session-sessionOptions-type.json delete mode 100644 test/unified-test-format/invalid/entity-stream-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/entity-stream-hexBytes-pattern.json delete mode 100644 test/unified-test-format/invalid/entity-stream-hexBytes-required.json delete mode 100644 test/unified-test-format/invalid/entity-stream-hexBytes-type.json delete mode 100644 test/unified-test-format/invalid/entity-stream-id-required.json delete mode 100644 test/unified-test-format/invalid/entity-stream-id-type.json delete mode 100644 test/unified-test-format/invalid/entity-thread-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/entity-thread-id-required.json delete mode 100644 test/unified-test-format/invalid/entity-thread-id-type.json delete mode 100644 test/unified-test-format/invalid/expectedCmapEvent-connectionCheckOutFailedEvent-reason-type.json delete mode 100644 test/unified-test-format/invalid/expectedCmapEvent-connectionCheckOutStartedEvent-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedCmapEvent-connectionCheckedInEvent-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedCmapEvent-connectionCheckedOutEvent-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedCmapEvent-connectionClosedEvent-reason-type.json delete mode 100644 test/unified-test-format/invalid/expectedCmapEvent-connectionCreatedEvent-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedCmapEvent-connectionReadyEvent-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedCmapEvent-poolClearedEvent-hasServiceId-type.json delete mode 100644 test/unified-test-format/invalid/expectedCmapEvent-poolClearedEvent-interruptInUseConnections-type.json delete mode 100644 test/unified-test-format/invalid/expectedCmapEvent-poolClosedEvent-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedCmapEvent-poolCreatedEvent-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedCmapEvent-poolReadyEvent-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandFailedEvent-commandName-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandFailedEvent-databaseName-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandFailedEvent-hasServerConnectionId-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandFailedEvent-hasServiceId-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandStartedEvent-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandStartedEvent-command-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandStartedEvent-commandName-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandStartedEvent-databaseName-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandStartedEvent-hasServerConnectionId-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandStartedEvent-hasServiceId-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandSucceededEvent-commandName-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandSucceededEvent-databaseName-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandSucceededEvent-hasServerConnectionId-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandSucceededEvent-hasServiceId-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-commandSucceededEvent-reply-type.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-maxProperties.json delete mode 100644 test/unified-test-format/invalid/expectedCommandEvent-minProperties.json delete mode 100644 test/unified-test-format/invalid/expectedError-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedError-errorCode-type.json delete mode 100644 test/unified-test-format/invalid/expectedError-errorCodeName-type.json delete mode 100644 test/unified-test-format/invalid/expectedError-errorContains-type.json delete mode 100644 test/unified-test-format/invalid/expectedError-errorLabelsContain-items.json delete mode 100644 test/unified-test-format/invalid/expectedError-errorLabelsContain-minItems.json delete mode 100644 test/unified-test-format/invalid/expectedError-errorLabelsContain-type.json delete mode 100644 test/unified-test-format/invalid/expectedError-errorLabelsOmit-items.json delete mode 100644 test/unified-test-format/invalid/expectedError-errorLabelsOmit-minItems.json delete mode 100644 test/unified-test-format/invalid/expectedError-errorLabelsOmit-type.json delete mode 100644 test/unified-test-format/invalid/expectedError-errorResponse-type.json delete mode 100644 test/unified-test-format/invalid/expectedError-isClientError-type.json delete mode 100644 test/unified-test-format/invalid/expectedError-isError-const.json delete mode 100644 test/unified-test-format/invalid/expectedError-isError-type.json delete mode 100644 test/unified-test-format/invalid/expectedError-isTimeoutError-type.json delete mode 100644 test/unified-test-format/invalid/expectedError-minProperties.json delete mode 100644 test/unified-test-format/invalid/expectedEventsForClient-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedEventsForClient-client-required.json delete mode 100644 test/unified-test-format/invalid/expectedEventsForClient-client-type.json delete mode 100644 test/unified-test-format/invalid/expectedEventsForClient-eventType-enum.json delete mode 100644 test/unified-test-format/invalid/expectedEventsForClient-eventType-type.json delete mode 100644 test/unified-test-format/invalid/expectedEventsForClient-events-items.json delete mode 100644 test/unified-test-format/invalid/expectedEventsForClient-events-required.json delete mode 100644 test/unified-test-format/invalid/expectedEventsForClient-events-type.json delete mode 100644 test/unified-test-format/invalid/expectedEventsForClient-events_conflicts_with_cmap_eventType.json delete mode 100644 test/unified-test-format/invalid/expectedEventsForClient-events_conflicts_with_command_eventType.json delete mode 100644 test/unified-test-format/invalid/expectedEventsForClient-events_conflicts_with_default_eventType.json delete mode 100644 test/unified-test-format/invalid/expectedEventsForClient-ignoreExtraEvents-type.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessage-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessage-component-enum.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessage-component-required.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessage-component-type.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessage-data-required.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessage-data-type.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessage-failureIsRedacted-type.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessage-level-enum.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessage-level-required.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessage-level-type.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessagesForClient-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessagesForClient-client-required.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessagesForClient-client-type.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessagesForClient-ignoreExtraMessages-type.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessagesForClient-ignoreMessages-items.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessagesForClient-ignoreMessages-type.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessagesForClient-messages-items.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessagesForClient-messages-required.json delete mode 100644 test/unified-test-format/invalid/expectedLogMessagesForClient-messages-type.json delete mode 100644 test/unified-test-format/invalid/expectedSdamEvent-serverDescriptionChangedEvent-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedSdamEvent-serverDescriptionChangedEvent-serverDescription-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/expectedSdamEvent-serverDescriptionChangedEvent-serverDescription-type-enum.json delete mode 100644 test/unified-test-format/invalid/expectedSdamEvent-serverDescriptionChangedEvent-serverDescription-type-type.json delete mode 100644 test/unified-test-format/invalid/expectedSdamEvent-topologyDescriptionChangedEvent-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/initialData-items.json delete mode 100644 test/unified-test-format/invalid/initialData-minItems.json delete mode 100644 test/unified-test-format/invalid/initialData-type.json delete mode 100644 test/unified-test-format/invalid/operation-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/operation-arguments-type.json delete mode 100644 test/unified-test-format/invalid/operation-expectError-conflicts_with_expectResult.json delete mode 100644 test/unified-test-format/invalid/operation-expectError-conflicts_with_saveResultAsEntity.json delete mode 100644 test/unified-test-format/invalid/operation-expectError-type.json delete mode 100644 test/unified-test-format/invalid/operation-expectEvents-type.json delete mode 100644 test/unified-test-format/invalid/operation-ignoreResultAndError-conflicts_with_expectError.json delete mode 100644 test/unified-test-format/invalid/operation-ignoreResultAndError-conflicts_with_expectResult.json delete mode 100644 test/unified-test-format/invalid/operation-ignoreResultAndError-conflicts_with_saveResultAsEntity.json delete mode 100644 test/unified-test-format/invalid/operation-name-required.json delete mode 100644 test/unified-test-format/invalid/operation-name-type.json delete mode 100644 test/unified-test-format/invalid/operation-object-required.json delete mode 100644 test/unified-test-format/invalid/operation-object-type.json delete mode 100644 test/unified-test-format/invalid/operation-saveResultAsEntity-type.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-auth-type.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-authMechanism-type.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-csfle-minLibmongocryptVersion-pattern.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-csfle-minLibmongocryptVersion-type.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-csfle-type.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-maxServerVersion-pattern.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-maxServerVersion-type.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-minProperties.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-minServerVersion-pattern.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-minServerVersion-type.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-serverless-enum.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-serverless-type.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-topologies-enum.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-topologies-items.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-topologies-minItems.json delete mode 100644 test/unified-test-format/invalid/runOnRequirement-topologies-type.json delete mode 100644 test/unified-test-format/invalid/runOnRequirements-items.json delete mode 100644 test/unified-test-format/invalid/runOnRequirements-minItems.json delete mode 100644 test/unified-test-format/invalid/runOnRequirements-type.json delete mode 100644 test/unified-test-format/invalid/schemaVersion-pattern.json delete mode 100644 test/unified-test-format/invalid/schemaVersion-required.json delete mode 100644 test/unified-test-format/invalid/schemaVersion-type.json delete mode 100644 test/unified-test-format/invalid/test-additionalProperties.json delete mode 100644 test/unified-test-format/invalid/test-description-required.json delete mode 100644 test/unified-test-format/invalid/test-description-type.json delete mode 100644 test/unified-test-format/invalid/test-expectEvents-items.json delete mode 100644 test/unified-test-format/invalid/test-expectEvents-minItems.json delete mode 100644 test/unified-test-format/invalid/test-expectEvents-type.json delete mode 100644 test/unified-test-format/invalid/test-expectLogMessages-items.json delete mode 100644 test/unified-test-format/invalid/test-expectLogMessages-minItems.json delete mode 100644 test/unified-test-format/invalid/test-expectLogMessages-type.json delete mode 100644 test/unified-test-format/invalid/test-operations-items.json delete mode 100644 test/unified-test-format/invalid/test-operations-required.json delete mode 100644 test/unified-test-format/invalid/test-operations-type.json delete mode 100644 test/unified-test-format/invalid/test-outcome-items.json delete mode 100644 test/unified-test-format/invalid/test-outcome-minItems.json delete mode 100644 test/unified-test-format/invalid/test-outcome-type.json delete mode 100644 test/unified-test-format/invalid/test-runOnRequirements-items.json delete mode 100644 test/unified-test-format/invalid/test-runOnRequirements-minItems.json delete mode 100644 test/unified-test-format/invalid/test-runOnRequirements-type.json delete mode 100644 test/unified-test-format/invalid/test-skipReason-type.json delete mode 100644 test/unified-test-format/invalid/tests-items.json delete mode 100644 test/unified-test-format/invalid/tests-minItems.json delete mode 100644 test/unified-test-format/invalid/tests-required.json delete mode 100644 test/unified-test-format/invalid/tests-type.json delete mode 100644 test/unified-test-format/valid-fail/assertNumberConnectionsCheckedOut.json delete mode 100644 test/unified-test-format/valid-fail/entity-bucket-database-undefined.json delete mode 100644 test/unified-test-format/valid-fail/entity-client-apiVersion-unsupported.json delete mode 100644 test/unified-test-format/valid-fail/entity-collection-database-undefined.json delete mode 100644 test/unified-test-format/valid-fail/entity-database-client-undefined.json delete mode 100644 test/unified-test-format/valid-fail/entity-findCursor-malformed.json delete mode 100644 test/unified-test-format/valid-fail/entity-findCursor.json delete mode 100644 test/unified-test-format/valid-fail/entity-session-client-undefined.json delete mode 100644 test/unified-test-format/valid-fail/ignoreResultAndError-malformed.json delete mode 100644 test/unified-test-format/valid-fail/ignoreResultAndError.json delete mode 100644 test/unified-test-format/valid-fail/kmsProviders-missing_aws_kms_credentials.json delete mode 100644 test/unified-test-format/valid-fail/kmsProviders-missing_azure_kms_credentials.json delete mode 100644 test/unified-test-format/valid-fail/kmsProviders-missing_gcp_kms_credentials.json delete mode 100644 test/unified-test-format/valid-fail/kmsProviders-no_kms.json delete mode 100644 test/unified-test-format/valid-fail/operation-failure.json delete mode 100644 test/unified-test-format/valid-fail/operation-unsupported.json delete mode 100644 test/unified-test-format/valid-fail/operator-matchAsDocument.json delete mode 100644 test/unified-test-format/valid-fail/operator-matchAsRoot.json delete mode 100644 test/unified-test-format/valid-fail/returnDocument-enum-invalid.json delete mode 100644 test/unified-test-format/valid-fail/schemaVersion-unsupported.json delete mode 100644 test/unified-test-format/valid-pass/assertNumberConnectionsCheckedOut.json delete mode 100644 test/unified-test-format/valid-pass/collectionData-createOptions.json delete mode 100644 test/unified-test-format/valid-pass/createEntities-operation.json delete mode 100644 test/unified-test-format/valid-pass/entity-client-cmap-events.json delete mode 100644 test/unified-test-format/valid-pass/entity-commandCursor.json delete mode 100644 test/unified-test-format/valid-pass/entity-cursor-iterateOnce.json delete mode 100644 test/unified-test-format/valid-pass/entity-find-cursor.json delete mode 100644 test/unified-test-format/valid-pass/expectedError-errorResponse.json delete mode 100644 test/unified-test-format/valid-pass/expectedError-isClientError.json delete mode 100644 test/unified-test-format/valid-pass/expectedEventsForClient-eventType.json delete mode 100644 test/unified-test-format/valid-pass/expectedEventsForClient-ignoreExtraEvents.json delete mode 100644 test/unified-test-format/valid-pass/expectedEventsForClient-topologyDescriptionChangedEvent.json delete mode 100644 test/unified-test-format/valid-pass/ignoreResultAndError.json delete mode 100644 test/unified-test-format/valid-pass/kmsProviders-explicit_kms_credentials.json delete mode 100644 test/unified-test-format/valid-pass/kmsProviders-mixed_kms_credential_fields.json delete mode 100644 test/unified-test-format/valid-pass/kmsProviders-placeholder_kms_credentials.json delete mode 100644 test/unified-test-format/valid-pass/kmsProviders-unconfigured_kms.json delete mode 100644 test/unified-test-format/valid-pass/observeSensitiveCommands.json delete mode 100644 test/unified-test-format/valid-pass/operation-empty_array.json delete mode 100644 test/unified-test-format/valid-pass/operator-lte.json delete mode 100644 test/unified-test-format/valid-pass/operator-matchAsDocument.json delete mode 100644 test/unified-test-format/valid-pass/operator-matchAsRoot.json delete mode 100644 test/unified-test-format/valid-pass/operator-type-number_alias.json delete mode 100644 test/unified-test-format/valid-pass/poc-change-streams.json delete mode 100644 test/unified-test-format/valid-pass/poc-command-monitoring.json delete mode 100644 test/unified-test-format/valid-pass/poc-crud.json delete mode 100644 test/unified-test-format/valid-pass/poc-gridfs.json delete mode 100644 test/unified-test-format/valid-pass/poc-queryable-encryption.json delete mode 100644 test/unified-test-format/valid-pass/poc-retryable-reads.json delete mode 100644 test/unified-test-format/valid-pass/poc-retryable-writes.json delete mode 100644 test/unified-test-format/valid-pass/poc-sessions.json delete mode 100644 test/unified-test-format/valid-pass/poc-transactions-convenient-api.json delete mode 100644 test/unified-test-format/valid-pass/poc-transactions-mongos-pin-auto.json delete mode 100644 test/unified-test-format/valid-pass/poc-transactions.json delete mode 100644 test/unified_format.py delete mode 100644 test/unified_format_shared.py delete mode 100644 test/uri_options/auth-options.json delete mode 100644 test/uri_options/ca.pem delete mode 100644 test/uri_options/cert.pem delete mode 100644 test/uri_options/client-backpressure-options.json delete mode 100644 test/uri_options/client.pem delete mode 100644 test/uri_options/compression-options.json delete mode 100644 test/uri_options/concern-options.json delete mode 100644 test/uri_options/connection-options.json delete mode 100644 test/uri_options/connection-pool-options.json delete mode 100644 test/uri_options/read-preference-options.json delete mode 100644 test/uri_options/sdam-options.json delete mode 100644 test/uri_options/single-threaded-options.json delete mode 100644 test/uri_options/srv-options.json delete mode 100644 test/uri_options/tls-options.json delete mode 100644 test/utils.py delete mode 100644 test/utils_selection_tests.py delete mode 100644 test/utils_selection_tests_shared.py delete mode 100644 test/utils_shared.py delete mode 100644 test/utils_spec_runner.py delete mode 100644 test/version.py delete mode 100644 test/versioned-api/crud-api-version-1-strict.json delete mode 100644 test/versioned-api/crud-api-version-1.json delete mode 100644 test/versioned-api/runcommand-helper-no-api-version-declared.json delete mode 100644 test/versioned-api/test-commands-deprecation-errors.json delete mode 100644 test/versioned-api/test-commands-strict-mode.json delete mode 100644 test/versioned-api/transaction-handling.json delete mode 100644 tools/README.rst delete mode 100644 tools/clean.py delete mode 100644 tools/compare_import_time.py delete mode 100644 tools/ensure_future_annotations_import.py delete mode 100644 tools/fail_if_no_c.py delete mode 100644 tools/generate_sbom_requirements.py delete mode 100644 tools/ocsptest.py delete mode 100644 tools/synchro.py delete mode 100644 tools/test_synchro.py delete mode 100644 uv.lock diff --git a/.codecov.yml b/.codecov.yml deleted file mode 100644 index 3d0f092af3..0000000000 --- a/.codecov.yml +++ /dev/null @@ -1,11 +0,0 @@ -# do not notify until at least 100 builds have been uploaded from the CI pipeline -# you can also set after_n_builds on comments independently -comment: - after_n_builds: 100 - -coverage: - status: - patch: - default: - target: 80% - threshold: 0% diff --git a/.evergreen/combine-coverage.sh b/.evergreen/combine-coverage.sh deleted file mode 100755 index 5f04f72adb..0000000000 --- a/.evergreen/combine-coverage.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# -# Coverage combine merges (and removes) all the coverage files and -# generates a new .coverage file in the current directory. - -set -eu - -# Set up the virtual env. -. .evergreen/scripts/setup-dev-env.sh -uv sync --group coverage -source .venv/bin/activate - -ls -la coverage/ - -coverage combine coverage/coverage.* -coverage html -d htmlcov diff --git a/.evergreen/config.yml b/.evergreen/config.yml deleted file mode 100644 index 791dd332f0..0000000000 --- a/.evergreen/config.yml +++ /dev/null @@ -1,84 +0,0 @@ -######################################## -# Evergreen Template for MongoDB Drivers -######################################## - -# When a task that used to pass starts to fail -# Go through all versions that may have been skipped to detect -# when the task started failing -stepback: true - -# Mark a failure as a system/bootstrap failure (purple box) rather then a task -# failure by default. -# Actual testing tasks are marked with `type: test` -command_type: system - -# Protect ourselves against rogue test case, or curl gone wild, that runs forever -# Good rule of thumb: the averageish length a task takes, times 5 -# That roughly accounts for variable system performance for various buildvariants -exec_timeout_secs: 3600 # 60 minutes is the longest we'll ever run (primarily - # for macos hosts) - -# What to do when evergreen hits the timeout (`post:` tasks are run automatically) -timeout: - - command: subprocess.exec - params: - binary: ls -la - -include: - - filename: .evergreen/generated_configs/functions.yml - - filename: .evergreen/generated_configs/tasks.yml - - filename: .evergreen/generated_configs/variants.yml - -pre: - - func: "fetch source" - - func: "setup system" - - func: "assume ec2 role" - -post: - # Disabled, causing timeouts - # - func: "upload working dir" - - func: "teardown system" - - func: "upload codecov" - - func: "upload coverage" - - func: "upload mo artifacts" - - func: "upload test results" - - func: "cleanup" - -tasks: - - name: linkcheck - commands: - - command: subprocess.exec - type: test - params: - binary: bash - args: - - .evergreen/just.sh - - docs-linkcheck - working_dir: src - - - name: resync_specs - commands: - - command: subprocess.exec - params: - binary: bash - include_expansions_in_env: [AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN] - args: - - .evergreen/scripts/resync-all-specs.sh - working_dir: src - -buildvariants: - - name: linkcheck - display_name: "Link Check" - run_on: rhel80-small - cron: '0 0 * * *' - patchable: true - tasks: - - name: linkcheck - - - name: resync_specs - display_name: "Resync Specs" - run_on: rhel80-small - cron: '0 16 * * MON' - patchable: true - tasks: - - name: resync_specs diff --git a/.evergreen/generated_configs/functions.yml b/.evergreen/generated_configs/functions.yml deleted file mode 100644 index cca9166af5..0000000000 --- a/.evergreen/generated_configs/functions.yml +++ /dev/null @@ -1,347 +0,0 @@ -functions: - # Assume ec2 role - assume ec2 role: - - command: ec2.assume_role - params: - role_arn: ${aws_test_secrets_role} - duration_seconds: 3600 - - # Attach benchmark test results - attach benchmark test results: - - command: attach.results - params: - file_location: src/report.json - - # Cleanup - cleanup: - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/scripts/cleanup.sh - working_dir: src - type: test - - # Download and merge coverage - download and merge coverage: - - command: ec2.assume_role - params: - role_arn: ${assume_role_arn} - type: setup - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/scripts/download-and-merge-coverage.sh - - ${bucket_name} - - ${revision} - - ${version_id} - working_dir: src - silent: true - include_expansions_in_env: - - AWS_ACCESS_KEY_ID - - AWS_SECRET_ACCESS_KEY - - AWS_SESSION_TOKEN - type: test - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/combine-coverage.sh - working_dir: src - type: test - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/scripts/upload-coverage-report.sh - - ${bucket_name} - - ${revision} - - ${version_id} - working_dir: src - silent: true - include_expansions_in_env: - - AWS_ACCESS_KEY_ID - - AWS_SECRET_ACCESS_KEY - - AWS_SESSION_TOKEN - type: test - - command: s3.put - params: - remote_file: coverage/${revision}/${version_id}/htmlcov/index.html - aws_key: ${AWS_ACCESS_KEY_ID} - aws_secret: ${AWS_SECRET_ACCESS_KEY} - aws_session_token: ${AWS_SESSION_TOKEN} - bucket: ${bucket_name} - local_file: src/htmlcov/index.html - permissions: public-read - content_type: text/html - display_name: Coverage Report HTML - optional: "true" - type: setup - - # Fetch source - fetch source: - - command: git.get_project - params: - directory: src - - # Run server - run server: - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/just.sh - - run-server - - ${TEST_NAME} - working_dir: src - include_expansions_in_env: - - VERSION - - TOPOLOGY - - AUTH - - SSL - - ORCHESTRATION_FILE - - UV_PYTHON - - UV_PYTHON_PREFERENCE - - STORAGE_ENGINE - - REQUIRE_API_VERSION - - DRIVERS_TOOLS - - TEST_CRYPT_SHARED - - AUTH_AWS - - LOAD_BALANCER - - LOCAL_ATLAS - - NO_EXT - - AWS_ACCESS_KEY_ID - - AWS_SECRET_ACCESS_KEY - - AWS_SESSION_TOKEN - type: test - - command: expansions.update - params: - file: ${DRIVERS_TOOLS}/mo-expansion.yml - - # Run tests - run tests: - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/just.sh - - setup-tests - - ${TEST_NAME} - - ${SUB_TEST_NAME} - working_dir: src - include_expansions_in_env: - - AUTH - - SSL - - AWS_ACCESS_KEY_ID - - AWS_SECRET_ACCESS_KEY - - AWS_SESSION_TOKEN - - COVERAGE - - UV_PYTHON - - UV_PYTHON_PREFERENCE - - LIBMONGOCRYPT_URL - - MONGODB_URI - - DISABLE_TEST_COMMANDS - - GREEN_FRAMEWORK - - NO_EXT - - COMPRESSORS - - MONGODB_API_VERSION - - REQUIRE_API_VERSION - - DEBUG_LOG - - DISABLE_FLAKY - - ORCHESTRATION_FILE - - OCSP_SERVER_TYPE - - VERSION - - IS_WIN32 - - REQUIRE_FIPS - - TEST_MIN_DEPS - - FUZZ_MAX_TIME - type: test - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/just.sh - - run-tests - working_dir: src - type: test - - # Send dashboard data - send dashboard data: - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/scripts/perf-submission-setup.sh - working_dir: src - include_expansions_in_env: - - requester - - revision_order_id - - project_id - - version_id - - build_variant - - parsed_order_id - - task_name - - task_id - - execution - - is_mainline - type: test - - command: expansions.update - params: - file: src/expansion.yml - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/scripts/perf-submission.sh - working_dir: src - include_expansions_in_env: - - requester - - revision_order_id - - project_id - - version_id - - build_variant - - parsed_order_id - - task_name - - task_id - - execution - - is_mainline - type: test - - # Setup system - setup system: - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/scripts/setup-system.sh - working_dir: src - include_expansions_in_env: - - is_patch - - project - - version_id - type: test - - command: expansions.update - params: - file: src/expansion.yml - - # Teardown system - teardown system: - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/just.sh - - teardown-tests - working_dir: src - type: test - - command: subprocess.exec - params: - binary: bash - args: - - ${DRIVERS_TOOLS}/.evergreen/teardown.sh - working_dir: src - type: test - - # Test numpy - test numpy: - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/just.sh - - test-numpy - working_dir: src - include_expansions_in_env: - - UV_PYTHON - - COVERAGE - type: test - - # Upload coverage codecov - upload codecov: - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/scripts/upload-codecov.sh - working_dir: src - include_expansions_in_env: - - CODECOV_TOKEN - - build_variant - - task_name - - github_commit - - github_pr_number - - github_pr_head_branch - - github_author - - requester - - branch_name - type: test - - # Upload coverage - upload coverage: - - command: ec2.assume_role - params: - role_arn: ${assume_role_arn} - type: setup - - command: s3.put - params: - remote_file: coverage/${revision}/${version_id}/coverage/coverage.${build_variant}.${task_name} - aws_key: ${AWS_ACCESS_KEY_ID} - aws_secret: ${AWS_SECRET_ACCESS_KEY} - aws_session_token: ${AWS_SESSION_TOKEN} - bucket: ${bucket_name} - local_file: src/.coverage - permissions: public-read - content_type: text/html - display_name: Raw Coverage Report - optional: "true" - type: setup - - # Upload mo artifacts - upload mo artifacts: - - command: ec2.assume_role - params: - role_arn: ${assume_role_arn} - type: setup - - command: archive.targz_pack - params: - target: mongo-coredumps.tgz - source_dir: ./ - include: - - ./**.core - - ./**.mdmp - - command: s3.put - params: - remote_file: ${build_variant}/${revision}/${version_id}/${build_id}/coredumps/${task_id}-${execution}-mongodb-coredumps.tar.gz - aws_key: ${AWS_ACCESS_KEY_ID} - aws_secret: ${AWS_SECRET_ACCESS_KEY} - aws_session_token: ${AWS_SESSION_TOKEN} - bucket: ${bucket_name} - local_file: mongo-coredumps.tgz - permissions: public-read - content_type: ${content_type|application/x-gzip} - display_name: Core Dumps - Execution - optional: "true" - type: setup - - command: s3.put - params: - remote_file: ${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-drivers-tools-logs.tar.gz - aws_key: ${AWS_ACCESS_KEY_ID} - aws_secret: ${AWS_SECRET_ACCESS_KEY} - aws_session_token: ${AWS_SESSION_TOKEN} - bucket: ${bucket_name} - local_file: ${DRIVERS_TOOLS}/.evergreen/test_logs.tar.gz - permissions: public-read - content_type: ${content_type|application/x-gzip} - display_name: drivers-tools-logs.tar.gz - optional: "true" - type: setup - - # Upload test results - upload test results: - - command: attach.results - params: - file_location: ${DRIVERS_TOOLS}/results.json - - command: attach.xunit_results - params: - file: src/xunit-results/TEST-*.xml diff --git a/.evergreen/generated_configs/tasks.yml b/.evergreen/generated_configs/tasks.yml deleted file mode 100644 index 7c120d0179..0000000000 --- a/.evergreen/generated_configs/tasks.yml +++ /dev/null @@ -1,5687 +0,0 @@ -tasks: - # Aws lambda tests - - name: test-aws-lambda-deployed - commands: - - func: assume ec2 role - - func: run tests - vars: - TEST_NAME: aws_lambda - tags: [aws_lambda] - - # Aws tests - - name: test-auth-aws-4.4-regular-python3.11-min-deps - commands: - - func: run server - vars: - AUTH_AWS: "1" - VERSION: "4.4" - - func: assume ec2 role - - func: run tests - vars: - TEST_NAME: auth_aws - SUB_TEST_NAME: regular - UV_PYTHON: "3.11" - TEST_MIN_DEPS: "1" - tags: [auth-aws, auth-aws-regular] - - name: test-auth-aws-5.0-assume-role-python3.12 - commands: - - func: run server - vars: - AUTH_AWS: "1" - VERSION: "5.0" - - func: assume ec2 role - - func: run tests - vars: - TEST_NAME: auth_aws - SUB_TEST_NAME: assume-role - UV_PYTHON: "3.12" - tags: [auth-aws, auth-aws-assume-role] - - name: test-auth-aws-6.0-ec2-python3.13 - commands: - - func: run server - vars: - AUTH_AWS: "1" - VERSION: "6.0" - - func: assume ec2 role - - func: run tests - vars: - TEST_NAME: auth_aws - SUB_TEST_NAME: ec2 - UV_PYTHON: "3.13" - tags: [auth-aws, auth-aws-ec2] - - name: test-auth-aws-7.0-env-creds-python3.14t - commands: - - func: run server - vars: - AUTH_AWS: "1" - VERSION: "7.0" - - func: assume ec2 role - - func: run tests - vars: - TEST_NAME: auth_aws - SUB_TEST_NAME: env-creds - UV_PYTHON: 3.14t - tags: [auth-aws, auth-aws-env-creds, free-threaded] - - name: test-auth-aws-8.0-session-creds-python3.14 - commands: - - func: run server - vars: - AUTH_AWS: "1" - VERSION: "8.0" - - func: assume ec2 role - - func: run tests - vars: - TEST_NAME: auth_aws - SUB_TEST_NAME: session-creds - UV_PYTHON: "3.14" - tags: [auth-aws, auth-aws-session-creds] - - name: test-auth-aws-9.0-regular-python3.11-min-deps-cov - commands: - - func: run server - vars: - AUTH_AWS: "1" - VERSION: "9.0" - - func: assume ec2 role - - func: run tests - vars: - TEST_NAME: auth_aws - SUB_TEST_NAME: regular - UV_PYTHON: "3.11" - TEST_MIN_DEPS: "1" - COVERAGE: "1" - tags: [auth-aws, auth-aws-regular, pr] - - name: test-auth-aws-9.0-regular-python3.15-cov - commands: - - func: run server - vars: - AUTH_AWS: "1" - VERSION: "9.0" - - func: assume ec2 role - - func: run tests - vars: - TEST_NAME: auth_aws - SUB_TEST_NAME: regular - UV_PYTHON: "3.15" - COVERAGE: "1" - tags: [auth-aws, auth-aws-regular, pr] - - name: test-auth-aws-9.0-web-identity-python3.15t - commands: - - func: run server - vars: - AUTH_AWS: "1" - VERSION: "9.0" - - func: assume ec2 role - - func: run tests - vars: - TEST_NAME: auth_aws - SUB_TEST_NAME: web-identity - UV_PYTHON: 3.15t - tags: [auth-aws, auth-aws-web-identity, free-threaded] - - name: test-auth-aws-9.0-web-identity-session-name-python3.15t - commands: - - func: run server - vars: - AUTH_AWS: "1" - VERSION: "9.0" - - func: assume ec2 role - - func: run tests - vars: - TEST_NAME: auth_aws - SUB_TEST_NAME: web-identity - AWS_ROLE_SESSION_NAME: test - UV_PYTHON: 3.15t - tags: [auth-aws, auth-aws-web-identity, free-threaded] - - name: test-auth-aws-latest-assume-role-python3.11-min-deps - commands: - - func: run server - vars: - AUTH_AWS: "1" - VERSION: latest - - func: assume ec2 role - - func: run tests - vars: - TEST_NAME: auth_aws - SUB_TEST_NAME: assume-role - UV_PYTHON: "3.11" - TEST_MIN_DEPS: "1" - tags: [auth-aws, auth-aws-assume-role] - - name: test-auth-aws-rapid-regular-python3.15-cov - commands: - - func: run server - vars: - AUTH_AWS: "1" - VERSION: rapid - - func: assume ec2 role - - func: run tests - vars: - TEST_NAME: auth_aws - SUB_TEST_NAME: regular - UV_PYTHON: "3.15" - COVERAGE: "1" - tags: [auth-aws, auth-aws-regular] - - name: test-auth-aws-ecs - commands: - - func: assume ec2 role - - func: run server - vars: - VERSION: "8.0" - - func: run tests - vars: - TEST_NAME: auth_aws - SUB_TEST_NAME: ecs - tags: [auth-aws-ecs] - - # Backport pr tests - - name: backport-pr - commands: - - func: assume ec2 role - - command: subprocess.exec - params: - binary: bash - args: - - ${DRIVERS_TOOLS}/.evergreen/github_app/backport-pr.sh - - mongodb - - mongo-python-driver - - ${github_commit} - working_dir: src - include_expansions_in_env: - - AWS_ACCESS_KEY_ID - - AWS_SECRET_ACCESS_KEY - - AWS_SESSION_TOKEN - type: test - - # Coverage report tests - - name: coverage-report - commands: - - func: download and merge coverage - depends_on: [{ name: .server-version, variant: .coverage_tag, status: "*", patch_optional: true }] - tags: [coverage, pr] - - # Fuzz tests - - name: fuzz-regression - commands: - - func: run tests - vars: - TEST_NAME: fuzz - SUB_TEST_NAME: regression - UV_PYTHON: "3.13" - tags: [fuzz, fuzz-regression, pr] - - name: fuzz - commands: - - func: run tests - vars: - TEST_NAME: fuzz - SUB_TEST_NAME: fuzz - UV_PYTHON: "3.13" - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/scripts/harvest-fuzz-corpus.sh - working_dir: src - include_expansions_in_env: - - is_patch - - FUZZ_CORPUS_MAX_UNITS - - FUZZ_CORPUS_MAX_UNIT_BYTES - - AWS_ACCESS_KEY_ID - - AWS_SECRET_ACCESS_KEY - - AWS_SESSION_TOKEN - type: test - tags: [fuzz, fuzz-nightly] - - # Getdata tests - - name: getdata - commands: - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/scripts/run-getdata.sh - working_dir: src - type: test - - # Import time tests - - name: check-import-time - commands: - - command: subprocess.exec - params: - binary: bash - args: - - .evergreen/scripts/check-import-time.sh - - ${revision} - - ${github_commit} - working_dir: src - type: test - tags: [pr] - - # Kms tests - - name: test-gcpkms - commands: - - func: run tests - vars: - TEST_NAME: kms - SUB_TEST_NAME: gcp - tags: [] - - name: test-gcpkms-fail - commands: - - func: run server - - func: run tests - vars: - TEST_NAME: kms - SUB_TEST_NAME: gcp-fail - tags: [pr] - - name: test-azurekms - commands: - - func: run tests - vars: - TEST_NAME: kms - SUB_TEST_NAME: azure - tags: [] - - name: test-azurekms-fail - commands: - - func: run server - - func: run tests - vars: - TEST_NAME: kms - SUB_TEST_NAME: azure-fail - tags: [pr] - - # Min support tests - - name: test-min-support-python3.11-standalone-noauth-nossl - commands: - - func: run server - - func: run tests - vars: - UV_PYTHON: "3.11" - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - tags: [test-min-support] - - name: test-min-support-python3.11-replica-set-noauth-ssl - commands: - - func: run server - - func: run tests - vars: - UV_PYTHON: "3.11" - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - tags: [test-min-support] - - name: test-min-support-python3.11-sharded-cluster-auth-ssl - commands: - - func: run server - - func: run tests - vars: - UV_PYTHON: "3.11" - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - tags: [test-min-support] - - # No orchestration tests - - name: test-no-orchestration-python3.11-min-deps - commands: - - func: assume ec2 role - - func: run tests - vars: - UV_PYTHON: "3.11" - TEST_MIN_DEPS: "1" - tags: [test-no-orchestration, python-3.11] - - name: test-no-orchestration-python3.15 - commands: - - func: assume ec2 role - - func: run tests - vars: - UV_PYTHON: "3.15" - tags: [test-no-orchestration, python-3.15] - - # No toolchain tests - - name: test-no-toolchain-sync-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - TEST_NAME: default_sync - tags: [test-no-toolchain, standalone-noauth-nossl] - - name: test-no-toolchain-async-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - TEST_NAME: default_async - tags: [test-no-toolchain, replica_set-noauth-ssl] - - name: test-no-toolchain-sync-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - TEST_NAME: default_sync - tags: [test-no-toolchain, sharded_cluster-auth-ssl] - - # Ocsp tests - - name: test-ocsp-ecdsa-valid-cert-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "4.4"] - - name: test-ocsp-ecdsa-valid-cert-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "5.0"] - - name: test-ocsp-ecdsa-valid-cert-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "6.0"] - - name: test-ocsp-ecdsa-valid-cert-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "7.0"] - - name: test-ocsp-ecdsa-valid-cert-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "8.0"] - - name: test-ocsp-ecdsa-valid-cert-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "9.0"] - - name: test-ocsp-ecdsa-valid-cert-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, rapid] - - name: test-ocsp-ecdsa-valid-cert-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-ecdsa, latest] - - name: test-ocsp-ecdsa-invalid-cert-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "4.4"] - - name: test-ocsp-ecdsa-invalid-cert-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "5.0"] - - name: test-ocsp-ecdsa-invalid-cert-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "6.0"] - - name: test-ocsp-ecdsa-invalid-cert-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "7.0"] - - name: test-ocsp-ecdsa-invalid-cert-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "8.0"] - - name: test-ocsp-ecdsa-invalid-cert-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "9.0"] - - name: test-ocsp-ecdsa-invalid-cert-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, rapid] - - name: test-ocsp-ecdsa-invalid-cert-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-ecdsa, latest] - - name: test-ocsp-ecdsa-delegate-valid-cert-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "4.4"] - - name: test-ocsp-ecdsa-delegate-valid-cert-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "5.0"] - - name: test-ocsp-ecdsa-delegate-valid-cert-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "6.0"] - - name: test-ocsp-ecdsa-delegate-valid-cert-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "7.0"] - - name: test-ocsp-ecdsa-delegate-valid-cert-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "8.0"] - - name: test-ocsp-ecdsa-delegate-valid-cert-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "9.0"] - - name: test-ocsp-ecdsa-delegate-valid-cert-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, rapid] - - name: test-ocsp-ecdsa-delegate-valid-cert-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-ecdsa, latest] - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "4.4"] - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "5.0"] - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "6.0"] - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "7.0"] - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "8.0"] - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "9.0"] - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, rapid] - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-ecdsa, latest] - - name: test-ocsp-ecdsa-soft-fail-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "4.4"] - - name: test-ocsp-ecdsa-soft-fail-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "5.0"] - - name: test-ocsp-ecdsa-soft-fail-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "6.0"] - - name: test-ocsp-ecdsa-soft-fail-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "7.0"] - - name: test-ocsp-ecdsa-soft-fail-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "8.0"] - - name: test-ocsp-ecdsa-soft-fail-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "9.0"] - - name: test-ocsp-ecdsa-soft-fail-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, rapid] - - name: test-ocsp-ecdsa-soft-fail-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-ecdsa, latest] - - name: test-ocsp-ecdsa-valid-cert-server-staples-v4.4-python3.11-min-deps-cov - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - COVERAGE: "1" - tags: - - ocsp - - ocsp-ecdsa - - "4.4" - - ocsp-staple - - pr - - name: test-ocsp-ecdsa-valid-cert-server-staples-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "5.0" - - ocsp-staple - - name: test-ocsp-ecdsa-valid-cert-server-staples-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "6.0" - - ocsp-staple - - name: test-ocsp-ecdsa-valid-cert-server-staples-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "7.0" - - ocsp-staple - - name: test-ocsp-ecdsa-valid-cert-server-staples-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "8.0" - - ocsp-staple - - name: test-ocsp-ecdsa-valid-cert-server-staples-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "9.0" - - ocsp-staple - - name: test-ocsp-ecdsa-valid-cert-server-staples-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - rapid - - ocsp-staple - - name: test-ocsp-ecdsa-valid-cert-server-staples-latest-python3.15-cov - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - COVERAGE: "1" - tags: - - ocsp - - ocsp-ecdsa - - latest - - ocsp-staple - - name: test-ocsp-ecdsa-valid-cert-server-staples-v9.0-python3.15-cov - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: "9.0" - COVERAGE: "1" - tags: - - ocsp - - ocsp-ecdsa - - "9.0" - - ocsp-staple - - pr - - name: test-ocsp-ecdsa-invalid-cert-server-staples-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "4.4" - - ocsp-staple - - name: test-ocsp-ecdsa-invalid-cert-server-staples-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "5.0" - - ocsp-staple - - name: test-ocsp-ecdsa-invalid-cert-server-staples-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "6.0" - - ocsp-staple - - name: test-ocsp-ecdsa-invalid-cert-server-staples-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "7.0" - - ocsp-staple - - name: test-ocsp-ecdsa-invalid-cert-server-staples-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "8.0" - - ocsp-staple - - name: test-ocsp-ecdsa-invalid-cert-server-staples-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "9.0" - - ocsp-staple - - name: test-ocsp-ecdsa-invalid-cert-server-staples-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - rapid - - ocsp-staple - - name: test-ocsp-ecdsa-invalid-cert-server-staples-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: - - ocsp - - ocsp-ecdsa - - latest - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-valid-cert-server-staples-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "4.4" - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-valid-cert-server-staples-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "5.0" - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-valid-cert-server-staples-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "6.0" - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-valid-cert-server-staples-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "7.0" - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-valid-cert-server-staples-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "8.0" - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-valid-cert-server-staples-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "9.0" - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-valid-cert-server-staples-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - rapid - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-valid-cert-server-staples-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: - - ocsp - - ocsp-ecdsa - - latest - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-staples-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "4.4" - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-staples-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "5.0" - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-staples-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "6.0" - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-staples-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "7.0" - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-staples-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "8.0" - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-staples-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - "9.0" - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-staples-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-ecdsa - - rapid - - ocsp-staple - - name: test-ocsp-ecdsa-delegate-invalid-cert-server-staples-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: - - ocsp - - ocsp-ecdsa - - latest - - ocsp-staple - - name: test-ocsp-ecdsa-malicious-invalid-cert-muststaple-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "4.4"] - - name: test-ocsp-ecdsa-malicious-invalid-cert-muststaple-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "5.0"] - - name: test-ocsp-ecdsa-malicious-invalid-cert-muststaple-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "6.0"] - - name: test-ocsp-ecdsa-malicious-invalid-cert-muststaple-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "7.0"] - - name: test-ocsp-ecdsa-malicious-invalid-cert-muststaple-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "8.0"] - - name: test-ocsp-ecdsa-malicious-invalid-cert-muststaple-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "9.0"] - - name: test-ocsp-ecdsa-malicious-invalid-cert-muststaple-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, rapid] - - name: test-ocsp-ecdsa-malicious-invalid-cert-muststaple-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-ecdsa, latest] - - name: test-ocsp-ecdsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "4.4"] - - name: test-ocsp-ecdsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "5.0"] - - name: test-ocsp-ecdsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "6.0"] - - name: test-ocsp-ecdsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "7.0"] - - name: test-ocsp-ecdsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "8.0"] - - name: test-ocsp-ecdsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "9.0"] - - name: test-ocsp-ecdsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, rapid] - - name: test-ocsp-ecdsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-ecdsa, latest] - - name: test-ocsp-ecdsa-malicious-no-responder-muststaple-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "4.4"] - - name: test-ocsp-ecdsa-malicious-no-responder-muststaple-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "5.0"] - - name: test-ocsp-ecdsa-malicious-no-responder-muststaple-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "6.0"] - - name: test-ocsp-ecdsa-malicious-no-responder-muststaple-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "7.0"] - - name: test-ocsp-ecdsa-malicious-no-responder-muststaple-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "8.0"] - - name: test-ocsp-ecdsa-malicious-no-responder-muststaple-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, "9.0"] - - name: test-ocsp-ecdsa-malicious-no-responder-muststaple-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-ecdsa, rapid] - - name: test-ocsp-ecdsa-malicious-no-responder-muststaple-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: ecdsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-ecdsa, latest] - - name: test-ocsp-rsa-valid-cert-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "4.4"] - - name: test-ocsp-rsa-valid-cert-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "5.0"] - - name: test-ocsp-rsa-valid-cert-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "6.0"] - - name: test-ocsp-rsa-valid-cert-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "7.0"] - - name: test-ocsp-rsa-valid-cert-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "8.0"] - - name: test-ocsp-rsa-valid-cert-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "9.0"] - - name: test-ocsp-rsa-valid-cert-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, rapid] - - name: test-ocsp-rsa-valid-cert-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-rsa, latest] - - name: test-ocsp-rsa-invalid-cert-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "4.4"] - - name: test-ocsp-rsa-invalid-cert-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "5.0"] - - name: test-ocsp-rsa-invalid-cert-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "6.0"] - - name: test-ocsp-rsa-invalid-cert-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "7.0"] - - name: test-ocsp-rsa-invalid-cert-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "8.0"] - - name: test-ocsp-rsa-invalid-cert-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "9.0"] - - name: test-ocsp-rsa-invalid-cert-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, rapid] - - name: test-ocsp-rsa-invalid-cert-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-rsa, latest] - - name: test-ocsp-rsa-delegate-valid-cert-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "4.4"] - - name: test-ocsp-rsa-delegate-valid-cert-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "5.0"] - - name: test-ocsp-rsa-delegate-valid-cert-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "6.0"] - - name: test-ocsp-rsa-delegate-valid-cert-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "7.0"] - - name: test-ocsp-rsa-delegate-valid-cert-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "8.0"] - - name: test-ocsp-rsa-delegate-valid-cert-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "9.0"] - - name: test-ocsp-rsa-delegate-valid-cert-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, rapid] - - name: test-ocsp-rsa-delegate-valid-cert-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-rsa, latest] - - name: test-ocsp-rsa-delegate-invalid-cert-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "4.4"] - - name: test-ocsp-rsa-delegate-invalid-cert-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "5.0"] - - name: test-ocsp-rsa-delegate-invalid-cert-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "6.0"] - - name: test-ocsp-rsa-delegate-invalid-cert-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "7.0"] - - name: test-ocsp-rsa-delegate-invalid-cert-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "8.0"] - - name: test-ocsp-rsa-delegate-invalid-cert-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "9.0"] - - name: test-ocsp-rsa-delegate-invalid-cert-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, rapid] - - name: test-ocsp-rsa-delegate-invalid-cert-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-rsa, latest] - - name: test-ocsp-rsa-soft-fail-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "4.4"] - - name: test-ocsp-rsa-soft-fail-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "5.0"] - - name: test-ocsp-rsa-soft-fail-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "6.0"] - - name: test-ocsp-rsa-soft-fail-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "7.0"] - - name: test-ocsp-rsa-soft-fail-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "8.0"] - - name: test-ocsp-rsa-soft-fail-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "9.0"] - - name: test-ocsp-rsa-soft-fail-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, rapid] - - name: test-ocsp-rsa-soft-fail-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-rsa, latest] - - name: test-ocsp-rsa-valid-cert-server-staples-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "4.4" - - ocsp-staple - - name: test-ocsp-rsa-valid-cert-server-staples-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "5.0" - - ocsp-staple - - name: test-ocsp-rsa-valid-cert-server-staples-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "6.0" - - ocsp-staple - - name: test-ocsp-rsa-valid-cert-server-staples-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "7.0" - - ocsp-staple - - name: test-ocsp-rsa-valid-cert-server-staples-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "8.0" - - ocsp-staple - - name: test-ocsp-rsa-valid-cert-server-staples-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "9.0" - - ocsp-staple - - name: test-ocsp-rsa-valid-cert-server-staples-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - rapid - - ocsp-staple - - name: test-ocsp-rsa-valid-cert-server-staples-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: - - ocsp - - ocsp-rsa - - latest - - ocsp-staple - - name: test-ocsp-rsa-invalid-cert-server-staples-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "4.4" - - ocsp-staple - - name: test-ocsp-rsa-invalid-cert-server-staples-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "5.0" - - ocsp-staple - - name: test-ocsp-rsa-invalid-cert-server-staples-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "6.0" - - ocsp-staple - - name: test-ocsp-rsa-invalid-cert-server-staples-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "7.0" - - ocsp-staple - - name: test-ocsp-rsa-invalid-cert-server-staples-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "8.0" - - ocsp-staple - - name: test-ocsp-rsa-invalid-cert-server-staples-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "9.0" - - ocsp-staple - - name: test-ocsp-rsa-invalid-cert-server-staples-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - rapid - - ocsp-staple - - name: test-ocsp-rsa-invalid-cert-server-staples-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: - - ocsp - - ocsp-rsa - - latest - - ocsp-staple - - name: test-ocsp-rsa-delegate-valid-cert-server-staples-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "4.4" - - ocsp-staple - - name: test-ocsp-rsa-delegate-valid-cert-server-staples-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "5.0" - - ocsp-staple - - name: test-ocsp-rsa-delegate-valid-cert-server-staples-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "6.0" - - ocsp-staple - - name: test-ocsp-rsa-delegate-valid-cert-server-staples-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "7.0" - - ocsp-staple - - name: test-ocsp-rsa-delegate-valid-cert-server-staples-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "8.0" - - ocsp-staple - - name: test-ocsp-rsa-delegate-valid-cert-server-staples-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "9.0" - - ocsp-staple - - name: test-ocsp-rsa-delegate-valid-cert-server-staples-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - rapid - - ocsp-staple - - name: test-ocsp-rsa-delegate-valid-cert-server-staples-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: valid-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: - - ocsp - - ocsp-rsa - - latest - - ocsp-staple - - name: test-ocsp-rsa-delegate-invalid-cert-server-staples-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "4.4" - - ocsp-staple - - name: test-ocsp-rsa-delegate-invalid-cert-server-staples-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "5.0" - - ocsp-staple - - name: test-ocsp-rsa-delegate-invalid-cert-server-staples-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "6.0" - - ocsp-staple - - name: test-ocsp-rsa-delegate-invalid-cert-server-staples-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "7.0" - - ocsp-staple - - name: test-ocsp-rsa-delegate-invalid-cert-server-staples-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "8.0" - - ocsp-staple - - name: test-ocsp-rsa-delegate-invalid-cert-server-staples-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - "9.0" - - ocsp-staple - - name: test-ocsp-rsa-delegate-invalid-cert-server-staples-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: - - ocsp - - ocsp-rsa - - rapid - - ocsp-staple - - name: test-ocsp-rsa-delegate-invalid-cert-server-staples-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: - - ocsp - - ocsp-rsa - - latest - - ocsp-staple - - name: test-ocsp-rsa-malicious-invalid-cert-muststaple-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "4.4"] - - name: test-ocsp-rsa-malicious-invalid-cert-muststaple-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "5.0"] - - name: test-ocsp-rsa-malicious-invalid-cert-muststaple-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "6.0"] - - name: test-ocsp-rsa-malicious-invalid-cert-muststaple-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "7.0"] - - name: test-ocsp-rsa-malicious-invalid-cert-muststaple-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "8.0"] - - name: test-ocsp-rsa-malicious-invalid-cert-muststaple-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "9.0"] - - name: test-ocsp-rsa-malicious-invalid-cert-muststaple-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, rapid] - - name: test-ocsp-rsa-malicious-invalid-cert-muststaple-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-rsa, latest] - - name: test-ocsp-rsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "4.4"] - - name: test-ocsp-rsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "5.0"] - - name: test-ocsp-rsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "6.0"] - - name: test-ocsp-rsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "7.0"] - - name: test-ocsp-rsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "8.0"] - - name: test-ocsp-rsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "9.0"] - - name: test-ocsp-rsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, rapid] - - name: test-ocsp-rsa-delegate-malicious-invalid-cert-muststaple-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: revoked-delegate - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-rsa, latest] - - name: test-ocsp-rsa-malicious-no-responder-muststaple-server-does-not-staple-v4.4-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "4.4" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "4.4"] - - name: test-ocsp-rsa-malicious-no-responder-muststaple-server-does-not-staple-v5.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "5.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "5.0"] - - name: test-ocsp-rsa-malicious-no-responder-muststaple-server-does-not-staple-v6.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "6.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "6.0"] - - name: test-ocsp-rsa-malicious-no-responder-muststaple-server-does-not-staple-v7.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "7.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "7.0"] - - name: test-ocsp-rsa-malicious-no-responder-muststaple-server-does-not-staple-v8.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "8.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "8.0"] - - name: test-ocsp-rsa-malicious-no-responder-muststaple-server-does-not-staple-v9.0-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: "9.0" - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, "9.0"] - - name: test-ocsp-rsa-malicious-no-responder-muststaple-server-does-not-staple-rapid-python3.11-min-deps - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.11" - VERSION: rapid - TEST_MIN_DEPS: "1" - tags: [ocsp, ocsp-rsa, rapid] - - name: test-ocsp-rsa-malicious-no-responder-muststaple-server-does-not-staple-latest-python3.15 - commands: - - func: run tests - vars: - ORCHESTRATION_FILE: rsa-basic-tls-ocsp-mustStaple-disableStapling.json - OCSP_SERVER_TYPE: no-responder - TEST_NAME: ocsp - UV_PYTHON: "3.15" - VERSION: latest - tags: [ocsp, ocsp-rsa, latest] - - # Oidc tests - - name: test-auth-oidc-default - commands: - - func: run tests - vars: - TEST_NAME: auth_oidc - SUB_TEST_NAME: default - tags: [auth_oidc] - - name: test-auth-oidc-azure - commands: - - func: run tests - vars: - TEST_NAME: auth_oidc - SUB_TEST_NAME: azure - tags: [auth_oidc, auth_oidc_remote] - - name: test-auth-oidc-gcp - commands: - - func: run tests - vars: - TEST_NAME: auth_oidc - SUB_TEST_NAME: gcp - tags: [auth_oidc, auth_oidc_remote] - - name: test-auth-oidc-eks - commands: - - func: run tests - vars: - TEST_NAME: auth_oidc - SUB_TEST_NAME: eks - tags: [auth_oidc, auth_oidc_remote] - - name: test-auth-oidc-aks - commands: - - func: run tests - vars: - TEST_NAME: auth_oidc - SUB_TEST_NAME: aks - tags: [auth_oidc, auth_oidc_remote] - - name: test-auth-oidc-gke - commands: - - func: run tests - vars: - TEST_NAME: auth_oidc - SUB_TEST_NAME: gke - tags: [auth_oidc, auth_oidc_remote] - - # Perf tests - - name: perf-8.0-standalone-ssl - commands: - - func: run server - vars: - VERSION: v8.0-perf - SSL: ssl - UV_PYTHON: 3.11.9 - UV_PYTHON_PREFERENCE: only-managed - - func: run tests - vars: - TEST_NAME: perf - SUB_TEST_NAME: sync - UV_PYTHON: 3.11.9 - UV_PYTHON_PREFERENCE: only-managed - - func: attach benchmark test results - - func: send dashboard data - tags: [perf] - - name: perf-8.0-standalone-ssl-async - commands: - - func: run server - vars: - VERSION: v8.0-perf - SSL: ssl - UV_PYTHON: 3.11.9 - UV_PYTHON_PREFERENCE: only-managed - - func: run tests - vars: - TEST_NAME: perf - SUB_TEST_NAME: async - UV_PYTHON: 3.11.9 - UV_PYTHON_PREFERENCE: only-managed - - func: attach benchmark test results - - func: send dashboard data - tags: [perf] - - name: perf-8.0-standalone - commands: - - func: run server - vars: - VERSION: v8.0-perf - SSL: nossl - UV_PYTHON: 3.11.9 - UV_PYTHON_PREFERENCE: only-managed - - func: run tests - vars: - TEST_NAME: perf - SUB_TEST_NAME: sync - UV_PYTHON: 3.11.9 - UV_PYTHON_PREFERENCE: only-managed - - func: attach benchmark test results - - func: send dashboard data - tags: [perf] - - name: perf-8.0-standalone-async - commands: - - func: run server - vars: - VERSION: v8.0-perf - SSL: nossl - UV_PYTHON: 3.11.9 - UV_PYTHON_PREFERENCE: only-managed - - func: run tests - vars: - TEST_NAME: perf - SUB_TEST_NAME: async - UV_PYTHON: 3.11.9 - UV_PYTHON_PREFERENCE: only-managed - - func: attach benchmark test results - - func: send dashboard data - tags: [perf] - - # Sanitizer tests - - name: test-sanitizer - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - TEST_NAME: sanitizer - tags: [sanitizer, pr] - - # Search index tests - - name: test-search-index-helpers - commands: - - func: assume ec2 role - - func: run server - vars: - TEST_NAME: search_index - - func: run tests - vars: - TEST_NAME: search_index - UV_PYTHON: "3.11" - tags: [search_index] - - # Server version tests - - name: test-server-version-python3.14-async-auth-nossl-replica-set - commands: - - func: run server - vars: - AUTH: auth - SSL: nossl - TOPOLOGY: replica_set - - func: run tests - vars: - AUTH: auth - SSL: nossl - TOPOLOGY: replica_set - UV_PYTHON: "3.14" - TEST_NAME: default_async - tags: - - server-version - - python-3.14 - - replica_set-auth-nossl - - async - - name: test-server-version-python3.14t-sync-auth-nossl-replica-set - commands: - - func: run server - vars: - AUTH: auth - SSL: nossl - TOPOLOGY: replica_set - - func: run tests - vars: - AUTH: auth - SSL: nossl - TOPOLOGY: replica_set - UV_PYTHON: 3.14t - TEST_NAME: default_sync - tags: - - server-version - - python-3.14t - - replica_set-auth-nossl - - sync - - free-threaded - - name: test-server-version-python3.13-async-auth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: replica_set - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: replica_set - UV_PYTHON: "3.13" - TEST_NAME: default_async - tags: - - server-version - - python-3.13 - - replica_set-auth-ssl - - async - - name: test-server-version-python3.12-sync-auth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: replica_set - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: replica_set - UV_PYTHON: "3.12" - TEST_NAME: default_sync - tags: - - server-version - - python-3.12 - - replica_set-auth-ssl - - sync - - name: test-server-version-python3.12-async-noauth-nossl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: replica_set - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: replica_set - UV_PYTHON: "3.12" - TEST_NAME: default_async - tags: - - server-version - - python-3.12 - - replica_set-noauth-nossl - - async - - name: test-server-version-python3.11-sync-noauth-nossl-replica-set-min-deps - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: replica_set - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: replica_set - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_sync - tags: - - server-version - - python-3.11 - - replica_set-noauth-nossl - - sync - - name: test-server-version-python3.15-async-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - UV_PYTHON: "3.15" - TEST_NAME: default_async - tags: - - server-version - - python-3.15 - - replica_set-noauth-ssl - - async - - name: test-server-version-python3.15t-sync-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - UV_PYTHON: 3.15t - TEST_NAME: default_sync - tags: - - server-version - - python-3.15t - - replica_set-noauth-ssl - - sync - - free-threaded - - name: test-server-version-python3.15t-async-auth-nossl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: nossl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: auth - SSL: nossl - TOPOLOGY: sharded_cluster - UV_PYTHON: 3.15t - TEST_NAME: default_async - tags: - - server-version - - python-3.15t - - sharded_cluster-auth-nossl - - async - - free-threaded - - name: test-server-version-python3.14-sync-auth-nossl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: nossl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: auth - SSL: nossl - TOPOLOGY: sharded_cluster - UV_PYTHON: "3.14" - TEST_NAME: default_sync - tags: - - server-version - - python-3.14 - - sharded_cluster-auth-nossl - - sync - - name: test-server-version-python3.11-async-auth-ssl-sharded-cluster-min-deps - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_async - tags: - - server-version - - python-3.11 - - sharded_cluster-auth-ssl - - async - - name: test-server-version-python3.12-async-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - UV_PYTHON: "3.12" - TEST_NAME: default_async - tags: - - server-version - - python-3.12 - - sharded_cluster-auth-ssl - - async - - name: test-server-version-python3.13-async-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - UV_PYTHON: "3.13" - TEST_NAME: default_async - tags: - - server-version - - python-3.13 - - sharded_cluster-auth-ssl - - async - - name: test-server-version-python3.14-async-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - UV_PYTHON: "3.14" - TEST_NAME: default_async - tags: - - server-version - - python-3.14 - - sharded_cluster-auth-ssl - - async - - name: test-server-version-python3.14t-async-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - UV_PYTHON: 3.14t - TEST_NAME: default_async - tags: - - server-version - - python-3.14t - - sharded_cluster-auth-ssl - - async - - free-threaded - - name: test-server-version-python3.15-async-auth-ssl-sharded-cluster-cov - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - COVERAGE: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - COVERAGE: "1" - UV_PYTHON: "3.15" - TEST_NAME: default_async - tags: - - server-version - - python-3.15 - - sharded_cluster-auth-ssl - - async - - name: test-server-version-python3.15t-async-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - UV_PYTHON: 3.15t - TEST_NAME: default_async - tags: - - server-version - - python-3.15t - - sharded_cluster-auth-ssl - - async - - free-threaded - - name: test-server-version-python3.11-sync-auth-ssl-sharded-cluster-min-deps - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_sync - tags: - - server-version - - python-3.11 - - sharded_cluster-auth-ssl - - sync - - name: test-server-version-python3.12-sync-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - UV_PYTHON: "3.12" - TEST_NAME: default_sync - tags: - - server-version - - python-3.12 - - sharded_cluster-auth-ssl - - sync - - name: test-server-version-python3.13-sync-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - UV_PYTHON: "3.13" - TEST_NAME: default_sync - tags: - - server-version - - python-3.13 - - sharded_cluster-auth-ssl - - sync - - name: test-server-version-python3.14-sync-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - UV_PYTHON: "3.14" - TEST_NAME: default_sync - tags: - - server-version - - python-3.14 - - sharded_cluster-auth-ssl - - sync - - name: test-server-version-python3.14t-sync-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - UV_PYTHON: 3.14t - TEST_NAME: default_sync - tags: - - server-version - - python-3.14t - - sharded_cluster-auth-ssl - - sync - - free-threaded - - name: test-server-version-python3.15-sync-auth-ssl-sharded-cluster-cov - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - COVERAGE: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - COVERAGE: "1" - UV_PYTHON: "3.15" - TEST_NAME: default_sync - tags: - - server-version - - python-3.15 - - sharded_cluster-auth-ssl - - sync - - name: test-server-version-python3.15t-sync-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - UV_PYTHON: 3.15t - TEST_NAME: default_sync - tags: - - server-version - - python-3.15t - - sharded_cluster-auth-ssl - - sync - - free-threaded - - name: test-server-version-python3.13-async-noauth-nossl-sharded-cluster - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: sharded_cluster - UV_PYTHON: "3.13" - TEST_NAME: default_async - tags: - - server-version - - python-3.13 - - sharded_cluster-noauth-nossl - - async - - name: test-server-version-python3.12-sync-noauth-nossl-sharded-cluster - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: sharded_cluster - UV_PYTHON: "3.12" - TEST_NAME: default_sync - tags: - - server-version - - python-3.12 - - sharded_cluster-noauth-nossl - - sync - - name: test-server-version-python3.11-async-noauth-ssl-sharded-cluster-min-deps - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: sharded_cluster - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: sharded_cluster - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_async - tags: - - server-version - - python-3.11 - - sharded_cluster-noauth-ssl - - async - - name: test-server-version-python3.15-sync-noauth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: sharded_cluster - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: sharded_cluster - UV_PYTHON: "3.15" - TEST_NAME: default_sync - tags: - - server-version - - python-3.15 - - sharded_cluster-noauth-ssl - - sync - - name: test-server-version-python3.14t-async-auth-nossl-standalone - commands: - - func: run server - vars: - AUTH: auth - SSL: nossl - TOPOLOGY: standalone - - func: run tests - vars: - AUTH: auth - SSL: nossl - TOPOLOGY: standalone - UV_PYTHON: 3.14t - TEST_NAME: default_async - tags: - - server-version - - python-3.14t - - standalone-auth-nossl - - async - - free-threaded - - name: test-server-version-python3.13-sync-auth-nossl-standalone - commands: - - func: run server - vars: - AUTH: auth - SSL: nossl - TOPOLOGY: standalone - - func: run tests - vars: - AUTH: auth - SSL: nossl - TOPOLOGY: standalone - UV_PYTHON: "3.13" - TEST_NAME: default_sync - tags: - - server-version - - python-3.13 - - standalone-auth-nossl - - sync - - name: test-server-version-python3.12-async-auth-ssl-standalone - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: standalone - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: standalone - UV_PYTHON: "3.12" - TEST_NAME: default_async - tags: - - server-version - - python-3.12 - - standalone-auth-ssl - - async - - name: test-server-version-python3.11-sync-auth-ssl-standalone-min-deps - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: standalone - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: standalone - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_sync - tags: - - server-version - - python-3.11 - - standalone-auth-ssl - - sync - - name: test-server-version-python3.11-async-noauth-nossl-standalone-min-deps-cov - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - TEST_MIN_DEPS: "1" - COVERAGE: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - TEST_MIN_DEPS: "1" - COVERAGE: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_async - tags: - - server-version - - python-3.11 - - standalone-noauth-nossl - - async - - name: test-server-version-python3.15-sync-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - UV_PYTHON: "3.15" - TEST_NAME: default_sync - tags: - - server-version - - python-3.15 - - standalone-noauth-nossl - - sync - - name: test-server-version-python3.15t-async-noauth-ssl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: standalone - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: standalone - UV_PYTHON: 3.15t - TEST_NAME: default_async - tags: - - server-version - - python-3.15t - - standalone-noauth-ssl - - async - - free-threaded - - name: test-server-version-python3.14-sync-noauth-ssl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: standalone - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: standalone - UV_PYTHON: "3.14" - TEST_NAME: default_sync - tags: - - server-version - - python-3.14 - - standalone-noauth-ssl - - sync - - name: test-server-version-v4.4-python3.11-sync-noauth-nossl-standalone-min-deps-cov - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - TEST_MIN_DEPS: "1" - VERSION: "4.4" - COVERAGE: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - TEST_MIN_DEPS: "1" - VERSION: "4.4" - COVERAGE: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_sync - tags: - - server-version - - python-3.11 - - standalone-noauth-nossl - - sync - - pr - - "4.4" - - name: test-server-version-v4.4-python3.11-async-noauth-nossl-standalone-min-deps-cov - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - TEST_MIN_DEPS: "1" - VERSION: "4.4" - COVERAGE: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - TEST_MIN_DEPS: "1" - VERSION: "4.4" - COVERAGE: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_async - tags: - - server-version - - python-3.11 - - standalone-noauth-nossl - - async - - pr - - "4.4" - - name: test-server-version-v9.0-python3.15-sync-noauth-nossl-replica-set-cov - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: replica_set - VERSION: "9.0" - COVERAGE: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: replica_set - VERSION: "9.0" - COVERAGE: "1" - UV_PYTHON: "3.15" - TEST_NAME: default_sync - tags: - - server-version - - python-3.15 - - replica_set-noauth-nossl - - sync - - pr - - "9.0" - - name: test-server-version-v9.0-python3.15-async-noauth-nossl-replica-set-cov - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: replica_set - VERSION: "9.0" - COVERAGE: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: replica_set - VERSION: "9.0" - COVERAGE: "1" - UV_PYTHON: "3.15" - TEST_NAME: default_async - tags: - - server-version - - python-3.15 - - replica_set-noauth-nossl - - async - - pr - - "9.0" - - name: test-server-version-v9.0-python3.15-sync-auth-ssl-sharded-cluster-cov - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - COVERAGE: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - COVERAGE: "1" - UV_PYTHON: "3.15" - TEST_NAME: default_sync - tags: - - server-version - - python-3.15 - - sharded_cluster-auth-ssl - - sync - - pr - - "9.0" - - name: test-server-version-v9.0-python3.15-async-auth-ssl-sharded-cluster-cov - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - COVERAGE: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - COVERAGE: "1" - UV_PYTHON: "3.15" - TEST_NAME: default_async - tags: - - server-version - - python-3.15 - - sharded_cluster-auth-ssl - - async - - pr - - "9.0" - - name: test-server-version-v9.0-python3.11-sync-noauth-nossl-standalone-min-deps-cov - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - TEST_MIN_DEPS: "1" - VERSION: "9.0" - COVERAGE: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - TEST_MIN_DEPS: "1" - VERSION: "9.0" - COVERAGE: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_sync - tags: - - server-version - - python-3.11 - - standalone-noauth-nossl - - sync - - pr - - "9.0" - - name: test-server-version-v9.0-python3.11-async-noauth-nossl-standalone-min-deps-cov - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - TEST_MIN_DEPS: "1" - VERSION: "9.0" - COVERAGE: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - TEST_MIN_DEPS: "1" - VERSION: "9.0" - COVERAGE: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_async - tags: - - server-version - - python-3.11 - - standalone-noauth-nossl - - async - - pr - - "9.0" - - # Standard tests - - name: test-standard-v4.4-python3.12-sync-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "4.4" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "4.4" - UV_PYTHON: "3.12" - TEST_NAME: default_sync - tags: - - test-standard - - server-4.4 - - python-3.12 - - replica_set-noauth-ssl - - sync - - name: test-standard-v4.4-python3.15t-sync-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "4.4" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "4.4" - UV_PYTHON: 3.15t - TEST_NAME: default_sync - tags: - - test-standard - - server-4.4 - - python-3.15t - - replica_set-noauth-ssl - - sync - - free-threaded - - name: test-standard-v4.4-python3.13-sync-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "4.4" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "4.4" - UV_PYTHON: "3.13" - TEST_NAME: default_sync - tags: - - test-standard - - server-4.4 - - python-3.13 - - sharded_cluster-auth-ssl - - sync - - name: test-standard-v4.4-python3.15-sync-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "4.4" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "4.4" - UV_PYTHON: "3.15" - TEST_NAME: default_sync - tags: - - test-standard - - server-4.4 - - python-3.15 - - sharded_cluster-auth-ssl - - sync - - name: test-standard-v4.4-python3.11-sync-noauth-nossl-standalone-min-deps - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "4.4" - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "4.4" - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_sync - tags: - - test-standard - - server-4.4 - - python-3.11 - - standalone-noauth-nossl - - sync - - name: test-standard-v4.4-python3.14-sync-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "4.4" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "4.4" - UV_PYTHON: "3.14" - TEST_NAME: default_sync - tags: - - test-standard - - server-4.4 - - python-3.14 - - standalone-noauth-nossl - - sync - - name: test-standard-v5.0-python3.12-async-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "5.0" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "5.0" - UV_PYTHON: "3.12" - TEST_NAME: default_async - tags: - - test-standard - - server-5.0 - - python-3.12 - - replica_set-noauth-ssl - - async - - name: test-standard-v5.0-python3.15t-async-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "5.0" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "5.0" - UV_PYTHON: 3.15t - TEST_NAME: default_async - tags: - - test-standard - - server-5.0 - - python-3.15t - - replica_set-noauth-ssl - - async - - free-threaded - - name: test-standard-v5.0-python3.13-async-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "5.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "5.0" - UV_PYTHON: "3.13" - TEST_NAME: default_async - tags: - - test-standard - - server-5.0 - - python-3.13 - - sharded_cluster-auth-ssl - - async - - name: test-standard-v5.0-python3.15-async-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "5.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "5.0" - UV_PYTHON: "3.15" - TEST_NAME: default_async - tags: - - test-standard - - server-5.0 - - python-3.15 - - sharded_cluster-auth-ssl - - async - - name: test-standard-v5.0-python3.11-async-noauth-nossl-standalone-min-deps - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "5.0" - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "5.0" - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_async - tags: - - test-standard - - server-5.0 - - python-3.11 - - standalone-noauth-nossl - - async - - name: test-standard-v5.0-python3.14-async-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "5.0" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "5.0" - UV_PYTHON: "3.14" - TEST_NAME: default_async - tags: - - test-standard - - server-5.0 - - python-3.14 - - standalone-noauth-nossl - - async - - name: test-standard-v6.0-python3.11-sync-noauth-ssl-replica-set-min-deps - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "6.0" - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "6.0" - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_sync - tags: - - test-standard - - server-6.0 - - python-3.11 - - replica_set-noauth-ssl - - sync - - name: test-standard-v6.0-python3.14-sync-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "6.0" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "6.0" - UV_PYTHON: "3.14" - TEST_NAME: default_sync - tags: - - test-standard - - server-6.0 - - python-3.14 - - replica_set-noauth-ssl - - sync - - name: test-standard-v6.0-python3.12-sync-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "6.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "6.0" - UV_PYTHON: "3.12" - TEST_NAME: default_sync - tags: - - test-standard - - server-6.0 - - python-3.12 - - sharded_cluster-auth-ssl - - sync - - name: test-standard-v6.0-python3.15t-sync-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "6.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "6.0" - UV_PYTHON: 3.15t - TEST_NAME: default_sync - tags: - - test-standard - - server-6.0 - - python-3.15t - - sharded_cluster-auth-ssl - - sync - - free-threaded - - name: test-standard-v6.0-python3.14t-sync-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "6.0" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "6.0" - UV_PYTHON: 3.14t - TEST_NAME: default_sync - tags: - - test-standard - - server-6.0 - - python-3.14t - - standalone-noauth-nossl - - sync - - free-threaded - - name: test-standard-v7.0-python3.11-async-noauth-ssl-replica-set-min-deps - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "7.0" - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "7.0" - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_async - tags: - - test-standard - - server-7.0 - - python-3.11 - - replica_set-noauth-ssl - - async - - name: test-standard-v7.0-python3.14-async-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "7.0" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "7.0" - UV_PYTHON: "3.14" - TEST_NAME: default_async - tags: - - test-standard - - server-7.0 - - python-3.14 - - replica_set-noauth-ssl - - async - - name: test-standard-v7.0-python3.12-async-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "7.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "7.0" - UV_PYTHON: "3.12" - TEST_NAME: default_async - tags: - - test-standard - - server-7.0 - - python-3.12 - - sharded_cluster-auth-ssl - - async - - name: test-standard-v7.0-python3.15t-async-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "7.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "7.0" - UV_PYTHON: 3.15t - TEST_NAME: default_async - tags: - - test-standard - - server-7.0 - - python-3.15t - - sharded_cluster-auth-ssl - - async - - free-threaded - - name: test-standard-v7.0-python3.14t-async-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "7.0" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "7.0" - UV_PYTHON: 3.14t - TEST_NAME: default_async - tags: - - test-standard - - server-7.0 - - python-3.14t - - standalone-noauth-nossl - - async - - free-threaded - - name: test-standard-v8.0-python3.14t-sync-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "8.0" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "8.0" - UV_PYTHON: 3.14t - TEST_NAME: default_sync - tags: - - test-standard - - server-8.0 - - python-3.14t - - replica_set-noauth-ssl - - sync - - free-threaded - - name: test-standard-v8.0-python3.11-sync-auth-ssl-sharded-cluster-min-deps - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "8.0" - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "8.0" - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_sync - tags: - - test-standard - - server-8.0 - - python-3.11 - - sharded_cluster-auth-ssl - - sync - - name: test-standard-v8.0-python3.14-sync-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "8.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "8.0" - UV_PYTHON: "3.14" - TEST_NAME: default_sync - tags: - - test-standard - - server-8.0 - - python-3.14 - - sharded_cluster-auth-ssl - - sync - - name: test-standard-v8.0-python3.13-sync-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "8.0" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "8.0" - UV_PYTHON: "3.13" - TEST_NAME: default_sync - tags: - - test-standard - - server-8.0 - - python-3.13 - - standalone-noauth-nossl - - sync - - name: test-standard-v8.0-python3.15-sync-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "8.0" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "8.0" - UV_PYTHON: "3.15" - TEST_NAME: default_sync - tags: - - test-standard - - server-8.0 - - python-3.15 - - standalone-noauth-nossl - - sync - - name: test-standard-v9.0-python3.14t-async-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "9.0" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "9.0" - UV_PYTHON: 3.14t - TEST_NAME: default_async - tags: - - test-standard - - server-9.0 - - python-3.14t - - replica_set-noauth-ssl - - async - - free-threaded - - name: test-standard-v9.0-python3.15-async-noauth-ssl-replica-set-cov - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "9.0" - COVERAGE: "1" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "9.0" - COVERAGE: "1" - UV_PYTHON: "3.15" - TEST_NAME: default_async - tags: - - test-standard - - server-9.0 - - python-3.15 - - replica_set-noauth-ssl - - async - - pr - - name: test-standard-v9.0-python3.11-async-auth-ssl-sharded-cluster-min-deps - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_async - tags: - - test-standard - - server-9.0 - - python-3.11 - - sharded_cluster-auth-ssl - - async - - name: test-standard-v9.0-python3.14-async-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - UV_PYTHON: "3.14" - TEST_NAME: default_async - tags: - - test-standard - - server-9.0 - - python-3.14 - - sharded_cluster-auth-ssl - - async - - name: test-standard-v9.0-python3.15t-sync-auth-ssl-sharded-cluster-cov - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - COVERAGE: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - COVERAGE: "1" - UV_PYTHON: 3.15t - TEST_NAME: default_sync - tags: - - test-standard - - server-9.0 - - python-3.15t - - sharded_cluster-auth-ssl - - sync - - free-threaded - - pr - - name: test-standard-v9.0-python3.11-async-noauth-nossl-standalone-min-deps-cov - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "9.0" - TEST_MIN_DEPS: "1" - COVERAGE: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "9.0" - TEST_MIN_DEPS: "1" - COVERAGE: "1" - UV_PYTHON: "3.11" - TEST_NAME: default_async - tags: - - test-standard - - server-9.0 - - python-3.11 - - standalone-noauth-nossl - - async - - pr - - name: test-standard-v9.0-python3.13-async-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "9.0" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "9.0" - UV_PYTHON: "3.13" - TEST_NAME: default_async - tags: - - test-standard - - server-9.0 - - python-3.13 - - standalone-noauth-nossl - - async - - name: test-standard-v9.0-python3.15-async-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "9.0" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "9.0" - UV_PYTHON: "3.15" - TEST_NAME: default_async - tags: - - test-standard - - server-9.0 - - python-3.15 - - standalone-noauth-nossl - - async - - name: test-standard-latest-python3.13-async-noauth-ssl-replica-set-cov - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: latest - COVERAGE: "1" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: latest - COVERAGE: "1" - UV_PYTHON: "3.13" - TEST_NAME: default_async - tags: - - test-standard - - server-latest - - python-3.13 - - replica_set-noauth-ssl - - async - - name: test-standard-latest-python3.15-async-noauth-ssl-replica-set-cov - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: latest - COVERAGE: "1" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: latest - COVERAGE: "1" - UV_PYTHON: "3.15" - TEST_NAME: default_async - tags: - - test-standard - - server-latest - - python-3.15 - - replica_set-noauth-ssl - - async - - name: test-standard-latest-python3.14t-async-auth-ssl-sharded-cluster-cov - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: latest - COVERAGE: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: latest - COVERAGE: "1" - UV_PYTHON: 3.14t - TEST_NAME: default_async - tags: - - test-standard - - server-latest - - python-3.14t - - sharded_cluster-auth-ssl - - async - - free-threaded - - name: test-standard-latest-python3.12-async-noauth-nossl-standalone-cov - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: latest - COVERAGE: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: latest - COVERAGE: "1" - UV_PYTHON: "3.12" - TEST_NAME: default_async - tags: - - test-standard - - server-latest - - python-3.12 - - standalone-noauth-nossl - - async - - name: test-standard-latest-python3.15t-async-noauth-nossl-standalone-cov - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: latest - COVERAGE: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: latest - COVERAGE: "1" - UV_PYTHON: 3.15t - TEST_NAME: default_async - tags: - - test-standard - - server-latest - - python-3.15t - - standalone-noauth-nossl - - async - - free-threaded - - name: test-standard-rapid-python3.13-sync-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: rapid - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: rapid - UV_PYTHON: "3.13" - TEST_NAME: default_sync - tags: - - test-standard - - server-rapid - - python-3.13 - - replica_set-noauth-ssl - - sync - - name: test-standard-rapid-python3.15-sync-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: rapid - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: rapid - UV_PYTHON: "3.15" - TEST_NAME: default_sync - tags: - - test-standard - - server-rapid - - python-3.15 - - replica_set-noauth-ssl - - sync - - name: test-standard-rapid-python3.14t-sync-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: rapid - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: rapid - UV_PYTHON: 3.14t - TEST_NAME: default_sync - tags: - - test-standard - - server-rapid - - python-3.14t - - sharded_cluster-auth-ssl - - sync - - free-threaded - - name: test-standard-rapid-python3.12-sync-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: rapid - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: rapid - UV_PYTHON: "3.12" - TEST_NAME: default_sync - tags: - - test-standard - - server-rapid - - python-3.12 - - standalone-noauth-nossl - - sync - - name: test-standard-rapid-python3.15t-sync-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: rapid - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: rapid - UV_PYTHON: 3.15t - TEST_NAME: default_sync - tags: - - test-standard - - server-rapid - - python-3.15t - - standalone-noauth-nossl - - sync - - free-threaded - - # Test non standard tests - - name: test-non-standard-v4.4-python3.12-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "4.4" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "4.4" - UV_PYTHON: "3.12" - tags: - - test-non-standard - - server-4.4 - - python-3.12 - - replica_set-noauth-ssl - - noauth - - name: test-non-standard-v4.4-python3.13-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "4.4" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "4.4" - UV_PYTHON: "3.13" - tags: - - test-non-standard - - server-4.4 - - python-3.13 - - sharded_cluster-auth-ssl - - auth - - name: test-non-standard-v4.4-python3.11-noauth-nossl-standalone-min-deps - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "4.4" - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "4.4" - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - tags: - - test-non-standard - - server-4.4 - - python-3.11 - - standalone-noauth-nossl - - noauth - - name: test-non-standard-v5.0-python3.14-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "5.0" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "5.0" - UV_PYTHON: "3.14" - tags: - - test-non-standard - - server-5.0 - - python-3.14 - - replica_set-noauth-ssl - - noauth - - name: test-non-standard-v5.0-python3.15t-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "5.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "5.0" - UV_PYTHON: 3.15t - tags: - - test-non-standard - - server-5.0 - - python-3.15t - - sharded_cluster-auth-ssl - - auth - - free-threaded - - name: test-non-standard-v5.0-python3.14t-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "5.0" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "5.0" - UV_PYTHON: 3.14t - tags: - - test-non-standard - - server-5.0 - - python-3.14t - - standalone-noauth-nossl - - noauth - - free-threaded - - name: test-non-standard-v6.0-python3.11-noauth-ssl-replica-set-min-deps - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "6.0" - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "6.0" - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - tags: - - test-non-standard - - server-6.0 - - python-3.11 - - replica_set-noauth-ssl - - noauth - - name: test-non-standard-v6.0-python3.12-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "6.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "6.0" - UV_PYTHON: "3.12" - tags: - - test-non-standard - - server-6.0 - - python-3.12 - - sharded_cluster-auth-ssl - - auth - - name: test-non-standard-v6.0-python3.15-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "6.0" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "6.0" - UV_PYTHON: "3.15" - tags: - - test-non-standard - - server-6.0 - - python-3.15 - - standalone-noauth-nossl - - noauth - - name: test-non-standard-v7.0-python3.14t-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "7.0" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "7.0" - UV_PYTHON: 3.14t - tags: - - test-non-standard - - server-7.0 - - python-3.14t - - replica_set-noauth-ssl - - noauth - - free-threaded - - name: test-non-standard-v7.0-python3.14-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "7.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "7.0" - UV_PYTHON: "3.14" - tags: - - test-non-standard - - server-7.0 - - python-3.14 - - sharded_cluster-auth-ssl - - auth - - name: test-non-standard-v7.0-python3.13-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "7.0" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "7.0" - UV_PYTHON: "3.13" - tags: - - test-non-standard - - server-7.0 - - python-3.13 - - standalone-noauth-nossl - - noauth - - name: test-non-standard-v8.0-python3.15-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "8.0" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "8.0" - UV_PYTHON: "3.15" - tags: - - test-non-standard - - server-8.0 - - python-3.15 - - replica_set-noauth-ssl - - noauth - - name: test-non-standard-v8.0-python3.11-auth-ssl-sharded-cluster-min-deps - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "8.0" - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "8.0" - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - tags: - - test-non-standard - - server-8.0 - - python-3.11 - - sharded_cluster-auth-ssl - - auth - - name: test-non-standard-v8.0-python3.15t-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "8.0" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "8.0" - UV_PYTHON: 3.15t - tags: - - test-non-standard - - server-8.0 - - python-3.15t - - standalone-noauth-nossl - - noauth - - free-threaded - - name: test-non-standard-v9.0-python3.13-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "9.0" - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: "9.0" - UV_PYTHON: "3.13" - tags: - - test-non-standard - - server-9.0 - - python-3.13 - - replica_set-noauth-ssl - - noauth - - name: test-non-standard-v9.0-python3.14t-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - UV_PYTHON: 3.14t - tags: - - test-non-standard - - server-9.0 - - python-3.14t - - sharded_cluster-auth-ssl - - auth - - free-threaded - - name: test-non-standard-v9.0-python3.15-auth-ssl-sharded-cluster-cov - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - COVERAGE: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - COVERAGE: "1" - UV_PYTHON: "3.15" - tags: - - test-non-standard - - server-9.0 - - python-3.15 - - sharded_cluster-auth-ssl - - auth - - pr - - cov - - name: test-non-standard-v9.0-python3.15-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - UV_PYTHON: "3.15" - tags: - - test-non-standard-no-cov - - server-9.0 - - python-3.15 - - sharded_cluster-auth-ssl - - auth - - name: test-non-standard-v9.0-python3.12-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "9.0" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: "9.0" - UV_PYTHON: "3.12" - tags: - - test-non-standard - - server-9.0 - - python-3.12 - - standalone-noauth-nossl - - noauth - - name: test-non-standard-latest-python3.12-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: latest - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: latest - UV_PYTHON: "3.12" - tags: - - test-non-standard - - server-latest - - python-3.12 - - replica_set-noauth-ssl - - noauth - - name: test-non-standard-latest-python3.13-auth-ssl-sharded-cluster-cov - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: latest - COVERAGE: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: latest - COVERAGE: "1" - UV_PYTHON: "3.13" - tags: - - test-non-standard - - server-latest - - python-3.13 - - sharded_cluster-auth-ssl - - auth - - cov - - name: test-non-standard-latest-python3.13-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: latest - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: latest - UV_PYTHON: "3.13" - tags: - - test-non-standard-no-cov - - server-latest - - python-3.13 - - sharded_cluster-auth-ssl - - auth - - name: test-non-standard-latest-python3.11-noauth-nossl-standalone-min-deps - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: latest - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: latest - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - tags: - - test-non-standard - - server-latest - - python-3.11 - - standalone-noauth-nossl - - noauth - - name: test-non-standard-rapid-python3.15t-noauth-ssl-replica-set - commands: - - func: run server - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: rapid - - func: run tests - vars: - AUTH: noauth - SSL: ssl - TOPOLOGY: replica_set - VERSION: rapid - UV_PYTHON: 3.15t - tags: - - test-non-standard - - server-rapid - - python-3.15t - - replica_set-noauth-ssl - - noauth - - free-threaded - - name: test-non-standard-rapid-python3.15-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: rapid - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: rapid - UV_PYTHON: "3.15" - tags: - - test-non-standard - - server-rapid - - python-3.15 - - sharded_cluster-auth-ssl - - auth - - name: test-non-standard-rapid-python3.14-noauth-nossl-standalone - commands: - - func: run server - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: rapid - - func: run tests - vars: - AUTH: noauth - SSL: nossl - TOPOLOGY: standalone - VERSION: rapid - UV_PYTHON: "3.14" - tags: - - test-non-standard - - server-rapid - - python-3.14 - - standalone-noauth-nossl - - noauth - - # Test numpy tests - - name: test-numpy-python3.11-python3.11 - commands: - - func: test numpy - vars: - UV_PYTHON: "3.11" - tags: - - binary - - vector - - python-3.11 - - test-numpy - - name: test-numpy-python3.15-python3.15-cov - commands: - - func: test numpy - vars: - UV_PYTHON: "3.15" - COVERAGE: "1" - tags: - - binary - - vector - - python-3.15 - - test-numpy - - pr - - # Test standard auth tests - - name: test-standard-auth-v4.4-python3.11-auth-ssl-sharded-cluster-min-deps - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "4.4" - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "4.4" - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - tags: - - test-standard-auth - - server-4.4 - - python-3.11 - - sharded_cluster-auth-ssl - - auth - - name: test-standard-auth-v5.0-python3.12-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "5.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "5.0" - UV_PYTHON: "3.12" - tags: - - test-standard-auth - - server-5.0 - - python-3.12 - - sharded_cluster-auth-ssl - - auth - - name: test-standard-auth-v6.0-python3.13-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "6.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "6.0" - UV_PYTHON: "3.13" - tags: - - test-standard-auth - - server-6.0 - - python-3.13 - - sharded_cluster-auth-ssl - - auth - - name: test-standard-auth-v7.0-python3.14t-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "7.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "7.0" - UV_PYTHON: 3.14t - tags: - - test-standard-auth - - server-7.0 - - python-3.14t - - sharded_cluster-auth-ssl - - auth - - free-threaded - - name: test-standard-auth-v8.0-python3.14-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "8.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "8.0" - UV_PYTHON: "3.14" - tags: - - test-standard-auth - - server-8.0 - - python-3.14 - - sharded_cluster-auth-ssl - - auth - - name: test-standard-auth-v9.0-python3.11-auth-ssl-sharded-cluster-min-deps-cov - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - TEST_MIN_DEPS: "1" - COVERAGE: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - TEST_MIN_DEPS: "1" - COVERAGE: "1" - UV_PYTHON: "3.11" - tags: - - test-standard-auth - - server-9.0 - - python-3.11 - - sharded_cluster-auth-ssl - - auth - - pr - - name: test-standard-auth-v9.0-python3.15-auth-ssl-sharded-cluster-cov - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - COVERAGE: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - COVERAGE: "1" - UV_PYTHON: "3.15" - tags: - - test-standard-auth - - server-9.0 - - python-3.15 - - sharded_cluster-auth-ssl - - auth - - pr - - name: test-standard-auth-v9.0-python3.15t-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: "9.0" - UV_PYTHON: 3.15t - tags: - - test-standard-auth - - server-9.0 - - python-3.15t - - sharded_cluster-auth-ssl - - auth - - free-threaded - - name: test-standard-auth-latest-python3.11-auth-ssl-sharded-cluster-min-deps - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: latest - TEST_MIN_DEPS: "1" - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: latest - TEST_MIN_DEPS: "1" - UV_PYTHON: "3.11" - tags: - - test-standard-auth - - server-latest - - python-3.11 - - sharded_cluster-auth-ssl - - auth - - name: test-standard-auth-rapid-python3.15-auth-ssl-sharded-cluster - commands: - - func: run server - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: rapid - - func: run tests - vars: - AUTH: auth - SSL: ssl - TOPOLOGY: sharded_cluster - VERSION: rapid - UV_PYTHON: "3.15" - tags: - - test-standard-auth - - server-rapid - - python-3.15 - - sharded_cluster-auth-ssl - - auth diff --git a/.evergreen/generated_configs/variants.yml b/.evergreen/generated_configs/variants.yml deleted file mode 100644 index e6892c7d77..0000000000 --- a/.evergreen/generated_configs/variants.yml +++ /dev/null @@ -1,754 +0,0 @@ -buildvariants: - # Alternative hosts tests - - name: other-hosts-rhel9-fips-latest - tasks: - - name: .test-no-toolchain - display_name: Other hosts RHEL9-FIPS latest - run_on: - - rhel92-fips - batchtime: 1440 - expansions: - VERSION: latest - NO_EXT: "1" - REQUIRE_FIPS: "1" - UV_PYTHON: /usr/bin/python3.11 - tags: [] - - name: other-hosts-rhel8-zseries-latest - tasks: - - name: .test-no-toolchain - display_name: Other hosts RHEL8-zseries latest - run_on: - - rhel8-zseries-small - batchtime: 1440 - expansions: - VERSION: latest - NO_EXT: "1" - tags: [] - - name: other-hosts-rhel8-power8-latest - tasks: - - name: .test-no-toolchain - display_name: Other hosts RHEL8-POWER8 latest - run_on: - - rhel8-power-small - batchtime: 1440 - expansions: - VERSION: latest - NO_EXT: "1" - tags: [] - - name: other-hosts-rhel8-arm64-latest - tasks: - - name: .test-no-toolchain - display_name: Other hosts RHEL8-arm64 latest - run_on: - - rhel82-arm64-small - batchtime: 1440 - expansions: - VERSION: latest - NO_EXT: "1" - tags: [] - - name: other-hosts-amazon2023-latest - tasks: - - name: .test-no-toolchain - display_name: Other hosts Amazon2023 latest - run_on: - - amazon2023-arm64-latest-large-m8g - batchtime: 1440 - expansions: - VERSION: latest - NO_EXT: "1" - tags: [pr] - - # Atlas connect tests - - name: atlas-connect-rhel8 - tasks: - - name: .test-no-orchestration - display_name: Atlas connect RHEL8 - run_on: - - rhel8.10-small - expansions: - TEST_NAME: atlas_connect - tags: [pr] - - # Aws auth tests - - name: auth-aws-rhel8 - tasks: - - name: .auth-aws - display_name: Auth AWS RHEL8 - run_on: - - rhel8.10-small - tags: [] - - name: auth-aws-win64 - tasks: - - name: .auth-aws - display_name: Auth AWS Win64 - run_on: - - windows-2022-latest-small - tags: [] - - name: auth-aws-macos - tasks: - - name: .auth-aws !.auth-aws-web-identity !.auth-aws-ec2 - display_name: Auth AWS macOS - run_on: - - macos-14 - tags: [pr] - - name: auth-aws-ecs-ubuntu-24 - tasks: - - name: .auth-aws-ecs - display_name: Auth AWS ECS Ubuntu-24 - run_on: - - ubuntu2404-small - tags: [] - - # Aws lambda tests - - name: faas-lambda - tasks: - - name: .aws_lambda - display_name: FaaS Lambda - run_on: - - rhel8.10-small - - # Backport pr tests - - name: backport-pr - tasks: - - name: backport-pr - display_name: Backport PR - run_on: - - rhel8.10-small - - # Compression tests - - name: compression-snappy-rhel8 - tasks: - - name: .test-standard - display_name: Compression snappy RHEL8 - run_on: - - rhel8.10-small - expansions: - COMPRESSOR: snappy - - name: compression-zlib-rhel8 - tasks: - - name: .test-standard - display_name: Compression zlib RHEL8 - run_on: - - rhel8.10-small - expansions: - COMPRESSOR: zlib - - name: compression-zstd-rhel8 - tasks: - - name: .test-standard - display_name: Compression zstd RHEL8 - run_on: - - rhel8.10-small - expansions: - COMPRESSOR: zstd - - name: compression-zstd-ubuntu-22 - tasks: - - name: .test-standard !.server-4.4 !.server-5.0 .python-3.14 - - name: .test-standard !.server-4.4 !.server-5.0 .python-3.14t - - name: .test-standard !.server-4.4 !.server-5.0 .python-3.15 - - name: .test-standard !.server-4.4 !.server-5.0 .python-3.15t - display_name: Compression zstd Ubuntu-22 - run_on: - - ubuntu2204-small - expansions: - COMPRESSOR: ztsd - - # Coverage report tests - - name: coverage-report - tasks: - - name: coverage-report - display_name: Coverage Report - run_on: - - rhel8.10-small - - # Disable test commands tests - - name: disable-test-commands-rhel8 - tasks: - - name: .test-standard .server-latest - display_name: Disable test commands RHEL8 - run_on: - - rhel8.10-small - expansions: - AUTH: auth - SSL: ssl - DISABLE_TEST_COMMANDS: "1" - - # Doctests tests - - name: doctests-rhel8 - tasks: - - name: .test-non-standard .standalone-noauth-nossl - display_name: Doctests RHEL8 - run_on: - - rhel8.10-small - expansions: - TEST_NAME: doctest - - # Encryption tests - - name: encryption-rhel8 - tasks: - - name: .test-non-standard !.python-3.15t - display_name: Encryption RHEL8 - run_on: - - rhel8.10-small - batchtime: 1440 - expansions: - TEST_NAME: encryption - tags: [encryption_tag] - - name: encryption-macos - tasks: - - name: .test-non-standard !.cov !.python-3.15t - - name: .test-non-standard-no-cov !.python-3.15t - display_name: Encryption macOS - run_on: - - macos-14 - batchtime: 1440 - expansions: - TEST_NAME: encryption - tags: [encryption_tag] - - name: encryption-win64 - tasks: - - name: .test-non-standard !.cov !.python-3.15t - - name: .test-non-standard-no-cov !.python-3.15t - display_name: Encryption Win64 - run_on: - - windows-2022-latest-small - batchtime: 1440 - expansions: - TEST_NAME: encryption - tags: [encryption_tag] - - name: encryption-crypt_shared-rhel8 - tasks: - - name: .test-non-standard !.python-3.15t - display_name: Encryption crypt_shared RHEL8 - run_on: - - rhel8.10-small - batchtime: 1440 - expansions: - TEST_NAME: encryption - TEST_CRYPT_SHARED: "true" - tags: [encryption_tag] - - name: encryption-crypt_shared-macos - tasks: - - name: .test-non-standard !.cov !.python-3.15t - - name: .test-non-standard-no-cov !.python-3.15t - display_name: Encryption crypt_shared macOS - run_on: - - macos-14 - batchtime: 1440 - expansions: - TEST_NAME: encryption - TEST_CRYPT_SHARED: "true" - tags: [encryption_tag] - - name: encryption-crypt_shared-win64 - tasks: - - name: .test-non-standard !.cov !.python-3.15t - - name: .test-non-standard-no-cov !.python-3.15t - display_name: Encryption crypt_shared Win64 - run_on: - - windows-2022-latest-small - batchtime: 1440 - expansions: - TEST_NAME: encryption - TEST_CRYPT_SHARED: "true" - tags: [encryption_tag] - - name: encryption-pyopenssl-rhel8 - tasks: - - name: .test-non-standard !.python-3.15t - display_name: Encryption PyOpenSSL RHEL8 - run_on: - - rhel8.10-small - batchtime: 1440 - expansions: - TEST_NAME: encryption - SUB_TEST_NAME: pyopenssl - tags: [encryption_tag] - - name: encryption-ubuntu-22 - tasks: - - name: .test-non-standard .python-3.15t !.server-4.4 !.server-5.0 - display_name: Encryption Ubuntu-22 - run_on: - - ubuntu2204-small - batchtime: 1440 - expansions: - TEST_NAME: encryption - tags: [encryption_tag, pr] - - name: encryption-pyopenssl-ubuntu-22 - tasks: - - name: .test-non-standard .python-3.15t !.server-4.4 !.server-5.0 - display_name: Encryption PyOpenSSL Ubuntu-22 - run_on: - - ubuntu2204-small - batchtime: 1440 - expansions: - TEST_NAME: encryption - SUB_TEST_NAME: pyopenssl - tags: [encryption_tag, pr] - - # Enterprise auth tests - - name: auth-enterprise-rhel8 - tasks: - - name: .test-standard-auth .auth !.free-threaded - display_name: Auth Enterprise RHEL8 - run_on: - - rhel8.10-small - expansions: - TEST_NAME: enterprise_auth - AUTH: auth - - name: auth-enterprise-macos - tasks: - - name: .test-standard-auth .auth !.free-threaded - display_name: Auth Enterprise macOS - run_on: - - macos-14 - expansions: - TEST_NAME: enterprise_auth - AUTH: auth - - name: auth-enterprise-win64 - tasks: - - name: .test-standard-auth .auth !.free-threaded - display_name: Auth Enterprise Win64 - run_on: - - windows-2022-latest-small - expansions: - TEST_NAME: enterprise_auth - AUTH: auth - - # Fuzz tests - - name: fuzz-rhel8 - tasks: - - name: .fuzz-regression - - name: .fuzz-nightly - display_name: Fuzz RHEL8 - run_on: - - rhel8.10-small - batchtime: 1440 - tags: [pr] - - # Green framework tests - - name: green-gevent-rhel8 - tasks: - - name: .test-standard .sync !.free-threaded - display_name: Green Gevent RHEL8 - run_on: - - rhel8.10-small - expansions: - GREEN_FRAMEWORK: gevent - - # Import time tests - - name: import-time - tasks: - - name: check-import-time - display_name: Import Time - run_on: - - rhel8.10-small - - # Kms tests - - name: kms - tasks: - - name: test-gcpkms - batchtime: 1440 - - name: test-gcpkms-fail - - name: test-azurekms - batchtime: 1440 - - name: test-azurekms-fail - display_name: KMS - run_on: - - debian11-small - - # Load balancer tests - - name: load-balancer - tasks: - - name: .test-non-standard .server-6.0 .sharded_cluster-auth-ssl - - name: .test-non-standard .server-7.0 .sharded_cluster-auth-ssl - - name: .test-non-standard .server-8.0 .sharded_cluster-auth-ssl - - name: .test-non-standard .server-9.0 .sharded_cluster-auth-ssl - - name: .test-non-standard .server-rapid .sharded_cluster-auth-ssl - - name: .test-non-standard .server-latest .sharded_cluster-auth-ssl - display_name: Load Balancer - run_on: - - rhel8.10-small - batchtime: 1440 - expansions: - TEST_NAME: load_balancer - - # Min support tests - - name: min-support-rhel8 - tasks: - - name: .test-min-support - display_name: Min Support RHEL8 - run_on: - - rhel8.10-small - - # Mockupdb tests - - name: mockupdb-rhel8 - tasks: - - name: .test-no-orchestration - display_name: MockupDB RHEL8 - run_on: - - rhel8.10-small - expansions: - TEST_NAME: mockupdb - tags: [pr] - - # No c ext tests - - name: no-c-ext-rhel8 - tasks: - - name: .test-standard - display_name: No C Ext RHEL8 - run_on: - - rhel8.10-small - expansions: - NO_EXT: "1" - - # No server tests - - name: no-server-rhel8 - tasks: - - name: .test-no-orchestration - display_name: No server RHEL8 - run_on: - - rhel8.10-small - tags: [pr] - - # Ocsp tests - - name: ocsp-rhel8 - tasks: - - name: .ocsp - display_name: OCSP RHEL8 - run_on: - - rhel8.10-small - batchtime: 10080 - - name: ocsp-staples-rhel8 - tasks: - - name: .ocsp-staple .pr - display_name: OCSP Staples RHEL8 - run_on: - - rhel8.10-small - tags: [pr] - - name: ocsp-win64 - tasks: - - name: .ocsp-rsa !.ocsp-staple .latest - - name: .ocsp-rsa !.ocsp-staple .4.4 - display_name: OCSP Win64 - run_on: - - windows-2022-latest-small - batchtime: 10080 - - name: ocsp-macos - tasks: - - name: .ocsp-rsa !.ocsp-staple .latest - - name: .ocsp-rsa !.ocsp-staple .4.4 - display_name: OCSP macOS - run_on: - - macos-14 - batchtime: 10080 - - # Oidc auth tests - - name: auth-oidc-ubuntu-22 - tasks: - - name: .auth_oidc_remote - display_name: Auth OIDC Ubuntu-22 - run_on: - - ubuntu2204-small - batchtime: 1440 - - name: auth-oidc-local-ubuntu-22 - tasks: - - name: "!.auth_oidc_remote .auth_oidc" - display_name: Auth OIDC Local Ubuntu-22 - run_on: - - ubuntu2204-small - batchtime: 1440 - expansions: - COVERAGE: "1" - tags: [pr] - - name: auth-oidc-macos - tasks: - - name: "!.auth_oidc_remote .auth_oidc" - display_name: Auth OIDC macOS - run_on: - - macos-14 - batchtime: 1440 - - name: auth-oidc-win64 - tasks: - - name: "!.auth_oidc_remote .auth_oidc" - display_name: Auth OIDC Win64 - run_on: - - windows-2022-latest-small - batchtime: 1440 - - # Perf tests - - name: performance-benchmarks - tasks: - - name: .perf - display_name: Performance Benchmarks - run_on: - - rhel90-dbx-perf-large - batchtime: 1440 - - # Pyopenssl tests - - name: pyopenssl-rhel8 - tasks: - - name: .test-standard !.python-3.15t .sync - - name: .test-standard !.python-3.15t .async .replica_set-noauth-ssl - display_name: PyOpenSSL RHEL8 - run_on: - - rhel8.10-small - batchtime: 1440 - expansions: - SUB_TEST_NAME: pyopenssl - - name: pyopenssl-macos - tasks: - - name: .test-standard !.python-3.15t .sync - - name: .test-standard !.python-3.15t .async .replica_set-noauth-ssl - display_name: PyOpenSSL macOS - run_on: - - macos-14 - batchtime: 1440 - expansions: - SUB_TEST_NAME: pyopenssl - - name: pyopenssl-win64 - tasks: - - name: .test-standard !.python-3.15t .sync - - name: .test-standard !.python-3.15t .async .replica_set-noauth-ssl - display_name: PyOpenSSL Win64 - run_on: - - windows-2022-latest-small - batchtime: 1440 - expansions: - SUB_TEST_NAME: pyopenssl - - name: pyopenssl-ubuntu-22 - tasks: - - name: .test-standard .python-3.15t !.server-4.4 !.server-5.0 .sync - - name: .test-standard .python-3.15t !.server-4.4 !.server-5.0 .async .replica_set-noauth-ssl - display_name: PyOpenSSL Ubuntu-22 - run_on: - - ubuntu2204-small - batchtime: 1440 - expansions: - SUB_TEST_NAME: pyopenssl - tags: [pr] - - # Sanitizer tests - - name: sanitizer-rhel8 - tasks: - - name: .sanitizer - display_name: Sanitizer RHEL8 - run_on: - - rhel8.10-large - expansions: - VERSION: "9.0" - tags: [pr] - - # Search index tests - - name: search-index-helpers-rhel8 - tasks: - - name: .search_index - display_name: Search Index Helpers RHEL8 - run_on: - - rhel8.10-small - - # Server version tests - - name: mongodb-v4.4 - tasks: - - name: .server-version !.pr - - name: .server-version .4.4 - display_name: "* MongoDB v4.4" - run_on: - - rhel8.10-small - expansions: - VERSION: "4.4" - tags: [coverage_tag] - - name: mongodb-v5.0 - tasks: - - name: .server-version !.pr - display_name: "* MongoDB v5.0" - run_on: - - rhel8.10-small - expansions: - VERSION: "5.0" - tags: [coverage_tag] - - name: mongodb-v6.0 - tasks: - - name: .server-version !.pr - display_name: "* MongoDB v6.0" - run_on: - - rhel8.10-small - expansions: - VERSION: "6.0" - tags: [coverage_tag] - - name: mongodb-v7.0 - tasks: - - name: .server-version !.pr - display_name: "* MongoDB v7.0" - run_on: - - rhel8.10-small - expansions: - VERSION: "7.0" - tags: [coverage_tag] - - name: mongodb-v8.0 - tasks: - - name: .server-version !.pr - display_name: "* MongoDB v8.0" - run_on: - - rhel8.10-small - expansions: - VERSION: "8.0" - tags: [coverage_tag] - - name: mongodb-v9.0 - tasks: - - name: .server-version !.pr - - name: .server-version .9.0 - display_name: "* MongoDB v9.0" - run_on: - - rhel8.10-small - expansions: - VERSION: "9.0" - tags: [coverage_tag] - - name: mongodb-rapid - tasks: - - name: .server-version !.pr - display_name: "* MongoDB rapid" - run_on: - - rhel8.10-small - expansions: - VERSION: rapid - tags: [coverage_tag] - - name: mongodb-latest - tasks: - - name: .server-version !.pr - display_name: "* MongoDB latest" - run_on: - - rhel8.10-small - expansions: - VERSION: latest - tags: [coverage_tag] - - # Sfp tests - - name: sfp-rhel8 - tasks: - - name: .test-no-orchestration - display_name: SFP RHEL8 - run_on: - - rhel8.10-small - expansions: - TEST_NAME: sfp - tags: [pr] - - # Stable api tests - - name: stable-api-require-v1-rhel8-auth - tasks: - - name: .test-standard !.replica_set-noauth-ssl .server-5.0 - - name: .test-standard !.replica_set-noauth-ssl .server-6.0 - - name: .test-standard !.replica_set-noauth-ssl .server-7.0 - - name: .test-standard !.replica_set-noauth-ssl .server-8.0 - - name: .test-standard !.replica_set-noauth-ssl .server-9.0 - - name: .test-standard !.replica_set-noauth-ssl .server-rapid - - name: .test-standard !.replica_set-noauth-ssl .server-latest - display_name: Stable API require v1 RHEL8 Auth - run_on: - - rhel8.10-small - expansions: - AUTH: auth - REQUIRE_API_VERSION: "1" - MONGODB_API_VERSION: "1" - tags: [versionedApi_tag] - - name: stable-api-accept-v2-rhel8-auth - tasks: - - name: .test-standard .server-5.0 .standalone-noauth-nossl - - name: .test-standard .server-6.0 .standalone-noauth-nossl - - name: .test-standard .server-7.0 .standalone-noauth-nossl - - name: .test-standard .server-8.0 .standalone-noauth-nossl - - name: .test-standard .server-9.0 .standalone-noauth-nossl - - name: .test-standard .server-rapid .standalone-noauth-nossl - - name: .test-standard .server-latest .standalone-noauth-nossl - display_name: Stable API accept v2 RHEL8 Auth - run_on: - - rhel8.10-small - expansions: - AUTH: auth - ORCHESTRATION_FILE: versioned-api-testing.json - tags: [versionedApi_tag] - - # Standard nonlinux tests - - name: test-macos - tasks: - - name: .test-standard - display_name: "* Test macOS" - run_on: - - macos-14 - tags: [standard-non-linux] - - name: test-macos-arm64 - tasks: - - name: .test-standard .server-6.0 - - name: .test-standard .server-7.0 - - name: .test-standard .server-8.0 - - name: .test-standard .server-9.0 - - name: .test-standard .server-rapid - - name: .test-standard .server-latest - display_name: "* Test macOS Arm64" - run_on: - - macos-14-arm64 - tags: [standard-non-linux] - - name: test-win64 - tasks: - - name: .test-standard - - name: .test-no-orchestration - display_name: "* Test Win64" - run_on: - - windows-2022-latest-small - tags: [standard-non-linux] - - name: test-win32 - tasks: - - name: .test-standard !.free-threaded - display_name: "* Test Win32" - run_on: - - windows-64-vsMulti-small - expansions: - IS_WIN32: "1" - tags: [standard-non-linux] - - # Storage engine tests - - name: storage-inmemory-rhel8 - tasks: - - name: .test-standard .standalone-noauth-nossl - display_name: Storage InMemory RHEL8 - run_on: - - rhel8.10-small - expansions: - STORAGE_ENGINE: inmemory - - # Test numpy tests - - name: test-numpy-rhel8 - tasks: - - name: .test-numpy - display_name: Test Numpy RHEL8 - run_on: - - rhel8.10-small - tags: [binary, vector, pr] - - name: test-numpy-macos - tasks: - - name: .test-numpy - display_name: Test Numpy macOS - run_on: - - macos-14 - tags: [binary, vector] - - name: test-numpy-macos-arm64 - tasks: - - name: .test-numpy - display_name: Test Numpy macOS Arm64 - run_on: - - macos-14-arm64 - tags: [binary, vector] - - name: test-numpy-win64 - tasks: - - name: .test-numpy - display_name: Test Numpy Win64 - run_on: - - windows-2022-latest-small - tags: [binary, vector] - - name: test-numpy-win32 - tasks: - - name: .test-numpy - display_name: Test Numpy Win32 - run_on: - - windows-64-vsMulti-small - expansions: - IS_WIN32: "1" - tags: [binary, vector] diff --git a/.evergreen/just.sh b/.evergreen/just.sh deleted file mode 100755 index bebbca8282..0000000000 --- a/.evergreen/just.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -eu - -. .evergreen/scripts/setup-dev-env.sh -just "$@" diff --git a/.evergreen/remove-unimplemented-tests.sh b/.evergreen/remove-unimplemented-tests.sh deleted file mode 100755 index 7982dd6b21..0000000000 --- a/.evergreen/remove-unimplemented-tests.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -PYMONGO=$(dirname "$(cd "$(dirname "$0")" || exit; pwd)") - -rm $PYMONGO/test/connection_monitoring/wait-queue-fairness.json # PYTHON-1873 -rm $PYMONGO/test/discovery_and_monitoring/unified/pool-clear-application-error.json # PYTHON-4918 -rm $PYMONGO/test/discovery_and_monitoring/unified/pool-clear-checkout-error.json # PYTHON-4918 -rm $PYMONGO/test/discovery_and_monitoring/unified/pool-clear-min-pool-size-error.json # PYTHON-4918 -rm $PYMONGO/test/client-side-encryption/spec/unified/client-bulkWrite-qe.json # PYTHON-4929 - -# Python doesn't implement DRIVERS-3064 -rm $PYMONGO/test/collection_management/listCollections-rawdata.json -rm $PYMONGO/test/crud/unified/aggregate-rawdata.json -rm $PYMONGO/test/crud/unified/bulkWrite-deleteMany-rawdata.json -rm $PYMONGO/test/crud/unified/bulkWrite-deleteOne-rawdata.json -rm $PYMONGO/test/crud/unified/bulkWrite-replaceOne-rawdata.json -rm $PYMONGO/test/crud/unified/bulkWrite-updateMany-rawdata.json -rm $PYMONGO/test/crud/unified/bulkWrite-updateOne-rawdata.json -rm $PYMONGO/test/crud/unified/client-bulkWrite-delete-rawdata.json -rm $PYMONGO/test/crud/unified/client-bulkWrite-replaceOne-rawdata.json -rm $PYMONGO/test/crud/unified/client-bulkWrite-update-rawdata.json -rm $PYMONGO/test/crud/unified/count-rawdata.json -rm $PYMONGO/test/crud/unified/countDocuments-rawdata.json -rm $PYMONGO/test/crud/unified/db-aggregate-rawdata.json -rm $PYMONGO/test/crud/unified/deleteMany-rawdata.json -rm $PYMONGO/test/crud/unified/deleteOne-rawdata.json -rm $PYMONGO/test/crud/unified/distinct-rawdata.json -rm $PYMONGO/test/crud/unified/estimatedDocumentCount-rawdata.json -rm $PYMONGO/test/crud/unified/find-rawdata.json -rm $PYMONGO/test/crud/unified/findOneAndDelete-rawdata.json -rm $PYMONGO/test/crud/unified/findOneAndReplace-rawdata.json -rm $PYMONGO/test/crud/unified/findOneAndUpdate-rawdata.json -rm $PYMONGO/test/crud/unified/insertMany-rawdata.json -rm $PYMONGO/test/crud/unified/insertOne-rawdata.json -rm $PYMONGO/test/crud/unified/replaceOne-rawdata.json -rm $PYMONGO/test/crud/unified/updateMany-rawdata.json -rm $PYMONGO/test/crud/unified/updateOne-rawdata.json -rm $PYMONGO/test/index_management/index-rawdata.json - -# PyMongo does not support modifyCollection -rm $PYMONGO/test/collection_management/modifyCollection-*.json - -# PYTHON-5248 - Remove support for MongoDB 4.0 -find /$PYMONGO/test -type f -name 'pre-42-*.json' -delete - -# PYTHON-3359 - Remove Database and Collection level timeout override -rm $PYMONGO/test/csot/override-collection-timeoutMS.json -rm $PYMONGO/test/csot/override-database-timeoutMS.json - -# PYTHON-2943 - Socks5 Proxy Support -rm $PYMONGO/test/uri_options/proxy-options.json - -# PYTHON-5517 - Avoid clearing the connection pool when the server connection rate limiter triggers -rm $PYMONGO/test/discovery_and_monitoring/unified/backpressure-*.json - -echo "Done removing unimplemented tests" diff --git a/.evergreen/resync-specs.sh b/.evergreen/resync-specs.sh deleted file mode 100755 index c2eb795ca1..0000000000 --- a/.evergreen/resync-specs.sh +++ /dev/null @@ -1,288 +0,0 @@ -#!/bin/bash -# Resync test files from the specifications repo. -set -eu -PYMONGO=$(dirname "$(cd "$(dirname "$0")"; pwd)") -SPECS=${MDB_SPECS:-~/Work/specifications} - -help (){ - echo "Usage: resync_specs.sh [-bcsp] spec" - echo "Required arguments:" - echo " spec determines which folder the spec tests will be copied from." - echo "Optional flags:" - echo " -b is used to add a string to the blocklist for that next run. Can be used" - echo " any number of times on a single command to block multiple patterns." - echo " You can use any regex pattern (it is passed to 'grep -Ev')." - echo " -c is used to set a branch or commit that will be checked out in the" - echo " specifications repo before copying." - echo " -s is used to set a unique path to the specs repo for that specific" - echo " run." - echo "Notes:" - echo "You can export the environment variable MDB_SPECS to set the specs" - echo " repo similar to -s, but this will persist between runs until you " - echo "unset it." -} - -# Parse flag args -BRANCH='' -BLOCKLIST='.*\.yml' -while getopts 'b:c:s:' flag; do - case "${flag}" in - b) BLOCKLIST+="|$OPTARG" - ;; - c) BRANCH="${OPTARG}" - ;; - s) SPECS="${OPTARG}" - ;; - *) help; exit 0 - ;; - esac -done -shift $((OPTIND-1)) - -if [ -n "$BRANCH" ] -then - git -C $SPECS checkout $BRANCH -fi - -# Ensure the JSON files are up to date. -if ! [ -n "${CI:-}" ] -then - cd $SPECS/source - make - cd - -fi -# cpjson unified-test-format/tests/invalid unified-test-format/invalid -# * param1: Path to spec tests dir in specifications repo -# * param2: Path to where the corresponding tests live in Python. -cpjson () { - find "$PYMONGO"/test/$2 -type f -delete - cd "$SPECS"/source/$1 - find . -name '*.json' | grep -Ev "${BLOCKLIST}" | cpio -pdm \ - $PYMONGO/test/$2 - printf "\nIgnored files for ${PWD}:\n" - IGNORED_FILES="$(printf "\n%s\n" "$(diff <(find . -name '*.json' | sort) \ - <(find . -name '*.json' | grep -Ev "${BLOCKLIST}" | sort))" | \ - sed -e '/^[0-9]/d' | sed -e 's|< ./||g' )" - printf "%s\n" $IGNORED_FILES - cd "$PYMONGO"/test/$2 - printf "%s\n" $IGNORED_FILES | xargs git checkout main - -} - -# Copy the Public Suffix List bundled with the driver from the specs repo. -# Unlike the spec tests, this is driver source, so it lives in pymongo/ rather -# than test/. -# -# Upstream stores internationalized rules in Unicode form (e.g. "公司.cn"), but -# the PSL algorithm requires rules and domains to be compared as lowercase -# Punycode. Convert the rules here, at vendoring time, so that loading the list -# at runtime stays a plain string parse. Comment lines are passed through -# unchanged in case a future upstream copy keeps them. -cp_psl () { - local src="$SPECS/source/public-suffix-list/public_suffix_list.dat" - if ! [ -f "$src" ] - then - echo "Could not find the public suffix list at $src" >&2 - return 1 - fi - # Use the newest mongodbtoolchain python on CI hosts; python3 fallback locally. - PY=$(ls -1d /opt/mongodbtoolchain/v*/bin/python3 2>/dev/null | sort -V | tail -1) - [ -n "$PY" ] || PY=python3 - [ "$("$PY" -c 'import sys; print(sys.version_info >= (3, 7))' 2>/dev/null)" = True ] \ - || { echo "Error: $PY is not Python 3.7+, which this conversion requires." >&2; return 1; } - "$PY" - "$src" "$PYMONGO"/pymongo/public_suffix_list.dat <<'EOF' -import os -import sys - -src, dst = sys.argv[1], sys.argv[2] - -# Convert in memory and write atomically so failures can't truncate the list. -with open(src, encoding="utf-8") as f: - lines = f.readlines() -if not lines: - print(f"Source public suffix list is empty: {src}", file=sys.stderr) - sys.exit(1) - -converted = [] -for line in lines: - rule = line.strip() - if rule and not rule.startswith("//") and not rule.isascii(): - # "!" and "*." prefixes are not valid IDNA, so encode only the - # domain part and re-attach the prefix afterwards. - prefix = "" - for p in ("!", "*."): - if rule.startswith(p): - prefix, rule = p, rule[len(p) :] - break - try: - rule = rule.encode("idna").decode("ascii") - except UnicodeError: - print(f"Could not convert rule to Punycode: {prefix}{rule}", file=sys.stderr) - sys.exit(1) - line = f"{prefix}{rule.lower()}\n" - converted.append(line) - -if len(converted) != len(lines): - print( - f"Conversion lost lines: {len(lines)} in, {len(converted)} out", - file=sys.stderr, - ) - sys.exit(1) - -# A blank or comment-only source must not replace the real list. -if not any(ln.strip() and not ln.strip().startswith("//") for ln in converted): - print(f"Source public suffix list has no rules: {src}", file=sys.stderr) - sys.exit(1) - -tmp = dst + ".tmp" -with open(tmp, "w", encoding="utf-8") as out: - out.writelines(converted) -os.replace(tmp, dst) -EOF -} - -for spec in "$@" -do - # Match the spec dir name, the python test dir name, and/or common abbreviations. - case "$spec" in - auth) - cpjson auth/tests/ auth - ;; - bson-binary-vector|bson_binary_vector) - cpjson bson-binary-vector/tests/ bson_binary_vector - ;; - bson-corpus|bson_corpus) - cpjson bson-corpus/tests/ bson_corpus - ;; - max-staleness|max_staleness) - cpjson max-staleness/tests/ max_staleness - ;; - collection-management|collection_management) - cpjson collection-management/tests/ collection_management - ;; - connection-string|connection_string) - cpjson connection-string/tests/ connection_string/test - ;; - change-streams|change_streams) - cpjson change-streams/tests/ change_streams/ - ;; - client-backpressure|client_backpressure) - cpjson client-backpressure/tests client-backpressure - ;; - client-side-encryption|csfle|fle) - cpjson client-side-encryption/tests/ client-side-encryption/spec - cpjson client-side-encryption/corpus/ client-side-encryption/corpus - cpjson client-side-encryption/external/ client-side-encryption/external - cpjson client-side-encryption/limits/ client-side-encryption/limits - cpjson client-side-encryption/etc/data client-side-encryption/etc/data - ;; - connection-monitoring|connection_monitoring) - cpjson connection-monitoring-and-pooling/tests/cmap-format connection_monitoring - ;; - connection-logging|connection_logging) - cpjson connection-monitoring-and-pooling/tests/logging connection_logging - ;; - cmap|CMAP|connection-monitoring-and-pooling) - cpjson connection-monitoring-and-pooling/tests/logging connection_logging - cpjson connection-monitoring-and-pooling/tests/cmap-format connection_monitoring - ;; - apm|APM|command-monitoring|command_monitoring) - cpjson command-logging-and-monitoring/tests/monitoring command_monitoring - ;; - causal|causal-consistency|causal_consistency) - cpjson causal-consistency/tests/ causal_consistency - ;; - command-logging|command_logging) - cpjson command-logging-and-monitoring/tests/logging command_logging - ;; - clam|CLAM|command-logging-and-monitoring|command_logging_and_monitoring) - cpjson command-logging-and-monitoring/tests/logging command_logging - cpjson command-logging-and-monitoring/tests/monitoring command_monitoring - ;; - crud|CRUD) - cpjson crud/tests/ crud - ;; - csot|CSOT|client-side-operations-timeout) - cpjson client-side-operations-timeout/tests csot - ;; - gridfs) - cpjson gridfs/tests gridfs - ;; - handshake) - cpjson mongodb-handshake/tests handshake - ;; - index|index-management) - cpjson index-management/tests index_management - ;; - load-balancers|load_balancer) - cpjson load-balancers/tests load_balancer - ;; - srv|SRV|initial-dns-seedlist-discovery|srv_seedlist) - cpjson initial-dns-seedlist-discovery/tests/ srv_seedlist - # srvAllowedHostsSuffix validation uses the bundled Public Suffix List. - cp_psl - ;; - psl|public-suffix-list|public_suffix_list) - cp_psl - ;; - read-write-concern|read_write_concern) - cpjson read-write-concern/tests/operation read_write_concern/operation - cpjson read-write-concern/tests/write-concern-errors read_write_concern/write-concern-errors - ;; - retryable-reads|retryable_reads) - cpjson retryable-reads/tests/ retryable_reads - ;; - retryable-writes|retryable_writes) - cpjson retryable-writes/tests/ retryable_writes - ;; - run-command|run_command) - cpjson run-command/tests/ run_command - ;; - sdam|SDAM|server-discovery-and-monitoring|discovery_and_monitoring) - cpjson server-discovery-and-monitoring/tests/errors \ - discovery_and_monitoring/errors - cpjson server-discovery-and-monitoring/tests/rs \ - discovery_and_monitoring/rs - cpjson server-discovery-and-monitoring/tests/sharded \ - discovery_and_monitoring/sharded - cpjson server-discovery-and-monitoring/tests/single \ - discovery_and_monitoring/single - cpjson server-discovery-and-monitoring/tests/unified \ - discovery_and_monitoring/unified - cpjson server-discovery-and-monitoring/tests/load-balanced \ - discovery_and_monitoring/load-balanced - ;; - sdam-monitoring|sdam_monitoring) - cpjson server-discovery-and-monitoring/tests/monitoring sdam_monitoring - ;; - server-selection|server_selection) - cpjson server-selection/tests/ server_selection - rm -rf $PYMONGO/test/server_selection/logging # these tests live in server_selection_logging - cpjson server-selection/tests/logging server_selection_logging - ;; - server-selection-logging|server_selection_logging) - cpjson server-selection/tests/logging server_selection_logging - ;; - sessions) - cpjson sessions/tests/ sessions - ;; - transactions|transactions-convenient-api) - cpjson transactions/tests/ transactions - cpjson transactions-convenient-api/tests/ transactions-convenient-api - ;; - unified|unified-test-format) - cpjson unified-test-format/tests/ unified-test-format/ - ;; - uri|uri-options|uri_options) - cpjson uri-options/tests uri_options - cp "$SPECS"/source/uri-options/tests/*.pem $PYMONGO/test/uri_options - ;; - stable-api|versioned-api) - cpjson versioned-api/tests versioned-api - ;; - *) - echo "Do not know how to resync spec tests for '${spec}'" - help - ;; - esac -done diff --git a/.evergreen/run-mongodb-aws-ecs-test.sh b/.evergreen/run-mongodb-aws-ecs-test.sh deleted file mode 100755 index 8b5521155a..0000000000 --- a/.evergreen/run-mongodb-aws-ecs-test.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# Script run on an ECS host to test MONGODB-AWS. -set -eu - -############################################ -# Main Program # -############################################ - -if [[ -z "$1" ]]; then - echo "usage: $0 " - exit 1 -fi -export MONGODB_URI="$1" - -if echo "$MONGODB_URI" | grep -q "@"; then - echo "MONGODB_URI unexpectedly contains user credentials in ECS test!"; - exit 1 -fi -# Now we can safely enable xtrace -set -o xtrace - -# Install a C compiler (for the C extensions), pip (needed by ensure_uv: -# the image's Python has neither pip nor ensurepip), and git (needed by uv -# to resolve the mockupdb git dependency) -apt-get -qq update < /dev/null > /dev/null -apt-get -q install -y build-essential git python3-pip - -export SET_XTRACE_ON=1 -export CI=true -cd src -rm -rf .venv -rm -f .evergreen/scripts/test-env.sh || true -rm -f .evergreen/scripts/env.sh || true -bash ./.evergreen/just.sh setup-tests auth_aws ecs-remote -bash .evergreen/just.sh run-tests diff --git a/.evergreen/run-mongodb-oidc-test.sh b/.evergreen/run-mongodb-oidc-test.sh deleted file mode 100755 index b34013a6ac..0000000000 --- a/.evergreen/run-mongodb-oidc-test.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# Script run on a remote host to test MONGODB-OIDC. -set -eu - -echo "Running MONGODB-OIDC authentication tests on ${OIDC_ENV}..." - -if [ ${OIDC_ENV} == "k8s" ]; then - SUB_TEST_NAME=$K8S_VARIANT-remote -else - SUB_TEST_NAME=$OIDC_ENV-remote - sudo apt-get install -y python3-dev build-essential -fi - -bash ./.evergreen/just.sh setup-tests auth_oidc $SUB_TEST_NAME -bash ./.evergreen/just.sh run-tests "${@:1}" - -echo "Running MONGODB-OIDC authentication tests on ${OIDC_ENV}... done." diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh deleted file mode 100755 index aa1fe97610..0000000000 --- a/.evergreen/run-tests.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# Run a test suite that was configured with setup-tests.sh. -set -eu - -SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0}) -SCRIPT_DIR="$( cd -- "$SCRIPT_DIR" > /dev/null 2>&1 && pwd )" -ROOT_DIR="$(dirname $SCRIPT_DIR)" - -PREV_DIR=$(pwd) -cd $ROOT_DIR - -# Try to source the env file. -if [ -f $SCRIPT_DIR/scripts/env.sh ]; then - echo "Sourcing env inputs" - . $SCRIPT_DIR/scripts/env.sh -else - echo "Not sourcing env inputs" -fi - -# Handle test inputs. -if [ -f $SCRIPT_DIR/scripts/test-env.sh ]; then - echo "Sourcing test inputs" - . $SCRIPT_DIR/scripts/test-env.sh -else - echo "Missing test inputs, please run 'just setup-tests'" - exit 1 -fi - -# No-op on Evergreen (just.sh already ran this); needed for direct/local runs (PYTHON-6135). -. $SCRIPT_DIR/scripts/setup-uv-python.sh - -# Start the test runner. -echo "Running tests with UV_PYTHON=${UV_PYTHON:-} UV_PYTHON_SEARCH_PATH=${UV_PYTHON_SEARCH_PATH:-}..." -echo "UV_ARGS=${UV_ARGS}" -uv run ${UV_ARGS} --reinstall-package pymongo .evergreen/scripts/run_tests.py "$@" -echo "Running tests with UV_PYTHON=${UV_PYTHON:-} UV_PYTHON_SEARCH_PATH=${UV_PYTHON_SEARCH_PATH:-}... done." - -cd $PREV_DIR diff --git a/.evergreen/scripts/__init__.py b/.evergreen/scripts/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/.evergreen/scripts/check-import-time.sh b/.evergreen/scripts/check-import-time.sh deleted file mode 100755 index ce4e834708..0000000000 --- a/.evergreen/scripts/check-import-time.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# Check for regressions in the import time of pymongo. -set -eu - -HERE=$(dirname ${BASH_SOURCE:-$0}) - -source $HERE/env.sh - -pushd $HERE/../.. >/dev/null - -BASE_SHA="$1" -HEAD_SHA="$2" - -# Set up the virtual env. -. $HERE/setup-dev-env.sh -uv venv --seed -source .venv/bin/activate - -# Use the previous commit if this was not a PR run. -if [ "$BASE_SHA" == "$HEAD_SHA" ]; then - BASE_SHA=$(git rev-parse HEAD~1) -fi - -function get_import_time() { - local log_file - python -m pip install -q ".[aws,encryption,gssapi,ocsp,snappy,zstd]" - # Import once to cache modules - python -c "import pymongo" - log_file="pymongo-$1.log" - python -X importtime -c "import pymongo" 2> $log_file -} - -get_import_time $HEAD_SHA -git stash || true -git checkout $BASE_SHA -get_import_time $BASE_SHA -git checkout $HEAD_SHA -git stash apply || true -python tools/compare_import_time.py $HEAD_SHA $BASE_SHA - -popd >/dev/null diff --git a/.evergreen/scripts/cleanup.sh b/.evergreen/scripts/cleanup.sh deleted file mode 100755 index 44b36d3569..0000000000 --- a/.evergreen/scripts/cleanup.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# Clean up resources at the end of an evergreen run. -set -eu - -HERE=$(dirname ${BASH_SOURCE:-$0}) - -# Try to source the env file. -if [ -f $HERE/env.sh ]; then - echo "Sourcing env file" - source $HERE/env.sh -fi - -# Don't delete the in-tree submodule; clean the ignored credential and state -# files (secrets-export.sh, AWS creds, token files) that `git submodule update` -# leaves behind, so they can't carry into later tasks on a reused host. A -# caller-provided DRIVERS_TOOLS wins, so the checkout actually used is cleaned. -: "${DRIVERS_TOOLS:=$HERE/../../drivers-evergreen-tools}" -rm -f $HERE/../../secrets-export.sh || true -git -C "$DRIVERS_TOOLS" clean -fdx 2>/dev/null || true diff --git a/.evergreen/scripts/configure-env.sh b/.evergreen/scripts/configure-env.sh deleted file mode 100755 index 360706a944..0000000000 --- a/.evergreen/scripts/configure-env.sh +++ /dev/null @@ -1,142 +0,0 @@ -#!/bin/bash -# Configure an evergreen test environment. -set -eu - -# Get the current unique version of this checkout -# shellcheck disable=SC2154 -if [ "${is_patch:-}" = "true" ]; then - # shellcheck disable=SC2154 - CURRENT_VERSION="$(git describe)-patch-$version_id" -else - CURRENT_VERSION=latest -fi - -PROJECT_DIRECTORY="$(pwd)" -# Default to the submodule; an env var override wins. -DRIVERS_TOOLS="${DRIVERS_TOOLS:-$PROJECT_DIRECTORY/drivers-evergreen-tools}" -CARGO_HOME=${CARGO_HOME:-${DRIVERS_TOOLS}/.cargo} -DRIVERS_TOOLS_BINARIES="$DRIVERS_TOOLS/.bin" -MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" - -# On Evergreen jobs, "CI" will be set, and we don't want to write to $HOME or -# have binaries shared across tasks, so use a TMPDIR. On non-CI hosts -# (spawn hosts, VMs such as GCP/Azure, and local dev), use the conventional -# ~/.local/bin which tools on the PATH (or the shell rc) can find. -if [ "${CI:-}" == "true" ]; then - PYMONGO_BIN_DIR="${TMPDIR:-/tmp}"/pymongo_bin -else - PYMONGO_BIN_DIR=$HOME/.local/bin -fi - -# Cygwin spelling for bash PATH entries; PYMONGO_BIN_DIR itself is converted -# to native form below for consumers like uv. -if [ "Windows_NT" = "${OS:-}" ]; then - PYMONGO_BIN_DIR_POSIX="$(cygpath -u "$PYMONGO_BIN_DIR")" -else - PYMONGO_BIN_DIR_POSIX="$PYMONGO_BIN_DIR" -fi - -# Add the latest MongoDB toolchain bin dir to PATH if it exists, so that hosts -# with an old system Python (e.g. RHEL8's 3.6) still get a modern interpreter -# for tool installs like `uv tool install rust-just`. It goes after -# PYMONGO_BIN_DIR so the pinned uv (installed there by setup_uv.py) takes -# precedence over the toolchain's uv. -if [ "Windows_NT" = "${OS:-}" ]; then - _toolchain_bin="/cygdrive/c/Python/Current/Scripts" -elif [ "$(uname -s)" == "Darwin" ]; then - _toolchain_bin="/Library/Frameworks/Python.Framework/Versions/Current/bin" -else - _toolchain_bin="/opt/python/Current/bin" -fi -if [ -d "$_toolchain_bin" ]; then - PATH_EXT="$MONGODB_BINARIES:$PYMONGO_BIN_DIR_POSIX:$_toolchain_bin:$DRIVERS_TOOLS_BINARIES:\$PATH" -else - PATH_EXT="$MONGODB_BINARIES:$PYMONGO_BIN_DIR_POSIX:$DRIVERS_TOOLS_BINARIES:\$PATH" -fi - -# Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory -if [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin - DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS) - PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY) - CARGO_HOME=$(cygpath -m $CARGO_HOME) - DRIVERS_TOOLS_BINARIES=$(cygpath -m "$DRIVERS_TOOLS_BINARIES") - MONGODB_BINARIES=$(cygpath -m "$MONGODB_BINARIES") - # Native form, uniform with the paths above, for consumers like uv. - PYMONGO_BIN_DIR=$(cygpath -m "$PYMONGO_BIN_DIR") -fi - -SCRIPT_DIR="$PROJECT_DIRECTORY/.evergreen/scripts" - -if [ -f "$SCRIPT_DIR/env.sh" ]; then - echo "Reading $SCRIPT_DIR/env.sh file" - . "$SCRIPT_DIR/env.sh" - exit 0 -fi - -export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration" -export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" - -cat < "$SCRIPT_DIR"/env.sh -export PROJECT_DIRECTORY="$PROJECT_DIRECTORY" -export CURRENT_VERSION="$CURRENT_VERSION" -export DRIVERS_TOOLS="$DRIVERS_TOOLS" -export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME" -export MONGODB_BINARIES="$MONGODB_BINARIES" -export DRIVERS_TOOLS_BINARIES="$DRIVERS_TOOLS_BINARIES" -export PROJECT_DIRECTORY="$PROJECT_DIRECTORY" - -export CARGO_HOME="$CARGO_HOME" -export PYMONGO_BIN_DIR="$PYMONGO_BIN_DIR" -export PYMONGO_BIN_DIR_POSIX="$PYMONGO_BIN_DIR_POSIX" -export PATH="$PATH_EXT" -# shellcheck disable=SC2154 -export PROJECT="${project:-mongo-python-driver}" -export PIP_QUIET=1 -EOT - -# Only touch the in-tree submodule when it is the checkout actually in use; -# an overridden DRIVERS_TOOLS is a checkout we do not own. -if [ "$DRIVERS_TOOLS" = "$PROJECT_DIRECTORY/drivers-evergreen-tools" ]; then - # Initialize the submodule (Evergreen's git.get_project does not); tolerate - # non-git hosts with a warning. - if ! git -C "$PROJECT_DIRECTORY" submodule update --init --recursive; then - echo "WARNING: could not initialize the drivers-evergreen-tools submodule;" \ - "using the existing checkout contents instead." - fi - - # Write a uv config boundary into the submodule: it is vendored inside this - # project, so uv run by the tools' own scripts would otherwise walk up to - # pyproject.toml and enforce our required-version pin. Write-if-absent, so an - # upstream uv.toml fails the submodule update loudly instead of being clobbered. - if [ -d "${DRIVERS_TOOLS}" ] && [ ! -f "${DRIVERS_TOOLS}/uv.toml" ]; then - cat < "${DRIVERS_TOOLS}/uv.toml" -# Written by mongo-python-driver to stop uv's config discovery here; see -# .evergreen/scripts/configure-env.sh. -EOT - fi - - # Keep the boundary out of git status via the submodule's local exclude; - # no-op without git. - if _git_dir=$(git -C "${DRIVERS_TOOLS}" rev-parse --absolute-git-dir 2>/dev/null); then - mkdir -p "${_git_dir}/info" - grep -qxF "uv.toml" "${_git_dir}/info/exclude" 2>/dev/null || - printf "uv.toml\n" >> "${_git_dir}/info/exclude" - fi -fi - -# Write the .env file for drivers-tools. Create the checkout if it is missing so -# a failed submodule init does not stop this script before setup-tests.py can -# reach check_drivers_tools() and report the problem actionably. -mkdir -p "${DRIVERS_TOOLS}" -cat < ${DRIVERS_TOOLS}/.env -SKIP_LEGACY_SHELL=1 -DRIVERS_TOOLS="$DRIVERS_TOOLS" -MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME" -MONGODB_BINARIES="$MONGODB_BINARIES" -EOT - -# Add these expansions to make it easier to call out tests scripts from the EVG yaml -cat < expansion.yml -DRIVERS_TOOLS: "$DRIVERS_TOOLS" -PROJECT_DIRECTORY: "$PROJECT_DIRECTORY" -EOT diff --git a/.evergreen/scripts/create-fuzz-corpus-pr.sh b/.evergreen/scripts/create-fuzz-corpus-pr.sh deleted file mode 100755 index 7bf337702e..0000000000 --- a/.evergreen/scripts/create-fuzz-corpus-pr.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -set -eu - -# Open (or update) the automated pull request that grows fuzz/corpus/ -# with freshly harvested units. Arguments: 1 = harvested units directory, -# 2 = harvest summary markdown to use as the PR body. - -harvest_dir="$1" -summary_file="$2" -today="$(date '+%m-%d-%Y')" - -# Shared github-app authentication, git branch and PR plumbing. -# shellcheck disable=SC1091 -. "$(dirname "${BASH_SOURCE[0]}")/github-pr-util.sh" - -acquire_github_token - -echo "Creating the git checkout..." -branch="fuzz-corpus-${today}" -prepare_bot_branch "$branch" - -mkdir -p fuzz/corpus -cp "$harvest_dir"/* fuzz/corpus/ -if ! stage_and_commit "PYTHON-6178 Grow the BSON fuzz corpus (${today})" fuzz/corpus; then - echo "No new corpus units to commit; skipping PR creation." - exit 0 -fi -echo "Creating the git checkout... done." - -push_branch "$branch" -create_or_update_pr "$branch" "[Fuzz Corpus] ${today}" "$summary_file" diff --git a/.evergreen/scripts/create-spec-pr.sh b/.evergreen/scripts/create-spec-pr.sh deleted file mode 100755 index 51561ef29f..0000000000 --- a/.evergreen/scripts/create-spec-pr.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -set -eu - -# Open (or update) the automated pull request resyncing the spec tests. -# Arguments: 1 = resync summary text to use as the PR body. - -summary_file="$1" -today="$(date '+%m-%d-%Y')" - -# Shared github-app authentication, git branch and PR plumbing. -# shellcheck disable=SC1091 -. "$(dirname "${BASH_SOURCE[0]}")/github-pr-util.sh" - -acquire_github_token - -echo "Creating the git checkout..." -branch="spec-resync-${today}" -prepare_bot_branch "$branch" - -# The spec sync also updates the vendored public suffix list (cp_psl in -# resync-specs.sh), a tracked file outside test/. -if ! stage_and_commit "resyncing specs ${today}" ./test pymongo/public_suffix_list.dat; then - echo "No spec changes to commit; skipping PR creation." - cat "$summary_file" - exit 0 -fi -echo "Creating the git checkout... done." - -push_branch "$branch" -create_or_update_pr "$branch" "[Spec Resync] ${today}" "$summary_file" diff --git a/.evergreen/scripts/dispatch.sh b/.evergreen/scripts/dispatch.sh deleted file mode 100755 index 372cf6535c..0000000000 --- a/.evergreen/scripts/dispatch.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# Route the just test recipes to the mod_wsgi tests or the Evergreen test -# runner. The mod_wsgi setup writes TEST_NAME to the test env file. -set -eu - -SCRIPT_DIR=$(dirname "${BASH_SOURCE:-$0}") -RECIPE="${1:-}" -if [ "$#" -gt 0 ]; then - shift -fi - -mod_wsgi_env() { - [ -f "$SCRIPT_DIR/test-env.sh" ] \ - && grep -q 'TEST_NAME="mod_wsgi"' "$SCRIPT_DIR/test-env.sh" \ - && bash "$SCRIPT_DIR/mod_wsgi.sh" active -} - -case "$RECIPE" in - setup-tests) - if [ "${1:-}" = "mod_wsgi" ]; then - shift - exec bash "$SCRIPT_DIR/mod_wsgi.sh" setup "${1:-}" - fi - exec bash "$SCRIPT_DIR/setup-tests.sh" "$@" - ;; - run-tests) - if mod_wsgi_env; then - if [ "$#" -gt 0 ]; then - echo "Ignoring arguments for the mod_wsgi tests: $*" >&2 - fi - exec bash "$SCRIPT_DIR/mod_wsgi.sh" test - fi - exec bash "$(dirname "$SCRIPT_DIR")/run-tests.sh" "$@" - ;; - teardown-tests) - if [ -f "$SCRIPT_DIR/test-env.sh" ] \ - && grep -q 'TEST_NAME="mod_wsgi"' "$SCRIPT_DIR/test-env.sh"; then - exec bash "$SCRIPT_DIR/mod_wsgi.sh" teardown - fi - exec bash "$SCRIPT_DIR/teardown-tests.sh" "$@" - ;; - *) - echo "Unknown recipe: $RECIPE" - exit 1 - ;; -esac diff --git a/.evergreen/scripts/download-and-merge-coverage.sh b/.evergreen/scripts/download-and-merge-coverage.sh deleted file mode 100755 index c006813ba9..0000000000 --- a/.evergreen/scripts/download-and-merge-coverage.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# Download all the task coverage files. -set -eu -aws s3 cp --recursive s3://"$1"/coverage/"$2"/"$3"/coverage/ coverage/ diff --git a/.evergreen/scripts/generate-config.sh b/.evergreen/scripts/generate-config.sh deleted file mode 100755 index 4f46605901..0000000000 --- a/.evergreen/scripts/generate-config.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# Entry point for the generate-config pre-commit hook. - -set -eu - -# Assert the generation rules, then regenerate the config. -python -m pytest .evergreen/scripts/test_generate_config.py -m "" - -python .evergreen/scripts/generate_config.py diff --git a/.evergreen/scripts/generate_config.py b/.evergreen/scripts/generate_config.py deleted file mode 100644 index 98cd1f14ea..0000000000 --- a/.evergreen/scripts/generate_config.py +++ /dev/null @@ -1,1545 +0,0 @@ -# Note: See CONTRIBUTING.md for how to update/run this file. -from __future__ import annotations - -import sys -from itertools import product -from typing import TYPE_CHECKING - -from generate_config_utils import ( - ALL_PYTHONS, - ALL_VERSIONS, - BATCHTIME_DAY, - BATCHTIME_WEEK, - C_EXTS, - CPYTHONS, - DEFAULT_HOST, - FREE_THREADED_PYTHON, - HOSTS, - MAX_PYTHON, - MAX_VERSION, - MIN_MAX_PYTHON, - MIN_PYTHON, - MIN_VERSION, - OTHER_HOSTS, - SYNCS, - TOPOLOGIES, - create_variant, - get_assume_role, - get_s3_put, - get_standard_auth_ssl, - get_subprocess_exec, - get_task_name, - get_variant_name, - get_versions_from, - handle_c_ext, - write_functions_to_file, - write_tasks_to_file, - write_variants_to_file, - zip_cycle, -) -from shrub.v3.evg_command import ( - FunctionCall, - archive_targz_pack, - attach_results, - attach_xunit_results, - ec2_assume_role, - expansions_update, - git_get_project, -) -from shrub.v3.evg_task import EvgTask, EvgTaskDependency, EvgTaskRef -from utils import PERF_PYTHON_VERSION - -if TYPE_CHECKING: - from shrub.v3.evg_build_variant import BuildVariant - -############## -# Variants -############## - - -def create_ocsp_variants() -> list[BuildVariant]: - variants = [] - # OCSP tests on default host with all servers v4.4+. - # MongoDB servers on Windows and MacOS do not staple OCSP responses and only support RSA. - # Only test with MongoDB 4.4 and latest. - for host_name in ["rhel8", "win64", "macos"]: - host = HOSTS[host_name] - if host == DEFAULT_HOST: - tasks = [".ocsp"] - else: - tasks = [".ocsp-rsa !.ocsp-staple .latest", ".ocsp-rsa !.ocsp-staple .4.4"] - variant = create_variant( - tasks, - get_variant_name("OCSP", host), - host=host, - batchtime=BATCHTIME_WEEK, - ) - variants.append(variant) - # Run the stapled OCSP tasks (tagged "pr") on every PR so cryptography-backend - # regressions, like the min-deps ML-KEM breakage in PYTHON-6032, are caught before merge - # instead of on the next weekly batch run. - if host == DEFAULT_HOST: - variants.append( - create_variant( - [".ocsp-staple .pr"], - get_variant_name("OCSP Staples", host), - tags=["pr"], - host=host, - ) - ) - return variants - - -def create_server_version_variants() -> list[BuildVariant]: - variants = [] - for version in ALL_VERSIONS: - display_name = get_variant_name("* MongoDB", version=version) - # Each version-boundary variant selects only the pr tasks pinned to its version. - if version in SERVER_VERSION_PR_PYTHONS: - tasks = [".server-version !.pr", f".server-version .{version}"] - else: - tasks = [".server-version !.pr"] - variant = create_variant( - tasks, - display_name, - version=version, - host=DEFAULT_HOST, - tags=["coverage_tag"], - ) - variants.append(variant) - return variants - - -def create_standard_nonlinux_variants() -> list[BuildVariant]: - variants = [] - base_display_name = "* Test" - - # Test a subset on each of the other platforms. - for host_name in ("macos", "macos-arm64", "win64", "win32"): - tasks = [".test-standard"] - # MacOS arm64 only works on server versions 6.0+ - if host_name == "macos-arm64": - tasks = [f".test-standard .server-{version}" for version in get_versions_from("6.0")] - if host_name == "win64": - tasks.append(".test-no-orchestration") - host = HOSTS[host_name] - tags = ["standard-non-linux"] - expansions = dict() - if host_name == "win32": - expansions["IS_WIN32"] = "1" - tasks = [".test-standard !.free-threaded"] - display_name = get_variant_name(base_display_name, host) - variant = create_variant(tasks, display_name, host=host, tags=tags, expansions=expansions) - variants.append(variant) - - return variants - - -def create_encryption_variants() -> list[BuildVariant]: - variants = [] - tags = ["encryption_tag"] - batchtime = BATCHTIME_DAY - - def get_encryption_expansions(encryption): - expansions = dict(TEST_NAME="encryption") - if "crypt_shared" in encryption: - expansions["TEST_CRYPT_SHARED"] = "true" - if "PyOpenSSL" in encryption: - expansions["SUB_TEST_NAME"] = "pyopenssl" - return expansions - - # Test encryption on all hosts. - for encryption, host in product( - ["Encryption", "Encryption crypt_shared"], ["rhel8", "macos", "win64"] - ): - expansions = get_encryption_expansions(encryption) - display_name = get_variant_name(encryption, host, **expansions) - tasks = [".test-non-standard !.python-3.15t"] - if host != "rhel8": - # Exclude coverage tasks (encryption suites exceed the 60-min timeout with - # coverage overhead on macOS/win64). - # Also include the non-coverage companion tasks (test-non-standard-no-cov) which - # carry the "latest" server tasks without COVERAGE=1. - tasks = [ - ".test-non-standard !.cov !.python-3.15t", - ".test-non-standard-no-cov !.python-3.15t", - ] - variant = create_variant( - tasks, - display_name, - host=host, - expansions=expansions, - batchtime=batchtime, - tags=tags, - ) - variants.append(variant) - - # Test PyOpenSSL on linux. - host = DEFAULT_HOST - encryption = "Encryption PyOpenSSL" - expansions = get_encryption_expansions(encryption) - display_name = get_variant_name(encryption, host, **expansions) - variant = create_variant( - [".test-non-standard !.python-3.15t"], - display_name, - host=host, - expansions=expansions, - batchtime=batchtime, - tags=tags, - ) - variants.append(variant) - - # The 3.15t encryption tests only run on Ubuntu 22, whose OpenSSL 3.0.2 is - # needed to build the cryptography package; only MongoDB 6.0+ runs there. - host = HOSTS["ubuntu22"] - expansions = get_encryption_expansions("Encryption") - display_name = get_variant_name("Encryption", host, **expansions) - variants.append( - create_variant( - [".test-non-standard .python-3.15t !.server-4.4 !.server-5.0"], - display_name, - host=host, - expansions=expansions, - batchtime=batchtime, - tags=[*tags, "pr"], - ) - ) - - # The 3.15t PyOpenSSL tests only run on Ubuntu 22, whose OpenSSL 3.0.2 is - # needed to build the cryptography package; only MongoDB 6.0+ runs there. - expansions = get_encryption_expansions("Encryption PyOpenSSL") - display_name = get_variant_name("Encryption PyOpenSSL", host, **expansions) - variants.append( - create_variant( - [".test-non-standard .python-3.15t !.server-4.4 !.server-5.0"], - display_name, - host=host, - expansions=expansions, - batchtime=batchtime, - tags=[*tags, "pr"], - ) - ) - return variants - - -def create_load_balancer_variants(): - tasks = [ - f".test-non-standard .server-{v} .sharded_cluster-auth-ssl" - for v in get_versions_from("6.0") - ] - expansions = dict(TEST_NAME="load_balancer") - return [ - create_variant( - tasks, - "Load Balancer", - host=DEFAULT_HOST, - batchtime=BATCHTIME_DAY, - expansions=expansions, - ) - ] - - -def create_compression_variants(): - # Compression tests - use the standard linux tests. - host = DEFAULT_HOST - variants = [] - for compressor in "snappy", "zlib", "zstd": - expansions = dict(COMPRESSOR=compressor) - tasks = [".test-standard"] - display_name = get_variant_name(f"Compression {compressor}", host) - variants.append( - create_variant( - tasks, - display_name, - host=host, - expansions=expansions, - ) - ) - # Add explicit tests with compression.zstd support on linux. - host = HOSTS["ubuntu22"] - expansions = dict(COMPRESSOR="ztsd") - tasks = [ - ".test-standard !.server-4.4 !.server-5.0 .python-3.14", - ".test-standard !.server-4.4 !.server-5.0 .python-3.14t", - ".test-standard !.server-4.4 !.server-5.0 .python-3.15", - ".test-standard !.server-4.4 !.server-5.0 .python-3.15t", - ] - display_name = get_variant_name(f"Compression {compressor}", host) - variants.append( - create_variant( - tasks, - display_name, - host=host, - expansions=expansions, - ) - ) - return variants - - -def create_enterprise_auth_variants(): - variants = [] - for host in ["rhel8", "macos", "win64"]: - expansions = dict(TEST_NAME="enterprise_auth", AUTH="auth") - display_name = get_variant_name("Auth Enterprise", host) - tasks = [".test-standard-auth .auth !.free-threaded"] - # https://jira.mongodb.org/browse/PYTHON-5586 - if host == "macos": - tasks = [".test-standard-auth .auth !.free-threaded"] - if host == "win64": - # https://jira.mongodb.org/browse/PYTHON-5704 - tasks = [".test-standard-auth .auth !.free-threaded"] - variant = create_variant(tasks, display_name, host=host, expansions=expansions) - variants.append(variant) - return variants - - -def create_pyopenssl_variants(): - base_name = "PyOpenSSL" - batchtime = BATCHTIME_DAY - expansions = dict(SUB_TEST_NAME="pyopenssl") - variants = [] - - for host in ["rhel8", "macos", "win64"]: - display_name = get_variant_name(base_name, host) - base_task = ".test-standard !.python-3.15t" - # We only need to run a subset on async. - tasks = [f"{base_task} .sync", f"{base_task} .async .replica_set-noauth-ssl"] - variants.append( - create_variant( - tasks, - display_name, - host=host, - expansions=expansions, - batchtime=batchtime, - ) - ) - - # The 3.15t PyOpenSSL tests only run on Ubuntu 22, whose OpenSSL 3.0.2 is - # needed to build the cryptography package; only MongoDB 6.0+ runs there. - host = HOSTS["ubuntu22"] - tasks = [ - ".test-standard .python-3.15t !.server-4.4 !.server-5.0 .sync", - ".test-standard .python-3.15t !.server-4.4 !.server-5.0 .async .replica_set-noauth-ssl", - ] - variants.append( - create_variant( - tasks, - get_variant_name(base_name, host), - host=host, - expansions=expansions, - batchtime=batchtime, - tags=["pr"], - ) - ) - - return variants - - -def create_storage_engine_variants(): - host = DEFAULT_HOST - engines = ["InMemory"] - variants = [] - for engine in engines: - expansions = dict(STORAGE_ENGINE=engine.lower()) - tasks = [".test-standard .standalone-noauth-nossl"] - display_name = get_variant_name(f"Storage {engine}", host) - variant = create_variant(tasks, display_name, host=host, expansions=expansions) - variants.append(variant) - return variants - - -def create_stable_api_variants(): - host = DEFAULT_HOST - tags = ["versionedApi_tag"] - variants = [] - types = ["require v1", "accept v2"] - - # All python versions across platforms. - for test_type in types: - expansions = dict(AUTH="auth") - # Test against a cluster with requireApiVersion=1. - if test_type == types[0]: - # REQUIRE_API_VERSION is set to make drivers-evergreen-tools - # start a cluster with the requireApiVersion parameter. - expansions["REQUIRE_API_VERSION"] = "1" - # MONGODB_API_VERSION is the apiVersion to use in the test suite. - expansions["MONGODB_API_VERSION"] = "1" - tasks = [ - f".test-standard !.replica_set-noauth-ssl .server-{v}" - for v in get_versions_from("5.0") - ] - else: - # Test against a cluster with acceptApiVersion2 but without - # requireApiVersion, and don't automatically add apiVersion to - # clients created in the test suite. - expansions["ORCHESTRATION_FILE"] = "versioned-api-testing.json" - tasks = [ - f".test-standard .server-{v} .standalone-noauth-nossl" - for v in get_versions_from("5.0") - ] - base_display_name = f"Stable API {test_type}" - display_name = get_variant_name(base_display_name, host, **expansions) - variant = create_variant(tasks, display_name, host=host, tags=tags, expansions=expansions) - variants.append(variant) - - return variants - - -def create_green_framework_variants(): - variants = [] - host = DEFAULT_HOST - for framework in ["gevent"]: - tasks = [".test-standard .sync !.free-threaded"] - expansions = dict(GREEN_FRAMEWORK=framework) - display_name = get_variant_name(f"Green {framework.capitalize()}", host) - variant = create_variant(tasks, display_name, host=host, expansions=expansions) - variants.append(variant) - return variants - - -def create_no_c_ext_variants(): - host = DEFAULT_HOST - tasks = [".test-standard"] - expansions = dict() - handle_c_ext(C_EXTS[0], expansions) - display_name = get_variant_name("No C Ext", host) - return [create_variant(tasks, display_name, host=host, expansions=expansions)] - - -def create_disable_test_commands_variants(): - host = DEFAULT_HOST - expansions = dict(AUTH="auth", SSL="ssl", DISABLE_TEST_COMMANDS="1") - display_name = get_variant_name("Disable test commands", host) - tasks = [".test-standard .server-latest"] - return [create_variant(tasks, display_name, host=host, expansions=expansions)] - - -def create_test_numpy_tasks(): - tasks = [] - for python in MIN_MAX_PYTHON: - tags = ["binary", "vector", f"python-{python}", "test-numpy"] - vars = dict(UV_PYTHON=python) - if python == MIN_MAX_PYTHON[-1]: - tags.append("pr") - vars["COVERAGE"] = "1" - task_name = get_task_name("test-numpy", python=python, **vars) - test_func = FunctionCall(func="test numpy", vars=vars) - tasks.append(EvgTask(name=task_name, tags=tags, commands=[test_func])) - return tasks - - -def create_test_numpy_variants() -> list[BuildVariant]: - variants = [] - base_display_name = "Test Numpy" - - # Test a subset on each of the other platforms. - for host_name in ("rhel8", "macos", "macos-arm64", "win64", "win32"): - tasks = [".test-numpy"] - host = HOSTS[host_name] - tags = ["binary", "vector"] - if host_name == "rhel8": - tags.append("pr") - expansions = dict() - if host_name == "win32": - expansions["IS_WIN32"] = "1" - display_name = get_variant_name(base_display_name, host) - variant = create_variant(tasks, display_name, host=host, tags=tags, expansions=expansions) - variants.append(variant) - - return variants - - -def create_oidc_auth_variants(): - variants = [] - for host_name in ["ubuntu22", "macos", "win64"]: - if host_name == "ubuntu22": - tasks = [".auth_oidc_remote"] - else: - tasks = ["!.auth_oidc_remote .auth_oidc"] - host = HOSTS[host_name] - variants.append( - create_variant( - tasks, - get_variant_name("Auth OIDC", host), - host=host, - batchtime=BATCHTIME_DAY, - ) - ) - # Add a specific local test to run on PRs. - if host_name == "ubuntu22": - tasks = ["!.auth_oidc_remote .auth_oidc"] - variants.append( - create_variant( - tasks, - get_variant_name("Auth OIDC Local", host), - tags=["pr"], - host=host, - batchtime=BATCHTIME_DAY, - expansions=dict(COVERAGE="1"), - ) - ) - return variants - - -def create_search_index_variants(): - host = DEFAULT_HOST - return [ - create_variant( - [".search_index"], - get_variant_name("Search Index Helpers", host), - host=host, - ) - ] - - -def create_mockupdb_variants(): - host = DEFAULT_HOST - expansions = dict(TEST_NAME="mockupdb") - return [ - create_variant( - [".test-no-orchestration"], - get_variant_name("MockupDB", host), - host=host, - tags=["pr"], - expansions=expansions, - ) - ] - - -def create_doctests_variants(): - host = DEFAULT_HOST - expansions = dict(TEST_NAME="doctest") - return [ - create_variant( - [".test-non-standard .standalone-noauth-nossl"], - get_variant_name("Doctests", host), - host=host, - expansions=expansions, - ) - ] - - -def create_fuzz_variants(): - # One variant for both fuzz flows: the regression reproducers run on - # every PR (pr-tagged task), the time-boxed fuzzing runs nightly. The - # host needs CPython, which the rhel8 toolchain provides. - host = HOSTS["rhel8"] - name = get_variant_name("Fuzz", host) - return [ - create_variant( - [".fuzz-regression", ".fuzz-nightly"], - name, - host=host, - batchtime=BATCHTIME_DAY, - tags=["pr"], - ) - ] - - -def create_sanitizer_variants() -> list[BuildVariant]: - # ASan/UBSan checks on every PR (PYTHON-6048). The rhel8 toolchain - # provides the instrumented CPython (utils.SANITIZER_PYTHON), and the - # large distro gives ASan's shadow memory and redzones room for the - # ~6GiB test_encode_size_limit allocation, so no test is skipped. - host = DEFAULT_HOST - return [ - create_variant( - [".sanitizer"], - get_variant_name("Sanitizer", host), - host=host, - run_on="rhel8.10-large", - version=MAX_VERSION, - tags=["pr"], - ) - ] - - -def create_atlas_connect_variants(): - host = DEFAULT_HOST - return [ - create_variant( - [".test-no-orchestration"], - get_variant_name("Atlas connect", host), - tags=["pr"], - host=DEFAULT_HOST, - expansions=dict(TEST_NAME="atlas_connect"), - ) - ] - - -def create_sfp_variants(): - host = DEFAULT_HOST - return [ - create_variant( - [".test-no-orchestration"], - get_variant_name("SFP", host), - tags=["pr"], - host=host, - expansions=dict(TEST_NAME="sfp"), - ) - ] - - -def create_coverage_report_variants(): - return [create_variant(["coverage-report"], "Coverage Report", host=DEFAULT_HOST)] - - -def create_kms_variants(): - tasks = [] - tasks.append(EvgTaskRef(name="test-gcpkms", batchtime=BATCHTIME_DAY)) - tasks.append("test-gcpkms-fail") - tasks.append(EvgTaskRef(name="test-azurekms", batchtime=BATCHTIME_DAY)) - tasks.append("test-azurekms-fail") - return [create_variant(tasks, "KMS", host=HOSTS["debian11"])] - - -def create_import_time_variants(): - return [create_variant(["check-import-time"], "Import Time", host=DEFAULT_HOST)] - - -def create_backport_pr_variants(): - return [create_variant(["backport-pr"], "Backport PR", host=DEFAULT_HOST)] - - -def create_perf_variants(): - host = HOSTS["perf"] - return [create_variant([".perf"], "Performance Benchmarks", host=host, batchtime=BATCHTIME_DAY)] - - -def create_aws_auth_variants(): - variants = [] - - for host_name in ["rhel8", "win64", "macos"]: - expansions = dict() - tasks = [".auth-aws"] - tags = [] - if host_name == "macos": - tasks = [".auth-aws !.auth-aws-web-identity !.auth-aws-ec2"] - tags = ["pr"] - elif host_name == "win64": - tasks = [".auth-aws"] - host = HOSTS[host_name] - variant = create_variant( - tasks, - get_variant_name("Auth AWS", host), - host=host, - tags=tags, - expansions=expansions, - ) - variants.append(variant) - - # The ECS test must be run on Ubuntu 24 to match the Fargate Config. - # Fresh tags and expansions: the loop's macOS values must not leak here. - variant = create_variant( - [".auth-aws-ecs"], - get_variant_name("Auth AWS ECS", HOSTS["ubuntu24"]), - host=HOSTS["ubuntu24"], - tags=[], - expansions=dict(), - ) - variants.append(variant) - return variants - - -def create_min_support_variants(): - host = HOSTS["rhel8"] - name = get_variant_name("Min Support", host=host) - return [create_variant([".test-min-support"], name, host=host)] - - -def create_no_server_variants(): - host = HOSTS["rhel8"] - name = get_variant_name("No server", host=host) - return [create_variant([".test-no-orchestration"], name, host=host, tags=["pr"])] - - -def create_alternative_hosts_variants(): - batchtime = BATCHTIME_DAY - variants = [] - - version = "latest" - for host_name in OTHER_HOSTS: - expansions = dict(VERSION="latest") - handle_c_ext(C_EXTS[0], expansions) - host = HOSTS[host_name] - tags = [] - if "fips" in host_name.lower(): - expansions["REQUIRE_FIPS"] = "1" - # Use explicit Python 3.11 binary on the host since the default python3 is 3.9. - expansions["UV_PYTHON"] = "/usr/bin/python3.11" - if "amazon" in host_name.lower(): - tags.append("pr") - variants.append( - create_variant( - [".test-no-toolchain"], - display_name=get_variant_name("Other hosts", host, version=version), - batchtime=batchtime, - host=host, - tags=tags, - expansions=expansions, - ) - ) - return variants - - -def create_aws_lambda_variants(): - host = HOSTS["rhel8"] - return [create_variant([".aws_lambda"], display_name="FaaS Lambda", host=host)] - - -############## -# Tasks -############## - - -# The server-version pr tasks: the Python boundaries pinned per server version. -SERVER_VERSION_PR_PYTHONS = { - MIN_VERSION: {("standalone", "noauth", "nossl"): MIN_PYTHON}, - MAX_VERSION: { - ("standalone", "noauth", "nossl"): MIN_PYTHON, - ("replica_set", "noauth", "nossl"): MAX_PYTHON, - ("sharded_cluster", "auth", "ssl"): MAX_PYTHON, - }, -} - - -def create_server_version_tasks(): - def make_task(topology, auth, ssl, sync, python, extra_tags=(), **extra_vars): - combo = f"{topology}-{auth}-{ssl}" - tags = ["server-version", f"python-{python}", combo, sync, *extra_tags] - expansions = dict(AUTH=auth, SSL=ssl, TOPOLOGY=topology) - if python == ALL_PYTHONS[0]: - expansions["TEST_MIN_DEPS"] = "1" - expansions.update(extra_vars) - if "t" in python: - tags.append("free-threaded") - name = get_task_name( - "test-server-version", - python=python, - sync=sync, - **expansions, - ) - server_func = FunctionCall(func="run server", vars=expansions) - test_vars = expansions.copy() - test_vars["UV_PYTHON"] = python - test_vars["TEST_NAME"] = f"default_{sync}" - test_func = FunctionCall(func="run tests", vars=test_vars) - return EvgTask(name=name, tags=tags, commands=[server_func, test_func]) - - tasks = [] - task_combos = set() - # All combinations of topology, auth, ssl, and sync should be tested. - for (topology, auth, ssl, sync), rotated in zip_cycle( - list(product(TOPOLOGIES, ["auth", "noauth"], ["ssl", "nossl"], SYNCS)), ALL_PYTHONS - ): - task_combos.add((topology, auth, ssl, sync, rotated)) - - # Every python should be tested with sharded cluster, auth, ssl, with sync and async. - for python, sync in product(ALL_PYTHONS, SYNCS): - task_combos.add(("sharded_cluster", "auth", "ssl", sync, python)) - - # Rotated tasks inherit the variant's VERSION; boundary-Python tasks keep - # COVERAGE without pr so per-commit coverage is not pr-only. - pr_pythons = { - combo: python - for combos in SERVER_VERSION_PR_PYTHONS.values() - for combo, python in combos.items() - } - for topology, auth, ssl, sync, python in sorted(task_combos): - extra_vars = {} - if python == pr_pythons.get((topology, auth, ssl)): - extra_vars["COVERAGE"] = "1" - tasks.append(make_task(topology, auth, ssl, sync, python, **extra_vars)) - - # The pinned pr tasks: the boundary Pythons per server version, stable as CPYTHONS changes. - for version, combos in sorted(SERVER_VERSION_PR_PYTHONS.items()): - for (topology, auth, ssl), python in sorted(combos.items()): - for sync in SYNCS: - tasks.append( - make_task( - topology, - auth, - ssl, - sync, - python, - extra_tags=("pr", version), - VERSION=version, - COVERAGE="1", - ) - ) - return tasks - - -def create_no_toolchain_tasks(): - tasks = [] - - for topology, sync in zip_cycle(TOPOLOGIES, SYNCS): - auth, ssl = get_standard_auth_ssl(topology) - tags = [ - "test-no-toolchain", - f"{topology}-{auth}-{ssl}", - ] - expansions = dict(AUTH=auth, SSL=ssl, TOPOLOGY=topology) - name = get_task_name("test-no-toolchain", sync=sync, **expansions) - server_func = FunctionCall(func="run server", vars=expansions) - test_vars = expansions.copy() - test_vars["TEST_NAME"] = f"default_{sync}" - test_func = FunctionCall(func="run tests", vars=test_vars) - tasks.append(EvgTask(name=name, tags=tags, commands=[server_func, test_func])) - return tasks - - -def create_test_non_standard_tasks(): - """For variants that set a TEST_NAME.""" - tasks = [] - task_combos = set() - # For each version and topology, rotate through the CPythons. - # Only the sharded_cluster topology runs on PRs to keep patch build size manageable. - for (version, topology), python in zip_cycle(list(product(ALL_VERSIONS, TOPOLOGIES)), CPYTHONS): - task_combos.add((version, topology, python)) - # The pinned PR task: the max Python on MAX_VERSION, sharded cluster. - task_combos.add((MAX_VERSION, "sharded_cluster", MAX_PYTHON)) - for version, topology, python in sorted(task_combos): - pr = version == MAX_VERSION and topology == "sharded_cluster" and python == MAX_PYTHON - auth, ssl = get_standard_auth_ssl(topology) - tags = [ - "test-non-standard", - f"server-{version}", - f"python-{python}", - f"{topology}-{auth}-{ssl}", - auth, - ] - if "t" in python: - tags.append("free-threaded") - if pr: - tags.append("pr") - expansions = dict(AUTH=auth, SSL=ssl, TOPOLOGY=topology, VERSION=version) - if python == ALL_PYTHONS[0]: - expansions["TEST_MIN_DEPS"] = "1" - elif pr or (version == "latest" and topology == "sharded_cluster"): - expansions["COVERAGE"] = "1" - tags.append("cov") - name = get_task_name("test-non-standard", python=python, **expansions) - server_func = FunctionCall(func="run server", vars=expansions) - test_vars = expansions.copy() - test_vars["UV_PYTHON"] = python - test_func = FunctionCall(func="run tests", vars=test_vars) - tasks.append(EvgTask(name=name, tags=tags, commands=[server_func, test_func])) - # For each coverage task, also emit a non-coverage companion so that - # macOS/Win64 encryption variants (which filter out .cov due to timeout - # constraints) still have a "latest" task to activate in patch builds. - if "cov" in tags: - nc_expansions = {k: v for k, v in expansions.items() if k != "COVERAGE"} - # Use a distinct primary tag so companions are not selected by existing - # ".test-non-standard" selectors (e.g. load-balancer, PyOpenSSL variants). - nc_tags = [ - "test-non-standard-no-cov" if t == "test-non-standard" else t - for t in tags - if t not in ("cov", "pr") - ] - nc_name = get_task_name("test-non-standard", python=python, **nc_expansions) - nc_server_func = FunctionCall(func="run server", vars=nc_expansions) - nc_test_vars = nc_expansions.copy() - nc_test_vars["UV_PYTHON"] = python - nc_test_func = FunctionCall(func="run tests", vars=nc_test_vars) - tasks.append( - EvgTask(name=nc_name, tags=nc_tags, commands=[nc_server_func, nc_test_func]) - ) - return tasks - - -def create_test_standard_auth_tasks(): - """We only use auth on sharded clusters""" - tasks = [] - task_combos = set() - # Rotate through the CPython and MongoDB versions - for (version, topology), python in zip_cycle( - list(product(ALL_VERSIONS, ["sharded_cluster"])), CPYTHONS - ): - task_combos.add((version, topology, python)) - # The pinned PR tasks: the min and max Python on MAX_VERSION. - task_combos.add((MAX_VERSION, "sharded_cluster", MIN_PYTHON)) - task_combos.add((MAX_VERSION, "sharded_cluster", MAX_PYTHON)) - for version, topology, python in sorted(task_combos): - pr = version == MAX_VERSION and python in (MIN_PYTHON, MAX_PYTHON) - auth, ssl = get_standard_auth_ssl(topology) - tags = [ - "test-standard-auth", - f"server-{version}", - f"python-{python}", - f"{topology}-{auth}-{ssl}", - auth, - ] - if "t" in python: - tags.append("free-threaded") - if pr: - tags.append("pr") - expansions = dict(AUTH=auth, SSL=ssl, TOPOLOGY=topology, VERSION=version) - if python == ALL_PYTHONS[0]: - expansions["TEST_MIN_DEPS"] = "1" - if pr: - expansions["COVERAGE"] = "1" - name = get_task_name("test-standard-auth", python=python, **expansions) - server_func = FunctionCall(func="run server", vars=expansions) - test_vars = expansions.copy() - test_vars["UV_PYTHON"] = python - test_func = FunctionCall(func="run tests", vars=test_vars) - tasks.append(EvgTask(name=name, tags=tags, commands=[server_func, test_func])) - return tasks - - -def create_standard_tasks(): - """For variants that do not set a TEST_NAME.""" - tasks = [] - task_combos = set() - # For each python and topology and sync/async, rotate through the the versions. - for (python, topology, sync), rotated in zip_cycle( - list(product(CPYTHONS, TOPOLOGIES, SYNCS)), ALL_VERSIONS - ): - # PR tasks pin to the Python boundaries on MAX_VERSION; the rotation - # keeps running every combination on its rotated server version. - pr = ( - (python == MIN_PYTHON and topology == "standalone" and sync == "async") - or (python == MAX_PYTHON and topology == "replica_set" and sync == "async") - or (python == FREE_THREADED_PYTHON and topology == "sharded_cluster" and sync == "sync") - ) - task_combos.add((rotated, topology, python, sync, False)) - if pr: - task_combos.add((MAX_VERSION, topology, python, sync, True)) - - # A pinned combo can collide with a rotated one on MAX_VERSION; keep the pinned (pr) task. - combos = {combo[:4]: combo for combo in sorted(task_combos)} - for version, topology, python, sync, pr in combos.values(): - auth, ssl = get_standard_auth_ssl(topology) - tags = [ - "test-standard", - f"server-{version}", - f"python-{python}", - f"{topology}-{auth}-{ssl}", - sync, - ] - if "t" in python: - tags.append("free-threaded") - if pr: - tags.append("pr") - expansions = dict(AUTH=auth, SSL=ssl, TOPOLOGY=topology, VERSION=version) - if python == ALL_PYTHONS[0]: - expansions["TEST_MIN_DEPS"] = "1" - if pr or (version == "latest" and python != ALL_PYTHONS[0]): - expansions["COVERAGE"] = "1" - name = get_task_name("test-standard", python=python, sync=sync, **expansions) - server_func = FunctionCall(func="run server", vars=expansions) - test_vars = expansions.copy() - test_vars["UV_PYTHON"] = python - test_vars["TEST_NAME"] = f"default_{sync}" - test_func = FunctionCall(func="run tests", vars=test_vars) - tasks.append(EvgTask(name=name, tags=tags, commands=[server_func, test_func])) - return tasks - - -def create_no_orchestration_tasks(): - tasks = [] - for python in MIN_MAX_PYTHON: - tags = [ - "test-no-orchestration", - f"python-{python}", - ] - assume_func = FunctionCall(func="assume ec2 role") - test_vars = dict(UV_PYTHON=python) - if python == ALL_PYTHONS[0]: - test_vars["TEST_MIN_DEPS"] = "1" - name = get_task_name("test-no-orchestration", **test_vars) - test_func = FunctionCall(func="run tests", vars=test_vars) - commands = [assume_func, test_func] - tasks.append(EvgTask(name=name, tags=tags, commands=commands)) - return tasks - - -def create_fuzz_tasks(): - # Deterministic regression test over the committed known-bug reproducers. - tags = ["fuzz", "fuzz-regression", "pr"] - test_vars = dict(TEST_NAME="fuzz", SUB_TEST_NAME="regression", UV_PYTHON="3.13") - test_func = FunctionCall(func="run tests", vars=test_vars) - tasks = [EvgTask(name="fuzz-regression", tags=tags, commands=[test_func])] - - # Time-boxed fuzzing against the generated seed corpus. - tags = ["fuzz", "fuzz-nightly"] - test_vars = dict(TEST_NAME="fuzz", SUB_TEST_NAME="fuzz", UV_PYTHON="3.13") - test_func = FunctionCall(func="run tests", vars=test_vars) - # PYTHON-6178: while the scratch corpus still exists, harvest the new - # coverage-increasing inputs, replay them through every target so a - # unit that fails one is never published, and open an automated PR - # growing fuzz/corpus/. - harvest_cmd = get_subprocess_exec( - args=[".evergreen/scripts/harvest-fuzz-corpus.sh"], - include_expansions_in_env=[ - "is_patch", - "FUZZ_CORPUS_MAX_UNITS", - "FUZZ_CORPUS_MAX_UNIT_BYTES", - # The harvest bootstraps the comment-bot github app, whose - # secrets live in AWS Secrets Manager; pass the assumed-role - # credentials as resync_specs and backport-pr also do. - "AWS_ACCESS_KEY_ID", - "AWS_SECRET_ACCESS_KEY", - "AWS_SESSION_TOKEN", - ], - ) - tasks.append(EvgTask(name="fuzz", tags=tags, commands=[test_func, harvest_cmd])) - return tasks - - -def create_sanitizer_tasks(): - # VERSION comes from the variant: a task-level VERSION would trip the - # pr-tasks-run-coverage rule, and coverage under ASan is not useful. - tags = ["sanitizer", "pr"] - expansions = dict(AUTH="noauth", SSL="nossl", TOPOLOGY="standalone") - server_func = FunctionCall(func="run server", vars=expansions) - test_vars = expansions.copy() - test_vars["TEST_NAME"] = "sanitizer" - test_func = FunctionCall(func="run tests", vars=test_vars) - name = get_task_name("test-sanitizer") - return [EvgTask(name=name, tags=tags, commands=[server_func, test_func])] - - -def create_kms_tasks(): - tasks = [] - for kms_type in ["gcp", "azure"]: - for success in [True, False]: - name = f"test-{kms_type}kms" - sub_test_name = kms_type - tags = [] - if not success: - name += "-fail" - sub_test_name += "-fail" - tags.append("pr") - commands = [] - if not success: - commands.append(FunctionCall(func="run server")) - test_vars = dict(TEST_NAME="kms", SUB_TEST_NAME=sub_test_name) - test_func = FunctionCall(func="run tests", vars=test_vars) - commands.append(test_func) - tasks.append(EvgTask(name=name, tags=tags, commands=commands)) - return tasks - - -def create_aws_tasks(): - tasks = [] - aws_test_types = [ - "regular", - "assume-role", - "ec2", - "env-creds", - "session-creds", - "web-identity", - ] - assume_func = FunctionCall(func="assume ec2 role") - task_combos = set(zip_cycle(get_versions_from("4.4"), aws_test_types, CPYTHONS)) - # The pinned PR tasks: the min and max Python on MAX_VERSION. - task_combos |= { - (MAX_VERSION, "regular", MIN_PYTHON), - (MAX_VERSION, "regular", MAX_PYTHON), - } - for version, test_type, python in sorted(task_combos): - base_name = f"test-auth-aws-{version}" - base_tags = ["auth-aws"] - server_vars = dict(AUTH_AWS="1", VERSION=version) - server_func = FunctionCall(func="run server", vars=server_vars) - tags = [*base_tags, f"auth-aws-{test_type}"] - if "t" in python: - tags.append("free-threaded") - test_vars = dict(TEST_NAME="auth_aws", SUB_TEST_NAME=test_type, UV_PYTHON=python) - # The rotation never produces (MAX_VERSION, regular). - pr = ( - version == MAX_VERSION and test_type == "regular" and python in (MIN_PYTHON, MAX_PYTHON) - ) - if python == MIN_MAX_PYTHON[0]: - test_vars["TEST_MIN_DEPS"] = "1" - if pr: - tags.append("pr") - if pr or python == MIN_MAX_PYTHON[-1]: - test_vars["COVERAGE"] = "1" - name = get_task_name(f"{base_name}-{test_type}", **test_vars) - test_func = FunctionCall(func="run tests", vars=test_vars) - funcs = [server_func, assume_func, test_func] - tasks.append(EvgTask(name=name, tags=tags, commands=funcs)) - - if test_type == "web-identity": - tags = [*base_tags, "auth-aws-web-identity"] - name = get_task_name(f"{base_name}-web-identity-session-name", python=python) - test_vars = dict( - TEST_NAME="auth_aws", - SUB_TEST_NAME="web-identity", - AWS_ROLE_SESSION_NAME="test", - UV_PYTHON=python, - ) - if "t" in python: - tags.append("free-threaded") - test_func = FunctionCall(func="run tests", vars=test_vars) - funcs = [server_func, assume_func, test_func] - tasks.append(EvgTask(name=name, tags=tags, commands=funcs)) - - # Add the ECS task. This will run on Ubuntu 24 to match the - # Fargate environment. - tags = ["auth-aws-ecs"] - test_vars = dict(TEST_NAME="auth_aws", SUB_TEST_NAME="ecs") - name = get_task_name("test-auth-aws-ecs", **test_vars) - test_func = FunctionCall(func="run tests", vars=test_vars) - server_func = FunctionCall(func="run server", vars=dict(VERSION="8.0")) - funcs = [assume_func, server_func, test_func] - tasks.append(EvgTask(name=name, tags=tags, commands=funcs)) - - return tasks - - -def create_oidc_tasks(): - tasks = [] - for sub_test in ["default", "azure", "gcp", "eks", "aks", "gke"]: - vars = dict(TEST_NAME="auth_oidc", SUB_TEST_NAME=sub_test) - tags = ["auth_oidc"] - if sub_test != "default": - tags.append("auth_oidc_remote") - test_func = FunctionCall(func="run tests", vars=vars) - task_name = get_task_name(f"test-auth-oidc-{sub_test}", **vars) - tasks.append(EvgTask(name=task_name, tags=tags, commands=[test_func])) - - return tasks - - -def _create_ocsp_tasks(algo, variant, server_type, base_task_name): - tasks = [] - file_name = f"{algo}-basic-tls-ocsp-{variant}.json" - - for version in get_versions_from("4.4"): - # Rotated nightlies: latest-CPython on "latest", min-deps Python elsewhere. - pr = base_task_name == "valid-cert-server-staples" and algo == "ecdsa" and version == "4.4" - # The "latest" ECDSA staples task keeps nightly coverage; the pinned - # MAX_VERSION task below is the pr task. - nightly_cov = ( - base_task_name == "valid-cert-server-staples" - and algo == "ecdsa" - and version == "latest" - ) - if version == "latest": - python = MIN_MAX_PYTHON[-1] - else: - python = MIN_MAX_PYTHON[0] - - vars = dict( - ORCHESTRATION_FILE=file_name, - OCSP_SERVER_TYPE=server_type, - TEST_NAME="ocsp", - UV_PYTHON=python, - VERSION=version, - ) - if python == ALL_PYTHONS[0]: - vars["TEST_MIN_DEPS"] = "1" - tags = ["ocsp", f"ocsp-{algo}", version] - if "disableStapling" not in variant: - tags.append("ocsp-staple") - if pr or nightly_cov: - vars["COVERAGE"] = "1" - if pr: - tags.append("pr") - test_func = FunctionCall(func="run tests", vars=vars) - task_name = get_task_name(f"test-ocsp-{algo}-{base_task_name}", **vars) - tasks.append(EvgTask(name=task_name, tags=tags, commands=[test_func])) - - # One latest-CPython ECDSA staples task on every PR, pinned to MAX_VERSION - # (the "latest" nightly is unstable): catches cryptography-backend - # regressions at the dependency extremes before merge (PYTHON-6032). - if base_task_name == "valid-cert-server-staples" and algo == "ecdsa": - vars = dict( - ORCHESTRATION_FILE=file_name, - OCSP_SERVER_TYPE=server_type, - TEST_NAME="ocsp", - UV_PYTHON=MIN_MAX_PYTHON[-1], - VERSION=MAX_VERSION, - COVERAGE="1", - ) - tags = ["ocsp", f"ocsp-{algo}", MAX_VERSION, "ocsp-staple", "pr"] - test_func = FunctionCall(func="run tests", vars=vars) - task_name = get_task_name(f"test-ocsp-{algo}-{base_task_name}", **vars) - tasks.append(EvgTask(name=task_name, tags=tags, commands=[test_func])) - - return tasks - - -def create_min_support_tasks(): - server_func = FunctionCall(func="run server") - from generate_config_utils import MIN_SUPPORT_VERSIONS - - tasks = [] - for python, topology in product(MIN_SUPPORT_VERSIONS, TOPOLOGIES): - auth, ssl = get_standard_auth_ssl(topology) - vars = dict(UV_PYTHON=python, AUTH=auth, SSL=ssl, TOPOLOGY=topology) - test_func = FunctionCall(func="run tests", vars=vars) - task_name = get_task_name( - "test-min-support", python=python, topology=topology, auth=auth, ssl=ssl - ) - tags = ["test-min-support"] - commands = [server_func, test_func] - tasks.append(EvgTask(name=task_name, tags=tags, commands=commands)) - return tasks - - -def create_aws_lambda_tasks(): - assume_func = FunctionCall(func="assume ec2 role") - vars = dict(TEST_NAME="aws_lambda") - test_func = FunctionCall(func="run tests", vars=vars) - task_name = "test-aws-lambda-deployed" - tags = ["aws_lambda"] - commands = [assume_func, test_func] - return [EvgTask(name=task_name, tags=tags, commands=commands)] - - -def create_search_index_tasks(): - assume_func = FunctionCall(func="assume ec2 role") - server_func = FunctionCall(func="run server", vars=dict(TEST_NAME="search_index")) - vars = dict(TEST_NAME="search_index", UV_PYTHON=CPYTHONS[0]) - test_func = FunctionCall(func="run tests", vars=vars) - task_name = "test-search-index-helpers" - tags = ["search_index"] - commands = [assume_func, server_func, test_func] - return [EvgTask(name=task_name, tags=tags, commands=commands)] - - -def create_perf_tasks(): - tasks = [] - for version, ssl, sync in product(["8.0"], ["ssl", "nossl"], ["sync", "async"]): - # The toolchain build may be this same patch version but is not - # optimized, which regressed CPU-bound benchmarks (PYTHON-6135). - perf_vars = dict(UV_PYTHON=PERF_PYTHON_VERSION, UV_PYTHON_PREFERENCE="only-managed") - vars = dict(VERSION=f"v{version}-perf", SSL=ssl, **perf_vars) - server_func = FunctionCall(func="run server", vars=vars) - vars = dict(TEST_NAME="perf", SUB_TEST_NAME=sync, **perf_vars) - test_func = FunctionCall(func="run tests", vars=vars) - attach_func = FunctionCall(func="attach benchmark test results") - send_func = FunctionCall(func="send dashboard data") - task_name = f"perf-{version}-standalone" - if ssl == "ssl": - task_name += "-ssl" - if sync == "async": - task_name += "-async" - tags = ["perf"] - commands = [server_func, test_func, attach_func, send_func] - tasks.append(EvgTask(name=task_name, tags=tags, commands=commands)) - return tasks - - -def create_getdata_tasks(): - # Wildcard task. Do you need to find out what tools are available and where? - # Throw it here, and execute this task on all buildvariants - cmd = get_subprocess_exec(args=[".evergreen/scripts/run-getdata.sh"]) - return [EvgTask(name="getdata", commands=[cmd])] - - -def create_coverage_report_tasks(): - tags = ["coverage", "pr"] - task_name = "coverage-report" - # BUILD-3165: We can't use "*" (all tasks) and specify "variant". - # Instead list out all coverage tasks using tags. - # Run the coverage task even if some tasks fail. - # Run the coverage task even if some tasks are not scheduled in a patch build. - task_deps = [ - EvgTaskDependency( - name=".server-version", variant=".coverage_tag", status="*", patch_optional=True - ) - ] - cmd = FunctionCall(func="download and merge coverage") - return [EvgTask(name=task_name, tags=tags, depends_on=task_deps, commands=[cmd])] - - -def create_import_time_tasks(): - name = "check-import-time" - tags = ["pr"] - args = [".evergreen/scripts/check-import-time.sh", "${revision}", "${github_commit}"] - cmd = get_subprocess_exec(args=args) - return [EvgTask(name=name, tags=tags, commands=[cmd])] - - -def create_backport_pr_tasks(): - name = "backport-pr" - args = [ - "${DRIVERS_TOOLS}/.evergreen/github_app/backport-pr.sh", - "mongodb", - "mongo-python-driver", - "${github_commit}", - ] - include_expansions = ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"] - cmd = get_subprocess_exec(args=args, include_expansions_in_env=include_expansions) - assume_func = FunctionCall(func="assume ec2 role") - return [EvgTask(name=name, commands=[assume_func, cmd], allowed_requesters=["commit"])] - - -def create_ocsp_tasks(): - tasks = [] - tests = [ - ("disableStapling", "valid", "valid-cert-server-does-not-staple"), - ("disableStapling", "revoked", "invalid-cert-server-does-not-staple"), - ("disableStapling", "valid-delegate", "delegate-valid-cert-server-does-not-staple"), - ("disableStapling", "revoked-delegate", "delegate-invalid-cert-server-does-not-staple"), - ("disableStapling", "no-responder", "soft-fail"), - ("mustStaple", "valid", "valid-cert-server-staples"), - ("mustStaple", "revoked", "invalid-cert-server-staples"), - ("mustStaple", "valid-delegate", "delegate-valid-cert-server-staples"), - ("mustStaple", "revoked-delegate", "delegate-invalid-cert-server-staples"), - ( - "mustStaple-disableStapling", - "revoked", - "malicious-invalid-cert-mustStaple-server-does-not-staple", - ), - ( - "mustStaple-disableStapling", - "revoked-delegate", - "delegate-malicious-invalid-cert-mustStaple-server-does-not-staple", - ), - ( - "mustStaple-disableStapling", - "no-responder", - "malicious-no-responder-mustStaple-server-does-not-staple", - ), - ] - for algo in ["ecdsa", "rsa"]: - for variant, server_type, base_task_name in tests: - new_tasks = _create_ocsp_tasks(algo, variant, server_type, base_task_name) - tasks.extend(new_tasks) - - return tasks - - -############## -# Functions -############## - - -def create_upload_coverage_func(): - # Upload the coverage report for all tasks in a single build to the same directory. - remote_file = ( - "coverage/${revision}/${version_id}/coverage/coverage.${build_variant}.${task_name}" - ) - display_name = "Raw Coverage Report" - cmd = get_s3_put( - local_file="src/.coverage", - remote_file=remote_file, - display_name=display_name, - content_type="text/html", - ) - return "upload coverage", [get_assume_role(), cmd] - - -def create_upload_coverage_codecov_func(): - # Upload the coverage xml report to codecov. - include_expansions = [ - "CODECOV_TOKEN", - "build_variant", - "task_name", - "github_commit", - "github_pr_number", - "github_pr_head_branch", - "github_author", - "requester", - "branch_name", - ] - args = [ - ".evergreen/scripts/upload-codecov.sh", - ] - upload_cmd = get_subprocess_exec(include_expansions_in_env=include_expansions, args=args) - return "upload codecov", [upload_cmd] - - -def create_download_and_merge_coverage_func(): - include_expansions = ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"] - args = [ - ".evergreen/scripts/download-and-merge-coverage.sh", - "${bucket_name}", - "${revision}", - "${version_id}", - ] - merge_cmd = get_subprocess_exec( - silent=True, include_expansions_in_env=include_expansions, args=args - ) - combine_cmd = get_subprocess_exec(args=[".evergreen/combine-coverage.sh"]) - # Upload the resulting html coverage report. - args = [ - ".evergreen/scripts/upload-coverage-report.sh", - "${bucket_name}", - "${revision}", - "${version_id}", - ] - upload_cmd = get_subprocess_exec( - silent=True, include_expansions_in_env=include_expansions, args=args - ) - display_name = "Coverage Report HTML" - remote_file = "coverage/${revision}/${version_id}/htmlcov/index.html" - put_cmd = get_s3_put( - local_file="src/htmlcov/index.html", - remote_file=remote_file, - display_name=display_name, - content_type="text/html", - ) - cmds = [get_assume_role(), merge_cmd, combine_cmd, upload_cmd, put_cmd] - return "download and merge coverage", cmds - - -def create_upload_mo_artifacts_func(): - include = ["./**.core", "./**.mdmp"] # Windows: minidumps - archive_cmd = archive_targz_pack(target="mongo-coredumps.tgz", source_dir="./", include=include) - display_name = "Core Dumps - Execution" - remote_file = "${build_variant}/${revision}/${version_id}/${build_id}/coredumps/${task_id}-${execution}-mongodb-coredumps.tar.gz" - s3_dumps = get_s3_put( - local_file="mongo-coredumps.tgz", remote_file=remote_file, display_name=display_name - ) - display_name = "drivers-tools-logs.tar.gz" - remote_file = "${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-drivers-tools-logs.tar.gz" - s3_logs = get_s3_put( - local_file="${DRIVERS_TOOLS}/.evergreen/test_logs.tar.gz", - remote_file=remote_file, - display_name=display_name, - ) - cmds = [get_assume_role(), archive_cmd, s3_dumps, s3_logs] - return "upload mo artifacts", cmds - - -def create_fetch_source_func(): - # Executes clone and applies the submitted patch, if any. - cmd = git_get_project(directory="src") - return "fetch source", [cmd] - - -def create_setup_system_func(): - # Make an evergreen expansion file with dynamic values. - includes = ["is_patch", "project", "version_id"] - args = [".evergreen/scripts/setup-system.sh"] - setup_cmd = get_subprocess_exec(include_expansions_in_env=includes, args=args) - # Load the expansion file to make an evergreen variable with the current unique version. - expansion_cmd = expansions_update(file="src/expansion.yml") - return "setup system", [setup_cmd, expansion_cmd] - - -def create_upload_test_results_func(): - results_cmd = attach_results(file_location="${DRIVERS_TOOLS}/results.json") - xresults_cmd = attach_xunit_results(file="src/xunit-results/TEST-*.xml") - return "upload test results", [results_cmd, xresults_cmd] - - -def create_run_server_func(): - includes = [ - "VERSION", - "TOPOLOGY", - "AUTH", - "SSL", - "ORCHESTRATION_FILE", - "UV_PYTHON", - "UV_PYTHON_PREFERENCE", - "STORAGE_ENGINE", - "REQUIRE_API_VERSION", - "DRIVERS_TOOLS", - "TEST_CRYPT_SHARED", - "AUTH_AWS", - "LOAD_BALANCER", - "LOCAL_ATLAS", - "NO_EXT", - # The AWS credentials are needed to download the "latest" nightly - # build from the private S3 bucket, see DRIVERS-3628. - "AWS_ACCESS_KEY_ID", - "AWS_SECRET_ACCESS_KEY", - "AWS_SESSION_TOKEN", - ] - args = [".evergreen/just.sh", "run-server", "${TEST_NAME}"] - sub_cmd = get_subprocess_exec(include_expansions_in_env=includes, args=args) - expansion_cmd = expansions_update(file="${DRIVERS_TOOLS}/mo-expansion.yml") - return "run server", [sub_cmd, expansion_cmd] - - -def create_run_tests_func(): - includes = [ - "AUTH", - "SSL", - "AWS_ACCESS_KEY_ID", - "AWS_SECRET_ACCESS_KEY", - "AWS_SESSION_TOKEN", - "COVERAGE", - "UV_PYTHON", - "UV_PYTHON_PREFERENCE", - "LIBMONGOCRYPT_URL", - "MONGODB_URI", - "DISABLE_TEST_COMMANDS", - "GREEN_FRAMEWORK", - "NO_EXT", - "COMPRESSORS", - "MONGODB_API_VERSION", - "REQUIRE_API_VERSION", - "DEBUG_LOG", - "DISABLE_FLAKY", - "ORCHESTRATION_FILE", - "OCSP_SERVER_TYPE", - "VERSION", - "IS_WIN32", - "REQUIRE_FIPS", - "TEST_MIN_DEPS", - "FUZZ_MAX_TIME", - ] - args = [".evergreen/just.sh", "setup-tests", "${TEST_NAME}", "${SUB_TEST_NAME}"] - setup_cmd = get_subprocess_exec(include_expansions_in_env=includes, args=args) - test_cmd = get_subprocess_exec(args=[".evergreen/just.sh", "run-tests"]) - return "run tests", [setup_cmd, test_cmd] - - -def create_test_numpy_func(): - includes = ["UV_PYTHON", "COVERAGE"] - test_cmd = get_subprocess_exec( - include_expansions_in_env=includes, args=[".evergreen/just.sh", "test-numpy"] - ) - return "test numpy", [test_cmd] - - -def create_cleanup_func(): - cmd = get_subprocess_exec(args=[".evergreen/scripts/cleanup.sh"]) - return "cleanup", [cmd] - - -def create_teardown_system_func(): - tests_cmd = get_subprocess_exec(args=[".evergreen/just.sh", "teardown-tests"]) - drivers_cmd = get_subprocess_exec(args=["${DRIVERS_TOOLS}/.evergreen/teardown.sh"]) - return "teardown system", [tests_cmd, drivers_cmd] - - -def create_assume_ec2_role_func(): - cmd = ec2_assume_role(role_arn="${aws_test_secrets_role}", duration_seconds=3600) - return "assume ec2 role", [cmd] - - -def create_attach_benchmark_test_results_func(): - cmd = attach_results(file_location="src/report.json") - return "attach benchmark test results", [cmd] - - -def create_send_dashboard_data_func(): - includes = [ - "requester", - "revision_order_id", - "project_id", - "version_id", - "build_variant", - "parsed_order_id", - "task_name", - "task_id", - "execution", - "is_mainline", - ] - cmds = [ - get_subprocess_exec( - include_expansions_in_env=includes, args=[".evergreen/scripts/perf-submission-setup.sh"] - ), - expansions_update(file="src/expansion.yml"), - get_subprocess_exec( - include_expansions_in_env=includes, args=[".evergreen/scripts/perf-submission.sh"] - ), - ] - return "send dashboard data", cmds - - -mod = sys.modules[__name__] -write_variants_to_file(mod) -write_tasks_to_file(mod) -write_functions_to_file(mod) diff --git a/.evergreen/scripts/generate_config_utils.py b/.evergreen/scripts/generate_config_utils.py deleted file mode 100644 index e131bcffe0..0000000000 --- a/.evergreen/scripts/generate_config_utils.py +++ /dev/null @@ -1,357 +0,0 @@ -from __future__ import annotations - -from dataclasses import dataclass -from inspect import getmembers, isfunction -from itertools import cycle, zip_longest -from pathlib import Path -from typing import Any - -from shrub.v3.evg_build_variant import BuildVariant -from shrub.v3.evg_command import ( - EvgCommandType, - ec2_assume_role, - s3_put, - subprocess_exec, -) -from shrub.v3.evg_project import EvgProject -from shrub.v3.evg_task import EvgTaskRef -from shrub.v3.shrub_service import ShrubService - -############## -# Globals -############## - -ALL_VERSIONS = ["4.4", "5.0", "6.0", "7.0", "8.0", "9.0", "rapid", "latest"] -CPYTHONS = ["3.11", "3.12", "3.13", "3.14t", "3.14", "3.15t", "3.15"] -MIN_SUPPORT_VERSIONS = ["3.11"] -ALL_PYTHONS = CPYTHONS -MIN_MAX_PYTHON = [CPYTHONS[0], CPYTHONS[-1]] -# The Python and server version boundaries that PR tasks pin to. -MIN_PYTHON = CPYTHONS[0] -MAX_PYTHON = CPYTHONS[-1] -FREE_THREADED_PYTHON = [p for p in CPYTHONS if "t" in p][-1] -MIN_VERSION = min((v for v in ALL_VERSIONS if v[0].isdigit()), key=float) -MAX_VERSION = max((v for v in ALL_VERSIONS if v[0].isdigit()), key=float) -BATCHTIME_WEEK = 10080 -BATCHTIME_DAY = 1440 -AUTH_SSLS = [("auth", "ssl"), ("noauth", "ssl"), ("noauth", "nossl")] -TOPOLOGIES = ["standalone", "replica_set", "sharded_cluster"] -C_EXTS = ["without_ext", "with_ext"] -SYNCS = ["sync", "async"] -DISPLAY_LOOKUP = dict( - ssl=dict(ssl="SSL", nossl="NoSSL"), - auth=dict(auth="Auth", noauth="NoAuth"), - topology=dict( - standalone="Standalone", replica_set="Replica Set", sharded_cluster="Sharded Cluster" - ), - test_suites=dict(default="Sync", default_async="Async"), - sync={"sync": "Sync", "async": "Async"}, - coverage={"1": "cov"}, - no_ext={"1": "No C"}, - test_min_deps={"1": "Min Deps"}, -) -HOSTS = dict() - - -@dataclass -class Host: - name: str - run_on: str - display_name: str - variables: dict[str, str] | None - - -# Hosts with toolchains. -HOSTS["rhel8"] = Host("rhel8", "rhel8.10-small", "RHEL8", dict()) -HOSTS["win64"] = Host("win64", "windows-64-vsMulti-small", "Win64", dict()) -HOSTS["win-latest"] = Host("win-latest", "windows-2022-latest-small", "WinLatest", dict()) -HOSTS["win32"] = Host("win32", "windows-64-vsMulti-small", "Win32", dict()) -HOSTS["macos"] = Host("macos", "macos-14", "macOS", dict()) -HOSTS["macos-arm64"] = Host("macos-arm64", "macos-14-arm64", "macOS Arm64", dict()) -HOSTS["ubuntu22"] = Host("ubuntu22", "ubuntu2204-small", "Ubuntu-22", dict()) -HOSTS["ubuntu24"] = Host("ubuntu24", "ubuntu2404-small", "Ubuntu-24", dict()) -HOSTS["perf"] = Host("perf", "rhel90-dbx-perf-large", "", dict()) -HOSTS["debian11"] = Host("debian11", "debian11-small", "Debian11", dict()) -DEFAULT_HOST = HOSTS["rhel8"] - -# Other hosts -OTHER_HOSTS = ["RHEL9-FIPS", "RHEL8-zseries", "RHEL8-POWER8", "RHEL8-arm64", "Amazon2023"] -for name, run_on in zip( - OTHER_HOSTS, - [ - "rhel92-fips", - "rhel8-zseries-small", - "rhel8-power-small", - "rhel82-arm64-small", - "amazon2023-arm64-latest-large-m8g", - ], - strict=True, -): - HOSTS[name] = Host(name, run_on, name, dict()) - -############## -# Helpers -############## - - -def create_variant_generic( - tasks: list[str | EvgTaskRef], - display_name: str, - *, - host: Host | str | None = None, - default_run_on="rhel8.10-small", - expansions: dict | None = None, - **kwargs: Any, -) -> BuildVariant: - """Create a build variant for the given inputs.""" - task_refs = [] - if isinstance(host, str): - host = HOSTS[host] - for t in tasks: - if isinstance(t, EvgTaskRef): - task_refs.append(t) - else: - task_refs.append(EvgTaskRef(name=t)) - expansions = (expansions and expansions.copy()) or dict() - if "run_on" in kwargs: - run_on = kwargs.pop("run_on") - elif host: - run_on = [host.run_on] - if host.variables: - expansions.update(host.variables) - else: - run_on = [default_run_on] - if isinstance(run_on, str): - run_on = [run_on] - name = display_name.replace(" ", "-").replace("*-", "").lower() - return BuildVariant( - name=name, - display_name=display_name, - tasks=task_refs, - expansions=expansions or None, - run_on=run_on, - **kwargs, - ) - - -def create_variant( - tasks: list[str | EvgTaskRef], - display_name: str, - *, - version: str | None = None, - host: Host | str | None = None, - expansions: dict | None = None, - **kwargs: Any, -) -> BuildVariant: - expansions = (expansions and expansions.copy()) or dict() - if version: - expansions["VERSION"] = version - # 8.0+ Windows builds must run on win-latest - if "win64" in display_name.lower() or ( - "win32" in display_name.lower() and version and version >= "8.0" - ): - kwargs["run_on"] = HOSTS["win-latest"].run_on - return create_variant_generic( - tasks, display_name, version=version, host=host, expansions=expansions, **kwargs - ) - - -def get_versions_from(min_version: str) -> list[str]: - """Get all server versions starting from a minimum version.""" - min_version_float = float(min_version) - rapid_latest = ["rapid", "latest"] - versions = [v for v in ALL_VERSIONS if v not in rapid_latest] - return [v for v in versions if float(v) >= min_version_float] + rapid_latest - - -def get_versions_until(max_version: str) -> list[str]: - """Get all server version up to a max version.""" - max_version_float = float(max_version) - versions = [v for v in ALL_VERSIONS if v not in ["rapid", "latest"]] - versions = [v for v in versions if float(v) <= max_version_float] - if not versions: - raise ValueError(f"No server versions found less <= {max_version}") - return versions - - -def get_common_name(base: str, sep: str, **kwargs) -> str: - display_name = base - version = kwargs.pop("VERSION", None) - version = version or kwargs.pop("version", None) - if version: - if version not in ["rapid", "latest"]: - version = f"v{version}" - display_name = f"{display_name}{sep}{version}" - for key, value in kwargs.items(): - name = value - if key.lower() in ["python", "uv_python"]: - name = f"Python{value}" - elif key.lower() in DISPLAY_LOOKUP and value in DISPLAY_LOOKUP[key.lower()]: - name = DISPLAY_LOOKUP[key.lower()][value] - else: - continue - display_name = f"{display_name}{sep}{name}" - return display_name - - -def get_variant_name(base: str, host: str | Host | None = None, **kwargs) -> str: - """Get the display name of a variant.""" - display_name = base - if isinstance(host, str): - host = HOSTS[host] - if host is not None: - display_name += f" {host.display_name}" - return get_common_name(display_name, " ", **kwargs) - - -def get_task_name(base: str, **kwargs): - return get_common_name(base, "-", **kwargs).replace(" ", "-").lower() - - -def zip_cycle(*iterables, empty_default=None): - """Get all combinations of the inputs, cycling over the shorter list(s).""" - cycles = [cycle(i) for i in iterables] - for _ in zip_longest(*iterables): - yield tuple(next(i, empty_default) for i in cycles) - - -def handle_c_ext(c_ext, expansions) -> None: - """Handle c extension option.""" - if c_ext == C_EXTS[0]: - expansions["NO_EXT"] = "1" - - -def get_standard_auth_ssl(topology): - auth = "auth" if topology == "sharded_cluster" else "noauth" - ssl = "nossl" if topology == "standalone" else "ssl" - return auth, ssl - - -def get_assume_role(**kwargs): - kwargs.setdefault("command_type", EvgCommandType.SETUP) - kwargs.setdefault("role_arn", "${assume_role_arn}") - return ec2_assume_role(**kwargs) - - -def get_subprocess_exec(**kwargs): - kwargs.setdefault("binary", "bash") - kwargs.setdefault("working_dir", "src") - kwargs.setdefault("command_type", EvgCommandType.TEST) - return subprocess_exec(**kwargs) - - -def get_s3_put(**kwargs): - kwargs["aws_key"] = "${AWS_ACCESS_KEY_ID}" - kwargs["aws_secret"] = "${AWS_SECRET_ACCESS_KEY}" # noqa:S105 - kwargs["aws_session_token"] = "${AWS_SESSION_TOKEN}" # noqa:S105 - kwargs["bucket"] = "${bucket_name}" - kwargs.setdefault("optional", "true") - kwargs.setdefault("permissions", "public-read") - kwargs.setdefault("content_type", "${content_type|application/x-gzip}") - kwargs.setdefault("command_type", EvgCommandType.SETUP) - return s3_put(**kwargs) - - -def generate_yaml(tasks=None, variants=None): - """Generate the yaml for a given set of tasks and variants.""" - project = EvgProject(tasks=tasks, buildvariants=variants) - out = ShrubService.generate_yaml(project) - # Dedent by two spaces to match what we use in config.yml - lines = [line[2:] for line in out.splitlines()] - print("\n".join(lines)) - - -################## -# Generate Config -################## - - -def write_variants_to_file(mod): - here = Path(__file__).absolute().parent - target = here.parent / "generated_configs" / "variants.yml" - if target.exists(): - target.unlink() - with target.open("w") as fid: - fid.write("buildvariants:\n") - - for name, func in sorted(getmembers(mod, isfunction)): - if not name.endswith("_variants"): - continue - if not name.startswith("create_"): - raise ValueError("Variant creators must start with create_") - title = name.replace("create_", "").replace("_variants", "").replace("_", " ").capitalize() - project = EvgProject(tasks=None, buildvariants=func()) - out = ShrubService.generate_yaml(project).splitlines() - with target.open("a") as fid: - fid.write(f" # {title} tests\n") - for line in out[1:]: - fid.write(f"{line}\n") - fid.write("\n") - - # Remove extra trailing newline: - data = target.read_text().splitlines() - with target.open("w") as fid: - for line in data[:-1]: - fid.write(f"{line}\n") - - -def write_tasks_to_file(mod): - here = Path(__file__).absolute().parent - target = here.parent / "generated_configs" / "tasks.yml" - if target.exists(): - target.unlink() - with target.open("w") as fid: - fid.write("tasks:\n") - - for name, func in sorted(getmembers(mod, isfunction)): - if name.startswith("_") or not name.endswith("_tasks"): - continue - if not name.startswith("create_"): - raise ValueError("Task creators must start with create_") - title = name.replace("create_", "").replace("_tasks", "").replace("_", " ").capitalize() - project = EvgProject(tasks=func(), buildvariants=None) - out = ShrubService.generate_yaml(project).splitlines() - with target.open("a") as fid: - fid.write(f" # {title} tests\n") - for line in out[1:]: - fid.write(f"{line}\n") - fid.write("\n") - - # Remove extra trailing newline: - data = target.read_text().splitlines() - with target.open("w") as fid: - for line in data[:-1]: - fid.write(f"{line}\n") - - -def write_functions_to_file(mod): - here = Path(__file__).absolute().parent - target = here.parent / "generated_configs" / "functions.yml" - if target.exists(): - target.unlink() - with target.open("w") as fid: - fid.write("functions:\n") - - functions = dict() - for name, func in sorted(getmembers(mod, isfunction)): - if name.startswith("_") or not name.endswith("_func"): - continue - if not name.startswith("create_"): - raise ValueError("Function creators must start with create_") - title = name.replace("create_", "").replace("_func", "").replace("_", " ").capitalize() - func_name, cmds = func() - functions = dict() - functions[func_name] = cmds - project = EvgProject(functions=functions, tasks=None, buildvariants=None) - out = ShrubService.generate_yaml(project).splitlines() - with target.open("a") as fid: - fid.write(f" # {title}\n") - for line in out[1:]: - fid.write(f"{line}\n") - fid.write("\n") - - # Remove extra trailing newline: - data = target.read_text().splitlines() - with target.open("w") as fid: - for line in data[:-1]: - fid.write(f"{line}\n") diff --git a/.evergreen/scripts/github-pr-util.sh b/.evergreen/scripts/github-pr-util.sh deleted file mode 100755 index e2b2d87de4..0000000000 --- a/.evergreen/scripts/github-pr-util.sh +++ /dev/null @@ -1,167 +0,0 @@ -#!/usr/bin/env bash -# Shared plumbing for the automated PR workflows (spec resync and fuzz -# corpus growth): github-app authentication, branch preparation, force -# pushing with retries, and create-or-update against the GitHub API. -# -# Source this file from a wrapper script run from the repository root -# (where the drivers-evergreen-tools submodule lives); it is not meant to -# be executed directly. Defines OWNER, REPO and the functions below; -# requires curl, jq and git. - -OWNER="mongodb" -REPO="mongo-python-driver" - -# Authenticate with the github app in drivers-evergreen-tools and set -# GITHUB_TOKEN. Exits the caller if no token can be obtained. -acquire_github_token() { - # Default to the drivers-evergreen-tools submodule when unset; a - # caller-provided DRIVERS_TOOLS wins, as in the other consumers. - local tools - tools="$(realpath -s "${DRIVERS_TOOLS:-./drivers-evergreen-tools}")" - pushd "$tools/.evergreen/github_app" || exit - - # Bootstrap the app. - echo "bootstrapping" - # shellcheck disable=SC1091 - source utils.sh - bootstrap drivers/comment-bot - - # Run the app. - # shellcheck disable=SC1091 - source ./secrets-export.sh - - # Get a github access token for the git checkout. - echo "Getting github token..." - - GITHUB_TOKEN=$(bash ./get-access-token.sh "$REPO" "$OWNER") - if [ -z "${GITHUB_TOKEN}" ]; then - echo "Failed to get github access token!" - popd || exit - exit 1 - fi - echo "Getting github token... done." - popd || exit -} - -# Prepare the git checkout: point origin at the repo with token auth, -# check out fresh from origin/main (-B resets a reused checkout, -# keeping reruns idempotent), and attribute commits to the drivers PR bot -# when its GitHub id is resolvable. -prepare_bot_branch() { - local branch="$1" - - git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${OWNER}/${REPO}.git" - git checkout -B "$branch" "origin/main" - - local bot_login="mongodb-drivers-pr-bot[bot]" bot_id - bot_id=$(curl -gsm 10 "https://api.github.com/users/${bot_login}" | jq -r '.id // empty' || true) - if [ -n "$bot_id" ]; then - git config user.name "$bot_login" - git config user.email "${bot_id}+${bot_login}@users.noreply.github.com" - fi -} - -# Stage the given paths and commit them. Arguments: the commit message, -# then the paths to stage. Returns 1 when the tree was already clean, so -# the caller can skip PR creation. Git failures exit the caller: errexit -# is suspended while this function runs in an "if" condition, so every -# fallible command is guarded explicitly. -stage_and_commit() { - local message="$1" - shift - - git add "$@" || exit - if git diff --cached --quiet && git diff --quiet --ignore-submodules=dirty; then - return 1 - fi - git commit -m "$message" || exit -} - -# Push to origin. Force-pushing makes same-day reruns of a -# date-stamped branch idempotent; the retries absorb GitHub's -# intermittent 403s on the receive-pack endpoint. Exits the caller after -# 3 failed attempts. -push_branch() { - local branch="$1" - - local push_ok=false - local attempt - for attempt in 1 2 3; do - if git push --force origin "$branch"; then - push_ok=true - break - fi - if [ "$attempt" -lt 3 ]; then - echo "Push attempt ${attempt} failed; retrying in 30s..." - sleep 30 - fi - done - if [ "$push_ok" != true ]; then - echo "Failed to push $branch after 3 attempts!" - exit 1 - fi -} - -# Create a PR from , or, when an open PR is already attached to -# that branch (a same-day rerun), update its title and body instead. -# Arguments: the branch name, the PR title, and the path to a file with -# the PR body. Echoes the PR url and exits the caller if GitHub rejects -# the request. -create_or_update_pr() { - local branch="$1" title="$2" summary_file="$3" - - # Build the payload as a file so the body content is always properly - # JSON-escaped, rather than interpolated into the command line as text. - # Not local: the EXIT trap below must still see it after this function - # returns. - payload_file=$(mktemp) - trap 'rm -f "$payload_file"' EXIT - jq -n \ - --arg title "$title" \ - --arg head "${branch}" \ - --rawfile body "$summary_file" \ - '{title: $title, body: $body, head: $head, base: "main"}' > "$payload_file" - - # Reuse an open PR for this branch (same-day rerun) instead of duplicating it. - local existing_pr_json existing_pr_url existing_pr_number - existing_pr_json=$(curl -gs \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - --url "https://api.github.com/repos/$OWNER/$REPO/pulls?head=$OWNER:$branch&state=open") - existing_pr_url=$(echo "$existing_pr_json" | jq -r '.[0].html_url // empty') - if [ -n "$existing_pr_url" ]; then - existing_pr_number=$(echo "$existing_pr_json" | jq -r '.[0].number // empty') - if ! curl -sfX PATCH \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -d "$(jq -n --arg title "$title" --rawfile body "$summary_file" '{title: $title, body: $body}')" \ - --url "https://api.github.com/repos/$OWNER/$REPO/pulls/${existing_pr_number}" > /dev/null - then - echo "Failed to update PR summary!" - exit 1 - fi - echo "$existing_pr_url" - echo "Creating the PR... done. (PR already existed; branch and summary were updated)" - return 0 - fi - - local resp pr_url - resp=$(curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -d "@${payload_file}" \ - --url "https://api.github.com/repos/$OWNER/$REPO/pulls") - - pr_url=$(echo "$resp" | jq -r '.html_url // empty') - if [ -z "$pr_url" ]; then - echo "Failed to create PR! API response:" - echo "$resp" | jq . - exit 1 - fi - echo "$pr_url" - echo "Creating the PR... done." -} diff --git a/.evergreen/scripts/harvest-fuzz-corpus.sh b/.evergreen/scripts/harvest-fuzz-corpus.sh deleted file mode 100755 index b7220cb3fe..0000000000 --- a/.evergreen/scripts/harvest-fuzz-corpus.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# PYTHON-6178: harvest coverage-increasing inputs from the nightly fuzz -# run and open an automated PR growing fuzz/corpus/. Runs as the last -# command of the Evergreen nightly "fuzz" task, after the targets have -# finished and while the scratch corpus still exists. -set -eu - -# Never open corpus PRs from patch builds; the nightly variant only. -if [ "${is_patch:-}" = "true" ]; then - echo "Patch build; skipping fuzz corpus harvest." - exit 0 -fi - -# Same environment as just.sh: venv on PATH for a modern Python. -. "$(dirname "${BASH_SOURCE:-$0}")/setup-dev-env.sh" - -# Harvest the new units. No new units means a quiet night: no commit, no -# PR (and the GitHub secrets flow is never touched). -uv run --no-sync python fuzz/harvest_corpus.py -if [ -z "$(ls -A fuzz-scratch/harvest 2>/dev/null || true)" ]; then - echo "No new fuzz corpus units; nothing to do." - exit 0 -fi - -# Replay the harvested units through every target before publishing. -# The targets ran sequentially over one shared corpus, so a unit found -# by a later target never ran through the earlier ones, and publishing -# it could break the regression run of every later PR. Each input runs -# exactly once, as in the regression sub-test; a replay failure leaves -# the unit in fuzz-scratch/ for triage and fails the task instead of -# opening a PR. -replay=(fuzz-scratch/harvest/*) -for target in fuzz_decode fuzz_decode_all fuzz_is_valid; do - echo "Replaying harvested units against ${target}..." - if ! uv run --no-sync python "fuzz/${target}.py" "${replay[@]}" \ - -artifact_prefix="$PWD/fuzz-scratch/" -atheris_runs="${#replay[@]}" - then - echo "Harvested unit fails ${target}; no corpus PR." >&2 - exit 1 - fi -done - -bash .evergreen/scripts/create-fuzz-corpus-pr.sh \ - fuzz-scratch/harvest fuzz-scratch/harvest-summary.md diff --git a/.evergreen/scripts/install-dependencies.sh b/.evergreen/scripts/install-dependencies.sh deleted file mode 100755 index 5c69b8875e..0000000000 --- a/.evergreen/scripts/install-dependencies.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash -# Install the necessary dependencies. -set -euo pipefail - -# The uv tool installs below (pinning uv, rust-just) just need a working -# interpreter, so drop the task's Python selection: it may not exist on this -# host (e.g. 3.15 with a 3.14 toolchain), and uv would fail on a too-old -# interpreter found in the search path (e.g. /usr/bin/python3 on RHEL) rather -# than skip it. Later steps re-source env.sh, restoring the selection. -unset UV_PYTHON UV_PYTHON_SEARCH_PATH UV_PYTHON_PREFERENCE - -HERE=$(dirname ${BASH_SOURCE:-$0}) -HERE="$( cd -- "$HERE" > /dev/null 2>&1 && pwd )" -pushd "$(dirname "$(dirname $HERE)")" > /dev/null - -# Source the env files to pick up common variables. -if [ -f $HERE/env.sh ]; then - . $HERE/env.sh -fi - -# PYMONGO_BIN_DIR is set by setup-system.sh/env.sh (or setup-dev-env.sh); default -# it for robustness. Native (Windows) form on cygwin, for consumers like uv; -# PYMONGO_BIN_DIR_POSIX is the cygwin form for bash PATH contexts. -export PYMONGO_BIN_DIR="${PYMONGO_BIN_DIR:-$HOME/.local/bin}" -if [ "Windows_NT" = "${OS:-}" ]; then - _bin_dir="$(cygpath -m "$PYMONGO_BIN_DIR")" - export PYMONGO_BIN_DIR="$_bin_dir" - _posix_bin_dir="$(cygpath -u "$_bin_dir")" - export PYMONGO_BIN_DIR_POSIX="$_posix_bin_dir" -else - export PYMONGO_BIN_DIR_POSIX="$PYMONGO_BIN_DIR" -fi -# UV_TOOL_BIN_DIR is uv's name for the same dir (setup_uv.py reads both). -# UV_TOOL_DIR is left to ensure_uv.sh. -export UV_TOOL_BIN_DIR="${UV_TOOL_BIN_DIR:-$PYMONGO_BIN_DIR}" - -# Ensure the bin dir is on PATH: hosts without env.sh (e.g. auth-aws-ecs) never -# export it, so a fresh pinned install there would be invisible to the probe -# below and to later steps like `uv tool install` and `uv sync`. -case ":$PATH:" in - *":$PYMONGO_BIN_DIR_POSIX:"*) ;; - *) export PATH="$PYMONGO_BIN_DIR_POSIX:$PATH" ;; -esac - -# Compute the setup script path once (native Windows path on cygwin). -_uv_setup_script="$HERE/setup_uv.py" -if [ "Windows_NT" = "${OS:-}" ]; then - _uv_setup_script="$(cygpath -m "$_uv_setup_script")" -fi - -# Skip setup when the pinned uv is already installed: `setup_uv.py --check` -# compares the uv on PATH with the required-version pin, without side effects. -# A full `uv sync` here would download Python and install/build dependencies -# just to make this decision, and would run before setup-uv-python.sh sets -# UV_PYTHON, creating the environment twice on local dev. -# -# On CI we also require UV_CACHE_DIR to be set: ensure_uv.sh scopes uv's cache -# to a task-local dir, so an unset UV_CACHE_DIR means the uv setup has not run -# yet in this task and we must do the setup phase. -_need_setup=1 -if [ "${CI:-}" != "true" ] || [ -n "${UV_CACHE_DIR:-}" ]; then - if python3 "$_uv_setup_script" --check >/dev/null 2>&1; then - echo "uv is already set up; skipping uv setup." - _need_setup=0 - fi -fi - -# Set up uv if needed. -if [ "$_need_setup" = "1" ]; then - # Default DRIVERS_TOOLS to the submodule; an env var override wins. - : "${DRIVERS_TOOLS:=$(dirname "$(dirname "$HERE")")/drivers-evergreen-tools}" - if [ -f "$DRIVERS_TOOLS/.evergreen/ensure-uv.sh" ]; then - . "$DRIVERS_TOOLS/.evergreen/ensure-uv.sh" - ensure_uv || exit 1 - fi - - # Do the uv setup (bin dir, pinning, env.sh). Uses the toolchain python3 - # (added to PATH by configure-env.sh) so no project .venv is created here, - # and no required-version check is triggered. - python3 "$_uv_setup_script" - - # Re-source env.sh so the values setup_uv.py wrote are available. - if [ -f $HERE/env.sh ]; then - . $HERE/env.sh - fi -fi - -# Make just available. It has no version constraint, so if it is already on PATH -# there is nothing to do; otherwise install it into the bin dir via uv. -if ! command -v just >/dev/null 2>&1; then - uv tool install --no-config rust-just -fi - -popd > /dev/null diff --git a/.evergreen/scripts/kms_tester.py b/.evergreen/scripts/kms_tester.py deleted file mode 100644 index 3ea50bbc1b..0000000000 --- a/.evergreen/scripts/kms_tester.py +++ /dev/null @@ -1,141 +0,0 @@ -from __future__ import annotations - -import os - -from utils import ( - DRIVERS_TOOLS, - LOGGER, - TMP_DRIVER_FILE, - create_archive, - read_env, - run_command, - write_env, -) - -DIRS = dict( - gcp=f"{DRIVERS_TOOLS}/.evergreen/csfle/gcpkms", - azure=f"{DRIVERS_TOOLS}/.evergreen/csfle/azurekms", -) - - -def _setup_azure_vm(base_env: dict[str, str]) -> None: - LOGGER.info("Setting up Azure VM...") - azure_dir = DIRS["azure"] - env = base_env.copy() - env["AZUREKMS_SRC"] = TMP_DRIVER_FILE - env["AZUREKMS_DST"] = "~/" - run_command(f"{azure_dir}/copy-file.sh", env=env) - - env = base_env.copy() - env["AZUREKMS_CMD"] = "tar xf mongo-python-driver.tgz" - run_command(f"{azure_dir}/run-command.sh", env=env) - - env["AZUREKMS_CMD"] = "sudo apt-get install -y python3-dev build-essential" - run_command(f"{azure_dir}/run-command.sh", env=env) - - env["AZUREKMS_CMD"] = "CI=true bash .evergreen/just.sh setup-tests kms azure-remote" - run_command(f"{azure_dir}/run-command.sh", env=env) - LOGGER.info("Setting up Azure VM... done.") - - -def _setup_gcp_vm(base_env: dict[str, str]) -> None: - LOGGER.info("Setting up GCP VM...") - gcp_dir = DIRS["gcp"] - env = base_env.copy() - env["GCPKMS_SRC"] = TMP_DRIVER_FILE - env["GCPKMS_DST"] = f"{env['GCPKMS_INSTANCENAME']}:" - run_command(f"{gcp_dir}/copy-file.sh", env=env) - - env = base_env.copy() - env["GCPKMS_CMD"] = "tar xf mongo-python-driver.tgz" - run_command(f"{gcp_dir}/run-command.sh", env=env) - - env["GCPKMS_CMD"] = "sudo apt-get install -y python3-dev build-essential" - run_command(f"{gcp_dir}/run-command.sh", env=env) - - env["GCPKMS_CMD"] = "CI=true bash ./.evergreen/just.sh setup-tests kms gcp-remote" - run_command(f"{gcp_dir}/run-command.sh", env=env) - LOGGER.info("Setting up GCP VM...") - - -def _load_kms_config(sub_test_target: str) -> dict[str, str]: - target_dir = DIRS[sub_test_target] - config = read_env(f"{target_dir}/secrets-export.sh") - base_env = os.environ.copy() - for key, value in config.items(): - base_env[key] = str(value) - return base_env - - -def setup_kms(sub_test_name: str) -> None: - if "-" in sub_test_name: - sub_test_target, sub_test_type = sub_test_name.split("-") - else: - sub_test_target = sub_test_name - sub_test_type = "" - - assert sub_test_target in ["azure", "gcp"], sub_test_target - assert sub_test_type in ["", "remote", "fail"], sub_test_type - success = sub_test_type != "fail" - kms_dir = DIRS[sub_test_target] - - if sub_test_target == "azure": - write_env("TEST_FLE_AZURE_AUTO") - else: - write_env("TEST_FLE_GCP_AUTO") - - write_env("SUCCESS", success) - - # For remote tests, there is no further work required. - if sub_test_type == "remote": - return - - if sub_test_target == "azure": - # Opt in to corporate Azure credentials (DRIVERS-3392) - os.environ["FLE_AZURE_USE_CORPORATE"] = "YES" - run_command("./setup-secrets.sh", cwd=kms_dir) - - if success: - create_archive() - if sub_test_target == "azure": - os.environ["AZUREKMS_VMNAME_PREFIX"] = "PYTHON_DRIVER" - else: - os.environ["GCPKMS_IMAGEFAMILY"] = "debian-12" - - run_command("./setup.sh", cwd=kms_dir) - base_env = _load_kms_config(sub_test_target) - - if sub_test_target == "azure": - _setup_azure_vm(base_env) - else: - _setup_gcp_vm(base_env) - - if sub_test_target == "azure": - config = read_env(f"{kms_dir}/secrets-export.sh") - if success: - write_env("AZUREKMS_VMNAME", config["AZUREKMS_VMNAME"]) - - write_env("KEY_NAME", config["AZUREKMS_KEYNAME"]) - write_env("KEY_VAULT_ENDPOINT", config["AZUREKMS_KEYVAULTENDPOINT"]) - - -def test_kms_send_to_remote(sub_test_name: str) -> None: - env = _load_kms_config(sub_test_name) - if sub_test_name == "azure": - key_name = os.environ["KEY_NAME"] - key_vault_endpoint = os.environ["KEY_VAULT_ENDPOINT"] - env["AZUREKMS_CMD"] = ( - f'KEY_NAME="{key_name}" KEY_VAULT_ENDPOINT="{key_vault_endpoint}" CI=true bash ./.evergreen/just.sh run-tests' - ) - else: - env["GCPKMS_CMD"] = "CI=true ./.evergreen/just.sh run-tests" - cmd = f"{DIRS[sub_test_name]}/run-command.sh" - run_command(cmd, env=env) - - -def teardown_kms(sub_test_name: str) -> None: - run_command(f"{DIRS[sub_test_name]}/teardown.sh") - - -if __name__ == "__main__": - setup_kms() diff --git a/.evergreen/scripts/mod_wsgi.sh b/.evergreen/scripts/mod_wsgi.sh deleted file mode 100755 index 78233a4ff2..0000000000 --- a/.evergreen/scripts/mod_wsgi.sh +++ /dev/null @@ -1,263 +0,0 @@ -#!/bin/bash -# Set up, run, or tear down the mod_wsgi tests. On Linux the test runs against -# the host's Apache; on other hosts it runs in an ubuntu:24.04 container with -# its own MongoDB replica set. -# -# Usage: mod_wsgi.sh setup | test | teardown | active -set -euo pipefail - -SCRIPT_DIR=$(dirname "${BASH_SOURCE:-$0}") -ROOT=$(dirname "$(dirname "$SCRIPT_DIR")") -CMD="${1:-}" -MODE="${2:-}" -CONTAINER=pymongo-mod-wsgi -HOME_SRC=/home/smoke/src -# The venv, MongoDB install, and the recorded version selection live outside -# the source copy, so refreshing the checkout never reinstalls them. -VENV=/home/smoke/venv -VERSIONS=/home/smoke/work/versions - -cd "$ROOT" - -case "$CMD" in - setup) - if [ "$MODE" != "standalone" ] && [ "$MODE" != "embedded" ]; then - echo "Usage: mod_wsgi.sh setup " - exit 1 - fi - # The harness recipes (run-tests, teardown-tests) dispatch on this. - echo "export TEST_NAME=\"mod_wsgi\"" > .evergreen/scripts/test-env.sh - echo "export SUB_TEST_NAME=\"$MODE\"" >> .evergreen/scripts/test-env.sh - # A failed setup leaves a partially started session behind. While the - # marker still routes to this session, tear it down; then remove the - # marker, so later just recipes do not route to the half-set-up state. - # The teardown is what stops the server or container setup may have - # started, and the next setup attempt stops any leftovers as well. - cleanup_marker() { - status=$? - if [ "$status" -ne 0 ]; then - bash "$SCRIPT_DIR/mod_wsgi.sh" teardown || true - rm -f .evergreen/scripts/test-env.sh - fi - } - trap cleanup_marker EXIT - ;; - test|teardown|active) ;; - *) - echo "Usage: mod_wsgi.sh setup | test | teardown | active" - exit 1 - ;; -esac - -if [ "$CMD" = "active" ]; then - # Exit 0 when a mod_wsgi session is active in this environment, so the - # dispatch script can route to us without a stale marker. Uses the system - # python and the tester's own STATE_FILE constant, so a missing or - # mismatched uv cannot break the dispatch and the path cannot drift. - if [ "$(uname -s)" = "Linux" ] && [ -z "${MOD_WSGI_DOCKER:-}" ]; then - if python3 -c " -import sys -sys.path.insert(0, '.evergreen/scripts') -from mod_wsgi_tester import STATE_FILE -sys.exit(0 if STATE_FILE.exists() else 1) -"; then - exit 0 - fi - exit 1 - fi - # The docker branch below handles the container case. -fi - -if [ "$(uname -s)" = "Linux" ] && [ -z "${MOD_WSGI_DOCKER:-}" ]; then - # Native: Apache runs on the host; MongoDB is already running, started by - # "just run-server" or the CI workflow. Set MOD_WSGI_DOCKER to force the - # container path on Linux. - if [ "$CMD" != "teardown" ]; then - # Other recipes' exact uv syncs prune the on-demand mod_wsgi install; - # restore it when missing. Checking first avoids reconciling a caller's - # differently-resolved dependencies. - if ! uv run --no-sync python -c "import mod_wsgi" 2>/dev/null; then - uv pip install -r requirements/mod_wsgi.txt --quiet - fi - fi - if [ "$CMD" = "setup" ]; then - uv run --no-sync python .evergreen/scripts/mod_wsgi_tester.py setup "$MODE" - else - uv run --no-sync python .evergreen/scripts/mod_wsgi_tester.py "$CMD" - fi - # Clear the dispatch marker so later just recipes use the harness. - if [ "$CMD" = "teardown" ]; then - rm -f .evergreen/scripts/test-env.sh - fi - exit 0 -fi - -# Docker path for hosts that cannot run Apache and mongod natively. -container_exists() { docker container inspect "$CONTAINER" >/dev/null 2>&1; } -container_running() { - [ "$(docker container inspect -f '{{.State.Running}}' "$CONTAINER" 2>/dev/null)" = "true" ] -} - -if [ "$CMD" = "active" ]; then - if container_exists; then - exit 0 - fi - exit 1 -fi - -# Copy the checkout into the container's home directory, so root-owned test -# artifacts never pollute it. -sync_source() { - docker exec "$CONTAINER" rm -rf "$HOME_SRC" - docker exec -u smoke "$CONTAINER" mkdir -p "$HOME_SRC" - tar -C "$ROOT" -cf - --exclude=.git --exclude=.venv \ - --exclude=access_log --exclude=error_log . | docker exec -i -u smoke "$CONTAINER" tar -C "$HOME_SRC" -xf - -} - -# Start a single-node replica set, if it is not already running. -ensure_mongod() { - docker exec --user smoke -w "$HOME_SRC" "$CONTAINER" bash -c 'set -euo pipefail - export PATH="$HOME/.local/bin:$PATH" - mkdir -p "$HOME/work/db" - if ! pgrep -x mongod >/dev/null; then - "$HOME/work/bin/mongod" --replSet rs0 --bind_ip 127.0.0.1 --port 27017 --dbpath "$HOME/work/db" --fork --logpath "$HOME/work/mongod.log" - fi - ' -} - -# Create the container and install the environment (idempotent). -bootstrap() { - if ! container_exists; then - docker run --name "$CONTAINER" -d ubuntu:24.04 sleep infinity - # A transient failure during initialization (for example in apt-get) - # would leave the half-created container behind, and later bootstraps - # would skip initialization and fail when sync_source expects the - # missing smoke user. Remove the container on failure, so the next - # attempt initializes a fresh one. - initialize() { - docker exec "$CONTAINER" apt-get update -qq - docker exec "$CONTAINER" apt-get install -y -qq apache2 apache2-dev build-essential curl jq git tar gzip ca-certificates - docker exec "$CONTAINER" useradd -m smoke - } - if ! initialize; then - docker rm -f "$CONTAINER" >/dev/null 2>&1 || true - exit 1 - fi - fi - if ! container_running; then - docker start "$CONTAINER" - fi - # Always refresh the checkout copy, so reused containers test the current - # source. The venv and versions file live outside it and survive the - # refresh. - sync_source - # Re-evaluate the newest Python and MongoDB on every bootstrap, so a reused - # container tracks matrix and server releases, but only reinstall when the - # recorded selection differs, since the downloads are slow. - docker exec --user smoke -w "$HOME_SRC" \ - -e VERSIONS="$VERSIONS" -e VENV="$VENV" "$CONTAINER" bash -c 'set -euo pipefail - export PATH="$HOME/.local/bin:$PATH" - export UV_PYTHON_INSTALL_DIR="$HOME/uv-python" - export UV_PROJECT_ENVIRONMENT="$VENV" - if ! command -v uv >/dev/null; then - curl -LsSf https://astral.sh/uv/install.sh | sh >/dev/null - fi - # Mirror the CI jobs and test the newest supported CPython. - LATEST_PYTHON=$(uv run --no-project --with "shrub.py>=3.10.0" python .evergreen/scripts/mod_wsgi_matrix.py | jq -r ".[-1].\"python-version\"") - case "$(uname -m)" in - aarch64|arm64) MARCH=aarch64 ;; - x86_64|amd64) MARCH=x86_64 ;; - *) echo "Unsupported architecture: $(uname -m)"; exit 1 ;; - esac - # MongoDB builds are per-distro; the container is ubuntu:24.04. - MONGODB_URL=$(curl -fsSL https://downloads.mongodb.org/current.json | jq -r " - .versions[] | select(.current and .production_release) | .downloads[] | - select(.target==\"ubuntu2404\" and .arch==\"$MARCH\") | .archive.url" | grep -v enterprise | head -1) - DESIRED="python=$LATEST_PYTHON mongodb=$MONGODB_URL" - if [ "$(cat "$VERSIONS" 2>/dev/null || true)" != "$DESIRED" ]; then - uv python install "$LATEST_PYTHON" >/dev/null - mkdir -p "$HOME/work/bin" - curl -fsSL "$MONGODB_URL" -o "$HOME/work/mongo.tgz" - MEMBER=$(tar -tzf "$HOME/work/mongo.tgz" | grep "bin/mongod$") - # Strip the two leading path components, so ensure_mongod finds the - # binary at "$HOME/work/bin/mongod". - tar -xz -C "$HOME/work/bin" --strip-components=2 -f "$HOME/work/mongo.tgz" "$MEMBER" - # A new interpreter needs a fresh venv; the sync below repopulates it. - rm -rf "$VENV" - printf "%s\n" "$DESIRED" > "$VERSIONS" - fi - # Rebuild the in-place C extensions on every bootstrap; the source - # refresh may carry artifacts built by a different interpreter. - export PYMONGO_C_EXT_MUST_BUILD=1 - uv sync --refresh-package pymongo - # The sync above prunes mod_wsgi, so install it after. - VIRTUAL_ENV="$VENV" uv pip install -r requirements/mod_wsgi.txt --quiet - ' - ensure_mongod - docker exec --user smoke -w "$HOME_SRC" "$CONTAINER" bash -c 'set -euo pipefail - export PATH="$HOME/.local/bin:$PATH" - export UV_PROJECT_ENVIRONMENT="'"$VENV"'" - # Probe replSetGetStatus over a direct connection: it returns immediately - # for an uninitialized replica set, while the default hello-based server - # selection would block for the full server selection timeout first. - if ! uv run --no-sync python -c " -from pymongo import MongoClient -client = MongoClient(\"127.0.0.1:27017\", directConnection=True) -try: - client.admin.command(\"replSetGetStatus\") -except Exception: - # NotYetInitialized (or a transient failure): initiation is still needed. - raise SystemExit(1) -" 2>/dev/null; then - uv run --no-sync python -c " -from pymongo import MongoClient -client = MongoClient(\"127.0.0.1:27017\", directConnection=True) -client.admin.command(\"replSetInitiate\", {\"_id\": \"rs0\", \"members\": [{\"_id\": 0, \"host\": \"127.0.0.1:27017\"}]}) -" - fi - ' -} - -# Bring a running session to readiness for a test run without refreshing the -# checkout copy: Apache may be live in it, and sync_source would unlink its -# pid file and error log. Only a missing, stopped, or never-bootstrapped -# container needs the full bootstrap, since then nothing is live to disturb. -ensure_ready() { - if container_exists && container_running \ - && docker exec "$CONTAINER" test -e "$VERSIONS"; then - ensure_mongod - else - bootstrap - fi -} - -case "$CMD" in - setup) - bootstrap - docker exec --user smoke -w "$HOME_SRC" "$CONTAINER" bash -c 'set -euo pipefail - export PATH="$HOME/.local/bin:$PATH" - export UV_PYTHON_INSTALL_DIR="$HOME/uv-python" - export UV_PROJECT_ENVIRONMENT="'"$VENV"'" - uv run --no-sync python .evergreen/scripts/mod_wsgi_tester.py setup '"$MODE"' - ' - ;; - test) - ensure_ready - docker exec --user smoke -w "$HOME_SRC" "$CONTAINER" bash -c 'set -euo pipefail - export PATH="$HOME/.local/bin:$PATH" - export UV_PROJECT_ENVIRONMENT="'"$VENV"'" - uv run --no-sync python .evergreen/scripts/mod_wsgi_tester.py test - ' - ;; - teardown) - if container_running; then - docker exec --user smoke -w "$HOME_SRC" "$CONTAINER" bash -c 'set -euo pipefail - export PATH="$HOME/.local/bin:$PATH" - export UV_PROJECT_ENVIRONMENT="'"$VENV"'" - uv run --no-sync python .evergreen/scripts/mod_wsgi_tester.py teardown - ' || true - docker stop -t 1 "$CONTAINER" - fi - rm -f .evergreen/scripts/test-env.sh - ;; -esac diff --git a/.evergreen/scripts/mod_wsgi_matrix.py b/.evergreen/scripts/mod_wsgi_matrix.py deleted file mode 100644 index 2b8bb6611b..0000000000 --- a/.evergreen/scripts/mod_wsgi_matrix.py +++ /dev/null @@ -1,29 +0,0 @@ -from __future__ import annotations - -import json -import sys - -from generate_config_utils import ALL_VERSIONS, CPYTHONS - -# MongoDB 6.0 with the oldest supported CPython and minimum dependencies, and -# the latest MongoDB with the newest supported CPython. MongoDB 6.0 is the -# oldest version that installs on the GitHub runners. -VERSIONS = [ - { - "python-version": CPYTHONS[0], - "mongodb-version": "6.0", - }, - { - "python-version": CPYTHONS[-1], - "mongodb-version": ALL_VERSIONS[-1], - }, -] - -if __name__ == "__main__": - if len(sys.argv) == 3 and sys.argv[1] == "--index": - # Emit one version pair in GITHUB_OUTPUT format. - entry = VERSIONS[int(sys.argv[2])] - print(f"python-version={entry['python-version']}") - print(f"mongodb-version={entry['mongodb-version']}") - else: - print(json.dumps(VERSIONS)) diff --git a/.evergreen/scripts/mod_wsgi_tester.py b/.evergreen/scripts/mod_wsgi_tester.py deleted file mode 100644 index c326f6b476..0000000000 --- a/.evergreen/scripts/mod_wsgi_tester.py +++ /dev/null @@ -1,312 +0,0 @@ -"""Setup, run, and tear down the mod_wsgi tests. - -Usage: - python .evergreen/scripts/mod_wsgi_tester.py setup - python .evergreen/scripts/mod_wsgi_tester.py test - python .evergreen/scripts/mod_wsgi_tester.py teardown - -The commands run as separate workflow steps, so state is passed between them -in a 0600 file in a user-owned cache directory. -""" - -from __future__ import annotations - -import json -import logging -import os -import signal -import socket -import subprocess -import sys -import time -import urllib.request -from pathlib import Path - -logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s") -LOGGER = logging.getLogger("mod_wsgi_tester") - -# Resolve __file__, so ROOT is correct when the script is invoked with a -# relative path, as mod_wsgi.sh does. -ROOT = Path(__file__).resolve().parents[2] -# State lives in a user-owned cache directory rather than shared /tmp: another -# local user must not be able to read or plant it, since teardown feeds its -# values into the commands that stop Apache. -STATE_DIR = Path(os.environ.get("XDG_CACHE_HOME", Path.home() / ".cache")) / "pymongo-mod-wsgi" -STATE_DIR.mkdir(mode=0o700, parents=True, exist_ok=True) -STATE_FILE = STATE_DIR / "state.json" -PORT = 8080 - - -def run_command( - cmd: str | list[str], env: dict[str, str] | None = None, check: bool = True -) -> None: - LOGGER.info(f"Running command: {cmd}") - try: - result = subprocess.run( # noqa: S603 - cmd, - shell=isinstance(cmd, str), - env={**os.environ, **(env or {})}, - cwd=str(ROOT), - capture_output=True, - text=True, - check=False, - ) - except FileNotFoundError: - # A missing binary is a failed command like any other: raised when - # required, logged and swallowed for best-effort calls. The shell - # path used to behave the same way via the exit code, and hosts like - # the Fedora job's container do not ship pkill. - if check: - raise - LOGGER.warning(f"Command not found: {cmd if isinstance(cmd, str) else cmd[0]}") - return - if result.stdout: - LOGGER.info(result.stdout) - if result.returncode != 0: - LOGGER.error(result.stderr) - if check: - raise RuntimeError(f"Command failed with code {result.returncode}: {cmd}") - - -def make_request(url: str, timeout: int = 10) -> None: - for _ in range(timeout): - try: - # Per-request timeout, so an Apache that accepts the connection - # but never answers fails after roughly timeout seconds instead - # of hanging forever. - urllib.request.urlopen(url, timeout=1) # noqa: S310 - return - except OSError: - # URLError (and its HTTPError subclass) plus a socket timeout. - pass - time.sleep(1) - raise TimeoutError(f"Failed to access {url}") - - -def find_mod_wsgi_so() -> str: - # The .so is built against the installing interpreter and lives in the - # installed package. - import mod_wsgi - - so_files = list((Path(mod_wsgi.__file__).parent / "server").glob("mod_wsgi*.so")) - if len(so_files) != 1: - raise ValueError(f"Expected one mod_wsgi.so in {mod_wsgi.__file__}, found {so_files}") - return str(so_files[0]) - - -def find_apache() -> tuple[str, str]: - """Return the Apache binary and the config file matching its distribution.""" - from shutil import which - - apache = which("apache2") - if not apache: - # apache2 lives in sbin, which is not always on PATH for non-root users. - for candidate in ("/usr/lib/apache2/mpm-prefork/apache2", "/usr/sbin/apache2"): - if Path(candidate).exists(): - apache = candidate - break - if apache: - return apache, "apache24ubuntu.conf" - apache = which("httpd") - if not apache: - for candidate in ("/usr/sbin/httpd", "/usr/local/apache2/bin/httpd"): - if Path(candidate).exists(): - apache = candidate - break - if not apache: - raise ValueError("Could not find apache2 or httpd") - return apache, "httpd24fedora.conf" - - -def port_is_open() -> bool: - try: - socket.create_connection(("127.0.0.1", PORT), timeout=1).close() - return True - except OSError: - return False - - -def pid_file(apache_config: str) -> Path: - # The test configs write the master process's pid to the checkout root. - return ROOT / ("httpd.pid" if "httpd" in apache_config else "apache2.pid") - - -def pid_is_our_apache(pid: int, apache_config: str) -> bool: - # A stale pid file may name a pid the OS has reused for an unrelated - # process, so only signal an Apache whose command line carries this - # checkout's config argument. - try: - cmdline = (Path("/proc") / str(pid) / "cmdline").read_bytes() - except OSError: - return False - argv = cmdline.decode("utf-8", "replace").split("\0") - return f"{ROOT}/test/mod_wsgi_test/{apache_config}" in argv - - -def stop_apache(apache: str, apache_config: str, env: dict[str, str] | None = None) -> None: - # Idempotent: safe to call when Apache is not running. - # Prefer the pid file: -k stop re-parses the config, which fails when the - # mod_wsgi .so or the config's env vars are unavailable. Fall back to a - # validated pgrep for a server whose pid file was removed under it. The - # commands run as argument lists, so state-derived values never reach a - # shell. - from shutil import which - - pid = pid_file(apache_config) - if pid.exists(): - try: - victim = int(pid.read_text().strip()) - except ValueError: - victim = 0 - if victim and pid_is_our_apache(victim, apache_config): - try: - os.kill(victim, signal.SIGTERM) - except (ProcessLookupError, PermissionError): - LOGGER.warning("Could not stop Apache via the pid file") - else: - # Stale, reused, or unreadable pid: remove the file and stop - # through the config-validated path instead. - LOGGER.warning(f"Removing stale pid file {pid}") - pid.unlink() - if not pid.exists(): - run_command( - [apache, "-k", "stop", "-f", f"{ROOT}/test/mod_wsgi_test/{apache_config}"], - env=env, - check=False, - ) - if port_is_open(): - # Last resort: find pids whose full command line mentions this - # checkout's absolute config path, then signal only the ones whose - # command line carries it as an exact argument, so a server from - # another checkout (or an unrelated process) is never killed. - config_path = f"{ROOT}/test/mod_wsgi_test/{apache_config}" - pgrep = which("pgrep") - if pgrep: - result = subprocess.run( # noqa: S603 - [pgrep, "-f", config_path], capture_output=True, text=True, check=False - ) - for line in result.stdout.split(): - try: - victim = int(line) - except ValueError: - continue - if pid_is_our_apache(victim, apache_config): - try: - os.kill(victim, signal.SIGTERM) - except (ProcessLookupError, PermissionError): - LOGGER.warning(f"Could not stop Apache pid {victim}") - - # Stopping returns before the port is released, which the next mode needs - # to rebind. - deadline = time.time() + 10 - while time.time() < deadline: - if not port_is_open(): - return - time.sleep(0.5) - raise ValueError(f"Apache did not release port {PORT}") - - -def write_state(state: dict) -> None: - # The cache directory is user-only (0700) and the file is created 0600, so - # no other local user can read or plant this state. - fd = os.open(STATE_FILE, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600) - with os.fdopen(fd, "w") as f: - json.dump(state, f) - - -def read_state() -> dict: - # Lost or corrupt state falls back to discovery in teardown. - try: - return json.loads(STATE_FILE.read_text()) - except (OSError, ValueError): - return {} - - -def setup(sub_test_name: str) -> None: - if sub_test_name == "embedded": - conf = "mod_wsgi_test_embedded.conf" - elif sub_test_name == "standalone": - conf = "mod_wsgi_test.conf" - else: - raise ValueError("mod_wsgi sub test must be either 'standalone' or 'embedded'") - apache, apache_config = find_apache() - # On Fedora/RHEL, httpd embeds the interpreter mod_wsgi was built with and - # needs to be told where the Python installation lives. - env = { - "MOD_WSGI_CONF": conf, - "MOD_WSGI_SO": find_mod_wsgi_so(), - "MOD_WSGI_PYTHON_HOME": sys.base_prefix, - "PROJECT_DIRECTORY": str(ROOT), - } - # Stop any server left behind by a previous failed run so the port is free. - stop_apache(apache, apache_config, env) - run_command( - [apache, "-k", "start", "-f", f"{ROOT}/test/mod_wsgi_test/{apache_config}"], - env=env, - ) - write_state({"apache": apache, "config": apache_config, "env": env}) - - try: - for interp in ("interpreter1", "interpreter2"): - make_request(f"http://localhost:{PORT}/{interp}{ROOT}", 10) - except Exception: - # The Apache error log holds the actual failure. Stop the server so a - # failed setup does not leave it bound to the port. - stop_apache(apache, apache_config, env) - error_log = Path("error_log") - if error_log.exists(): - LOGGER.error(error_log.read_text()) - raise - - -def test() -> None: - sys.path.insert(0, str(ROOT)) - from test.mod_wsgi_test.test_client import main, parse_args - - uri1 = f"http://localhost:{PORT}/interpreter1{ROOT}" - uri2 = f"http://localhost:{PORT}/interpreter2{ROOT}" - try: - main(*parse_args(f"-n 25000 -t 100 parallel {uri1} {uri2}".split())) - main(*parse_args(f"-n 25000 serial {uri1} {uri2}".split())) - except BaseException: - # The test client raises KeyboardInterrupt in the failing path. - error_log = Path("error_log") - if error_log.exists(): - LOGGER.error(error_log.read_text()) - raise - - -def teardown() -> None: - state = read_state() - apache = state.get("apache") - apache_config = state.get("config") - env = state.get("env") - if not apache or not apache_config: - # State lost; fall back to discovery to stop a leftover server. The - # pid file in stop_apache usually makes this unnecessary. - try: - apache, apache_config = find_apache() - except ValueError: - return - env = { - "MOD_WSGI_CONF": "mod_wsgi_test.conf", - "MOD_WSGI_PYTHON_HOME": sys.base_prefix, - "PROJECT_DIRECTORY": str(ROOT), - } - try: - env["MOD_WSGI_SO"] = find_mod_wsgi_so() - except (ImportError, ValueError): - pass - stop_apache(apache, apache_config, env) - - -if __name__ == "__main__": - command = sys.argv[1] if len(sys.argv) > 1 else "" - if command == "setup": - setup(sys.argv[2]) - elif command == "test": - test() - elif command == "teardown": - teardown() - else: - raise SystemExit(f"Usage: {sys.argv[0]} setup |test|teardown") diff --git a/.evergreen/scripts/oidc_tester.py b/.evergreen/scripts/oidc_tester.py deleted file mode 100644 index 145ce4dece..0000000000 --- a/.evergreen/scripts/oidc_tester.py +++ /dev/null @@ -1,119 +0,0 @@ -from __future__ import annotations - -import os - -from utils import ( - DRIVERS_TOOLS, - TMP_DRIVER_FILE, - create_archive, - read_env, - run_command, - write_env, -) - -K8S_NAMES = ["aks", "gke", "eks"] -K8S_REMOTE_NAMES = [f"{n}-remote" for n in K8S_NAMES] -OIDC_APP_NAME = "auth_oidc" - - -def _get_target_dir(sub_test_name: str) -> str: - if sub_test_name == "default": - target_dir = "auth_oidc" - elif sub_test_name.startswith("azure"): - target_dir = "auth_oidc/azure" - elif sub_test_name.startswith("gcp"): - target_dir = "auth_oidc/gcp" - elif sub_test_name in K8S_NAMES + K8S_REMOTE_NAMES: - target_dir = "auth_oidc/k8s" - else: - raise ValueError(f"Invalid sub test name '{sub_test_name}'") - return f"{DRIVERS_TOOLS}/.evergreen/{target_dir}" - - -def _with_appname(uri: str, appname: str) -> str: - """Append ``appName`` so the failpoint's ``appName`` filter matches.""" - separator = "&" if "?" in uri else "?" - return f"{uri}{separator}appName={appname}" - - -def setup_oidc(sub_test_name: str) -> dict[str, str] | None: - write_env("OIDC_APP_NAME", OIDC_APP_NAME) - target_dir = _get_target_dir(sub_test_name) - env = os.environ.copy() - - if sub_test_name == "eks" and "AWS_ACCESS_KEY_ID" in os.environ: - # Store AWS creds for kubectl access. - for key in ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]: - if key in os.environ: - write_env(key, os.environ[key]) - - if sub_test_name == "azure": - env["AZUREOIDC_VMNAME_PREFIX"] = "PYTHON_DRIVER" - if "-remote" not in sub_test_name: - if sub_test_name != "azure": - env["GCPKMS_IMAGEFAMILY"] = "debian-12" - run_command(f"bash {target_dir}/setup.sh", env=env) - if sub_test_name in K8S_NAMES: - run_command(f"bash {target_dir}/setup-pod.sh {sub_test_name}") - run_command(f"bash {target_dir}/run-self-test.sh") - return None - - source_file = None - if sub_test_name == "default": - source_file = f"{target_dir}/secrets-export.sh" - elif sub_test_name in ["azure-remote", "gcp-remote"]: - source_file = "./secrets-export.sh" - if sub_test_name in K8S_REMOTE_NAMES: - write_env( - "MONGODB_URI_SINGLE", _with_appname(os.environ["MONGODB_URI_SINGLE"], OIDC_APP_NAME) - ) - return os.environ.copy() - if source_file is None: - return None - - config = read_env(source_file) - write_env("MONGODB_URI_SINGLE", _with_appname(config["MONGODB_URI_SINGLE"], OIDC_APP_NAME)) - write_env("MONGODB_URI", config["MONGODB_URI"]) - write_env("DB_IP", config["MONGODB_URI"]) - - if sub_test_name == "default": - write_env("OIDC_TOKEN_FILE", config["OIDC_TOKEN_FILE"]) - write_env("OIDC_TOKEN_DIR", config["OIDC_TOKEN_DIR"]) - if "OIDC_DOMAIN" in config: - write_env("OIDC_DOMAIN", config["OIDC_DOMAIN"]) - elif sub_test_name == "azure-remote": - write_env("AZUREOIDC_RESOURCE", config["AZUREOIDC_RESOURCE"]) - elif sub_test_name == "gcp-remote": - write_env("GCPOIDC_AUDIENCE", config["GCPOIDC_AUDIENCE"]) - return config - - -def test_oidc_send_to_remote(sub_test_name: str) -> None: - env = os.environ.copy() - target_dir = _get_target_dir(sub_test_name) - create_archive() - if sub_test_name in ["azure", "gcp"]: - upper_name = sub_test_name.upper() - env[f"{upper_name}OIDC_DRIVERS_TAR_FILE"] = TMP_DRIVER_FILE - env[f"{upper_name}OIDC_TEST_CMD"] = ( - f"OIDC_ENV={sub_test_name} ./.evergreen/run-mongodb-oidc-test.sh" - ) - elif sub_test_name in K8S_NAMES: - env["K8S_DRIVERS_TAR_FILE"] = TMP_DRIVER_FILE - env["K8S_TEST_CMD"] = "OIDC_ENV=k8s ./.evergreen/run-mongodb-oidc-test.sh" - run_command(f"bash {target_dir}/run-driver-test.sh", env=env) - - -def teardown_oidc(sub_test_name: str) -> None: - target_dir = _get_target_dir(sub_test_name) - # For k8s, make sure an error while tearing down the pod doesn't prevent - # the Altas server teardown. - error = None - if sub_test_name in K8S_NAMES: - try: - run_command(f"bash {target_dir}/teardown-pod.sh") - except Exception as e: - error = e - run_command(f"bash {target_dir}/teardown.sh") - if error: - raise error diff --git a/.evergreen/scripts/perf-submission-setup.sh b/.evergreen/scripts/perf-submission-setup.sh deleted file mode 100755 index ecb38751a5..0000000000 --- a/.evergreen/scripts/perf-submission-setup.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# We use the requester expansion to determine whether the data is from a mainline evergreen run or not - -set -eu - -# shellcheck disable=SC2154 -if [ "${requester}" == "commit" ]; then - echo "is_mainline: true" >> expansion.yml -else - echo "is_mainline: false" >> expansion.yml -fi - -# We parse the username out of the order_id as patches append that in and SPS does not need that information -# shellcheck disable=SC2154 -echo "parsed_order_id: $(echo "${revision_order_id}" | awk -F'_' '{print $NF}')" >> expansion.yml diff --git a/.evergreen/scripts/perf-submission.sh b/.evergreen/scripts/perf-submission.sh deleted file mode 100755 index f7c3ea6664..0000000000 --- a/.evergreen/scripts/perf-submission.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# We use the requester expansion to determine whether the data is from a mainline evergreen run or not - -set -eu - -# Submit the performance data to the SPS endpoint -# shellcheck disable=SC2154 -response=$(curl -s -w "\nHTTP_STATUS:%{http_code}" -X 'POST' \ - "https://performance-monitoring-api.corp.mongodb.com/raw_perf_results/cedar_report?project=${project_id}&version=${version_id}&variant=${build_variant}&order=${parsed_order_id}&task_name=${task_name}&task_id=${task_id}&execution=${execution}&mainline=${is_mainline}" \ - -H 'accept: application/json' \ - -H 'Content-Type: application/json' \ - -d @results.json) - -http_status=$(echo "$response" | grep "HTTP_STATUS" | awk -F':' '{print $2}') -response_body=$(echo "$response" | sed '/HTTP_STATUS/d') - -# We want to throw an error if the data was not successfully submitted -if [ "$http_status" -ne 200 ]; then - echo "Error: Received HTTP status $http_status" - echo "Response Body: $response_body" - exit 1 -fi - -echo "Response Body: $response_body" -echo "HTTP Status: $http_status" diff --git a/.evergreen/scripts/resync-all-specs.sh b/.evergreen/scripts/resync-all-specs.sh deleted file mode 100755 index 51d365cb88..0000000000 --- a/.evergreen/scripts/resync-all-specs.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash -# Run spec syncing script and create PR -set -eu - -# SETUP -SRC_URL="https://github.com/mongodb/specifications.git" -# needs to be set for resync-specs.sh -SPEC_SRC="$(realpath "../specifications")" -SCRIPT="$(realpath "./.evergreen/resync-specs.sh")" - -# Clone the spec repo if the directory does not exist -if [[ ! -d $SPEC_SRC ]]; then - git clone $SRC_URL $SPEC_SRC - if [[ $? -ne 0 ]]; then - echo "Error: Failed to clone repository." - exit 1 - fi -fi - -# Set environment variable to the cloned spec repo for resync-specs.sh -export MDB_SPECS="$SPEC_SRC" - -# Check that resync-specs.sh exists and is executable -if [[ ! -x $SCRIPT ]]; then - echo "Error: $SCRIPT not found or is not executable." - exit 1 -fi - -PR_DESC="spec_sync.txt" - -# run python script that actually does all the resyncing -if ! [ -n "${CI:-}" ] -then - # we're running locally - python3 ./.evergreen/scripts/resync_all_specs.py -else - # Use the newest mongodbtoolchain python; the default python3 may be too old. - PY=$(ls -1d /opt/mongodbtoolchain/v*/bin/python3 2>/dev/null | sort -V | tail -1) - [ -n "$PY" ] || PY=python3 - [ "$("$PY" -c 'import sys; print(sys.version_info >= (3, 7))' 2>/dev/null)" = True ] \ - || { echo "Error: $PY is not Python 3.7+, which resync_all_specs.py requires." >&2; exit 1; } - "$PY" ./.evergreen/scripts/resync_all_specs.py --filename "$PR_DESC" - if [[ -f $PR_DESC ]]; then - # changes were made -> call scrypt to create PR for us - .evergreen/scripts/create-spec-pr.sh "$PR_DESC" - rm "$PR_DESC" - fi -fi diff --git a/.evergreen/scripts/resync_all_specs.py b/.evergreen/scripts/resync_all_specs.py deleted file mode 100644 index 52c276b8b8..0000000000 --- a/.evergreen/scripts/resync_all_specs.py +++ /dev/null @@ -1,159 +0,0 @@ -from __future__ import annotations - -import argparse -import os -import pathlib -import subprocess -from argparse import Namespace -from subprocess import CalledProcessError - -JIRA_FILTER = "https://jira.mongodb.org/issues/?jql=labels%20%3D%20automated-sync%20AND%20status%20!%3D%20Closed" - - -def resync_specs(directory: pathlib.Path, errored: dict[str, str]) -> None: - """Actually sync the specs""" - print("Beginning to sync specs") - for spec in os.scandir(directory): - if not spec.is_dir(): - continue - - if spec.name in ["asynchronous"]: - continue - try: - subprocess.run( # noqa: S603 - ["bash", "./.evergreen/resync-specs.sh", spec.name], # noqa: S607 - capture_output=True, - text=True, - check=True, - ) - except CalledProcessError as exc: - errored[spec.name] = exc.stderr - # The PR-body summary is lost if PR creation fails. - print(f"Spec sync failed for {spec.name}:\n{exc.stderr}", flush=True) - print("Done syncing specs") - - -def apply_patches(errored): - print("Beginning to apply patches") - subprocess.run( - ["bash", "./.evergreen/remove-unimplemented-tests.sh"], # noqa: S607 - check=True, - ) - # Avoid shell=True by passing arguments as a list. - # Note: glob expansion doesn't work in shell=False, so we use a list of files. - spec_patch_dir = pathlib.Path("./.evergreen/spec-patch/") - patches = [str(p) for p in spec_patch_dir.glob("*.patch")] - patches += [str(p) for p in (spec_patch_dir / "permanent").glob("*.patch")] - if patches: - for patch in patches: - print(f"Applying patch {patch}") - try: - subprocess.run( # noqa: S603 - [ # noqa: S607 - "git", - "apply", - "-R", - "--allow-empty", - "--whitespace=fix", - str(patch), - ], - check=True, - stderr=subprocess.PIPE, - text=True, - ) - except CalledProcessError as exc: - errored[f"{patch}"] = exc.stderr - print(f"Patch application failed for {patch}:\n{exc.stderr}", flush=True) - - -def check_new_spec_directories(directory: pathlib.Path) -> list[str]: - """Check to see if there are any directories in the spec repo that don't exist in pymongo/test""" - spec_dir = pathlib.Path(os.environ["MDB_SPECS"]) / "source" - spec_set = { - entry.name.replace("-", "_") - for entry in os.scandir(spec_dir) - if entry.is_dir() - and (pathlib.Path(entry.path) / "tests").is_dir() - and len(list(os.scandir(pathlib.Path(entry.path) / "tests"))) > 1 - } - test_set = {entry.name.replace("-", "_") for entry in os.scandir(directory) if entry.is_dir()} - known_mappings = { - "ocsp_support": "ocsp", - "client_side_operations_timeout": "csot", - "mongodb_handshake": "handshake", - "load_balancers": "load_balancer", - "connection_monitoring_and_pooling": "connection_monitoring", - "command_logging_and_monitoring": "command_logging", - "initial_dns_seedlist_discovery": "srv_seedlist", - "server_discovery_and_monitoring": "sdam_monitoring", - } - - for k, v in known_mappings.items(): - if k in spec_set: - spec_set.remove(k) - spec_set.add(v) - return list(spec_set - test_set) - - -def write_summary(errored: dict[str, str], new: list[str], filename: str | None) -> None: - """Generate the PR description""" - pr_body = "" - # Avoid shell=True and complex pipes by using Python to process git output - process = subprocess.run( - ["git", "diff", "--name-only"], # noqa: S607 - capture_output=True, - text=True, - check=True, - ) - changed_files = process.stdout.strip().splitlines() - succeeded_set = set() - for f in changed_files: - parts = f.split("/") - if len(parts) > 1: - succeeded_set.add(parts[1]) - succeeded = sorted(succeeded_set) - - if len(succeeded) > 0: - pr_body += "The following specs were changed:\n -" - pr_body += "\n -".join(succeeded) - pr_body += "\n" - if len(errored) > 0: - pr_body += "\n\nThe following spec syncs encountered errors:" - for k, v in errored.items(): - pr_body += f"\n -{k}\n```{v}\n```" - pr_body += "\n" - if len(new) > 0: - pr_body += "\n\nThe following directories are in the specification repository and not in our test directory:\n -" - pr_body += "\n -".join(new) - pr_body += "\n" - if pr_body != "": - pr_body = f"Jira tickets: {JIRA_FILTER}\n\n" + pr_body - if filename is None: - print(f"\n{pr_body}") - else: - # Plain text: the consumer embeds this file via jq --rawfile, - # which handles the JSON escaping itself. - with open(filename, "w") as f: - f.write(pr_body) - - -def main(args: Namespace): - directory = pathlib.Path("./test") - errored: dict[str, str] = {} - resync_specs(directory, errored) - apply_patches(errored) - new = check_new_spec_directories(directory) - write_summary(errored, new, args.filename) - - -if __name__ == "__main__": - parser = argparse.ArgumentParser( - description="Python Script to resync all specs and generate summary for PR." - ) - parser.add_argument( - "--filename", - help="Name of file for the summary to be written into.", - default=None, - ) - args = parser.parse_args() - main(args) diff --git a/.evergreen/scripts/run-getdata.sh b/.evergreen/scripts/run-getdata.sh deleted file mode 100755 index 416744ac03..0000000000 --- a/.evergreen/scripts/run-getdata.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# Get the debug data for an evergreen task. -set -eu - -HERE=$(dirname ${BASH_SOURCE:-$0}) -HERE="$( cd -- "$HERE" > /dev/null 2>&1 && pwd )" -ROOT=$(dirname "$(dirname $HERE)") - -# Default to the drivers-evergreen-tools submodule when unset. -: "${DRIVERS_TOOLS:=$ROOT/drivers-evergreen-tools}" - -. ${DRIVERS_TOOLS}/.evergreen/get-distro.sh || true -get_distro || true -echo $DISTRO -echo $MARCH -echo $OS - -set -x -uname -a || true -ls /etc/*release* || true -cc --version || true -gcc --version || true -clang --version || true -gcov --version || true -lcov --version || true -llvm-cov --version || true -echo $PATH -ls -la /usr/local/Cellar/llvm/*/bin/ || true -ls -la /usr/local/Cellar/ || true -scan-build --version || true -genhtml --version || true -valgrind --version || true -set +x diff --git a/.evergreen/scripts/run-server.sh b/.evergreen/scripts/run-server.sh deleted file mode 100755 index 298eedcd3e..0000000000 --- a/.evergreen/scripts/run-server.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set -eu - -HERE=$(dirname ${BASH_SOURCE:-$0}) - -# Try to source the env file. -if [ -f $HERE/env.sh ]; then - echo "Sourcing env file" - source $HERE/env.sh -fi - -uv run $HERE/run_server.py "$@" diff --git a/.evergreen/scripts/run_server.py b/.evergreen/scripts/run_server.py deleted file mode 100644 index 38f817c15d..0000000000 --- a/.evergreen/scripts/run_server.py +++ /dev/null @@ -1,79 +0,0 @@ -from __future__ import annotations - -import os -import subprocess -import sys -from pathlib import Path -from typing import Any - -from utils import DRIVERS_TOOLS, ROOT, check_drivers_tools, get_test_options, run_command - - -def set_env(name: str, value: Any = "1") -> None: - os.environ[name] = str(value) - - -def start_server(): - run_mongodb_script = Path(DRIVERS_TOOLS) / ".evergreen" / "run-mongodb.sh" - want_help = bool({"-h", "--help"} & set(sys.argv[1:])) - if want_help and run_mongodb_script.is_file(): - # Forward straight to run-mongodb.sh's own help, without run_command's - # "Running command..." logging noise. - subprocess.run( # noqa: S603 - ["bash", str(run_mongodb_script), "start", "-h"], # noqa: S607 - cwd=DRIVERS_TOOLS, - check=True, - ) - return - - # DRIVERS_TOOLS is only needed to start a server; allow -h/--help to fall - # through to argparse when the submodule is missing. - if not want_help: - check_drivers_tools() - - opts, extra_opts = get_test_options( - "Run a MongoDB server. All given flags will be passed to run-mongodb.sh in DRIVERS_TOOLS.", - require_sub_test_name=False, - allow_extra_opts=True, - ) - test_name = opts.test_name - - # drivers-evergreen-tools expects the version variable to be named MONGODB_VERSION. - if "VERSION" in os.environ: - os.environ["MONGODB_VERSION"] = os.environ["VERSION"] - - if test_name == "auth_aws": - set_env("AUTH_AWS") - - elif test_name == "load_balancer": - set_env("LOAD_BALANCER") - - elif test_name == "search_index": - os.environ["TOPOLOGY"] = "replica_set" - os.environ["MONGODB_VERSION"] = "7.0" - - if not os.environ.get("TEST_CRYPT_SHARED"): - set_env("SKIP_CRYPT_SHARED") - - if opts.ssl: - extra_opts.append("--ssl") - if test_name != "ocsp": - certs = ROOT / "test/certificates" - set_env("TLS_CERT_KEY_FILE", certs / "client.pem") - set_env("TLS_PEM_KEY_FILE", certs / "server.pem") - set_env("TLS_CA_FILE", certs / "ca.pem") - - if opts.auth: - extra_opts.append("--auth") - - if opts.verbose: - extra_opts.append("-v") - elif opts.quiet: - extra_opts.append("-q") - - cmd = ["bash", f"{DRIVERS_TOOLS}/.evergreen/run-mongodb.sh", "start", *extra_opts] - run_command(cmd, cwd=DRIVERS_TOOLS) - - -if __name__ == "__main__": - start_server() diff --git a/.evergreen/scripts/run_tests.py b/.evergreen/scripts/run_tests.py deleted file mode 100644 index 9c3cdf13f5..0000000000 --- a/.evergreen/scripts/run_tests.py +++ /dev/null @@ -1,272 +0,0 @@ -from __future__ import annotations - -import json -import logging -import os -import platform -import shutil -import subprocess -import sys -from datetime import datetime -from pathlib import Path -from shutil import which - -try: - import importlib_metadata -except ImportError: - from importlib import metadata as importlib_metadata - - -import pytest -from utils import DRIVERS_TOOLS, LOGGER, ROOT, run_command - -AUTH = os.environ.get("AUTH", "noauth") -SSL = os.environ.get("SSL", "nossl") -UV_ARGS = os.environ.get("UV_ARGS", "") -TEST_PERF = os.environ.get("TEST_PERF") -GREEN_FRAMEWORK = os.environ.get("GREEN_FRAMEWORK") -TEST_ARGS = os.environ.get("TEST_ARGS", "").split() -TEST_NAME = os.environ.get("TEST_NAME") -SUB_TEST_NAME = os.environ.get("SUB_TEST_NAME") - - -def list_packages(): - packages = set() - for distribution in importlib_metadata.distributions(): - if distribution.name: - packages.add(distribution.name) - print("Package Version URL") - print("------------------- ----------- ----------------------------------------------------") - for name in sorted(packages): - distribution = importlib_metadata.distribution(name) - url = "" - if distribution.origin is not None: - url = distribution.origin.url - print(f"{name:20s}{distribution.version:12s}{url}") - print("------------------- ----------- ----------------------------------------------------\n") - - -def handle_perf(start_time: datetime): - end_time = datetime.now() - elapsed_secs = (end_time - start_time).total_seconds() - with open("results.json") as fid: - results = json.load(fid) - LOGGER.info("results.json:\n%s", json.dumps(results, indent=2)) - - results = dict( - status="PASS", - exit_code=0, - test_file="BenchMarkTests", - start=int(start_time.timestamp()), - end=int(end_time.timestamp()), - elapsed=elapsed_secs, - ) - report = dict(failures=0, results=[results]) - LOGGER.info("report.json\n%s", json.dumps(report, indent=2)) - - with open("report.json", "w", newline="\n") as fid: - json.dump(report, fid) - - -def handle_green_framework() -> None: - if GREEN_FRAMEWORK == "gevent": - from gevent import monkey - - monkey.patch_all() - - # Never run async tests with a framework. - if len(TEST_ARGS) <= 1: - TEST_ARGS.extend(["-m", "not default_async and default"]) - else: - for i in range(len(TEST_ARGS) - 1): - if "-m" in TEST_ARGS[i]: - TEST_ARGS[i + 1] = f"not default_async and {TEST_ARGS[i + 1]}" - - LOGGER.info(f"Running tests with {GREEN_FRAMEWORK}...") - - -def handle_c_ext() -> None: - if platform.python_implementation() != "CPython": - return - sys.path.insert(0, str(ROOT / "tools")) - from fail_if_no_c import main as fail_if_no_c - - fail_if_no_c() - - -def handle_pymongocrypt() -> None: - import pymongocrypt - - LOGGER.info(f"pymongocrypt version: {pymongocrypt.__version__})") - LOGGER.info(f"libmongocrypt version: {pymongocrypt.libmongocrypt_version()})") - - -def handle_aws_lambda() -> None: - env = os.environ.copy() - target_dir = ROOT / "test/lambda" - env["TEST_LAMBDA_DIRECTORY"] = str(target_dir) - env.setdefault("AWS_REGION", "us-east-1") - dirs = ["pymongo", "gridfs", "bson"] - # Remove the original .so files. - for dname in dirs: - so_paths = [f"{f.parent.name}/{f.name}" for f in (ROOT / dname).glob("*.so")] - for so_path in list(so_paths): - Path(so_path).unlink() - # Build the c extensions. - docker = which("docker") or which("podman") - if not docker: - raise ValueError("Could not find docker!") - image = "quay.io/pypa/manylinux2014_x86_64:latest" - run_command( - f'{docker} run --rm -v "{ROOT}:/src" --platform linux/amd64 {image} /src/test/lambda/build_internal.sh' - ) - for dname in dirs: - target = ROOT / "test/lambda/mongodb" / dname - shutil.rmtree(target, ignore_errors=True) - shutil.copytree(ROOT / dname, target) - # Remove the new so files from the ROOT directory. - for dname in dirs: - so_paths = [f"{f.parent.name}/{f.name}" for f in (ROOT / dname).glob("*.so")] - for so_path in list(so_paths): - Path(so_path).unlink() - - script_name = "run-deployed-lambda-aws-tests.sh" - run_command(f"bash {DRIVERS_TOOLS}/.evergreen/aws_lambda/{script_name}", env=env) - - -def handle_fuzz() -> None: - """Run the BSON fuzz targets (PYTHON-4232). Not pytest-based.""" - targets = ["fuzz_decode", "fuzz_decode_all", "fuzz_is_valid"] - - if SUB_TEST_NAME == "regression": - # Run the committed reproducers plus the seed corpus. - # Skip dotfiles (pathlib globbing matches them). - inputs = sorted( - str(p) for p in (ROOT / "fuzz" / "regression").glob("*") if not p.name.startswith(".") - ) - if not inputs: - raise RuntimeError("No fuzz regression inputs found in fuzz/regression/") - corpus_dir = os.environ.get("FUZZ_CORPUS_DIR", str(ROOT / "fuzz-scratch" / "corpus")) - # Fail fast on a missing or empty corpus; libFuzzer would silently - # skip it. - corpus_files = sorted( - str(p) for p in Path(corpus_dir).glob("*") if not p.name.startswith(".") - ) - if not corpus_files: - raise RuntimeError( - f"No fuzz seed corpus found in {corpus_dir}; was setup_tests.py run?" - ) - inputs.extend(corpus_files) - # Each input runs exactly once without random fuzzing; the -atheris_runs - # budget equals the file count so atheris exits cleanly after the last. - runs = len(inputs) - for target in targets: - run_command( - f"{sys.executable} fuzz/{target}.py {' '.join(inputs)} -atheris_runs={runs}" - ) - return - - # Time-boxed fuzzing against the generated seed corpus. - corpus_dir = os.environ.get("FUZZ_CORPUS_DIR", str(ROOT / "fuzz-scratch" / "corpus")) - # Fail fast on a missing or empty corpus: libFuzzer would only log - # "starting from an empty corpus" and burn the whole time budget - # without the seeds the task exists to exercise. - if not any(Path(corpus_dir).glob("*")): - raise RuntimeError(f"No fuzz seed corpus found in {corpus_dir}; was setup_tests.py run?") - # Keep libFuzzer artifacts (crash-*, leak-*, ...) under the scratch dir. - artifact_prefix = f"{ROOT}/fuzz-scratch/" - max_time = os.environ.get("FUZZ_MAX_TIME", "300") - for target in targets: - run_command( - f"{sys.executable} fuzz/{target}.py {corpus_dir} " - f"-artifact_prefix={artifact_prefix} " - f"-max_total_time={max_time} -max_len=1048576 -print_final_stats=1" - ) - - -def run() -> None: - # Add diagnostic for python version. - print("Running with python", sys.version) - - # List the installed packages. - list_packages() - - # Handle green framework first so they can patch modules. - if GREEN_FRAMEWORK: - handle_green_framework() - - # Ensure C extensions if applicable. - if not os.environ.get("NO_EXT"): - handle_c_ext() - - if os.environ.get("PYMONGOCRYPT_LIB"): - handle_pymongocrypt() - - LOGGER.info(f"Test setup:\n{AUTH=}\n{SSL=}\n{UV_ARGS=}\n{TEST_ARGS=}") - - # Record the start time for a perf test. - if TEST_PERF: - start_time = datetime.now() - - # Send kms tests to run remotely. - if TEST_NAME == "kms" and SUB_TEST_NAME in ["azure", "gcp"]: - from kms_tester import test_kms_send_to_remote - - test_kms_send_to_remote(SUB_TEST_NAME) - return - - # Handle doctests. - if TEST_NAME == "doctest": - from sphinx.cmd.build import main - - result = main(["-E", "-b", "doctest", "doc", "./doc/_build/doctest"]) - sys.exit(result) - - # Send ecs tests to run remotely. - if TEST_NAME == "auth_aws" and SUB_TEST_NAME == "ecs": - run_command(f"{DRIVERS_TOOLS}/.evergreen/auth_aws/aws_setup.sh ecs") - return - - # Send OIDC tests to run remotely. - if ( - TEST_NAME == "auth_oidc" - and SUB_TEST_NAME != "default" - and not SUB_TEST_NAME.endswith("-remote") - ): - from oidc_tester import test_oidc_send_to_remote - - test_oidc_send_to_remote(SUB_TEST_NAME) - return - - # Run deployed aws lambda tests. - if TEST_NAME == "aws_lambda": - handle_aws_lambda() - return - - if TEST_NAME == "fuzz": - handle_fuzz() - return - - if os.environ.get("DEBUG_LOG"): - TEST_ARGS.extend(f"-o log_cli_level={logging.DEBUG}".split()) - - if os.environ.get("COVERAGE"): - # Pass the args as a list to preserve multi-word entries like the - # marker expression added by handle_green_framework(). - cmd = [sys.executable, "-m", "coverage", "run", "-m", "pytest", *TEST_ARGS, *sys.argv[1:]] - result = subprocess.run(cmd, check=False) # noqa: S603 - subprocess.run([sys.executable, "-m", "coverage", "report"], check=False) - sys.exit(result.returncode) - - # Run local tests. - ret = pytest.main(TEST_ARGS + sys.argv[1:]) - if ret != 0: - sys.exit(ret) - - # Handle perf test post actions. - if TEST_PERF: - handle_perf(start_time) - - -if __name__ == "__main__": - run() diff --git a/.evergreen/scripts/setup-dev-env.sh b/.evergreen/scripts/setup-dev-env.sh deleted file mode 100755 index d9fbef2b04..0000000000 --- a/.evergreen/scripts/setup-dev-env.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash -# Set up development environment. -set -eu - -HERE=$(dirname ${BASH_SOURCE:-$0}) -HERE="$( cd -- "$HERE" > /dev/null 2>&1 && pwd )" -ROOT=$(dirname "$(dirname $HERE)") - -# Source the env files to pick up common variables. -if [ -f $HERE/env.sh ]; then - . $HERE/env.sh -fi - -# Get variables defined in test-env.sh. -if [ -f $HERE/test-env.sh ]; then - . $HERE/test-env.sh -fi - -# The bin dir for the pinned uv/just. setup-system.sh sets it on evergreen hosts; -# default it here so local dev (without setup-system.sh) also has a usable value. -# Native (Windows) form on cygwin, like install-dependencies.sh. -export PYMONGO_BIN_DIR="${PYMONGO_BIN_DIR:-$HOME/.local/bin}" -if [ "Windows_NT" = "${OS:-}" ]; then - _bin_dir="$(cygpath -m "$PYMONGO_BIN_DIR")" - export PYMONGO_BIN_DIR="$_bin_dir" - _posix_bin_dir="$(cygpath -u "$_bin_dir")" - export PYMONGO_BIN_DIR_POSIX="$_posix_bin_dir" -else - export PYMONGO_BIN_DIR_POSIX="$PYMONGO_BIN_DIR" -fi - -# install-dependencies.sh runs as a child process, so its PATH changes do not -# propagate back here: ensure the bin dir is on this process's PATH too, so a -# fresh install (first run, bin dir not on PATH yet) is visible to the -# `uv sync` and pre-commit setup below. -case ":$PATH:" in - *":$PYMONGO_BIN_DIR_POSIX:"*) ;; - *) export PATH="$PYMONGO_BIN_DIR_POSIX:$PATH" ;; -esac - -# Make sure a login shell can find the bin dir by adding it to the rc file, so -# local dev (which may never run setup-system.sh) still has it on PATH. env.sh's -# PATH does not persist past this session. Select the rc file from $SHELL (not -# by which rc file happens to exist) so the user's actual shell is updated, and -# create it if it does not exist yet. -if [ "${CI:-}" != "true" ] && [ "${GITHUB_ACTIONS:-}" != "true" ]; then - case "${SHELL:-}" in - */zsh) _rc="$HOME/.zshrc" ;; - *) _rc="$HOME/.bashrc" ;; - esac - touch "$_rc" - grep -qF 'export PATH="'"$PYMONGO_BIN_DIR_POSIX"':$PATH"' "$_rc" 2>/dev/null || \ - printf 'export PATH="%s:$PATH"\n' "$PYMONGO_BIN_DIR_POSIX" >> "$_rc" -fi - -# Initialize the submodule (Evergreen's git.get_project does not); tolerate -# non-git hosts with a warning. -if ! git -C "$ROOT" submodule update --init --recursive; then - echo "WARNING: could not initialize the drivers-evergreen-tools submodule;" \ - "set DRIVERS_TOOLS to a drivers-evergreen-tools checkout instead." -fi - -# Mirror configure-env.sh's uv config boundary; see it for the full explanation. -if [ -d "$ROOT/drivers-evergreen-tools" ] && [ ! -f "$ROOT/drivers-evergreen-tools/uv.toml" ]; then - cat < "$ROOT/drivers-evergreen-tools/uv.toml" -# Written by mongo-python-driver to stop uv's config discovery here; see -# .evergreen/scripts/configure-env.sh. -EOT -fi - -# Keep the boundary out of git status via the submodule's local exclude; -# no-op without git. -if _git_dir=$(git -C "$ROOT/drivers-evergreen-tools" rev-parse --absolute-git-dir 2>/dev/null); then - mkdir -p "${_git_dir}/info" - grep -qxF "uv.toml" "${_git_dir}/info/exclude" 2>/dev/null || - printf "uv.toml\n" >> "${_git_dir}/info/exclude" -fi - -# Ensure dependencies are installed. -bash $HERE/install-dependencies.sh - -# Re-source env.sh in case a dependency install updated it, e.g. on a host -# without a toolchain where uv was installed into a shared bin dir. -if [ -f $HERE/env.sh ]; then - . $HERE/env.sh -fi - -# Handle the value for UV_PYTHON. -. $HERE/setup-uv-python.sh - -# Only run the next part if not running on CI. -if [ -z "${CI:-}" ]; then - # Set up venv, making sure c extensions build unless disabled. - if [ -z "${NO_EXT:-}" ]; then - export PYMONGO_C_EXT_MUST_BUILD=1 - fi - - ( - cd $ROOT && uv sync - ) - - # Set up build utilities on Windows spawn hosts. - if [ -f $HOME/.visualStudioEnv.sh ]; then - set +u - SSH_TTY=1 source $HOME/.visualStudioEnv.sh - set -u - fi - - # Only set up pre-commit if we are in a git checkout. - if [ -f $HERE/.git ]; then - if ! command -v pre-commit &>/dev/null; then - uv tool install pre-commit - fi - - if [ ! -f .git/hooks/pre-commit ]; then - uvx pre-commit install - fi - fi -fi diff --git a/.evergreen/scripts/setup-system.sh b/.evergreen/scripts/setup-system.sh deleted file mode 100755 index bd7e2dd4bc..0000000000 --- a/.evergreen/scripts/setup-system.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# Set up the system on an evergreen host. -set -eu - -HERE=$(dirname ${BASH_SOURCE:-$0}) -pushd "$(dirname "$(dirname $HERE)")" -echo "Setting up system..." -bash .evergreen/scripts/configure-env.sh -source .evergreen/scripts/env.sh -bash $DRIVERS_TOOLS/.evergreen/setup.sh -popd - -# Run spawn host-specific tasks. -if [ -z "${CI:-}" ]; then - bash $HERE/setup-dev-env.sh -fi - -# Enable core dumps if enabled on the machine -# Copied from https://github.com/mongodb/mongo/blob/master/etc/evergreen.yml -if [ -f /proc/self/coredump_filter ]; then - # Set the shell process (and its children processes) to dump ELF headers (bit 4), - # anonymous shared mappings (bit 1), and anonymous private mappings (bit 0). - echo 0x13 >/proc/self/coredump_filter - - if [ -f /sbin/sysctl ]; then - # Check that the core pattern is set explicitly on our distro image instead - # of being the OS's default value. This ensures that coredump names are consistent - # across distros and can be picked up by Evergreen. - core_pattern=$(/sbin/sysctl -n "kernel.core_pattern") - if [ "$core_pattern" = "dump_%e.%p.core" ]; then - echo "Enabling coredumps" - ulimit -c unlimited - fi - fi -fi - -if [ "$(uname -s)" = "Darwin" ]; then - core_pattern_mac=$(/usr/sbin/sysctl -n "kern.corefile") - if [ "$core_pattern_mac" = "dump_%N.%P.core" ]; then - echo "Enabling coredumps" - ulimit -c unlimited - fi -fi - -if [ -w /etc/hosts ]; then - SUDO="" -else - SUDO="sudo" -fi - -# Add 'server' and 'hostname_not_in_cert' as a hostnames -echo "127.0.0.1 server" | $SUDO tee -a /etc/hosts -echo "127.0.0.1 hostname_not_in_cert" | $SUDO tee -a /etc/hosts - -echo "Setting up system... done." diff --git a/.evergreen/scripts/setup-tests.sh b/.evergreen/scripts/setup-tests.sh deleted file mode 100755 index 858906a39e..0000000000 --- a/.evergreen/scripts/setup-tests.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# Set up the test environment, including secrets and services. -set -eu - -# Supported/used environment variables: -# AUTH Set to enable authentication. Defaults to "noauth" -# SSL Set to enable SSL. Defaults to "nossl" -# GREEN_FRAMEWORK The green framework to test with, if any. -# COVERAGE If non-empty, run the test suite with coverage. -# COMPRESSORS If non-empty, install appropriate compressor. -# LIBMONGOCRYPT_URL The URL to download libmongocrypt. -# TEST_CRYPT_SHARED If non-empty, install crypt_shared lib. -# MONGODB_API_VERSION The mongodb api version to use in tests. -# MONGODB_URI If non-empty, use as the MONGODB_URI in tests. -# USE_ACTIVE_VENV If non-empty, use the active virtual environment. - -SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0}) - -# Try to source the env file. -if [ -f $SCRIPT_DIR/env.sh ]; then - source $SCRIPT_DIR/env.sh -fi - -echo "Setting up tests with args \"$*\"..." -uv run ${USE_ACTIVE_VENV:+--active} "$SCRIPT_DIR/setup_tests.py" "$@" -echo "Setting up tests with args \"$*\"... done." diff --git a/.evergreen/scripts/setup-uv-python.sh b/.evergreen/scripts/setup-uv-python.sh deleted file mode 100755 index 2fe4ff5f3c..0000000000 --- a/.evergreen/scripts/setup-uv-python.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash -# Choose the Python that uv uses, and make sure uv can provide it. -# -# Input: -# UV_PYTHON - a version ("3.11", "3.14t") or an interpreter path -# ("/usr/bin/python3.11"). -# -# Exports: -# UV_PYTHON_SEARCH_PATH - the Python toolchain bin dir for the request, so uv -# uses the toolchain Python instead of downloading one. -# UV_PYTHON_PREFERENCE - "system" so the toolchain wins over managed installs. -# A preference set by the task is left alone. -# UV_PYTHON - the Python interpreter uv uses; defaults to CPython -# 3.11 when the task does not set one. -set -euo pipefail - -HERE=$(dirname "${BASH_SOURCE:-$0}") -HERE="$( cd -- "$HERE" > /dev/null 2>&1 && pwd )" -ROOT=$(dirname "$(dirname "$HERE")") - -# A .venv whose interpreter was removed breaks every `uv python find` and -# `uv sync`. It is a build artifact, so remove it and let `uv sync` recreate it. -# A removed base interpreter leaves a dangling symlink on Linux/macOS and a -# launcher that will not start on Windows, so probe by running the interpreter. -for _py in "$ROOT/.venv/bin/python3" "$ROOT/.venv/bin/python" "$ROOT/.venv/Scripts/python.exe"; do - if [ -e "$_py" ] || [ -L "$_py" ]; then - if ! "$_py" -c 'import sys' > /dev/null 2>&1; then - echo "Removing broken .venv (its interpreter will not start); uv sync will recreate it." - rm -rf "$ROOT/.venv" - fi - break - fi -done -unset _py - -# Source the env files to pick up common variables. -if [ -f "$HERE/env.sh" ]; then - . "$HERE/env.sh" -fi - -# Get variables defined in test-env.sh. -if [ -f "$HERE/test-env.sh" ]; then - . "$HERE/test-env.sh" -fi - -# Default to a known-good Python so behavior is deterministic when a task does -# not pin one. Selecting the uv binary is separate and driven by the required -# uv version in pyproject.toml. -export UV_PYTHON="${UV_PYTHON:-3.11}" - -# Print the Python toolchain bin dir for a version like "3.11" or "3.14t". -function _toolchain_dir() { - local version="$1" dir - # Only plain CPython versions live in the toolchain. - [[ "$version" =~ ^[0-9]+\.[0-9]+t?$ ]] || return 1 - if [ "Windows_NT" = "${OS:-}" ]; then - local winver="${version%t}" - winver="${winver//./}" - if [ -n "${IS_WIN32:-}" ]; then - dir="C:/python/32/Python${winver}" - else - dir="C:/python/Python${winver}" - fi - elif [ "$(uname -s)" = "Darwin" ]; then - if [[ "$version" == *t ]]; then - dir="/Library/Frameworks/PythonT.Framework/Versions/${version%t}/bin" - else - dir="/Library/Frameworks/Python.Framework/Versions/${version}/bin" - fi - else - dir="/opt/python/${version}/bin" - fi - [ -d "$dir" ] || return 1 - echo "$dir" -} - -# Make sure uv can provide the requested Python, downloading it if needed. -# If that fails, fall back to any available Python on local hosts; on CI, fail. -function _ensure_python() { - local request="$1" out _fallback - if out=$(uv python find "$request" 2>&1); then - return 0 - fi - # Show why find failed: e.g. an interpreter uv cannot run, or none at all. - echo "Python \"$request\" was not found on this host:" >&2 - sed 's/^/ /' <<<"$out" >&2 - echo "Asking uv to install Python \"$request\"..." - if uv python install "$request"; then - return 0 - fi - echo "uv could not install Python \"$request\"; looking for another interpreter..." - # Ignore UV_PYTHON and friends: they would steer the fallback right back to - # the broken interpreter. Local setup only: the Evergreen agent exports - # CI=true for every task command. - if [ "${CI:-}" != "true" ] && \ - _fallback=$(env -u UV_PYTHON -u UV_PYTHON_SEARCH_PATH -u UV_PYTHON_PREFERENCE \ - uv python find ">=3.9" 2>/dev/null); then - echo "Using fallback interpreter: $_fallback" - export UV_PYTHON="$_fallback" - return 0 - fi - echo "ERROR: uv could not find or install Python \"$request\"." >&2 - return 1 -} - -_search_path="" -_skip_ensure="" - -if [[ "$UV_PYTHON" == */* || "$UV_PYTHON" == *\\* ]]; then - # An explicit interpreter path; uv uses it as-is, so probe/install is skipped. - if [ ! -x "$UV_PYTHON" ]; then - echo "ERROR: UV_PYTHON=$UV_PYTHON does not exist or is not executable." >&2 - exit 1 - fi - _skip_ensure=1 -elif _dir=$(_toolchain_dir "$UV_PYTHON"); then - _search_path="$_dir" -fi - -# Point uv at the toolchain Python when there is one and the task did not set -# its own preference: a task-level UV_PYTHON_PREFERENCE wins (PYTHON-6135). -# On CI the toolchain dir is already first on PATH (configure-env.sh), so this -# mainly benefits local hosts and later steps. -if [ -n "$_search_path" ] && [ -z "${UV_PYTHON_PREFERENCE:-}" ]; then - export UV_PYTHON_SEARCH_PATH="$_search_path" - export UV_PYTHON_PREFERENCE="system" -fi - -if [ -z "$_skip_ensure" ]; then - _ensure_python "${UV_PYTHON:-}" -fi diff --git a/.evergreen/scripts/setup_tests.py b/.evergreen/scripts/setup_tests.py deleted file mode 100644 index 68ddc9eea6..0000000000 --- a/.evergreen/scripts/setup_tests.py +++ /dev/null @@ -1,627 +0,0 @@ -from __future__ import annotations - -import base64 -import hashlib -import os -import platform -import shutil -import stat -import sys -import zipfile -from pathlib import Path -from urllib import request - -from utils import ( - DRIVERS_TOOLS, - ENV_FILE, - HERE, - LOGGER, - PERF_PYTHON_VERSION, - PLATFORM, - ROOT, - SANITIZER_PYTHON, - TEST_SUITE_MAP, - Distro, - check_drivers_tools, - get_test_options, - read_env, - run_command, - write_env, -) - -# Passthrough environment variables. -PASS_THROUGH_ENV = [ - "GREEN_FRAMEWORK", - "NO_EXT", - "MONGODB_API_VERSION", - "DEBUG_LOG", - "UV_PYTHON", - "UV_PYTHON_SEARCH_PATH", - "UV_PYTHON_PREFERENCE", - "REQUIRE_FIPS", - "IS_WIN32", - "FUZZ_MAX_TIME", -] - -# Map the test name to test extra. -EXTRAS_MAP = { - "auth_aws": "aws", - "auth_oidc": "aws", - "encryption": "encryption", - "enterprise_auth": "gssapi", - "kms": "encryption", - "ocsp": "ocsp", - "pyopenssl": "ocsp", -} - - -# Map the test name to test group. -GROUP_MAP = dict(fuzz="fuzz", mockupdb="mockupdb", perf="perf") - -# The test files run under ASan/UBSan (PYTHON-6048). They exercise the -# buffer-protocol acquisition path in bson/_cbsonmodule.c -# (_get_buffer/_prepare_input_buffer) and the wire-message builders in -# pymongo/_cmessagemodule.c (_op_msg, _batched_op_msg, -# _encode_batched_write_command). -SANITIZER_FILES = [ - "test/test_bson.py", - "test/test_raw_bson.py", - "test/test_raw_bson_shared.py", - "test/test_client.py", -] - -# The libmongocrypt release used when LIBMONGOCRYPT_URL is not set. Must be at -# least 1.21.0; the beta preview string query types were removed in 1.21.0 -# (MONGOCRYPT-938). -LIBMONGOCRYPT_VERSION = "1.21.0" - - -def is_set(var: str) -> bool: - value = os.environ.get(var, "") - return len(value.strip()) > 0 - - -def get_distro() -> Distro: - name = "" - version_id = "" - arch = platform.machine() - with open("/etc/os-release") as fid: - for line in fid: - line = line.replace('"', "") # noqa: PLW2901 - if line.startswith("NAME="): - _, _, name = line.strip().partition("=") - if line.startswith("VERSION_ID="): - _, _, version_id = line.strip().partition("=") - return Distro(name=name, version_id=version_id, arch=arch) - - -def get_libmongocrypt_target() -> str: - """Return the libmongocrypt release asset target for this platform. - - These are the names used by the signed release assets on GitHub, which are - keyed by libc flavor rather than by distro (MONGOCRYPT-838 moved the - per-variant release builds to a restricted bucket). - """ - if PLATFORM == "windows": - return "windows-x86_64" - if PLATFORM == "darwin": - return "macos-universal" - - distro = get_distro() - arch = distro.arch - if arch in ("aarch64", "arm64"): - arch = "arm64" - elif arch in ("x86_64", "amd64"): - arch = "x86_64" - - # Alpine and other musl distros need the musl build. - if "Alpine" in distro.name: - if arch not in ("x86_64", "arm64"): - raise ValueError(f"No musl libmongocrypt build for architecture {distro.arch}!") - return f"linux-{arch}-musl_1_2-nocrypto" - - libc = { - "x86_64": "glibc_2_7", - "arm64": "glibc_2_17", - "ppc64le": "glibc_2_17", - "s390x": "glibc_2_7", - }.get(arch) - if libc is None: - raise ValueError(f"No libmongocrypt build for architecture {distro.arch}!") - return f"linux-{arch}-{libc}-nocrypto" - - -def setup_libmongocrypt(): - if PLATFORM == "windows" and is_set("TEST_FLE_GCP_AUTO"): - # PYTHON-2808 Ensure this machine has the CA cert for google KMS. - run_command('powershell.exe "Invoke-WebRequest -URI https://oauth2.googleapis.com/"') - - if is_set("LIBMONGOCRYPT_URL"): - url = os.environ["LIBMONGOCRYPT_URL"] - else: - version = os.environ.get("LIBMONGOCRYPT_VERSION", LIBMONGOCRYPT_VERSION) - target = get_libmongocrypt_target() - url = ( - f"https://github.com/mongodb/libmongocrypt/releases/download/" - f"{version}/libmongocrypt-{target}-{version}.tar.gz" - ) - - shutil.rmtree(HERE / "libmongocrypt", ignore_errors=True) - - LOGGER.info(f"Fetching {url}...") - with request.urlopen(request.Request(url), timeout=15.0) as response: # noqa: S310 - if response.status == 200: - with Path("libmongocrypt.tar.gz").open("wb") as f: - f.write(response.read()) - Path("libmongocrypt").mkdir() - run_command("tar -xzf libmongocrypt.tar.gz -C libmongocrypt") - LOGGER.info(f"Fetching {url}... done.") - - run_command("ls -la libmongocrypt") - - if PLATFORM == "windows": - # libmongocrypt's windows dll is not marked executable. Use Path.chmod - # rather than shelling out: the bundled POSIX chmod cannot resolve the - # drive-lettered absolute path that get_libmongocrypt_base() returns. - dll = get_libmongocrypt_base() / "bin/mongocrypt.dll" - dll.chmod(dll.stat().st_mode | stat.S_IEXEC) - - -def get_libmongocrypt_base() -> Path: - """Return the root of the extracted libmongocrypt archive. - - The signed release archives put ``lib/`` at the archive root, while the - older master builds nested everything under ``nocrypto/``. - """ - base = ROOT / "libmongocrypt" - if (base / "nocrypto").exists(): - return base / "nocrypto" - return base - - -def load_config_from_file(path: str | Path) -> dict[str, str]: - config = read_env(path) - for key, value in config.items(): - write_env(key, value) - return config - - -def get_secrets(name: str) -> dict[str, str]: - secrets_dir = Path(f"{DRIVERS_TOOLS}/.evergreen/secrets_handling") - run_command(f"bash {secrets_dir.as_posix()}/setup-secrets.sh {name}", cwd=secrets_dir) - return load_config_from_file(secrets_dir / "secrets-export.sh") - - -def handle_test_env() -> None: - opts, _ = get_test_options("Set up the test environment and services.") - test_name = opts.test_name - sub_test_name = opts.sub_test_name - AUTH = "auth" if opts.auth else "noauth" - SSL = "ssl" if opts.ssl else "nossl" - TEST_ARGS = "" - - # Start compiling the args we'll pass to uv. - UV_ARGS = ["--extra test --no-group dev"] - - # If USE_ACTIVE_VENV is set, add --active to UV_ARGS so run-tests.sh uses the active venv. - if is_set("USE_ACTIVE_VENV"): - UV_ARGS.append("--active") - - test_title = test_name - if sub_test_name: - test_title += f" {sub_test_name}" - - # Create the test env file with the initial set of values. - with ENV_FILE.open("w", newline="\n") as fid: - fid.write("#!/usr/bin/env bash\n") - fid.write("set +x\n") - ENV_FILE.chmod(ENV_FILE.stat().st_mode | stat.S_IEXEC) - - write_env("PIP_QUIET") # Quiet by default. - write_env("PIP_PREFER_BINARY") # Prefer binary dists by default. - - # Set an environment variable for the test name and sub test name. - write_env(f"TEST_{test_name.upper()}") - write_env("TEST_NAME", test_name) - write_env("SUB_TEST_NAME", sub_test_name) - - # Handle pass through env vars. - for var in PASS_THROUGH_ENV: - if is_set(var) or getattr(opts, var.lower(), ""): - write_env(var, os.environ.get(var, getattr(opts, var.lower(), ""))) - - if extra := EXTRAS_MAP.get(test_name, ""): - UV_ARGS.append(f"--extra {extra}") - - if group := GROUP_MAP.get(test_name, ""): - UV_ARGS.append(f"--group {group}") - - if opts.test_min_deps: - UV_ARGS.append("--resolution=lowest-direct") - - if test_name == "auth_oidc": - from oidc_tester import setup_oidc - - config = setup_oidc(sub_test_name) - if not config: - AUTH = "noauth" - - if test_name in ["aws_lambda", "search_index"]: - env = os.environ.copy() - env["MONGODB_VERSION"] = "7.0" - env["LAMBDA_STACK_NAME"] = "dbx-python-lambda" - write_env("LAMBDA_STACK_NAME", env["LAMBDA_STACK_NAME"]) - run_command( - f"bash {DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh", - env=env, - cwd=DRIVERS_TOOLS, - ) - - if test_name == "search_index": - AUTH = "auth" - - if test_name == "ocsp": - SSL = "ssl" - - write_env("AUTH", AUTH) - write_env("SSL", SSL) - LOGGER.info(f"Setting up '{test_title}' with {AUTH=} and {SSL=}...") - - if test_name == "aws_lambda": - UV_ARGS.append("--group pip") - # Store AWS creds if they were given. - if "AWS_ACCESS_KEY_ID" in os.environ: - for key in ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]: - if key in os.environ: - write_env(key, os.environ[key]) - - if AUTH != "noauth": - if test_name == "auth_oidc": - DB_USER = config["OIDC_ADMIN_USER"] - DB_PASSWORD = config["OIDC_ADMIN_PWD"] - elif test_name == "search_index": - config = read_env(f"{DRIVERS_TOOLS}/.evergreen/atlas/secrets-export.sh") - DB_USER = config["DRIVERS_ATLAS_LAMBDA_USER"] - DB_PASSWORD = config["DRIVERS_ATLAS_LAMBDA_PASSWORD"] - write_env("MONGODB_URI", config["MONGODB_URI"]) - else: - DB_USER = "bob" - DB_PASSWORD = "pwd123" # noqa: S105 - write_env("DB_USER", DB_USER) - write_env("DB_PASSWORD", DB_PASSWORD) - LOGGER.info("Added auth, DB_USER: %s", DB_USER) - - if is_set("MONGODB_URI"): - write_env("PYMONGO_MUST_CONNECT", "true") - - if opts.disable_test_commands: - write_env("PYMONGO_DISABLE_TEST_COMMANDS", "1") - - if test_name == "enterprise_auth": - config = get_secrets("drivers/enterprise_auth") - if PLATFORM == "windows": - LOGGER.info("Setting GSSAPI_PASS") - write_env("GSSAPI_PASS", config["SASL_PASS"]) - write_env("GSSAPI_CANONICALIZE", "true") - else: - # BUILD-3830 - krb_conf = ROOT / ".evergreen/krb5.conf.empty" - krb_conf.touch() - write_env("KRB5_CONFIG", krb_conf) - LOGGER.info("Writing keytab") - # Python 3.15 rejects unpadded base64 by default; padded=False - # accepts it, and older Pythons need the padding added explicitly. - keytab_b64 = "".join(config["KEYTAB_BASE64"].split()) - try: - keytab = base64.b64decode(keytab_b64, padded=False) - except TypeError: - keytab = base64.b64decode(keytab_b64 + "=" * (-len(keytab_b64) % 4)) - keytab_file = ROOT / ".evergreen/drivers.keytab" - with keytab_file.open("wb") as fid: - fid.write(keytab) - principal = config["PRINCIPAL"] - LOGGER.info("Running kinit") - os.environ["KRB5_CONFIG"] = str(krb_conf) - cmd = f"kinit -k -t {keytab_file} -p {principal}" - run_command(cmd) - - LOGGER.info("Setting GSSAPI variables") - write_env("GSSAPI_HOST", config["SASL_HOST"]) - write_env("GSSAPI_PORT", config["SASL_PORT"]) - write_env("GSSAPI_PRINCIPAL", config["PRINCIPAL"]) - write_env("SASL_HOST", config["SASL_HOST"]) - - if test_name == "doctest": - UV_ARGS.append("--extra docs") - - if test_name == "load_balancer": - SINGLE_MONGOS_LB_URI = os.environ.get( - "SINGLE_MONGOS_LB_URI", "mongodb://127.0.0.1:8000/?loadBalanced=true" - ) - MULTI_MONGOS_LB_URI = os.environ.get( - "MULTI_MONGOS_LB_URI", "mongodb://127.0.0.1:8001/?loadBalanced=true" - ) - if SSL != "nossl": - SINGLE_MONGOS_LB_URI += "&tls=true" - MULTI_MONGOS_LB_URI += "&tls=true" - write_env("SINGLE_MONGOS_LB_URI", SINGLE_MONGOS_LB_URI) - write_env("MULTI_MONGOS_LB_URI", MULTI_MONGOS_LB_URI) - check_drivers_tools() - cmd = f'bash "{DRIVERS_TOOLS}/.evergreen/run-load-balancer.sh" start' - run_command(cmd) - - if test_name == "ocsp": - if sub_test_name: - os.environ["OCSP_SERVER_TYPE"] = sub_test_name - for name in ["OCSP_SERVER_TYPE", "ORCHESTRATION_FILE"]: - if name not in os.environ: - raise ValueError(f"Please set {name}") - - server_type = os.environ["OCSP_SERVER_TYPE"] - orch_file = os.environ["ORCHESTRATION_FILE"] - ocsp_algo = orch_file.split("-")[0] - if server_type == "no-responder": - tls_should_succeed = "false" if "mustStaple-disableStapling" in orch_file else "true" - else: - tls_should_succeed = "true" if "valid" in server_type else "false" - - write_env("OCSP_TLS_SHOULD_SUCCEED", tls_should_succeed) - write_env("CA_FILE", f"{DRIVERS_TOOLS}/.evergreen/ocsp/{ocsp_algo}/ca.pem") - - if server_type != "no-responder": - env = os.environ.copy() - env["SERVER_TYPE"] = server_type - env["OCSP_ALGORITHM"] = ocsp_algo - run_command(f"bash {DRIVERS_TOOLS}/.evergreen/ocsp/setup.sh", env=env) - - # The mock OCSP responder MUST BE started before the mongod as the mongod expects that - # a responder will be available upon startup. - # Default to the newest stable release; the "latest" nightly build is - # downloaded from a private S3 bucket and needs AWS credentials. - version = os.environ.get("VERSION", "latest-stable") - cmd = [ - "bash", - f"{DRIVERS_TOOLS}/.evergreen/run-mongodb.sh", - "start", - "--ssl", - "--version", - version, - ] - if opts.verbose: - cmd.append("-v") - elif opts.quiet: - cmd.append("-q") - run_command(cmd, cwd=DRIVERS_TOOLS) - - if SSL != "nossl": - check_drivers_tools() - write_env("CLIENT_PEM", f"{DRIVERS_TOOLS}/.evergreen/x509gen/client.pem") - write_env("CA_PEM", f"{DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem") - - compressors = os.environ.get("COMPRESSORS") or opts.compressor - if compressors == "snappy": - UV_ARGS.append("--extra snappy") - elif compressors == "zstd": - UV_ARGS.append("--extra zstd") - - if test_name in ["encryption", "kms"]: - # The GA string query types need libmongocrypt 1.19.0+ and the beta - # preview query types were removed in 1.21.0 (PYTHON-5959), so always - # use the master pymongocrypt build against the pinned libmongocrypt - # rather than the lib bundled in the released wheel. - # Check for libmongocrypt download. - if not (ROOT / "libmongocrypt").exists(): - setup_libmongocrypt() - - if not opts.test_min_deps: - UV_ARGS.append( - "--with pymongocrypt@git+https://github.com/mongodb/libmongocrypt@master#subdirectory=bindings/python" - ) - - # Use the nocrypto build to avoid dependency issues with older windows/python versions. - BASE = get_libmongocrypt_base() - if PLATFORM == "linux": - if (BASE / "lib/libmongocrypt.so").exists(): - PYMONGOCRYPT_LIB = BASE / "lib/libmongocrypt.so" - else: - PYMONGOCRYPT_LIB = BASE / "lib64/libmongocrypt.so" - elif PLATFORM == "darwin": - PYMONGOCRYPT_LIB = BASE / "lib/libmongocrypt.dylib" - else: - PYMONGOCRYPT_LIB = BASE / "bin/mongocrypt.dll" - if not PYMONGOCRYPT_LIB.exists(): - raise RuntimeError("Cannot find libmongocrypt shared object file") - write_env("PYMONGOCRYPT_LIB", PYMONGOCRYPT_LIB.as_posix()) - # PATH is updated by configure-env.sh for access to mongocryptd. - - if test_name == "encryption": - check_drivers_tools() - csfle_dir = Path(f"{DRIVERS_TOOLS}/.evergreen/csfle") - # Opt in to corporate Azure credentials (DRIVERS-3392) - os.environ["FLE_AZURE_USE_CORPORATE"] = "YES" - run_command(f"bash {csfle_dir.as_posix()}/setup-secrets.sh", cwd=csfle_dir) - load_config_from_file(csfle_dir / "secrets-export.sh") - run_command(f"bash {csfle_dir.as_posix()}/start-servers.sh") - - if sub_test_name == "pyopenssl": - UV_ARGS.append("--extra ocsp") - - if opts.crypt_shared: - config = read_env(f"{DRIVERS_TOOLS}/mo-expansion.sh") - CRYPT_SHARED_DIR = Path(config["CRYPT_SHARED_LIB_PATH"]).parent.as_posix() - LOGGER.info("Using crypt_shared_dir %s", CRYPT_SHARED_DIR) - if PLATFORM == "windows": - write_env("PATH", f"{CRYPT_SHARED_DIR}:$PATH") - else: - write_env( - "DYLD_FALLBACK_LIBRARY_PATH", - f"{CRYPT_SHARED_DIR}:${{DYLD_FALLBACK_LIBRARY_PATH:-}}", - ) - write_env("LD_LIBRARY_PATH", f"{CRYPT_SHARED_DIR}:${{LD_LIBRARY_PATH:-}}") - - if test_name == "kms": - from kms_tester import setup_kms - - setup_kms(sub_test_name) - - if test_name == "auth_aws" and sub_test_name != "ecs-remote": - auth_aws_dir = f"{DRIVERS_TOOLS}/.evergreen/auth_aws" - if "AWS_ROLE_SESSION_NAME" in os.environ: - write_env("AWS_ROLE_SESSION_NAME") - if sub_test_name != "ecs": - aws_setup = f"{auth_aws_dir}/aws_setup.sh" - run_command(f"bash {aws_setup} {sub_test_name}") - creds = read_env(f"{auth_aws_dir}/test-env.sh") - for name, value in creds.items(): - write_env(name, value) - else: - run_command(f"bash {auth_aws_dir}/setup-secrets.sh") - - if test_name == "atlas_connect": - secrets = get_secrets("drivers/atlas_connect") - - # Write file with Atlas X509 client certificate: - decoded = base64.b64decode(secrets["ATLAS_X509_DEV_CERT_BASE64"]).decode("utf8") - cert_file = ROOT / ".evergreen/atlas_x509_dev_client_certificate.pem" - with cert_file.open("w") as file: - file.write(decoded) - write_env( - "ATLAS_X509_DEV_WITH_CERT", - secrets["ATLAS_X509_DEV"] + "&tlsCertificateKeyFile=" + str(cert_file), - ) - - # We do not want the default client_context to be initialized. - write_env("DISABLE_CONTEXT") - - if test_name == "sfp": - secrets = get_secrets("drivers/sfp") - - # Write file with SFP Atlas X509 client certificate: - decoded = base64.b64decode(secrets["SFP_ATLAS_X509_BASE64"]).decode("utf8") - cert_file = ROOT / ".evergreen/atlas_x509_sfp_client_certificate.pem" - with cert_file.open("w") as file: - file.write(decoded) - write_env("SFP_ATLAS_X509_CERT", str(cert_file)) - - # We do not want the default client_context to be initialized. - write_env("DISABLE_CONTEXT") - - if test_name == "numpy": - UV_ARGS.append("--with numpy") - - if test_name == "perf": - data_dir = ROOT / "specifications/source/benchmarking/data" - if not data_dir.exists(): - run_command("git clone --depth 1 https://github.com/mongodb/specifications.git") - run_command("tar xf extended_bson.tgz", cwd=data_dir) - run_command("tar xf parallel.tgz", cwd=data_dir) - run_command("tar xf single_and_multi_document.tgz", cwd=data_dir) - write_env("TEST_PATH", str(data_dir)) - write_env("OUTPUT_FILE", str(ROOT / "results.json")) - # The toolchain build may be this same patch version but is not - # optimized, which regressed CPU-bound benchmarks (PYTHON-6135). - write_env("UV_PYTHON", PERF_PYTHON_VERSION) - write_env("UV_PYTHON_PREFERENCE", "only-managed") - with ENV_FILE.open("a", newline="\n") as fid: - fid.write("unset UV_PYTHON_SEARCH_PATH\n") - - UV_ARGS.append(f"--python={PERF_PYTHON_VERSION}") - - # PYTHON-4769 Run perf_test.py directly otherwise pytest's test collection negatively - # affects the benchmark results. - if sub_test_name == "sync": - TEST_ARGS = f"test/performance/perf_test.py {TEST_ARGS}" - else: - TEST_ARGS = f"test/performance/async_perf_test.py {TEST_ARGS}" - - if test_name == "fuzz": - # Build the seed corpus from the vendored spec data. Regression runs - # run it too. - scratch_dir = ROOT / "fuzz-scratch" - shutil.rmtree(scratch_dir, ignore_errors=True) - corpus_dir = scratch_dir / "corpus" - corpus_dir.mkdir(parents=True) - zip_path = scratch_dir / "corpus-seed.zip" - run_command( - f"{sys.executable} fuzz/build_corpus.py {zip_path} --data-dir {ROOT / 'test' / 'bson_corpus'}" - ) - with zipfile.ZipFile(zip_path) as zf: - zf.extractall(corpus_dir) - zip_path.unlink() - if sub_test_name == "fuzz": - # PYTHON-6178 Also seed from the committed corpus of previously - # harvested inputs, so the nightly builds on prior discoveries - # instead of the spec seeds alone. Regression runs (PRs) keep - # running only the reproducers and the spec seed corpus. - committed_dir = ROOT / "fuzz" / "corpus" - if committed_dir.is_dir(): - for path in sorted(committed_dir.iterdir()): - if path.name.startswith("."): - continue - shutil.copyfile(path, corpus_dir / path.name) - # Manifest of every input this run starts from; harvest_corpus.py - # treats these digests as already-known, so only units the fuzzer - # discovered during the run get harvested. - with open(scratch_dir / "baseline.txt", "w", encoding="utf-8") as fp: - for path in sorted(corpus_dir.iterdir()): - if path.is_file(): - fp.write(hashlib.sha256(path.read_bytes()).hexdigest() + "\n") - write_env("FUZZ_CORPUS_DIR", str(corpus_dir)) - - if test_name == "sanitizer": - if PLATFORM != "linux": - raise RuntimeError("The sanitizer tests require the Linux Python toolchain.") - if not Path(SANITIZER_PYTHON).is_file(): - raise RuntimeError( - f"Sanitizer interpreter not found at {SANITIZER_PYTHON}; " - "the task must run on a host with the ASan/UBSan toolchain Python." - ) - # Clear stale C artifacts: build_ext reuses them by mtime, and a - # plain same-version CPython build shares the ABI tag. - shutil.rmtree(ROOT / "build", ignore_errors=True) - for pkg in ["bson", "pymongo"]: - for ext in (ROOT / pkg).glob("*.so"): - ext.unlink() - # Build and run against the ASan/UBSan-instrumented toolchain CPython, - # and fail loudly rather than silently skip the C extension build. - write_env("UV_PYTHON", SANITIZER_PYTHON) - write_env("PYMONGO_C_EXT_MUST_BUILD") - write_env("CFLAGS", "-fsanitize=address,undefined -fno-omit-frame-pointer -g -O1") - write_env("LDFLAGS", "-fsanitize=address,undefined") - # CPython's pymalloc trips LeakSanitizer with false positives. - write_env("ASAN_OPTIONS", "detect_leaks=0") - # UBSan only warns by default; make undefined behavior fail the task. - write_env("UBSAN_OPTIONS", "halt_on_error=1:print_stacktrace=1") - # The toolchain interpreter self-initializes the sanitizer runtimes, - # so no LD_PRELOAD: gcc's libasan.so is a linker script that ld.so - # cannot preload, and preloading a mismatched runtime would mix two - # sanitizers in one process. - # -s: with halt_on_error=1, a sanitizer failure exits the interpreter - # before pytest replays captured stderr, losing the report and trace. - TEST_ARGS = "-s " + " ".join(SANITIZER_FILES) + " " + TEST_ARGS - - # Add coverage if requested. - if opts.cov: - # Keep in sync with combine-coverage.sh. - # coverage >=5 is needed for relative_files=true. - UV_ARGS.append("--group coverage") - write_env("COVERAGE") - - if opts.green_framework: - framework = opts.green_framework or os.environ["GREEN_FRAMEWORK"] - UV_ARGS.append(f"--group {framework}") - - else: - TEST_ARGS = f"-v --durations=5 {TEST_ARGS}" - TEST_SUITE = TEST_SUITE_MAP.get(test_name) - if TEST_SUITE: - TEST_ARGS = f"-m {TEST_SUITE} {TEST_ARGS}" - - write_env("TEST_ARGS", TEST_ARGS) - write_env("UV_ARGS", " ".join(UV_ARGS)) - - LOGGER.info(f"Setting up test '{test_title}' with {AUTH=} and {SSL=}... done.") - - -if __name__ == "__main__": - handle_test_env() diff --git a/.evergreen/scripts/setup_uv.py b/.evergreen/scripts/setup_uv.py deleted file mode 100755 index a3f5f9dc20..0000000000 --- a/.evergreen/scripts/setup_uv.py +++ /dev/null @@ -1,176 +0,0 @@ -#!/usr/bin/env python3 -"""Bootstrap the pinned uv/just for the test environment. - -install-dependencies.sh probes with `setup_uv.py --check`, sources ensure-uv.sh -(which finds or installs uv), then runs this script for the rest. Only the -standard library is used. - -This runs under the host's system python3, which may be older than our minimum supported version. -""" - -from __future__ import annotations - -import os -import re -import shlex -import shutil -import subprocess -import sys -import tempfile -from pathlib import Path - -HERE = Path(__file__).resolve().parent -ROOT = HERE.parent.parent -ENV_SH = HERE / "env.sh" -ASTRAL_INSTALL_URL = "https://astral.sh/uv/install.sh" - - -def required_uv_pin() -> str: - """Return [tool.uv] required-version, e.g. '==0.12.12' ('' if absent).""" - pattern = re.compile(r"required-version\s*=\s*['\"]?([^'\"\s]+)['\"]?") - in_uv = False - for line in (ROOT / "pyproject.toml").read_text().splitlines(): - stripped = line.strip() - if stripped.startswith("["): - in_uv = stripped == "[tool.uv]" - continue - if in_uv: - match = pattern.search(stripped) - if match: - return match.group(1) - return "" - - -def _add_path(dir_: str) -> None: - os.environ["PATH"] = dir_ + os.pathsep + os.environ.get("PATH", "") - - -def _install_uv_astral() -> None: - """Install uv from astral when ensure-uv.sh was not available. - - UV_TOOL_BIN_DIR is set (in native form on Windows) by install-dependencies.sh. - """ - print("uv not found; installing the latest uv from astral...") - env = { - **os.environ, - "UV_INSTALL_DIR": os.environ["UV_TOOL_BIN_DIR"], - "INSTALLER_NO_MODIFY_PATH": "1", - } - curl = shutil.which("curl") - sh = shutil.which("sh") - proc = subprocess.run( # noqa: S603 - [curl, "-LsSf", ASTRAL_INSTALL_URL], stdout=subprocess.PIPE, env=env, check=True - ) - subprocess.run([sh], input=proc.stdout, env=env, check=True) # noqa: S603 - _add_path(os.environ["UV_TOOL_BIN_DIR"]) - - -def _pin_uv(uv_pin: str) -> None: - """Install the pinned uv via uv tool install --force. - - UV_TOOL_BIN_DIR and UV_TOOL_DIR are inherited from the environment (set by - install-dependencies.sh / ensure-uv.sh, in native form on Windows). uv tool - install writes the binary into UV_TOOL_BIN_DIR and the tool venv into - UV_TOOL_DIR; --force lets it overwrite an existing install. - - Windows will not overwrite a running executable, so when the current uv is - already the target bin dir, run the install from a copy of the binary. - """ - uv_path = shutil.which("uv") - tool = uv_path - tmp_uv = None - if os.name == "nt": - tmp_uv = Path(tempfile.mkdtemp()) / Path(uv_path).name - shutil.copy2(uv_path, tmp_uv) - tool = str(tmp_uv) - try: - subprocess.run( # noqa: S603 - [ - tool, - "tool", - "install", - "--no-config", - "-q", - "--force", - "--from", - f"uv{uv_pin}", - "uv", - ], - check=True, - ) - finally: - if tmp_uv: - shutil.rmtree(tmp_uv.parent, ignore_errors=True) - - -# The UV_* env vars this bootstrap (or its caller, ensure-uv.sh) manages and -# may persist into env.sh. Deliberately narrow: other UV_* vars (e.g. -# UV_PUBLISH_TOKEN, UV_INDEX_..._PASSWORD) may hold credentials and must -# never be written out. -PERSISTED_UV_VARS = ("UV_CACHE_DIR", "UV_PYTHON_INSTALL_DIR", "UV_TOOL_BIN_DIR", "UV_TOOL_DIR") - - -def _write_env() -> None: - """Write the bootstrap's UV_* env vars into env.sh, replacing existing UV_* entries.""" - values = {k: v for k, v in os.environ.items() if k in PERSISTED_UV_VARS} - if not values: - return - existing = ENV_SH.read_text() if ENV_SH.exists() else "" - keep = [] - for line in existing.splitlines(): - stripped = line.strip() - if stripped.startswith("export "): - var, _, _ = stripped[len("export ") :].partition("=") - if var.startswith("UV_"): - continue - keep.append(line) - keep.append("") - # shlex.quote emits shell-safe values (single-quoted, escaping embedded - # quotes) so a value cannot break out of or inject into the assignment. - keep.extend(f"export {name}={shlex.quote(value)}" for name, value in sorted(values.items())) - # Write LF bytes directly: on Windows text mode translates \n to \r\n, which - # breaks bash sourcing env.sh, and `newline=` isn't available on all Pythons. - ENV_SH.write_bytes(("\n".join(keep) + "\n").encode()) - - -def _pinned_uv_installed() -> bool: - """Return True when the uv on PATH already matches the required-version pin.""" - pin = required_uv_pin() - if not pin.startswith("=="): - # Only exact pins are checked here; anything else falls back to setup. - return False - uv_path = shutil.which("uv") - if uv_path is None: - return False - proc = subprocess.run( # noqa: S603 - [uv_path, "--version"], stdout=subprocess.PIPE, check=True - ) - # Output looks like "uv 0.12.12 (aarch64-unknown-linux-gnu)". - return proc.stdout.decode().split()[1] == pin[len("==") :] - - -def main() -> int: - # Side-effect-free probe for install-dependencies.sh: a full `uv sync` - # there would download Python and install dependencies just to decide - # whether setup is needed. - if "--check" in sys.argv[1:]: - return 0 if _pinned_uv_installed() else 1 - - bin_dir = os.environ["UV_TOOL_BIN_DIR"] - Path(bin_dir).mkdir(parents=True, exist_ok=True) - _add_path(bin_dir) - - # Bootstrap a uv from astral if ensure-uv.sh didn't run and uv isn't on PATH. - if shutil.which("uv") is None: - _install_uv_astral() - - uv_pin = required_uv_pin() - if uv_pin: - _pin_uv(uv_pin) - - _write_env() - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/.evergreen/scripts/stop-server.sh b/.evergreen/scripts/stop-server.sh deleted file mode 100755 index a254a2715a..0000000000 --- a/.evergreen/scripts/stop-server.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# Stop a server that was started using run-mongodb.sh in DRIVERS_TOOLS. -set -eu - -HERE=$(dirname ${BASH_SOURCE:-$0}) -HERE="$( cd -- "$HERE" > /dev/null 2>&1 && pwd )" -ROOT=$(dirname "$(dirname $HERE)") - -# Try to source the env file. -if [ -f $HERE/env.sh ]; then - echo "Sourcing env file" - source $HERE/env.sh -fi - -# Default to the drivers-evergreen-tools submodule when unset. -: "${DRIVERS_TOOLS:=$ROOT/drivers-evergreen-tools}" - -bash ${DRIVERS_TOOLS}/.evergreen/run-mongodb.sh stop diff --git a/.evergreen/scripts/teardown-tests.sh b/.evergreen/scripts/teardown-tests.sh deleted file mode 100755 index 898425b6cf..0000000000 --- a/.evergreen/scripts/teardown-tests.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# Tear down any services that were used by tests. -set -eu - -SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0}) - -# Try to source the env file. -if [ -f $SCRIPT_DIR/env.sh ]; then - echo "Sourcing env inputs" - . $SCRIPT_DIR/env.sh -else - echo "Not sourcing env inputs" -fi - -# Handle test inputs. -if [ -f $SCRIPT_DIR/test-env.sh ]; then - echo "Sourcing test inputs" - . $SCRIPT_DIR/test-env.sh -else - echo "Missing test inputs, please run 'just setup-tests'" -fi - -# Teardown the test runner. -uv run $SCRIPT_DIR/teardown_tests.py diff --git a/.evergreen/scripts/teardown_tests.py b/.evergreen/scripts/teardown_tests.py deleted file mode 100644 index 09f2925ef5..0000000000 --- a/.evergreen/scripts/teardown_tests.py +++ /dev/null @@ -1,58 +0,0 @@ -from __future__ import annotations - -import os -import shutil -import sys -from pathlib import Path - -from utils import DRIVERS_TOOLS, LOGGER, ROOT, run_command - -TEST_NAME = os.environ.get("TEST_NAME", "unconfigured") -SUB_TEST_NAME = os.environ.get("SUB_TEST_NAME") - -LOGGER.info(f"Tearing down tests of type '{TEST_NAME}'...") - -# Shut down csfle servers if applicable. -if TEST_NAME == "encryption": - run_command(f"bash {DRIVERS_TOOLS}/.evergreen/csfle/stop-servers.sh") - -# Shut down load balancer if applicable. -elif TEST_NAME == "load-balancer": - run_command(f"bash {DRIVERS_TOOLS}/.evergreen/run-load-balancer.sh stop") - -# Tear down kms VM if applicable. -elif TEST_NAME == "kms" and SUB_TEST_NAME in ["azure", "gcp"]: - from kms_tester import teardown_kms - - teardown_kms(SUB_TEST_NAME) - -# Tear down OIDC if applicable. -elif TEST_NAME == "auth_oidc": - from oidc_tester import teardown_oidc - - teardown_oidc(SUB_TEST_NAME) - -# Tear down ocsp if applicable. -elif TEST_NAME == "ocsp": - run_command(f"bash {DRIVERS_TOOLS}/.evergreen/ocsp/teardown.sh") - -# Tear down atlas cluster if applicable. -if TEST_NAME in ["aws_lambda", "search_index"]: - run_command(f"bash {DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh") - -# Tear down auth_aws if applicable. -# We do not run web-identity hosts on macos, because the hosts lack permissions, -# so there is no reason to run the teardown, which would error with a 401. -elif TEST_NAME == "auth_aws" and sys.platform != "darwin": - run_command(f"bash {DRIVERS_TOOLS}/.evergreen/auth_aws/teardown.sh") - -# Tear down perf if applicable. -elif TEST_NAME == "perf": - shutil.rmtree(ROOT / "specifications", ignore_errors=True) - Path(os.environ["OUTPUT_FILE"]).unlink(missing_ok=True) - -# Tear down coverage if applicable. -if os.environ.get("COVERAGE"): - shutil.rmtree(".pytest_cache", ignore_errors=True) - -LOGGER.info(f"Tearing down tests of type '{TEST_NAME}'... done.") diff --git a/.evergreen/scripts/test_generate_config.py b/.evergreen/scripts/test_generate_config.py deleted file mode 100644 index 4336d4dcb4..0000000000 --- a/.evergreen/scripts/test_generate_config.py +++ /dev/null @@ -1,329 +0,0 @@ -"""Tests for the Evergreen PR task rules (PYTHON-6112). - -Run: pytest .evergreen/scripts/test_generate_config.py -m "" -(-m "" clears the repo-wide marker filter.) -Requires the generate-config hook's dependencies: pytest, pytest-asyncio, shrub.py, pyyaml. -""" - -from __future__ import annotations - -import sys -from inspect import getmembers, isfunction -from pathlib import Path - -sys.path.insert(0, str(Path(__file__).parent)) - -import generate_config -import generate_config_utils - - -def all_tasks(): - tasks = [] - for name, func in getmembers(generate_config, isfunction): - if name.startswith("create_") and name.endswith("_tasks"): - tasks.extend(func()) - return tasks - - -def task_vars(task): - vars = {} - for command in task.commands or []: - vars.update(getattr(command, "vars", None) or {}) - return vars - - -def pr_tasks(): - return [task for task in all_tasks() if "pr" in (task.tags or [])] - - -def all_variants(): - variants = [] - for name, func in getmembers(generate_config, isfunction): - if name.startswith("create_") and name.endswith("_variants"): - variants.extend(func()) - return variants - - -def variant_selects(variant, task): - """Whether the variant's task selectors match the task: "." selects a - tag, "!" negates the token that follows, a bare token names a task.""" - tags = task.tags or [] - for ref in variant.tasks: - includes, excludes, names = [], [], [] - for token in ref.name.split(): - if token.startswith("!."): - excludes.append(token[2:]) - elif token.startswith("!"): - excludes.append(token[1:]) - elif token.startswith("."): - includes.append(token[1:]) - else: - names.append(token) - if any(tag in tags for tag in excludes): - continue - if not includes and not names: - # A negation-only selector matches every remaining task. - return True - if names and task.name not in names: - continue - if includes and not all(tag in tags for tag in includes): - continue - return True - return False - - -def test_pr_tasks_pin_max_version(): - """Task-level pins: pr tasks pin MAX_VERSION (the "latest" nightly is - unstable); the explicit 4.4 min-deps pin is the exception. Variant-merged - pins are checked by test_pr_tasks_effectively_pin_max_version.""" - offenders = [ - (task.name, task_vars(task).get("VERSION")) - for task in pr_tasks() - if task_vars(task).get("VERSION") not in (None, generate_config_utils.MAX_VERSION) - and not ( - task_vars(task).get("VERSION") == "4.4" and task_vars(task).get("TEST_MIN_DEPS") == "1" - ) - ] - assert not offenders, f"PR tasks not pinned to MAX_VERSION: {offenders}" - - -def test_pr_tasks_effectively_pin_max_version(): - """Effective pins: a pr task without its own VERSION var inherits the - selecting variant's version, so every pr task that runs a server must - resolve to MAX_VERSION once variant expansions merge in. The explicit - 4.4 min-deps pin is the exception.""" - tasks = [task for task in all_tasks() if "pr" in (task.tags or [])] - offenders = [] - for variant in all_variants(): - variant_version = (variant.expansions or {}).get("VERSION") - for task in tasks: - if not variant_selects(variant, task): - continue - task_vars_ = task_vars(task) - if task_vars_.get("VERSION") == "4.4" and task_vars_.get("TEST_MIN_DEPS") == "1": - continue - effective = task_vars_.get("VERSION") or variant_version - if effective is None: - # Helpers that run the stable default server, like kms-fail. - continue - if effective != generate_config_utils.MAX_VERSION: - offenders.append((variant.name, task.name, effective)) - assert not offenders, f"pr tasks not effectively pinned to MAX_VERSION: {offenders}" - - -def test_server_version_pr_tasks_selected_once(): - """A pr server-version task must be selected only by the variant running - the server version it pins. The expected family comes from - create_server_version_variants(), not from the selections: a variant - missing its PR selector would otherwise drop from both sides and the - comparison would pass. Variants outside the family must not select these - tasks (the sanitizer variant pins MAX_VERSION for its own mongod).""" - sv_tasks = [task for task in pr_tasks() if "server-version" in (task.tags or [])] - sv_variants = generate_config.create_server_version_variants() - offenders = {} - for task in sv_tasks: - own = task_vars(task).get("VERSION") - selecting = [variant.name for variant in all_variants() if variant_selects(variant, task)] - matching = [ - variant.name - for variant in sv_variants - if (variant.expansions or {}).get("VERSION") == own - ] - if selecting != matching: - offenders[task.name] = {"selected by": selecting, "pins": own} - assert not offenders, ( - f"server-version pr tasks not selected by the variant matching their pin: {offenders}" - ) - - -def test_pr_tasks_cover_version_boundaries(): - """PRs test the server version boundaries: the newest numbered server - with every Python boundary, the min server with its min-Python floor.""" - for version, pythons in ( - ( - generate_config_utils.MAX_VERSION, - (generate_config_utils.MIN_PYTHON, generate_config_utils.MAX_PYTHON), - ), - (generate_config_utils.MIN_VERSION, (generate_config_utils.MIN_PYTHON,)), - ): - tasks = [ - task - for task in pr_tasks() - if "server-version" in (task.tags or []) and task_vars(task).get("VERSION") == version - ] - seen = {task_vars(task).get("UV_PYTHON") for task in tasks} - assert seen == set(pythons), ( - f"{version} pr tasks pin {sorted(seen)}, want {sorted(pythons)}" - ) - assert len(tasks) >= 2, f"{version} has too few server-version pr tasks" - - -def test_server_version_rotated_tasks_keep_coverage(): - """Per-commit coverage for this family rides the rotated boundary-Python - tasks, not the pr tasks (which run only on MAX_VERSION).""" - family = [task for task in all_tasks() if "server-version" in (task.tags or [])] - cov = [task for task in family if task_vars(task).get("COVERAGE") == "1"] - assert any("pr" not in (task.tags or []) for task in cov), ( - "the server-version family's only COVERAGE tasks are pr tasks" - ) - pr_pythons = { - combo: python - for combos in generate_config.SERVER_VERSION_PR_PYTHONS.values() - for combo, python in combos.items() - } - offenders = [] - for task in family: - if "pr" in (task.tags or []): - continue - vars = task_vars(task) - boundary = pr_pythons.get((vars["TOPOLOGY"], vars["AUTH"], vars["SSL"])) - if vars.get("UV_PYTHON") == boundary and vars.get("COVERAGE") != "1": - offenders.append(task.name) - assert not offenders, f"rotated server-version boundary tasks without COVERAGE: {offenders}" - - -def test_pr_min_deps_tasks_also_run_coverage(): - offenders = [ - task.name - for task in pr_tasks() - if task_vars(task).get("TEST_MIN_DEPS") == "1" and task_vars(task).get("COVERAGE") != "1" - ] - assert not offenders, f"min-deps PR tasks without COVERAGE: {offenders}" - - -def test_standard_family_pr_budget(): - """Patch-build PR budget: at most 5 pr-tagged test-standard tasks (the - pre-pin baseline), at most 3 on Python 3.14+ (the ubuntu22 compression - filter).""" - tasks = [task for task in pr_tasks() if "test-standard" in (task.tags or [])] - assert len(tasks) <= 5, f"too many test-standard PR tasks: {[t.name for t in tasks]}" - newer = [ - task - for task in tasks - if any( - tag in (task.tags or []) - for tag in ("python-3.14", "python-3.14t", "python-3.15", "python-3.15t") - ) - ] - assert len(newer) <= 3, f"too many 3.14+ test-standard PR tasks: {[t.name for t in newer]}" - - -def test_pr_tasks_run_coverage(): - """Pr tasks that pin a server version run with COVERAGE=1; no-cov - companions and infrastructure tasks (no VERSION) are exempt.""" - offenders = [ - task.name - for task in pr_tasks() - if task_vars(task).get("VERSION") is not None - and "test-non-standard-no-cov" not in (task.tags or []) - and task_vars(task).get("COVERAGE") != "1" - ] - assert not offenders, f"PR tasks without COVERAGE: {offenders}" - - -def test_rotated_tasks_keep_nightly_coverage(): - """Batch coverage rides the rotation independently of the pr tasks: - rotated "latest" tasks and max-Python auth-aws tasks keep COVERAGE=1 - (min-deps excepted).""" - offenders = [] - for task in all_tasks(): - tags = task.tags or [] - vars = task_vars(task) - if vars.get("TEST_MIN_DEPS") == "1" or "pr" in tags: - continue - rotated_latest = "server-latest" in tags or ("ocsp-ecdsa" in tags and "latest" in tags) - is_tested = ("test-standard" in tags and "server-latest" in tags) or ( - "test-non-standard" in tags - and "server-latest" in tags - and "sharded_cluster-auth-ssl" in tags - ) - is_aws_max_python = ( - "auth-aws" in tags - and "session-name" not in task.name - and vars.get("UV_PYTHON") == generate_config_utils.MAX_PYTHON - ) - if rotated_latest and is_tested and vars.get("COVERAGE") != "1": - offenders.append(task.name) - if is_aws_max_python and vars.get("COVERAGE") != "1": - offenders.append(task.name) - assert not offenders, f"rotated tasks without nightly COVERAGE: {offenders}" - # The "latest" ECDSA staples task keeps its nightly coverage. - latest_staples = [ - task.name - for task in all_tasks() - if "ocsp-ecdsa" in (task.tags or []) - and "ocsp-staple" in (task.tags or []) - and "latest" in (task.tags or []) - and task_vars(task).get("COVERAGE") == "1" - ] - assert latest_staples, "no ECDSA staples task on the latest nightly with COVERAGE" - # The 9.0 nightly OCSP tasks stay on the min-deps Python. - offenders = [ - task.name - for task in all_tasks() - if "ocsp" in (task.tags or []) - and "9.0" in (task.tags or []) - and "pr" not in (task.tags or []) - and task_vars(task).get("TEST_MIN_DEPS") != "1" - ] - assert not offenders, f"nightly 9.0 OCSP tasks not on min-deps Python: {offenders}" - - -def test_non_standard_cov_tasks_have_no_cov_companions(): - """Each non-standard coverage task also emits a no-cov companion, so the - macOS/Win64 encryption variants (which filter .cov) have a task to - activate in patch builds.""" - no_cov = {task.name for task in all_tasks() if "test-non-standard-no-cov" in (task.tags or [])} - for task in all_tasks(): - if "test-non-standard-no-cov" in (task.tags or []): - assert "pr" not in (task.tags or []), f"no-cov companion tagged pr: {task.name}" - elif "cov" in (task.tags or []) and "test-non-standard" in (task.tags or []): - companion = task.name.removesuffix("-cov") - assert companion in no_cov, f"missing no-cov companion for {task.name}" - - -def test_fuzz_task_wiring(): - """One fuzz variant serving both flows: the pr-tagged regression task - runs on every PR, the untagged nightly task (which also harvests the - corpus) never runs in a patch build.""" - tasks = [task for task in all_tasks() if "fuzz" in (task.tags or [])] - assert [task.name for task in tasks if "pr" in (task.tags or [])] == ["fuzz-regression"] - assert [task.name for task in tasks if "pr" not in (task.tags or [])] == ["fuzz"] - variants = generate_config.create_fuzz_variants() - assert len(variants) == 1 - variant = variants[0] - for task in tasks: - assert variant_selects(variant, task) - assert "pr" in (variant.tags or []) - assert variant.batchtime == generate_config_utils.BATCHTIME_DAY - # The harvest subprocess bootstraps the comment-bot github app, whose - # secrets live in AWS Secrets Manager: it needs the assumed-role - # credentials (as resync_specs and backport-pr also pass them). - nightly = tasks[1] - harvest = nightly.commands[-1] - env_vars = harvest.params["include_expansions_in_env"] - for var in ("AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"): - assert var in env_vars, f"harvest subprocess missing {var}" - - -def test_sanitizer_task_wiring(): - """PYTHON-6048: one pr-tagged sanitizer task, selected by exactly one - variant that pins MAX_VERSION and runs on a large host for ASan's memory - headroom. VERSION stays off the task so it is exempt - from the pr COVERAGE rule (coverage under ASan is not useful).""" - tasks = [task for task in all_tasks() if "sanitizer" in (task.tags or [])] - assert len(tasks) == 1 - task = tasks[0] - assert "pr" in task.tags - funcs = [getattr(cmd, "func", None) for cmd in task.commands] - assert funcs == ["run server", "run tests"] - vars_ = task_vars(task) - assert vars_["TEST_NAME"] == "sanitizer" - assert vars_["TOPOLOGY"] == "standalone" - assert vars_["AUTH"] == "noauth" - assert vars_["SSL"] == "nossl" - assert "VERSION" not in vars_ - variants = [v for v in all_variants() if variant_selects(v, task)] - assert len(variants) == 1 - assert variants[0].run_on == ["rhel8.10-large"] - assert (variants[0].expansions or {}).get("VERSION") == generate_config_utils.MAX_VERSION diff --git a/.evergreen/scripts/upload-codecov.sh b/.evergreen/scripts/upload-codecov.sh deleted file mode 100755 index 5c1d84c55c..0000000000 --- a/.evergreen/scripts/upload-codecov.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC2154 -# Upload a coverate report to codecov. -set -eu - -HERE=$(dirname ${BASH_SOURCE:-$0}) -ROOT=$(dirname "$(dirname $HERE)") - -pushd $ROOT > /dev/null -export FNAME=coverage.xml -REQUESTER=${requester:-} - -if [ ! -f ".coverage" ]; then - echo "There are no coverage results, not running codecov" - exit 0 -fi - -if [[ "${REQUESTER}" == "github_pr" || "${REQUESTER}" == "commit" ]]; then - echo "Uploading codecov for $REQUESTER..." -else - echo "Error: requester must be 'github_pr' or 'commit', got '${REQUESTER}'" >&2 - exit 1 -fi - -printf 'sha: %s\n' "$github_commit" -printf 'flag: %s-%s\n' "$build_variant" "$task_name" -printf 'file: %s\n' "$FNAME" -uv tool run --with "coverage[toml]" coverage xml - -codecov_args=( - upload-process - --report-type coverage - --disable-search - --fail-on-error - --git-service github - --token "${CODECOV_TOKEN}" - --sha "${github_commit}" - --flag "${build_variant}-${task_name}" - --file "${FNAME}" -) - -if [ -n "${github_pr_number:-}" ]; then - printf 'branch: %s:%s\n' "$github_author" "$github_pr_head_branch" - printf 'pr: %s\n' "$github_pr_number" - uv tool run --from codecov-cli codecovcli \ - "${codecov_args[@]}" \ - --pr "${github_pr_number}" \ - --branch "${github_author}:${github_pr_head_branch}" -else - printf 'branch: %s\n' "$branch_name" - uv tool run --from codecov-cli codecovcli \ - "${codecov_args[@]}" \ - --branch "${branch_name}" -fi -echo "Uploading codecov for $REQUESTER... done." - -popd > /dev/null diff --git a/.evergreen/scripts/upload-coverage-report.sh b/.evergreen/scripts/upload-coverage-report.sh deleted file mode 100755 index 895664cbf2..0000000000 --- a/.evergreen/scripts/upload-coverage-report.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# Upload a coverate report to s3. -set -eu -aws s3 cp htmlcov/ s3://"$1"/coverage/"$2"/"$3"/htmlcov/ --recursive --acl public-read --region us-east-1 diff --git a/.evergreen/scripts/utils.py b/.evergreen/scripts/utils.py deleted file mode 100644 index 4126b86998..0000000000 --- a/.evergreen/scripts/utils.py +++ /dev/null @@ -1,342 +0,0 @@ -from __future__ import annotations - -import argparse -import dataclasses -import logging -import os -import shlex -import subprocess -import sys -from pathlib import Path -from typing import Any - -HERE = Path(__file__).absolute().parent -ROOT = HERE.parent.parent -# DRIVERS_TOOLS defaults to the drivers-evergreen-tools submodule; an env var -# override wins. -DRIVERS_TOOLS = (os.environ.get("DRIVERS_TOOLS") or str(ROOT / "drivers-evergreen-tools")).replace( - os.sep, "/" -) -TMP_DRIVER_FILE = "/tmp/mongo-python-driver.tgz" # noqa: S108 - -LOGGER = logging.getLogger("test") -logging.basicConfig(level=logging.INFO, format="%(levelname)-8s %(message)s") -ENV_FILE = HERE / "test-env.sh" -PLATFORM = "windows" if os.name == "nt" else sys.platform.lower() - - -@dataclasses.dataclass -class Distro: - name: str - version_id: str - arch: str - - -# Map the test name to a test suite. -TEST_SUITE_MAP = { - "atlas_connect": "atlas_connect", - "auth_aws": "auth_aws", - "auth_oidc": "auth_oidc", - "default": "", - "default_async": "default_async", - "default_sync": "default", - "encryption": "encryption", - "enterprise_auth": "auth", - "search_index": "search_index", - "kms": "kms", - "load_balancer": "load_balancer", - "mockupdb": "mockupdb", - "ocsp": "ocsp", - "perf": "perf", - "sanitizer": "", - "sfp": "sfp", - "numpy": "", -} - -# Tests that require a sub test suite, mapped to their valid sub_test_name -# values, for test names where they're fully enumerable. A value of None -# means the sub_test_name is required but not restricted to a fixed set. -SUB_TEST_NAME_MAP: dict[str, list[str] | None] = { - "auth_aws": [ - "regular", - "assume-role", - "ec2", - "env-creds", - "session-creds", - "web-identity", - "ecs", - "ecs-remote", - ], - "kms": ["azure", "azure-remote", "azure-fail", "gcp", "gcp-remote", "gcp-fail"], - "fuzz": ["regression", "fuzz"], - "perf": ["sync", "async"], - "auth_oidc": [ - "default", - "azure", - "azure-remote", - "gcp", - "gcp-remote", - "aks", - "aks-remote", - "gke", - "gke-remote", - "eks", - "eks-remote", - ], -} - -EXTRA_TESTS = ["aws_lambda", "doctest", "fuzz"] - -# The managed Python version used for perf tests (PYTHON-6135). -PERF_PYTHON_VERSION = "3.11.9" - -# The ASan/UBSan-instrumented toolchain CPython used by the sanitizer task -# (PYTHON-6048), built by mongo-python-toolchain (PYTHON-6067). Linux only. -SANITIZER_PYTHON = "/opt/python/3.14-asan-ubsan/bin/python3" - -# Tests that do not use run-mongodb directly. -NO_RUN_ORCHESTRATION = [ - "auth_oidc", - "atlas_connect", - "aws_lambda", - "fuzz", - "mockupdb", - "ocsp", - "sfp", -] - -# Mapping of env variables to options -OPTION_TO_ENV_VAR = {"cov": "COVERAGE", "crypt_shared": "TEST_CRYPT_SHARED"} - -# Options that consume a following value, so it isn't mistaken for the test_name -# positional when inferring known_test_name below. -OPTIONS_WITH_VALUES = ["--green-framework", "--compressor", "--mongodb-api-version"] - - -def _first_positional_arg(argv: list[str]) -> str | None: - args = iter(argv) - for arg in args: - if arg in OPTIONS_WITH_VALUES: - next(args, None) - elif not arg.startswith("-"): - return arg - return None - - -def get_test_options( - description, require_sub_test_name=True, allow_extra_opts=False -) -> tuple[argparse.Namespace, list[str]]: - # If a test name with known sub_test_name choices was given, pin the test_name - # argument to it so the usage/help output isn't cluttered with every choice. - known_test_name = None - sub_test_choices = None - if require_sub_test_name: - first_positional = _first_positional_arg(sys.argv[1:]) - if first_positional in SUB_TEST_NAME_MAP: - known_test_name = first_positional - sub_test_choices = SUB_TEST_NAME_MAP[known_test_name] - description = f"{description.rstrip('.')} for '{known_test_name}'." - - parser = argparse.ArgumentParser( - description=description, formatter_class=argparse.RawDescriptionHelpFormatter - ) - if require_sub_test_name: - if known_test_name: - parser.prog = f"{parser.prog} {known_test_name}" - test_name_choices = [known_test_name] - test_name_help = argparse.SUPPRESS - else: - test_name_choices = sorted(list(TEST_SUITE_MAP) + EXTRA_TESTS) - test_name_help = ( - "The optional name of the test suite to set up, typically the same name " - f"as a pytest marker. One of: {', '.join(test_name_choices)}." - ) - parser.add_argument( - "test_name", - choices=test_name_choices, - nargs="?", - default="default", - metavar=known_test_name or "test_name", - help=test_name_help, - ) - if known_test_name: - example_sub_test_name = sub_test_choices[0] if sub_test_choices else "azure" - help_text = f"The sub test name, for example {example_sub_test_name!r}. Required for {known_test_name!r}." - if sub_test_choices: - help_text += f" One of: {', '.join(sub_test_choices)}." - else: - help_text = "The optional sub test name, for example 'azure'." - parser.add_argument( - "sub_test_name", - nargs="?", - choices=sub_test_choices, - metavar="sub_test_name", - help=help_text, - ) - else: - run_server_choices = sorted( - set(list(TEST_SUITE_MAP) + EXTRA_TESTS) - set(NO_RUN_ORCHESTRATION) - ) - parser.add_argument( - "test_name", - choices=run_server_choices, - nargs="?", - default="default", - metavar="test_name", - help=( - "The optional name of the test suite to be run, which informs the server " - f"configuration. One of: {', '.join(run_server_choices)}." - ), - ) - parser.add_argument( - "--verbose", "-v", action="store_true", help="Whether to log at the DEBUG level." - ) - parser.add_argument( - "--quiet", "-q", action="store_true", help="Whether to log at the WARNING level." - ) - parser.add_argument("--auth", action="store_true", help="Whether to add authentication.") - parser.add_argument("--ssl", action="store_true", help="Whether to add TLS configuration.") - - other_group = parser.add_argument_group("other options") - other_group.add_argument( - "--test-min-deps", action="store_true", help="Test against minimum dependency versions" - ) - - # Add the test modifiers. - if require_sub_test_name: - parser.add_argument( - "--debug-log", action="store_true", help="Enable pymongo standard logging." - ) - parser.add_argument("--cov", action="store_true", help="Add test coverage.") - other_group.add_argument( - "--green-framework", - nargs=1, - choices=["gevent"], - help="Optional green framework to test against.", - ) - other_group.add_argument( - "--compressor", - nargs=1, - choices=["zlib", "zstd", "snappy"], - help="Optional compression algorithm.", - ) - other_group.add_argument( - "--crypt-shared", action="store_true", help="Test with crypt_shared." - ) - other_group.add_argument("--no-ext", action="store_true", help="Run without c extensions.") - other_group.add_argument( - "--mongodb-api-version", choices=["1"], help="MongoDB stable API version to use." - ) - other_group.add_argument( - "--disable-test-commands", action="store_true", help="Disable test commands." - ) - - # Get the options. - if not allow_extra_opts: - opts, extra_opts = parser.parse_args(), [] - else: - opts, extra_opts = parser.parse_known_args() - - # Convert list inputs to strings. - for name in vars(opts): - value = getattr(opts, name) - if isinstance(value, list): - setattr(opts, name, value[0]) - - # Handle validation and environment variable overrides. - test_name = opts.test_name - sub_test_name = opts.sub_test_name if require_sub_test_name else "" - if require_sub_test_name and test_name in SUB_TEST_NAME_MAP and not sub_test_name: - raise ValueError(f"Test '{test_name}' requires a sub_test_name") - handle_env_overrides(parser, opts) - if "auth" in test_name: - opts.auth = True - # 'auth_aws ecs' shouldn't have extra auth set. - if test_name == "auth_aws" and sub_test_name == "ecs": - opts.auth = False - if opts.verbose: - LOGGER.setLevel(logging.DEBUG) - elif opts.quiet: - LOGGER.setLevel(logging.WARNING) - return opts, extra_opts - - -def handle_env_overrides(parser: argparse.ArgumentParser, opts: argparse.Namespace) -> None: - # Get the options, and then allow environment variable overrides. - for key in vars(opts): - if key in OPTION_TO_ENV_VAR: - env_var = OPTION_TO_ENV_VAR[key] - else: - env_var = key.upper() - if env_var in os.environ: - if parser.get_default(key) != getattr(opts, key): - LOGGER.info("Overriding env var '%s' with cli option", env_var) - elif env_var == "AUTH": - opts.auth = os.environ.get("AUTH") == "auth" - elif env_var == "SSL": - ssl_opt = os.environ.get("SSL", "") - opts.ssl = ssl_opt and ssl_opt.lower() != "nossl" - elif isinstance(getattr(opts, key), bool): - if os.environ[env_var]: - setattr(opts, key, True) - else: - setattr(opts, key, os.environ[env_var]) - - -def read_env(path: Path | str) -> dict[str, str]: - config = dict() - with Path(path).open() as fid: - for line in fid: - if "=" not in line: - continue - name, _, value = line.strip().partition("=") - if value.startswith(('"', "'")): - value = value[1:-1] - name = name.replace("export ", "") - config[name] = value - return config - - -def write_env(name: str, value: Any = "1") -> None: - with ENV_FILE.open("a", newline="\n") as fid: - # Remove any existing quote chars. - value = str(value).replace('"', "") - fid.write(f'export {name}="{value}"\n') - - -def run_command(cmd: str | list[str], **kwargs: Any) -> None: - if isinstance(cmd, list): - cmd = " ".join(cmd) - LOGGER.info("Running command '%s'...", cmd) - kwargs.setdefault("check", True) - # Prevent overriding the python used by other tools. - env = kwargs.pop("env", os.environ).copy() - for var in ["UV_PYTHON", "UV_PYTHON_SEARCH_PATH", "UV_PYTHON_PREFERENCE"]: - env.pop(var, None) - kwargs["env"] = env - try: - subprocess.run(shlex.split(cmd), **kwargs) # noqa: PLW1510, S603 - except subprocess.CalledProcessError as e: - LOGGER.error(e.output) - LOGGER.error(str(e)) - sys.exit(e.returncode) - LOGGER.info("Running command '%s'... done.", cmd) - - -def check_drivers_tools() -> None: - """Raise a clear error when the drivers-evergreen-tools checkout is missing.""" - # An uninitialized submodule can exist as an empty directory, so a bare - # is_dir() check passes. Require a script every consumer needs instead. - if not (Path(DRIVERS_TOOLS) / ".evergreen" / "run-mongodb.sh").is_file(): - raise RuntimeError( - "The drivers-evergreen-tools checkout is missing or empty; run `just " - "install` to initialize the submodule, or set DRIVERS_TOOLS to a " - "drivers-evergreen-tools checkout." - ) - - -def create_archive() -> str: - run_command("git add .", cwd=ROOT) - run_command('git commit --no-verify -m "add files"', check=False, cwd=ROOT) - run_command(f"git archive -o {TMP_DRIVER_FILE} HEAD", cwd=ROOT) - return TMP_DRIVER_FILE diff --git a/.evergreen/setup-spawn-host.sh b/.evergreen/setup-spawn-host.sh deleted file mode 100755 index 3db18d15ab..0000000000 --- a/.evergreen/setup-spawn-host.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# Set up a remote evergreen spawn host. -set -eu - -if [ -z "$1" ] - then - echo "Must supply a spawn host URL!" -fi - -target=$1 -user=${target%@*} -remote_dir=/home/$user/mongo-python-driver - -echo "Copying files to $target..." -rsync -az -e ssh --exclude '.git' --filter=':- .gitignore' -r . $target:$remote_dir -echo "Copying files to $target... done" - -ssh $target "$remote_dir/.evergreen/scripts/setup-system.sh" diff --git a/.evergreen/spec-patch/PYTHON-3712.patch b/.evergreen/spec-patch/PYTHON-3712.patch deleted file mode 100644 index 25ac2de351..0000000000 --- a/.evergreen/spec-patch/PYTHON-3712.patch +++ /dev/null @@ -1,15 +0,0 @@ -NEEDED UNTIL SHARDED-REPLICASET IS REMOVED FROM THE SPEC TEST -diff --git a/test/discovery_and_monitoring/unified/serverMonitoringMode.json b/test/discovery_and_monitoring/unified/serverMonitoringMode.json -index e44fad1b..4b492f7d 100644 ---- a/test/discovery_and_monitoring/unified/serverMonitoringMode.json -+++ b/test/discovery_and_monitoring/unified/serverMonitoringMode.json -@@ -5,7 +5,8 @@ - { - "topologies": [ - "single", -- "sharded" -+ "sharded", -+ "sharded-replicaset" - ], - "serverless": "forbid" - } diff --git a/.evergreen/spec-patch/PYTHON-4918.patch b/.evergreen/spec-patch/PYTHON-4918.patch deleted file mode 100644 index 5f409c5870..0000000000 --- a/.evergreen/spec-patch/PYTHON-4918.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/test/connection_monitoring/pool-create-min-size-error.json b/test/connection_monitoring/pool-create-min-size-error.json -index 1c744b85..509b2a23 100644 ---- a/test/connection_monitoring/pool-create-min-size-error.json -+++ b/test/connection_monitoring/pool-create-min-size-error.json -@@ -49,15 +49,15 @@ - "type": "ConnectionCreated", - "address": 42 - }, -+ { -+ "type": "ConnectionPoolCleared", -+ "address": 42 -+ }, - { - "type": "ConnectionClosed", - "address": 42, - "connectionId": 42, - "reason": "error" -- }, -- { -- "type": "ConnectionPoolCleared", -- "address": 42 - } - ], - "ignore": [ diff --git a/.evergreen/spec-patch/PYTHON-5052.patch b/.evergreen/spec-patch/PYTHON-5052.patch deleted file mode 100644 index 01cbc00116..0000000000 --- a/.evergreen/spec-patch/PYTHON-5052.patch +++ /dev/null @@ -1,440 +0,0 @@ -diff --git a/test/unified-test-format/invalid/entity-client-observeTracingMessages-additionalProperties.json b/test/unified-test-format/invalid/entity-client-observeTracingMessages-additionalProperties.json -new file mode 100644 -index 00000000..aa8046d2 ---- /dev/null -+++ b/test/unified-test-format/invalid/entity-client-observeTracingMessages-additionalProperties.json -@@ -0,0 +1,20 @@ -+{ -+ "description": "entity-client-observeTracingMessages-additionalProperties", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0", -+ "observeTracingMessages": { -+ "foo": "bar" -+ } -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "observeTracingMessages must not have additional properties'", -+ "operations": [] -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/entity-client-observeTracingMessages-additionalPropertyType.json b/test/unified-test-format/invalid/entity-client-observeTracingMessages-additionalPropertyType.json -new file mode 100644 -index 00000000..0b3a65f5 ---- /dev/null -+++ b/test/unified-test-format/invalid/entity-client-observeTracingMessages-additionalPropertyType.json -@@ -0,0 +1,20 @@ -+{ -+ "description": "entity-client-observeTracingMessages-additionalPropertyType", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0", -+ "observeTracingMessages": { -+ "enableCommandPayload": 0 -+ } -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "observeTracingMessages enableCommandPayload must be boolean", -+ "operations": [] -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/entity-client-observeTracingMessages-type.json b/test/unified-test-format/invalid/entity-client-observeTracingMessages-type.json -new file mode 100644 -index 00000000..de3ef39a ---- /dev/null -+++ b/test/unified-test-format/invalid/entity-client-observeTracingMessages-type.json -@@ -0,0 +1,18 @@ -+{ -+ "description": "entity-client-observeTracingMessages-type", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0", -+ "observeTracingMessages": "foo" -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "observeTracingMessages must be an object", -+ "operations": [] -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/expectedTracingSpans-additionalProperties.json b/test/unified-test-format/invalid/expectedTracingSpans-additionalProperties.json -new file mode 100644 -index 00000000..5947a286 ---- /dev/null -+++ b/test/unified-test-format/invalid/expectedTracingSpans-additionalProperties.json -@@ -0,0 +1,30 @@ -+{ -+ "description": "expectedTracingSpans-additionalProperties", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0" -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "additional property foo not allowed in expectTracingMessages", -+ "operations": [], -+ "expectTracingMessages": { -+ "client": "client0", -+ "ignoreExtraSpans": false, -+ "spans": [ -+ { -+ "name": "command", -+ "tags": { -+ "db.system": "mongodb" -+ } -+ } -+ ], -+ "foo": 0 -+ } -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/expectedTracingSpans-clientType.json b/test/unified-test-format/invalid/expectedTracingSpans-clientType.json -new file mode 100644 -index 00000000..2fe7faea ---- /dev/null -+++ b/test/unified-test-format/invalid/expectedTracingSpans-clientType.json -@@ -0,0 +1,28 @@ -+{ -+ "description": "expectedTracingSpans-clientType", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0" -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "client type must be string", -+ "operations": [], -+ "expectTracingMessages": { -+ "client": 0, -+ "spans": [ -+ { -+ "name": "command", -+ "tags": { -+ "db.system": "mongodb" -+ } -+ } -+ ] -+ } -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/expectedTracingSpans-emptyNestedSpan.json b/test/unified-test-format/invalid/expectedTracingSpans-emptyNestedSpan.json -new file mode 100644 -index 00000000..8a98d5ba ---- /dev/null -+++ b/test/unified-test-format/invalid/expectedTracingSpans-emptyNestedSpan.json -@@ -0,0 +1,29 @@ -+{ -+ "description": "expectedTracingSpans-emptyNestedSpan", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0" -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "nested spans must not have fewer than 1 items'", -+ "operations": [], -+ "expectTracingMessages": { -+ "client": "client0", -+ "spans": [ -+ { -+ "name": "command", -+ "tags": { -+ "db.system": "mongodb" -+ }, -+ "nested": [] -+ } -+ ] -+ } -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/expectedTracingSpans-invalidNestedSpan.json b/test/unified-test-format/invalid/expectedTracingSpans-invalidNestedSpan.json -new file mode 100644 -index 00000000..79a86744 ---- /dev/null -+++ b/test/unified-test-format/invalid/expectedTracingSpans-invalidNestedSpan.json -@@ -0,0 +1,31 @@ -+{ -+ "description": "expectedTracingSpans-invalidNestedSpan", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0" -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "nested span must have required property name", -+ "operations": [], -+ "expectTracingMessages": { -+ "client": "client0", -+ "spans": [ -+ { -+ "name": "command", -+ "tags": { -+ "db.system": "mongodb" -+ }, -+ "nested": [ -+ {} -+ ] -+ } -+ ] -+ } -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/expectedTracingSpans-missingPropertyClient.json b/test/unified-test-format/invalid/expectedTracingSpans-missingPropertyClient.json -new file mode 100644 -index 00000000..2fb1cd5b ---- /dev/null -+++ b/test/unified-test-format/invalid/expectedTracingSpans-missingPropertyClient.json -@@ -0,0 +1,27 @@ -+{ -+ "description": "expectedTracingSpans-missingPropertyClient", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0" -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "missing required property client", -+ "operations": [], -+ "expectTracingMessages": { -+ "spans": [ -+ { -+ "name": "command", -+ "tags": { -+ "db.system": "mongodb" -+ } -+ } -+ ] -+ } -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/expectedTracingSpans-missingPropertySpans.json b/test/unified-test-format/invalid/expectedTracingSpans-missingPropertySpans.json -new file mode 100644 -index 00000000..acd10307 ---- /dev/null -+++ b/test/unified-test-format/invalid/expectedTracingSpans-missingPropertySpans.json -@@ -0,0 +1,20 @@ -+{ -+ "description": "expectedTracingSpans-missingPropertySpans", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0" -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "missing required property spans", -+ "operations": [], -+ "expectTracingMessages": { -+ "client": "client0" -+ } -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedAdditionalProperties.json b/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedAdditionalProperties.json -new file mode 100644 -index 00000000..17299f86 ---- /dev/null -+++ b/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedAdditionalProperties.json -@@ -0,0 +1,28 @@ -+{ -+ "description": "expectedTracingSpans-spanMalformedAdditionalProperties", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0" -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "Span must not have additional properties", -+ "operations": [], -+ "expectTracingMessages": { -+ "client": "client0", -+ "spans": [ -+ { -+ "name": "foo", -+ "tags": {}, -+ "nested": [], -+ "foo": "bar" -+ } -+ ] -+ } -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedMissingName.json b/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedMissingName.json -new file mode 100644 -index 00000000..0257cd9b ---- /dev/null -+++ b/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedMissingName.json -@@ -0,0 +1,27 @@ -+{ -+ "description": "expectedTracingSpans-spanMalformedMissingName", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0" -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "missing required span name", -+ "operations": [], -+ "expectTracingMessages": { -+ "client": "client0", -+ "spans": [ -+ { -+ "tags": { -+ "db.system": "mongodb" -+ } -+ } -+ ] -+ } -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedMissingTags.json b/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedMissingTags.json -new file mode 100644 -index 00000000..a09ca31c ---- /dev/null -+++ b/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedMissingTags.json -@@ -0,0 +1,25 @@ -+{ -+ "description": "expectedTracingSpans-spanMalformedMissingTags", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0" -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "missing required span tags", -+ "operations": [], -+ "expectTracingMessages": { -+ "client": "client0", -+ "spans": [ -+ { -+ "name": "foo" -+ } -+ ] -+ } -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedNestedMustBeArray.json b/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedNestedMustBeArray.json -new file mode 100644 -index 00000000..ccff0410 ---- /dev/null -+++ b/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedNestedMustBeArray.json -@@ -0,0 +1,27 @@ -+{ -+ "description": "expectedTracingSpans-spanMalformedNestedMustBeArray", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0" -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "nested spans must be an array", -+ "operations": [], -+ "expectTracingMessages": { -+ "client": "client0", -+ "spans": [ -+ { -+ "name": "foo", -+ "tags": {}, -+ "nested": {} -+ } -+ ] -+ } -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedTagsMustBeObject.json b/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedTagsMustBeObject.json -new file mode 100644 -index 00000000..72af1c29 ---- /dev/null -+++ b/test/unified-test-format/invalid/expectedTracingSpans-spanMalformedTagsMustBeObject.json -@@ -0,0 +1,26 @@ -+{ -+ "description": "expectedTracingSpans-spanMalformedNestedMustBeObject", -+ "schemaVersion": "1.26", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0" -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "span tags must be an object", -+ "operations": [], -+ "expectTracingMessages": { -+ "client": "client0", -+ "spans": [ -+ { -+ "name": "foo", -+ "tags": [] -+ } -+ ] -+ } -+ } -+ ] -+} diff --git a/.evergreen/spec-patch/PYTHON-5445.patch b/.evergreen/spec-patch/PYTHON-5445.patch deleted file mode 100644 index 4ff67399b5..0000000000 --- a/.evergreen/spec-patch/PYTHON-5445.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/test/auth/legacy/connection-string.json b/test/auth/legacy/connection-string.json -index 3a099c813..8982b61d5 100644 ---- a/test/auth/legacy/connection-string.json -+++ b/test/auth/legacy/connection-string.json -@@ -440,6 +440,21 @@ - } - } - }, -+ { -+ "description": "should throw an exception if username provided (MONGODB-AWS)", -+ "uri": "mongodb://user@localhost.com/?authMechanism=MONGODB-AWS", -+ "valid": false -+ }, -+ { -+ "description": "should throw an exception if username and password provided (MONGODB-AWS)", -+ "uri": "mongodb://user:pass@localhost.com/?authMechanism=MONGODB-AWS", -+ "valid": false -+ }, -+ { -+ "description": "should throw an exception if AWS_SESSION_TOKEN provided (MONGODB-AWS)", -+ "uri": "mongodb://localhost/?authMechanism=MONGODB-AWS&authMechanismProperties=AWS_SESSION_TOKEN:token", -+ "valid": false -+ }, - { - "description": "should recognise the mechanism with test environment (MONGODB-OIDC)", - "uri": "mongodb://localhost/?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:test", diff --git a/.evergreen/spec-patch/PYTHON-5493.patch b/.evergreen/spec-patch/PYTHON-5493.patch deleted file mode 100644 index 99c105dcef..0000000000 --- a/.evergreen/spec-patch/PYTHON-5493.patch +++ /dev/null @@ -1,50 +0,0 @@ -diff --git a/test/connection_logging/connection-logging.json b/test/connection_logging/connection-logging.json -index 5799e834..72103b3c 100644 ---- a/test/connection_logging/connection-logging.json -+++ b/test/connection_logging/connection-logging.json -@@ -446,6 +446,22 @@ - } - } - }, -+ { -+ "level": "debug", -+ "component": "connection", -+ "data": { -+ "message": "Connection pool cleared", -+ "serverHost": { -+ "$$type": "string" -+ }, -+ "serverPort": { -+ "$$type": [ -+ "int", -+ "long" -+ ] -+ } -+ } -+ }, - { - "level": "debug", - "component": "connection", -@@ -498,22 +514,6 @@ - ] - } - } -- }, -- { -- "level": "debug", -- "component": "connection", -- "data": { -- "message": "Connection pool cleared", -- "serverHost": { -- "$$type": "string" -- }, -- "serverPort": { -- "$$type": [ -- "int", -- "long" -- ] -- } -- } - } - ] - } diff --git a/.evergreen/spec-patch/PYTHON-5559.patch b/.evergreen/spec-patch/PYTHON-5559.patch deleted file mode 100644 index 29ad8d4829..0000000000 --- a/.evergreen/spec-patch/PYTHON-5559.patch +++ /dev/null @@ -1,815 +0,0 @@ -diff --git a/test/sessions/snapshot-sessions.json b/test/sessions/snapshot-sessions.json -index 260f8b6f4..8f806ea75 100644 ---- a/test/sessions/snapshot-sessions.json -+++ b/test/sessions/snapshot-sessions.json -@@ -988,6 +988,810 @@ - } - } - ] -+ }, -+ { -+ "description": "Find operation with snapshot and snapshot time", -+ "operations": [ -+ { -+ "name": "find", -+ "object": "collection0", -+ "arguments": { -+ "session": "session0", -+ "filter": {} -+ }, -+ "expectResult": [ -+ { -+ "_id": 1, -+ "x": 11 -+ }, -+ { -+ "_id": 2, -+ "x": 11 -+ } -+ ] -+ }, -+ { -+ "name": "getSnapshotTime", -+ "object": "session0", -+ "saveResultAsEntity": "savedSnapshotTime" -+ }, -+ { -+ "name": "insertOne", -+ "object": "collection0", -+ "arguments": { -+ "document": { -+ "_id": 3, -+ "x": 33 -+ } -+ } -+ }, -+ { -+ "name": "createEntities", -+ "object": "testRunner", -+ "arguments": { -+ "entities": [ -+ { -+ "session": { -+ "id": "session2", -+ "client": "client0", -+ "sessionOptions": { -+ "snapshot": true, -+ "snapshotTime": "savedSnapshotTime" -+ } -+ } -+ } -+ ] -+ } -+ }, -+ { -+ "name": "find", -+ "object": "collection0", -+ "arguments": { -+ "session": "session2", -+ "filter": {} -+ }, -+ "expectResult": [ -+ { -+ "_id": 1, -+ "x": 11 -+ }, -+ { -+ "_id": 2, -+ "x": 11 -+ } -+ ] -+ }, -+ { -+ "name": "find", -+ "object": "collection0", -+ "arguments": { -+ "session": "session2", -+ "filter": {} -+ }, -+ "expectResult": [ -+ { -+ "_id": 1, -+ "x": 11 -+ }, -+ { -+ "_id": 2, -+ "x": 11 -+ } -+ ] -+ }, -+ { -+ "name": "find", -+ "object": "collection0", -+ "arguments": { -+ "filter": {} -+ }, -+ "expectResult": [ -+ { -+ "_id": 1, -+ "x": 11 -+ }, -+ { -+ "_id": 2, -+ "x": 11 -+ }, -+ { -+ "_id": 3, -+ "x": 33 -+ } -+ ] -+ } -+ ], -+ "expectEvents": [ -+ { -+ "client": "client0", -+ "events": [ -+ { -+ "commandStartedEvent": { -+ "command": { -+ "find": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$exists": false -+ } -+ } -+ }, -+ "databaseName": "database0" -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "find": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$matchesEntity": "savedSnapshotTime" -+ } -+ } -+ }, -+ "databaseName": "database0" -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "find": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$matchesEntity": "savedSnapshotTime" -+ } -+ } -+ }, -+ "databaseName": "database0" -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "find": "collection0", -+ "readConcern": { -+ "$$exists": false -+ } -+ }, -+ "databaseName": "database0" -+ } -+ } -+ ] -+ } -+ ] -+ }, -+ { -+ "description": "Distinct operation with snapshot and snapshot time", -+ "operations": [ -+ { -+ "name": "distinct", -+ "object": "collection0", -+ "arguments": { -+ "session": "session0", -+ "filter": {}, -+ "fieldName": "x" -+ }, -+ "expectResult": [ -+ 11 -+ ] -+ }, -+ { -+ "name": "getSnapshotTime", -+ "object": "session0", -+ "saveResultAsEntity": "savedSnapshotTime" -+ }, -+ { -+ "name": "insertOne", -+ "object": "collection0", -+ "arguments": { -+ "document": { -+ "_id": 3, -+ "x": 33 -+ } -+ } -+ }, -+ { -+ "name": "createEntities", -+ "object": "testRunner", -+ "arguments": { -+ "entities": [ -+ { -+ "session": { -+ "id": "session2", -+ "client": "client0", -+ "sessionOptions": { -+ "snapshot": true, -+ "snapshotTime": "savedSnapshotTime" -+ } -+ } -+ } -+ ] -+ } -+ }, -+ { -+ "name": "distinct", -+ "object": "collection0", -+ "arguments": { -+ "session": "session2", -+ "filter": {}, -+ "fieldName": "x" -+ }, -+ "expectResult": [ -+ 11 -+ ] -+ }, -+ { -+ "name": "distinct", -+ "object": "collection0", -+ "arguments": { -+ "session": "session2", -+ "filter": {}, -+ "fieldName": "x" -+ }, -+ "expectResult": [ -+ 11 -+ ] -+ }, -+ { -+ "name": "distinct", -+ "object": "collection0", -+ "arguments": { -+ "filter": {}, -+ "fieldName": "x" -+ }, -+ "expectResult": [ -+ 11, -+ 33 -+ ] -+ } -+ ], -+ "expectEvents": [ -+ { -+ "client": "client0", -+ "events": [ -+ { -+ "commandStartedEvent": { -+ "command": { -+ "distinct": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$exists": false -+ } -+ } -+ }, -+ "databaseName": "database0" -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "distinct": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$matchesEntity": "savedSnapshotTime" -+ } -+ } -+ }, -+ "databaseName": "database0" -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "distinct": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$matchesEntity": "savedSnapshotTime" -+ } -+ } -+ }, -+ "databaseName": "database0" -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "distinct": "collection0", -+ "readConcern": { -+ "$$exists": false -+ } -+ }, -+ "databaseName": "database0" -+ } -+ } -+ ] -+ } -+ ] -+ }, -+ { -+ "description": "Aggregate operation with snapshot and snapshot time", -+ "operations": [ -+ { -+ "name": "aggregate", -+ "object": "collection0", -+ "arguments": { -+ "session": "session0", -+ "pipeline": [ -+ { -+ "$match": { -+ "_id": 1 -+ } -+ } -+ ] -+ }, -+ "expectResult": [ -+ { -+ "_id": 1, -+ "x": 11 -+ } -+ ] -+ }, -+ { -+ "name": "getSnapshotTime", -+ "object": "session0", -+ "saveResultAsEntity": "savedSnapshotTime" -+ }, -+ { -+ "name": "findOneAndUpdate", -+ "object": "collection0", -+ "arguments": { -+ "filter": { -+ "_id": 1 -+ }, -+ "update": { -+ "$inc": { -+ "x": 1 -+ } -+ }, -+ "returnDocument": "After" -+ }, -+ "expectResult": { -+ "_id": 1, -+ "x": 12 -+ } -+ }, -+ { -+ "name": "createEntities", -+ "object": "testRunner", -+ "arguments": { -+ "entities": [ -+ { -+ "session": { -+ "id": "session2", -+ "client": "client0", -+ "sessionOptions": { -+ "snapshot": true, -+ "snapshotTime": "savedSnapshotTime" -+ } -+ } -+ } -+ ] -+ } -+ }, -+ { -+ "name": "aggregate", -+ "object": "collection0", -+ "arguments": { -+ "session": "session2", -+ "pipeline": [ -+ { -+ "$match": { -+ "_id": 1 -+ } -+ } -+ ] -+ }, -+ "expectResult": [ -+ { -+ "_id": 1, -+ "x": 11 -+ } -+ ] -+ }, -+ { -+ "name": "aggregate", -+ "object": "collection0", -+ "arguments": { -+ "session": "session2", -+ "pipeline": [ -+ { -+ "$match": { -+ "_id": 1 -+ } -+ } -+ ] -+ }, -+ "expectResult": [ -+ { -+ "_id": 1, -+ "x": 11 -+ } -+ ] -+ }, -+ { -+ "name": "aggregate", -+ "object": "collection0", -+ "arguments": { -+ "pipeline": [ -+ { -+ "$match": { -+ "_id": 1 -+ } -+ } -+ ] -+ }, -+ "expectResult": [ -+ { -+ "_id": 1, -+ "x": 12 -+ } -+ ] -+ } -+ ], -+ "expectEvents": [ -+ { -+ "client": "client0", -+ "events": [ -+ { -+ "commandStartedEvent": { -+ "command": { -+ "aggregate": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$exists": false -+ } -+ } -+ }, -+ "databaseName": "database0" -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "aggregate": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$matchesEntity": "savedSnapshotTime" -+ } -+ } -+ }, -+ "databaseName": "database0" -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "aggregate": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$matchesEntity": "savedSnapshotTime" -+ } -+ } -+ }, -+ "databaseName": "database0" -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "aggregate": "collection0", -+ "readConcern": { -+ "$$exists": false -+ } -+ }, -+ "databaseName": "database0" -+ } -+ } -+ ] -+ } -+ ] -+ }, -+ { -+ "description": "countDocuments operation with snapshot and snapshot time", -+ "operations": [ -+ { -+ "name": "countDocuments", -+ "object": "collection0", -+ "arguments": { -+ "session": "session0", -+ "filter": {} -+ }, -+ "expectResult": 2 -+ }, -+ { -+ "name": "getSnapshotTime", -+ "object": "session0", -+ "saveResultAsEntity": "savedSnapshotTime" -+ }, -+ { -+ "name": "insertOne", -+ "object": "collection0", -+ "arguments": { -+ "document": { -+ "_id": 3, -+ "x": 33 -+ } -+ } -+ }, -+ { -+ "name": "createEntities", -+ "object": "testRunner", -+ "arguments": { -+ "entities": [ -+ { -+ "session": { -+ "id": "session2", -+ "client": "client0", -+ "sessionOptions": { -+ "snapshot": true, -+ "snapshotTime": "savedSnapshotTime" -+ } -+ } -+ } -+ ] -+ } -+ }, -+ { -+ "name": "countDocuments", -+ "object": "collection0", -+ "arguments": { -+ "session": "session2", -+ "filter": {} -+ }, -+ "expectResult": 2 -+ }, -+ { -+ "name": "countDocuments", -+ "object": "collection0", -+ "arguments": { -+ "session": "session2", -+ "filter": {} -+ }, -+ "expectResult": 2 -+ }, -+ { -+ "name": "countDocuments", -+ "object": "collection0", -+ "arguments": { -+ "filter": {} -+ }, -+ "expectResult": 3 -+ } -+ ], -+ "expectEvents": [ -+ { -+ "client": "client0", -+ "events": [ -+ { -+ "commandStartedEvent": { -+ "command": { -+ "aggregate": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$exists": false -+ } -+ } -+ }, -+ "databaseName": "database0" -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "aggregate": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$matchesEntity": "savedSnapshotTime" -+ } -+ } -+ }, -+ "databaseName": "database0" -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "aggregate": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$matchesEntity": "savedSnapshotTime" -+ } -+ } -+ }, -+ "databaseName": "database0" -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "aggregate": "collection0", -+ "readConcern": { -+ "$$exists": false -+ } -+ }, -+ "databaseName": "database0" -+ } -+ } -+ ] -+ } -+ ] -+ }, -+ { -+ "description": "Mixed operation with snapshot and snapshotTime", -+ "operations": [ -+ { -+ "name": "find", -+ "object": "collection0", -+ "arguments": { -+ "session": "session0", -+ "filter": { -+ "_id": 1 -+ } -+ }, -+ "expectResult": [ -+ { -+ "_id": 1, -+ "x": 11 -+ } -+ ] -+ }, -+ { -+ "name": "getSnapshotTime", -+ "object": "session0", -+ "saveResultAsEntity": "savedSnapshotTime" -+ }, -+ { -+ "name": "findOneAndUpdate", -+ "object": "collection0", -+ "arguments": { -+ "filter": { -+ "_id": 1 -+ }, -+ "update": { -+ "$inc": { -+ "x": 1 -+ } -+ }, -+ "returnDocument": "After" -+ }, -+ "expectResult": { -+ "_id": 1, -+ "x": 12 -+ } -+ }, -+ { -+ "name": "createEntities", -+ "object": "testRunner", -+ "arguments": { -+ "entities": [ -+ { -+ "session": { -+ "id": "session2", -+ "client": "client0", -+ "sessionOptions": { -+ "snapshot": true, -+ "snapshotTime": "savedSnapshotTime" -+ } -+ } -+ } -+ ] -+ } -+ }, -+ { -+ "name": "find", -+ "object": "collection0", -+ "arguments": { -+ "filter": { -+ "_id": 1 -+ } -+ }, -+ "expectResult": [ -+ { -+ "_id": 1, -+ "x": 12 -+ } -+ ] -+ }, -+ { -+ "name": "aggregate", -+ "object": "collection0", -+ "arguments": { -+ "pipeline": [ -+ { -+ "$match": { -+ "_id": 1 -+ } -+ } -+ ], -+ "session": "session2" -+ }, -+ "expectResult": [ -+ { -+ "_id": 1, -+ "x": 11 -+ } -+ ] -+ }, -+ { -+ "name": "distinct", -+ "object": "collection0", -+ "arguments": { -+ "fieldName": "x", -+ "filter": {}, -+ "session": "session2" -+ }, -+ "expectResult": [ -+ 11 -+ ] -+ } -+ ], -+ "expectEvents": [ -+ { -+ "client": "client0", -+ "events": [ -+ { -+ "commandStartedEvent": { -+ "command": { -+ "find": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$exists": false -+ } -+ } -+ } -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "find": "collection0", -+ "readConcern": { -+ "$$exists": false -+ } -+ } -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "aggregate": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$matchesEntity": "savedSnapshotTime" -+ } -+ } -+ } -+ } -+ }, -+ { -+ "commandStartedEvent": { -+ "command": { -+ "distinct": "collection0", -+ "readConcern": { -+ "level": "snapshot", -+ "atClusterTime": { -+ "$$matchesEntity": "savedSnapshotTime" -+ } -+ } -+ } -+ } -+ } -+ ] -+ } -+ ] - } - ] - } diff --git a/.evergreen/spec-patch/PYTHON-5759.patch b/.evergreen/spec-patch/PYTHON-5759.patch deleted file mode 100644 index e23c8956c5..0000000000 --- a/.evergreen/spec-patch/PYTHON-5759.patch +++ /dev/null @@ -1,460 +0,0 @@ -diff --git a/test/client-side-encryption/spec/unified/accessToken-azure.json b/test/client-side-encryption/spec/unified/accessToken-azure.json -new file mode 100644 -index 000000000..9e7d68f44 ---- /dev/null -+++ b/test/client-side-encryption/spec/unified/accessToken-azure.json -@@ -0,0 +1,186 @@ -+{ -+ "description": "accessToken-azure", -+ "schemaVersion": "1.28", -+ "runOnRequirements": [ -+ { -+ "minServerVersion": "4.1.10", -+ "csfle": { -+ "minLibmongocryptVersion": "1.6.0" -+ } -+ } -+ ], -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client", -+ "autoEncryptOpts": { -+ "keyVaultNamespace": "keyvault.datakeys", -+ "kmsProviders": { -+ "azure": { -+ "accessToken": { -+ "$$placeholder": 1 -+ } -+ } -+ } -+ } -+ } -+ }, -+ { -+ "database": { -+ "id": "db", -+ "client": "client", -+ "databaseName": "db" -+ } -+ }, -+ { -+ "collection": { -+ "id": "coll", -+ "database": "db", -+ "collectionName": "coll" -+ } -+ }, -+ { -+ "clientEncryption": { -+ "id": "clientEncryption", -+ "clientEncryptionOpts": { -+ "keyVaultClient": "client", -+ "keyVaultNamespace": "keyvault.datakeys", -+ "kmsProviders": { -+ "azure": { -+ "accessToken": { -+ "$$placeholder": 1 -+ } -+ } -+ } -+ } -+ } -+ } -+ ], -+ "initialData": [ -+ { -+ "databaseName": "db", -+ "collectionName": "coll", -+ "documents": [], -+ "createOptions": { -+ "validator": { -+ "$jsonSchema": { -+ "properties": { -+ "secret": { -+ "encrypt": { -+ "keyId": [ -+ { -+ "$binary": { -+ "base64": "AZURE+AAAAAAAAAAAAAAAA==", -+ "subType": "04" -+ } -+ } -+ ], -+ "bsonType": "string", -+ "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" -+ } -+ } -+ }, -+ "bsonType": "object" -+ } -+ } -+ } -+ }, -+ { -+ "databaseName": "keyvault", -+ "collectionName": "datakeys", -+ "documents": [ -+ { -+ "_id": { -+ "$binary": { -+ "base64": "AZURE+AAAAAAAAAAAAAAAA==", -+ "subType": "04" -+ } -+ }, -+ "keyAltNames": [ -+ "my-key" -+ ], -+ "keyMaterial": { -+ "$binary": { -+ "base64": "Vlza0NjSsxbiJbHUM++3EWyhd5/m4QHv0ZaH87LsljVDltHNZyR9YBFOTDFE1RKeY/uGSW35IdOLVxpHvo1/qBz7E6Iv14obBmniRetWZq0wxerm72LlF+VPTHHmNn1sIv3TY/HsHSx7S1U/ILaKukD7hBKZ5/4A2tPOXtdnTzC4Rpc8bRjaM8heQSNEWbTBPqcQ9xD4YLi+uQlzbLZjQA+Ljr540QJEwa7RGw8J22eo1sb3vSeDAhR24GH6RPJ5v72yElGcOZrKCjxnbd4mrCtSHssfOzCnK2Dw3mHikSLeBFGjnlXydBWiTn2AlhOs+YpXdAJ6Zm3xjkdJOXKytg==", -+ "subType": "00" -+ } -+ }, -+ "creationDate": { -+ "$date": { -+ "$numberLong": "1552949630483" -+ } -+ }, -+ "updateDate": { -+ "$date": { -+ "$numberLong": "1552949630483" -+ } -+ }, -+ "status": { -+ "$numberInt": "0" -+ }, -+ "masterKey": { -+ "provider": "azure", -+ "keyVaultEndpoint": "drivers-3392-key-vault.vault.azure.net", -+ "keyName": "drivers-3392-keyname" -+ } -+ } -+ ] -+ } -+ ], -+ "tests": [ -+ { -+ "description": "Auto encrypt using access token Azure credentials", -+ "operations": [ -+ { -+ "name": "insertOne", -+ "arguments": { -+ "document": { -+ "_id": 1, -+ "secret": "string0" -+ } -+ }, -+ "object": "coll" -+ } -+ ], -+ "outcome": [ -+ { -+ "documents": [ -+ { -+ "_id": 1, -+ "secret": { -+ "$binary": { -+ "base64": "AQGVERPgAAAAAAAAAAAAAAAC5DbBSwPwfSlBrDtRuglvNvCXD1KzDuCKY2P+4bRFtHDjpTOE2XuytPAUaAbXf1orsPq59PVZmsbTZbt2CB8qaQ==", -+ "subType": "06" -+ } -+ } -+ } -+ ], -+ "collectionName": "coll", -+ "databaseName": "db" -+ } -+ ] -+ }, -+ { -+ "description": "Explicit encrypt using access token Azure credentials", -+ "operations": [ -+ { -+ "name": "encrypt", -+ "object": "clientEncryption", -+ "arguments": { -+ "value": "string0", -+ "opts": { -+ "keyAltName": "my-key", -+ "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" -+ } -+ }, -+ "expectResult": { -+ "$binary": { -+ "base64": "AQGVERPgAAAAAAAAAAAAAAAC5DbBSwPwfSlBrDtRuglvNvCXD1KzDuCKY2P+4bRFtHDjpTOE2XuytPAUaAbXf1orsPq59PVZmsbTZbt2CB8qaQ==", -+ "subType": "06" -+ } -+ } -+ } -+ ] -+ } -+ ] -+} -diff --git a/test/client-side-encryption/spec/unified/accessToken-gcp.json b/test/client-side-encryption/spec/unified/accessToken-gcp.json -new file mode 100644 -index 000000000..f5cf8914f ---- /dev/null -+++ b/test/client-side-encryption/spec/unified/accessToken-gcp.json -@@ -0,0 +1,188 @@ -+{ -+ "description": "accessToken-gcp", -+ "schemaVersion": "1.28", -+ "runOnRequirements": [ -+ { -+ "minServerVersion": "4.1.10", -+ "csfle": { -+ "minLibmongocryptVersion": "1.6.0" -+ } -+ } -+ ], -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client", -+ "autoEncryptOpts": { -+ "keyVaultNamespace": "keyvault.datakeys", -+ "kmsProviders": { -+ "gcp": { -+ "accessToken": { -+ "$$placeholder": 1 -+ } -+ } -+ } -+ } -+ } -+ }, -+ { -+ "database": { -+ "id": "db", -+ "client": "client", -+ "databaseName": "db" -+ } -+ }, -+ { -+ "collection": { -+ "id": "coll", -+ "database": "db", -+ "collectionName": "coll" -+ } -+ }, -+ { -+ "clientEncryption": { -+ "id": "clientEncryption", -+ "clientEncryptionOpts": { -+ "keyVaultClient": "client", -+ "keyVaultNamespace": "keyvault.datakeys", -+ "kmsProviders": { -+ "gcp": { -+ "accessToken": { -+ "$$placeholder": 1 -+ } -+ } -+ } -+ } -+ } -+ } -+ ], -+ "initialData": [ -+ { -+ "databaseName": "db", -+ "collectionName": "coll", -+ "documents": [], -+ "createOptions": { -+ "validator": { -+ "$jsonSchema": { -+ "properties": { -+ "secret": { -+ "encrypt": { -+ "keyId": [ -+ { -+ "$binary": { -+ "base64": "GCP+AAAAAAAAAAAAAAAAAA==", -+ "subType": "04" -+ } -+ } -+ ], -+ "bsonType": "string", -+ "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" -+ } -+ } -+ }, -+ "bsonType": "object" -+ } -+ } -+ } -+ }, -+ { -+ "databaseName": "keyvault", -+ "collectionName": "datakeys", -+ "documents": [ -+ { -+ "_id": { -+ "$binary": { -+ "base64": "GCP+AAAAAAAAAAAAAAAAAA==", -+ "subType": "04" -+ } -+ }, -+ "keyAltNames": [ -+ "my-key" -+ ], -+ "keyMaterial": { -+ "$binary": { -+ "base64": "CiQAIgLj0WyktnB4dfYHo5SLZ41K4ASQrjJUaSzl5vvVH0G12G0SiQEAjlV8XPlbnHDEDFbdTO4QIe8ER2/172U1ouLazG0ysDtFFIlSvWX5ZnZUrRMmp/R2aJkzLXEt/zf8Mn4Lfm+itnjgo5R9K4pmPNvvPKNZX5C16lrPT+aA+rd+zXFSmlMg3i5jnxvTdLHhg3G7Q/Uv1ZIJskKt95bzLoe0tUVzRWMYXLIEcohnQg==", -+ "subType": "00" -+ } -+ }, -+ "creationDate": { -+ "$date": { -+ "$numberLong": "1552949630483" -+ } -+ }, -+ "updateDate": { -+ "$date": { -+ "$numberLong": "1552949630483" -+ } -+ }, -+ "status": { -+ "$numberInt": "0" -+ }, -+ "masterKey": { -+ "provider": "gcp", -+ "projectId": "devprod-drivers", -+ "location": "global", -+ "keyRing": "key-ring-csfle", -+ "keyName": "key-name-csfle" -+ } -+ } -+ ] -+ } -+ ], -+ "tests": [ -+ { -+ "description": "Auto encrypt using access token GCP credentials", -+ "operations": [ -+ { -+ "name": "insertOne", -+ "arguments": { -+ "document": { -+ "_id": 1, -+ "secret": "string0" -+ } -+ }, -+ "object": "coll" -+ } -+ ], -+ "outcome": [ -+ { -+ "documents": [ -+ { -+ "_id": 1, -+ "secret": { -+ "$binary": { -+ "base64": "ARgj/gAAAAAAAAAAAAAAAAACwFd+Y5Ojw45GUXNvbcIpN9YkRdoHDHkR4kssdn0tIMKlDQOLFkWFY9X07IRlXsxPD8DcTiKnl6XINK28vhcGlg==", -+ "subType": "06" -+ } -+ } -+ } -+ ], -+ "collectionName": "coll", -+ "databaseName": "db" -+ } -+ ] -+ }, -+ { -+ "description": "Explicit encrypt using access token GCP credentials", -+ "operations": [ -+ { -+ "name": "encrypt", -+ "object": "clientEncryption", -+ "arguments": { -+ "value": "string0", -+ "opts": { -+ "keyAltName": "my-key", -+ "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" -+ } -+ }, -+ "expectResult": { -+ "$binary": { -+ "base64": "ARgj/gAAAAAAAAAAAAAAAAACwFd+Y5Ojw45GUXNvbcIpN9YkRdoHDHkR4kssdn0tIMKlDQOLFkWFY9X07IRlXsxPD8DcTiKnl6XINK28vhcGlg==", -+ "subType": "06" -+ } -+ } -+ } -+ ] -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-azure-accessToken-type.json b/test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-azure-accessToken-type.json -new file mode 100644 -index 000000000..8fe5c150a ---- /dev/null -+++ b/test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-azure-accessToken-type.json -@@ -0,0 +1,31 @@ -+{ -+ "description": "clientEncryptionOpts-kmsProviders-azure-accessToken-type", -+ "schemaVersion": "1.28", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0" -+ } -+ }, -+ { -+ "clientEncryption": { -+ "id": "clientEncryption0", -+ "clientEncryptionOpts": { -+ "keyVaultClient": "client0", -+ "keyVaultNamespace": "keyvault.datakeys", -+ "kmsProviders": { -+ "azure": { -+ "accessToken": 0 -+ } -+ } -+ } -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "", -+ "operations": [] -+ } -+ ] -+} -diff --git a/test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-gcp-accessToken-type.json b/test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-gcp-accessToken-type.json -new file mode 100644 -index 000000000..2284e26cb ---- /dev/null -+++ b/test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-gcp-accessToken-type.json -@@ -0,0 +1,31 @@ -+{ -+ "description": "clientEncryptionOpts-kmsProviders-gcp-accessToken-type", -+ "schemaVersion": "1.28", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0" -+ } -+ }, -+ { -+ "clientEncryption": { -+ "id": "clientEncryption0", -+ "clientEncryptionOpts": { -+ "keyVaultClient": "client0", -+ "keyVaultNamespace": "keyvault.datakeys", -+ "kmsProviders": { -+ "gcp": { -+ "accessToken": 0 -+ } -+ } -+ } -+ } -+ } -+ ], -+ "tests": [ -+ { -+ "description": "", -+ "operations": [] -+ } -+ ] -+} diff --git a/.evergreen/spec-patch/PYTHON-5993.patch b/.evergreen/spec-patch/PYTHON-5993.patch deleted file mode 100644 index 3880924e83..0000000000 --- a/.evergreen/spec-patch/PYTHON-5993.patch +++ /dev/null @@ -1,94 +0,0 @@ -diff --git a/test/unified-test-format/valid-pass/operator-gte.json b/test/unified-test-format/valid-pass/operator-gte.json -new file mode 100644 -index 000000000..ae69da5c9 ---- /dev/null -+++ b/test/unified-test-format/valid-pass/operator-gte.json -@@ -0,0 +1,88 @@ -+{ -+ "description": "operator-gte", -+ "schemaVersion": "1.29", -+ "createEntities": [ -+ { -+ "client": { -+ "id": "client0", -+ "observeEvents": [ -+ "commandStartedEvent" -+ ] -+ } -+ }, -+ { -+ "database": { -+ "id": "database0", -+ "client": "client0", -+ "databaseName": "database0Name" -+ } -+ }, -+ { -+ "collection": { -+ "id": "collection0", -+ "database": "database0", -+ "collectionName": "coll0" -+ } -+ } -+ ], -+ "initialData": [ -+ { -+ "collectionName": "coll0", -+ "databaseName": "database0Name", -+ "documents": [] -+ } -+ ], -+ "tests": [ -+ { -+ "description": "special gte matching operator", -+ "operations": [ -+ { -+ "name": "insertOne", -+ "object": "collection0", -+ "arguments": { -+ "document": { -+ "_id": 1, -+ "x": 2, -+ "y": 3, -+ "z": 4 -+ } -+ } -+ } -+ ], -+ "expectEvents": [ -+ { -+ "client": "client0", -+ "events": [ -+ { -+ "commandStartedEvent": { -+ "command": { -+ "insert": "coll0", -+ "documents": [ -+ { -+ "_id": { -+ "$$gte": 1 -+ }, -+ "x": { -+ "$$gte": 1.9 -+ }, -+ "y": { -+ "$$gte": { -+ "$numberLong": "3" -+ } -+ }, -+ "z": { -+ "$$gte": 4 -+ } -+ } -+ ] -+ }, -+ "commandName": "insert", -+ "databaseName": "database0Name" -+ } -+ } -+ ] -+ } -+ ] -+ } -+ ] -+} diff --git a/.evergreen/spec-patch/permanent/PYTHON-2673.patch b/.evergreen/spec-patch/permanent/PYTHON-2673.patch deleted file mode 100644 index ea6b185439..0000000000 --- a/.evergreen/spec-patch/permanent/PYTHON-2673.patch +++ /dev/null @@ -1,65 +0,0 @@ -PYMONGO BEHAVES SLIGHTLY DIFFERENTLY -- WE NEED THIS PATCH -diff --git a/test/load_balancer/cursors.json b/test/load_balancer/cursors.json -index 43e4fbb4f..4e2a55fd4 100644 ---- a/test/load_balancer/cursors.json -+++ b/test/load_balancer/cursors.json -@@ -376,7 +376,7 @@ - ] - }, - { -+ "description": "pinned connections are not returned after an network error during getMore", -- "description": "pinned connections are returned after an network error during getMore", - "operations": [ - { - "name": "failPoint", -@@ -440,7 +440,7 @@ - "object": "testRunner", - "arguments": { - "client": "client0", -+ "connections": 1 -- "connections": 0 - } - }, - { -@@ -659,7 +659,7 @@ - ] - }, - { -+ "description": "pinned connections are not returned to the pool after a non-network error on getMore", -- "description": "pinned connections are returned to the pool after a non-network error on getMore", - "operations": [ - { - "name": "failPoint", -@@ -715,7 +715,7 @@ - "object": "testRunner", - "arguments": { - "client": "client0", -+ "connections": 1 -- "connections": 0 - } - }, - { -diff --git a/test/load_balancer/sdam-error-handling.json b/test/load_balancer/sdam-error-handling.json -index 63aabc04d..462fa0aac 100644 ---- a/test/load_balancer/sdam-error-handling.json -+++ b/test/load_balancer/sdam-error-handling.json -@@ -366,6 +366,9 @@ - { - "connectionCreatedEvent": {} - }, -+ { -+ "poolClearedEvent": {} -+ }, - { - "connectionClosedEvent": { - "reason": "error" -@@ -378,9 +375,6 @@ - "connectionCheckOutFailedEvent": { - "reason": "connectionError" - } -- }, -- { -- "poolClearedEvent": {} - } - ] - } diff --git a/.evergreen/spec-patch/permanent/PYTHON-4261.patch b/.evergreen/spec-patch/permanent/PYTHON-4261.patch deleted file mode 100644 index c0b67f202d..0000000000 --- a/.evergreen/spec-patch/permanent/PYTHON-4261.patch +++ /dev/null @@ -1,62 +0,0 @@ -PYMONGO BEHAVES DIFFERENTLY INTENTIONALLY -- WE NEED THIS PATCH -diff --git a/test/server_selection_logging/replica-set.json b/test/server_selection_logging/replica-set.json -index 830b1ea51..5eba784bf 100644 ---- a/test/server_selection_logging/replica-set.json -+++ b/test/server_selection_logging/replica-set.json -@@ -184,7 +184,7 @@ - } - }, - { -- "level": "debug", -+ "level": "info", - "component": "serverSelection", - "data": { - "message": "Waiting for suitable server to become available", -diff --git a/test/server_selection_logging/standalone.json b/test/server_selection_logging/standalone.json -index 830b1ea51..5eba784bf 100644 ---- a/test/server_selection_logging/standalone.json -+++ b/test/server_selection_logging/standalone.json -@@ -191,7 +191,7 @@ - } - }, - { -- "level": "debug", -+ "level": "info", - "component": "serverSelection", - "data": { - "message": "Waiting for suitable server to become available", -diff --git a/test/server_selection_logging/sharded.json b/test/server_selection_logging/sharded.json -index 830b1ea51..5eba784bf 100644 ---- a/test/server_selection_logging/sharded.json -+++ b/test/server_selection_logging/sharded.json -@@ -193,7 +193,7 @@ - } - }, - { -- "level": "debug", -+ "level": "info", - "component": "serverSelection", - "data": { - "message": "Waiting for suitable server to become available", -diff --git a/test/server_selection_logging/sharded.json b/test/server_selection_logging/operation-id.json -index 830b1ea51..5eba784bf 100644 ---- a/test/server_selection_logging/operation-id.json -+++ b/test/server_selection_logging/operation-id.json -@@ -197,7 +197,7 @@ - } - }, - { -- "level": "debug", -+ "level": "info", - "component": "serverSelection", - "data": { - "message": "Waiting for suitable server to become available", -@@ -383,7 +383,7 @@ - } - }, - { -- "level": "debug", -+ "level": "info", - "component": "serverSelection", - "data": { - "message": "Waiting for suitable server to become available", diff --git a/.evergreen/sync-spawn-host.sh b/.evergreen/sync-spawn-host.sh deleted file mode 100755 index 61dd84ec22..0000000000 --- a/.evergreen/sync-spawn-host.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# Synchronize local files to a remote Evergreen spawn host. -set -eu - -if [ -z "$1" ] - then - echo "Must supply a spawn host URL!" -fi - -target=$1 -user=${target%@*} -remote_dir=/home/$user/mongo-python-driver - -echo "Copying files to $target..." -rsync -az -e ssh --exclude '.git' --filter=':- .gitignore' -r . $target:$remote_dir -echo "Copying files to $target... done." -echo "Syncing files to $target..." -# shellcheck disable=SC2034 -fswatch -o . | while read f; do rsync -hazv -e ssh --exclude '.git' --filter=':- .gitignore' -r . $target:/home/$user/mongo-python-driver; done -echo "Syncing files to $target... done." diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs deleted file mode 100644 index eac2263c9a..0000000000 --- a/.git-blame-ignore-revs +++ /dev/null @@ -1,12 +0,0 @@ -# Initial pre-commit reformat -5578999a90e439fbca06fc0ffc98f4d04e96f7b4 -# pyupgrade and ruff -0092b0af79378abf35b6db73a082ecb91af1d973 -# Ruff upgrade from v0.1.3 to v0.15.15 -d88aaa6cfdb05599a79f60a2cbea5513f3788f6c -# Enable ruff rule UP035 -269a552da95439d38038f95794c5012428c07141 -# Enable ruff rules UP007 and UP045 -ce09d45acd3822235d433fde2d7f2f53ddb30dcd -# Enable ruff rule B905 -16d94e2b6ba2e11f93d344b55e9ecb237451d35f diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index e21b87ddd3..0000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @mongodb/dbx-python diff --git a/.github/actions/mod-wsgi-versions/action.yml b/.github/actions/mod-wsgi-versions/action.yml deleted file mode 100644 index 63994a3c14..0000000000 --- a/.github/actions/mod-wsgi-versions/action.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Compute Mod WSGI versions -description: Compute the CPython and MongoDB versions for a Mod WSGI job. -inputs: - index: - description: Row of the version matrix to use. - required: true -outputs: - python-version: - description: The CPython version to test with. - value: ${{ steps.versions.outputs.python-version }} - mongodb-version: - description: The MongoDB version to test against. - value: ${{ steps.versions.outputs.mongodb-version }} -runs: - using: composite - steps: - - id: versions - # The versions come from the Evergreen config's version lists. - shell: bash - env: - INDEX: ${{ inputs.index }} - run: | - uv run --no-project --with 'shrub.py>=3.10.0' python .evergreen/scripts/mod_wsgi_matrix.py --index "$INDEX" >> "$GITHUB_OUTPUT" diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md deleted file mode 100644 index 17f517f8b8..0000000000 --- a/.github/copilot-instructions.md +++ /dev/null @@ -1,48 +0,0 @@ -When reviewing code, focus on: - -## Coding Standards -- All guidelines in [CODING-STANDARDS.md](../CODING-STANDARDS.md). - -## Security Critical Issues -- Check for hardcoded secrets, API keys, or credentials. -- Check for instances of potential method call injection, dynamic code execution, symbol injection or other code injection vulnerabilities. - -## Performance Red Flags -- Spot inefficient loops and algorithmic issues. -- Check for memory leaks and resource cleanup. - -## Code Quality Essentials -- Methods should be focused and appropriately sized. If a method is doing too much, suggest refactorings to split it up. -- Use clear, descriptive naming conventions. -- Avoid encapsulation violations and ensure proper separation of concerns. -- All public classes, modules, and methods should have clear documentation in Sphinx format. - -## PyMongo-specific Concerns -- Do not review files within `pymongo/synchronous` or files in `test/` that also have a file of the same name in `test/asynchronous` unless the reviewed changes include a `_IS_SYNC` statement. PyMongo generates these files from `pymongo/asynchronous` and `test/asynchronous` using `tools/synchro.py`. -- All asynchronous functions must not call any blocking I/O. - -## Review Style -- Be specific and actionable in feedback. -- Explain the "why" behind recommendations. Source findings directly to the guideline that produced them. -- Acknowledge good patterns when you see them. -- Ask clarifying questions when code intent is unclear. - -Always prioritize security vulnerabilities and performance issues that could impact users. - -Always suggest changes to improve readability and testability. For example, this suggestion seeks to make the code more readable, reusable, and testable: - -```python -# Instead of: -if user.email and "@" in user.email and len(user.email) > 5: - submit_button.enabled = True -else: - submit_button.enabled = False - - -# Consider: -def valid_email(email): - return email and "@" in email and len(email) > 5 - - -submit_button.enabled = valid_email(user.email) -``` diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 8f82505fcb..0000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,47 +0,0 @@ -version: 2 -updates: - # GitHub Actions - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" - cooldown: - default-days: 7 - groups: - actions: - patterns: - - "*" - # Python (uv). Routine version updates are handled by the uv-lock-update - # workflow, so a limit of 0 turns off Dependabot version-update PRs here. - # Security updates are exempt from this limit and still open normally. - - package-ecosystem: "uv" - directory: "/" - schedule: - interval: "weekly" - open-pull-requests-limit: 0 - # drivers-evergreen-tools submodule - - package-ecosystem: "gitsubmodule" - directory: "/" - schedule: - interval: "weekly" - cooldown: - default-days: 7 - allow: - - dependency-name: "drivers-evergreen-tools" - # Python (pip). Manages requirements/mod_wsgi.txt only; the other - # requirements files are resolved in uv.lock. - - package-ecosystem: "pip" - directory: "/" - schedule: - interval: "weekly" - exclude-paths: - - "pyproject.toml" - - "requirements.txt" - - "requirements/aws.txt" - - "requirements/docs.txt" - - "requirements/encryption.txt" - - "requirements/gssapi.txt" - - "requirements/ocsp.txt" - - "requirements/snappy.txt" - - "requirements/test.txt" - - "requirements/zstd.txt" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index e9376d1322..0000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,35 +0,0 @@ - - - -PYTHON-XXXX - -## Changes in this PR - - -## Test Plan - - -## Checklist - - -### Checklist for Author -- [ ] Did you update the changelog (if necessary)? -- [ ] Is there test coverage? -- [ ] Is any followup work tracked in a JIRA ticket? If so, add link(s). - -### Checklist for Reviewer -- [ ] Does the title of the PR reference a JIRA Ticket? -- [ ] Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?) -- [ ] Is all relevant documentation (README or docstring) updated? diff --git a/.github/reviewers.txt b/.github/reviewers.txt deleted file mode 100644 index 9e38ee71b5..0000000000 --- a/.github/reviewers.txt +++ /dev/null @@ -1,5 +0,0 @@ -# List of reviewers for auto-assignment of reviews. -caseyclements -blink1073 -Jibola -NoahStapp diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 29d0f17113..0000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [ "main", "v*"] - tags: ['*'] - pull_request: - workflow_call: - inputs: - ref: - required: true - type: string - schedule: - - cron: '17 10 * * 2' - -concurrency: - group: codeql-${{ github.ref }} - cancel-in-progress: true - -jobs: - analyze: - name: Analyze (${{ matrix.language }}) - runs-on: "ubuntu-latest" - timeout-minutes: 360 - permissions: - security-events: write - - strategy: - fail-fast: false - matrix: - include: - - language: c-cpp - build-mode: manual - manual-build-command: pip install -e . - - language: python - build-mode: none - - language: actions - build-mode: none - steps: - - uses: mongodb-labs/drivers-github-tools/codeql@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - language: ${{ matrix.language }} - build-mode: ${{ matrix.build-mode }} - manual-build-command: ${{ matrix.manual-build-command }} - ref: ${{ inputs.ref }} - config: | - paths-ignore: - - 'doc/**' - - 'tools/**' - - 'test/**' diff --git a/.github/workflows/create-release-branch.yml b/.github/workflows/create-release-branch.yml deleted file mode 100644 index abcf095c04..0000000000 --- a/.github/workflows/create-release-branch.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: Create Release Branch - -on: - workflow_dispatch: - inputs: - branch_name: - description: The name of the new branch - required: true - version: - description: The version to set on the branch - required: true - base_ref: - description: The base reference for the branch - push_changes: - description: Whether to push the changes - default: "true" - -concurrency: - group: create-branch-${{ github.ref }} - cancel-in-progress: true - -defaults: - run: - shell: bash -eux {0} - -jobs: - create-branch: - environment: release - runs-on: ubuntu-latest - permissions: - id-token: write - contents: write - outputs: - version: ${{ steps.pre-publish.outputs.version }} - steps: - - name: Create app token - id: app-token - uses: actions/create-github-app-token@v3 - with: - app-id: ${{ vars.APP_ID }} - private-key: ${{ secrets.APP_PRIVATE_KEY }} - permission-contents: write - permission-pull-requests: write - permission-workflows: write - - name: Store token - shell: bash -eu {0} - # zizmor: ignore[template-injection] GH_TOKEN is a GitHub App installation token, not attacker-controllable - run: echo "GH_TOKEN=${{ steps.app-token.outputs.token }}" >> "$GITHUB_ENV" - - uses: actions/checkout@v7.0.1 - with: - ref: ${{ github.ref }} - token: ${{ env.GH_TOKEN }} - fetch-depth: 1 - persist-credentials: false - - name: Configure git auth for push - shell: bash -eu {0} - run: | - auth_header=$(printf 'x-access-token:%s' "${GH_TOKEN}" | base64 -w0) - git config --local http.https://github.com/.extraheader "AUTHORIZATION: basic ${auth_header}" - - uses: mongodb-labs/drivers-github-tools/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} - aws_region_name: ${{ vars.AWS_REGION_NAME }} - aws_secret_id: ${{ secrets.AWS_SECRET_ID }} - artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }} - - name: Get hatch - run: pip install hatch - - uses: mongodb-labs/drivers-github-tools/create-branch@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - id: create-branch - with: - branch_name: ${{ inputs.branch_name }} - version: ${{ inputs.version }} - base_ref: ${{ inputs.base_ref }} - push_changes: ${{ inputs.push_changes }} - version_bump_script: hatch version - evergreen_project: mongo-python-driver-release - release_workflow_path: ./.github/workflows/release-python.yml diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml deleted file mode 100644 index ca87b82c72..0000000000 --- a/.github/workflows/dist.yml +++ /dev/null @@ -1,153 +0,0 @@ -name: Python Dist - -on: - push: - tags: - - "[0-9]+.[0-9]+.[0-9]+" - - "[0-9]+.[0-9]+.[0-9]+.post[0-9]+" - - "[0-9]+.[0-9]+.[0-9]+[a-b][0-9]+" - - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+" - workflow_dispatch: - pull_request: - workflow_call: - inputs: - ref: - required: true - type: string - -concurrency: - group: dist-${{ github.ref }} - cancel-in-progress: true - -defaults: - run: - shell: bash -eux {0} - -jobs: - build_wheels: - name: Build wheels for ${{ matrix.buildplat[1] }} - runs-on: ${{ matrix.buildplat[0] }} - strategy: - # Ensure that a wheel builder finishes even if another fails - fail-fast: false - matrix: - # Github Actions doesn't support pairing matrix values together, let's improvise - # https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 - buildplat: - - [ubuntu-latest, "manylinux_x86_64", "cp3*-manylinux_x86_64"] - - [ubuntu-latest, "manylinux_aarch64", "cp3*-manylinux_aarch64"] - - [ubuntu-latest, "manylinux_ppc64le", "cp3*-manylinux_ppc64le"] - - [ubuntu-latest, "manylinux_s390x", "cp3*-manylinux_s390x"] - - [ubuntu-24.04, "manylinux_i686", "cp3*-manylinux_i686"] # ubuntu-latest blocks the legacy DNS calls that i686 uses - - [windows-2022, "win_amd6", "cp3*-win_amd64"] - - [windows-2022, "win32", "cp3*-win32"] - - [windows-11-arm, "win_arm64", "cp3*-win_arm64"] - - [macos-15, "macos", "cp*-macosx_*"] - - steps: - - name: Checkout pymongo - uses: actions/checkout@v7.0.1 - with: - fetch-depth: 0 - persist-credentials: false - ref: ${{ inputs.ref }} - - - uses: actions/setup-python@v7.1.0 - with: - cache: 'pip' - python-version: 3.11 - cache-dependency-path: 'pyproject.toml' - allow-prereleases: true - - - name: Set up QEMU - if: runner.os == 'Linux' - uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0 - with: - # setup-qemu-action by default uses `tonistiigi/binfmt:latest` image, - # which is out of date. This causes seg faults during build. - # Here we manually fix the version. - image: tonistiigi/binfmt:qemu-v8.1.5 - platforms: all - - - name: Install cibuildwheel - # Note: the default manylinux is manylinux_2_28 - run: | - python -m pip install -U pip - python -m pip install "cibuildwheel>=4.2.0,<5" - - - name: Build wheels - env: - CIBW_BUILD: ${{ matrix.buildplat[2] }} - # Strip any in-place C extensions from previous builds - # so they don't leak into the next wheel. - CIBW_BEFORE_BUILD: python ./tools/clean.py - run: python -m cibuildwheel --output-dir wheelhouse - - - name: Assert all versions in wheelhouse - if: ${{ ! startsWith(matrix.buildplat[1], 'macos') }} - run: | - ls wheelhouse/*cp311*.whl - ls wheelhouse/*cp312*.whl - ls wheelhouse/*cp313*.whl - ls wheelhouse/*cp314*.whl - # The free-threaded wheel's interpreter tag is also cp315, so match - # the standard wheel on its interpreter-abi boundary. - ls wheelhouse/*cp315-cp315-*.whl - # Free-threading builds: - ls wheelhouse/*cp314t*.whl - ls wheelhouse/*cp315t*.whl - - - uses: actions/upload-artifact@v7 - with: - name: wheel-${{ matrix.buildplat[1] }} - path: ./wheelhouse/*.whl - if-no-files-found: error - - make_sdist: - name: Make SDist - runs-on: macos-latest - steps: - - uses: actions/checkout@v7.0.1 - with: - fetch-depth: 0 - persist-credentials: false - ref: ${{ inputs.ref }} - - - uses: actions/setup-python@v7.1.0 - with: - # Build sdist on lowest supported Python - python-version: "3.11" - - - name: Build SDist - run: | - set -ex - python -m pip install -U pip build - python -m build --sdist . - - - name: Test SDist - run: | - python -m pip install dist/*.gz - cd .. - python -c "from pymongo import has_c; assert has_c()" - - - uses: actions/upload-artifact@v7 - with: - name: "sdist" - path: ./dist/*.tar.gz - - collect_dist: - runs-on: ubuntu-latest - needs: [build_wheels, make_sdist] - name: Download Wheels - steps: - - name: Download all workflow run artifacts - uses: actions/download-artifact@v8 - - name: Flatten directory - working-directory: . - run: | - find . -mindepth 2 -type f -exec mv {} . \; - find . -type d -empty -delete - - uses: actions/upload-artifact@v7 - with: - name: all-dist-${{ github.run_id }} - path: "./*" diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml deleted file mode 100644 index 74e682bba9..0000000000 --- a/.github/workflows/release-python.yml +++ /dev/null @@ -1,111 +0,0 @@ -name: Release - -on: - workflow_dispatch: - inputs: - following_version: - description: "The post (dev) version to set" - dry_run: - description: "Dry Run?" - default: false - type: boolean - schedule: - - cron: '30 5 * * *' - -env: - # Changes per repo - PRODUCT_NAME: PyMongo - # Changes per branch - EVERGREEN_PROJECT: mongo-python-driver - # Constant - # inputs will be empty on a scheduled run. so, we only set dry_run - # to 'false' when the input is set to 'false'. - DRY_RUN: ${{ ! contains(inputs.dry_run, 'false') }} - FOLLOWING_VERSION: ${{ inputs.following_version || '' }} - -defaults: - run: - shell: bash -eux {0} - -jobs: - pre-publish: - environment: release - runs-on: ubuntu-latest - if: github.repository_owner == 'mongodb' || github.event_name == 'workflow_dispatch' - permissions: - id-token: write - contents: write - outputs: - version: ${{ steps.pre-publish.outputs.version }} - steps: - - uses: mongodb-labs/drivers-github-tools/secure-checkout@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - app_id: ${{ vars.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} - - uses: mongodb-labs/drivers-github-tools/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} - aws_region_name: ${{ vars.AWS_REGION_NAME }} - aws_secret_id: ${{ secrets.AWS_SECRET_ID }} - - uses: mongodb-labs/drivers-github-tools/python/pre-publish@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - id: pre-publish - with: - dry_run: ${{ env.DRY_RUN }} - - build-dist: - needs: [pre-publish] - uses: ./.github/workflows/dist.yml - with: - ref: ${{ needs.pre-publish.outputs.version }} - - static-scan: - needs: [pre-publish] - uses: ./.github/workflows/codeql.yml - permissions: - security-events: write - with: - ref: ${{ needs.pre-publish.outputs.version }} - - publish: - needs: [build-dist, static-scan] - name: Upload release to PyPI - runs-on: ubuntu-latest - environment: release - permissions: - id-token: write - steps: - - name: Download all the dists - uses: actions/download-artifact@v8 - with: - name: all-dist-${{ github.run_id }} - path: dist/ - - name: Publish package distributions to PyPI - if: startsWith(env.DRY_RUN, 'false') - uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 release/v1 - - post-publish: - needs: [publish] - runs-on: ubuntu-latest - environment: release - permissions: - id-token: write - contents: write - attestations: write - security-events: write - steps: - - uses: mongodb-labs/drivers-github-tools/secure-checkout@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - app_id: ${{ vars.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} - - uses: mongodb-labs/drivers-github-tools/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} - aws_region_name: ${{ vars.AWS_REGION_NAME }} - aws_secret_id: ${{ secrets.AWS_SECRET_ID }} - - uses: mongodb-labs/drivers-github-tools/python/post-publish@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - following_version: ${{ env.FOLLOWING_VERSION }} - product_name: ${{ env.PRODUCT_NAME }} - evergreen_project: ${{ env.EVERGREEN_PROJECT }} - token: ${{ github.token }} - dry_run: ${{ env.DRY_RUN }} diff --git a/.github/workflows/sbom.yml b/.github/workflows/sbom.yml deleted file mode 100644 index 47f2e40d0f..0000000000 --- a/.github/workflows/sbom.yml +++ /dev/null @@ -1,105 +0,0 @@ -name: Generate SBOM - -# This workflow uses cyclonedx-py and publishes an sbom.json artifact. -# It runs on manual trigger or when package files change on main branch, -# and creates a PR with the updated SBOM. -# Internal documentation: go/sbom-scope - -on: - workflow_dispatch: {} - push: - branches: ['main'] - paths: - - 'requirements.txt' - - 'requirements/**.txt' - - '!requirements/docs.txt' - - '!requirements/test.txt' - - '!requirements/mod_wsgi.txt' - -permissions: - contents: write - pull-requests: write - -jobs: - sbom: - name: Generate SBOM and Create PR - runs-on: ubuntu-latest - concurrency: - group: sbom-${{ github.ref }} - cancel-in-progress: false - - steps: - - name: Checkout repository - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - - name: Set up Python - uses: actions/setup-python@v7.1.0 - with: - python-version: "3.11" - - - name: Generate SBOM - run: | - python -m venv .venv - source .venv/bin/activate - python tools/generate_sbom_requirements.py - pip install -r sbom-requirements.txt - pip install . - pip uninstall -y pip setuptools - deactivate - python -m venv .venv-sbom - source .venv-sbom/bin/activate - pip install cyclonedx-bom==7.2.1 - cyclonedx-py environment --spec-version 1.5 --output-format JSON --output-file sbom.json .venv - # Add PURL for pymongo (local package doesn't get PURL automatically) - jq '(.components[] | select(.name == "pymongo" and .purl == null)) |= (. + {purl: ("pkg:pypi/pymongo@" + .version)})' sbom.json > sbom.tmp.json && mv sbom.tmp.json sbom.json - - - name: Download CycloneDX CLI - run: | - curl -L -s -o /tmp/cyclonedx "https://github.com/CycloneDX/cyclonedx-cli/releases/download/v0.29.1/cyclonedx-linux-x64" - chmod +x /tmp/cyclonedx - - - name: Validate SBOM - run: /tmp/cyclonedx validate --input-file sbom.json --fail-on-errors - - - name: Cleanup - if: always() - run: rm -rf .venv .venv-sbom sbom-requirements.txt - - - name: Upload SBOM artifact - uses: actions/upload-artifact@v7 - with: - name: sbom - path: sbom.json - if-no-files-found: error - - - name: Create Pull Request - uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: 'chore: Update SBOM after dependency changes' - branch: auto-update-sbom-${{ github.run_id }} - delete-branch: true - title: 'Automation: Update SBOM' - body: | - ## Automated SBOM Update - - This PR was automatically generated because dependency manifest files changed. - - ### Changes - - Updated `sbom.json` to reflect current dependencies - - ### Verification - The SBOM was generated using cyclonedx-py v7.2.1 with the current Python environment. - - ### Triggered by - - Commit: ${{ github.sha }} - - Workflow run: ${{ github.run_id }} - - --- - _This PR was created automatically by the [SBOM workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})_ - labels: | - sbom - automated - dependencies diff --git a/.github/workflows/test-mod-wsgi.yml b/.github/workflows/test-mod-wsgi.yml deleted file mode 100644 index 8225df13cd..0000000000 --- a/.github/workflows/test-mod-wsgi.yml +++ /dev/null @@ -1,181 +0,0 @@ -name: Mod WSGI Tests - -on: - push: - branches: ["main", "v**"] - paths: - - ".evergreen/scripts/mod_wsgi_*" - - ".evergreen/scripts/mod_wsgi.sh" - - ".evergreen/scripts/dispatch.sh" - - ".evergreen/scripts/generate_config_utils.py" - - ".github/workflows/test-mod-wsgi.yml" - - ".github/actions/mod-wsgi-*/**" - - "test/mod_wsgi_test/**" - - "pymongo/**" - - "bson/**" - - "justfile" - - "pyproject.toml" - - "uv.lock" - - "requirements/mod_wsgi.txt" - pull_request: - paths: - - ".evergreen/scripts/mod_wsgi_*" - - ".evergreen/scripts/mod_wsgi.sh" - - ".evergreen/scripts/dispatch.sh" - - ".evergreen/scripts/generate_config_utils.py" - - ".github/workflows/test-mod-wsgi.yml" - - ".github/actions/mod-wsgi-*/**" - - "test/mod_wsgi_test/**" - - "pymongo/**" - - "bson/**" - - "justfile" - - "pyproject.toml" - - "uv.lock" - - "requirements/mod_wsgi.txt" - workflow_dispatch: - -concurrency: - group: mod-wsgi-${{ github.ref }} - cancel-in-progress: true - -defaults: - run: - shell: bash -eux {0} - -permissions: - contents: read - -jobs: - mod_wsgi_min_deps: - # Exercise the minimum dependency versions against Fedora's httpd, so the - # mod_wsgi tests cover httpd in addition to Ubuntu's apache2. - runs-on: ubuntu-latest - name: Mod WSGI Min Deps - container: - # fedora:latest, pinned by digest; bump periodically. - image: fedora@sha256:43b29f65a41eb9c35e1cd5323e3bdf3b655c2357a9f4f1ff2f9c2798e5045d80 - env: - # Install the interpreter where the Apache user can read it. - UV_PYTHON_INSTALL_DIR: /opt/uv-python - # The test rounds run against the lowest direct dependency versions - # installed below; a resync would reconcile them back to the lockfile. - JUST_NO_RESYNC: "1" - steps: - # actions/checkout needs git, which fedora:latest does not include. - - name: Install git - run: dnf install -y git - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 - - name: Install just - run: | - uv tool install rust-just - echo "$HOME/.local/bin" >> "$GITHUB_PATH" - - name: Install Apache - # jq and curl are needed to pick the MongoDB download. - run: dnf install -y httpd httpd-devel jq curl - - id: versions - uses: $/.github/actions/mod-wsgi-versions - with: - index: 0 - - name: Install Python - env: - PYTHON_VERSION: ${{ steps.versions.outputs.python-version }} - run: | - uv python install "$PYTHON_VERSION" - echo "UV_PYTHON=$PYTHON_VERSION" >> "$GITHUB_ENV" - - name: Install dependencies - run: | - export PYMONGO_C_EXT_MUST_BUILD=1 - just install - # just install skips the sync when uv is already set up. - uv sync --refresh-package pymongo - uv run --no-sync python tools/fail_if_no_c.py - # Exercise the mod_wsgi>=4.9.4 lower bound. - uv pip install -e ".[test]" -r requirements/mod_wsgi.txt --resolution=lowest-direct --force-reinstall - - name: Start MongoDB - # Fedora is not a supported MongoDB platform, so install the RHEL build - # directly instead of using the drivers-evergreen-tools action, which - # relies on actions/setup-python and does not run on Fedora. - env: - MONGODB_VERSION: ${{ steps.versions.outputs.mongodb-version }} - run: | - ARCH=$(uname -m) - URL=$(curl -fsSL https://downloads.mongodb.org/current.json | jq -r --arg v "$MONGODB_VERSION." --arg a "$ARCH" ' - .versions[] | select(.current and .production_release) | select(.version | startswith($v)) | - .downloads[] | select(.target=="rhel90" and .arch==$a) | .archive.url' | grep -v enterprise | head -1) - curl -fsSL "$URL" -o /tmp/mongo.tgz - tar -xz -C /tmp --strip-components=1 -f /tmp/mongo.tgz - mkdir -p /tmp/db - /tmp/bin/mongod --replSet rs0 --bind_ip 127.0.0.1 --port 27017 --dbpath /tmp/db --fork --logpath /tmp/mongod.log - # --no-sync: a sync would reconcile the lowest-direct dependency - # versions installed above back to the lockfile. - uv run --no-sync python -c " - from pymongo import MongoClient - client = MongoClient('127.0.0.1:27017', directConnection=True) - client.admin.command('replSetInitiate', {'_id': 'rs0', 'members': [{'_id': 0, 'host': '127.0.0.1:27017'}]}) - MongoClient().admin.command('hello') - " - - name: Run standalone tests - run: | - just setup-tests mod_wsgi standalone - just run-tests - - name: Teardown standalone - if: always() - run: just teardown-tests - - name: Run embedded tests - run: | - just setup-tests mod_wsgi embedded - just run-tests - - name: Teardown embedded - if: always() - run: just teardown-tests - - mod_wsgi_latest: - runs-on: ubuntu-22.04 - name: Mod WSGI Latest - steps: - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 - - id: versions - uses: $/.github/actions/mod-wsgi-versions - with: - index: 1 - - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - python-version: ${{ steps.versions.outputs.python-version }} - - name: Install Apache - run: | - sudo apt-get update - sudo apt-get install -y apache2 apache2-dev - - name: Install dependencies - run: | - export PYMONGO_C_EXT_MUST_BUILD=1 - just install - # just install skips the sync when uv is already set up. - uv sync --refresh-package pymongo - uv pip install -r requirements/mod_wsgi.txt - uv run --no-sync python tools/fail_if_no_c.py - - id: setup-mongodb - uses: mongodb-labs/drivers-evergreen-tools@979453df1aaeefd176db3fdfe696779ddd03fd9e # v1.5.0 - with: - version: ${{ steps.versions.outputs.mongodb-version }} - topology: "replica_set" - - name: Run standalone tests - run: | - just setup-tests mod_wsgi standalone - just run-tests - - name: Teardown standalone - if: always() - run: just teardown-tests - - name: Run embedded tests - run: | - just setup-tests mod_wsgi embedded - just run-tests - - name: Teardown embedded - if: always() - run: just teardown-tests diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml deleted file mode 100644 index 7ab185c6fa..0000000000 --- a/.github/workflows/test-python.yml +++ /dev/null @@ -1,290 +0,0 @@ -name: Python Tests - -on: - push: - branches: ["main", "v**"] - pull_request: - workflow_dispatch: - -concurrency: - group: tests-${{ github.ref }} - cancel-in-progress: true - -defaults: - run: - shell: bash -eux {0} - -permissions: - contents: read - -jobs: - - static: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - python-version: "3.11" - # Runs before the install so a stale lock fails in seconds rather than - # after the build and typecheck. - - name: Check lockfile is up to date - run: | - uv lock --check - - name: Install Python dependencies - run: | - just install - - name: Run linters - run: | - just lint-manual - - name: Run compilation - run: | - export PYMONGO_C_EXT_MUST_BUILD=1 - pip install -v -e . - python tools/fail_if_no_c.py - - name: Run typecheck - run: | - just typing - - name: Run synchro smoke test - run: | - uv run --extra test --with unasync pytest tools/test_synchro.py -v --override-ini="addopts=" - - name: Validate pyproject.toml - run: | - uvx --from 'validate-pyproject[all]' validate-pyproject pyproject.toml - - name: Check package metadata - run: | - uv build - uvx twine check --strict dist/* - - run: | - sudo apt-get install -y cppcheck - - run: | - cppcheck --force bson - cppcheck pymongo - - build: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - # Tests currently only pass on ubuntu on GitHub Actions. - os: [ubuntu-latest] - python-version: ["3.11", "3.13t", "3.15"] - mongodb-version: ["8.0"] - - name: Python ${{ matrix.python-version }}-${{ matrix.os }} - steps: - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - # The beta Python here relies on the action's prerelease default. - python-version: ${{ matrix.python-version }} - - id: setup-mongodb - uses: mongodb-labs/drivers-evergreen-tools@979453df1aaeefd176db3fdfe696779ddd03fd9e # v1.5.0 - with: - version: "${{ matrix.mongodb-version }}" - - name: Run tests - run: uv run --extra test pytest -v - - coverage: - # This enables a coverage report for a given PR, which will be augmented by - # the combined codecov report uploaded in Evergreen. - runs-on: ubuntu-latest - - name: Coverage - steps: - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - submodules: true - - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - python-version: "3.11" - - id: setup-mongodb - uses: mongodb-labs/drivers-evergreen-tools@979453df1aaeefd176db3fdfe696779ddd03fd9e # v1.5.0 - with: - version: "8.0" - - name: Setup tests - run: COVERAGE=1 just setup-tests - - name: Run tests - run: just run-tests - - name: Generate xml report - run: uv tool run --with "coverage[toml]" coverage xml - - name: Upload test results to Codecov - uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - doctest: - runs-on: ubuntu-latest - name: DocTest - steps: - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - submodules: true - - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - python-version: "3.11" - - name: Install dependencies - run: just install - - id: setup-mongodb - uses: mongodb-labs/drivers-evergreen-tools@979453df1aaeefd176db3fdfe696779ddd03fd9e # v1.5.0 - with: - version: "8.0" - - name: Run tests - run: | - just setup-tests doctest - just run-tests - - docs: - name: Docs Checks - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - python-version: "3.11" - - name: Install dependencies - run: just install - - name: Build docs - run: just docs - - typing: - name: Typing Tests - runs-on: ubuntu-latest - strategy: - matrix: - python: ["3.11"] - steps: - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - python-version: "${{matrix.python}}" - - name: Install dependencies - run: just install - - name: Run typecheck - run: | - just typing - - integration_tests: - runs-on: ubuntu-latest - name: Integration Tests - steps: - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - submodules: true - - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - python-version: "3.11" - - name: Install dependencies - run: just install - - id: setup-mongodb - uses: mongodb-labs/drivers-evergreen-tools@979453df1aaeefd176db3fdfe696779ddd03fd9e # v1.5.0 - - name: Run tests - run: | - just integration-tests - - id: setup-mongodb-ssl - uses: mongodb-labs/drivers-evergreen-tools@979453df1aaeefd176db3fdfe696779ddd03fd9e # v1.5.0 - with: - ssl: true - - name: Run tests - run: | - just integration-tests - - make_sdist: - runs-on: ubuntu-latest - name: "Make an sdist" - steps: - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - uses: actions/setup-python@v7.1.0 - with: - cache: 'pip' - cache-dependency-path: 'pyproject.toml' - # Build sdist on lowest supported Python - python-version: "3.11" - - name: Build SDist - shell: bash - run: | - pip install build - python -m build --sdist - - uses: actions/upload-artifact@v7 - with: - name: "sdist" - path: dist/*.tar.gz - - test_sdist: - runs-on: ubuntu-latest - needs: [make_sdist] - name: Install from SDist and Test - timeout-minutes: 20 - steps: - - name: Download sdist - uses: actions/download-artifact@v8 - with: - path: sdist/ - - name: Unpack SDist - shell: bash - run: | - cd sdist - ls - mkdir test - tar --strip-components=1 -zxf *.tar.gz -C ./test - ls test - - uses: actions/setup-python@v7.1.0 - with: - cache: 'pip' - cache-dependency-path: 'sdist/test/pyproject.toml' - # Test sdist on lowest supported Python - python-version: "3.11" - - id: setup-mongodb - uses: mongodb-labs/drivers-evergreen-tools@979453df1aaeefd176db3fdfe696779ddd03fd9e # v1.5.0 - - name: Run connect test from sdist - shell: bash - run: | - cd sdist/test - ls - which python - pip install -e ".[test]" - PYMONGO_MUST_CONNECT=1 pytest -v -k client_context - - test_minimum: - permissions: - contents: read - runs-on: ubuntu-latest - name: Test minimum dependencies and Python - steps: - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - name: Install Python tooling - uses: mongodb-labs/drivers-github-tools/python/setup@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - python-version: "3.11" - - id: setup-mongodb - uses: mongodb-labs/drivers-evergreen-tools@979453df1aaeefd176db3fdfe696779ddd03fd9e # v1.5.0 - with: - version: "8.0" - - name: Run tests - shell: bash - run: | - uv venv - source .venv/bin/activate - uv pip install -e ".[test]" --resolution=lowest-direct --force-reinstall - pytest -v test/test_srv_polling.py test/test_dns.py test/asynchronous/test_srv_polling.py test/asynchronous/test_dns.py diff --git a/.github/workflows/uv-lock-update.yml b/.github/workflows/uv-lock-update.yml deleted file mode 100644 index 61744bbcb4..0000000000 --- a/.github/workflows/uv-lock-update.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: uv Lock Update - -on: - schedule: - # Tuesdays at 12:00 UTC. - - cron: "0 12 * * 2" - workflow_dispatch: - inputs: - dry_run: - description: "Run without pushing or opening a pull request" - type: boolean - default: false - -permissions: - contents: read - # A live run uses the app token, but a dry run looks up the existing pull - # request with github.token, so that read has to be granted here. - pull-requests: read - -concurrency: - group: uv-lock-update - cancel-in-progress: false - -jobs: - update: - name: Update uv.lock - runs-on: ubuntu-latest - environment: automation - if: github.repository_owner == 'mongodb' || github.event_name == 'workflow_dispatch' - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - name: Install uv - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 - with: - python-version: "3.11" - - uses: mongodb-labs/drivers-github-tools/python/uv-lock-update@99b1cbd729bc83bf7fc74e1b2a97fffad3d65d7b # v3.1.1 - with: - app_id: ${{ vars.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} - dry_run: ${{ inputs.dry_run || 'false' }} diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml deleted file mode 100644 index f4e933269f..0000000000 --- a/.github/workflows/zizmor.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: GitHub Actions Security Analysis with zizmor 🌈 - -on: - push: - branches: ["main"] - pull_request: - branches: ["**"] - -jobs: - zizmor: - name: zizmor latest via Cargo - runs-on: ubuntu-latest - permissions: - security-events: write - steps: - - name: Checkout repository - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - name: Run zizmor 🌈 - uses: zizmorcore/zizmor-action@53290badfa369cb0bf7ad16342cb62c2fa47ac7b # v0.8.0 diff --git a/.github/zizmor.yml b/.github/zizmor.yml deleted file mode 100644 index 2a69f0dd1a..0000000000 --- a/.github/zizmor.yml +++ /dev/null @@ -1,7 +0,0 @@ -rules: - unpinned-uses: - config: - policies: - actions/*: ref-pin - mongodb-labs/drivers-github-tools/*: hash-pin - mongodb-labs/drivers-evergreen-tools: hash-pin diff --git a/.gitignore b/.gitignore deleted file mode 100644 index c113d3ec21..0000000000 --- a/.gitignore +++ /dev/null @@ -1,58 +0,0 @@ -*~ -*#* -.DS* -*.cm -*.class -*.pyc -*.pyd -build/ -doc/_build/ -dist/ -tools/settings.py -pymongo.egg-info/ -*.so -*.egg* -.tox -mongocryptd.pid -.idea/ -.vscode/ -.nova/ -.temp/ -venv/ -.local/ -secrets-export.sh -libmongocrypt.tar.gz -libmongocrypt/ -.venv -expansion.yml -*expansions.yml -.evergreen/scripts/env.sh -.evergreen/scripts/test-env.sh -specifications/ -results.json -.synchro-modified -.evergreen/atlas_x509_dev_client_certificate.pem -.evergreen/atlas_x509_sfp_client_certificate.pem - -# Lambda temp files -test/lambda/.aws-sam -test/lambda/mongodb/pymongo/* -test/lambda/mongodb/gridfs/* -test/lambda/mongodb/bson/* -test/lambda/*.json - -# test results and logs -xunit-results/ -coverage.xml -server.log -.coverage -test-results.json -access_log -error_log - -# AI-assistant review workflow logs (kept untracked) -/REVIEW_STATE.md -/REVIEW.md - -# Fuzzing (PYTHON-4232) -/fuzz-scratch/ diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index d89986aa20..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "drivers-evergreen-tools"] - path = drivers-evergreen-tools - url = https://github.com/mongodb-labs/drivers-evergreen-tools.git diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 27e4e2bd02..0000000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,131 +0,0 @@ -exclude: ^drivers-evergreen-tools/ - -repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 - hooks: - - id: check-added-large-files - exclude: ^uv\.lock$ - - id: check-case-conflict - - id: check-toml - - id: check-json - - id: check-yaml - exclude: template.yaml - - id: debug-statements - - id: end-of-file-fixer - exclude: WHEEL - exclude_types: [json] - - id: forbid-new-submodules - - id: trailing-whitespace - exclude: .patch - exclude_types: [json] - -- repo: local - hooks: - - id: ruff - name: ruff - entry: uv run --group lint ruff check --fix --show-fixes - language: system - types_or: [python, pyi] - require_serial: true - - id: ruff-format - name: ruff-format - entry: uv run --group lint ruff format - language: system - types_or: [python, pyi] - require_serial: true - -- repo: local - hooks: - - id: synchro - name: synchro - entry: uv run --group unasync ./tools/synchro.py - language: system - require_serial: true - always_run: true - - id: synchro-stage-files - name: synchro-stage-files - entry: bash -c 'if [ -s .synchro-modified ]; then xargs git add < .synchro-modified || true; fi' - language: system - require_serial: true - always_run: true - pass_filenames: false - -- repo: https://github.com/pre-commit/pygrep-hooks - rev: "v1.10.0" - hooks: - - id: rst-backticks - - id: rst-directive-colons - - id: rst-inline-touching-normal - -- repo: https://github.com/rstcheck/rstcheck - rev: v6.2.0 - hooks: - - id: rstcheck - additional_dependencies: [sphinx] - args: ["--ignore-directives=doctest,testsetup,todo,automodule","--ignore-substitutions=release", "--report-level=error"] - -# We use the Python version instead of the original version which seems to require Docker -# https://github.com/koalaman/shellcheck-precommit -- repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.9.0.6 - hooks: - - id: shellcheck - name: shellcheck - args: ["--severity=warning"] - stages: [manual] - -- repo: https://github.com/PyCQA/doc8 - rev: v1.1.1 - hooks: - - id: doc8 - args: ["--ignore=D001"] # ignore line length - stages: [manual] - -- repo: https://github.com/sirosen/check-jsonschema - rev: 0.37.2 - hooks: - - id: check-github-workflows - - id: check-github-actions - - id: check-dependabot - -- repo: https://github.com/ariebovenberg/slotscheck - rev: v0.19.0 - hooks: - - id: slotscheck - files: \.py$ - exclude: "^(test|tools)/" - stages: [manual] - args: ["--no-strict-imports"] - -- repo: https://github.com/codespell-project/codespell - rev: "v2.2.6" - hooks: - - id: codespell - # Examples of errors or updates to justify the exceptions: - # - test/test_on_demand_csfle.py:44: FLE ==> FILE - # - test/test_bson.py:1043: fo ==> of, for, to, do, go - # - test/bson_corpus/decimal128-4.json:98: Infinit ==> Infinite - # - test/test_bson.py:267: isnt ==> isn't - # - test/versioned-api/crud-api-version-1-strict.json:514: nin ==> inn, min, bin, nine - # - test/test_client.py:188: te ==> the, be, we, to - args: ["-L", "fle,fo,infinit,isnt,nin,te,aks"] - exclude: ^pymongo/public_suffix_list\.dat$ - -- repo: local - hooks: - - id: executable-shell - name: executable-shell - entry: chmod +x - language: system - types: [shell] - exclude: | - (?x)( - .evergreen/retry-with-backoff.sh - ) - - id: generate-config - name: generate-config - entry: .evergreen/scripts/generate-config.sh - language: python - require_serial: true - additional_dependencies: ["pytest", "pytest-asyncio", "shrub.py>=3.10.0", "pyyaml>=6.0.2"] diff --git a/.readthedocs.yaml b/.readthedocs.yaml deleted file mode 100644 index a3693074f6..0000000000 --- a/.readthedocs.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# .readthedocs.yaml -# Read the Docs configuration file -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details - -# Required -version: 2 - -# Build documentation in the doc/ directory with Sphinx -sphinx: - configuration: doc/conf.py - fail_on_warning: true - -# Set the version of Python and requirements required to build the docs. -python: - install: - # Install pymongo itself. - - method: pip - path: . - - requirements: requirements/docs.txt - -build: - os: ubuntu-22.04 - tools: - python: "3.11" diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index 1018b63902..0000000000 --- a/AGENTS.md +++ /dev/null @@ -1,50 +0,0 @@ -# AGENTS.md - PyMongo (mongo-python-driver) - -## Overview -Official Python driver for MongoDB. - -## Tech Stack -- **Task runner:** `just` (Justfile at repo root) -- **Linter/formatter:** `ruff` via pre-commit -- **Type checker:** `mypy` (strict) -- **Docs:** Sphinx / reStructuredText; use Sphinx docstring format for all docstrings - -> **Never** run `pip install bson`. PyMongo ships its own `bson`; the PyPI `bson` package silently breaks things. - -## Project Structure -- `pymongo/asynchronous/` — async driver (AsyncMongoClient, AsyncCollection, etc.) -- `pymongo/synchronous/` — sync driver (MongoClient, Collection, etc.) generated from `pymongo/asynchronous/` using `just synchro` -- `bson/` — BSON implementation -- `gridfs/` — GridFS API -- `test/asynchronous/` — async test suite -- `test/` — sync test suite (generated from `test/asynchronous/` by `just synchro`) and shared test suite -- `test/unified_format/` — cross-driver spec tests (Unified Test Format) -- `fuzz/` — BSON fuzz tests (not pytest; see `fuzz/README.md`) - -Do not edit files in `pymongo/synchronous/` or mirrored files in `test/` directly: they are generated by `just synchro` from `pymongo/asynchronous/` and `test/asynchronous/`. -A file in `test/` is mirrored if a file of the same name exists in `test/asynchronous/`. - -## Commands -```bash -just install # set up venv + pre-commit hooks -just typing # type check -just lint-manual # pre-commit linting and synchro -just synchro # generate synchronous driver and mirrored tests -just test # run all tests -just test test/asynchronous # run async tests -MONGODB_VERSION=8.0 just run-server # start a local MongoDB 8.0 server -``` - -## Testing -Tests require a live MongoDB server (`just run-server` above). - -Async functions must not call blocking I/O. - -New features need integration tests. Bug fixes need regression tests. - -## Commit and PR Conventions -- Prefix commits and PR titles with the JIRA ticket: `PYTHON-1234 Fix retryable write on mongos` -- Backport PRs: append the target branch in brackets — `PYTHON-1234 [v4.9] Fix retryable write` -- Merge via **Squash and Merge** only - -See [copilot-instructions.md](.github/copilot-instructions.md) and [CODING-STANDARDS.md](CODING-STANDARDS.md) for more details. diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 43c994c2d3..0000000000 --- a/CLAUDE.md +++ /dev/null @@ -1 +0,0 @@ -@AGENTS.md diff --git a/CODING-STANDARDS.md b/CODING-STANDARDS.md deleted file mode 100644 index ad73f15d36..0000000000 --- a/CODING-STANDARDS.md +++ /dev/null @@ -1,204 +0,0 @@ -# Intent - -This document describes the common coding standards for all projects maintained by the Python Drivers team. These standards apply to all written code, comments, and docstrings, both human and machine-authored. Use these guidelines both when writing and reviewing code. - -This is a living document: when an issue or difference of opinion occurs several times across reviews or designs, the final resolution should be added as a new guiding rule here. - -# Comments - -1. Comments provide additional context for code when that context is not apparent in the code itself. Code that is self-explanatory should never have a comment. -* A good comment: - -```py -# SSLSocket can have buffered data which won't be caught by select. -if hasattr(sock, "pending") and sock.pending() > 0: - readable = True -``` - -* An unnecessary comment: - -```py -# Check if the socket is pending. -if hasattr(sock, "pending") and sock.pending() > 0: - readable = True -``` - -2. Comments are concise. -3. Comments use proper English grammar: start with a capital letter, use correct punctuation, and end with a period. -4. Avoid metaphors, similes, analogies, and other figurative language. - -# Docstrings - -1. Follow [PEP 257](https://peps.python.org/pep-0257/)’s conventions alongside the following example Sphinx formatting (this is for [AsyncCollection.distinct](https://github.com/mongodb/mongo-python-driver/blob/7512bad908e24a248a36cd286fa7c9ab1663da3d/pymongo/asynchronous/collection.py#L3147)()): - -```py -"""Get a list of distinct values for `key` among all documents -in this collection. - -Raises :class:`TypeError` if `key` is not an instance of -:class:`str`. - -All optional distinct parameters should be passed as keyword arguments -to this method. Valid options include: - - - `maxTimeMS` (int): The maximum amount of time to allow the count - command to run, in milliseconds. - - `collation` (optional): An instance of - :class:`~pymongo.collation.Collation`. - -The :meth:`distinct` method obeys the :attr:`read_preference` of -this :class:`AsyncCollection`. - -:param key: Name of the field for which we want to get the distinct - values. -:param filter: A query document that specifies the documents - from which to retrieve the distinct values. -:param session: A - :class:`~pymongo.asynchronous.client_session.AsyncClientSession`. -:param comment: A user-provided comment to attach to this - command. -:param hint: An index to use to support the query - predicate specified either by its string name, or in the same - format as passed to :meth:`~pymongo.asynchronous.collection.AsyncCollection.create_index` - (e.g. ``[('field', ASCENDING)]``). -:param kwargs: See list of options above. - -.. versionchanged:: 4.12 - Added ``hint`` parameter. - -.. versionchanged:: 3.6 - Added ``session`` parameter. - -.. versionchanged:: 3.4 - Support the `collation` option. - -""" -``` - -2. Docstrings tell the reader the purpose and behavior of an API. They do not describe internal implementation details. -3. Include what errors can be raised from the API. - -# Code Style - -1. Follow [PEP 8](https://peps.python.org/pep-0008/)’s conventions, mostly enforced by ruff and pre-commit. Note that we use a line length of 100 characters rather than 79\. -2. Avoid [magic numbers](https://en.wikipedia.org/wiki/Magic_number_\(programming\)). - -# Code Structure and Design - -1. Prefer shared helpers and abstraction over code duplication. -2. Bias towards less code. -3. Use consistent patterns for similar code. -4. Consider race conditions. -5. Handle or explicitly rule out edge cases with a comment if the reason is non-obvious or undocumented. -6. Prioritize future maintainability. If you would be unhappy maintaining a piece of code five years in the future, do not commit it. -7. When updating a method or class with multiple arguments, append the argument name unless strictly necessary. - -# Error Handling - -1. Raise or catch specific rather than general error types: - -```py -# Do this -except OperationFailure: -... - -# Not this -except PyMongoError: -... - -# Not this -except OperationFailure: -raise Exception(...) - -``` - -2. Use “raise … from …” syntax when chaining errors. - -# Performance - -1. Avoid doing unnecessary work: if an operation can be avoided in certain conditions, check those conditions before performing it. -* Do this: - -```py -if value == "abc": - return -result = expensive_function_call(value) -if result == ... -``` - -* Avoid this: - -```py -result = expensive_function_call(value) -if value == "abc": - return -if result == ... -``` - -2. Hold locks only for the minimal critical section. -3. Run the [performance benchmarking suite](https://github.com/mongodb/mongo-python-driver/blob/main/CONTRIBUTING.md#perf-tests) to catch possible regressions for large feature or performance changes. - -# Testing - -1. All tests should pass; if one does not pass and you can prove that it is unrelated to your current changes, note the failure in your PR before merging. -2. All code reachable through a public API must have test coverage. -3. Prefer many small tests over one large one. -4. Use [unittest-style assertions](https://docs.python.org/3/library/unittest.html#basic-example) when using unittest. -5. Setup and cleanup test resources safely for both success and failure. -6. Prefer unit tests instead of integration tests where possible. - -# Typing - -1. Annotate public APIs and verify using “mypy \--strict”. -2. Type-only dependencies should be imported within a TYPE\_CHECKING block: - -```py -from pymongo import MongoClient - -if TYPE_CHECKING: - from pymongo.collection import Collection -``` - -# Backwards compatibility - -1. We support all of the currently maintained CPython versions. All code must be compatible with the oldest supported version, which is 3.11 as of October 2026\. -2. Avoid breaking changes when possible. -3. Follow [semantic versioning](https://semver.org/) guidelines. -4. When deprecating a public API, add a deprecation warning to every call, a “deprecated::” line in its docstring, and a note in the changelog of the deprecating release. - 1. Changes marked `deprecated::` get removed in the next **major** release - -# Changelog - -1. All user-facing changes require a changelog entry. -2. Changelog entries are concise summaries of their described changes written using proper English grammar and in the past tense. -3. Changelog entries must start with one of the following words that categorize the type of change: - 1. `Added`: new features. - 2. `Changed`: changes in existing functionality. - 3. `Deprecated`: features to be removed in a future version. - 4. `Removed`: features removed in the described version. - 5. `Fixed`: bug fixes. - 6. `Security`: patched vulnerabilities. -4. Group all entries of the same type together in each version. -5. Changelog entries do not contain implementation details. -6. Use the guiding principle of "what would a user want to know about this" when describing a change. -7. Changelog entries must end with a link to the JIRA ticket that implemented their changes. -8. Cross-references to code must use one of the following Sphinx roles: - 1. `:meth:`: methods. - 2. `:class:`: classes. - 3. `:attr:`: attributes and properties. - 4. `:mod:`: modules. - 5. `:exc:`: exceptions. - 6. `:func:`: functions. - 7. `:data:`: module-level variables. - 8. `:const:`: constants. -9. Code snippets that do not fit any of the above roles must be contained within double backticks: ``text``. - -# Git - -1. Commit messages are concise summaries of their described changes. -2. Commit messages use proper English grammar except they do not end with a period. -3. Commit messages are written in the [imperative mood](https://en.wikipedia.org/wiki/Imperative_mood): they complete the sentence “this commit will …”. - 1. A good commit message: “Improve insert performance for large documents” - 2. A poor commit message: “2x speedup on inserts (if document \> 1MB).” -4. Extended messages longer than the one line summary are permitted, but are not encouraged as they are squashed during pull-request merge. They may contain periods. -5. Do not force-push to an open PR unless absolutely necessary. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 99c1fccaaf..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,692 +0,0 @@ -# Contributing to PyMongo - -PyMongo has a large -[community](https://pymongo.readthedocs.io/en/stable/contributors.html) -and contributions are always encouraged. Contributions can be as simple -as minor tweaks to the documentation. Please read these guidelines -before sending a pull request. - -## Bugfixes and New Features - -Before starting to write code, look for existing -[tickets](https://jira.mongodb.org/browse/PYTHON) or [create -one](https://jira.mongodb.org/browse/PYTHON) for your specific issue or -feature request. That way you avoid working on something that might not -be of interest or that has already been addressed. - -## Supported Interpreters - -PyMongo supports CPython 3.11+. - -## Style Guide - -PyMongo follows [PEP8](http://www.python.org/dev/peps/pep-0008/) -including 4 space indents and 79 character line limits. - -## General Guidelines - -- Avoid backward breaking changes if at all possible. -- Write inline documentation for new classes and methods. -- We use [uv](https://docs.astral.sh/uv/) for python environment management and packaging. -- We use [just](https://just.systems/man/en/) as our task runner. -- Write tests and make sure they pass (make sure you have a mongod - running on the default port, then execute `just test` from the cmd - line to run the test suite). -- Add yourself to doc/contributors.rst `:)` - -## Authoring a Pull Request - -**Our Pull Request Policy is based on this** [Code Review Developer -Guide](https://google.github.io/eng-practices/review) - -The expectation for any code author is to provide all the context needed -in the space of a pull request for any engineer to feel equipped to -review the code. Depending on the type of change, do your best to -highlight important new functions or objects you've introduced in the -code; think complex functions or new abstractions. Whilst it may seem -like more work for you to adjust your pull request, the reality is your -likelihood for getting review sooner shoots up. - -**Self Review Guidelines to follow** - -- If the PR is too large, split it if possible. - - - Use 250 LoC (excluding test data and config changes) as a - rule-of-thumb. - - - Moving and changing code should be in separate PRs or commits. - - - Moving: Taking large code blobs and transplanting - them to another file. There\'s generally no (or very - little) actual code changed other than a cut and - paste. It can even be extended to large deletions. - - Changing: Adding code changes (be that refactors or - functionality additions/subtractions). - - These two, when mixed, can muddy understanding and - sometimes make it harder for reviewers to keep track - of things. - -- Prefer explaining with code comments instead of PR comments. - -**Provide background** - -- The PR description and linked tickets should answer the "what" and - "why" of the change. The code change explains the "how". - -**Follow the Template** - -- Please do not deviate from the template we make; it is there for a - lot of reasons. If it is a one line fix, we still need to have - context on what and why it is needed. - -- If making a versioning change, please let that be known. See examples below: - - - `versionadded:: 3.11` - - `versionchanged:: 3.5` - -### AI-Generated Contributions Policy - -#### Our Stance - -We only accept pull requests that are authored and submitted by human contributors who fully understand the changes they are proposing. Pull requests that are not clearly owned and understood by a human contributor may be closed. **All contributions must be submitted, reviewed, and understood by human contributors.** - -##### Why This Policy Exists - -At MongoDB, we understand the power and prevalence of AI tools in software development. With that being said, many MongoDB libraries are foundational tools used in production systems worldwide. The nature of these libraries requires: - -- **Deep domain expertise**: MongoDB's wire protocol, BSON specification, connection pooling, authentication mechanisms, and concurrency patterns require an understanding that AI alone cannot substantiate. - -- **Long-term maintainability**: Contributors need to be able to explain *why* code is written a certain way, explain design decisions, and be available to iterate on their contributions. - -- **Security responsibility**: Authentication, credential handling, and TLS implementation cannot be left to probabilistic code generation. - -##### What This Means for Contributors - -**Required:** - -- Full understanding of every line of code you submit -- Ability to explain and defend your implementation choices -- Willingness to iterate and maintain your contributions - -**Encouraged:** - -- Using AI assistants as learning tools to understand concepts -- IDE autocomplete features that suggest standard patterns -- AI help for brainstorming approaches (but write the code yourself) -- Writing code using AI tools, reviewing each line and revising code as necessary. - -**Not allowed:** - -- Submitting PRs generated solely by AI tools -- Copy-pasting AI-generated code without full understanding - -##### Disclosure - -If you used AI assistance in any way during your contribution, please disclose what the AI assistant was used for in your PR description. We would love to know what tools developers have found useful in iterating in their day to day. - -##### Questions? - -If you're unsure whether your contribution complies with this policy, please ask for guidance within the scope of the PR and clarify any uncertainty. We're happy to guide contributors toward successful contributions. - ---- - -*This policy helps us maintain the reliability, security, and trustworthiness that production applications depend on. Thank you for understanding and for contributing thoughtfully to PyMongo.* - -## Running Linters - -PyMongo uses [pre-commit](https://pypi.org/project/pre-commit/) for -managing linting of the codebase. `pre-commit` performs various checks -on all files in PyMongo and uses tools that help follow a consistent -code style within the codebase. - -To set up `pre-commit` locally, run: - -```bash -brew install pre-commit -pre-commit install -``` - -To run `pre-commit` manually, run: - -```bash -pre-commit run --all-files -``` - -To run a manual hook like `ruff` manually, run: - -```bash -pre-commit run --all-files --hook-stage manual ruff -``` - -Typically we use `just` to run the linters, e.g. - -```bash -just install # this will install a venv with pre-commit installed, and install the pre-commit hook. -just typing-mypy -just run lint-manual -``` - -## Documentation - -To contribute to the [API documentation](https://pymongo.readthedocs.io/en/stable/) just make your -changes to the inline documentation of the appropriate [source code](https://github.com/mongodb/mongo-python-driver) or -[rst file](https://github.com/mongodb/mongo-python-driver/tree/main/doc) in -a branch and submit a [pull request](https://help.github.com/articles/using-pull-requests). You -might also use the GitHub -[Edit](https://github.com/blog/844-forking-with-the-edit-button) button. - -We use [reStructuredText](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html) for all -documentation including narrative docs, and the [Sphinx docstring format](https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html). - -You can build the documentation locally by running: - -```bash -just docs -``` - -When updating docs, it can be helpful to run the live docs server as: - -```bash -just docs-serve -``` - -Browse to the link provided, and then as you make changes to docstrings or narrative docs, -the pages will re-render and the browser will automatically refresh. - -## Running Tests Locally - -- Run `just install` to set a local virtual environment, or you can manually - create a virtual environment and run `pytest` directly. If you want to use a specific - version of Python, set `UV_PYTHON` before running `just install`. - - `just install` installs the pinned version of `uv` (from `[tool.uv] required-version`) into `$HOME/.local/bin`, - and adds that directory to your shell rc file when missing, so the pinned `uv` takes effect in new shells. If a - project `uv` command (e.g. `just test`) runs with a different `uv` version, `uv` fails fast and tells you how to update. - Scripts inside the vendored `drivers-evergreen-tools` submodule are exempt: the setup scripts write a `uv.toml` - boundary file into that checkout (see `.evergreen/scripts/configure-env.sh`), which stops uv's config discovery - there, since the tools' scripts run uv versions this project does not pin. -- Ensure you have started the appropriate Mongo Server(s). You can run `just run-server` with optional args - to set up the server. All given options will be passed to - [`run-mongodb.sh`](https://github.com/mongodb-labs/drivers-evergreen-tools/blob/master/.evergreen/run-mongodb.sh). Run `${DRIVERS_TOOLS:-drivers-evergreen-tools}/.evergreen/run-mongodb.sh start -h` - for a full list of options. By default the newest stable server release is used. To test against the - nightly build instead, pass `--version latest`, which is downloaded from a private S3 bucket and requires - an `AWS_PROFILE` with [Drivers test secrets](https://github.com/mongodb-labs/drivers-evergreen-tools/tree/master/.evergreen/secrets_handling#secrets-handling) credentials. -- Run `just test` or `pytest` to run all of the tests. -- Append `test/.py::::` to run - specific tests. You can omit the `` to test a full class - and the `` to test a full module. For example: - `just test test/test_change_stream.py::TestUnifiedChangeStreamsErrors::test_change_stream_errors_on_ElectionInProgress`. -- Use the `-k` argument to select tests by pattern. -- Run `just test-coverage` to run tests with coverage and display a report. After running tests with coverage, use `just coverage-html` to generate an HTML report in `htmlcov/index.html`. - - -## Running tests that require secrets, services, or other configuration - -### Prerequisites - -- The `drivers-evergreen-tools` submodule (see - [The drivers-evergreen-tools submodule](#the-drivers-evergreen-tools-submodule)). - `just install` initializes it; no manual clone or `export DRIVERS_TOOLS` is needed. - `DRIVERS_TOOLS` remains an optional override for an existing local checkout. -- Some tests require access to [Drivers test secrets](https://github.com/mongodb-labs/drivers-evergreen-tools/tree/master/.evergreen/secrets_handling#secrets-handling). - -### Usage - -- Run `just run-server` with optional args to set up the server. -- Run `just setup-tests` with optional args to set up the test environment, secrets, etc. - See `just setup-tests -h` for a full list of available options. -- Run `just run-tests` to run the tests in an appropriate Python environment. -- When done, run `just teardown-tests` to clean up and `just stop-server` to stop the server. - -### SSL tests - -- Run `just run-server --ssl` to start the server with TLS enabled. -- Run `just setup-tests --ssl`. -- Run `just run-tests`. - -Note: for general testing purposes with an TLS-enabled server, you can use the following (this should ONLY be used -for local testing): - -```python -from pymongo import MongoClient - -client = MongoClient( - "mongodb://localhost:27017?tls=true&tlsAllowInvalidCertificates=true" -) -``` - -If you want to use the actual certificate file then set `tlsCertificateKeyFile` to the local path -to `/test/certificates/client.pem` and `tlsCAFile` to the local path to `/test/certificates/ca.pem`. - -### Encryption tests - -- Run `just run-server` to start the server. -- Run `just setup-tests encryption`. -- Run the tests with `just run-tests`. - -To test with `encryption` and `PyOpenSSL`, use `just setup-tests encryption pyopenssl`. - -### PyOpenSSL tests - -- Run `just run-server` to start the server. -- Run `just setup-tests default_sync pyopenssl`. -- Run the tests with `just run-tests`. - -Note: `PyOpenSSL` is not used in async tests, but you can use `just setup-tests default_async pyopenssl` -to verify that PyMongo falls back to the standard library `OpenSSL`. - -### Load balancer tests - -- Install `haproxy` (available as `brew install haproxy` on macOS). -- Start the server with `just run-server load_balancer`. -- Set up the test with `just setup-tests load_balancer`. -- Run the tests with `just run-tests`. - -### AWS auth tests - -- Run `just run-server auth_aws` to start the server. -- Run `just setup-tests auth_aws ` to set up the AWS test. -- Run the tests with `just run-tests`. - -### OIDC auth tests - -- Run `just setup-tests auth_oidc ` to set up the OIDC test. -- Run the tests with `just run-tests`. - -The supported types are [`default`, `azure`, `gcp`, `eks`, `aks`, and `gke`]. -For the `eks` test, you will need to set up access to the `drivers-test-secrets-role`, see the [Wiki](https://wiki.corp.mongodb.com/spaces/DRIVERS/pages/239737385/Using+AWS+Secrets+Manager+to+Store+Testing+Secrets). - -### KMS tests - -For KMS tests that are run locally, and expected to fail, in this case using `azure`: - -- Run `just run-server`. -- Run `just setup-tests kms azure-fail`. -- Run `just run-tests`. - -For KMS tests that run remotely and are expected to pass, in this case using `gcp`: - -- Run `just setup-tests kms gcp`. -- Run `just run-tests`. - -### Enterprise Auth tests - -Note: these tests can only be run from an Evergreen host. - -- Run `just run-server enterprise_auth`. -- Run `just setup-tests enterprise_auth`. -- Run `just run-tests`. - -### Atlas Connect tests - -- Run `just setup-tests atlas_connect`. -- Run `just run-tests`. - -### Search Index tests - -- Run `just run-server search_index`. -- Run `just setup-tests search_index`. -- Run `just run-tests`. - -### MockupDB tests - -- Run `just setup-tests mockupdb`. -- Run `just run-tests`. - -### Doc tests - -The doc tests require a running server. - -- Run `just run-server`. -- Run `just setup-tests doctest`. -- Run `just run-tests`. - -### Free-threaded Python Tests - -In the evergreen builds, the tests are configured to use the free-threaded python from the toolchain. -Locally you can run: - -- Run `just run-server`. -- Run `just setup-tests`. -- Run `UV_PYTHON=3.14t just run-tests`. - -### AWS Lambda tests - -You will need to set up access to the `drivers-test-secrets-role`, see the [Wiki](https://wiki.corp.mongodb.com/spaces/DRIVERS/pages/239737385/Using+AWS+Secrets+Manager+to+Store+Testing+Secrets). - -- Run `just setup-tests aws_lambda`. -- Run `just run-tests`. - -### mod_wsgi tests - -Continuous integration runs the tests on pull requests that change -mod_wsgi-relevant files, in the `test-mod-wsgi.yml` workflow. - -To run the tests by hand, install Apache and mod_wsgi (`sudo apt-get install -y apache2 -apache2-dev` and `uv pip install -r requirements/mod_wsgi.txt` on Ubuntu), then: - -- On Linux, run `TOPOLOGY=replica_set just run-server`. -- Run `just setup-tests mod_wsgi `. -- Run `just run-tests`. -- Run `just teardown-tests`. - -The `mode` can be `standalone` or `embedded`. On non-Linux hosts the same -commands run inside an ubuntu container, which bootstraps its own replica -set (so the `run-server` step does not apply), or use `just smoke-mod-wsgi` -to run both modes. - -### OCSP tests - -- Export the orchestration file, e.g. `export ORCHESTRATION_FILE=rsa-basic-tls-ocsp-disableStapling.json`. -This corresponds to a config file in `${DRIVERS_TOOLS:-drivers-evergreen-tools}/.evergreen/orchestration/configs/servers`. -MongoDB servers on MacOS and Windows do not staple OCSP responses and only support RSA. -NOTE: because the mock ocsp responder MUST be started prior to the server starting, the ocsp tests start the server -as part of `setup-tests`. - -- Run `just setup-tests ocsp ` (options are "valid", "revoked", "valid-delegate", "revoked-delegate"). -- Run `just run-tests` - -If you are running one of the `no-responder` tests, omit the `run-server` step. - -### Perf Tests - -- Start the appropriate server, e.g. `just run-server --version=v8.0-perf --ssl`. -- Set up the tests with `sync` or `async`: `just setup-tests perf sync`. -- Run the tests: `just run-tests`. - -## The drivers-evergreen-tools submodule - -The `drivers-evergreen-tools` repository is consumed as a git submodule at the repo root, -pinned to a specific commit. Dependabot bumps the pin weekly. - -### Daily flow - -Nothing to do: `just install` initializes the submodule, and Dependabot keeps it fresh. - -### Manually bumping the submodule - -```bash -git -C drivers-evergreen-tools fetch --tags -git -C drivers-evergreen-tools checkout vX.Y.Z -git add drivers-evergreen-tools -``` - -### Evergreen patches that need tools changes - -Point the submodule at the needed commit and commit the new gitlink in the patch branch; -`configure-env.sh` checks out the recorded SHA on Evergreen hosts (`setup-dev-env.sh` does -the same for local checkouts with `just install`). - -### Using a local checkout instead - -Set `DRIVERS_TOOLS` to the path of a local clone — the environment variable wins over the -submodule default: - -```bash -export DRIVERS_TOOLS=/path/to/drivers-evergreen-tools -``` - -Alternatively, keep a local pin from being reset by `git submodule update`: - -```bash -git config submodule.drivers-evergreen-tools.update none -``` - -## Enable Debug Logs - -- Use `-o log_cli_level="DEBUG" -o log_cli=1` with `just test` or `pytest` to output all debug logs to the terminal. **Warning**: This will output a huge amount of logs. -- Add `log_cli=1` and `log_cli_level="DEBUG"` to the `tool.pytest.ini_options` section in `pyproject.toml` to enable debug logs in this manner by default on your machine. -- Set `DEBUG_LOG=1` and run `just setup-tests`, `just-test`, or `pytest` to enable debug logs only for failed tests. -- Finally, you can use `just setup-tests --debug-log`. -- For evergreen patch builds, you can use `evergreen patch --param DEBUG_LOG=1` to enable debug logs for failed tests in the patch. - -## Testing minimum dependencies - -To run any of the test suites with minimum supported dependencies, pass `--test-min-deps` to -`just setup-tests`. - -## Fuzz tests - -The `fuzz/` directory holds coverage-guided fuzz tests for `bson` -(PYTHON-4232). See [fuzz/README.md](fuzz/README.md) for details. The fuzz -tests can only be run on Linux x86_64, the only platform with atheris -wheels (CPython 3.12-3.14). - -- Regression test (runs on every PR): - `just setup-tests fuzz regression` then `just run-tests`. -- Time-boxed fuzzing (runs daily on Evergreen): `just setup-tests fuzz fuzz` - then `just run-tests`. Set `FUZZ_MAX_TIME` (seconds, default 300) to change - the per-target budget. -- Nightly fuzzing harvests coverage-increasing inputs into `fuzz/corpus/` - via an automated PR (PYTHON-6178); see [fuzz/README.md](fuzz/README.md). - -## Testing time-dependent operations - -- `test.utils_shared.delay` - One can trigger an arbitrarily long-running operation on the server using this delay utility - in combination with a `$where` operation. Use this to test behaviors around timeouts or signals. - -## Adding a new test suite - -- If adding new tests files that should only be run for that test suite, add a pytest marker to the file and add - to the list of pytest markers in `pyproject.toml`. Then add the test suite to the `TEST_SUITE_MAP` in `.evergreen/scripts/utils.py`. If for some reason it is not a pytest-runnable test, add it to the list of `EXTRA_TESTS` instead. -- If the test uses Atlas or otherwise doesn't use `run-mongodb.sh`, add it to the `NO_RUN_ORCHESTRATION` list in - `.evergreen/scripts/utils.py`. -- If there is something special required to run the local server or there is an extra flag that should always be set - like `AUTH`, add that logic to `.evergreen/scripts/run_server.py`. -- The bulk of the logic will typically be in `.evergreen/scripts/setup_tests.py`. This is where you should fetch secrets and make them available using `write_env`, start services, and write other env vars needed using `write_env`. -- If there are any special test considerations, including not running `pytest` at all, handle it in `.evergreen/scripts/run_tests.py`. -- If there are any services or atlas clusters to teardown, handle them in `.evergreen/scripts/teardown_tests.py`. -- Add functions to generate the test variant(s) and task(s) to the `.evergreen/scripts/generate_config.py`. -- There are some considerations about the Python version used in the test: - - To request a specific Python, set `UV_PYTHON` (e.g. `UV_PYTHON=3.10` or `UV_PYTHON=3.14t`). -Tasks are host-agnostic, so the interpreter lookup happens on the host: for a plain -CPython version whose toolchain dir exists, `UV_PYTHON_SEARCH_PATH` points uv at it, and for anything else -(a version the toolchain lacks) uv downloads it. - - If a specific Python binary is needed (for example on the FIPS host), set `UV_PYTHON=/path/to/python`. - - The default if `UV_PYTHON` is not set is CPython 3.10. This is deterministic across host types, so a task - that does not pin a version always gets the same Python (with the build headers (`Python.h`) needed to build - the C extensions). - - The uv binary version is pinned once in `[tool.uv] required-version` in `pyproject.toml`. - `.evergreen/scripts/install-dependencies.sh` installs it with `uv tool install`, uv enforces it locally, and - `astral-sh/setup-uv` reads it on GitHub. Bump it manually when a newer uv is needed. If uv cannot find the - requested Python, it installs it; if that fails, the task fails. The pin is not enforced for scripts inside - the vendored `drivers-evergreen-tools` submodule: those scripts run uv versions this project does not pin, so - the setup scripts write a `uv.toml` boundary into the submodule checkout that stops uv's config discovery - (and with it the required-version check) at the submodule boundary. -- Regenerate the test variants and tasks using `pre-commit run --all-files generate-config`. -- PR tasks pin to the Python boundaries: `MIN_PYTHON` with `TEST_MIN_DEPS=1`, `MAX_PYTHON`, and one - `FREE_THREADED_PYTHON`, against the newest numbered server (`MAX_VERSION`; the `latest` nightly - is unstable), plus the min server (`MIN_VERSION`) through its `MIN_PYTHON` floor. Each runs with - `COVERAGE=1`. The pins derive from `CPYTHONS` in `generate_config_utils.py`, so CPython changes - re-bind them rather than reshuffle the set. Check the regenerated `generated_configs/tasks.yml` - diff to confirm the `pr` tags. -- Make sure to add instructions for running the test suite to `CONTRIBUTING.md`. - -### Sanitizer tests - -The `sanitizer` test suite (PYTHON-6048) builds the C extensions with -`-fsanitize=address,undefined` against the toolchain's ASan/UBSan-instrumented -CPython (`SANITIZER_PYTHON` in `.evergreen/scripts/utils.py`) and runs the -files listed in `SANITIZER_FILES` in `.evergreen/scripts/setup_tests.py`. The -toolchain interpreter initializes the sanitizer runtimes itself. It runs on -PRs via the "Sanitizer RHEL8" variant. To run it on a Linux host with the -toolchain: - - just run-server - just setup-tests sanitizer - just run-tests - -## Handling flaky tests - -We have a custom `flaky` decorator in [test/asynchronous/utils.py](test/asynchronous/utils.py) that can be used for -tests that are `flaky`. By default the decorator only applies when not running on CPython on Linux, since other -runtimes tend to have more variation. When using the `flaky` decorator, open a corresponding ticket and -a use the ticket number as the "reason" parameter to the decorator, e.g. `@flaky(reason="PYTHON-1234")`. -When running tests locally (not in CI), the `flaky` decorator will be disabled unless `ENABLE_FLAKY` is set. -To disable the `flaky` decorator in CI, you can use `evergreen patch --param DISABLE_FLAKY=1`. - -## Integration Tests - -The `integration_tests` directory has a set of scripts that verify the usage of PyMongo with downstream packages or frameworks. See the [README](./integration_tests/README.md) for more information. - -To run the tests, use `just integration_tests`. - -The tests should be able to run with and without SSL enabled. - -## Specification Tests - -The MongoDB [specifications repository](https://github.com/mongodb/specifications) -holds in progress and completed specifications for features of MongoDB, drivers, -and associated products. PyMongo supports the [Unified Test Format](https://jira.mongodb.org/browse/DRIVERS-709) -for running specification tests to confirm PyMongo behaves as expected. - -### Resynchronizing the Specification Tests - -If you would like to re-sync the copy of the specification tests in the -PyMongo repository with that which is inside the [specifications -repo](https://github.com/mongodb/specifications), please use the script -provided in `.evergreen/resync-specs.sh`.: - -```bash -git clone git@github.com:mongodb/specifications.git -export MDB_SPECS=~/specifications -cd ~/mongo-python-driver/.evergreen -./resync-specs.sh -b "" spec1 spec2 ... -./resync-specs.sh -b "connection-string*" crud bson-corpus # Updates crud and bson-corpus specs while ignoring all files with the regex "connection-string*" -cd .. -``` - -The `-b` flag adds as a regex pattern to block files you do not wish to -update in PyMongo. This is primarily helpful if you are implementing a -new feature in PyMongo that has spec tests already implemented, or if -you are attempting to validate new spec tests in PyMongo. - -### Automated Specification Test Resyncing -The (`/.evergreen/scripts/resync-all-specs.sh`) script -automatically runs once a week to resync all the specs with the [specifications repo](https://github.com/mongodb/specifications). -A PR will be generated by mongodb-drivers-pr-bot containing any changes picked up by this resync. -The PR description will display the name(s) of the updated specs along -with any errors that occurred. - -Spec test changes associated with a behavioral change or bugfix that has yet to be implemented in PyMongo -must be added to a patch file in `/.evergreen/spec-patch`. Each patch -file must be named after the associated PYTHON ticket and contain the -test differences between PyMongo's current tests and the specification. -All changes listed in these patch files will be *undone* by the script and won't -be applied to PyMongo's tests. - -When a new test file or folder is added to the spec repo before the associated code changes are implemented, that test's path must be added to `.evergreen/remove-unimplemented-tests.sh` along with a comment indicating the associated PYTHON ticket for those changes. - -Any PR that implements a PYTHON ticket documented in a patch file or within `.evergreen/remove-unimplemented-tests.sh` must also remove the associated patch file or entry in `remove-unimplemented-tests.sh`. - -#### Adding to a patch file -To add to or create a patch file, run `git diff` to show the desired changes to undo and copy the -results into the patch file. - -For example: the imaginary, unimplemented PYTHON-1234 ticket has associated spec test changes. To add those changes to `PYTHON-1234.patch`), do the following: -```bash -git diff HEAD~1 path/to/file >> .evergreen/spec-patch/PYTHON-1234.patch -``` - -#### Running Locally -Both `resync-all-specs.sh` and `resync_all_specs.py` can be run locally (and won't generate a PR). -```bash -./.evergreen/scripts/resync-all-specs.sh -python3 ./.evergreen/scripts/resync_all_specs.py -``` - -## Making a Release - -Follow the [Python Driver Release Process Wiki](https://wiki.corp.mongodb.com/display/DRIVERS/Python+Driver+Release+Process). - -## Project Structure and Asyncio Considerations - -This section describes the layout of the `pymongo/` package. - -Within `pymongo/`, the code is further divided into the `pymongo/asynchronous` and `pymongo/synchronous` subdirectories. -Files in `pymongo/synchronous` are generated from `pymongo/asynchronous` using the `synchro` pre-commit hook, which uses [unasync](https://github.com/python-trio/unasync/) and some custom transforms. - -As a result, **all modifications** within `pymongo` must be made in either the top-level `pymongo` directory when they have to exhibit differing behavior between sync and async contexts or the `pymongo/asynchronous` directory, not `pymongo/synchronous`. -Any changes made directly to files in the `pymongo/synchronous` directory will be overwritten by the `synchro` hook when it is run, which happens automatically on commit. - -Some top-level files (e.g. `pymongo/collection.py`) are re-export files for existing import compatibility and should not be modified directly. -The other top-level files (e.g. `pymongo/network_layer.py`, `pymongo/pool_shared.py`) contain either shared code used in both the asynchronous and synchronous APIs, or code that is very different between the two APIs and therefore cannot be generated from the async version using `synchro`. - -Run `pre-commit run --all-files synchro` before running tests to generate the latest version of the synchronous code. - -To prevent the `synchro` hook from accidentally overwriting code, it first checks to see whether a sync version -of a file is changing and not its async counterpart, and will fail. -In the unlikely scenario that you want to override this behavior, first export `OVERRIDE_SYNCHRO_CHECK=1`. - -Sometimes, the `synchro` hook will fail and introduce changes many previously unmodified files. This is due to static -Python errors, such as missing imports, incorrect syntax, or other fatal typos. To resolve these issues, -run `pre-commit run --all-files --hook-stage manual ruff` and fix all reported errors before running the `synchro` -hook again. - -## CPU profiling - -To profile a test script and generate a flame graph, follow these steps: - -1. Install `py-spy` if you haven't already: - ```bash - pip install py-spy - ``` -2. Inside your test script, perform any required setup and then loop over the code you want to profile for improved sampling. -3. Run `py-spy record -o -r -- python ` to generate a `.svg` file containing the flame graph. - (Note: on macOS you will need to run this command using `sudo` to allow `py-spy` to attach to the Python process.) -4. If you need to include native code (for example the C extensions), profiling should be done on a Linux system, as macOS and Windows do not support the `--native` option of `py-spy`. - Creating an ubuntu Evergreen spawn host and using `scp` to copy the flamegraph `.svg` file back to your local machine is the best way to do this. -5. You can then view the flamegraph using an SVG viewer like a browser. - -## Memory profiling - -To test for a memory leak or any memory-related issues, the current best tool is [memray](https://bloomberg.github.io/memray/overview.html). -In order to include code from our C extensions, it must be run in native mode, on Linux. -To do so, either spin up an Ubuntu docker container or an Ubuntu Evergreen spawn host. - -From the spawn host or Ubuntu image, do the following: - -1. Install `memray` if you haven't already: - ```bash - pip install memray - ``` -2. Inside your test script, perform any required setup and then loop over the code you want to profile for improved sampling. -3. Run memray with the script under test with the `--native` flag, e.g. `python -m memray run --native -o test.bin `. -4. Generate the flamegraph with `python -m memray flamegraph -o test.html test.bin`. - See the [docs](https://bloomberg.github.io/memray/flamegraph.html) for more options. -5. Then, from the host computer, use either scp or docker cp to copy the flamegraph, e.g. `scp ubuntu@ec2-3-82-52-49.compute-1.amazonaws.com:/home/ubuntu/test.html .`. -6. You can then view the flamegraph html in a browser. - -## Dependency updates - -Dependabot raises PRs at most once per week for GitHub Actions updates. For Python -dependencies it is limited to security updates, because routine upgrades are handled by -a scheduled workflow that runs weekly, running `uv lock --upgrade` and keeping a single -open pull request on the `uv-lock-update` branch. - -If a typing dependency has changed, run `just typing` and handle any new findings. - -### The uv.lock file - -`uv.lock` is committed to the repository so builds resolve identically on every machine -and in CI. Continuous integration runs `uv lock --check`, which fails when the lock file -no longer matches `pyproject.toml`. - -If that check fails on your pull request, regenerate the lock file and commit the result. -A 7 day cutoff (`exclude-newer` in `pyproject.toml`) applies automatically, so a package -version yanked shortly after release is less likely to land in the lock file: - -```bash -uv lock -``` - -To resolve a `uv.lock` conflict when rebasing, check out either side and regenerate -rather than editing the file by hand. Which side you pick does not matter, because -`uv lock` rewrites the file from `pyproject.toml`. Use `--theirs` in place of -`--ours` if you prefer: - -```bash -git checkout --ours uv.lock -uv lock -git add uv.lock -``` diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 261eeb9e9f..0000000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.md b/README.md deleted file mode 100644 index 8528bf35ac..0000000000 --- a/README.md +++ /dev/null @@ -1,219 +0,0 @@ -# PyMongo - -[![PyPI Version](https://img.shields.io/pypi/v/pymongo)](https://pypi.org/project/pymongo) -[![Python Versions](https://img.shields.io/pypi/pyversions/pymongo)](https://pypi.org/project/pymongo) -[![Monthly Downloads](https://static.pepy.tech/badge/pymongo/month)](https://pepy.tech/project/pymongo) -[![API Documentation Status](https://readthedocs.org/projects/pymongo/badge/?version=stable)](http://pymongo.readthedocs.io/en/stable/api?badge=stable) -[![codecov](https://codecov.io/gh/mongodb/mongo-python-driver/graph/badge.svg?branch=main)](https://codecov.io/gh/mongodb/mongo-python-driver) - -## About - -The PyMongo distribution contains tools for interacting with MongoDB -database from Python. The `bson` package is an implementation of the -[BSON format](http://bsonspec.org) for Python. The `pymongo` package is -a native Python driver for MongoDB, offering both synchronous and asynchronous APIs. The `gridfs` package is a -[gridfs](https://github.com/mongodb/specifications/blob/master/source/gridfs/gridfs-spec.md/) -implementation on top of `pymongo`. - -PyMongo supports MongoDB 4.4, 5.0, 6.0, 7.0, 8.0, and 9.0. PyMongo follows [semantic versioning](https://semver.org/spec/v2.0.0.html) for its releases. - -## Documentation - -Documentation is available at -[mongodb.com](https://www.mongodb.com/docs/languages/python/pymongo-driver/current/). - -[API documentation](https://pymongo.readthedocs.io/en/stable/api/) and the [full changelog](https://pymongo.readthedocs.io/en/stable/changelog.html) for each release is available at [readthedocs.io](https://pymongo.readthedocs.io/en/stable/index.html). - -## Support / Feedback - -For issues with, questions about, or feedback for PyMongo, please look -into our [support channels](https://support.mongodb.com/welcome). Please -do not email any of the PyMongo developers directly with issues or -questions - you're more likely to get an answer on -[StackOverflow](https://stackoverflow.com/questions/tagged/mongodb) -(using a "mongodb" tag). - -## Bugs / Feature Requests - -Think you've found a bug? Want to see a new feature in PyMongo? Please -open a case in our issue management tool, JIRA: - -- [Create an account and login](https://jira.mongodb.org). -- Navigate to [the PYTHON - project](https://jira.mongodb.org/browse/PYTHON). -- Click **Create Issue** - Please provide as much information as - possible about the issue type and how to reproduce it. - -Bug reports in JIRA for all driver projects (i.e. PYTHON, CSHARP, JAVA) -and the Core Server (i.e. SERVER) project are **public**. - -### How To Ask For Help - -Please include all of the following information when opening an issue: - -- Detailed steps to reproduce the problem, including full traceback, - if possible. - -- The exact python version used, with patch level: - -```bash -python -c "import sys; print(sys.version)" -``` - -- The exact version of PyMongo used, with patch level: - -```bash -python -c "import pymongo; print(pymongo.version); print(pymongo.has_c())" -``` - -- The operating system and version (e.g. Windows 7, OSX 10.8, ...) - -- Web framework or asynchronous network library used, if any, with - version (e.g. Django 1.7, mod_wsgi 4.3.0, gevent 1.0.1, Tornado - 4.0.2, ...) - -### Security Vulnerabilities - -If you've identified a security vulnerability in a driver or any other -MongoDB project, please report it according to the [instructions -here](https://www.mongodb.com/docs/manual/tutorial/create-a-vulnerability-report/). - -## Installation - -PyMongo can be installed with [pip](http://pypi.python.org/pypi/pip): - -```bash -python -m pip install pymongo -``` - -You can also download the project source and do: - -```bash -pip install . -``` - -Do **not** install the "bson" package from pypi. PyMongo comes with -its own bson package; running "pip install bson" installs a third-party -package that is incompatible with PyMongo. - -## Dependencies - -PyMongo supports CPython 3.11+. - -Required dependencies: - -Support for `mongodb+srv://` URIs requires [dnspython](https://pypi.python.org/pypi/dnspython) - -Optional dependencies: - -GSSAPI authentication requires -[pykerberos](https://pypi.python.org/pypi/pykerberos) on Unix or -[WinKerberos](https://pypi.python.org/pypi/winkerberos) on Windows. The -correct dependency can be installed automatically along with PyMongo: - -```bash -python -m pip install "pymongo[gssapi]" -``` - -MONGODB-AWS authentication requires -[pymongo-auth-aws](https://pypi.org/project/pymongo-auth-aws/): - -```bash -python -m pip install "pymongo[aws]" -``` - -OCSP (Online Certificate Status Protocol) requires -[PyOpenSSL](https://pypi.org/project/pyOpenSSL/), -[requests](https://pypi.org/project/requests/), -[service_identity](https://pypi.org/project/service_identity/) and may -require [certifi](https://pypi.python.org/pypi/certifi): - -```bash -python -m pip install "pymongo[ocsp]" -``` - -Wire protocol compression with snappy requires -[python-snappy](https://pypi.org/project/python-snappy): - -```bash -python -m pip install "pymongo[snappy]" -``` - -Wire protocol compression with zstandard requires -[backports.zstd](https://pypi.org/project/backports.zstd) -when used with Python versions before 3.14: - -```bash -python -m pip install "pymongo[zstd]" -``` - -Client-Side Field Level Encryption requires -[pymongocrypt](https://pypi.org/project/pymongocrypt/) and -[pymongo-auth-aws](https://pypi.org/project/pymongo-auth-aws/): - -```bash -python -m pip install "pymongo[encryption]" -``` -You can install all dependencies automatically with the following -command: - -```bash -python -m pip install "pymongo[gssapi,aws,ocsp,snappy,zstd,encryption]" -``` - -## Examples - -Here's a basic example (for more see the *examples* section of the -docs): - -```pycon ->>> import pymongo ->>> client = pymongo.MongoClient("localhost", 27017) ->>> db = client.test ->>> db.name -'test' ->>> db.my_collection -Collection(Database(MongoClient('localhost', 27017), 'test'), 'my_collection') ->>> db.my_collection.insert_one({"x": 10}).inserted_id -ObjectId('4aba15ebe23f6b53b0000000') ->>> db.my_collection.insert_one({"x": 8}).inserted_id -ObjectId('4aba160ee23f6b543e000000') ->>> db.my_collection.insert_one({"x": 11}).inserted_id -ObjectId('4aba160ee23f6b543e000002') ->>> db.my_collection.find_one() -{'x': 10, '_id': ObjectId('4aba15ebe23f6b53b0000000')} ->>> for item in db.my_collection.find(): -... print(item["x"]) -... -10 -8 -11 ->>> db.my_collection.create_index("x") -'x_1' ->>> for item in db.my_collection.find().sort("x", pymongo.ASCENDING): -... print(item["x"]) -... -8 -10 -11 ->>> [item["x"] for item in db.my_collection.find().limit(2).skip(1)] -[8, 11] -``` - -## Learning Resources - -- MongoDB Learn - [Python -courses](https://learn.mongodb.com/catalog?labels=%5B%22Language%22%5D&values=%5B%22Python%22%5D). -- [Python Articles on Developer -Center](https://www.mongodb.com/developer/languages/python/). - -## Testing - -The easiest way to run the tests is to run the following from the repository root. - -```bash -pip install -e ".[test]" -pytest -``` - -For more advanced testing scenarios, see the [contributing guide](https://github.com/mongodb/mongo-python-driver/blob/main/CONTRIBUTING.md#running-tests-locally). diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES deleted file mode 100644 index ad00831a2a..0000000000 --- a/THIRD-PARTY-NOTICES +++ /dev/null @@ -1,98 +0,0 @@ -PyMongo uses third-party libraries or other resources that may -be distributed under licenses different than the PyMongo software. - -In the event that we accidentally failed to list a required notice, -please bring it to our attention through any of the ways detailed here: - - https://jira.mongodb.org/projects/PYTHON - -The attached notices are provided for information only. - -For any licenses that require disclosure of source, sources are available at -https://github.com/mongodb/mongo-python-driver. - - -1) License Notice for time64.c ------------------------------- - -Copyright (c) 2007-2010 Michael G Schwern - -This software originally derived from Paul Sheer's pivotal_gmtime_r.c. - -The MIT License: - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -2) License Notice for _asyncio_lock.py ------------------------------------------ - -1. This LICENSE AGREEMENT is between the Python Software Foundation -("PSF"), and the Individual or Organization ("Licensee") accessing and -otherwise using this software ("Python") in source or binary form and -its associated documentation. - -2. Subject to the terms and conditions of this License Agreement, PSF hereby -grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, -analyze, test, perform and/or display publicly, prepare derivative works, -distribute, and otherwise use Python alone or in any derivative version, -provided, however, that PSF's License Agreement and PSF's notice of copyright, -i.e., "Copyright (c) 2001-2024 Python Software Foundation; All Rights Reserved" -are retained in Python alone or in any derivative version prepared by Licensee. - -3. In the event Licensee prepares a derivative work that is based on -or incorporates Python or any part thereof, and wants to make -the derivative work available to others as provided herein, then -Licensee hereby agrees to include in any such work a brief summary of -the changes made to Python. - -4. PSF is making Python available to Licensee on an "AS IS" -basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT -INFRINGE ANY THIRD PARTY RIGHTS. - -5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON -FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS -A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, -OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -6. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -7. Nothing in this License Agreement shall be deemed to create any -relationship of agency, partnership, or joint venture between PSF and -Licensee. This License Agreement does not grant permission to use PSF -trademarks or trade name in a trademark sense to endorse or promote -products or services of Licensee, or any third party. - -8. By copying, installing or otherwise using Python, Licensee -agrees to be bound by the terms and conditions of this License -Agreement. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. diff --git a/_setup.py b/_setup.py deleted file mode 100644 index 8a1f1e6e82..0000000000 --- a/_setup.py +++ /dev/null @@ -1,148 +0,0 @@ -from __future__ import annotations - -import os -import sys -import warnings - -# Hack to silence atexit traceback in some Python versions -try: - import multiprocessing # noqa: F401 -except ImportError: - pass - -from setuptools import setup -from setuptools.command.build_ext import build_ext -from setuptools.extension import Extension - - -class custom_build_ext(build_ext): - """Allow C extension building to fail. - - The C extension speeds up BSON encoding, but is not essential. - """ - - warning_message = """ -******************************************************************** -WARNING: %s could not -be compiled. No C extensions are essential for PyMongo to run, -although they do result in significant speed improvements. -%s - -Please see the installation docs for solutions to build issues: - -https://pymongo.readthedocs.io/en/stable/installation.html - -Here are some hints for popular operating systems: - -If you are seeing this message on Linux you probably need to -install GCC and/or the Python development package for your -version of Python. - -Debian and Ubuntu users should issue the following command: - - $ sudo apt-get install build-essential python-dev - -Users of Red Hat based distributions (RHEL, CentOS, Amazon Linux, -Oracle Linux, Fedora, etc.) should issue the following command: - - $ sudo yum install gcc python-devel - -If you are seeing this message on Microsoft Windows please install -PyMongo using pip. Modern versions of pip will install PyMongo -from binary wheels available on pypi. If you must install from -source read the documentation here: - -https://pymongo.readthedocs.io/en/stable/installation.html#installing-from-source-on-windows - -If you are seeing this message on macOS / OSX please install PyMongo -using pip. Modern versions of pip will install PyMongo from binary -wheels available on pypi. If wheels are not available for your version -of macOS / OSX, or you must install from source read the documentation -here: - -https://pymongo.readthedocs.io/en/stable/installation.html#osx -******************************************************************** -""" - - def run(self): - try: - build_ext.run(self) - except Exception: - if os.environ.get("PYMONGO_C_EXT_MUST_BUILD"): - raise - e = sys.exc_info()[1] - sys.stdout.write(f"{e!s}\n") - warnings.warn( - self.warning_message - % ( - "Extension modules", - "There was an issue with your platform configuration - see above.", - ), - stacklevel=2, - ) - - def build_extension(self, ext): - # "ProgramFiles(x86)" is not a valid environment variable in Cygwin but is needed for - # the MSVCCompiler in distutils. - if os.name == "nt": - if "ProgramFiles" in os.environ and "ProgramFiles(x86)" not in os.environ: - os.environ["ProgramFiles(x86)"] = os.environ["ProgramFiles"] + " (x86)" - name = ext.name - try: - build_ext.build_extension(self, ext) - except Exception: - if os.environ.get("PYMONGO_C_EXT_MUST_BUILD"): - raise - e = sys.exc_info()[1] - sys.stdout.write(f"{e!s}\n") - warnings.warn( - self.warning_message - % ( - "The %s extension module" % (name,), # noqa: UP031 - "The output above this warning shows how the compilation failed.", - ), - stacklevel=2, - ) - - -ext_modules = [ - Extension( - "bson._cbson", - include_dirs=["bson"], - sources=["bson/_cbsonmodule.c", "bson/time64.c", "bson/buffer.c"], - ), - Extension( - "pymongo._cmessage", - include_dirs=["bson"], - sources=[ - "pymongo/_cmessagemodule.c", - "bson/_cbsonmodule.c", - "bson/time64.c", - "bson/buffer.c", - ], - ), -] - - -if "--no_ext" in sys.argv or os.environ.get("NO_EXT"): - try: - sys.argv.remove("--no_ext") - except ValueError: - pass - ext_modules = [] -elif sys.implementation.name == "graalpy": - sys.stdout.write( - """ -*****************************************************\n -The optional C extensions are currently not supported\n -by this python implementation.\n -*****************************************************\n -""" - ) - ext_modules = [] - -setup( - cmdclass={"build_ext": custom_build_ext}, - ext_modules=ext_modules, - packages=["bson", "pymongo", "gridfs"], -) # type:ignore diff --git a/bson/__init__.py b/bson/__init__.py deleted file mode 100644 index 801ae77e74..0000000000 --- a/bson/__init__.py +++ /dev/null @@ -1,1513 +0,0 @@ -# Copyright 2009-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""BSON (Binary JSON) encoding and decoding. - -The mapping from Python types to BSON types is as follows: - -======================================= ============= =================== -Python Type BSON Type Supported Direction -======================================= ============= =================== -None null both -bool boolean both -int [#int]_ int32 / int64 py -> bson -:class:`bson.int64.Int64` int64 both -float number (real) both -str string both -list array both -dict object both -:class:`~bson.son.SON` object both -:py:class:`~collections.abc.Mapping` object py -> bson -:class:`~bson.raw_bson.RawBSONDocument` object both [#raw]_ -datetime.datetime [#dt]_ [#dt2]_ UTC datetime both -:class:`~bson.datetime_ms.DatetimeMS` UTC datetime both [#dt3]_ -:class:`~bson.regex.Regex` regex both -compiled re [#re]_ regex py -> bson -:class:`~bson.binary.Binary` binary both -:py:class:`uuid.UUID` [#uuid]_ binary both -:class:`~bson.objectid.ObjectId` oid both -:class:`~bson.dbref.DBRef` dbref both -:class:`~bson.dbref.DBRef` dbpointer bson -> py -None undefined bson -> py -:class:`~bson.code.Code` code both -str symbol bson -> py -bytes [#bytes]_ binary both -:class:`~bson.timestamp.Timestamp` timestamp both -:class:`~bson.decimal128.Decimal128` decimal128 both -:class:`~bson.min_key.MinKey` min key both -:class:`~bson.max_key.MaxKey` max key both -======================================= ============= =================== - -.. [#int] A Python int will be saved as a BSON int32 or BSON int64 depending - on its size. A BSON int32 will always decode to a Python int. A BSON - int64 will always decode to a :class:`~bson.int64.Int64`. -.. [#raw] Decoding a bson object to :class:`~bson.raw_bson.RawBSONDocument` can be - optionally configured via :attr:`~bson.codec_options.CodecOptions.document_class`. -.. [#dt] datetime.datetime instances are encoded with millisecond precision so - the microsecond field is truncated. -.. [#dt2] all datetime.datetime instances are encoded as UTC. By default, they - are decoded as *naive* but timezone aware datetimes are also supported. - See `Dates and Times `_ for examples. -.. [#dt3] To enable decoding a bson UTC datetime to a :class:`~bson.datetime_ms.DatetimeMS` - instance see `handling out of range datetimes `_. -.. [#uuid] For :py:class:`uuid.UUID` encoding and decoding behavior see ``_. -.. [#re] :class:`~bson.regex.Regex` instances and regular expression - objects from ``re.compile()`` are both saved as BSON regular expressions. - BSON regular expressions are decoded as :class:`~bson.regex.Regex` - instances. -.. [#bytes] The bytes type is encoded as BSON binary with - subtype 0. It will be decoded back to bytes. -""" - -from __future__ import annotations - -import datetime -import itertools -import os -import re -import struct -import sys -import uuid -from codecs import utf_8_decode as _utf_8_decode -from codecs import utf_8_encode as _utf_8_encode -from collections import abc as _abc -from collections.abc import Callable, Generator, Iterator, Mapping, MutableMapping, Sequence -from typing import ( - IO, - TYPE_CHECKING, - Any, - BinaryIO, - NoReturn, - TypeVar, - cast, - overload, -) - -from bson.binary import ( - ALL_UUID_SUBTYPES, - CSHARP_LEGACY, - JAVA_LEGACY, - OLD_UUID_SUBTYPE, - STANDARD, - UUID_SUBTYPE, - Binary, - UuidRepresentation, -) -from bson.code import Code -from bson.codec_options import ( - _RAW_BSON_VIEW_THRESHOLD, - DEFAULT_CODEC_OPTIONS, - CodecOptions, - DatetimeConversion, - _raw_document_class, -) -from bson.datetime_ms import ( - EPOCH_AWARE, - EPOCH_NAIVE, - DatetimeMS, - _datetime_to_millis, - _millis_to_datetime, -) -from bson.dbref import DBRef -from bson.decimal128 import Decimal128 -from bson.errors import InvalidBSON, InvalidDocument, InvalidStringData -from bson.int64 import Int64 -from bson.max_key import MaxKey -from bson.min_key import MinKey -from bson.objectid import ObjectId -from bson.regex import Regex -from bson.son import RE_TYPE, SON -from bson.timestamp import Timestamp -from bson.tz_util import utc - -# Import some modules for type-checking only. -if TYPE_CHECKING: - from bson.raw_bson import RawBSONDocument - from bson.typings import _DocumentType, _ReadableBuffer - -try: - from bson import _cbson # type: ignore[attr-defined] - - _USE_C = True -except ImportError: - _USE_C = False - -__all__ = [ - "ALL_UUID_SUBTYPES", - "BSON", - "BSONARR", - "BSONBIN", - "BSONBOO", - "BSONCOD", - "BSONCWS", - "BSONDAT", - "BSONDEC", - "BSONINT", - "BSONLON", - "BSONMAX", - "BSONMIN", - "BSONNUL", - "BSONNUM", - "BSONOBJ", - "BSONOID", - "BSONREF", - "BSONRGX", - "BSONSTR", - "BSONSYM", - "BSONTIM", - "BSONUND", - "CSHARP_LEGACY", - "DEFAULT_CODEC_OPTIONS", - "EPOCH_AWARE", - "EPOCH_NAIVE", - "JAVA_LEGACY", - "OLD_UUID_SUBTYPE", - "RE_TYPE", - "SON", - "STANDARD", - "UUID_SUBTYPE", - "Binary", - "Code", - "CodecOptions", - "DBRef", - "DatetimeConversion", - "DatetimeMS", - "Decimal128", - "Int64", - "InvalidBSON", - "InvalidDocument", - "InvalidStringData", - "MaxKey", - "MinKey", - "ObjectId", - "Regex", - "Timestamp", - "UuidRepresentation", - "decode", - "decode_all", - "decode_file_iter", - "decode_iter", - "encode", - "gen_list_name", - "get_data_and_view", - "has_c", - "is_valid", - "utc", -] - -BSONNUM = b"\x01" # Floating point -BSONSTR = b"\x02" # UTF-8 string -BSONOBJ = b"\x03" # Embedded document -BSONARR = b"\x04" # Array -BSONBIN = b"\x05" # Binary -BSONUND = b"\x06" # Undefined -BSONOID = b"\x07" # ObjectId -BSONBOO = b"\x08" # Boolean -BSONDAT = b"\x09" # UTC Datetime -BSONNUL = b"\x0a" # Null -BSONRGX = b"\x0b" # Regex -BSONREF = b"\x0c" # DBRef -BSONCOD = b"\x0d" # Javascript code -BSONSYM = b"\x0e" # Symbol -BSONCWS = b"\x0f" # Javascript code with scope -BSONINT = b"\x10" # 32bit int -BSONTIM = b"\x11" # Timestamp -BSONLON = b"\x12" # 64bit int -BSONDEC = b"\x13" # Decimal128 -BSONMIN = b"\xff" # Min key -BSONMAX = b"\x7f" # Max key - - -_UNPACK_FLOAT_FROM = struct.Struct(" tuple[Any, memoryview]: - if isinstance(data, (bytes, bytearray)): - return data, memoryview(data) - # Copy other inputs so decoding is immutable - data = memoryview(data).tobytes() - return data, memoryview(data) - - -def _raw_as_bytes(raw: bytes | bytearray | memoryview) -> bytes: - """Convert a raw BSON buffer (bytes, bytearray, or memoryview) to bytes.""" - return raw if isinstance(raw, bytes) else bytes(raw) - - -def _raw_slice(data: Any, view: memoryview, position: int, end: int, obj_size: int) -> Any: - """Return the raw BSON document spanning ``position`` to ``end`` for use as a buffer.""" - whole_span = position == 0 and obj_size == len(data) - if view.readonly: # data is immutable (bytes). - if whole_span: - return data - if obj_size >= _RAW_BSON_VIEW_THRESHOLD: - return view[position : end + 1] - return data[position : end + 1] - # Mutable buffer, must copy. - return bytes(data) if whole_span else _raw_as_bytes(data[position : end + 1]) - - -def _raise_unknown_type(element_type: int, element_name: str) -> NoReturn: - """Unknown type helper.""" - raise InvalidBSON( - f"Detected unknown BSON type {chr(element_type).encode()!r} for fieldname '{element_name}'. Are " - "you using the latest driver version?" - ) - - -def _get_int( - data: Any, _view: Any, position: int, dummy0: Any, dummy1: Any, dummy2: Any -) -> tuple[int, int]: - """Decode a BSON int32 to python int.""" - return _UNPACK_INT_FROM(data, position)[0], position + 4 - - -def _get_c_string(data: Any, view: Any, position: int, opts: CodecOptions[Any]) -> tuple[str, int]: - """Decode a BSON 'C' string to python str.""" - end = data.index(b"\x00", position) - return _utf_8_decode(view[position:end], opts.unicode_decode_error_handler, True)[0], end + 1 - - -def _get_float( - data: Any, _view: Any, position: int, dummy0: Any, dummy1: Any, dummy2: Any -) -> tuple[float, int]: - """Decode a BSON double to python float.""" - return _UNPACK_FLOAT_FROM(data, position)[0], position + 8 - - -def _get_string( - data: Any, view: Any, position: int, obj_end: int, opts: CodecOptions[Any], dummy: Any -) -> tuple[str, int]: - """Decode a BSON string to python str.""" - length = _UNPACK_INT_FROM(data, position)[0] - position += 4 - if length < 1 or obj_end - position < length: - raise InvalidBSON("invalid string length") - end = position + length - 1 - if data[end] != 0: - raise InvalidBSON("invalid end of string") - return _utf_8_decode(view[position:end], opts.unicode_decode_error_handler, True)[0], end + 1 - - -def _get_object_size(data: Any, position: int, obj_end: int) -> tuple[int, int]: - """Validate and return a BSON document's size.""" - try: - obj_size = _UNPACK_INT_FROM(data, position)[0] - except struct.error as exc: - raise InvalidBSON(str(exc)) from None - end = position + obj_size - 1 - if end >= obj_end: - raise InvalidBSON("invalid object length") - if data[end] != 0: - raise InvalidBSON("bad eoo") - # If this is the top-level document, validate the total size too. - if position == 0 and obj_size != obj_end: - raise InvalidBSON("invalid object length") - return obj_size, end - - -def _get_object( - data: Any, view: Any, position: int, obj_end: int, opts: CodecOptions[Any], dummy: Any -) -> tuple[Any, int]: - """Decode a BSON subdocument to opts.document_class or bson.dbref.DBRef.""" - obj_size, end = _get_object_size(data, position, obj_end) - if _raw_document_class(opts.document_class): - buf = _raw_slice(data, view, position, end, obj_size) - return (opts.document_class(buf, opts), position + obj_size) - - obj = _elements_to_dict(data, view, position + 4, end, opts) - - position += obj_size - # If DBRef validation fails, return a normal doc. - if ( - isinstance(obj.get("$ref"), str) - and "$id" in obj - and isinstance(obj.get("$db"), (str, type(None))) - ): - return (DBRef(obj.pop("$ref"), obj.pop("$id", None), obj.pop("$db", None), obj), position) - return obj, position - - -def _get_array( - data: Any, view: Any, position: int, obj_end: int, opts: CodecOptions[Any], element_name: str -) -> tuple[Any, int]: - """Decode a BSON array to python list.""" - size = _UNPACK_INT_FROM(data, position)[0] - end = position + size - 1 - if data[end] != 0: - raise InvalidBSON("bad eoo") - - position += 4 - end -= 1 - result: list[Any] = [] - - # Avoid doing global and attribute lookups in the loop. - append = result.append - index = data.index - getter = _ELEMENT_GETTER - decoder_map = opts.type_registry._decoder_map - - while position < end: - element_type = data[position] - # Just skip the keys. - position = index(b"\x00", position) + 1 - try: - value, position = getter[element_type]( - data, view, position, obj_end, opts, element_name - ) - except KeyError: - _raise_unknown_type(element_type, element_name) - - if decoder_map: - custom_decoder = decoder_map.get(type(value)) - if custom_decoder is not None: - value = custom_decoder(value) - - append(value) - - if position != end + 1: - raise InvalidBSON("bad array length") - return result, position + 1 - - -def _get_binary( - data: Any, _view: Any, position: int, obj_end: int, opts: CodecOptions[Any], dummy1: Any -) -> tuple[Binary | uuid.UUID, int]: - """Decode a BSON binary to bson.binary.Binary or python UUID.""" - length, subtype = _UNPACK_LENGTH_SUBTYPE_FROM(data, position) - position += 5 - if subtype == 2: - length2 = _UNPACK_INT_FROM(data, position)[0] - position += 4 - if length2 != length - 4: - raise InvalidBSON("invalid binary (st 2) - lengths don't match!") - length = length2 - end = position + length - if length < 0 or end > obj_end: - raise InvalidBSON("bad binary object length") - - # Convert UUID subtypes to native UUIDs. - if subtype in ALL_UUID_SUBTYPES: - uuid_rep = opts.uuid_representation - binary_value = Binary(data[position:end], subtype) - if ( - (uuid_rep == UuidRepresentation.UNSPECIFIED) - or (subtype == UUID_SUBTYPE and uuid_rep != STANDARD) - or (subtype == OLD_UUID_SUBTYPE and uuid_rep == STANDARD) - ): - return binary_value, end - return binary_value.as_uuid(uuid_rep), end - - # Decode subtype 0 to 'bytes'. - if subtype == 0: - value = data[position:end] - else: - value = Binary(data[position:end], subtype) - - return value, end - - -def _get_oid( - data: Any, _view: Any, position: int, dummy0: Any, dummy1: Any, dummy2: Any -) -> tuple[ObjectId, int]: - """Decode a BSON ObjectId to bson.objectid.ObjectId.""" - end = position + 12 - return ObjectId(data[position:end]), end - - -def _get_boolean( - data: Any, _view: Any, position: int, dummy0: Any, dummy1: Any, dummy2: Any -) -> tuple[bool, int]: - """Decode a BSON true/false to python True/False.""" - end = position + 1 - boolean_byte = data[position:end] - if boolean_byte == b"\x00": - return False, end - elif boolean_byte == b"\x01": - return True, end - raise InvalidBSON(f"invalid boolean value: {boolean_byte!r}") - - -def _get_date( - data: Any, _view: Any, position: int, dummy0: int, opts: CodecOptions[Any], dummy1: Any -) -> tuple[datetime.datetime | DatetimeMS, int]: - """Decode a BSON datetime to python datetime.datetime.""" - return _millis_to_datetime(_UNPACK_LONG_FROM(data, position)[0], opts), position + 8 - - -def _get_code( - data: Any, view: Any, position: int, obj_end: int, opts: CodecOptions[Any], element_name: str -) -> tuple[Code, int]: - """Decode a BSON code to bson.code.Code.""" - code, position = _get_string(data, view, position, obj_end, opts, element_name) - return Code(code), position - - -def _get_code_w_scope( - data: Any, view: Any, position: int, _obj_end: int, opts: CodecOptions[Any], element_name: str -) -> tuple[Code, int]: - """Decode a BSON code_w_scope to bson.code.Code.""" - code_end = position + _UNPACK_INT_FROM(data, position)[0] - code, position = _get_string(data, view, position + 4, code_end, opts, element_name) - scope, position = _get_object(data, view, position, code_end, opts, element_name) - if position != code_end: - raise InvalidBSON("scope outside of javascript code boundaries") - return Code(code, scope), position - - -def _get_regex( - data: Any, view: Any, position: int, dummy0: Any, opts: CodecOptions[Any], dummy1: Any -) -> tuple[Regex[Any], int]: - """Decode a BSON regex to bson.regex.Regex or a python pattern object.""" - pattern, position = _get_c_string(data, view, position, opts) - bson_flags, position = _get_c_string(data, view, position, opts) - bson_re = Regex(pattern, bson_flags) - return bson_re, position - - -def _get_ref( - data: Any, view: Any, position: int, obj_end: int, opts: CodecOptions[Any], element_name: str -) -> tuple[DBRef, int]: - """Decode (deprecated) BSON DBPointer to bson.dbref.DBRef.""" - collection, position = _get_string(data, view, position, obj_end, opts, element_name) - oid, position = _get_oid(data, view, position, obj_end, opts, element_name) - return DBRef(collection, oid), position - - -def _get_timestamp( - data: Any, _view: Any, position: int, dummy0: Any, dummy1: Any, dummy2: Any -) -> tuple[Timestamp, int]: - """Decode a BSON timestamp to bson.timestamp.Timestamp.""" - inc, timestamp = _UNPACK_TIMESTAMP_FROM(data, position) - return Timestamp(timestamp, inc), position + 8 - - -def _get_int64( - data: Any, _view: Any, position: int, dummy0: Any, dummy1: Any, dummy2: Any -) -> tuple[Int64, int]: - """Decode a BSON int64 to bson.int64.Int64.""" - return Int64(_UNPACK_LONG_FROM(data, position)[0]), position + 8 - - -def _get_decimal128( - data: Any, _view: Any, position: int, dummy0: Any, dummy1: Any, dummy2: Any -) -> tuple[Decimal128, int]: - """Decode a BSON decimal128 to bson.decimal128.Decimal128.""" - end = position + 16 - return Decimal128.from_bid(data[position:end]), end - - -# Each decoder function's signature is: -# - data: bytes -# - view: memoryview that references `data` -# - position: int, beginning of object in 'data' to decode -# - obj_end: int, end of object to decode in 'data' if variable-length type -# - opts: a CodecOptions -_ELEMENT_GETTER: dict[int, Callable[..., tuple[Any, int]]] = { - ord(BSONNUM): _get_float, - ord(BSONSTR): _get_string, - ord(BSONOBJ): _get_object, - ord(BSONARR): _get_array, - ord(BSONBIN): _get_binary, - ord(BSONUND): lambda u, v, w, x, y, z: (None, w), # noqa: ARG005 # Deprecated undefined - ord(BSONOID): _get_oid, - ord(BSONBOO): _get_boolean, - ord(BSONDAT): _get_date, - ord(BSONNUL): lambda u, v, w, x, y, z: (None, w), # noqa: ARG005 - ord(BSONRGX): _get_regex, - ord(BSONREF): _get_ref, # Deprecated DBPointer - ord(BSONCOD): _get_code, - ord(BSONSYM): _get_string, # Deprecated symbol - ord(BSONCWS): _get_code_w_scope, - ord(BSONINT): _get_int, - ord(BSONTIM): _get_timestamp, - ord(BSONLON): _get_int64, - ord(BSONDEC): _get_decimal128, - ord(BSONMIN): lambda u, v, w, x, y, z: (MinKey(), w), # noqa: ARG005 - ord(BSONMAX): lambda u, v, w, x, y, z: (MaxKey(), w), # noqa: ARG005 -} - - -if _USE_C: - - def _element_to_dict( - data: Any, - view: Any, # noqa: ARG001 - position: int, - obj_end: int, - opts: CodecOptions[Any], - raw_array: bool = False, - ) -> tuple[str, Any, int]: - return cast( - "tuple[str, Any, int]", - _cbson._element_to_dict(data, position, obj_end, opts, raw_array), - ) - -else: - - def _element_to_dict( - data: Any, - view: Any, - position: int, - obj_end: int, - opts: CodecOptions[Any], - raw_array: bool = False, - ) -> tuple[str, Any, int]: - """Decode a single key, value pair.""" - element_type = data[position] - position += 1 - element_name, position = _get_c_string(data, view, position, opts) - if raw_array and element_type == ord(BSONARR): - _, end = _get_object_size(data, position, len(data)) - return element_name, view[position : end + 1], end + 1 - try: - value, position = _ELEMENT_GETTER[element_type]( - data, view, position, obj_end, opts, element_name - ) - except KeyError: - _raise_unknown_type(element_type, element_name) - - if opts.type_registry._decoder_map: - custom_decoder = opts.type_registry._decoder_map.get(type(value)) - if custom_decoder is not None: - value = custom_decoder(value) - - return element_name, value, position - - -_T = TypeVar("_T", bound=MutableMapping[str, Any]) - - -if _USE_C: - - def _raw_to_dict( - data: Any, - position: int, - obj_end: int, - opts: CodecOptions[RawBSONDocument], - result: _T, - raw_array: bool = False, - ) -> _T: - return cast("_T", _cbson._raw_to_dict(data, position, obj_end, opts, result, raw_array)) - -else: - - def _raw_to_dict( - data: Any, - position: int, - obj_end: int, - opts: CodecOptions[RawBSONDocument], - result: _T, - raw_array: bool = False, - ) -> _T: - data, view = get_data_and_view(data) - return cast( - "_T", - _elements_to_dict(data, view, position, obj_end, opts, result, raw_array=raw_array), - ) - - -def _elements_to_dict( - data: Any, - view: Any, - position: int, - obj_end: int, - opts: CodecOptions[Any], - result: Any = None, - raw_array: bool = False, -) -> Any: - """Decode a BSON document into result.""" - if result is None: - result = opts.document_class() - end = obj_end - 1 - while position < end: - key, value, position = _element_to_dict( - data, view, position, obj_end, opts, raw_array=raw_array - ) - result[key] = value - if position != obj_end: - raise InvalidBSON("bad object or element length") - return result - - -def _bson_to_dict(data: Any, opts: CodecOptions[_DocumentType]) -> _DocumentType: - """Decode a BSON string to document_class.""" - data, view = get_data_and_view(data) - try: - if _raw_document_class(opts.document_class): - buf = _raw_slice(data, view, 0, len(data) - 1, len(data)) - return opts.document_class(buf, opts) # type:ignore[call-arg] - _, end = _get_object_size(data, 0, len(data)) - return cast("_DocumentType", _elements_to_dict(data, view, 4, end, opts)) - except InvalidBSON: - raise - except Exception: - # Change exception type to InvalidBSON but preserve traceback. - _, exc_value, exc_tb = sys.exc_info() - raise InvalidBSON(str(exc_value)).with_traceback(exc_tb) from None - - -if _USE_C: - _bson_to_dict = _cbson._bson_to_dict - - -_PACK_FLOAT = struct.Struct(" Generator[bytes, None, None]: - """Generate "keys" for encoded lists in the sequence - b"0\x00", b"1\x00", b"2\x00", ... - - The first 1000 keys are returned from a pre-built cache. All - subsequent keys are generated on the fly. - """ - yield from _LIST_NAMES - - counter = itertools.count(1000) - while True: - yield (str(next(counter)) + "\x00").encode("utf8") - - -def _make_c_string_check(string: str | bytes) -> bytes: - """Make a 'C' string, checking for embedded NUL characters.""" - if isinstance(string, bytes): - if b"\x00" in string: - raise InvalidDocument("BSON keys / regex patterns must not contain a NUL character") - try: - _utf_8_decode(string, None, True) - return string + b"\x00" - except UnicodeError: - raise InvalidStringData( - f"strings in documents must be valid UTF-8: {string!r}" - ) from None - else: - if "\x00" in string: - raise InvalidDocument("BSON keys / regex patterns must not contain a NUL character") - return _utf_8_encode(string)[0] + b"\x00" - - -def _make_c_string(string: str | bytes) -> bytes: - """Make a 'C' string.""" - if isinstance(string, bytes): - try: - _utf_8_decode(string, None, True) - return string + b"\x00" - except UnicodeError: - raise InvalidStringData( - f"strings in documents must be valid UTF-8: {string!r}" - ) from None - else: - return _utf_8_encode(string)[0] + b"\x00" - - -def _make_name(string: str) -> bytes: - """Make a 'C' string suitable for a BSON key.""" - if "\x00" in string: - raise InvalidDocument("BSON keys must not contain a NUL character") - return _utf_8_encode(string)[0] + b"\x00" - - -def _encode_float(name: bytes, value: float, dummy0: Any, dummy1: Any) -> bytes: - """Encode a float.""" - return b"\x01" + name + _PACK_FLOAT(value) - - -def _encode_bytes(name: bytes, value: bytes, dummy0: Any, dummy1: Any) -> bytes: - """Encode a python bytes.""" - # Python3 special case. Store 'bytes' as BSON binary subtype 0. - return b"\x05" + name + _PACK_INT(len(value)) + b"\x00" + value - - -def _encode_mapping(name: bytes, value: Any, check_keys: bool, opts: CodecOptions[Any]) -> bytes: - """Encode a mapping type.""" - if _raw_document_class(value): - # join avoids a copy by consuming a memoryview raw directly. - return b"".join((b"\x03", name, value.raw)) - data = b"".join([_element_to_bson(key, val, check_keys, opts) for key, val in value.items()]) - return b"\x03" + name + _PACK_INT(len(data) + 5) + data + b"\x00" - - -def _encode_dbref(name: bytes, value: DBRef, check_keys: bool, opts: CodecOptions[Any]) -> bytes: - """Encode bson.dbref.DBRef.""" - buf = bytearray(b"\x03" + name + b"\x00\x00\x00\x00") - begin = len(buf) - 4 - - buf += _name_value_to_bson(b"$ref\x00", value.collection, check_keys, opts) - buf += _name_value_to_bson(b"$id\x00", value.id, check_keys, opts) - if value.database is not None: - buf += _name_value_to_bson(b"$db\x00", value.database, check_keys, opts) - for key, val in value._DBRef__kwargs.items(): - buf += _element_to_bson(key, val, check_keys, opts) - - buf += b"\x00" - buf[begin : begin + 4] = _PACK_INT(len(buf) - begin) - return bytes(buf) - - -def _encode_list( - name: bytes, value: Sequence[Any], check_keys: bool, opts: CodecOptions[Any] -) -> bytes: - """Encode a list/tuple.""" - lname = gen_list_name() - data = b"".join([_name_value_to_bson(next(lname), item, check_keys, opts) for item in value]) - return b"\x04" + name + _PACK_INT(len(data) + 5) + data + b"\x00" - - -def _encode_text(name: bytes, value: str, dummy0: Any, dummy1: Any) -> bytes: - """Encode a python str.""" - bvalue = _utf_8_encode(value)[0] - return b"\x02" + name + _PACK_INT(len(bvalue) + 1) + bvalue + b"\x00" - - -def _encode_binary(name: bytes, value: Binary, dummy0: Any, dummy1: Any) -> bytes: - """Encode bson.binary.Binary.""" - subtype = value.subtype - if subtype == 2: - value = _PACK_INT(len(value)) + value # type: ignore - return b"\x05" + name + _PACK_LENGTH_SUBTYPE(len(value), subtype) + value - - -def _encode_uuid(name: bytes, value: uuid.UUID, dummy: Any, opts: CodecOptions[Any]) -> bytes: - """Encode uuid.UUID.""" - uuid_representation = opts.uuid_representation - binval = Binary.from_uuid(value, uuid_representation=uuid_representation) - return _encode_binary(name, binval, dummy, opts) - - -def _encode_objectid(name: bytes, value: ObjectId, dummy: Any, dummy1: Any) -> bytes: - """Encode bson.objectid.ObjectId.""" - return b"\x07" + name + value.binary - - -def _encode_bool(name: bytes, value: bool, dummy0: Any, dummy1: Any) -> bytes: - """Encode a python boolean (True/False).""" - return b"\x08" + name + ((value and b"\x01") or b"\x00") - - -def _encode_datetime(name: bytes, value: datetime.datetime, dummy0: Any, dummy1: Any) -> bytes: - """Encode datetime.datetime.""" - millis = _datetime_to_millis(value) - return b"\x09" + name + _PACK_LONG(millis) - - -def _encode_datetime_ms(name: bytes, value: DatetimeMS, dummy0: Any, dummy1: Any) -> bytes: - """Encode datetime.datetime.""" - millis = int(value) - return b"\x09" + name + _PACK_LONG(millis) - - -def _encode_none(name: bytes, dummy0: Any, dummy1: Any, dummy2: Any) -> bytes: - """Encode python None.""" - return b"\x0a" + name - - -def _encode_regex(name: bytes, value: Regex[Any], dummy0: Any, dummy1: Any) -> bytes: - """Encode a python regex or bson.regex.Regex.""" - flags = value.flags - # Python 3 common case - if flags == re.UNICODE: - return b"\x0b" + name + _make_c_string_check(value.pattern) + b"u\x00" - elif flags == 0: - return b"\x0b" + name + _make_c_string_check(value.pattern) + b"\x00" - else: - sflags = b"" - if flags & re.IGNORECASE: - sflags += b"i" - if flags & re.LOCALE: - sflags += b"l" - if flags & re.MULTILINE: - sflags += b"m" - if flags & re.DOTALL: - sflags += b"s" - if flags & re.UNICODE: - sflags += b"u" - if flags & re.VERBOSE: - sflags += b"x" - sflags += b"\x00" - return b"\x0b" + name + _make_c_string_check(value.pattern) + sflags - - -def _encode_code(name: bytes, value: Code, dummy: Any, opts: CodecOptions[Any]) -> bytes: - """Encode bson.code.Code.""" - cstring = _make_c_string(value) - cstrlen = len(cstring) - if value.scope is None: - return b"\x0d" + name + _PACK_INT(cstrlen) + cstring - scope = _dict_to_bson(value.scope, False, opts, False) - full_length = _PACK_INT(8 + cstrlen + len(scope)) - return b"\x0f" + name + full_length + _PACK_INT(cstrlen) + cstring + scope - - -def _encode_int(name: bytes, value: int, dummy0: Any, dummy1: Any) -> bytes: - """Encode a python int.""" - if -2147483648 <= value <= 2147483647: - return b"\x10" + name + _PACK_INT(value) - else: - try: - return b"\x12" + name + _PACK_LONG(value) - except struct.error: - raise OverflowError("BSON can only handle up to 8-byte ints") from None - - -def _encode_timestamp(name: bytes, value: Any, dummy0: Any, dummy1: Any) -> bytes: - """Encode bson.timestamp.Timestamp.""" - return b"\x11" + name + _PACK_TIMESTAMP(value.inc, value.time) - - -def _encode_long(name: bytes, value: Any, dummy0: Any, dummy1: Any) -> bytes: - """Encode a bson.int64.Int64.""" - try: - return b"\x12" + name + _PACK_LONG(value) - except struct.error: - raise OverflowError("BSON can only handle up to 8-byte ints") from None - - -def _encode_decimal128(name: bytes, value: Decimal128, dummy0: Any, dummy1: Any) -> bytes: - """Encode bson.decimal128.Decimal128.""" - return b"\x13" + name + value.bid - - -def _encode_minkey(name: bytes, dummy0: Any, dummy1: Any, dummy2: Any) -> bytes: - """Encode bson.min_key.MinKey.""" - return b"\xff" + name - - -def _encode_maxkey(name: bytes, dummy0: Any, dummy1: Any, dummy2: Any) -> bytes: - """Encode bson.max_key.MaxKey.""" - return b"\x7f" + name - - -# Each encoder function's signature is: -# - name: utf-8 bytes -# - value: a Python data type, e.g. a Python int for _encode_int -# - check_keys: bool, whether to check for invalid names -# - opts: a CodecOptions -_ENCODERS = { - bool: _encode_bool, - bytes: _encode_bytes, - datetime.datetime: _encode_datetime, - DatetimeMS: _encode_datetime_ms, - dict: _encode_mapping, - float: _encode_float, - int: _encode_int, - list: _encode_list, - str: _encode_text, - tuple: _encode_list, - type(None): _encode_none, - uuid.UUID: _encode_uuid, - Binary: _encode_binary, - Int64: _encode_long, - Code: _encode_code, - DBRef: _encode_dbref, - MaxKey: _encode_maxkey, - MinKey: _encode_minkey, - ObjectId: _encode_objectid, - Regex: _encode_regex, - RE_TYPE: _encode_regex, - SON: _encode_mapping, - Timestamp: _encode_timestamp, - Decimal128: _encode_decimal128, - # Special case. This will never be looked up directly. - _abc.Mapping: _encode_mapping, -} - -# Map each _type_marker to its encoder for faster lookup. -_MARKERS = {} -for _typ, _encoder in _ENCODERS.items(): - if hasattr(_typ, "_type_marker"): - _MARKERS[_typ._type_marker] = _encoder - - -_BUILT_IN_TYPES = tuple(t for t in _ENCODERS) - - -def _name_value_to_bson( - name: bytes, - value: Any, - check_keys: bool, - opts: CodecOptions[Any], - in_custom_call: bool = False, - in_fallback_call: bool = False, -) -> bytes: - """Encode a single name, value pair.""" - - was_integer_overflow = False - - # First see if the type is already cached. KeyError will only ever - # happen once per subtype. - try: - return _ENCODERS[type(value)](name, value, check_keys, opts) # type: ignore - except KeyError: - pass - except OverflowError: - if not isinstance(value, int): - raise - - # Give the fallback_encoder a chance - was_integer_overflow = True - - # Second, fall back to trying _type_marker. This has to be done - # before the loop below since users could subclass one of our - # custom types that subclasses a python built-in (e.g. Binary) - marker = getattr(value, "_type_marker", None) - if isinstance(marker, int) and marker in _MARKERS: - func = _MARKERS[marker] - # Cache this type for faster subsequent lookup. - _ENCODERS[type(value)] = func - return func(name, value, check_keys, opts) # type: ignore - - # Third, check if a type encoder is registered for this type. - # Note that subtypes of registered custom types are not auto-encoded. - if not in_custom_call and opts.type_registry._encoder_map: - custom_encoder = opts.type_registry._encoder_map.get(type(value)) - if custom_encoder is not None: - return _name_value_to_bson( - name, custom_encoder(value), check_keys, opts, in_custom_call=True - ) - - # Fourth, test each base type. This will only happen once for - # a subtype of a supported base type. Unlike in the C-extensions, this - # is done after trying the custom type encoder because checking for each - # subtype is expensive. - for base in _BUILT_IN_TYPES: - if not was_integer_overflow and isinstance(value, base): - func = _ENCODERS[base] - # Cache this type for faster subsequent lookup. - _ENCODERS[type(value)] = func - return func(name, value, check_keys, opts) # type: ignore - - # As a last resort, try using the fallback encoder, if the user has - # provided one. - fallback_encoder = opts.type_registry._fallback_encoder - if not in_fallback_call and fallback_encoder is not None: - return _name_value_to_bson( - name, fallback_encoder(value), check_keys, opts, in_fallback_call=True - ) - - if was_integer_overflow: - raise OverflowError("BSON can only handle up to 8-byte ints") - raise InvalidDocument(f"cannot encode object: {value!r}, of type: {type(value)!r}") - - -def _element_to_bson(key: Any, value: Any, check_keys: bool, opts: CodecOptions[Any]) -> bytes: - """Encode a single key, value pair.""" - if not isinstance(key, str): - raise InvalidDocument(f"documents must have only string keys, key was {key!r}") - if check_keys: - if key.startswith("$"): - raise InvalidDocument(f"key {key!r} must not start with '$'") - if "." in key: - raise InvalidDocument(f"key {key!r} must not contain '.'") - - name = _make_name(key) - return _name_value_to_bson(name, value, check_keys, opts) - - -def _dict_to_bson( - doc: Any, check_keys: bool, opts: CodecOptions[Any], top_level: bool = True -) -> bytes: - """Encode a document to BSON.""" - if _raw_document_class(doc): - return _raw_as_bytes(doc.raw) - try: - elements = [] - if top_level and "_id" in doc: - elements.append(_name_value_to_bson(b"_id\x00", doc["_id"], check_keys, opts)) - for key, value in doc.items(): - if not top_level or key != "_id": - try: - elements.append(_element_to_bson(key, value, check_keys, opts)) - except InvalidDocument as err: - raise InvalidDocument(f"Invalid document: {err}", doc) from err - except AttributeError: - raise TypeError(f"encoder expected a mapping type but got: {doc!r}") from None - - encoded = b"".join(elements) - return _PACK_INT(len(encoded) + 5) + encoded + b"\x00" - - -if _USE_C: - _dict_to_bson = _cbson._dict_to_bson - - -_CODEC_OPTIONS_TYPE_ERROR = TypeError("codec_options must be an instance of CodecOptions") - - -def encode( - document: Mapping[str, Any], - check_keys: bool = False, - codec_options: CodecOptions[Any] = DEFAULT_CODEC_OPTIONS, -) -> bytes: - """Encode a document to BSON. - - A document can be any mapping type (like :class:`dict`). - - Raises :class:`TypeError` if `document` is not a mapping type, - or contains keys that are not instances of :class:`str`. Raises - :class:`~bson.errors.InvalidDocument` if `document` cannot be - converted to :class:`BSON`. - - :param document: mapping type representing a document - :param check_keys: check if keys start with '$' or - contain '.', raising :class:`~bson.errors.InvalidDocument` in - either case - :param codec_options: An instance of - :class:`~bson.codec_options.CodecOptions`. - - .. versionadded:: 3.9 - """ - if not isinstance(codec_options, CodecOptions): - raise _CODEC_OPTIONS_TYPE_ERROR - - return _dict_to_bson(document, check_keys, codec_options) - - -@overload -def decode(data: _ReadableBuffer, codec_options: None = None) -> dict[str, Any]: ... - - -@overload -def decode(data: _ReadableBuffer, codec_options: CodecOptions[_DocumentType]) -> _DocumentType: ... - - -def decode( - data: _ReadableBuffer, codec_options: CodecOptions[_DocumentType] | None = None -) -> dict[str, Any] | _DocumentType: - """Decode BSON to a document. - - By default, returns a BSON document represented as a Python - :class:`dict`. To use a different :class:`MutableMapping` class, - configure a :class:`~bson.codec_options.CodecOptions`:: - - >>> import collections # From Python standard library. - >>> import bson - >>> from bson.codec_options import CodecOptions - >>> data = bson.encode({'a': 1}) - >>> decoded_doc = bson.decode(data) - - >>> options = CodecOptions(document_class=collections.OrderedDict) - >>> decoded_doc = bson.decode(data, codec_options=options) - >>> type(decoded_doc) - - - :param data: the BSON to decode. Any bytes-like object that implements - the buffer protocol. - :param codec_options: An instance of - :class:`~bson.codec_options.CodecOptions`. - - .. versionadded:: 3.9 - """ - opts: CodecOptions[Any] = codec_options or DEFAULT_CODEC_OPTIONS - if not isinstance(opts, CodecOptions): - raise _CODEC_OPTIONS_TYPE_ERROR - - return cast("dict[str, Any] | _DocumentType", _bson_to_dict(data, opts)) - - -def _decode_all(data: _ReadableBuffer, opts: CodecOptions[_DocumentType]) -> list[_DocumentType]: - """Decode a BSON data to multiple documents.""" - data, view = get_data_and_view(data) - data_len = len(data) - docs: list[_DocumentType] = [] - position = 0 - use_raw = _raw_document_class(opts.document_class) - try: - while position < data_len: - # A document is at minimum 5 bytes: the 4-byte size and the EOO. - if data_len - position < 5: - raise InvalidBSON("not enough data for a BSON document") - obj_size = _UNPACK_INT_FROM(data, position)[0] - if obj_size < 5: - raise InvalidBSON("invalid message size") - if data_len - position < obj_size: - raise InvalidBSON("objsize too large") - obj_end = position + obj_size - 1 - if data[obj_end] != 0: - raise InvalidBSON("bad eoo") - if use_raw: - raw_buf = _raw_slice(data, view, position, obj_end, obj_size) - docs.append(opts.document_class(raw_buf, opts)) # type: ignore - else: - docs.append(_elements_to_dict(data, view, position + 4, obj_end, opts)) - position += obj_size - return docs - except InvalidBSON: - raise - except Exception: - # Change exception type to InvalidBSON but preserve traceback. - _, exc_value, exc_tb = sys.exc_info() - raise InvalidBSON(str(exc_value)).with_traceback(exc_tb) from None - - -if _USE_C: - _decode_all = _cbson._decode_all - - -@overload -def decode_all(data: _ReadableBuffer, codec_options: None = None) -> list[dict[str, Any]]: ... - - -@overload -def decode_all( - data: _ReadableBuffer, codec_options: CodecOptions[_DocumentType] -) -> list[_DocumentType]: ... - - -def decode_all( - data: _ReadableBuffer, codec_options: CodecOptions[_DocumentType] | None = None -) -> list[dict[str, Any]] | list[_DocumentType]: - """Decode BSON data to multiple documents. - - `data` must be a bytes-like object implementing the buffer protocol that - provides concatenated, valid, BSON-encoded documents. - - :param data: BSON data - :param codec_options: An instance of - :class:`~bson.codec_options.CodecOptions`. - - .. versionchanged:: 3.9 - Supports bytes-like objects that implement the buffer protocol. - - .. versionchanged:: 3.0 - Removed `compile_re` option: PyMongo now always represents BSON regular - expressions as :class:`~bson.regex.Regex` objects. Use - :meth:`~bson.regex.Regex.try_compile` to attempt to convert from a - BSON regular expression to a Python regular expression object. - - Replaced `as_class`, `tz_aware`, and `uuid_subtype` options with - `codec_options`. - """ - if codec_options is None: - return _decode_all(data, DEFAULT_CODEC_OPTIONS) - - if not isinstance(codec_options, CodecOptions): - raise _CODEC_OPTIONS_TYPE_ERROR - - return _decode_all(data, codec_options) - - -def _decode_selective( - rawdoc: Any, fields: Any, codec_options: CodecOptions[_DocumentType] -) -> _DocumentType: - if _raw_document_class(codec_options.document_class): - # If document_class is RawBSONDocument, use vanilla dictionary for - # decoding command response. - doc: _DocumentType = {} # type:ignore[assignment] - else: - # Else, use the specified document_class. - doc = codec_options.document_class() - for key, value in rawdoc.items(): - if key in fields: - if fields[key] == 1: - doc[key] = _bson_to_dict(rawdoc.raw, codec_options)[key] # type:ignore[index] - else: - doc[key] = _decode_selective( # type:ignore[index] - value, fields[key], codec_options - ) - else: - doc[key] = value # type:ignore[index] - return doc - - -def _array_of_documents_to_buffer(data: memoryview | bytes) -> bytes: - # Extract the raw bytes of each document. - position = 0 - view = memoryview(data) - _, end = _get_object_size(view, position, len(view)) - position += 4 - buffers: list[memoryview] = [] - append = buffers.append - while position < end - 1: - # Just skip the keys. - while view[position] != 0: - position += 1 - position += 1 - obj_size, _ = _get_object_size(view, position, end) - append(view[position : position + obj_size]) - position += obj_size - if position != end: - raise InvalidBSON("bad object or element length") - return b"".join(buffers) - - -if _USE_C: - _array_of_documents_to_buffer = _cbson._array_of_documents_to_buffer - - -def _convert_raw_document_lists_to_streams(document: Any) -> None: - """Convert raw array of documents to a stream of BSON documents.""" - cursor = document.get("cursor") - if not cursor: - return - for key in ("firstBatch", "nextBatch"): - batch = cursor.get(key) - if not batch: - continue - data = _array_of_documents_to_buffer(batch) - if data: - cursor[key] = [data] - else: - cursor[key] = [] - - -def _decode_all_selective( - data: Any, codec_options: CodecOptions[_DocumentType], fields: Any -) -> list[_DocumentType]: - """Decode BSON data to a single document while using user-provided - custom decoding logic. - - `data` must be a string representing a valid, BSON-encoded document. - - :param data: BSON data - :param codec_options: An instance of - :class:`~bson.codec_options.CodecOptions` with user-specified type - decoders. If no decoders are found, this method is the same as - ``decode_all``. - :param fields: Map of document namespaces where data that needs - to be custom decoded lives or None. For example, to custom decode a - list of objects in 'field1.subfield1', the specified value should be - ``{'field1': {'subfield1': 1}}``. If ``fields`` is an empty map or - None, this method is the same as ``decode_all``. - - :return: Single-member list containing the decoded document. - - .. versionadded:: 3.8 - """ - if not codec_options.type_registry._decoder_map: - return decode_all(data, codec_options) - - if not fields: - return decode_all(data, codec_options.with_options(type_registry=None)) - - # Decode documents for internal use. - from bson.raw_bson import RawBSONDocument - - internal_codec_options: CodecOptions[RawBSONDocument] = codec_options.with_options( - document_class=RawBSONDocument, type_registry=None - ) - _doc = _bson_to_dict(data, internal_codec_options) - return [ - _decode_selective( - _doc, - fields, - codec_options, - ) - ] - - -@overload -def decode_iter(data: bytes, codec_options: None = None) -> Iterator[dict[str, Any]]: ... - - -@overload -def decode_iter( - data: bytes, codec_options: CodecOptions[_DocumentType] -) -> Iterator[_DocumentType]: ... - - -def decode_iter( - data: bytes, codec_options: CodecOptions[_DocumentType] | None = None -) -> Iterator[dict[str, Any]] | Iterator[_DocumentType]: - """Decode BSON data to multiple documents as a generator. - - Works similarly to the decode_all function, but yields one document at a - time. - - `data` must be a string of concatenated, valid, BSON-encoded - documents. - - :param data: BSON data - :param codec_options: An instance of - :class:`~bson.codec_options.CodecOptions`. - - .. versionchanged:: 3.0 - Replaced `as_class`, `tz_aware`, and `uuid_subtype` options with - `codec_options`. - - .. versionadded:: 2.8 - """ - opts = codec_options or DEFAULT_CODEC_OPTIONS - if not isinstance(opts, CodecOptions): - raise _CODEC_OPTIONS_TYPE_ERROR - - position = 0 - end = len(data) - 1 - while position < end: - obj_size = _UNPACK_INT_FROM(data, position)[0] - elements = data[position : position + obj_size] - position += obj_size - - yield _bson_to_dict(elements, opts) - - -@overload -def decode_file_iter( - file_obj: BinaryIO | IO[bytes], codec_options: None = None -) -> Iterator[dict[str, Any]]: ... - - -@overload -def decode_file_iter( - file_obj: BinaryIO | IO[bytes], codec_options: CodecOptions[_DocumentType] -) -> Iterator[_DocumentType]: ... - - -def decode_file_iter( - file_obj: BinaryIO | IO[bytes], - codec_options: CodecOptions[_DocumentType] | None = None, -) -> Iterator[dict[str, Any]] | Iterator[_DocumentType]: - """Decode bson data from a file to multiple documents as a generator. - - Works similarly to the decode_all function, but reads from the file object - in chunks and parses bson in chunks, yielding one document at a time. - - :param file_obj: A file object containing BSON data. - :param codec_options: An instance of - :class:`~bson.codec_options.CodecOptions`. - - .. versionchanged:: 3.0 - Replaced `as_class`, `tz_aware`, and `uuid_subtype` options with - `codec_options`. - - .. versionadded:: 2.8 - """ - opts = codec_options or DEFAULT_CODEC_OPTIONS - while True: - # Read size of next object. - size_data: Any = file_obj.read(4) - if not size_data: - break # Finished with file normally. - elif len(size_data) != 4: - raise InvalidBSON("cut off in middle of objsize") - obj_size = _UNPACK_INT_FROM(size_data, 0)[0] - 4 - elements = size_data + file_obj.read(max(0, obj_size)) - yield _bson_to_dict(elements, opts) # type:ignore[misc] - - -def is_valid(bson: bytes) -> bool: - """Check that the given string represents valid :class:`BSON` data. - - Raises :class:`TypeError` if `bson` is not an instance of - :class:`bytes`. Returns ``True`` - if `bson` is valid :class:`BSON`, ``False`` otherwise. - - :param bson: the data to be validated - """ - if not isinstance(bson, bytes): - raise TypeError(f"BSON data must be an instance of a subclass of bytes, not {type(bson)}") - - try: - _bson_to_dict(bson, DEFAULT_CODEC_OPTIONS) - return True - except Exception: - return False - - -class BSON(bytes): - """BSON (Binary JSON) data. - - .. warning:: Using this class to encode and decode BSON adds a performance - cost. For better performance use the module level functions - :func:`encode` and :func:`decode` instead. - """ - - @classmethod - def encode( - cls: type[BSON], - document: Mapping[str, Any], - check_keys: bool = False, - codec_options: CodecOptions[Any] = DEFAULT_CODEC_OPTIONS, - ) -> BSON: - """Encode a document to a new :class:`BSON` instance. - - A document can be any mapping type (like :class:`dict`). - - Raises :class:`TypeError` if `document` is not a mapping type, - or contains keys that are not instances of - :class:`str'. Raises :class:`~bson.errors.InvalidDocument` - if `document` cannot be converted to :class:`BSON`. - - :param document: mapping type representing a document - :param check_keys: check if keys start with '$' or - contain '.', raising :class:`~bson.errors.InvalidDocument` in - either case - :param codec_options: An instance of - :class:`~bson.codec_options.CodecOptions`. - - .. versionchanged:: 3.0 - Replaced `uuid_subtype` option with `codec_options`. - """ - return cls(encode(document, check_keys, codec_options)) - - def decode( # type:ignore[override] - self, codec_options: CodecOptions[Any] = DEFAULT_CODEC_OPTIONS - ) -> dict[str, Any]: - """Decode this BSON data. - - By default, returns a BSON document represented as a Python - :class:`dict`. To use a different :class:`MutableMapping` class, - configure a :class:`~bson.codec_options.CodecOptions`:: - - >>> import collections # From Python standard library. - >>> import bson - >>> from bson.codec_options import CodecOptions - >>> data = bson.BSON.encode({'a': 1}) - >>> decoded_doc = bson.BSON(data).decode() - - >>> options = CodecOptions(document_class=collections.OrderedDict) - >>> decoded_doc = bson.BSON(data).decode(codec_options=options) - >>> type(decoded_doc) - - - :param codec_options: An instance of - :class:`~bson.codec_options.CodecOptions`. - - .. versionchanged:: 3.0 - Removed `compile_re` option: PyMongo now always represents BSON - regular expressions as :class:`~bson.regex.Regex` objects. Use - :meth:`~bson.regex.Regex.try_compile` to attempt to convert from a - BSON regular expression to a Python regular expression object. - - Replaced `as_class`, `tz_aware`, and `uuid_subtype` options with - `codec_options`. - """ - return decode(self, codec_options) - - -def has_c() -> bool: - """Is the C extension installed?""" - return _USE_C - - -def _after_fork() -> None: - """Releases the ObjectID lock child.""" - if ObjectId._inc_lock.locked(): - ObjectId._inc_lock.release() - - -if hasattr(os, "register_at_fork"): - # This will run in the same thread as the fork was called. - # If we fork in a critical region on the same thread, it should break. - # This is fine since we would never call fork directly from a critical region. - os.register_at_fork(after_in_child=_after_fork) diff --git a/bson/_cbsonmodule.c b/bson/_cbsonmodule.c deleted file mode 100644 index a0deb7de77..0000000000 --- a/bson/_cbsonmodule.c +++ /dev/null @@ -1,3723 +0,0 @@ -/* - * Copyright 2009-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * This file contains C implementations of some of the functions - * needed by the bson module. If possible, these implementations - * should be used to speed up BSON encoding and decoding. - */ - -#define PY_SSIZE_T_CLEAN -#include "Python.h" -#include "datetime.h" - -#include "buffer.h" -#include "time64.h" - -#define _CBSON_MODULE -#include "_cbsonmodule.h" - -/* New module state and initialization code. - * See the module-initialization-and-state - * section in the following doc: - * http://docs.python.org/release/3.1.3/howto/cporting.html - * which references the following pep: - * http://www.python.org/dev/peps/pep-3121/ - * */ -struct module_state { - PyObject* Binary; - PyObject* Code; - PyObject* ObjectId; - PyObject* DBRef; - PyObject* Regex; - PyObject* UUID; - PyObject* Timestamp; - PyObject* MinKey; - PyObject* MaxKey; - PyObject* UTC; - PyTypeObject* REType; - PyObject* BSONInt64; - PyObject* Decimal128; - PyObject* Mapping; - PyObject* DatetimeMS; - PyObject* min_datetime; - PyObject* max_datetime; - PyObject* replace_args; - PyObject* replace_kwargs; - PyObject* _type_marker_str; - PyObject* _flags_str; - PyObject* _pattern_str; - PyObject* _encoder_map_str; - PyObject* _decoder_map_str; - PyObject* _fallback_encoder_str; - PyObject* _raw_str; - PyObject* _subtype_str; - PyObject* _binary_str; - PyObject* _scope_str; - PyObject* _inc_str; - PyObject* _time_str; - PyObject* _bid_str; - PyObject* _replace_str; - PyObject* _astimezone_str; - PyObject* _id_str; - PyObject* _dollar_ref_str; - PyObject* _dollar_id_str; - PyObject* _dollar_db_str; - PyObject* _tzinfo_str; - PyObject* _as_doc_str; - PyObject* _utcoffset_str; - PyObject* _from_uuid_str; - PyObject* _as_uuid_str; - PyObject* _from_bid_str; - int64_t min_millis; - int64_t max_millis; - Py_ssize_t raw_bson_view_threshold; -}; - -#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) - -/* Maximum number of regex flags */ -#define FLAGS_SIZE 7 - -/* Default UUID representation type code. */ -#define PYTHON_LEGACY 3 - -/* Other UUID representations. */ -#define STANDARD 4 -#define JAVA_LEGACY 5 -#define CSHARP_LEGACY 6 -#define UNSPECIFIED 0 - -#define BSON_MAX_SIZE 2147483647 -/* The smallest possible BSON document, i.e. "{}" */ -#define BSON_MIN_SIZE 5 - -/* Datetime codec options */ -#define DATETIME 1 -#define DATETIME_CLAMP 2 -#define DATETIME_MS 3 -#define DATETIME_AUTO 4 -#define PYTHON_3_12 0x030C0000 - -/* Converts integer to its string representation in decimal notation. */ -extern int cbson_long_long_to_str(long long num, char* str, size_t size) { - // Buffer should fit 64-bit signed integer - if (size < 21) { - PyErr_Format( - PyExc_RuntimeError, - "Buffer too small to hold long long: %d < 21", size); - return -1; - } - int index = 0; - int sign = 1; - // Convert to unsigned to handle -LLONG_MIN overflow - unsigned long long absNum; - // Handle the case of 0 - if (num == 0) { - str[index++] = '0'; - str[index] = '\0'; - return 0; - } - // Handle negative numbers - if (num < 0) { - sign = -1; - absNum = 0ULL - (unsigned long long)num; - } else { - absNum = (unsigned long long)num; - } - // Convert the number to string - unsigned long long digit; - while (absNum > 0) { - digit = absNum % 10ULL; - str[index++] = (char)digit + '0'; // Convert digit to character - absNum /= 10; - } - // Add minus sign if negative - if (sign == -1) { - str[index++] = '-'; - } - str[index] = '\0'; // Null terminator - // Reverse the string - int start = 0; - int end = index - 1; - while (start < end) { - char temp = str[start]; - str[start++] = str[end]; - str[end--] = temp; - } - return 0; -} - -static PyObject* _test_long_long_to_str(PyObject* self, PyObject* args) { - // Test extreme values - Py_ssize_t maxNum = PY_SSIZE_T_MAX; - Py_ssize_t minNum = PY_SSIZE_T_MIN; - Py_ssize_t num; - char str_1[BUF_SIZE]; - char str_2[BUF_SIZE]; - int res = LL2STR(str_1, (long long)minNum); - if (res == -1) { - return NULL; - } - INT2STRING(str_2, (long long)minNum); - if (strcmp(str_1, str_2) != 0) { - PyErr_Format( - PyExc_RuntimeError, - "LL2STR != INT2STRING: %s != %s", str_1, str_2); - return NULL; - } - LL2STR(str_1, (long long)maxNum); - INT2STRING(str_2, (long long)maxNum); - if (strcmp(str_1, str_2) != 0) { - PyErr_Format( - PyExc_RuntimeError, - "LL2STR != INT2STRING: %s != %s", str_1, str_2); - return NULL; - } - - // Test common values - for (num = 0; num < 10000; num++) { - char str_1[BUF_SIZE]; - char str_2[BUF_SIZE]; - LL2STR(str_1, (long long)num); - INT2STRING(str_2, (long long)num); - if (strcmp(str_1, str_2) != 0) { - PyErr_Format( - PyExc_RuntimeError, - "LL2STR != INT2STRING: %s != %s", str_1, str_2); - return NULL; - } - } - - return args; -} - -/* Get an error class from the bson.errors module. - * - * Returns a new ref */ -static PyObject* _error(char* name) { - PyObject* error = NULL; - PyObject* errors = PyImport_ImportModule("bson.errors"); - if (!errors) { - return NULL; - } - error = PyObject_GetAttrString(errors, name); - Py_DECREF(errors); - return error; -} - -/* Safely downcast from Py_ssize_t to int, setting an - * exception and returning -1 on error. */ -static int -_downcast_and_check(Py_ssize_t size, uint8_t extra) { - if (size > BSON_MAX_SIZE || ((BSON_MAX_SIZE - extra) < size)) { - PyObject* InvalidStringData = _error("InvalidStringData"); - if (InvalidStringData) { - PyErr_SetString(InvalidStringData, - "String length must be <= 2147483647"); - Py_DECREF(InvalidStringData); - } - return -1; - } - return (int)size + extra; -} - -static PyObject* elements_to_dict(PyObject* self, const char* string, - unsigned max, - const codec_options_t* options); - -static int _write_element_to_buffer(PyObject* self, buffer_t buffer, - int type_byte, PyObject* value, - unsigned char check_keys, - const codec_options_t* options, - unsigned char in_custom_call, - unsigned char in_fallback_call); - -/* Write a RawBSONDocument to the buffer. - * Returns the number of bytes written or 0 on failure. - */ -static int write_raw_doc(buffer_t buffer, PyObject* raw, PyObject* _raw); - -/* Get a read-only buffer view of a bytes-like object. - * Returns 1 on success or 0 on failure with an exception set. - */ -static int _get_buffer(PyObject *exporter, Py_buffer *view); - -#if PY_VERSION_HEX >= PYTHON_3_12 -/* Transfer traceback from old_exc to new_exc. - * Steals reference to old_exc. */ -static PyObject* _transfer_traceback(PyObject *old_exc, PyObject *new_exc) { - PyObject *tb = PyException_GetTraceback(old_exc); - if (tb) { - PyException_SetTraceback(new_exc, tb); - Py_DECREF(tb); - } - Py_DECREF(old_exc); - return new_exc; -} -#endif - -/* Rewrap the current exception as InvalidBSON(str(e)) if it is not already an InvalidBSON error. */ -static void _rewrap_as_invalid_bson(void) { -#if PY_VERSION_HEX >= PYTHON_3_12 - PyObject *exc = PyErr_GetRaisedException(); - if (exc && PyErr_GivenExceptionMatches(exc, PyExc_Exception)) { - PyObject *InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - if (!PyErr_GivenExceptionMatches(exc, InvalidBSON)) { - PyObject *err_msg = PyObject_Str(exc); - if (err_msg) { - PyObject *new_exc = PyObject_CallOneArg(InvalidBSON, err_msg); - if (new_exc) { - exc = _transfer_traceback(exc, new_exc); - } - } - Py_XDECREF(err_msg); - } - Py_DECREF(InvalidBSON); - } - } - /* Steals reference to exc. */ - PyErr_SetRaisedException(exc); -#else - PyObject *etype = NULL, *evalue = NULL, *etrace = NULL; - PyObject *InvalidBSON = NULL; - PyErr_Fetch(&etype, &evalue, &etrace); - if (PyErr_GivenExceptionMatches(etype, PyExc_Exception)) { - InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - if (!PyErr_GivenExceptionMatches(etype, InvalidBSON)) { - Py_DECREF(etype); - etype = InvalidBSON; - if (evalue) { - PyObject *msg = PyObject_Str(evalue); - Py_DECREF(evalue); - evalue = msg; - } - PyErr_NormalizeException(&etype, &evalue, &etrace); - } else { - Py_DECREF(InvalidBSON); - } - } - } - PyErr_Restore(etype, evalue, etrace); -#endif -} - -/* Date stuff */ -static PyObject* datetime_from_millis(long long millis) { - /* To encode a datetime instance like datetime(9999, 12, 31, 23, 59, 59, 999999) - * we follow these steps: - * 1. Calculate a timestamp in seconds: 253402300799 - * 2. Multiply that by 1000: 253402300799000 - * 3. Add in microseconds divided by 1000 253402300799999 - * - * (Note: BSON doesn't support microsecond accuracy, hence the truncation.) - * - * To decode we could do: - * 1. Get seconds: timestamp / 1000: 253402300799 - * 2. Get micros: (timestamp % 1000) * 1000: 999000 - * Resulting in datetime(9999, 12, 31, 23, 59, 59, 999000) -- the expected result - * - * Now what if the we encode (1, 1, 1, 1, 1, 1, 111111)? - * 1. and 2. gives: -62135593139000 - * 3. Gives us: -62135593138889 - * - * Now decode: - * 1. Gives us: -62135593138 - * 2. Gives us: -889000 - * Resulting in datetime(1, 1, 1, 1, 1, 2, 15888216) -- an invalid result - * - * If instead to decode we do: - * diff = ((millis % 1000) + 1000) % 1000: 111 - * seconds = (millis - diff) / 1000: -62135593139 - * micros = diff * 1000 111000 - * Resulting in datetime(1, 1, 1, 1, 1, 1, 111000) -- the expected result - */ - PyObject* datetime = NULL; - int diff = (int)(((millis % 1000) + 1000) % 1000); - int microseconds = diff * 1000; - Time64_T seconds = (millis - diff) / 1000; - struct TM timeinfo; - cbson_gmtime64_r(&seconds, &timeinfo); - - datetime = PyDateTime_FromDateAndTime(timeinfo.tm_year + 1900, - timeinfo.tm_mon + 1, - timeinfo.tm_mday, - timeinfo.tm_hour, - timeinfo.tm_min, - timeinfo.tm_sec, - microseconds); - if(!datetime) { - #if PY_VERSION_HEX >= PYTHON_3_12 - PyObject *exc = PyErr_GetRaisedException(); - - /* Only add additional error message on ValueError exceptions. */ - if (exc && PyErr_GivenExceptionMatches(exc, PyExc_ValueError)) { - PyObject* err_msg = PyObject_Str(exc); - if (err_msg) { - PyObject* appendage = PyUnicode_FromString(" (Consider Using CodecOptions(datetime_conversion=DATETIME_AUTO) or MongoClient(datetime_conversion='DATETIME_AUTO')). See: https://www.mongodb.com/docs/languages/python/pymongo-driver/current/data-formats/dates-and-times/#handling-out-of-range-datetimes"); - if (appendage) { - PyObject* msg = PyUnicode_Concat(err_msg, appendage); - if (msg) { - PyObject* new_exc = PyObject_CallOneArg(PyExc_ValueError, msg); - if (new_exc) { - exc = _transfer_traceback(exc, new_exc); - } - Py_DECREF(msg); - } - } - Py_XDECREF(appendage); - } - Py_XDECREF(err_msg); - } - /* Steals reference to exc. */ - PyErr_SetRaisedException(exc); - #else - /* Calling _error clears the error state, so fetch it first.*/ - PyObject *etype = NULL, *evalue = NULL, *etrace = NULL; - PyErr_Fetch(&etype, &evalue, &etrace); - - /* Only add additional error message on ValueError exceptions. */ - if (PyErr_GivenExceptionMatches(etype, PyExc_ValueError)) { - if (evalue) { - PyObject* err_msg = PyObject_Str(evalue); - if (err_msg) { - PyObject* appendage = PyUnicode_FromString(" (Consider Using CodecOptions(datetime_conversion=DATETIME_AUTO) or MongoClient(datetime_conversion='DATETIME_AUTO')). See: https://www.mongodb.com/docs/languages/python/pymongo-driver/current/data-formats/dates-and-times/#handling-out-of-range-datetimes"); - if (appendage) { - PyObject* msg = PyUnicode_Concat(err_msg, appendage); - if (msg) { - Py_DECREF(evalue); - evalue = msg; - } - } - Py_XDECREF(appendage); - } - Py_XDECREF(err_msg); - } - PyErr_NormalizeException(&etype, &evalue, &etrace); - } - /* Steals references to args. */ - PyErr_Restore(etype, evalue, etrace); - #endif - } - return datetime; -} - -static long long millis_from_datetime(PyObject* datetime) { - struct TM timeinfo; - long long millis; - - timeinfo.tm_year = PyDateTime_GET_YEAR(datetime) - 1900; - timeinfo.tm_mon = PyDateTime_GET_MONTH(datetime) - 1; - timeinfo.tm_mday = PyDateTime_GET_DAY(datetime); - timeinfo.tm_hour = PyDateTime_DATE_GET_HOUR(datetime); - timeinfo.tm_min = PyDateTime_DATE_GET_MINUTE(datetime); - timeinfo.tm_sec = PyDateTime_DATE_GET_SECOND(datetime); - - millis = cbson_timegm64(&timeinfo) * 1000; - millis += PyDateTime_DATE_GET_MICROSECOND(datetime) / 1000; - return millis; -} - -/* Extended-range datetime, returns a DatetimeMS object with millis */ -static PyObject* datetime_ms_from_millis(PyObject* self, long long millis){ - // Allocate a new DatetimeMS object. - struct module_state *state = GETSTATE(self); - if (!state) { - return NULL; - } - - PyObject* dt = NULL; - PyObject* ll_millis = NULL; - - if (!(ll_millis = PyLong_FromLongLong(millis))){ - return NULL; - } - PyObject* args[1] = {ll_millis}; - dt = PyObject_Vectorcall(state->DatetimeMS, args, 1, NULL); - Py_DECREF(ll_millis); - return dt; -} - -/* Extended-range datetime, takes a DatetimeMS object and extracts the long long value. */ -static int millis_from_datetime_ms(PyObject* dt, long long* out){ - PyObject* ll_millis; - long long millis; - - if (!(ll_millis = PyNumber_Long(dt))){ - return 0; - } - millis = PyLong_AsLongLong(ll_millis); - Py_DECREF(ll_millis); - if (millis == -1 && PyErr_Occurred()) { /* Overflow */ - PyErr_SetString(PyExc_OverflowError, - "MongoDB datetimes can only handle up to 8-byte ints"); - return 0; - } - *out = millis; - return 1; -} - -static PyObject* decode_datetime(PyObject* self, long long millis, const codec_options_t* options){ - PyObject* naive = NULL; - PyObject* replace = NULL; - PyObject* value = NULL; - struct module_state *state = GETSTATE(self); - if (!state) { - goto invalid; - } - if (options->datetime_conversion == DATETIME_MS){ - return datetime_ms_from_millis(self, millis); - } - - int dt_clamp = options->datetime_conversion == DATETIME_CLAMP; - int dt_auto = options->datetime_conversion == DATETIME_AUTO; - - if (dt_clamp || dt_auto){ - int64_t min_millis = state->min_millis; - int64_t max_millis = state->max_millis; - int64_t min_millis_offset = 0; - int64_t max_millis_offset = 0; - if (options->tz_aware && options->tzinfo && options->tzinfo != Py_None) { - PyObject* utcoffset_args[2] = {options->tzinfo, state->min_datetime}; - PyObject* utcoffset = PyObject_VectorcallMethod( - state->_utcoffset_str, utcoffset_args, 2, NULL); - if (utcoffset == NULL) { - return 0; - } - if (utcoffset != Py_None) { - if (!PyDelta_Check(utcoffset)) { - PyObject* BSONError = _error("BSONError"); - if (BSONError) { - PyErr_SetString(BSONError, "tzinfo.utcoffset() did not return a datetime.timedelta"); - Py_DECREF(BSONError); - } - Py_DECREF(utcoffset); - return 0; - } - min_millis_offset = (PyDateTime_DELTA_GET_DAYS(utcoffset) * (int64_t)86400 + - PyDateTime_DELTA_GET_SECONDS(utcoffset)) * (int64_t)1000 + - (PyDateTime_DELTA_GET_MICROSECONDS(utcoffset) / 1000); - } - Py_DECREF(utcoffset); - utcoffset_args[1] = state->max_datetime; - utcoffset = PyObject_VectorcallMethod( - state->_utcoffset_str, utcoffset_args, 2, NULL); - if (utcoffset == NULL) { - return 0; - } - if (utcoffset != Py_None) { - if (!PyDelta_Check(utcoffset)) { - PyObject* BSONError = _error("BSONError"); - if (BSONError) { - PyErr_SetString(BSONError, "tzinfo.utcoffset() did not return a datetime.timedelta"); - Py_DECREF(BSONError); - } - Py_DECREF(utcoffset); - return 0; - } - max_millis_offset = (PyDateTime_DELTA_GET_DAYS(utcoffset) * (int64_t)86400 + - PyDateTime_DELTA_GET_SECONDS(utcoffset)) * (int64_t)1000 + - (PyDateTime_DELTA_GET_MICROSECONDS(utcoffset) / 1000); - } - Py_DECREF(utcoffset); - } - if (min_millis_offset < 0) { - min_millis -= min_millis_offset; - } - - if (max_millis_offset > 0) { - max_millis -= max_millis_offset; - } - - if (dt_clamp) { - if (millis < min_millis) { - millis = min_millis; - } else if (millis > max_millis) { - millis = max_millis; - } - // Continues from here to return a datetime. - } else { // dt_auto - if (millis < min_millis || millis > max_millis){ - return datetime_ms_from_millis(self, millis); - } - } - } - - naive = datetime_from_millis(millis); - if (!naive) { - goto invalid; - } - - if (!options->tz_aware) { /* In the naive case, we're done here. */ - return naive; - } - replace = PyObject_GetAttr(naive, state->_replace_str); - if (!replace) { - goto invalid; - } - value = PyObject_Call(replace, state->replace_args, state->replace_kwargs); - if (!value) { - goto invalid; - } - - /* convert to local time */ - if (options->tzinfo != Py_None) { - PyObject* astimezone_args[2] = {value, options->tzinfo}; - PyObject* temp = PyObject_VectorcallMethod( - state->_astimezone_str, astimezone_args, 2, NULL); - Py_DECREF(value); - value = temp; - } -invalid: - Py_XDECREF(naive); - Py_XDECREF(replace); - return value; -} - -/* Just make this compatible w/ the old API. */ -int buffer_write_bytes(buffer_t buffer, const char* data, int size) { - if (pymongo_buffer_write(buffer, data, size)) { - return 0; - } - return 1; -} - -int buffer_write_double(buffer_t buffer, double data) { - double data_le = BSON_DOUBLE_TO_LE(data); - return buffer_write_bytes(buffer, (const char*)&data_le, 8); -} - -int buffer_write_int32(buffer_t buffer, int32_t data) { - uint32_t data_le = BSON_UINT32_TO_LE(data); - return buffer_write_bytes(buffer, (const char*)&data_le, 4); -} - -int buffer_write_int64(buffer_t buffer, int64_t data) { - uint64_t data_le = BSON_UINT64_TO_LE(data); - return buffer_write_bytes(buffer, (const char*)&data_le, 8); -} - -void buffer_write_int32_at_position(buffer_t buffer, - int position, - int32_t data) { - uint32_t data_le = BSON_UINT32_TO_LE(data); - memcpy(pymongo_buffer_get_buffer(buffer) + position, &data_le, 4); -} - -static int write_unicode(buffer_t buffer, PyObject* py_string) { - int size; - const char* data; - PyObject* encoded = PyUnicode_AsUTF8String(py_string); - if (!encoded) { - return 0; - } - data = PyBytes_AS_STRING(encoded); - if (!data) - goto unicodefail; - - if ((size = _downcast_and_check(PyBytes_GET_SIZE(encoded), 1)) == -1) - goto unicodefail; - - if (!buffer_write_int32(buffer, (int32_t)size)) - goto unicodefail; - - if (!buffer_write_bytes(buffer, data, size)) - goto unicodefail; - - Py_DECREF(encoded); - return 1; - -unicodefail: - Py_DECREF(encoded); - return 0; -} - -/* returns 0 on failure */ -static int write_string(buffer_t buffer, PyObject* py_string) { - int size; - const char* data; - if (PyUnicode_Check(py_string)){ - return write_unicode(buffer, py_string); - } - data = PyBytes_AsString(py_string); - if (!data) { - return 0; - } - - if ((size = _downcast_and_check(PyBytes_Size(py_string), 1)) == -1) - return 0; - - if (!buffer_write_int32(buffer, (int32_t)size)) { - return 0; - } - if (!buffer_write_bytes(buffer, data, size)) { - return 0; - } - return 1; -} - -/* Load a Python object to cache. - * - * Returns non-zero on failure. */ -static int _load_object(PyObject** object, char* module_name, char* object_name) { - PyObject* module; - - module = PyImport_ImportModule(module_name); - if (!module) { - return 1; - } - - *object = PyObject_GetAttrString(module, object_name); - Py_DECREF(module); - - return (*object) ? 0 : 2; -} - -/* Load all Python objects to cache. - * - * Returns non-zero on failure. */ -static int _load_python_objects(PyObject* module) { - PyObject* empty_string = NULL; - PyObject* re_compile = NULL; - PyObject* compiled = NULL; - PyObject* min_datetime_ms = NULL; - PyObject* max_datetime_ms = NULL; - PyObject* raw_bson_view_threshold = NULL; - struct module_state *state = GETSTATE(module); - if (!state) { - return 1; - } - - /* Cache commonly used attribute names to improve performance. */ - if (!((state->_type_marker_str = PyUnicode_FromString("_type_marker")) && - (state->_flags_str = PyUnicode_FromString("flags")) && - (state->_pattern_str = PyUnicode_FromString("pattern")) && - (state->_encoder_map_str = PyUnicode_FromString("_encoder_map")) && - (state->_decoder_map_str = PyUnicode_FromString("_decoder_map")) && - (state->_fallback_encoder_str = PyUnicode_FromString("_fallback_encoder")) && - (state->_raw_str = PyUnicode_FromString("raw")) && - (state->_subtype_str = PyUnicode_FromString("subtype")) && - (state->_binary_str = PyUnicode_FromString("binary")) && - (state->_scope_str = PyUnicode_FromString("scope")) && - (state->_inc_str = PyUnicode_FromString("inc")) && - (state->_time_str = PyUnicode_FromString("time")) && - (state->_bid_str = PyUnicode_FromString("bid")) && - (state->_replace_str = PyUnicode_FromString("replace")) && - (state->_astimezone_str = PyUnicode_FromString("astimezone")) && - (state->_id_str = PyUnicode_FromString("_id")) && - (state->_dollar_ref_str = PyUnicode_FromString("$ref")) && - (state->_dollar_id_str = PyUnicode_FromString("$id")) && - (state->_dollar_db_str = PyUnicode_FromString("$db")) && - (state->_tzinfo_str = PyUnicode_FromString("tzinfo")) && - (state->_as_doc_str = PyUnicode_FromString("as_doc")) && - (state->_utcoffset_str = PyUnicode_FromString("utcoffset")) && - (state->_from_uuid_str = PyUnicode_FromString("from_uuid")) && - (state->_as_uuid_str = PyUnicode_FromString("as_uuid")) && - (state->_from_bid_str = PyUnicode_FromString("from_bid")))) { - return 1; - } - - if (_load_object(&state->Binary, "bson.binary", "Binary") || - _load_object(&state->Code, "bson.code", "Code") || - _load_object(&state->ObjectId, "bson.objectid", "ObjectId") || - _load_object(&state->DBRef, "bson.dbref", "DBRef") || - _load_object(&state->Timestamp, "bson.timestamp", "Timestamp") || - _load_object(&state->MinKey, "bson.min_key", "MinKey") || - _load_object(&state->MaxKey, "bson.max_key", "MaxKey") || - _load_object(&state->UTC, "bson.tz_util", "utc") || - _load_object(&state->Regex, "bson.regex", "Regex") || - _load_object(&state->BSONInt64, "bson.int64", "Int64") || - _load_object(&state->Decimal128, "bson.decimal128", "Decimal128") || - _load_object(&state->UUID, "uuid", "UUID") || - _load_object(&state->Mapping, "collections.abc", "Mapping") || - _load_object(&state->DatetimeMS, "bson.datetime_ms", "DatetimeMS") || - _load_object(&min_datetime_ms, "bson.datetime_ms", "_MIN_UTC_MS") || - _load_object(&max_datetime_ms, "bson.datetime_ms", "_MAX_UTC_MS") || - _load_object(&state->min_datetime, "bson.datetime_ms", "_MIN_UTC") || - _load_object(&state->max_datetime, "bson.datetime_ms", "_MAX_UTC") || - _load_object(&raw_bson_view_threshold, "bson.codec_options", "_RAW_BSON_VIEW_THRESHOLD")) { - return 1; - } - - state->min_millis = PyLong_AsLongLong(min_datetime_ms); - state->max_millis = PyLong_AsLongLong(max_datetime_ms); - state->raw_bson_view_threshold = PyLong_AsSsize_t(raw_bson_view_threshold); - Py_DECREF(min_datetime_ms); - Py_DECREF(max_datetime_ms); - Py_DECREF(raw_bson_view_threshold); - if ((state->min_millis == -1 || state->max_millis == -1 || - state->raw_bson_view_threshold == -1) && PyErr_Occurred()) { - return 1; - } - - /* Speed up datetime.replace(tzinfo=utc) call */ - state->replace_args = PyTuple_New(0); - if (!state->replace_args) { - return 1; - } - state->replace_kwargs = PyDict_New(); - if (!state->replace_kwargs) { - return 1; - } - if (PyDict_SetItem(state->replace_kwargs, state->_tzinfo_str, state->UTC) == -1) { - return 1; - } - - /* Reload our REType hack too. */ - empty_string = PyBytes_FromString(""); - if (empty_string == NULL) { - state->REType = NULL; - return 1; - } - - if (_load_object(&re_compile, "re", "compile")) { - state->REType = NULL; - Py_DECREF(empty_string); - return 1; - } - - PyObject* compile_args[1] = {empty_string}; - compiled = PyObject_Vectorcall(re_compile, compile_args, 1, NULL); - Py_DECREF(re_compile); - if (compiled == NULL) { - state->REType = NULL; - Py_DECREF(empty_string); - return 1; - } - Py_INCREF(Py_TYPE(compiled)); - state->REType = Py_TYPE(compiled); - Py_DECREF(empty_string); - Py_DECREF(compiled); - return 0; -} - -/* - * Get the _type_marker from an Object. - * - * Return the type marker, 0 if there is no marker, or -1 on failure. - */ -static long _type_marker(PyObject* object, PyObject* _type_marker_str) { - PyObject* type_marker = NULL; - long type = 0; - - #if PY_VERSION_HEX >= 0x030D0000 - // 3.13 - if (PyObject_GetOptionalAttr(object, _type_marker_str, &type_marker) == -1) { - return -1; - } - # else - if (PyObject_HasAttr(object, _type_marker_str)) { - type_marker = PyObject_GetAttr(object, _type_marker_str); - if (type_marker == NULL) { - return -1; - } - } - #endif - /* - * Python objects with broken __getattr__ implementations could return - * arbitrary types for a call to PyObject_GetAttrString. For example - * pymongo.database.Database returns a new Collection instance for - * __getattr__ calls with names that don't match an existing attribute - * or method. In some cases "value" could be a subtype of something - * we know how to serialize. Make a best effort to encode these types. - */ - if (type_marker && PyLong_CheckExact(type_marker)) { - type = PyLong_AsLong(type_marker); - Py_DECREF(type_marker); - } else { - Py_XDECREF(type_marker); - } - - return type; -} - -/* Fill out a type_registry_t* from a TypeRegistry object. - * - * Return 1 on success. options->document_class is a new reference. - * Return 0 on failure. - */ -int cbson_convert_type_registry(PyObject* registry_obj, type_registry_t* registry, PyObject* _encoder_map_str, PyObject* _decoder_map_str, PyObject* _fallback_encoder_str) { - registry->encoder_map = NULL; - registry->decoder_map = NULL; - registry->fallback_encoder = NULL; - registry->registry_obj = NULL; - - registry->encoder_map = PyObject_GetAttr(registry_obj, _encoder_map_str); - if (registry->encoder_map == NULL) { - goto fail; - } - registry->is_encoder_empty = (PyDict_Size(registry->encoder_map) == 0); - - registry->decoder_map = PyObject_GetAttr(registry_obj, _decoder_map_str); - if (registry->decoder_map == NULL) { - goto fail; - } - registry->is_decoder_empty = (PyDict_Size(registry->decoder_map) == 0); - - registry->fallback_encoder = PyObject_GetAttr(registry_obj, _fallback_encoder_str); - if (registry->fallback_encoder == NULL) { - goto fail; - } - registry->has_fallback_encoder = (registry->fallback_encoder != Py_None); - - registry->registry_obj = registry_obj; - Py_INCREF(registry->registry_obj); - return 1; - -fail: - Py_XDECREF(registry->encoder_map); - Py_XDECREF(registry->decoder_map); - Py_XDECREF(registry->fallback_encoder); - return 0; -} - -/* Fill out a codec_options_t* from a CodecOptions object. - * - * Return 1 on success. options->document_class is a new reference. - * Return 0 on failure. - */ -int convert_codec_options(PyObject* self, PyObject* options_obj, codec_options_t* options) { - PyObject* type_registry_obj = NULL; - struct module_state *state = GETSTATE(self); - long type_marker; - if (!state) { - return 0; - } - - options->unicode_decode_error_handler = NULL; - - if (!PyArg_ParseTuple(options_obj, "ObbzOOb", - &options->document_class, - &options->tz_aware, - &options->uuid_rep, - &options->unicode_decode_error_handler, - &options->tzinfo, - &type_registry_obj, - &options->datetime_conversion)) { - return 0; - } - - type_marker = _type_marker(options->document_class, - state->_type_marker_str); - if (type_marker < 0) { - return 0; - } - - if (!cbson_convert_type_registry(type_registry_obj, - &options->type_registry, state->_encoder_map_str, state->_decoder_map_str, state->_fallback_encoder_str)) { - return 0; - } - - options->is_raw_bson = (101 == type_marker); - options->is_dict_class = (options->document_class == (PyObject*)&PyDict_Type); - options->buffer_owner = NULL; - options->options_obj = options_obj; - - Py_INCREF(options->options_obj); - Py_INCREF(options->document_class); - Py_INCREF(options->tzinfo); - - return 1; -} - -void destroy_codec_options(codec_options_t* options) { - Py_CLEAR(options->document_class); - Py_CLEAR(options->tzinfo); - Py_CLEAR(options->options_obj); - Py_CLEAR(options->type_registry.registry_obj); - Py_CLEAR(options->type_registry.encoder_map); - Py_CLEAR(options->type_registry.decoder_map); - Py_CLEAR(options->type_registry.fallback_encoder); -} - -static int write_element_to_buffer(PyObject* self, buffer_t buffer, - int type_byte, PyObject* value, - unsigned char check_keys, - const codec_options_t* options, - unsigned char in_custom_call, - unsigned char in_fallback_call) { - int result = 0; - if(Py_EnterRecursiveCall(" while encoding an object to BSON ")) { - return 0; - } - result = _write_element_to_buffer(self, buffer, type_byte, - value, check_keys, options, - in_custom_call, in_fallback_call); - Py_LeaveRecursiveCall(); - return result; -} - -static void -_set_cannot_encode(PyObject* value) { - if (PyLong_Check(value)) { - if ((PyLong_AsLongLong(value) == -1) && PyErr_Occurred()) { - return PyErr_SetString(PyExc_OverflowError, - "MongoDB can only handle up to 8-byte ints"); - } - } - - PyObject* type = NULL; - PyObject* InvalidDocument = _error("InvalidDocument"); - if (InvalidDocument == NULL) { - goto error; - } - - type = PyObject_Type(value); - if (type == NULL) { - goto error; - } - PyErr_Format(InvalidDocument, "cannot encode object: %R, of type: %R", - value, type); -error: - Py_XDECREF(type); - Py_XDECREF(InvalidDocument); -} - -/* - * Encode a builtin Python regular expression or our custom Regex class. - * - * Sets exception and returns 0 on failure. - */ -static int _write_regex_to_buffer( - buffer_t buffer, int type_byte, PyObject* value, PyObject* _flags_str, PyObject* _pattern_str) { - - PyObject* py_flags; - PyObject* py_pattern; - PyObject* encoded_pattern; - PyObject* decoded_pattern; - long int_flags; - char flags[FLAGS_SIZE]; - char check_utf8 = 0; - const char* pattern_data; - int pattern_length, flags_length; - - /* - * Both the builtin re type and our Regex class have attributes - * "flags" and "pattern". - */ - py_flags = PyObject_GetAttr(value, _flags_str); - if (!py_flags) { - return 0; - } - int_flags = PyLong_AsLong(py_flags); - Py_DECREF(py_flags); - if (int_flags == -1 && PyErr_Occurred()) { - return 0; - } - py_pattern = PyObject_GetAttr(value, _pattern_str); - if (!py_pattern) { - return 0; - } - - if (PyUnicode_Check(py_pattern)) { - encoded_pattern = PyUnicode_AsUTF8String(py_pattern); - Py_DECREF(py_pattern); - if (!encoded_pattern) { - return 0; - } - } else { - encoded_pattern = py_pattern; - check_utf8 = 1; - } - - if (!(pattern_data = PyBytes_AsString(encoded_pattern))) { - Py_DECREF(encoded_pattern); - return 0; - } - if ((pattern_length = _downcast_and_check(PyBytes_Size(encoded_pattern), 0)) == -1) { - Py_DECREF(encoded_pattern); - return 0; - } - - if (strlen(pattern_data) != (size_t) pattern_length){ - PyObject* InvalidDocument = _error("InvalidDocument"); - if (InvalidDocument) { - PyErr_SetString(InvalidDocument, - "regex patterns must not contain the NULL byte"); - Py_DECREF(InvalidDocument); - } - Py_DECREF(encoded_pattern); - return 0; - } - - if (check_utf8) { - decoded_pattern = PyUnicode_DecodeUTF8(pattern_data, (Py_ssize_t) pattern_length, NULL); - if (decoded_pattern == NULL) { - PyErr_Clear(); - PyObject* InvalidStringData = _error("InvalidStringData"); - if (InvalidStringData) { - PyErr_SetString(InvalidStringData, - "regex patterns must be valid UTF-8"); - Py_DECREF(InvalidStringData); - } - Py_DECREF(encoded_pattern); - return 0; - } - Py_DECREF(decoded_pattern); - } - - if (!buffer_write_bytes(buffer, pattern_data, pattern_length + 1)) { - Py_DECREF(encoded_pattern); - return 0; - } - Py_DECREF(encoded_pattern); - - flags[0] = 0; - - if (int_flags & 2) { - STRCAT(flags, FLAGS_SIZE, "i"); - } - if (int_flags & 4) { - STRCAT(flags, FLAGS_SIZE, "l"); - } - if (int_flags & 8) { - STRCAT(flags, FLAGS_SIZE, "m"); - } - if (int_flags & 16) { - STRCAT(flags, FLAGS_SIZE, "s"); - } - if (int_flags & 32) { - STRCAT(flags, FLAGS_SIZE, "u"); - } - if (int_flags & 64) { - STRCAT(flags, FLAGS_SIZE, "x"); - } - flags_length = (int)strlen(flags) + 1; - if (!buffer_write_bytes(buffer, flags, flags_length)) { - return 0; - } - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x0B; - return 1; -} - -/* Write a single value to the buffer (also write its type_byte, for which - * space has already been reserved. - * - * returns 0 on failure */ -static int _write_element_to_buffer(PyObject* self, buffer_t buffer, - int type_byte, PyObject* value, - unsigned char check_keys, - const codec_options_t* options, - unsigned char in_custom_call, - unsigned char in_fallback_call) { - PyObject* new_value = NULL; - int retval; - int is_list; - long type; - struct module_state *state = GETSTATE(self); - if (!state) { - return 0; - } - /* - * Use _type_marker attribute instead of PyObject_IsInstance for better perf. - * - * Skip _type_marker lookup for common built-in types - * that we know don't have a _type_marker attribute. This avoids the overhead - * of PyObject_HasAttr/PyObject_GetAttr calls for the most common cases. - */ - if (PyUnicode_CheckExact(value) || PyLong_CheckExact(value) || PyFloat_CheckExact(value) || - PyBool_Check(value) || PyDict_CheckExact(value) || PyList_CheckExact(value) || - PyTuple_CheckExact(value) || PyBytes_CheckExact(value) || value == Py_None) { - type = 0; - } else { - type = _type_marker(value, state->_type_marker_str); - if (type < 0) { - return 0; - } - } - - switch (type) { - case 5: - { - /* Binary */ - PyObject* subtype_object; - long subtype_long; - unsigned char subtype; - const char* data; - int size; - - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x05; - subtype_object = PyObject_GetAttr(value, state->_subtype_str); - if (!subtype_object) { - return 0; - } - subtype_long = PyLong_AsLong(subtype_object); - if (subtype_long == -1 && PyErr_Occurred()) { - Py_DECREF(subtype_object); - return 0; - } - /* Subtype is 0-255, so a signed char would turn 255 into -1. */ - subtype = (unsigned char)subtype_long; - size = _downcast_and_check(PyBytes_Size(value), 0); - if (size == -1) { - Py_DECREF(subtype_object); - return 0; - } - - Py_DECREF(subtype_object); - if (subtype == 2) { - int other_size = _downcast_and_check(PyBytes_Size(value), 4); - if (other_size == -1) - return 0; - if (!buffer_write_int32(buffer, other_size)) { - return 0; - } - if (!buffer_write_bytes(buffer, (const char*)&subtype, 1)) { - return 0; - } - } - if (!buffer_write_int32(buffer, size)) { - return 0; - } - if (subtype != 2) { - if (!buffer_write_bytes(buffer, (const char*)&subtype, 1)) { - return 0; - } - } - data = PyBytes_AsString(value); - if (!data) { - return 0; - } - if (!buffer_write_bytes(buffer, data, size)) { - return 0; - } - return 1; - } - case 7: - { - /* ObjectId */ - const char* data; - PyObject* pystring = PyObject_GetAttr(value, state->_binary_str); - if (!pystring) { - return 0; - } - data = PyBytes_AsString(pystring); - if (!data) { - Py_DECREF(pystring); - return 0; - } - if (!buffer_write_bytes(buffer, data, 12)) { - Py_DECREF(pystring); - return 0; - } - Py_DECREF(pystring); - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x07; - return 1; - } - case 9: - { - /* DatetimeMS */ - long long millis; - if (!millis_from_datetime_ms(value, &millis)) { - return 0; - } - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x09; - return buffer_write_int64(buffer, (int64_t)millis); - } - case 11: - { - /* Regex */ - return _write_regex_to_buffer(buffer, type_byte, value, state->_flags_str, state->_pattern_str); - } - case 13: - { - /* Code */ - int start_position, - length_location, - length; - - PyObject* scope = PyObject_GetAttr(value, state->_scope_str); - if (!scope) { - return 0; - } - - if (scope == Py_None) { - Py_DECREF(scope); - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x0D; - return write_string(buffer, value); - } - - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x0F; - - start_position = pymongo_buffer_get_position(buffer); - /* save space for length */ - length_location = pymongo_buffer_save_space(buffer, 4); - if (length_location == -1) { - Py_DECREF(scope); - return 0; - } - - if (!write_string(buffer, value)) { - Py_DECREF(scope); - return 0; - } - - if (!write_dict(self, buffer, scope, 0, options, 0)) { - Py_DECREF(scope); - return 0; - } - Py_DECREF(scope); - - length = pymongo_buffer_get_position(buffer) - start_position; - buffer_write_int32_at_position( - buffer, length_location, (int32_t)length); - return 1; - } - case 17: - { - /* Timestamp */ - PyObject* obj; - unsigned long i; - - obj = PyObject_GetAttr(value, state->_inc_str); - if (!obj) { - return 0; - } - i = PyLong_AsUnsignedLong(obj); - Py_DECREF(obj); - if (i == (unsigned long)-1 && PyErr_Occurred()) { - return 0; - } - if (!buffer_write_int32(buffer, (int32_t)i)) { - return 0; - } - - obj = PyObject_GetAttr(value, state->_time_str); - if (!obj) { - return 0; - } - i = PyLong_AsUnsignedLong(obj); - Py_DECREF(obj); - if (i == (unsigned long)-1 && PyErr_Occurred()) { - return 0; - } - if (!buffer_write_int32(buffer, (int32_t)i)) { - return 0; - } - - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x11; - return 1; - } - case 18: - { - /* Int64 */ - const long long ll = PyLong_AsLongLong(value); - if (PyErr_Occurred()) { /* Overflow */ - PyErr_SetString(PyExc_OverflowError, - "MongoDB can only handle up to 8-byte ints"); - return 0; - } - if (!buffer_write_int64(buffer, (int64_t)ll)) { - return 0; - } - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x12; - return 1; - } - case 19: - { - /* Decimal128 */ - const char* data; - PyObject* pystring = PyObject_GetAttr(value, state->_bid_str); - if (!pystring) { - return 0; - } - data = PyBytes_AsString(pystring); - if (!data) { - Py_DECREF(pystring); - return 0; - } - if (!buffer_write_bytes(buffer, data, 16)) { - Py_DECREF(pystring); - return 0; - } - Py_DECREF(pystring); - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x13; - return 1; - } - case 100: - { - /* DBRef */ - PyObject* as_doc_args[1] = {value}; - PyObject* as_doc = PyObject_VectorcallMethod( - state->_as_doc_str, as_doc_args, 1, NULL); - if (!as_doc) { - return 0; - } - if (!write_dict(self, buffer, as_doc, 0, options, 0)) { - Py_DECREF(as_doc); - return 0; - } - Py_DECREF(as_doc); - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x03; - return 1; - } - case 101: - { - /* RawBSONDocument */ - if (!write_raw_doc(buffer, value, state->_raw_str)) { - return 0; - } - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x03; - return 1; - } - case 255: - { - /* MinKey */ - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0xFF; - return 1; - } - case 127: - { - /* MaxKey */ - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x7F; - return 1; - } - } - - /* No _type_marker attribute or not one of our types. */ - - if (PyBool_Check(value)) { - const char c = (value == Py_True) ? 0x01 : 0x00; - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x08; - return buffer_write_bytes(buffer, &c, 1); - } - else if (PyLong_Check(value)) { - const long long long_long_value = PyLong_AsLongLong(value); - if (long_long_value == -1 && PyErr_Occurred()) { - /* Ignore error and give the fallback_encoder a chance. */ - PyErr_Clear(); - } else if (-2147483648LL <= long_long_value && long_long_value <= 2147483647LL) { - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x10; - return buffer_write_int32(buffer, (int32_t)long_long_value); - } else { - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x12; - return buffer_write_int64(buffer, (int64_t)long_long_value); - } - } else if (PyFloat_Check(value)) { - const double d = PyFloat_AsDouble(value); - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x01; - return buffer_write_double(buffer, d); - } else if (value == Py_None) { - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x0A; - return 1; - } else if (PyDict_Check(value)) { - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x03; - return write_dict(self, buffer, value, check_keys, options, 0); - } else if ((is_list = PyList_Check(value)) || PyTuple_Check(value)) { - Py_ssize_t items, i; - int start_position, - length_location, - length; - char zero = 0; - - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x04; - start_position = pymongo_buffer_get_position(buffer); - - /* save space for length */ - length_location = pymongo_buffer_save_space(buffer, 4); - if (length_location == -1) { - return 0; - } - if (is_list) { - items = PyList_Size(value); - } else { - items = PyTuple_Size(value); - } - if (items > BSON_MAX_SIZE) { - PyObject* BSONError = _error("BSONError"); - if (BSONError) { - PyErr_SetString(BSONError, - "Too many items to serialize."); - Py_DECREF(BSONError); - } - return 0; - } - for(i = 0; i < items; i++) { - int list_type_byte = pymongo_buffer_save_space(buffer, 1); - char name[BUF_SIZE]; - PyObject* item_value; - - if (list_type_byte == -1) { - return 0; - } - int res = LL2STR(name, (long long)i); - if (res == -1) { - return 0; - } - if (!buffer_write_bytes(buffer, name, (int)strlen(name) + 1)) { - return 0; - } - if (is_list) { - item_value = PyList_GET_ITEM(value, i); - } else { - item_value = PyTuple_GET_ITEM(value, i); - } - if (!item_value) { - return 0; - } - if (!write_element_to_buffer(self, buffer, list_type_byte, - item_value, check_keys, options, - 0, 0)) { - return 0; - } - } - - /* write null byte and fill in length */ - if (!buffer_write_bytes(buffer, &zero, 1)) { - return 0; - } - length = pymongo_buffer_get_position(buffer) - start_position; - buffer_write_int32_at_position( - buffer, length_location, (int32_t)length); - return 1; - /* Python3 special case. Store bytes as BSON binary subtype 0. */ - } else if (PyBytes_Check(value)) { - char subtype = 0; - int size; - const char* data = PyBytes_AS_STRING(value); - if (!data) - return 0; - if ((size = _downcast_and_check(PyBytes_GET_SIZE(value), 0)) == -1) - return 0; - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x05; - if (!buffer_write_int32(buffer, (int32_t)size)) { - return 0; - } - if (!buffer_write_bytes(buffer, &subtype, 1)) { - return 0; - } - if (!buffer_write_bytes(buffer, data, size)) { - return 0; - } - return 1; - } else if (PyUnicode_Check(value)) { - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x02; - return write_unicode(buffer, value); - } else if (PyDateTime_Check(value)) { - long long millis; - PyObject* utcoffset_args[1] = {value}; - PyObject* utcoffset = PyObject_VectorcallMethod( - state->_utcoffset_str, utcoffset_args, 1, NULL); - if (utcoffset == NULL) - return 0; - if (utcoffset != Py_None) { - PyObject* result = PyNumber_Subtract(value, utcoffset); - if (!result) { - Py_DECREF(utcoffset); - return 0; - } - millis = millis_from_datetime(result); - Py_DECREF(result); - } else { - millis = millis_from_datetime(value); - } - Py_DECREF(utcoffset); - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x09; - return buffer_write_int64(buffer, (int64_t)millis); - } else if (PyObject_TypeCheck(value, state->REType)) { - return _write_regex_to_buffer(buffer, type_byte, value, state->_flags_str, state->_pattern_str); - } else if (PyObject_IsInstance(value, state->Mapping)) { - /* PyObject_IsInstance returns -1 on error */ - if (PyErr_Occurred()) { - return 0; - } - *(pymongo_buffer_get_buffer(buffer) + type_byte) = 0x03; - return write_dict(self, buffer, value, check_keys, options, 0); - } else if (PyObject_IsInstance(value, state->UUID)) { - PyObject* binary_value = NULL; - PyObject *uuid_rep_obj = NULL; - int result; - - /* PyObject_IsInstance returns -1 on error */ - if (PyErr_Occurred()) { - return 0; - } - - if (!(uuid_rep_obj = PyLong_FromLong(options->uuid_rep))) { - return 0; - } - PyObject* from_uuid_args[3] = {state->Binary, value, uuid_rep_obj}; - binary_value = PyObject_VectorcallMethod( - state->_from_uuid_str, from_uuid_args, 3, NULL); - Py_DECREF(uuid_rep_obj); - - if (binary_value == NULL) { - return 0; - } - - result = _write_element_to_buffer(self, buffer, - type_byte, binary_value, - check_keys, options, - in_custom_call, - in_fallback_call); - Py_DECREF(binary_value); - return result; - } - - /* Try a custom encoder if one is provided and we have not already - * attempted to use a type encoder. */ - if (!in_custom_call && !options->type_registry.is_encoder_empty) { - PyObject* value_type = NULL; - PyObject* converter = NULL; - value_type = PyObject_Type(value); - if (value_type == NULL) { - return 0; - } - converter = PyDict_GetItem(options->type_registry.encoder_map, value_type); - Py_XDECREF(value_type); - if (converter != NULL) { - /* Transform types that have a registered converter. - * A new reference is created upon transformation. */ - PyObject* converter_args[1] = {value}; - new_value = PyObject_Vectorcall(converter, converter_args, 1, NULL); - if (new_value == NULL) { - return 0; - } - retval = write_element_to_buffer(self, buffer, type_byte, new_value, - check_keys, options, 1, 0); - Py_XDECREF(new_value); - return retval; - } - } - - /* Try the fallback encoder if one is provided and we have not already - * attempted to use the fallback encoder. */ - if (!in_fallback_call && options->type_registry.has_fallback_encoder) { - PyObject* fallback_args[1] = {value}; - new_value = PyObject_Vectorcall( - options->type_registry.fallback_encoder, fallback_args, 1, NULL); - if (new_value == NULL) { - // propagate any exception raised by the callback - return 0; - } - retval = write_element_to_buffer(self, buffer, type_byte, new_value, - check_keys, options, 0, 1); - Py_XDECREF(new_value); - return retval; - } - - /* We can't determine value's type. Fail. */ - _set_cannot_encode(value); - return 0; -} - -static int check_key_name(const char* name, int name_length) { - - if (name_length > 0 && name[0] == '$') { - PyObject* InvalidDocument = _error("InvalidDocument"); - if (InvalidDocument) { - PyObject* errmsg = PyUnicode_FromFormat( - "key '%s' must not start with '$'", name); - if (errmsg) { - PyErr_SetObject(InvalidDocument, errmsg); - Py_DECREF(errmsg); - } - Py_DECREF(InvalidDocument); - } - return 0; - } - if (strchr(name, '.')) { - PyObject* InvalidDocument = _error("InvalidDocument"); - if (InvalidDocument) { - PyObject* errmsg = PyUnicode_FromFormat( - "key '%s' must not contain '.'", name); - if (errmsg) { - PyErr_SetObject(InvalidDocument, errmsg); - Py_DECREF(errmsg); - } - Py_DECREF(InvalidDocument); - } - return 0; - } - return 1; -} - -/* Write a (key, value) pair to the buffer. - * - * Returns 0 on failure */ -int write_pair(PyObject* self, buffer_t buffer, const char* name, int name_length, - PyObject* value, unsigned char check_keys, - const codec_options_t* options, unsigned char allow_id) { - int type_byte; - - /* Don't write any _id elements unless we're explicitly told to - - * _id has to be written first so we do so, but don't bother - * deleting it from the dictionary being written. */ - if (!allow_id && strcmp(name, "_id") == 0) { - return 1; - } - - type_byte = pymongo_buffer_save_space(buffer, 1); - if (type_byte == -1) { - return 0; - } - if (check_keys && !check_key_name(name, name_length)) { - return 0; - } - if (!buffer_write_bytes(buffer, name, name_length + 1)) { - return 0; - } - if (!write_element_to_buffer(self, buffer, type_byte, - value, check_keys, options, 0, 0)) { - return 0; - } - return 1; -} - -int decode_and_write_pair(PyObject* self, buffer_t buffer, - PyObject* key, PyObject* value, - unsigned char check_keys, - const codec_options_t* options, - unsigned char top_level) { - PyObject* encoded; - const char* data; - int size; - if (PyUnicode_Check(key)) { - encoded = PyUnicode_AsUTF8String(key); - if (!encoded) { - return 0; - } - if (!(data = PyBytes_AS_STRING(encoded))) { - Py_DECREF(encoded); - return 0; - } - if ((size = _downcast_and_check(PyBytes_GET_SIZE(encoded), 1)) == -1) { - Py_DECREF(encoded); - return 0; - } - if (strlen(data) != (size_t)(size - 1)) { - PyObject* InvalidDocument = _error("InvalidDocument"); - if (InvalidDocument) { - PyErr_SetString(InvalidDocument, - "Key names must not contain the NULL byte"); - Py_DECREF(InvalidDocument); - } - Py_DECREF(encoded); - return 0; - } - } else { - PyObject* InvalidDocument = _error("InvalidDocument"); - if (InvalidDocument) { - PyObject* repr = PyObject_Repr(key); - if (repr) { - PyObject* errmsg = PyUnicode_FromString( - "documents must have only string keys, key was "); - if (errmsg) { - PyObject* error = PyUnicode_Concat(errmsg, repr); - if (error) { - PyErr_SetObject(InvalidDocument, error); - Py_DECREF(error); - } - Py_DECREF(errmsg); - Py_DECREF(repr); - } else { - Py_DECREF(repr); - } - } - Py_DECREF(InvalidDocument); - } - return 0; - } - - /* If top_level is True, don't allow writing _id here - it was already written. */ - if (!write_pair(self, buffer, data, - size - 1, value, check_keys, options, !top_level)) { - Py_DECREF(encoded); - return 0; - } - - Py_DECREF(encoded); - return 1; -} - - -/* Write a RawBSONDocument to the buffer. - * Returns the number of bytes written or 0 on failure. - */ -static int write_raw_doc(buffer_t buffer, PyObject* raw, PyObject* _raw_str) { - char* data; - Py_ssize_t len; - int len_int; - int bytes_written = 0; - PyObject* bytes_obj = NULL; - Py_buffer view = {0}; - - bytes_obj = PyObject_GetAttr(raw, _raw_str); - if (!bytes_obj) { - goto fail; - } - - if (PyBytes_Check(bytes_obj)) { - /* The common case: raw is bytes. */ - data = PyBytes_AS_STRING(bytes_obj); - len = PyBytes_GET_SIZE(bytes_obj); - } else if (PyMemoryView_Check(bytes_obj)) { - /* raw may also be a memoryview of the decode buffer. */ - if (!_get_buffer(bytes_obj, &view)) { - goto fail; - } - data = (char*)view.buf; - len = view.len; - } else { - PyErr_Format(PyExc_TypeError, - "RawBSONDocument.raw must be bytes or memoryview, not %.200s", - Py_TYPE(bytes_obj)->tp_name); - goto fail; - } - len_int = _downcast_and_check(len, 0); - if (-1 == len_int) { - goto fail; - } - if (!buffer_write_bytes(buffer, data, len_int)) { - goto fail; - } - bytes_written = len_int; -fail: - PyBuffer_Release(&view); - Py_XDECREF(bytes_obj); - return bytes_written; -} - - -/* Update Invalid Document error to include doc as a property. - */ -void handle_invalid_doc_error(PyObject* dict) { -#if PY_VERSION_HEX >= PYTHON_3_12 - PyObject *exc = PyErr_GetRaisedException(); - PyObject *msg = NULL, *new_msg = NULL; - PyObject *InvalidDocument = NULL; - - if (exc == NULL) { - return; - } - - InvalidDocument = _error("InvalidDocument"); - if (InvalidDocument == NULL) { - goto cleanup; - } - - if (PyErr_GivenExceptionMatches(exc, InvalidDocument)) { - msg = PyObject_Str(exc); - if (msg) { - const char *msg_utf8 = PyUnicode_AsUTF8(msg); - if (msg_utf8 == NULL) { - goto cleanup; - } - new_msg = PyUnicode_FromFormat("Invalid document: %s", msg_utf8); - if (new_msg == NULL) { - goto cleanup; - } - /* Add doc to the error instance as a property. */ - PyObject* exc_args[2] = {new_msg, dict}; - PyObject* new_exc = PyObject_Vectorcall(InvalidDocument, exc_args, 2, NULL); - if (new_exc) { - exc = _transfer_traceback(exc, new_exc); - } - } - } -cleanup: - /* Steals reference to exc. */ - PyErr_SetRaisedException(exc); - Py_XDECREF(msg); - Py_XDECREF(InvalidDocument); - Py_XDECREF(new_msg); -#else - PyObject *etype = NULL, *evalue = NULL, *etrace = NULL; - PyObject *msg = NULL, *new_msg = NULL, *new_evalue = NULL; - PyErr_Fetch(&etype, &evalue, &etrace); - PyObject *InvalidDocument = _error("InvalidDocument"); - if (InvalidDocument == NULL) { - goto cleanup; - } - - if (evalue && PyErr_GivenExceptionMatches(etype, InvalidDocument)) { - msg = PyObject_Str(evalue); - if (msg) { - const char * msg_utf8 = PyUnicode_AsUTF8(msg); - if (msg_utf8 == NULL) { - goto cleanup; - } - new_msg = PyUnicode_FromFormat("Invalid document: %s", msg_utf8); - if (new_msg == NULL) { - goto cleanup; - } - // Add doc to the error instance as a property. - PyObject* exc_args[2] = {new_msg, dict}; - new_evalue = PyObject_Vectorcall(InvalidDocument, exc_args, 2, NULL); - Py_DECREF(evalue); - Py_DECREF(etype); - etype = InvalidDocument; - InvalidDocument = NULL; - if (new_evalue) { - evalue = new_evalue; - new_evalue = NULL; - } else { - evalue = msg; - msg = NULL; - } - } - PyErr_NormalizeException(&etype, &evalue, &etrace); - } -cleanup: - PyErr_Restore(etype, evalue, etrace); - Py_XDECREF(msg); - Py_XDECREF(InvalidDocument); - Py_XDECREF(new_evalue); - Py_XDECREF(new_msg); -#endif -} - - -/* returns the number of bytes written or 0 on failure */ -int write_dict(PyObject* self, buffer_t buffer, - PyObject* dict, unsigned char check_keys, - const codec_options_t* options, unsigned char top_level) { - PyObject* key; - PyObject* iter; - char zero = 0; - int length; - int length_location; - struct module_state *state = GETSTATE(self); - long type_marker; - int is_dict = PyDict_Check(dict); - if (!state) { - return 0; - } - - if (!is_dict) { - /* check for RawBSONDocument */ - type_marker = _type_marker(dict, state->_type_marker_str); - if (type_marker < 0) { - return 0; - } - - if (101 == type_marker) { - return write_raw_doc(buffer, dict, state->_raw_str); - } - - if (!PyObject_IsInstance(dict, state->Mapping)) { - PyObject* repr; - if ((repr = PyObject_Repr(dict))) { - PyObject* errmsg = PyUnicode_FromString( - "encoder expected a mapping type but got: "); - if (errmsg) { - PyObject* error = PyUnicode_Concat(errmsg, repr); - if (error) { - PyErr_SetObject(PyExc_TypeError, error); - Py_DECREF(error); - } - Py_DECREF(errmsg); - Py_DECREF(repr); - } - else { - Py_DECREF(repr); - } - } else { - PyErr_SetString(PyExc_TypeError, - "encoder expected a mapping type"); - } - - return 0; - } - /* PyObject_IsInstance returns -1 on error */ - if (PyErr_Occurred()) { - return 0; - } - } - - length_location = pymongo_buffer_save_space(buffer, 4); - if (length_location == -1) { - return 0; - } - - /* Write _id first if this is a top level doc. */ - if (top_level) { - /* - * If "dict" is a defaultdict we don't want to call - * PyObject_GetItem on it. That would **create** - * an _id where one didn't previously exist (PYTHON-871). - */ - if (is_dict) { - /* PyDict_GetItem returns a borrowed reference. */ - PyObject* _id = PyDict_GetItem(dict, state->_id_str); - if (_id) { - if (!write_pair(self, buffer, "_id", 3, - _id, check_keys, options, 1)) { - return 0; - } - } - } else if (PyMapping_HasKey(dict, state->_id_str)) { - PyObject* _id = PyObject_GetItem(dict, state->_id_str); - if (!_id) { - return 0; - } - if (!write_pair(self, buffer, "_id", 3, - _id, check_keys, options, 1)) { - Py_DECREF(_id); - return 0; - } - /* PyObject_GetItem returns a new reference. */ - Py_DECREF(_id); - } - } - - if (is_dict) { - PyObject* value; - Py_ssize_t pos = 0; - while (PyDict_Next(dict, &pos, &key, &value)) { - if (!decode_and_write_pair(self, buffer, key, value, - check_keys, options, top_level)) { - if (PyErr_Occurred() && top_level) { - handle_invalid_doc_error(dict); - } - return 0; - } - } - } else { - iter = PyObject_GetIter(dict); - if (iter == NULL) { - return 0; - } - while ((key = PyIter_Next(iter)) != NULL) { - PyObject* value = PyObject_GetItem(dict, key); - if (!value) { - PyErr_SetObject(PyExc_KeyError, key); - Py_DECREF(key); - Py_DECREF(iter); - return 0; - } - if (!decode_and_write_pair(self, buffer, key, value, - check_keys, options, top_level)) { - if (PyErr_Occurred() && top_level) { - handle_invalid_doc_error(dict); - } - Py_DECREF(key); - Py_DECREF(value); - Py_DECREF(iter); - return 0; - } - Py_DECREF(key); - Py_DECREF(value); - } - Py_DECREF(iter); - if (PyErr_Occurred()) { - return 0; - } - } - - /* write null byte and fill in length */ - if (!buffer_write_bytes(buffer, &zero, 1)) { - return 0; - } - length = pymongo_buffer_get_position(buffer) - length_location; - buffer_write_int32_at_position( - buffer, length_location, (int32_t)length); - return length; -} - -static PyObject* _cbson_dict_to_bson(PyObject* self, PyObject* args) { - PyObject* dict; - PyObject* result; - unsigned char check_keys; - unsigned char top_level = 1; - PyObject* options_obj = NULL; - codec_options_t options; - buffer_t buffer; - PyObject* raw_bson_document_bytes_obj; - long type_marker; - struct module_state *state = GETSTATE(self); - if (!state) { - return NULL; - } - - if (!(PyArg_ParseTuple(args, "ObO|b", &dict, &check_keys, - &options_obj, &top_level) && - convert_codec_options(self, options_obj, &options))) { - return NULL; - } - - /* check for RawBSONDocument */ - type_marker = _type_marker(dict, state->_type_marker_str); - if (type_marker < 0) { - destroy_codec_options(&options); - return NULL; - } else if (101 == type_marker) { - destroy_codec_options(&options); - raw_bson_document_bytes_obj = PyObject_GetAttr(dict, state->_raw_str); - if (NULL == raw_bson_document_bytes_obj) { - return NULL; - } - /* raw may be a memoryview but - * encoding must always produce bytes. */ - if (!PyBytes_Check(raw_bson_document_bytes_obj)) { - PyObject* as_bytes = PyBytes_FromObject(raw_bson_document_bytes_obj); - Py_DECREF(raw_bson_document_bytes_obj); - return as_bytes; - } - return raw_bson_document_bytes_obj; - } - - buffer = pymongo_buffer_new(); - if (!buffer) { - destroy_codec_options(&options); - return NULL; - } - - if (!write_dict(self, buffer, dict, check_keys, &options, top_level)) { - destroy_codec_options(&options); - pymongo_buffer_free(buffer); - return NULL; - } - - /* objectify buffer */ - result = Py_BuildValue("y#", pymongo_buffer_get_buffer(buffer), - (Py_ssize_t)pymongo_buffer_get_position(buffer)); - destroy_codec_options(&options); - pymongo_buffer_free(buffer); - return result; -} - -/* - * Hook for optional decoding BSON documents to DBRef. - */ -static PyObject *_dbref_hook(PyObject* self, PyObject* value) { - struct module_state *state = GETSTATE(self); - PyObject* ref = NULL; - PyObject* id = NULL; - PyObject* database = NULL; - PyObject* ret = NULL; - int db_present = 0; - if (!state) { - return NULL; - } - - /* Decoding for DBRefs */ - if (PyMapping_HasKey(value, state->_dollar_ref_str) && PyMapping_HasKey(value, state->_dollar_id_str)) { /* DBRef */ - ref = PyObject_GetItem(value, state->_dollar_ref_str); - /* PyObject_GetItem returns NULL to indicate error. */ - if (!ref) { - goto invalid; - } - id = PyObject_GetItem(value, state->_dollar_id_str); - /* PyObject_GetItem returns NULL to indicate error. */ - if (!id) { - goto invalid; - } - - if (PyMapping_HasKey(value, state->_dollar_db_str)) { - database = PyObject_GetItem(value, state->_dollar_db_str); - if (!database) { - goto invalid; - } - db_present = 1; - } else { - database = Py_None; - Py_INCREF(database); - } - - // check types - if (!(PyUnicode_Check(ref) && (database == Py_None || PyUnicode_Check(database)))) { - ret = value; - goto invalid; - } - - PyMapping_DelItem(value, state->_dollar_ref_str); - PyMapping_DelItem(value, state->_dollar_id_str); - if (db_present) { - PyMapping_DelItem(value, state->_dollar_db_str); - } - - PyObject* dbref_args[4] = {ref, id, database, value}; - ret = PyObject_Vectorcall(state->DBRef, dbref_args, 4, NULL); - Py_DECREF(value); - } else { - ret = value; - } -invalid: - Py_XDECREF(ref); - Py_XDECREF(id); - Py_XDECREF(database); - return ret; -} - -static PyObject* get_value(PyObject* self, PyObject* name, const char* buffer, - unsigned* position, unsigned char type, - unsigned max, const codec_options_t* options, int raw_array) { - struct module_state *state = GETSTATE(self); - PyObject* value = NULL; - if (!state) { - return NULL; - } - switch (type) { - case 1: - { - double d; - if (max < 8) { - goto invalid; - } - memcpy(&d, buffer + *position, 8); - value = PyFloat_FromDouble(BSON_DOUBLE_FROM_LE(d)); - *position += 8; - break; - } - case 2: - case 14: - { - uint32_t value_length; - if (max < 4) { - goto invalid; - } - memcpy(&value_length, buffer + *position, 4); - value_length = BSON_UINT32_FROM_LE(value_length); - /* Encoded string length + string */ - if (!value_length || max < value_length || max < 4 + value_length) { - goto invalid; - } - *position += 4; - /* Strings must end in \0 */ - if (buffer[*position + value_length - 1]) { - goto invalid; - } - value = PyUnicode_DecodeUTF8( - buffer + *position, value_length - 1, - options->unicode_decode_error_handler); - if (!value) { - goto invalid; - } - *position += value_length; - break; - } - case 3: - { - uint32_t size; - - if (max < 4) { - goto invalid; - } - memcpy(&size, buffer + *position, 4); - size = BSON_UINT32_FROM_LE(size); - if (size < BSON_MIN_SIZE || max < size) { - goto invalid; - } - /* Check for bad eoo */ - if (buffer[*position + size - 1]) { - goto invalid; - } - - value = elements_to_dict(self, buffer + *position, - size, options); - if (!value) { - goto invalid; - } - - if (options->is_raw_bson) { - *position += size; - break; - } - - /* Hook for DBRefs */ - value = _dbref_hook(self, value); - if (!value) { - goto invalid; - } - - *position += size; - break; - } - case 4: - { - uint32_t size, end; - - if (max < 4) { - goto invalid; - } - memcpy(&size, buffer + *position, 4); - size = BSON_UINT32_FROM_LE(size); - if (size < BSON_MIN_SIZE || max < size) { - goto invalid; - } - - end = *position + size - 1; - /* Check for bad eoo */ - if (buffer[end]) { - goto invalid; - } - - if (raw_array != 0) { - // Treat it as a binary buffer. - value = PyBytes_FromStringAndSize(buffer + *position, size); - *position += size; - break; - } - - *position += 4; - - value = PyList_New(0); - if (!value) { - goto invalid; - } - while (*position < end) { - PyObject* to_append; - - unsigned char bson_type = (unsigned char)buffer[(*position)++]; - - size_t key_size = strlen(buffer + *position); - if (max < key_size) { - Py_DECREF(value); - goto invalid; - } - /* just skip the key, they're in order. */ - *position += (unsigned)key_size + 1; - if (Py_EnterRecursiveCall(" while decoding a list value")) { - Py_DECREF(value); - goto invalid; - } - to_append = get_value(self, name, buffer, position, bson_type, - max - (unsigned)key_size, options, raw_array); - Py_LeaveRecursiveCall(); - if (!to_append) { - Py_DECREF(value); - goto invalid; - } - if (PyList_Append(value, to_append) < 0) { - Py_DECREF(value); - Py_DECREF(to_append); - goto invalid; - } - Py_DECREF(to_append); - } - if (*position != end) { - goto invalid; - } - (*position)++; - break; - } - case 5: - { - PyObject* data; - PyObject* st; - uint32_t length, length2; - unsigned char subtype; - - if (max < 5) { - goto invalid; - } - memcpy(&length, buffer + *position, 4); - length = BSON_UINT32_FROM_LE(length); - if (max - 5 < length) { // Account for 5-byte header. max >= 5 guaranteed above - goto invalid; - } - - subtype = (unsigned char)buffer[*position + 4]; - *position += 5; - if (subtype == 2) { - if (length < 4) { - goto invalid; - } - memcpy(&length2, buffer + *position, 4); - length2 = BSON_UINT32_FROM_LE(length2); - if (length2 != length - 4) { - goto invalid; - } - } - /* Python3 special case. Decode BSON binary subtype 0 to bytes. */ - if (subtype == 0) { - value = PyBytes_FromStringAndSize(buffer + *position, length); - *position += length; - break; - } - if (subtype == 2) { - data = PyBytes_FromStringAndSize(buffer + *position + 4, length - 4); - } else { - data = PyBytes_FromStringAndSize(buffer + *position, length); - } - if (!data) { - goto invalid; - } - /* Encode as UUID or Binary based on options->uuid_rep */ - if (subtype == 3 || subtype == 4) { - PyObject* binary_value = NULL; - char uuid_rep = options->uuid_rep; - - PyObject* subtype_obj = PyLong_FromLong(subtype); - if (!subtype_obj) { - goto uuiderror; - } - PyObject* binary_args[2] = {data, subtype_obj}; - binary_value = PyObject_Vectorcall(state->Binary, binary_args, 2, NULL); - Py_DECREF(subtype_obj); - if (binary_value == NULL) { - goto uuiderror; - } - - if ((uuid_rep == UNSPECIFIED) || - (subtype == 4 && uuid_rep != STANDARD) || - (subtype == 3 && uuid_rep == STANDARD)) { - value = binary_value; - Py_INCREF(value); - } else { - PyObject *uuid_rep_obj = PyLong_FromLong(uuid_rep); - if (!uuid_rep_obj) { - goto uuiderror; - } - PyObject* as_uuid_args[2] = {binary_value, uuid_rep_obj}; - value = PyObject_VectorcallMethod( - state->_as_uuid_str, as_uuid_args, 2, NULL); - Py_DECREF(uuid_rep_obj); - } - - uuiderror: - Py_XDECREF(binary_value); - Py_DECREF(data); - if (!value) { - goto invalid; - } - *position += length; - break; - } - - st = PyLong_FromLong(subtype); - if (!st) { - Py_DECREF(data); - goto invalid; - } - PyObject* binary_args[2] = {data, st}; - value = PyObject_Vectorcall(state->Binary, binary_args, 2, NULL); - Py_DECREF(st); - Py_DECREF(data); - if (!value) { - goto invalid; - } - *position += length; - break; - } - case 6: - case 10: - { - value = Py_None; - Py_INCREF(value); - break; - } - case 7: - { - if (max < 12) { - goto invalid; - } - PyObject* oid_bytes = PyBytes_FromStringAndSize(buffer + *position, 12); - if (!oid_bytes) { - goto invalid; - } - PyObject* oid_args[1] = {oid_bytes}; - value = PyObject_Vectorcall(state->ObjectId, oid_args, 1, NULL); - Py_DECREF(oid_bytes); - *position += 12; - break; - } - case 8: - { - if (max < 1) { - goto invalid; - } - char boolean_raw = buffer[(*position)++]; - if (0 == boolean_raw) { - value = Py_False; - } else if (1 == boolean_raw) { - value = Py_True; - } else { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_Format(InvalidBSON, "invalid boolean value: %x", boolean_raw); - Py_DECREF(InvalidBSON); - } - return NULL; - } - Py_INCREF(value); - break; - } - case 9: - { - int64_t millis; - if (max < 8) { - goto invalid; - } - memcpy(&millis, buffer + *position, 8); - millis = (int64_t)BSON_UINT64_FROM_LE(millis); - *position += 8; - - value = decode_datetime(self, millis, options); - break; - } - case 11: - { - PyObject* pattern; - int flags; - size_t flags_length, i; - /* PYTHON-6110: Search for each NUL within the bytes remaining - * in the document rather than scanning the buffer. */ - const char* start = buffer + *position; - const char* pattern_nul = memchr(start, 0, max); - if (!pattern_nul) { - goto invalid; - } - size_t pattern_length = (size_t)(pattern_nul - start); - if (pattern_length > BSON_MAX_SIZE) { - goto invalid; - } - pattern = PyUnicode_DecodeUTF8( - start, pattern_length, - options->unicode_decode_error_handler); - if (!pattern) { - goto invalid; - } - *position += (unsigned)pattern_length + 1; - start += pattern_length + 1; - /* PYTHON-6111: account for the pattern NUL consumed above so - * the flags terminator cannot overlap the document terminator. */ - const char* flags_nul = memchr(start, 0, max - pattern_length - 1); - if (!flags_nul) { - Py_DECREF(pattern); - goto invalid; - } - flags_length = (size_t)(flags_nul - start); - if (flags_length > BSON_MAX_SIZE || - (BSON_MAX_SIZE - pattern_length) < flags_length) { - Py_DECREF(pattern); - goto invalid; - } - /* Validate the flags as UTF-8. */ - PyObject* flags_str = PyUnicode_DecodeUTF8( - start, flags_length, - options->unicode_decode_error_handler); - if (!flags_str) { - Py_DECREF(pattern); - goto invalid; - } - Py_DECREF(flags_str); - flags = 0; - for (i = 0; i < flags_length; i++) { - if (buffer[*position + i] == 'i') { - flags |= 2; - } else if (buffer[*position + i] == 'l') { - flags |= 4; - } else if (buffer[*position + i] == 'm') { - flags |= 8; - } else if (buffer[*position + i] == 's') { - flags |= 16; - } else if (buffer[*position + i] == 'u') { - flags |= 32; - } else if (buffer[*position + i] == 'x') { - flags |= 64; - } - } - *position += (unsigned)flags_length + 1; - - PyObject* flags_obj = PyLong_FromLong(flags); - if (!flags_obj) { - Py_DECREF(pattern); - goto invalid; - } - PyObject* regex_args[2] = {pattern, flags_obj}; - value = PyObject_Vectorcall(state->Regex, regex_args, 2, NULL); - Py_DECREF(flags_obj); - Py_DECREF(pattern); - break; - } - case 12: - { - uint32_t coll_length; - PyObject* collection; - PyObject* id = NULL; - - if (max < 4) { - goto invalid; - } - memcpy(&coll_length, buffer + *position, 4); - coll_length = BSON_UINT32_FROM_LE(coll_length); - /* Encoded string length + string + 12 byte ObjectId */ - if (!coll_length || max < coll_length || max < 4 + coll_length + 12) { - goto invalid; - } - *position += 4; - /* Strings must end in \0 */ - if (buffer[*position + coll_length - 1]) { - goto invalid; - } - - collection = PyUnicode_DecodeUTF8( - buffer + *position, coll_length - 1, - options->unicode_decode_error_handler); - if (!collection) { - goto invalid; - } - *position += coll_length; - - PyObject* oid_bytes = PyBytes_FromStringAndSize(buffer + *position, 12); - if (!oid_bytes) { - Py_DECREF(collection); - goto invalid; - } - PyObject* oid_args[1] = {oid_bytes}; - id = PyObject_Vectorcall(state->ObjectId, oid_args, 1, NULL); - Py_DECREF(oid_bytes); - if (!id) { - Py_DECREF(collection); - goto invalid; - } - *position += 12; - PyObject* dbref_args[2] = {collection, id}; - value = PyObject_Vectorcall(state->DBRef, dbref_args, 2, NULL); - Py_DECREF(collection); - Py_DECREF(id); - break; - } - case 13: - { - PyObject* code; - uint32_t value_length; - if (max < 4) { - goto invalid; - } - memcpy(&value_length, buffer + *position, 4); - value_length = BSON_UINT32_FROM_LE(value_length); - /* Encoded string length + string */ - if (!value_length || max < value_length || max < 4 + value_length) { - goto invalid; - } - *position += 4; - /* Strings must end in \0 */ - if (buffer[*position + value_length - 1]) { - goto invalid; - } - code = PyUnicode_DecodeUTF8( - buffer + *position, value_length - 1, - options->unicode_decode_error_handler); - if (!code) { - goto invalid; - } - *position += value_length; - PyObject* code_args[1] = {code}; - value = PyObject_Vectorcall(state->Code, code_args, 1, NULL); - Py_DECREF(code); - break; - } - case 15: - { - uint32_t c_w_s_size; - uint32_t code_size; - uint32_t scope_size; - uint32_t len; - PyObject* code; - PyObject* scope; - - if (max < 8) { - goto invalid; - } - - memcpy(&c_w_s_size, buffer + *position, 4); - c_w_s_size = BSON_UINT32_FROM_LE(c_w_s_size); - *position += 4; - - if (max < c_w_s_size) { - goto invalid; - } - - memcpy(&code_size, buffer + *position, 4); - code_size = BSON_UINT32_FROM_LE(code_size); - /* code_w_scope length + code length + code + scope length */ - len = 4 + 4 + code_size + 4; - if (!code_size || max < code_size || max < len || len < code_size) { - goto invalid; - } - *position += 4; - /* Strings must end in \0 */ - if (buffer[*position + code_size - 1]) { - goto invalid; - } - code = PyUnicode_DecodeUTF8( - buffer + *position, code_size - 1, - options->unicode_decode_error_handler); - if (!code) { - goto invalid; - } - *position += code_size; - - memcpy(&scope_size, buffer + *position, 4); - scope_size = BSON_UINT32_FROM_LE(scope_size); - /* code length + code + scope length + scope */ - len = 4 + 4 + code_size + scope_size; - if (scope_size < BSON_MIN_SIZE || len != c_w_s_size || len < scope_size) { - Py_DECREF(code); - goto invalid; - } - - /* Check for bad eoo */ - if (buffer[*position + scope_size - 1]) { - goto invalid; - } - scope = elements_to_dict(self, buffer + *position, - scope_size, options); - if (!scope) { - Py_DECREF(code); - goto invalid; - } - *position += scope_size; - - PyObject* code_scope_args[2] = {code, scope}; - value = PyObject_Vectorcall(state->Code, code_scope_args, 2, NULL); - Py_DECREF(code); - Py_DECREF(scope); - break; - } - case 16: - { - int32_t i; - if (max < 4) { - goto invalid; - } - memcpy(&i, buffer + *position, 4); - i = (int32_t)BSON_UINT32_FROM_LE(i); - value = PyLong_FromLong(i); - if (!value) { - goto invalid; - } - *position += 4; - break; - } - case 17: - { - uint32_t time, inc; - if (max < 8) { - goto invalid; - } - memcpy(&inc, buffer + *position, 4); - memcpy(&time, buffer + *position + 4, 4); - inc = BSON_UINT32_FROM_LE(inc); - time = BSON_UINT32_FROM_LE(time); - PyObject* time_obj = PyLong_FromUnsignedLong(time); - if (!time_obj) { - goto invalid; - } - PyObject* inc_obj = PyLong_FromUnsignedLong(inc); - if (!inc_obj) { - Py_DECREF(time_obj); - goto invalid; - } - PyObject* ts_args[2] = {time_obj, inc_obj}; - value = PyObject_Vectorcall(state->Timestamp, ts_args, 2, NULL); - Py_DECREF(time_obj); - Py_DECREF(inc_obj); - *position += 8; - break; - } - case 18: - { - int64_t ll; - if (max < 8) { - goto invalid; - } - memcpy(&ll, buffer + *position, 8); - ll = (int64_t)BSON_UINT64_FROM_LE(ll); - PyObject* ll_obj = PyLong_FromLongLong(ll); - if (!ll_obj) { - goto invalid; - } - PyObject* int64_args[1] = {ll_obj}; - value = PyObject_Vectorcall(state->BSONInt64, int64_args, 1, NULL); - Py_DECREF(ll_obj); - *position += 8; - break; - } - case 19: - { - if (max < 16) { - goto invalid; - } - PyObject *_bytes_obj = PyBytes_FromStringAndSize(buffer + *position, (Py_ssize_t)16); - if (!_bytes_obj) { - goto invalid; - } - PyObject* dec128_args[2] = {state->Decimal128, _bytes_obj}; - value = PyObject_VectorcallMethod( - state->_from_bid_str, dec128_args, 2, NULL); - Py_DECREF(_bytes_obj); - *position += 16; - break; - } - case 255: - { - value = PyObject_Vectorcall(state->MinKey, NULL, 0, NULL); - break; - } - case 127: - { - value = PyObject_Vectorcall(state->MaxKey, NULL, 0, NULL); - break; - } - default: - { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyObject* bobj = PyBytes_FromFormat("%c", type); - if (bobj) { - PyObject* repr = PyObject_Repr(bobj); - Py_DECREF(bobj); - /* - * See http://bugs.python.org/issue22023 for why we can't - * just use PyUnicode_FromFormat with %S or %R to do this - * work. - */ - if (repr) { - PyObject* left = PyUnicode_FromString( - "Detected unknown BSON type "); - if (left) { - PyObject* lmsg = PyUnicode_Concat(left, repr); - Py_DECREF(left); - if (lmsg) { - PyObject* errmsg = PyUnicode_FromFormat( - "%U for fieldname '%U'. Are you using the " - "latest driver version?", lmsg, name); - if (errmsg) { - PyErr_SetObject(InvalidBSON, errmsg); - Py_DECREF(errmsg); - } - Py_DECREF(lmsg); - } - } - Py_DECREF(repr); - } - } - Py_DECREF(InvalidBSON); - } - goto invalid; - } - } - - if (value) { - if (!options->type_registry.is_decoder_empty) { - PyObject* value_type = NULL; - PyObject* converter = NULL; - value_type = PyObject_Type(value); - if (value_type == NULL) { - goto invalid; - } - converter = PyDict_GetItem(options->type_registry.decoder_map, value_type); - if (converter != NULL) { - PyObject* converter_args[1] = {value}; - PyObject* new_value = PyObject_Vectorcall(converter, converter_args, 1, NULL); - Py_DECREF(value_type); - Py_DECREF(value); - return new_value; - } else { - Py_DECREF(value_type); - return value; - } - } - return value; - } - - invalid: - - /* - * Wrap any non-InvalidBSON errors in InvalidBSON. - */ - if (PyErr_Occurred()) { - _rewrap_as_invalid_bson(); - } else { - PyObject *InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "invalid length or type code"); - Py_DECREF(InvalidBSON); - } - } - return NULL; -} - -/* - * Get the next 'name' and 'value' from a document in a string, whose position - * is provided. - * - * Returns the position of the next element in the document, or -1 on error. - */ -static int _element_to_dict(PyObject* self, const char* string, - unsigned position, unsigned max, - const codec_options_t* options, - int raw_array, - PyObject** name, PyObject** value) { - unsigned char type = (unsigned char)string[position++]; - size_t name_length = strlen(string + position); - if (name_length > BSON_MAX_SIZE || position + name_length >= max) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "field name too large"); - Py_DECREF(InvalidBSON); - } - return -1; - } - *name = PyUnicode_DecodeUTF8( - string + position, name_length, - options->unicode_decode_error_handler); - if (!*name) { - /* If NULL is returned then wrap the UnicodeDecodeError - in an InvalidBSON error */ - _rewrap_as_invalid_bson(); - return -1; - } - position += (unsigned)name_length + 1; - *value = get_value(self, *name, string, &position, type, - max - position, options, raw_array); - if (!*value) { - Py_DECREF(*name); - return -1; - } - return position; -} - -static PyObject* _cbson_element_to_dict(PyObject* self, PyObject* args) { - char* string; - PyObject* bson; - PyObject* options_obj = NULL; - codec_options_t options; - unsigned position; - unsigned max; - int new_position; - int raw_array = 0; - PyObject* name; - PyObject* value; - PyObject* result_tuple = NULL; - - if (!(PyArg_ParseTuple(args, "OIIOp", &bson, &position, &max, - &options_obj, &raw_array) && - convert_codec_options(self, options_obj, &options))) { - return NULL; - } - - if (!PyBytes_Check(bson)) { - PyErr_SetString(PyExc_TypeError, "argument to _element_to_dict must be a bytes object"); - goto done; - } - string = PyBytes_AS_STRING(bson); - options.buffer_owner = bson; - - new_position = _element_to_dict(self, string, position, max, &options, raw_array, &name, &value); - if (new_position < 0) { - goto done; - } - - result_tuple = Py_BuildValue("NNi", name, value, new_position); - if (!result_tuple) { - Py_DECREF(name); - Py_DECREF(value); - } - -done: - destroy_codec_options(&options); - return result_tuple; -} - -static PyObject* _elements_to_dict(PyObject* self, const char* string, - unsigned max, - const codec_options_t* options) { - unsigned position = 0; - PyObject* dict; - int raw_array = 0; - - /* Use PyDict_New() directly when document_class is dict. - * This avoids the overhead of PyObject_CallObject() for the common case. */ - if (options->is_dict_class) { - dict = PyDict_New(); - } else { - dict = PyObject_CallObject(options->document_class, NULL); - } - if (!dict) { - return NULL; - } - - while (position < max) { - PyObject* name = NULL; - PyObject* value = NULL; - int new_position; - - new_position = _element_to_dict( - self, string, position, max, options, raw_array, &name, &value); - if (new_position < 0) { - Py_DECREF(dict); - return NULL; - } else { - position = (unsigned)new_position; - } - - /* Use PyDict_SetItem() when document_class is dict. - * PyDict_SetItem() is faster than PyObject_SetItem() because it - * avoids method lookup overhead. */ - if (options->is_dict_class) { - if (PyDict_SetItem(dict, name, value) < 0) { - Py_DECREF(name); - Py_DECREF(value); - Py_DECREF(dict); - return NULL; - } - } else { - if (PyObject_SetItem(dict, name, value) < 0) { - Py_DECREF(name); - Py_DECREF(value); - Py_DECREF(dict); - return NULL; - } - } - Py_DECREF(name); - Py_DECREF(value); - } - return dict; -} - -static PyObject* elements_to_dict(PyObject* self, const char* string, - unsigned max, - const codec_options_t* options) { - PyObject* result; - if (options->is_raw_bson) { - PyObject* bson_bytes; - PyObject* buffer_owner = options->buffer_owner; - int owner_is_bytes = buffer_owner && PyBytes_Check(buffer_owner); - Py_ssize_t offset = 0; - if (owner_is_bytes) { - offset = string - PyBytes_AS_STRING(buffer_owner); - if (offset < 0 || - offset + (Py_ssize_t)max > PyBytes_GET_SIZE(buffer_owner)) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "invalid buffer offset"); - Py_DECREF(InvalidBSON); - } - return NULL; - } - } - if (owner_is_bytes && offset == 0 && - (Py_ssize_t)max == PyBytes_GET_SIZE(buffer_owner)) { - /* The document spans the entire buffer, pass the buffer - * itself through. */ - bson_bytes = buffer_owner; - Py_INCREF(bson_bytes); - } else if (owner_is_bytes && - (Py_ssize_t)max >= GETSTATE(self)->raw_bson_view_threshold) { - /* Zero-copy: pass a read-only slice of the buffer instead of a - * bytes copy. Only immutable (bytes) buffers may be sliced this - * way, mutable buffers must be copied so - * the caller can't mutate the document after decoding. */ - PyObject* top_view = PyMemoryView_FromObject(buffer_owner); - if (!top_view) { - return NULL; - } - bson_bytes = PySequence_GetSlice(top_view, offset, - offset + (Py_ssize_t)max); - Py_DECREF(top_view); - } else { - bson_bytes = PyBytes_FromStringAndSize(string, max); - } - if (!bson_bytes) { - return NULL; - } - PyObject* raw_args[2] = {bson_bytes, options->options_obj}; - result = PyObject_Vectorcall(options->document_class, raw_args, 2, NULL); - Py_DECREF(bson_bytes); - return result; - } - if (Py_EnterRecursiveCall(" while decoding a BSON document")) - return NULL; - result = _elements_to_dict(self, string + 4, max - 5, options); - Py_LeaveRecursiveCall(); - return result; -} - -static int _get_buffer(PyObject *exporter, Py_buffer *view) { - if (PyObject_GetBuffer(exporter, view, PyBUF_SIMPLE) == -1) { - return 0; - } - if (!PyBuffer_IsContiguous(view, 'C')) { - PyErr_SetString(PyExc_ValueError, - "must be a contiguous buffer"); - goto fail; - } - if (!view->buf || view->len < 0) { - PyErr_SetString(PyExc_ValueError, "invalid buffer"); - goto fail; - } - if (view->itemsize != 1) { - PyErr_SetString(PyExc_ValueError, - "buffer data must be ascii or utf8"); - goto fail; - } - return 1; -fail: - PyBuffer_Release(view); - return 0; -} - -/* Return 1 if any document in a stream of BSON documents is at least - * `threshold` bytes. Malformed lengths return 0. */ -static int _contains_view_eligible_doc(const char* data, Py_ssize_t len, - Py_ssize_t threshold) { - Py_ssize_t position = 0; - while (len - position >= 4) { - int32_t size; - memcpy(&size, data + position, 4); - size = (int32_t)BSON_UINT32_FROM_LE(size); - if (size < BSON_MIN_SIZE || (Py_ssize_t)size > len - position) { - return 0; - } - if ((Py_ssize_t)size >= threshold) { - return 1; - } - position += size; - } - return 0; -} - -/* Prepare an input buffer for raw-document decoding: bytes and - * bytearray are returned as-is, with other inputs copied to - * bytes only if the stream contains a document large enough for a zero-copy - * view. Returns a new reference or NULL on failure with an exception set. */ -static PyObject* _prepare_input_buffer(PyObject* self, PyObject* bson, - const codec_options_t* options) { - Py_buffer tmp = {0}; - int needs_copy; - if (!options->is_raw_bson || PyBytes_Check(bson) || PyByteArray_Check(bson)) { - Py_INCREF(bson); - return bson; - } - if (!_get_buffer(bson, &tmp)) { - return NULL; - } - needs_copy = _contains_view_eligible_doc( - (const char*)tmp.buf, tmp.len, GETSTATE(self)->raw_bson_view_threshold); - PyBuffer_Release(&tmp); - if (!needs_copy) { - Py_INCREF(bson); - return bson; - } - return PyBytes_FromObject(bson); -} - -/* Decode all elements of a raw BSON document into `result`. */ -static PyObject* _cbson_raw_to_dict(PyObject* self, PyObject* args) { - PyObject* data; - unsigned position; - unsigned obj_end; - PyObject* options_obj; - PyObject* result; - int raw_array = 0; - codec_options_t options; - PyObject* bson = NULL; - Py_buffer view = {0}; - PyObject* ret = NULL; - const char* string; - unsigned end; - - if (!(PyArg_ParseTuple(args, "OIIOOp", &data, &position, &obj_end, - &options_obj, &result, &raw_array) && - convert_codec_options(self, options_obj, &options))) { - return NULL; - } - - bson = _prepare_input_buffer(self, data, &options); - if (!bson) { - destroy_codec_options(&options); - return NULL; - } - - if (!_get_buffer(bson, &view)) { - Py_DECREF(bson); - destroy_codec_options(&options); - return NULL; - } - - string = (char*)view.buf; - /* obj_end must be the index of the document's eoo byte. The eoo check - * also protects against field scans running past the end of the buffer. */ - if (obj_end < 1 || (Py_ssize_t)obj_end >= view.len || position > obj_end || - string[obj_end]) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "bad object or element length"); - Py_DECREF(InvalidBSON); - } - goto done; - } - - options.buffer_owner = bson; - - end = obj_end - 1; - while (position < end) { - PyObject* name = NULL; - PyObject* value = NULL; - int new_position = _element_to_dict( - self, string, position, obj_end, &options, raw_array, &name, &value); - if (new_position < 0) { - goto done; - } - position = (unsigned)new_position; - - if (PyDict_CheckExact(result)) { - if (PyDict_SetItem(result, name, value) < 0) { - Py_DECREF(name); - Py_DECREF(value); - goto done; - } - } else { - if (PyObject_SetItem(result, name, value) < 0) { - Py_DECREF(name); - Py_DECREF(value); - goto done; - } - } - Py_DECREF(name); - Py_DECREF(value); - } - if (position != obj_end) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "bad object or element length"); - Py_DECREF(InvalidBSON); - } - goto done; - } - Py_INCREF(result); - ret = result; -done: - PyBuffer_Release(&view); - Py_DECREF(bson); - destroy_codec_options(&options); - return ret; -} - -static PyObject* _cbson_bson_to_dict(PyObject* self, PyObject* args) { - int32_t size; - Py_ssize_t total_size; - const char* string; - PyObject* bson = NULL; - codec_options_t options; - PyObject* result = NULL; - PyObject* options_obj; - Py_buffer view = {0}; - - if (! (PyArg_ParseTuple(args, "OO", &bson, &options_obj) && - convert_codec_options(self, options_obj, &options))) { - return result; - } - - bson = _prepare_input_buffer(self, bson, &options); - if (!bson) { - destroy_codec_options(&options); - return result; - } - - if (!_get_buffer(bson, &view)) { - Py_DECREF(bson); - destroy_codec_options(&options); - return result; - } - - total_size = view.len; - - if (total_size < BSON_MIN_SIZE) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, - "not enough data for a BSON document"); - Py_DECREF(InvalidBSON); - } - goto done;; - } - - string = (char*)view.buf; - options.buffer_owner = bson; - memcpy(&size, string, 4); - size = (int32_t)BSON_UINT32_FROM_LE(size); - if (size < BSON_MIN_SIZE) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "invalid message size"); - Py_DECREF(InvalidBSON); - } - goto done; - } - - if (total_size < size || total_size > BSON_MAX_SIZE) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "objsize too large"); - Py_DECREF(InvalidBSON); - } - goto done; - } - - if (size != total_size || string[size - 1]) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "bad eoo"); - Py_DECREF(InvalidBSON); - } - goto done; - } - - result = elements_to_dict(self, string, (unsigned)size, &options); -done: - PyBuffer_Release(&view); - Py_DECREF(bson); - destroy_codec_options(&options); - return result; -} - -static PyObject* _cbson_decode_all(PyObject* self, PyObject* args) { - int32_t size; - Py_ssize_t total_size; - const char* string; - PyObject* bson; - PyObject* dict; - PyObject* result = NULL; - codec_options_t options; - PyObject* options_obj = NULL; - Py_buffer view = {0}; - - if (!(PyArg_ParseTuple(args, "OO", &bson, &options_obj) && - convert_codec_options(self, options_obj, &options))) { - return NULL; - } - - bson = _prepare_input_buffer(self, bson, &options); - if (!bson) { - destroy_codec_options(&options); - return NULL; - } - - if (!_get_buffer(bson, &view)) { - Py_DECREF(bson); - destroy_codec_options(&options); - return NULL; - } - total_size = view.len; - string = (char*)view.buf; - options.buffer_owner = bson; - - if (!(result = PyList_New(0))) { - goto fail; - } - - while (total_size > 0) { - if (total_size < BSON_MIN_SIZE) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, - "not enough data for a BSON document"); - Py_DECREF(InvalidBSON); - } - Py_DECREF(result); - goto fail; - } - - memcpy(&size, string, 4); - size = (int32_t)BSON_UINT32_FROM_LE(size); - if (size < BSON_MIN_SIZE) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "invalid message size"); - Py_DECREF(InvalidBSON); - } - Py_DECREF(result); - goto fail; - } - - if (total_size < size) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "objsize too large"); - Py_DECREF(InvalidBSON); - } - Py_DECREF(result); - goto fail; - } - - if (string[size - 1]) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "bad eoo"); - Py_DECREF(InvalidBSON); - } - Py_DECREF(result); - goto fail; - } - - dict = elements_to_dict(self, string, (unsigned)size, &options); - if (!dict) { - Py_DECREF(result); - goto fail; - } - if (PyList_Append(result, dict) < 0) { - Py_DECREF(dict); - Py_DECREF(result); - goto fail; - } - Py_DECREF(dict); - string += size; - total_size -= size; - } - goto done; -fail: - result = NULL; -done: - PyBuffer_Release(&view); - Py_DECREF(bson); - destroy_codec_options(&options); - return result; -} - - -static PyObject* _cbson_array_of_documents_to_buffer(PyObject* self, PyObject* args) { - uint32_t size; - uint32_t value_length; - uint32_t position = 0; - buffer_t buffer; - const char* string; - PyObject* arr; - PyObject* result = NULL; - Py_buffer view = {0}; - - if (!PyArg_ParseTuple(args, "O", &arr)) { - return NULL; - } - - if (!_get_buffer(arr, &view)) { - return NULL; - } - - buffer = pymongo_buffer_new(); - if (!buffer) { - PyBuffer_Release(&view); - return NULL; - } - - string = (char*)view.buf; - - if (view.len < BSON_MIN_SIZE) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, - "not enough data for a BSON document"); - Py_DECREF(InvalidBSON); - } - goto fail; - } - - memcpy(&size, string, 4); - size = BSON_UINT32_FROM_LE(size); - - /* validate the size of the array */ - if (view.len != (int32_t)size || (int32_t)size < BSON_MIN_SIZE) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "objsize too large"); - Py_DECREF(InvalidBSON); - } - goto fail; - } - - if (string[size - 1]) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "bad eoo"); - Py_DECREF(InvalidBSON); - } - goto fail; - } - - /* save space for length */ - if (pymongo_buffer_save_space(buffer, size) == -1) { - goto fail; - } - pymongo_buffer_update_position(buffer, 0); - - position += 4; - while (position < size - 1) { - // Verify the value is an object. - unsigned char type = (unsigned char)string[position]; - if (type != 3) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "array element was not an object"); - Py_DECREF(InvalidBSON); - } - goto fail; - } - - // Just skip the keys. - position = position + strlen(string + position) + 1; - - if (position >= size || (size - position) < BSON_MIN_SIZE) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "invalid array content"); - Py_DECREF(InvalidBSON); - } - goto fail; - } - - memcpy(&value_length, string + position, 4); - value_length = BSON_UINT32_FROM_LE(value_length); - if (value_length < BSON_MIN_SIZE) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "invalid message size"); - Py_DECREF(InvalidBSON); - } - goto fail; - } - - if (value_length >= (uint32_t)(size - position)) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, "invalid array content"); - Py_DECREF(InvalidBSON); - } - goto fail; - } - - if (pymongo_buffer_write(buffer, string + position, value_length) == 1) { - goto fail; - } - position += value_length; - } - - if (position != size - 1) { - PyObject* InvalidBSON = _error("InvalidBSON"); - if (InvalidBSON) { - PyErr_SetString(InvalidBSON, - "bad object or element length"); - Py_DECREF(InvalidBSON); - } - goto fail; - } - - /* objectify buffer */ - result = Py_BuildValue("y#", pymongo_buffer_get_buffer(buffer), - (Py_ssize_t)pymongo_buffer_get_position(buffer)); - goto done; -fail: - result = NULL; -done: - PyBuffer_Release(&view); - pymongo_buffer_free(buffer); - return result; -} - - -static PyMethodDef _CBSONMethods[] = { - {"_dict_to_bson", _cbson_dict_to_bson, METH_VARARGS, - "convert a dictionary to a string containing its BSON representation."}, - {"_bson_to_dict", _cbson_bson_to_dict, METH_VARARGS, - "convert a BSON string to a SON object."}, - {"_decode_all", _cbson_decode_all, METH_VARARGS, - "convert binary data to a sequence of documents."}, - {"_element_to_dict", _cbson_element_to_dict, METH_VARARGS, - "Decode a single key, value pair."}, - {"_raw_to_dict", _cbson_raw_to_dict, METH_VARARGS, - "Decode all elements of a raw BSON document into a result mapping."}, - {"_array_of_documents_to_buffer", _cbson_array_of_documents_to_buffer, METH_VARARGS, "Convert raw array of documents to a stream of BSON documents"}, - {"_test_long_long_to_str", _test_long_long_to_str, METH_VARARGS, "Test conversion of extreme and common Py_ssize_t values to str."}, - {NULL, NULL, 0, NULL} -}; - -#define INITERROR return -1; -static int _cbson_traverse(PyObject *m, visitproc visit, void *arg) { - struct module_state *state = GETSTATE(m); - if (!state) { - return 0; - } - Py_VISIT(state->Binary); - Py_VISIT(state->Code); - Py_VISIT(state->ObjectId); - Py_VISIT(state->DBRef); - Py_VISIT(state->Regex); - Py_VISIT(state->UUID); - Py_VISIT(state->Timestamp); - Py_VISIT(state->MinKey); - Py_VISIT(state->MaxKey); - Py_VISIT(state->UTC); - Py_VISIT(state->REType); - Py_VISIT(state->_type_marker_str); - Py_VISIT(state->_flags_str); - Py_VISIT(state->_pattern_str); - Py_VISIT(state->_encoder_map_str); - Py_VISIT(state->_decoder_map_str); - Py_VISIT(state->_fallback_encoder_str); - Py_VISIT(state->_raw_str); - Py_VISIT(state->_subtype_str); - Py_VISIT(state->_binary_str); - Py_VISIT(state->_scope_str); - Py_VISIT(state->_inc_str); - Py_VISIT(state->_time_str); - Py_VISIT(state->_bid_str); - Py_VISIT(state->_replace_str); - Py_VISIT(state->_astimezone_str); - Py_VISIT(state->_id_str); - Py_VISIT(state->_dollar_ref_str); - Py_VISIT(state->_dollar_id_str); - Py_VISIT(state->_dollar_db_str); - Py_VISIT(state->_tzinfo_str); - Py_VISIT(state->_as_doc_str); - Py_VISIT(state->_utcoffset_str); - Py_VISIT(state->_from_uuid_str); - Py_VISIT(state->_as_uuid_str); - Py_VISIT(state->_from_bid_str); - Py_VISIT(state->min_datetime); - Py_VISIT(state->max_datetime); - Py_VISIT(state->replace_args); - Py_VISIT(state->replace_kwargs); - return 0; -} - -static int _cbson_clear(PyObject *m) { - struct module_state *state = GETSTATE(m); - if (!state) { - return 0; - } - Py_CLEAR(state->Binary); - Py_CLEAR(state->Code); - Py_CLEAR(state->ObjectId); - Py_CLEAR(state->DBRef); - Py_CLEAR(state->Regex); - Py_CLEAR(state->UUID); - Py_CLEAR(state->Timestamp); - Py_CLEAR(state->MinKey); - Py_CLEAR(state->MaxKey); - Py_CLEAR(state->UTC); - Py_CLEAR(state->REType); - Py_CLEAR(state->_type_marker_str); - Py_CLEAR(state->_flags_str); - Py_CLEAR(state->_pattern_str); - Py_CLEAR(state->_encoder_map_str); - Py_CLEAR(state->_decoder_map_str); - Py_CLEAR(state->_fallback_encoder_str); - Py_CLEAR(state->_raw_str); - Py_CLEAR(state->_subtype_str); - Py_CLEAR(state->_binary_str); - Py_CLEAR(state->_scope_str); - Py_CLEAR(state->_inc_str); - Py_CLEAR(state->_time_str); - Py_CLEAR(state->_bid_str); - Py_CLEAR(state->_replace_str); - Py_CLEAR(state->_astimezone_str); - Py_CLEAR(state->_id_str); - Py_CLEAR(state->_dollar_ref_str); - Py_CLEAR(state->_dollar_id_str); - Py_CLEAR(state->_dollar_db_str); - Py_CLEAR(state->_tzinfo_str); - Py_CLEAR(state->_as_doc_str); - Py_CLEAR(state->_utcoffset_str); - Py_CLEAR(state->_from_uuid_str); - Py_CLEAR(state->_as_uuid_str); - Py_CLEAR(state->_from_bid_str); - Py_CLEAR(state->min_datetime); - Py_CLEAR(state->max_datetime); - Py_CLEAR(state->replace_args); - Py_CLEAR(state->replace_kwargs); - return 0; -} - -/* Multi-phase extension module initialization code. - * See https://peps.python.org/pep-0489/. -*/ -static int -_cbson_exec(PyObject *m) -{ - PyObject *c_api_object; - static void *_cbson_API[_cbson_API_POINTER_COUNT]; - - PyDateTime_IMPORT; - if (PyDateTimeAPI == NULL) { - INITERROR; - } - - /* Export C API */ - _cbson_API[_cbson_buffer_write_bytes_INDEX] = (void *) buffer_write_bytes; - _cbson_API[_cbson_write_dict_INDEX] = (void *) write_dict; - _cbson_API[_cbson_write_pair_INDEX] = (void *) write_pair; - _cbson_API[_cbson_decode_and_write_pair_INDEX] = (void *) decode_and_write_pair; - _cbson_API[_cbson_convert_codec_options_INDEX] = (void *) convert_codec_options; - _cbson_API[_cbson_destroy_codec_options_INDEX] = (void *) destroy_codec_options; - _cbson_API[_cbson_buffer_write_double_INDEX] = (void *) buffer_write_double; - _cbson_API[_cbson_buffer_write_int32_INDEX] = (void *) buffer_write_int32; - _cbson_API[_cbson_buffer_write_int64_INDEX] = (void *) buffer_write_int64; - _cbson_API[_cbson_buffer_write_int32_at_position_INDEX] = - (void *) buffer_write_int32_at_position; - _cbson_API[_cbson_downcast_and_check_INDEX] = (void *) _downcast_and_check; - - c_api_object = PyCapsule_New((void *) _cbson_API, "_cbson._C_API", NULL); - if (c_api_object == NULL) - INITERROR; - - /* Import several python objects */ - if (_load_python_objects(m)) { - Py_DECREF(c_api_object); - Py_DECREF(m); - INITERROR; - } - -#if PY_VERSION_HEX >= 0x030D0000 - if (PyModule_Add(m, "_C_API", c_api_object) < 0) { - Py_DECREF(m); - INITERROR; - } -# else - if (PyModule_AddObject(m, "_C_API", c_api_object) < 0) { - Py_DECREF(c_api_object); - Py_DECREF(m); - INITERROR; - } -#endif - - return 0; -} - -static PyModuleDef_Slot _cbson_slots[] = { - {Py_mod_exec, _cbson_exec}, -#if defined(Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED) - {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED}, -#endif -#if PY_VERSION_HEX >= 0x030D0000 - {Py_mod_gil, Py_MOD_GIL_NOT_USED}, -#endif - {0, NULL}, -}; - - -static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, - "_cbson", - NULL, - sizeof(struct module_state), - _CBSONMethods, - _cbson_slots, - _cbson_traverse, - _cbson_clear, - NULL -}; - -PyMODINIT_FUNC -PyInit__cbson(void) -{ - return PyModuleDef_Init(&moduledef); -} diff --git a/bson/_cbsonmodule.h b/bson/_cbsonmodule.h deleted file mode 100644 index 2cf357bd5d..0000000000 --- a/bson/_cbsonmodule.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright 2009-present MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "bson-endian.h" - -#ifndef _CBSONMODULE_H -#define _CBSONMODULE_H - -#if defined(WIN32) || defined(_MSC_VER) -/* - * This macro is basically an implementation of asprintf for win32 - * We print to the provided buffer to get the string value as an int. - * USE LL2STR. This is kept only to test LL2STR. - */ -#if defined(_MSC_VER) && (_MSC_VER >= 1400) -#define INT2STRING(buffer, i) \ - _snprintf_s((buffer), \ - _scprintf("%lld", (i)) + 1, \ - _scprintf("%lld", (i)) + 1, \ - "%lld", \ - (i)) -#define STRCAT(dest, n, src) strcat_s((dest), (n), (src)) -#else -#define INT2STRING(buffer, i) \ - _snprintf((buffer), \ - _scprintf("%lld", (i)) + 1, \ - "%lld", \ - (i)) -#define STRCAT(dest, n, src) strcat((dest), (src)) -#endif -#else -#define INT2STRING(buffer, i) snprintf((buffer), sizeof((buffer)), "%lld", (i)) -#define STRCAT(dest, n, src) strcat((dest), (src)) -#endif - -/* Just enough space in char array to hold LLONG_MIN and null terminator */ -#define BUF_SIZE 21 -/* Converts integer to its string representation in decimal notation. */ -extern int cbson_long_long_to_str(long long int num, char* str, size_t size); -#define LL2STR(buffer, i) cbson_long_long_to_str((i), (buffer), sizeof(buffer)) - -typedef struct type_registry_t { - PyObject* encoder_map; - PyObject* decoder_map; - PyObject* fallback_encoder; - PyObject* registry_obj; - unsigned char is_encoder_empty; - unsigned char is_decoder_empty; - unsigned char has_fallback_encoder; -} type_registry_t; - -typedef struct codec_options_t { - PyObject* document_class; - unsigned char tz_aware; - unsigned char uuid_rep; - char* unicode_decode_error_handler; - PyObject* tzinfo; - type_registry_t type_registry; - unsigned char datetime_conversion; - PyObject* options_obj; - unsigned char is_raw_bson; - unsigned char is_dict_class; - PyObject* buffer_owner; /* The owning decode input buffer for RawBSONDocument */ -} codec_options_t; - -/* C API functions */ -#define _cbson_buffer_write_bytes_INDEX 0 -#define _cbson_buffer_write_bytes_RETURN int -#define _cbson_buffer_write_bytes_PROTO (buffer_t buffer, const char* data, int size) - -#define _cbson_write_dict_INDEX 1 -#define _cbson_write_dict_RETURN int -#define _cbson_write_dict_PROTO (PyObject* self, buffer_t buffer, PyObject* dict, unsigned char check_keys, const codec_options_t* options, unsigned char top_level) - -#define _cbson_write_pair_INDEX 2 -#define _cbson_write_pair_RETURN int -#define _cbson_write_pair_PROTO (PyObject* self, buffer_t buffer, const char* name, int name_length, PyObject* value, unsigned char check_keys, const codec_options_t* options, unsigned char allow_id) - -#define _cbson_decode_and_write_pair_INDEX 3 -#define _cbson_decode_and_write_pair_RETURN int -#define _cbson_decode_and_write_pair_PROTO (PyObject* self, buffer_t buffer, PyObject* key, PyObject* value, unsigned char check_keys, const codec_options_t* options, unsigned char top_level) - -#define _cbson_convert_codec_options_INDEX 4 -#define _cbson_convert_codec_options_RETURN int -#define _cbson_convert_codec_options_PROTO (PyObject* self, PyObject* options_obj, codec_options_t* options) - -#define _cbson_destroy_codec_options_INDEX 5 -#define _cbson_destroy_codec_options_RETURN void -#define _cbson_destroy_codec_options_PROTO (codec_options_t* options) - -#define _cbson_buffer_write_double_INDEX 6 -#define _cbson_buffer_write_double_RETURN int -#define _cbson_buffer_write_double_PROTO (buffer_t buffer, double data) - -#define _cbson_buffer_write_int32_INDEX 7 -#define _cbson_buffer_write_int32_RETURN int -#define _cbson_buffer_write_int32_PROTO (buffer_t buffer, int32_t data) - -#define _cbson_buffer_write_int64_INDEX 8 -#define _cbson_buffer_write_int64_RETURN int -#define _cbson_buffer_write_int64_PROTO (buffer_t buffer, int64_t data) - -#define _cbson_buffer_write_int32_at_position_INDEX 9 -#define _cbson_buffer_write_int32_at_position_RETURN void -#define _cbson_buffer_write_int32_at_position_PROTO (buffer_t buffer, int position, int32_t data) - -#define _cbson_downcast_and_check_INDEX 10 -#define _cbson_downcast_and_check_RETURN int -#define _cbson_downcast_and_check_PROTO (Py_ssize_t size, uint8_t extra) - -/* Total number of C API pointers */ -#define _cbson_API_POINTER_COUNT 11 - -#ifdef _CBSON_MODULE -/* This section is used when compiling _cbsonmodule */ - -static _cbson_buffer_write_bytes_RETURN buffer_write_bytes _cbson_buffer_write_bytes_PROTO; - -static _cbson_write_dict_RETURN write_dict _cbson_write_dict_PROTO; - -static _cbson_write_pair_RETURN write_pair _cbson_write_pair_PROTO; - -static _cbson_decode_and_write_pair_RETURN decode_and_write_pair _cbson_decode_and_write_pair_PROTO; - -static _cbson_convert_codec_options_RETURN convert_codec_options _cbson_convert_codec_options_PROTO; - -static _cbson_destroy_codec_options_RETURN destroy_codec_options _cbson_destroy_codec_options_PROTO; - -static _cbson_buffer_write_double_RETURN buffer_write_double _cbson_buffer_write_double_PROTO; - -static _cbson_buffer_write_int32_RETURN buffer_write_int32 _cbson_buffer_write_int32_PROTO; - -static _cbson_buffer_write_int64_RETURN buffer_write_int64 _cbson_buffer_write_int64_PROTO; - -static _cbson_buffer_write_int32_at_position_RETURN buffer_write_int32_at_position _cbson_buffer_write_int32_at_position_PROTO; - -static _cbson_downcast_and_check_RETURN _downcast_and_check _cbson_downcast_and_check_PROTO; - -#else -/* This section is used in modules that use _cbsonmodule's API */ - -static void **_cbson_API; - -#define buffer_write_bytes (*(_cbson_buffer_write_bytes_RETURN (*)_cbson_buffer_write_bytes_PROTO) _cbson_API[_cbson_buffer_write_bytes_INDEX]) - -#define write_dict (*(_cbson_write_dict_RETURN (*)_cbson_write_dict_PROTO) _cbson_API[_cbson_write_dict_INDEX]) - -#define write_pair (*(_cbson_write_pair_RETURN (*)_cbson_write_pair_PROTO) _cbson_API[_cbson_write_pair_INDEX]) - -#define decode_and_write_pair (*(_cbson_decode_and_write_pair_RETURN (*)_cbson_decode_and_write_pair_PROTO) _cbson_API[_cbson_decode_and_write_pair_INDEX]) - -#define convert_codec_options (*(_cbson_convert_codec_options_RETURN (*)_cbson_convert_codec_options_PROTO) _cbson_API[_cbson_convert_codec_options_INDEX]) - -#define destroy_codec_options (*(_cbson_destroy_codec_options_RETURN (*)_cbson_destroy_codec_options_PROTO) _cbson_API[_cbson_destroy_codec_options_INDEX]) - -#define buffer_write_double (*(_cbson_buffer_write_double_RETURN (*)_cbson_buffer_write_double_PROTO) _cbson_API[_cbson_buffer_write_double_INDEX]) - -#define buffer_write_int32 (*(_cbson_buffer_write_int32_RETURN (*)_cbson_buffer_write_int32_PROTO) _cbson_API[_cbson_buffer_write_int32_INDEX]) - -#define buffer_write_int64 (*(_cbson_buffer_write_int64_RETURN (*)_cbson_buffer_write_int64_PROTO) _cbson_API[_cbson_buffer_write_int64_INDEX]) - -#define buffer_write_int32_at_position (*(_cbson_buffer_write_int32_at_position_RETURN (*)_cbson_buffer_write_int32_at_position_PROTO) _cbson_API[_cbson_buffer_write_int32_at_position_INDEX]) - -#define _downcast_and_check (*(_cbson_downcast_and_check_RETURN (*)_cbson_downcast_and_check_PROTO) _cbson_API[_cbson_downcast_and_check_INDEX]) - -#define _cbson_IMPORT _cbson_API = (void **)PyCapsule_Import("_cbson._C_API", 0) - -#endif - -#endif // _CBSONMODULE_H diff --git a/bson/_helpers.py b/bson/_helpers.py deleted file mode 100644 index 596965a138..0000000000 --- a/bson/_helpers.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2021-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Setstate and getstate functions for objects with __slots__, allowing -compatibility with default pickling protocol -""" - -from __future__ import annotations - -from typing import TYPE_CHECKING, Any - -if TYPE_CHECKING: - from collections.abc import Mapping - - -def _setstate_slots(self: Any, state: Any) -> None: - for slot, value in state.items(): - setattr(self, slot, value) - - -def _mangle_name(name: str, prefix: str) -> str: - if name.startswith("__"): - prefix = "_" + prefix - else: - prefix = "" - return prefix + name - - -def _getstate_slots(self: Any) -> Mapping[Any, Any]: - prefix = self.__class__.__name__ - ret = {} - for name in self.__slots__: - mangled_name = _mangle_name(name, prefix) - if hasattr(self, mangled_name): - ret[mangled_name] = getattr(self, mangled_name) - return ret diff --git a/bson/binary.py b/bson/binary.py deleted file mode 100644 index 2a05970f2f..0000000000 --- a/bson/binary.py +++ /dev/null @@ -1,669 +0,0 @@ -# Copyright 2009-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from __future__ import annotations - -import struct -import warnings -from enum import Enum -from typing import TYPE_CHECKING, Any, Self, overload -from uuid import UUID - -"""Tools for representing BSON binary data. -""" - -BINARY_SUBTYPE = 0 -"""BSON binary subtype for binary data. - -This is the default subtype for binary data. -""" - -FUNCTION_SUBTYPE = 1 -"""BSON binary subtype for functions. -""" - -OLD_BINARY_SUBTYPE = 2 -"""Old BSON binary subtype for binary data. - -This is the old default subtype, the current -default is :data:`BINARY_SUBTYPE`. -""" - -OLD_UUID_SUBTYPE = 3 -"""Old BSON binary subtype for a UUID. - -:class:`uuid.UUID` instances will automatically be encoded -by :mod:`bson` using this subtype when using -:data:`UuidRepresentation.PYTHON_LEGACY`, -:data:`UuidRepresentation.JAVA_LEGACY`, or -:data:`UuidRepresentation.CSHARP_LEGACY`. - -.. versionadded:: 2.1 -""" - -UUID_SUBTYPE = 4 -"""BSON binary subtype for a UUID. - -This is the standard BSON binary subtype for UUIDs. -:class:`uuid.UUID` instances will automatically be encoded -by :mod:`bson` using this subtype when using -:data:`UuidRepresentation.STANDARD`. -""" - - -if TYPE_CHECKING: - from array import array as _array - from collections.abc import Sequence - from mmap import mmap as _mmap - - import numpy as np - import numpy.typing as npt - - -class UuidRepresentation: - UNSPECIFIED = 0 - """An unspecified UUID representation. - - When configured, :class:`uuid.UUID` instances will **not** be - automatically encoded to or decoded from :class:`~bson.binary.Binary`. - When encoding a :class:`uuid.UUID` instance, an error will be raised. - To encode a :class:`uuid.UUID` instance with this configuration, it must - be wrapped in the :class:`~bson.binary.Binary` class by the application - code. When decoding a BSON binary field with a UUID subtype, a - :class:`~bson.binary.Binary` instance will be returned instead of a - :class:`uuid.UUID` instance. - - See `unspecified representation details `_ for details. - - .. versionadded:: 3.11 - """ - - STANDARD = UUID_SUBTYPE - """The standard UUID representation. - - :class:`uuid.UUID` instances will automatically be encoded to - and decoded from BSON binary, using RFC-4122 byte order with - binary subtype :data:`UUID_SUBTYPE`. - - See `standard representation details `_ for details. - - .. versionadded:: 3.11 - """ - - PYTHON_LEGACY = OLD_UUID_SUBTYPE - """The Python legacy UUID representation. - - :class:`uuid.UUID` instances will automatically be encoded to - and decoded from BSON binary, using RFC-4122 byte order with - binary subtype :data:`OLD_UUID_SUBTYPE`. - - See `python legacy representation details `_ for details. - - .. versionadded:: 3.11 - """ - - JAVA_LEGACY = 5 - """The Java legacy UUID representation. - - :class:`uuid.UUID` instances will automatically be encoded to - and decoded from BSON binary subtype :data:`OLD_UUID_SUBTYPE`, - using the Java driver's legacy byte order. - - See `Java Legacy UUID `_ for details. - - .. versionadded:: 3.11 - """ - - CSHARP_LEGACY = 6 - """The C#/.net legacy UUID representation. - - :class:`uuid.UUID` instances will automatically be encoded to - and decoded from BSON binary subtype :data:`OLD_UUID_SUBTYPE`, - using the C# driver's legacy byte order. - - See `C# Legacy UUID `_ for details. - - .. versionadded:: 3.11 - """ - - -STANDARD = UuidRepresentation.STANDARD -"""An alias for :data:`UuidRepresentation.STANDARD`. - -.. versionadded:: 3.0 -""" - -PYTHON_LEGACY = UuidRepresentation.PYTHON_LEGACY -"""An alias for :data:`UuidRepresentation.PYTHON_LEGACY`. - -.. versionadded:: 3.0 -""" - -JAVA_LEGACY = UuidRepresentation.JAVA_LEGACY -"""An alias for :data:`UuidRepresentation.JAVA_LEGACY`. - -.. versionchanged:: 3.6 - BSON binary subtype 4 is decoded using RFC-4122 byte order. -.. versionadded:: 2.3 -""" - -CSHARP_LEGACY = UuidRepresentation.CSHARP_LEGACY -"""An alias for :data:`UuidRepresentation.CSHARP_LEGACY`. - -.. versionchanged:: 3.6 - BSON binary subtype 4 is decoded using RFC-4122 byte order. -.. versionadded:: 2.3 -""" - -ALL_UUID_SUBTYPES = (OLD_UUID_SUBTYPE, UUID_SUBTYPE) -ALL_UUID_REPRESENTATIONS = ( - UuidRepresentation.UNSPECIFIED, - UuidRepresentation.STANDARD, - UuidRepresentation.PYTHON_LEGACY, - UuidRepresentation.JAVA_LEGACY, - UuidRepresentation.CSHARP_LEGACY, -) -UUID_REPRESENTATION_NAMES = { - UuidRepresentation.UNSPECIFIED: "UuidRepresentation.UNSPECIFIED", - UuidRepresentation.STANDARD: "UuidRepresentation.STANDARD", - UuidRepresentation.PYTHON_LEGACY: "UuidRepresentation.PYTHON_LEGACY", - UuidRepresentation.JAVA_LEGACY: "UuidRepresentation.JAVA_LEGACY", - UuidRepresentation.CSHARP_LEGACY: "UuidRepresentation.CSHARP_LEGACY", -} - -MD5_SUBTYPE = 5 -"""BSON binary subtype for an MD5 hash. -""" - -COLUMN_SUBTYPE = 7 -"""BSON binary subtype for columns. - -.. versionadded:: 4.0 -""" - -SENSITIVE_SUBTYPE = 8 -"""BSON binary subtype for sensitive data. - -.. versionadded:: 4.5 -""" - - -VECTOR_SUBTYPE = 9 -"""BSON binary subtype for densely packed vector data. - -.. versionadded:: 4.10 -""" - - -USER_DEFINED_SUBTYPE = 128 -"""BSON binary subtype for any user defined structure. -""" - - -class BinaryVectorDtype(Enum): - """Datatypes of vector subtype. - - :param FLOAT32: (0x27) Pack list of :class:`float` as float32 - :param INT8: (0x03) Pack list of :class:`int` in [-128, 127] as signed int8 - :param PACKED_BIT: (0x10) Pack list of :class:`int` in [0, 255] as unsigned uint8 - - The `PACKED_BIT` value represents a special case where vector values themselves - can only be of two values (0 or 1) but these are packed together into groups of 8, - a byte. In Python, these are displayed as ints in range [0, 255] - - Each value is of type bytes with a length of one. - - .. versionadded:: 4.10 - """ - - INT8 = b"\x03" - FLOAT32 = b"\x27" - PACKED_BIT = b"\x10" - - -class BinaryVector: - """Vector of numbers along with metadata for binary interoperability. - .. versionadded:: 4.10 - """ - - __slots__ = ("data", "dtype", "padding") - - def __init__( - self, - data: Sequence[float | int] | npt.NDArray[np.number], - dtype: BinaryVectorDtype, - padding: int = 0, - ): - """ - :param data: Sequence of numbers representing the mathematical vector. - :param dtype: The data type stored in binary - :param padding: The number of bits in the final byte that are to be ignored - when a vector element's size is less than a byte - and the length of the vector is not a multiple of 8. - (Padding is equivalent to a negative value of `count` in - `numpy.unpackbits `_) - """ - self.data = data - self.dtype = dtype - self.padding = padding - - def __repr__(self) -> str: - return f"BinaryVector(dtype={self.dtype}, padding={self.padding}, data={self.data})" - - def __eq__(self, other: object) -> bool: - if not isinstance(other, BinaryVector): - return False - return ( - self.dtype == other.dtype and self.padding == other.padding and self.data == other.data - ) - - __hash__ = None # type: ignore[assignment] - - def __len__(self) -> int: - return len(self.data) - - -class Binary(bytes): - """Representation of BSON binary data. - - We want to represent Python strings as the BSON string type. - We need to wrap binary data so that we can tell - the difference between what should be considered binary data and - what should be considered a string when we encode to BSON. - - Subtype 9 provides a space-efficient representation of 1-dimensional vector data. - Its data is prepended with two bytes of metadata. - The first (dtype) describes its data type, such as float32 or int8. - The second (padding) prescribes the number of bits to ignore in the final byte. - This is relevant when the element size of the dtype is not a multiple of 8. - - Raises TypeError if `subtype` is not an instance of :class:`int`. - Raises ValueError if `subtype` is not in [0, 256). - - .. note:: - Instances of Binary with subtype 0 will be decoded directly to :class:`bytes`. - - :param data: the binary data to represent. Can be any bytes-like type - that implements the buffer protocol. - :param subtype: the `binary subtype - `_ - to use - - .. versionchanged:: 3.9 - Support any bytes-like type that implements the buffer protocol. - - .. versionchanged:: 4.10 - Addition of vector subtype. - """ - - _type_marker = 5 - __subtype: int - - def __new__( - cls, - data: memoryview | bytes | bytearray | _mmap | _array[Any], - subtype: int = BINARY_SUBTYPE, - ) -> Self: - if not isinstance(subtype, int): - raise TypeError(f"subtype must be an instance of int, not {type(subtype)}") - if subtype >= 256 or subtype < 0: - raise ValueError("subtype must be contained in [0, 256)") - # Support any type that implements the buffer protocol. - self = bytes.__new__(cls, memoryview(data).tobytes()) - self.__subtype = subtype - return self - - @classmethod - def from_uuid( - cls: type[Binary], uuid: UUID, uuid_representation: int = UuidRepresentation.STANDARD - ) -> Binary: - """Create a BSON Binary object from a Python UUID. - - Creates a :class:`~bson.binary.Binary` object from a - :class:`uuid.UUID` instance. Assumes that the native - :class:`uuid.UUID` instance uses the byte-order implied by the - provided ``uuid_representation``. - - Raises :exc:`TypeError` if `uuid` is not an instance of - :class:`~uuid.UUID`. - - :param uuid: A :class:`uuid.UUID` instance. - :param uuid_representation: A member of - :class:`~bson.binary.UuidRepresentation`. Default: - :const:`~bson.binary.UuidRepresentation.STANDARD`. - See `UUID representations `_ for details. - - .. versionadded:: 3.11 - """ - if not isinstance(uuid, UUID): - raise TypeError(f"uuid must be an instance of uuid.UUID, not {type(uuid)}") - - if uuid_representation not in ALL_UUID_REPRESENTATIONS: - raise ValueError( - "uuid_representation must be a value from bson.binary.UuidRepresentation" - ) - - if uuid_representation == UuidRepresentation.UNSPECIFIED: - raise ValueError( - "cannot encode native uuid.UUID with " - "UuidRepresentation.UNSPECIFIED. UUIDs can be manually " - "converted to bson.Binary instances using " - "bson.Binary.from_uuid() or a different UuidRepresentation " - "can be configured. See the documentation for " - "UuidRepresentation for more information." - ) - - subtype = OLD_UUID_SUBTYPE - if uuid_representation == UuidRepresentation.PYTHON_LEGACY: - payload = uuid.bytes - elif uuid_representation == UuidRepresentation.JAVA_LEGACY: - from_uuid = uuid.bytes - payload = from_uuid[0:8][::-1] + from_uuid[8:16][::-1] - elif uuid_representation == UuidRepresentation.CSHARP_LEGACY: - payload = uuid.bytes_le - else: - # uuid_representation == UuidRepresentation.STANDARD - subtype = UUID_SUBTYPE - payload = uuid.bytes - - return cls(payload, subtype) - - def as_uuid(self, uuid_representation: int = UuidRepresentation.STANDARD) -> UUID: - """Create a Python UUID from this BSON Binary object. - - Decodes this binary object as a native :class:`uuid.UUID` instance - with the provided ``uuid_representation``. - - Raises :exc:`ValueError` if this :class:`~bson.binary.Binary` instance - does not contain a UUID, or its payload is not exactly 16 bytes. - - :param uuid_representation: A member of - :class:`~bson.binary.UuidRepresentation`. Default: - :const:`~bson.binary.UuidRepresentation.STANDARD`. - See `UUID representations `_ for details. - - .. versionadded:: 3.11 - """ - if self.subtype not in ALL_UUID_SUBTYPES: - raise ValueError(f"cannot decode subtype {self.subtype} as a uuid") - - if uuid_representation not in ALL_UUID_REPRESENTATIONS: - raise ValueError( - "uuid_representation must be a value from bson.binary.UuidRepresentation" - ) - - if uuid_representation == UuidRepresentation.UNSPECIFIED: - raise ValueError("uuid_representation cannot be UNSPECIFIED") - - if len(self) != 16: - raise ValueError(f"cannot decode a uuid from a {len(self)}-byte payload, expected 16") - - if uuid_representation == UuidRepresentation.PYTHON_LEGACY: - if self.subtype == OLD_UUID_SUBTYPE: - return UUID(bytes=self) - elif uuid_representation == UuidRepresentation.JAVA_LEGACY: - if self.subtype == OLD_UUID_SUBTYPE: - return UUID(bytes=self[0:8][::-1] + self[8:16][::-1]) - elif uuid_representation == UuidRepresentation.CSHARP_LEGACY: - if self.subtype == OLD_UUID_SUBTYPE: - return UUID(bytes_le=self) - else: - # uuid_representation == UuidRepresentation.STANDARD - if self.subtype == UUID_SUBTYPE: - return UUID(bytes=self) - - raise ValueError( - f"cannot decode subtype {self.subtype} to {UUID_REPRESENTATION_NAMES[uuid_representation]}" - ) - - @classmethod - @overload - def from_vector(cls: type[Binary], vector: BinaryVector) -> Binary: ... - - @classmethod - @overload - def from_vector( - cls: type[Binary], - vector: list[int] | list[float], - dtype: BinaryVectorDtype, - padding: int = 0, - ) -> Binary: ... - - @classmethod - @overload - def from_vector( - cls: type[Binary], - vector: npt.NDArray[np.number], - dtype: BinaryVectorDtype, - padding: int = 0, - ) -> Binary: ... - - @classmethod - def from_vector( - cls: type[Binary], - vector: BinaryVector | list[int] | list[float] | npt.NDArray[np.number], - dtype: BinaryVectorDtype | None = None, - padding: int | None = None, - ) -> Binary: - """Create a BSON :class:`~bson.binary.Binary` of Vector subtype. - - To interpret the representation of the numbers, a data type must be included. - See :class:`~bson.binary.BinaryVectorDtype` for available types and descriptions. - - The dtype and padding are prepended to the binary data's value. - - :param vector: Either a List of values, or a :class:`~bson.binary.BinaryVector` dataclass. - :param dtype: Data type of the values - :param padding: For fractional bytes, number of bits to ignore at end of vector. - :return: Binary packed data identified by dtype and padding. - - .. versionchanged:: 4.14 - When padding is non-zero, ignored bits should be zero. Raise exception on encoding, warn on decoding. - - .. versionadded:: 4.10 - """ - if isinstance(vector, BinaryVector): - if dtype or padding: - raise ValueError( - "The first argument, vector, has type BinaryVector. " - "dtype or padding cannot be separately defined, but were." - ) - dtype = vector.dtype - padding = vector.padding - vector = vector.data # type: ignore - - padding = 0 if padding is None else padding - if not isinstance(dtype, BinaryVectorDtype): - raise TypeError( - "dtype must be a bson.BinaryVectorDtype of BinaryVectorDType.INT8, PACKED_BIT, FLOAT32" - ) - metadata = struct.pack(" 7: - raise ValueError(f"{padding=}. It must be in [0,1, ..7].") - if padding and not vector: - raise ValueError("Empty vector with non-zero padding.") - elif dtype == BinaryVectorDtype.FLOAT32: # pack floats as float32 - format_str = "f" - if padding: - raise ValueError(f"padding does not apply to {dtype=}") - else: - raise NotImplementedError(f"{dtype} not yet supported") - data = struct.pack(f"<{len(vector)}{format_str}", *vector) - else: # vector is numpy array or incorrect type. - try: - import numpy as np - except ImportError as exc: - raise ImportError( - "Failed to create binary from vector. Check type. If numpy array, numpy must be installed." - ) from exc - if not isinstance(vector, np.ndarray): - raise TypeError( - "Could not create Binary. Vector must be a BinaryVector, list[int], list[float] or numpy ndarray." - ) - if vector.ndim != 1: - raise ValueError( - "from_numpy_vector only supports 1D arrays as it creates a single vector." - ) - - if dtype == BinaryVectorDtype.FLOAT32: - vector = vector.astype(np.dtype("float32"), copy=False) - elif dtype == BinaryVectorDtype.INT8: - if vector.min() >= -128 and vector.max() <= 127: - vector = vector.astype(np.dtype("int8"), copy=False) - else: - raise ValueError("Values found outside INT8 range.") - elif dtype == BinaryVectorDtype.PACKED_BIT: - if vector.min() >= 0 and vector.max() <= 127: - vector = vector.astype(np.dtype("uint8"), copy=False) - else: - raise ValueError("Values found outside UINT8 range.") - else: - raise NotImplementedError(f"{dtype} not yet supported") - data = vector.tobytes() - - if padding and len(vector) and not (data[-1] & ((1 << padding) - 1)) == 0: - raise ValueError( - "Vector has a padding P, but bits in the final byte lower than P are non-zero. They must be zero." - ) - return cls(metadata + data, subtype=VECTOR_SUBTYPE) - - def as_vector(self, return_numpy: bool = False) -> BinaryVector: - """From the Binary, create a list or 1-d numpy array of numbers, along with dtype and padding. - - :param return_numpy: If True, BinaryVector.data will be a one-dimensional numpy array. By default, it is a list. - :return: BinaryVector - - .. versionadded:: 4.10 - """ - - if self.subtype != VECTOR_SUBTYPE: - raise ValueError(f"Cannot decode subtype {self.subtype} as a vector") - - dtype, padding = struct.unpack_from(" 7 or padding < 0: - raise ValueError(f"Corrupt data. Padding ({padding}) must be between 0 and 7.") - dtype_format = "B" - format_string = f"<{n_bytes}{dtype_format}" - unpacked_uint8s = list(struct.unpack_from(format_string, self, offset)) - if padding and n_bytes and unpacked_uint8s[-1] & (1 << padding) - 1 != 0: - warnings.warn( - "Vector has a padding P, but bits in the final byte lower than P are non-zero. For pymongo>=5.0, they must be zero.", - DeprecationWarning, - stacklevel=2, - ) - return BinaryVector(unpacked_uint8s, dtype, padding) - - else: - raise NotImplementedError(f"Binary Vector dtype {dtype.name} not yet supported") - else: # create a numpy array - try: - import numpy as np - except ImportError as exc: - raise ImportError( - "Converting binary to numpy.ndarray requires numpy to be installed." - ) from exc - if dtype == BinaryVectorDtype.INT8: - data = np.frombuffer(self[offset:], dtype="int8") - elif dtype == BinaryVectorDtype.FLOAT32: - if n_bytes % 4: - raise ValueError( - "Corrupt data. N bytes for a float32 vector must be a multiple of 4." - ) - data = np.frombuffer(self[offset:], dtype="float32") - elif dtype == BinaryVectorDtype.PACKED_BIT: - # data packed as uint8 - if padding and not n_bytes: - raise ValueError("Corrupt data. Vector has a padding P, but no data.") - if padding > 7 or padding < 0: - raise ValueError(f"Corrupt data. Padding ({padding}) must be between 0 and 7.") - data = np.frombuffer(self[offset:], dtype="uint8") - if padding and np.unpackbits(data[-1])[-padding:].sum() > 0: - warnings.warn( - "Vector has a padding P, but bits in the final byte lower than P are non-zero. For pymongo>=5.0, they must be zero.", - DeprecationWarning, - stacklevel=2, - ) - else: - raise NotImplementedError(f"Binary Vector dtype {dtype.name} not yet supported") - return BinaryVector(data, dtype, padding) - - @property - def subtype(self) -> int: - """Subtype of this binary data.""" - return self.__subtype - - def __getnewargs__(self) -> tuple[bytes, int]: # type: ignore[override] - # Work around http://bugs.python.org/issue7382 - data = super().__getnewargs__()[0] - if not isinstance(data, bytes): - data = data.encode("latin-1") - return data, self.__subtype - - def __eq__(self, other: object) -> bool: - if isinstance(other, Binary): - return (self.__subtype, bytes(self)) == (other.subtype, bytes(other)) - # We don't return NotImplemented here because if we did then - # Binary("foo") == "foo" would return True, since Binary is a - # subclass of str... - return False - - def __hash__(self) -> int: - return super().__hash__() ^ hash(self.__subtype) - - def __ne__(self, other: object) -> bool: - return not self == other - - def __repr__(self) -> str: - if self.__subtype == SENSITIVE_SUBTYPE: - return f"" - else: - return f"Binary({bytes.__repr__(self)}, {self.__subtype})" diff --git a/bson/bson-endian.h b/bson/bson-endian.h deleted file mode 100644 index e906b0776f..0000000000 --- a/bson/bson-endian.h +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright 2013-2016 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef BSON_ENDIAN_H -#define BSON_ENDIAN_H - - -#if defined(__sun) -# include -#endif - - -#ifdef _MSC_VER -# define BSON_INLINE __inline -#else -# include -# define BSON_INLINE __inline__ -#endif - - -#define BSON_BIG_ENDIAN 4321 -#define BSON_LITTLE_ENDIAN 1234 - - -/* WORDS_BIGENDIAN from pyconfig.h / Python.h */ -#ifdef WORDS_BIGENDIAN -# define BSON_BYTE_ORDER BSON_BIG_ENDIAN -#else -# define BSON_BYTE_ORDER BSON_LITTLE_ENDIAN -#endif - - -#if defined(__sun) -# define BSON_UINT16_SWAP_LE_BE(v) BSWAP_16((uint16_t)v) -# define BSON_UINT32_SWAP_LE_BE(v) BSWAP_32((uint32_t)v) -# define BSON_UINT64_SWAP_LE_BE(v) BSWAP_64((uint64_t)v) -#elif defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__) && \ - (__clang_major__ >= 3) && (__clang_minor__ >= 1) -# if __has_builtin(__builtin_bswap16) -# define BSON_UINT16_SWAP_LE_BE(v) __builtin_bswap16(v) -# endif -# if __has_builtin(__builtin_bswap32) -# define BSON_UINT32_SWAP_LE_BE(v) __builtin_bswap32(v) -# endif -# if __has_builtin(__builtin_bswap64) -# define BSON_UINT64_SWAP_LE_BE(v) __builtin_bswap64(v) -# endif -#elif defined(__GNUC__) && (__GNUC__ >= 4) -# if __GNUC__ >= 4 && defined (__GNUC_MINOR__) && __GNUC_MINOR__ >= 3 -# define BSON_UINT32_SWAP_LE_BE(v) __builtin_bswap32 ((uint32_t)v) -# define BSON_UINT64_SWAP_LE_BE(v) __builtin_bswap64 ((uint64_t)v) -# endif -# if __GNUC__ >= 4 && defined (__GNUC_MINOR__) && __GNUC_MINOR__ >= 8 -# define BSON_UINT16_SWAP_LE_BE(v) __builtin_bswap16 ((uint32_t)v) -# endif -#endif - - -#ifndef BSON_UINT16_SWAP_LE_BE -# define BSON_UINT16_SWAP_LE_BE(v) __bson_uint16_swap_slow ((uint16_t)v) -#endif - - -#ifndef BSON_UINT32_SWAP_LE_BE -# define BSON_UINT32_SWAP_LE_BE(v) __bson_uint32_swap_slow ((uint32_t)v) -#endif - - -#ifndef BSON_UINT64_SWAP_LE_BE -# define BSON_UINT64_SWAP_LE_BE(v) __bson_uint64_swap_slow ((uint64_t)v) -#endif - - -#if BSON_BYTE_ORDER == BSON_LITTLE_ENDIAN -# define BSON_UINT16_FROM_LE(v) ((uint16_t)v) -# define BSON_UINT16_TO_LE(v) ((uint16_t)v) -# define BSON_UINT16_FROM_BE(v) BSON_UINT16_SWAP_LE_BE (v) -# define BSON_UINT16_TO_BE(v) BSON_UINT16_SWAP_LE_BE (v) -# define BSON_UINT32_FROM_LE(v) ((uint32_t)v) -# define BSON_UINT32_TO_LE(v) ((uint32_t)v) -# define BSON_UINT32_FROM_BE(v) BSON_UINT32_SWAP_LE_BE (v) -# define BSON_UINT32_TO_BE(v) BSON_UINT32_SWAP_LE_BE (v) -# define BSON_UINT64_FROM_LE(v) ((uint64_t)v) -# define BSON_UINT64_TO_LE(v) ((uint64_t)v) -# define BSON_UINT64_FROM_BE(v) BSON_UINT64_SWAP_LE_BE (v) -# define BSON_UINT64_TO_BE(v) BSON_UINT64_SWAP_LE_BE (v) -# define BSON_DOUBLE_FROM_LE(v) ((double)v) -# define BSON_DOUBLE_TO_LE(v) ((double)v) -#elif BSON_BYTE_ORDER == BSON_BIG_ENDIAN -# define BSON_UINT16_FROM_LE(v) BSON_UINT16_SWAP_LE_BE (v) -# define BSON_UINT16_TO_LE(v) BSON_UINT16_SWAP_LE_BE (v) -# define BSON_UINT16_FROM_BE(v) ((uint16_t)v) -# define BSON_UINT16_TO_BE(v) ((uint16_t)v) -# define BSON_UINT32_FROM_LE(v) BSON_UINT32_SWAP_LE_BE (v) -# define BSON_UINT32_TO_LE(v) BSON_UINT32_SWAP_LE_BE (v) -# define BSON_UINT32_FROM_BE(v) ((uint32_t)v) -# define BSON_UINT32_TO_BE(v) ((uint32_t)v) -# define BSON_UINT64_FROM_LE(v) BSON_UINT64_SWAP_LE_BE (v) -# define BSON_UINT64_TO_LE(v) BSON_UINT64_SWAP_LE_BE (v) -# define BSON_UINT64_FROM_BE(v) ((uint64_t)v) -# define BSON_UINT64_TO_BE(v) ((uint64_t)v) -# define BSON_DOUBLE_FROM_LE(v) (__bson_double_swap_slow (v)) -# define BSON_DOUBLE_TO_LE(v) (__bson_double_swap_slow (v)) -#else -# error "The endianness of target architecture is unknown." -#endif - - -/* - *-------------------------------------------------------------------------- - * - * __bson_uint16_swap_slow -- - * - * Fallback endianness conversion for 16-bit integers. - * - * Returns: - * The endian swapped version. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static BSON_INLINE uint16_t -__bson_uint16_swap_slow (uint16_t v) /* IN */ -{ - return ((v & 0x00FF) << 8) | - ((v & 0xFF00) >> 8); -} - - -/* - *-------------------------------------------------------------------------- - * - * __bson_uint32_swap_slow -- - * - * Fallback endianness conversion for 32-bit integers. - * - * Returns: - * The endian swapped version. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static BSON_INLINE uint32_t -__bson_uint32_swap_slow (uint32_t v) /* IN */ -{ - return ((v & 0x000000FFU) << 24) | - ((v & 0x0000FF00U) << 8) | - ((v & 0x00FF0000U) >> 8) | - ((v & 0xFF000000U) >> 24); -} - - -/* - *-------------------------------------------------------------------------- - * - * __bson_uint64_swap_slow -- - * - * Fallback endianness conversion for 64-bit integers. - * - * Returns: - * The endian swapped version. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - -static BSON_INLINE uint64_t -__bson_uint64_swap_slow (uint64_t v) /* IN */ -{ - return ((v & 0x00000000000000FFULL) << 56) | - ((v & 0x000000000000FF00ULL) << 40) | - ((v & 0x0000000000FF0000ULL) << 24) | - ((v & 0x00000000FF000000ULL) << 8) | - ((v & 0x000000FF00000000ULL) >> 8) | - ((v & 0x0000FF0000000000ULL) >> 24) | - ((v & 0x00FF000000000000ULL) >> 40) | - ((v & 0xFF00000000000000ULL) >> 56); -} - - -/* - *-------------------------------------------------------------------------- - * - * __bson_double_swap_slow -- - * - * Fallback endianness conversion for double floating point. - * - * Returns: - * The endian swapped version. - * - * Side effects: - * None. - * - *-------------------------------------------------------------------------- - */ - - -static BSON_INLINE double -__bson_double_swap_slow (double v) /* IN */ -{ - uint64_t uv; - - memcpy(&uv, &v, sizeof(v)); - uv = BSON_UINT64_SWAP_LE_BE(uv); - memcpy(&v, &uv, sizeof(v)); - - return v; -} - - -#endif /* BSON_ENDIAN_H */ diff --git a/bson/buffer.c b/bson/buffer.c deleted file mode 100644 index c7df462980..0000000000 --- a/bson/buffer.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright 2009-2015 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* Include Python.h so we can set Python's error indicator. */ -#define PY_SSIZE_T_CLEAN -#include "Python.h" - -#include -#include -#include - -#include "buffer.h" - -#define INITIAL_BUFFER_SIZE 256 - -struct buffer { - char* buffer; - int size; - int position; -}; - -/* Set Python's error indicator to MemoryError. - * Called after allocation failures. */ -static void set_memory_error(void) { - PyErr_NoMemory(); -} - -/* Allocate and return a new buffer. - * Return NULL and sets MemoryError on allocation failure. */ -buffer_t pymongo_buffer_new(void) { - buffer_t buffer; - buffer = (buffer_t)malloc(sizeof(struct buffer)); - if (buffer == NULL) { - set_memory_error(); - return NULL; - } - - buffer->size = INITIAL_BUFFER_SIZE; - buffer->position = 0; - buffer->buffer = (char*)malloc(sizeof(char) * INITIAL_BUFFER_SIZE); - if (buffer->buffer == NULL) { - free(buffer); - set_memory_error(); - return NULL; - } - - return buffer; -} - -/* Free the memory allocated for `buffer`. - * Return non-zero on failure. */ -int pymongo_buffer_free(buffer_t buffer) { - if (buffer == NULL) { - return 1; - } - /* Buffer will be NULL when buffer_grow fails. */ - if (buffer->buffer != NULL) { - free(buffer->buffer); - } - free(buffer); - return 0; -} - -/* Grow `buffer` to at least `min_length`. - * Return non-zero and sets MemoryError on allocation failure. */ -static int buffer_grow(buffer_t buffer, int min_length) { - int old_size = 0; - int size = buffer->size; - char* old_buffer = buffer->buffer; - if (size >= min_length) { - return 0; - } - while (size < min_length) { - old_size = size; - if (size > INT_MAX / 2) { - /* Doubling `size` would overflow `int`; grow to exactly - * min_length instead. */ - size = min_length; - } else { - size *= 2; - if (size <= old_size) { - /* Size did not increase. Could be size < 1. */ - size = min_length; - } - } - } - buffer->buffer = (char*)realloc(buffer->buffer, sizeof(char) * size); - if (buffer->buffer == NULL) { - free(old_buffer); - set_memory_error(); - return 1; - } - buffer->size = size; - return 0; -} - -/* Assure that `buffer` has at least `size` free bytes (and grow if needed). - * Return non-zero and sets MemoryError on allocation failure. - * Return non-zero and sets ValueError if `size` would exceed 2GiB. */ -static int buffer_assure_space(buffer_t buffer, int size) { - long long new_size; - if (size < 0) { - PyErr_SetString(PyExc_ValueError, - "Document would overflow BSON size limit"); - return 1; - } - - /* Compute in a wider type so the addition cannot overflow `int`. */ - new_size = (long long)buffer->position + (long long)size; - if (new_size > INT_MAX) { - PyErr_SetString(PyExc_ValueError, - "Document would overflow BSON size limit"); - return 1; - } - - if ((int)new_size <= buffer->size) { - return 0; - } - return buffer_grow(buffer, (int)new_size); -} - -/* Save `size` bytes from the current position in `buffer` (and grow if needed). - * Return offset for writing, or -1 on failure. - * Sets MemoryError or ValueError on failure. */ -buffer_position pymongo_buffer_save_space(buffer_t buffer, int size) { - int position = buffer->position; - if (buffer_assure_space(buffer, size) != 0) { - return -1; - } - buffer->position += size; - return position; -} - -/* Write `size` bytes from `data` to `buffer` (and grow if needed). - * Return non-zero on failure. - * Sets MemoryError or ValueError on failure. */ -int pymongo_buffer_write(buffer_t buffer, const char* data, int size) { - if (buffer_assure_space(buffer, size) != 0) { - return 1; - } - - memcpy(buffer->buffer + buffer->position, data, size); - buffer->position += size; - return 0; -} - -int pymongo_buffer_get_position(buffer_t buffer) { - return buffer->position; -} - -char* pymongo_buffer_get_buffer(buffer_t buffer) { - return buffer->buffer; -} - -void pymongo_buffer_update_position(buffer_t buffer, buffer_position new_position) { - buffer->position = new_position; -} diff --git a/bson/buffer.h b/bson/buffer.h deleted file mode 100644 index a78e34e4de..0000000000 --- a/bson/buffer.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2009-2015 MongoDB, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef BUFFER_H -#define BUFFER_H - -/* Note: if any of these functions return a failure condition then the buffer - * has already been freed. */ - -/* A buffer */ -typedef struct buffer* buffer_t; -/* A position in the buffer */ -typedef int buffer_position; - -/* Allocate and return a new buffer. - * Return NULL on allocation failure. */ -buffer_t pymongo_buffer_new(void); - -/* Free the memory allocated for `buffer`. - * Return non-zero on failure. */ -int pymongo_buffer_free(buffer_t buffer); - -/* Save `size` bytes from the current position in `buffer` (and grow if needed). - * Return offset for writing, or -1 on allocation failure. */ -buffer_position pymongo_buffer_save_space(buffer_t buffer, int size); - -/* Write `size` bytes from `data` to `buffer` (and grow if needed). - * Return non-zero on allocation failure. */ -int pymongo_buffer_write(buffer_t buffer, const char* data, int size); - -/* Getters for the internals of a buffer_t. - * Should try to avoid using these as much as possible - * since they break the abstraction. */ -buffer_position pymongo_buffer_get_position(buffer_t buffer); -char* pymongo_buffer_get_buffer(buffer_t buffer); -void pymongo_buffer_update_position(buffer_t buffer, buffer_position new_position); - -#endif diff --git a/bson/code.py b/bson/code.py deleted file mode 100644 index 60193e12f5..0000000000 --- a/bson/code.py +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright 2009-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Tools for representing JavaScript code in BSON.""" - -from __future__ import annotations - -from collections.abc import Mapping -from collections.abc import Mapping as _Mapping -from typing import Any, Self - - -class Code(str): - """BSON's JavaScript code type. - - Raises :class:`TypeError` if `code` is not an instance of - :class:`str` or `scope` is not ``None`` or an instance - of :class:`dict`. - - Scope variables can be set by passing a dictionary as the `scope` - argument or by using keyword arguments. If a variable is set as a - keyword argument it will override any setting for that variable in - the `scope` dictionary. - - :param code: A string containing JavaScript code to be evaluated or another - instance of Code. In the latter case, the scope of `code` becomes this - Code's :attr:`scope`. - :param scope: dictionary representing the scope in which - `code` should be evaluated - a mapping from identifiers (as - strings) to values. Defaults to ``None``. This is applied after any - scope associated with a given `code` above. - :param kwargs: scope variables can also be passed as - keyword arguments. These are applied after `scope` and `code`. - - .. versionchanged:: 3.4 - The default value for :attr:`scope` is ``None`` instead of ``{}``. - - """ - - _type_marker = 13 - __scope: Mapping[str, Any] | None - - def __new__( - cls, - code: str | Code, - scope: Mapping[str, Any] | None = None, - **kwargs: Any, - ) -> Self: - if not isinstance(code, str): - raise TypeError(f"code must be an instance of str, not {type(code)}") - - self = str.__new__(cls, code) - - try: - self.__scope = code.scope # type: ignore - except AttributeError: - self.__scope = None - - if scope is not None: - if not isinstance(scope, _Mapping): - raise TypeError(f"scope must be an instance of dict, not {type(scope)}") - if self.__scope is not None: - self.__scope.update(scope) # type: ignore - else: - self.__scope = scope - - if kwargs: - if self.__scope is not None: - self.__scope.update(kwargs) # type: ignore - else: - self.__scope = kwargs - - return self - - @property - def scope(self) -> Mapping[str, Any] | None: - """Scope dictionary for this instance or ``None``.""" - return self.__scope - - def __repr__(self) -> str: - return f"Code({str.__repr__(self)}, {self.__scope!r})" - - def __eq__(self, other: object) -> bool: - if isinstance(other, Code): - return (self.__scope, str(self)) == (other.__scope, str(other)) - return False - - __hash__: Any = None - - def __ne__(self, other: object) -> bool: - return not self == other diff --git a/bson/codec_options.py b/bson/codec_options.py deleted file mode 100644 index 1727e2e094..0000000000 --- a/bson/codec_options.py +++ /dev/null @@ -1,490 +0,0 @@ -# Copyright 2014-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Tools for specifying BSON codec options.""" - -from __future__ import annotations - -import abc -import datetime -import enum -from collections.abc import Callable, Iterable, Mapping -from collections.abc import MutableMapping as _MutableMapping -from typing import ( - TYPE_CHECKING, - Any, - Generic, - NamedTuple, - Self, - cast, -) - -from bson.binary import ( - ALL_UUID_REPRESENTATIONS, - UUID_REPRESENTATION_NAMES, - UuidRepresentation, -) - -_RAW_BSON_DOCUMENT_MARKER = 101 - -# Raw BSON documents at least this many bytes are exposed as read-only -# memoryview slices of the decode buffer instead of bytes copies. -_RAW_BSON_VIEW_THRESHOLD = 4096 - - -def _raw_document_class(document_class: Any) -> bool: - """Determine if a document_class is a RawBSONDocument class.""" - marker = getattr(document_class, "_type_marker", None) - return marker == _RAW_BSON_DOCUMENT_MARKER - - -class TypeEncoder(abc.ABC): - """Base class for defining type codec classes which describe how a - custom type can be transformed to one of the types BSON understands. - - Codec classes must implement the ``python_type`` attribute, and the - ``transform_python`` method to support encoding. - - See `encode data with type codecs `_ documentation for an example. - """ - - @abc.abstractproperty - def python_type(self) -> Any: - """The Python type to be converted into something serializable.""" - - @abc.abstractmethod - def transform_python(self, value: Any) -> Any: - """Convert the given Python object into something serializable.""" - - -class TypeDecoder(abc.ABC): - """Base class for defining type codec classes which describe how a - BSON type can be transformed to a custom type. - - Codec classes must implement the ``bson_type`` attribute, and the - ``transform_bson`` method to support decoding. - - See `encode data with type codecs `_ documentation for an example. - """ - - @abc.abstractproperty - def bson_type(self) -> Any: - """The BSON type to be converted into our own type.""" - - @abc.abstractmethod - def transform_bson(self, value: Any) -> Any: - """Convert the given BSON value into our own type.""" - - -class TypeCodec(TypeEncoder, TypeDecoder): - """Base class for defining type codec classes which describe how a - custom type can be transformed to/from one of the types :mod:`bson` - can already encode/decode. - - Codec classes must implement the ``python_type`` attribute, and the - ``transform_python`` method to support encoding, as well as the - ``bson_type`` attribute, and the ``transform_bson`` method to support - decoding. - - See `encode data with type codecs `_ documentation for an example. - """ - - -_Codec = TypeEncoder | TypeDecoder | TypeCodec -_Fallback = Callable[[Any], Any] - - -class TypeRegistry: - """Encapsulates type codecs used in encoding and / or decoding BSON, as - well as the fallback encoder. Type registries cannot be modified after - instantiation. - - ``TypeRegistry`` can be initialized with an iterable of type codecs, and - a callable for the fallback encoder:: - - >>> from bson.codec_options import TypeRegistry - >>> type_registry = TypeRegistry([Codec1, Codec2, Codec3, ...], - ... fallback_encoder) - - See `add codec to the type registry `_ documentation for an example. - - :param type_codecs: iterable of type codec instances. If - ``type_codecs`` contains multiple codecs that transform a single - python or BSON type, the transformation specified by the type codec - occurring last prevails. A TypeError will be raised if one or more - type codecs modify the encoding behavior of a built-in :mod:`bson` - type. - :param fallback_encoder: callable that accepts a single, - unencodable python value and transforms it into a type that - :mod:`bson` can encode. See `define a fallback encoder `_ - documentation for an example. - """ - - def __init__( - self, - type_codecs: Iterable[_Codec] | None = None, - fallback_encoder: _Fallback | None = None, - ) -> None: - self.__type_codecs = list(type_codecs or []) - self._fallback_encoder = fallback_encoder - self._encoder_map: dict[Any, Any] = {} - self._decoder_map: dict[Any, Any] = {} - - if self._fallback_encoder is not None: - if not callable(fallback_encoder): - raise TypeError(f"fallback_encoder {fallback_encoder!r} is not a callable") - - for codec in self.__type_codecs: - is_valid_codec = False - if isinstance(codec, TypeEncoder): - self._validate_type_encoder(codec) - is_valid_codec = True - self._encoder_map[codec.python_type] = codec.transform_python - if isinstance(codec, TypeDecoder): - is_valid_codec = True - self._decoder_map[codec.bson_type] = codec.transform_bson - if not is_valid_codec: - raise TypeError( - f"Expected an instance of {TypeEncoder.__name__}, {TypeDecoder.__name__}, or {TypeCodec.__name__}, got {codec!r} instead" - ) - - @property - def codecs(self) -> list[TypeEncoder | TypeDecoder | TypeCodec]: - """The list of type codecs in this registry.""" - return self.__type_codecs - - @property - def fallback_encoder(self) -> _Fallback | None: - """The fallback encoder in this registry.""" - return self._fallback_encoder - - def _validate_type_encoder(self, codec: _Codec) -> None: - from bson import _BUILT_IN_TYPES - - for pytype in _BUILT_IN_TYPES: - if issubclass(cast("TypeCodec", codec).python_type, pytype): - err_msg = ( - "TypeEncoders cannot change how built-in types are " - f"encoded (encoder {codec} transforms type {pytype})" - ) - raise TypeError(err_msg) - - def __repr__(self) -> str: - return f"{self.__class__.__name__}(type_codecs={self.__type_codecs!r}, fallback_encoder={self._fallback_encoder!r})" - - def __eq__(self, other: object) -> Any: - if not isinstance(other, type(self)): - return NotImplemented - return ( - (self._decoder_map == other._decoder_map) - and (self._encoder_map == other._encoder_map) - and (self._fallback_encoder == other._fallback_encoder) - ) - - __hash__ = None # type: ignore[assignment] - - -class DatetimeConversion(int, enum.Enum): - """Options for decoding BSON datetimes.""" - - DATETIME = 1 - """Decode a BSON UTC datetime as a :class:`datetime.datetime`. - - BSON UTC datetimes that cannot be represented as a - :class:`~datetime.datetime` will raise an :class:`OverflowError` - or a :class:`ValueError`. - - .. versionadded 4.3 - """ - - DATETIME_CLAMP = 2 - """Decode a BSON UTC datetime as a :class:`datetime.datetime`, clamping - to :attr:`~datetime.datetime.min` and :attr:`~datetime.datetime.max`. - - .. versionadded 4.3 - """ - - DATETIME_MS = 3 - """Decode a BSON UTC datetime as a :class:`~bson.datetime_ms.DatetimeMS` - object. - - .. versionadded 4.3 - """ - - DATETIME_AUTO = 4 - """Decode a BSON UTC datetime as a :class:`datetime.datetime` if possible, - and a :class:`~bson.datetime_ms.DatetimeMS` if not. - - .. versionadded 4.3 - """ - - -class _BaseCodecOptions(NamedTuple): - document_class: type[Mapping[str, Any]] - tz_aware: bool - uuid_representation: int - unicode_decode_error_handler: str - tzinfo: datetime.tzinfo | None - type_registry: TypeRegistry - datetime_conversion: DatetimeConversion | None - - -if TYPE_CHECKING: - from bson.typings import _DocumentType - - class CodecOptions(tuple[_DocumentType], Generic[_DocumentType]): - document_class: type[_DocumentType] - tz_aware: bool - uuid_representation: int - unicode_decode_error_handler: str | None - tzinfo: datetime.tzinfo | None - type_registry: TypeRegistry - datetime_conversion: int | None - - def __new__( - cls: type[CodecOptions[_DocumentType]], - document_class: type[_DocumentType] | None = ..., - tz_aware: bool = ..., - uuid_representation: int | None = ..., - unicode_decode_error_handler: str | None = ..., - tzinfo: datetime.tzinfo | None = ..., - type_registry: TypeRegistry | None = ..., - datetime_conversion: int | None = ..., - ) -> CodecOptions[_DocumentType]: ... - - # CodecOptions API - def with_options(self, **kwargs: Any) -> CodecOptions[Any]: ... - - def _arguments_repr(self) -> str: ... - - # NamedTuple API - @classmethod - def _make(cls, obj: Iterable[Any]) -> CodecOptions[_DocumentType]: ... - - def _asdict(self) -> dict[str, Any]: ... - - def _replace(self, **kwargs: Any) -> CodecOptions[_DocumentType]: ... - - _source: str - _fields: tuple[str] - -else: - - class CodecOptions(_BaseCodecOptions): - """Encapsulates options used encoding and / or decoding BSON.""" - - def __init__(self, *args, **kwargs): - """Encapsulates options used encoding and / or decoding BSON. - - The `document_class` option is used to define a custom type for use - decoding BSON documents. Access to the underlying raw BSON bytes for - a document is available using the :class:`~bson.raw_bson.RawBSONDocument` - type:: - - >>> from bson.raw_bson import RawBSONDocument - >>> from bson.codec_options import CodecOptions - >>> codec_options = CodecOptions(document_class=RawBSONDocument) - >>> coll = db.get_collection('test', codec_options=codec_options) - >>> doc = coll.find_one() - >>> doc.raw - '\\x16\\x00\\x00\\x00\\x07_id\\x00[0\\x165\\x91\\x10\\xea\\x14\\xe8\\xc5\\x8b\\x93\\x00' - - The document class can be any type that inherits from - :class:`~collections.abc.MutableMapping`:: - - >>> class AttributeDict(dict): - ... # A dict that supports attribute access. - ... def __getattr__(self, key): - ... return self[key] - ... def __setattr__(self, key, value): - ... self[key] = value - ... - >>> codec_options = CodecOptions(document_class=AttributeDict) - >>> coll = db.get_collection('test', codec_options=codec_options) - >>> doc = coll.find_one() - >>> doc._id - ObjectId('5b3016359110ea14e8c58b93') - - See `Dates and Times `_ for examples using the `tz_aware` and - `tzinfo` options. - - See `UUID `_ for examples using the `uuid_representation` - option. - - :param document_class: BSON documents returned in queries will be decoded - to an instance of this class. Must be a subclass of - :class:`~collections.abc.MutableMapping`. Defaults to :class:`dict`. - :param tz_aware: If ``True``, BSON datetimes will be decoded to timezone - aware instances of :class:`~datetime.datetime`. Otherwise they will be - naive. Defaults to ``False``. - :param uuid_representation: The BSON representation to use when encoding - and decoding instances of :class:`~uuid.UUID`. Defaults to - :data:`~bson.binary.UuidRepresentation.UNSPECIFIED`. New - applications should consider setting this to - :data:`~bson.binary.UuidRepresentation.STANDARD` for cross language - compatibility. See `UUID representations `_ for details. - :param unicode_decode_error_handler: The error handler to apply when - a Unicode-related error occurs during BSON decoding that would - otherwise raise :exc:`UnicodeDecodeError`. Valid options include - 'strict', 'replace', 'backslashreplace', 'surrogateescape', and - 'ignore'. Defaults to 'strict'. - :param tzinfo: A :class:`~datetime.tzinfo` subclass that specifies the - timezone to/from which :class:`~datetime.datetime` objects should be - encoded/decoded. - :param type_registry: Instance of :class:`TypeRegistry` used to customize - encoding and decoding behavior. - :param datetime_conversion: Specifies how UTC datetimes should be decoded - within BSON. Valid options include 'datetime_ms' to return as a - DatetimeMS, 'datetime' to return as a datetime.datetime and - raising a ValueError for out-of-range values, 'datetime_auto' to - return DatetimeMS objects when the underlying datetime is - out-of-range and 'datetime_clamp' to clamp to the minimum and - maximum possible datetimes. Defaults to 'datetime'. - - .. versionchanged:: 4.0 - The default for `uuid_representation` was changed from - :const:`~bson.binary.UuidRepresentation.PYTHON_LEGACY` to - :const:`~bson.binary.UuidRepresentation.UNSPECIFIED`. - - .. versionadded:: 3.8 - `type_registry` attribute. - - .. warning:: Care must be taken when changing - `unicode_decode_error_handler` from its default value ('strict'). - The 'replace' and 'ignore' modes should not be used when documents - retrieved from the server will be modified in the client application - and stored back to the server. - """ - super().__init__() - - def __new__( - cls, - document_class: type[Mapping[str, Any]] | None = None, - tz_aware: bool = False, - uuid_representation: int | None = UuidRepresentation.UNSPECIFIED, - unicode_decode_error_handler: str = "strict", - tzinfo: datetime.tzinfo | None = None, - type_registry: TypeRegistry | None = None, - datetime_conversion: DatetimeConversion | None = DatetimeConversion.DATETIME, - ) -> Self: - doc_class = document_class or dict - # Generic aliases like SON[str, Any] or dict[str, Any] aren't classes, so - # resolve to their origin before the subclass check. issubclass() raises - # TypeError for such aliases, so check the origin proactively instead of - # relying on catching the error. - check_class = getattr(doc_class, "__origin__", doc_class) - try: - is_mapping = issubclass(check_class, _MutableMapping) - except TypeError: - is_mapping = False - if not (is_mapping or _raw_document_class(doc_class)): - raise TypeError( - "document_class must be dict, bson.son.SON, " - "bson.raw_bson.RawBSONDocument, or a " - "subclass of collections.abc.MutableMapping" - ) - if not isinstance(tz_aware, bool): - raise TypeError(f"tz_aware must be True or False, was: tz_aware={tz_aware}") - if uuid_representation not in ALL_UUID_REPRESENTATIONS: - raise ValueError( - "uuid_representation must be a value from bson.binary.UuidRepresentation" - ) - if not isinstance(unicode_decode_error_handler, str): - raise TypeError( - f"unicode_decode_error_handler must be a string, not {type(unicode_decode_error_handler)}" - ) - if tzinfo is not None: - if not isinstance(tzinfo, datetime.tzinfo): - raise TypeError( - f"tzinfo must be an instance of datetime.tzinfo, not {type(tzinfo)}" - ) - if not tz_aware: - raise ValueError("cannot specify tzinfo without also setting tz_aware=True") - - type_registry = type_registry or TypeRegistry() - - if not isinstance(type_registry, TypeRegistry): - raise TypeError( - f"type_registry must be an instance of TypeRegistry, not {type(type_registry)}" - ) - - return tuple.__new__( - cls, - ( - doc_class, - tz_aware, - uuid_representation, - unicode_decode_error_handler, - tzinfo, - type_registry, - datetime_conversion, - ), - ) - - def _arguments_repr(self) -> str: - """Representation of the arguments used to create this object.""" - document_class_repr = ( - "dict" if self.document_class is dict else repr(self.document_class) - ) - - uuid_rep_repr = UUID_REPRESENTATION_NAMES.get( - self.uuid_representation, self.uuid_representation - ) - - return ( - f"document_class={document_class_repr}, tz_aware={self.tz_aware!r}, uuid_representation={uuid_rep_repr}, " - f"unicode_decode_error_handler={self.unicode_decode_error_handler!r}, tzinfo={self.tzinfo!r}, " - f"type_registry={self.type_registry!r}, datetime_conversion={self.datetime_conversion!s}" - ) - - def __repr__(self) -> str: - return f"{self.__class__.__name__}({self._arguments_repr()})" - - def with_options(self, **kwargs: Any) -> CodecOptions: - """Make a copy of this CodecOptions, overriding some options:: - - >>> from bson.codec_options import DEFAULT_CODEC_OPTIONS - >>> DEFAULT_CODEC_OPTIONS.tz_aware - False - >>> options = DEFAULT_CODEC_OPTIONS.with_options(tz_aware=True) - >>> options.tz_aware - True - - .. versionadded:: 3.5 - """ - opts = self._asdict() - opts.update(kwargs) - return CodecOptions(**opts) - - -DEFAULT_CODEC_OPTIONS: CodecOptions[dict[str, Any]] = CodecOptions() - - -def _parse_codec_options(options: Any) -> CodecOptions[Any]: - """Parse BSON codec options.""" - kwargs = {} - for k in set(options) & { - "document_class", - "tz_aware", - "uuidrepresentation", - "unicode_decode_error_handler", - "tzinfo", - "type_registry", - "datetime_conversion", - }: - if k == "uuidrepresentation": - kwargs["uuid_representation"] = options[k] - else: - kwargs[k] = options[k] - return CodecOptions(**kwargs) diff --git a/bson/datetime_ms.py b/bson/datetime_ms.py deleted file mode 100644 index d659323717..0000000000 --- a/bson/datetime_ms.py +++ /dev/null @@ -1,181 +0,0 @@ -# Copyright 2022-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you -# may not use this file except in compliance with the License. You -# may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. See the License for the specific language governing -# permissions and limitations under the License. - -"""Tools for representing the BSON datetime type. - -.. versionadded:: 4.3 -""" - -from __future__ import annotations - -import calendar -import datetime -from typing import Any, cast - -from bson.codec_options import DEFAULT_CODEC_OPTIONS, CodecOptions, DatetimeConversion -from bson.errors import InvalidBSON -from bson.tz_util import utc - -EPOCH_AWARE = datetime.datetime.fromtimestamp(0, utc) -EPOCH_NAIVE = EPOCH_AWARE.replace(tzinfo=None) -_DATETIME_ERROR_SUGGESTION = ( - "(Consider Using CodecOptions(datetime_conversion=DATETIME_AUTO)" - " or MongoClient(datetime_conversion='DATETIME_AUTO'))." - " See: https://www.mongodb.com/docs/languages/python/pymongo-driver/current/data-formats/dates-and-times/#handling-out-of-range-datetimes" -) - - -class DatetimeMS: - """Represents a BSON UTC datetime.""" - - __slots__ = ("_value",) - - def __init__(self, value: int | datetime.datetime): - """Represents a BSON UTC datetime. - - BSON UTC datetimes are defined as an int64 of milliseconds since the - Unix epoch. The principal use of DatetimeMS is to represent - datetimes outside the range of the Python builtin - :class:`~datetime.datetime` class when - encoding/decoding BSON. - - To decode UTC datetimes as a ``DatetimeMS``, `datetime_conversion` in - :class:`~bson.codec_options.CodecOptions` must be set to 'datetime_ms' or - 'datetime_auto'. See `handling out of range datetimes `_ for - details. - - :param value: An instance of :class:`datetime.datetime` to be - represented as milliseconds since the Unix epoch, or int of - milliseconds since the Unix epoch. - """ - if isinstance(value, int): - if not (-(2**63) <= value <= 2**63 - 1): - raise OverflowError("Must be a 64-bit integer of milliseconds") - self._value = value - elif isinstance(value, datetime.datetime): - self._value = _datetime_to_millis(value) - else: - raise TypeError(f"{type(value)} is not a valid type for DatetimeMS") - - def __hash__(self) -> int: - return hash(self._value) - - def __repr__(self) -> str: - return type(self).__name__ + "(" + str(self._value) + ")" - - def __lt__(self, other: DatetimeMS | int) -> bool: - return self._value < other - - def __le__(self, other: DatetimeMS | int) -> bool: - return self._value <= other - - def __eq__(self, other: object) -> bool: - if isinstance(other, DatetimeMS): - return self._value == other._value - return False - - def __ne__(self, other: object) -> bool: - if isinstance(other, DatetimeMS): - return self._value != other._value - return True - - def __gt__(self, other: DatetimeMS | int) -> bool: - return self._value > other - - def __ge__(self, other: DatetimeMS | int) -> bool: - return self._value >= other - - _type_marker = 9 - - def as_datetime( - self, codec_options: CodecOptions[Any] = DEFAULT_CODEC_OPTIONS - ) -> datetime.datetime: - """Create a Python :class:`~datetime.datetime` from this DatetimeMS object. - - :param codec_options: A CodecOptions instance for specifying how the - resulting DatetimeMS object will be formatted using ``tz_aware`` - and ``tz_info``. Defaults to - :const:`~bson.codec_options.DEFAULT_CODEC_OPTIONS`. - """ - return cast("datetime.datetime", _millis_to_datetime(self._value, codec_options)) - - def __int__(self) -> int: - return self._value - - -def _datetime_to_millis(dtm: datetime.datetime) -> int: - """Convert datetime to milliseconds since epoch UTC.""" - if dtm.utcoffset() is not None: - dtm = dtm - dtm.utcoffset() # type: ignore - return int(calendar.timegm(dtm.timetuple()) * 1000 + dtm.microsecond // 1000) - - -_MIN_UTC = datetime.datetime.min.replace(tzinfo=utc) -_MAX_UTC = datetime.datetime.max.replace(tzinfo=utc) -_MIN_UTC_MS = _datetime_to_millis(_MIN_UTC) -_MAX_UTC_MS = _datetime_to_millis(_MAX_UTC) - - -# Inclusive min and max for timezones. -def _min_datetime_ms(tz: datetime.tzinfo = utc) -> int: - delta = tz.utcoffset(_MIN_UTC) - if delta is not None: - offset_millis = (delta.days * 86400 + delta.seconds) * 1000 + delta.microseconds // 1000 - else: - offset_millis = 0 - return max(_MIN_UTC_MS, _MIN_UTC_MS - offset_millis) - - -def _max_datetime_ms(tz: datetime.tzinfo = utc) -> int: - delta = tz.utcoffset(_MAX_UTC) - if delta is not None: - offset_millis = (delta.days * 86400 + delta.seconds) * 1000 + delta.microseconds // 1000 - else: - offset_millis = 0 - return min(_MAX_UTC_MS, _MAX_UTC_MS - offset_millis) - - -def _millis_to_datetime(millis: int, opts: CodecOptions[Any]) -> datetime.datetime | DatetimeMS: - """Convert milliseconds since epoch UTC to datetime.""" - if ( - opts.datetime_conversion == DatetimeConversion.DATETIME - or opts.datetime_conversion == DatetimeConversion.DATETIME_CLAMP - or opts.datetime_conversion == DatetimeConversion.DATETIME_AUTO - ): - tz = opts.tzinfo or utc - if opts.datetime_conversion == DatetimeConversion.DATETIME_CLAMP: - millis = max(_min_datetime_ms(tz), min(millis, _max_datetime_ms(tz))) - elif opts.datetime_conversion == DatetimeConversion.DATETIME_AUTO: - if not (_min_datetime_ms(tz) <= millis <= _max_datetime_ms(tz)): - return DatetimeMS(millis) - - diff = ((millis % 1000) + 1000) % 1000 - seconds = (millis - diff) // 1000 - micros = diff * 1000 - - try: - if opts.tz_aware: - dt = EPOCH_AWARE + datetime.timedelta(seconds=seconds, microseconds=micros) - if opts.tzinfo: - dt = dt.astimezone(tz) - return dt - else: - return EPOCH_NAIVE + datetime.timedelta(seconds=seconds, microseconds=micros) - except ArithmeticError as err: - raise InvalidBSON(f"{err} {_DATETIME_ERROR_SUGGESTION}") from err - - elif opts.datetime_conversion == DatetimeConversion.DATETIME_MS: - return DatetimeMS(millis) - else: - raise ValueError("datetime_conversion must be an element of DatetimeConversion") diff --git a/bson/dbref.py b/bson/dbref.py deleted file mode 100644 index 90f0d7d733..0000000000 --- a/bson/dbref.py +++ /dev/null @@ -1,137 +0,0 @@ -# Copyright 2009-2015 MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Tools for manipulating DBRefs (references to MongoDB documents).""" - -from __future__ import annotations - -from copy import deepcopy -from typing import TYPE_CHECKING, Any - -from bson._helpers import _getstate_slots, _setstate_slots -from bson.son import SON - -if TYPE_CHECKING: - from collections.abc import Mapping - - -class DBRef: - """A reference to a document stored in MongoDB.""" - - __slots__ = "__collection", "__database", "__id", "__kwargs" - __getstate__ = _getstate_slots - __setstate__ = _setstate_slots - # DBRef isn't actually a BSON "type" so this number was arbitrarily chosen. - _type_marker = 100 - - def __init__( - self, - collection: str, - id: Any, - database: str | None = None, - _extra: Mapping[str, Any] | None = None, - **kwargs: Any, - ) -> None: - """Initialize a new :class:`DBRef`. - - Raises :class:`TypeError` if `collection` or `database` is not - an instance of :class:`str`. `database` is optional and allows - references to documents to work across databases. Any additional - keyword arguments will create additional fields in the resultant - embedded document. - - :param collection: name of the collection the document is stored in - :param id: the value of the document's ``"_id"`` field - :param database: name of the database to reference - :param kwargs: additional keyword arguments will - create additional, custom fields - - .. seealso:: The MongoDB documentation on `dbrefs `_. - """ - if not isinstance(collection, str): - raise TypeError(f"collection must be an instance of str, not {type(collection)}") - if database is not None and not isinstance(database, str): - raise TypeError(f"database must be an instance of str, not {type(database)}") - - self.__collection = collection - self.__id = id - self.__database = database - kwargs.update(_extra or {}) - self.__kwargs = kwargs - - @property - def collection(self) -> str: - """Get the name of this DBRef's collection.""" - return self.__collection - - @property - def id(self) -> Any: - """Get this DBRef's _id.""" - return self.__id - - @property - def database(self) -> str | None: - """Get the name of this DBRef's database. - - Returns None if this DBRef doesn't specify a database. - """ - return self.__database - - def __getattr__(self, key: Any) -> Any: - try: - return self.__kwargs[key] - except KeyError: - raise AttributeError(key) from None - - def as_doc(self) -> SON[str, Any]: - """Get the SON document representation of this DBRef. - - Generally not needed by application developers - """ - doc = SON([("$ref", self.collection), ("$id", self.id)]) - if self.database is not None: - doc["$db"] = self.database - doc.update(self.__kwargs) - return doc - - def __repr__(self) -> str: - extra = "".join([f", {k}={v!r}" for k, v in self.__kwargs.items()]) - if self.database is None: - return f"DBRef({self.collection!r}, {self.id!r}{extra})" - return f"DBRef({self.collection!r}, {self.id!r}, {self.database!r}{extra})" - - def __eq__(self, other: object) -> bool: - if isinstance(other, DBRef): - us = (self.__database, self.__collection, self.__id, self.__kwargs) - them = (other.__database, other.__collection, other.__id, other.__kwargs) - return us == them - return NotImplemented - - def __ne__(self, other: object) -> bool: - return not self == other - - def __hash__(self) -> int: - """Get a hash value for this :class:`DBRef`.""" - return hash( - (self.__collection, self.__id, self.__database, tuple(sorted(self.__kwargs.items()))) - ) - - def __deepcopy__(self, memo: Any) -> DBRef: - """Support function for `copy.deepcopy()`.""" - return DBRef( - deepcopy(self.__collection, memo), - deepcopy(self.__id, memo), - deepcopy(self.__database, memo), - deepcopy(self.__kwargs, memo), - ) diff --git a/bson/decimal128.py b/bson/decimal128.py deleted file mode 100644 index 1e62d1767b..0000000000 --- a/bson/decimal128.py +++ /dev/null @@ -1,361 +0,0 @@ -# Copyright 2016-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Tools for working with the BSON decimal128 type. - -.. versionadded:: 3.4 -""" - -from __future__ import annotations - -import decimal -import struct -from collections.abc import Sequence -from decimal import Decimal -from typing import Any - -from bson.codec_options import TypeDecoder, TypeEncoder - -_PACK_64 = struct.Struct(" type[Decimal]: - return Decimal - - def transform_python(self, value: Any) -> Decimal128: - return Decimal128(value) - - -class DecimalDecoder(TypeDecoder): - """Converts BSON :class:`Decimal128` to Python :class:`decimal.Decimal`. - - For example:: - opts = CodecOptions(type_registry=TypeRegistry([DecimalDecoder()])) - bson.decode(data, codec_options=opts) - - .. versionadded:: 4.15 - """ - - @property - def bson_type(self) -> type[Decimal128]: - return Decimal128 - - def transform_bson(self, value: Any) -> decimal.Decimal: - return value.to_decimal() - - -def create_decimal128_context() -> decimal.Context: - """Returns an instance of :class:`decimal.Context` appropriate - for working with IEEE-754 128-bit decimal floating point values. - """ - opts = _CTX_OPTIONS.copy() - opts["traps"] = [] - return decimal.Context(**opts) # type: ignore - - -def _decimal_to_128(value: _VALUE_OPTIONS) -> tuple[int, int]: - """Converts a decimal.Decimal to BID (high bits, low bits). - - :param value: An instance of decimal.Decimal - """ - with decimal.localcontext(_DEC128_CTX) as ctx: - value = ctx.create_decimal(value) - - if value.is_infinite(): - return _NINF if value.is_signed() else _PINF - - sign, digits, exponent = value.as_tuple() - - if value.is_nan(): - if digits: - raise ValueError("NaN with debug payload is not supported") - if value.is_snan(): - return _NSNAN if value.is_signed() else _PSNAN - return _NNAN if value.is_signed() else _PNAN - - significand = int("".join([str(digit) for digit in digits])) - bit_length = significand.bit_length() - - high = 0 - low = 0 - for i in range(min(64, bit_length)): - if significand & (1 << i): - low |= 1 << i - - for i in range(64, bit_length): - if significand & (1 << i): - high |= 1 << (i - 64) - - biased_exponent = exponent + _EXPONENT_BIAS # type: ignore[operator] - - if high >> 49 == 1: - high = high & 0x7FFFFFFFFFFF - high |= _EXPONENT_MASK - high |= (biased_exponent & 0x3FFF) << 47 - else: - high |= biased_exponent << 49 - - if sign: - high |= _SIGN - - return high, low - - -class Decimal128: - """BSON Decimal128 type:: - - >>> Decimal128(Decimal("0.0005")) - Decimal128('0.0005') - >>> Decimal128("0.0005") - Decimal128('0.0005') - >>> Decimal128((3474527112516337664, 5)) - Decimal128('0.0005') - - :param value: An instance of :class:`decimal.Decimal`, string, or tuple of - (high bits, low bits) from Binary Integer Decimal (BID) format. - - .. note:: :class:`~Decimal128` uses an instance of :class:`decimal.Context` - configured for IEEE-754 Decimal128 when validating parameters. - Signals like :class:`decimal.InvalidOperation`, :class:`decimal.Inexact`, - and :class:`decimal.Overflow` are trapped and raised as exceptions:: - - >>> Decimal128(".13.1") - Traceback (most recent call last): - File "", line 1, in - ... - decimal.InvalidOperation: [] - >>> - >>> Decimal128("1E-6177") - Traceback (most recent call last): - File "", line 1, in - ... - decimal.Inexact: [] - >>> - >>> Decimal128("1E6145") - Traceback (most recent call last): - File "", line 1, in - ... - decimal.Overflow: [, ] - - To ensure the result of a calculation can always be stored as BSON - Decimal128 use the context returned by - :func:`create_decimal128_context`:: - - >>> import decimal - >>> decimal128_ctx = create_decimal128_context() - >>> with decimal.localcontext(decimal128_ctx) as ctx: - ... Decimal128(ctx.create_decimal(".13.3")) - ... - Decimal128('NaN') - >>> - >>> with decimal.localcontext(decimal128_ctx) as ctx: - ... Decimal128(ctx.create_decimal("1E-6177")) - ... - Decimal128('0E-6176') - >>> - >>> with decimal.localcontext(DECIMAL128_CTX) as ctx: - ... Decimal128(ctx.create_decimal("1E6145")) - ... - Decimal128('Infinity') - - To match the behavior of MongoDB's Decimal128 implementation - str(Decimal(value)) may not match str(Decimal128(value)) for NaN values:: - - >>> Decimal128(Decimal('NaN')) - Decimal128('NaN') - >>> Decimal128(Decimal('-NaN')) - Decimal128('NaN') - >>> Decimal128(Decimal('sNaN')) - Decimal128('NaN') - >>> Decimal128(Decimal('-sNaN')) - Decimal128('NaN') - - However, :meth:`~Decimal128.to_decimal` will return the exact value:: - - >>> Decimal128(Decimal('NaN')).to_decimal() - Decimal('NaN') - >>> Decimal128(Decimal('-NaN')).to_decimal() - Decimal('-NaN') - >>> Decimal128(Decimal('sNaN')).to_decimal() - Decimal('sNaN') - >>> Decimal128(Decimal('-sNaN')).to_decimal() - Decimal('-sNaN') - - Two instances of :class:`Decimal128` compare equal if their Binary - Integer Decimal encodings are equal:: - - >>> Decimal128('NaN') == Decimal128('NaN') - True - >>> Decimal128('NaN').bid == Decimal128('NaN').bid - True - - This differs from :class:`decimal.Decimal` comparisons for NaN:: - - >>> Decimal('NaN') == Decimal('NaN') - False - """ - - __slots__ = ("__high", "__low") - - _type_marker = 19 - - def __init__(self, value: _VALUE_OPTIONS) -> None: - if isinstance(value, (str, decimal.Decimal)): - self.__high, self.__low = _decimal_to_128(value) - elif isinstance(value, (list, tuple)): - if len(value) != 2: - raise ValueError( - "Invalid size for creation of Decimal128 " - "from list or tuple. Must have exactly 2 " - "elements." - ) - self.__high, self.__low = value - else: - raise TypeError(f"Cannot convert {value!r} to Decimal128") - - def to_decimal(self) -> decimal.Decimal: - """Returns an instance of :class:`decimal.Decimal` for this - :class:`Decimal128`. - """ - high = self.__high - low = self.__low - sign = 1 if (high & _SIGN) else 0 - - if (high & _SNAN) == _SNAN: - return decimal.Decimal((sign, (), "N")) # type: ignore - elif (high & _NAN) == _NAN: - return decimal.Decimal((sign, (), "n")) # type: ignore - elif (high & _INF) == _INF: - return decimal.Decimal((sign, (), "F")) # type: ignore - - if (high & _EXPONENT_MASK) == _EXPONENT_MASK: - exponent = ((high & 0x1FFFE00000000000) >> 47) - _EXPONENT_BIAS - return decimal.Decimal((sign, (0,), exponent)) - else: - exponent = ((high & 0x7FFF800000000000) >> 49) - _EXPONENT_BIAS - - arr = bytearray(15) - mask = 0x00000000000000FF - for i in range(14, 6, -1): - arr[i] = (low & mask) >> ((14 - i) << 3) - mask = mask << 8 - - mask = 0x00000000000000FF - for i in range(6, 0, -1): - arr[i] = (high & mask) >> ((6 - i) << 3) - mask = mask << 8 - - mask = 0x0001000000000000 - arr[0] = (high & mask) >> 48 - - coefficient = int.from_bytes(arr, "big") - if coefficient > _MAX_COEFFICIENT: - # A significand of more than 34 digits is treated as 0. - return decimal.Decimal((sign, (0,), exponent)) - - # cdecimal only accepts a tuple for digits. - digits = tuple(int(digit) for digit in str(coefficient)) - - with decimal.localcontext(_DEC128_CTX) as ctx: - return ctx.create_decimal((sign, digits, exponent)) - - @classmethod - def from_bid(cls: type[Decimal128], value: bytes) -> Decimal128: - """Create an instance of :class:`Decimal128` from Binary Integer - Decimal string. - - :param value: 16 byte string (128-bit IEEE 754-2008 decimal floating - point in Binary Integer Decimal (BID) format). - """ - if not isinstance(value, bytes): - raise TypeError(f"value must be an instance of bytes, not {type(value)}") - if len(value) != 16: - raise ValueError("value must be exactly 16 bytes") - return cls((_UNPACK_64(value[8:])[0], _UNPACK_64(value[:8])[0])) # type: ignore - - @property - def bid(self) -> bytes: - """The Binary Integer Decimal (BID) encoding of this instance.""" - return _PACK_64(self.__low) + _PACK_64(self.__high) - - def __str__(self) -> str: - dec = self.to_decimal() - if dec.is_nan(): - # Required by the drivers spec to match MongoDB behavior. - return "NaN" - return str(dec) - - def __repr__(self) -> str: - return f"Decimal128('{self!s}')" - - def __setstate__(self, value: tuple[int, int]) -> None: - self.__high, self.__low = value - - def __getstate__(self) -> tuple[int, int]: - return self.__high, self.__low - - def __eq__(self, other: object) -> bool: - if isinstance(other, Decimal128): - return self.bid == other.bid - return NotImplemented - - __hash__ = None # type: ignore[assignment] - - def __ne__(self, other: object) -> bool: - return not self == other diff --git a/bson/errors.py b/bson/errors.py deleted file mode 100644 index 85fd3e2a6a..0000000000 --- a/bson/errors.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2009-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Exceptions raised by the BSON package.""" - -from __future__ import annotations - -from typing import Any - - -class BSONError(Exception): - """Base class for all BSON exceptions.""" - - -class InvalidBSON(BSONError): - """Raised when trying to create a BSON object from invalid data.""" - - -class InvalidStringData(BSONError): - """Raised when trying to encode a string containing non-UTF8 data.""" - - -class InvalidDocument(BSONError): - """Raised when trying to create a BSON object from an invalid document.""" - - def __init__(self, message: str, document: Any | None = None) -> None: - super().__init__(message) - self._document = document - - @property - def document(self) -> Any: - """The invalid document that caused the error. - - ..versionadded:: 4.16""" - return self._document - - -class InvalidId(BSONError): - """Raised when trying to create an ObjectId from invalid data.""" diff --git a/bson/int64.py b/bson/int64.py deleted file mode 100644 index a1a77b5b73..0000000000 --- a/bson/int64.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2014-2015 MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""A BSON wrapper for long (int in python3)""" - -from __future__ import annotations - -from typing import Any - - -class Int64(int): - """Representation of the BSON int64 type. - - This is necessary because every integral number is an :class:`int` in - Python 3. Small integral numbers are encoded to BSON int32 by default, - but Int64 numbers will always be encoded to BSON int64. - - :param value: the numeric value to represent - """ - - __slots__ = () - - _type_marker = 18 - - def __getstate__(self) -> Any: - return {} - - def __setstate__(self, state: Any) -> None: - pass diff --git a/bson/json_util.py b/bson/json_util.py deleted file mode 100644 index 98f4612683..0000000000 --- a/bson/json_util.py +++ /dev/null @@ -1,1148 +0,0 @@ -# Copyright 2009-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Tools for using Python's :mod:`json` module with BSON documents. - -This module provides two helper methods `dumps` and `loads` that wrap the -native :mod:`json` methods and provide explicit BSON conversion to and from -JSON. :class:`~bson.json_util.JSONOptions` provides a way to control how JSON -is emitted and parsed, with the default being the Relaxed Extended JSON format. -:mod:`~bson.json_util` can also generate Canonical or legacy `Extended JSON`_ -when :const:`CANONICAL_JSON_OPTIONS` or :const:`LEGACY_JSON_OPTIONS` is -provided, respectively. - -.. _Extended JSON: https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md - -Example usage (deserialization): - -.. doctest:: - - >>> from bson.json_util import loads - >>> loads( - ... '[{"foo": [1, 2]}, {"bar": {"hello": "world"}}, {"code": {"$scope": {}, "$code": "function x() { return 1; }"}}, {"bin": {"$type": "80", "$binary": "AQIDBA=="}}]' - ... ) - [{'foo': [1, 2]}, {'bar': {'hello': 'world'}}, {'code': Code('function x() { return 1; }', {})}, {'bin': Binary(b'...', 128)}] - -Example usage with :const:`RELAXED_JSON_OPTIONS` (the default): - -.. doctest:: - - >>> from bson import Binary, Code - >>> from bson.json_util import dumps - >>> dumps( - ... [ - ... {"foo": [1, 2]}, - ... {"bar": {"hello": "world"}}, - ... {"code": Code("function x() { return 1; }")}, - ... {"bin": Binary(b"\x01\x02\x03\x04")}, - ... ] - ... ) - '[{"foo": [1, 2]}, {"bar": {"hello": "world"}}, {"code": {"$code": "function x() { return 1; }"}}, {"bin": {"$binary": {"base64": "AQIDBA==", "subType": "00"}}}]' - -Example usage (with :const:`CANONICAL_JSON_OPTIONS`): - -.. doctest:: - - >>> from bson import Binary, Code - >>> from bson.json_util import dumps, CANONICAL_JSON_OPTIONS - >>> dumps( - ... [ - ... {"foo": [1, 2]}, - ... {"bar": {"hello": "world"}}, - ... {"code": Code("function x() { return 1; }")}, - ... {"bin": Binary(b"\x01\x02\x03\x04")}, - ... ], - ... json_options=CANONICAL_JSON_OPTIONS, - ... ) - '[{"foo": [{"$numberInt": "1"}, {"$numberInt": "2"}]}, {"bar": {"hello": "world"}}, {"code": {"$code": "function x() { return 1; }"}}, {"bin": {"$binary": {"base64": "AQIDBA==", "subType": "00"}}}]' - -Example usage (with :const:`LEGACY_JSON_OPTIONS`): - -.. doctest:: - - >>> from bson import Binary, Code - >>> from bson.json_util import dumps, LEGACY_JSON_OPTIONS - >>> dumps( - ... [ - ... {"foo": [1, 2]}, - ... {"bar": {"hello": "world"}}, - ... {"code": Code("function x() { return 1; }", {})}, - ... {"bin": Binary(b"\x01\x02\x03\x04")}, - ... ], - ... json_options=LEGACY_JSON_OPTIONS, - ... ) - '[{"foo": [1, 2]}, {"bar": {"hello": "world"}}, {"code": {"$code": "function x() { return 1; }", "$scope": {}}}, {"bin": {"$binary": "AQIDBA==", "$type": "00"}}]' - -Alternatively, you can manually pass the `default` to :func:`json.dumps`. -It won't handle :class:`~bson.binary.Binary` and :class:`~bson.code.Code` -instances (as they are extended strings you can't provide custom defaults), -but it will be faster as there is less recursion. - -.. note:: - If your application does not need the flexibility offered by - :class:`JSONOptions` and spends a large amount of time in the `json_util` - module, look to - `python-bsonjs `_ for a nice - performance improvement. `python-bsonjs` is a fast BSON to MongoDB - Extended JSON converter for Python built on top of - `libbson `_. `python-bsonjs` works best - with PyMongo when using :class:`~bson.raw_bson.RawBSONDocument`. Note that - `python-bsonjs` requires an exact :class:`bytes` instance, while - :attr:`~bson.raw_bson.RawBSONDocument.raw` may be a :class:`memoryview`, - so pass ``bytes(doc.raw)``. -""" - -from __future__ import annotations - -import base64 -import datetime -import json -import math -import re -import uuid -from collections.abc import Callable, Mapping, MutableMapping, Sequence -from typing import ( - TYPE_CHECKING, - Any, - Self, - cast, -) - -from bson.binary import ALL_UUID_SUBTYPES, UUID_SUBTYPE, Binary, UuidRepresentation -from bson.code import Code -from bson.codec_options import CodecOptions, DatetimeConversion -from bson.datetime_ms import ( - _MAX_UTC_MS, - EPOCH_AWARE, - DatetimeMS, - _datetime_to_millis, - _millis_to_datetime, -) -from bson.dbref import DBRef -from bson.decimal128 import Decimal128 -from bson.int64 import Int64 -from bson.max_key import MaxKey -from bson.min_key import MinKey -from bson.objectid import ObjectId -from bson.regex import Regex -from bson.son import RE_TYPE -from bson.timestamp import Timestamp -from bson.tz_util import utc - -_RE_OPT_TABLE = { - "i": re.IGNORECASE, - "l": re.LOCALE, - "m": re.MULTILINE, - "s": re.DOTALL, - "u": re.UNICODE, - "x": re.VERBOSE, -} - - -class DatetimeRepresentation: - LEGACY = 0 - """Legacy MongoDB Extended JSON datetime representation. - - :class:`datetime.datetime` instances will be encoded to JSON in the - format `{"$date": }`, where `dateAsMilliseconds` is - a 64-bit signed integer giving the number of milliseconds since the Unix - epoch UTC. This was the default encoding before PyMongo version 3.4. - - .. versionadded:: 3.4 - """ - - NUMBERLONG = 1 - """NumberLong datetime representation. - - :class:`datetime.datetime` instances will be encoded to JSON in the - format `{"$date": {"$numberLong": ""}}`, - where `dateAsMilliseconds` is the string representation of a 64-bit signed - integer giving the number of milliseconds since the Unix epoch UTC. - - .. versionadded:: 3.4 - """ - - ISO8601 = 2 - """ISO-8601 datetime representation. - - :class:`datetime.datetime` instances greater than or equal to the Unix - epoch UTC will be encoded to JSON in the format `{"$date": ""}`. - :class:`datetime.datetime` instances before the Unix epoch UTC will be - encoded as if the datetime representation is - :const:`~DatetimeRepresentation.NUMBERLONG`. - - .. versionadded:: 3.4 - """ - - -class JSONMode: - LEGACY = 0 - """Legacy Extended JSON representation. - - In this mode, :func:`~bson.json_util.dumps` produces PyMongo's legacy - non-standard JSON output. Consider using - :const:`~bson.json_util.JSONMode.RELAXED` or - :const:`~bson.json_util.JSONMode.CANONICAL` instead. - - .. versionadded:: 3.5 - """ - - RELAXED = 1 - """Relaxed Extended JSON representation. - - In this mode, :func:`~bson.json_util.dumps` produces Relaxed Extended JSON, - a mostly JSON-like format. Consider using this for things like a web API, - where one is sending a document (or a projection of a document) that only - uses ordinary JSON type primitives. In particular, the ``int``, - :class:`~bson.int64.Int64`, and ``float`` numeric types are represented in - the native JSON number format. This output is also the most human readable - and is useful for debugging and documentation. - - .. seealso:: The specification for Relaxed `Extended JSON`_. - - .. versionadded:: 3.5 - """ - - CANONICAL = 2 - """Canonical Extended JSON representation. - - In this mode, :func:`~bson.json_util.dumps` produces Canonical Extended - JSON, a type preserving format. Consider using this for things like - testing, where one has to precisely specify expected types in JSON. In - particular, the ``int``, :class:`~bson.int64.Int64`, and ``float`` numeric - types are encoded with type wrappers. - - .. seealso:: The specification for Canonical `Extended JSON`_. - - .. versionadded:: 3.5 - """ - - -if TYPE_CHECKING: - _BASE_CLASS = CodecOptions[MutableMapping[str, Any]] -else: - _BASE_CLASS = CodecOptions - -_INT32_MAX = 2**31 - - -class JSONOptions(_BASE_CLASS): - json_mode: int - strict_number_long: bool - datetime_representation: int - strict_uuid: bool - document_class: type[MutableMapping[str, Any]] - - def __init__(self, *args: Any, **kwargs: Any): - """Encapsulates JSON options for :func:`dumps` and :func:`loads`. - - :param strict_number_long: If ``True``, :class:`~bson.int64.Int64` objects - are encoded to MongoDB Extended JSON's *Strict mode* type - `NumberLong`, ie ``'{"$numberLong": "" }'``. Otherwise they - will be encoded as an `int`. Defaults to ``False``. - :param datetime_representation: The representation to use when encoding - instances of :class:`datetime.datetime`. Defaults to - :const:`~DatetimeRepresentation.LEGACY`. - :param strict_uuid: If ``True``, :class:`uuid.UUID` object are encoded to - MongoDB Extended JSON's *Strict mode* type `Binary`. Otherwise it - will be encoded as ``'{"$uuid": "" }'``. Defaults to ``False``. - :param json_mode: The :class:`JSONMode` to use when encoding BSON types to - Extended JSON. Defaults to :const:`~JSONMode.LEGACY`. - :param document_class: BSON documents returned by :func:`loads` will be - decoded to an instance of this class. Must be a subclass of - :class:`collections.MutableMapping`. Defaults to :class:`dict`. - :param uuid_representation: The :class:`~bson.binary.UuidRepresentation` - to use when encoding and decoding instances of :class:`uuid.UUID`. - Defaults to :const:`~bson.binary.UuidRepresentation.UNSPECIFIED`. - :param tz_aware: If ``True``, MongoDB Extended JSON's *Strict mode* type - `Date` will be decoded to timezone aware instances of - :class:`datetime.datetime`. Otherwise they will be naive. Defaults - to ``False``. - :param tzinfo: A :class:`datetime.tzinfo` subclass that specifies the - timezone from which :class:`~datetime.datetime` objects should be - decoded. Defaults to :const:`~bson.tz_util.utc`. - :param datetime_conversion: Specifies how UTC datetimes should be decoded - within BSON. Valid options include 'datetime_ms' to return as a - DatetimeMS, 'datetime' to return as a datetime.datetime and - raising a ValueError for out-of-range values, 'datetime_auto' to - return DatetimeMS objects when the underlying datetime is - out-of-range and 'datetime_clamp' to clamp to the minimum and - maximum possible datetimes. Defaults to 'datetime'. See - `handling out of range datetimes `_ for details. - :param args: arguments to :class:`~bson.codec_options.CodecOptions` - :param kwargs: arguments to :class:`~bson.codec_options.CodecOptions` - - .. seealso:: The specification for Relaxed and Canonical `Extended JSON`_. - - .. versionchanged:: 4.0 - The default for `json_mode` was changed from :const:`JSONMode.LEGACY` - to :const:`JSONMode.RELAXED`. - The default for `uuid_representation` was changed from - :const:`~bson.binary.UuidRepresentation.PYTHON_LEGACY` to - :const:`~bson.binary.UuidRepresentation.UNSPECIFIED`. - - .. versionchanged:: 3.5 - Accepts the optional parameter `json_mode`. - - .. versionchanged:: 4.0 - Changed default value of `tz_aware` to False. - """ - super().__init__() - - def __new__( - cls, - strict_number_long: bool | None = None, - datetime_representation: int | None = None, - strict_uuid: bool | None = None, - json_mode: int = JSONMode.RELAXED, - *args: Any, - **kwargs: Any, - ) -> Self: - kwargs["tz_aware"] = kwargs.get("tz_aware", False) - if kwargs["tz_aware"]: - kwargs["tzinfo"] = kwargs.get("tzinfo", utc) - if datetime_representation not in ( - DatetimeRepresentation.LEGACY, - DatetimeRepresentation.NUMBERLONG, - DatetimeRepresentation.ISO8601, - None, - ): - raise ValueError( - "JSONOptions.datetime_representation must be one of LEGACY, " - "NUMBERLONG, or ISO8601 from DatetimeRepresentation." - ) - self = cast("Self", super().__new__(cls, *args, **kwargs)) - if json_mode not in (JSONMode.LEGACY, JSONMode.RELAXED, JSONMode.CANONICAL): - raise ValueError( - "JSONOptions.json_mode must be one of LEGACY, RELAXED, or CANONICAL from JSONMode." - ) - self.json_mode = json_mode - if self.json_mode == JSONMode.RELAXED: - if strict_number_long: - raise ValueError("Cannot specify strict_number_long=True with JSONMode.RELAXED") - if datetime_representation not in (None, DatetimeRepresentation.ISO8601): - raise ValueError( - "datetime_representation must be DatetimeRepresentation." - "ISO8601 or omitted with JSONMode.RELAXED" - ) - if strict_uuid not in (None, True): - raise ValueError("Cannot specify strict_uuid=False with JSONMode.RELAXED") - self.strict_number_long = False - self.datetime_representation = DatetimeRepresentation.ISO8601 - self.strict_uuid = True - elif self.json_mode == JSONMode.CANONICAL: - if strict_number_long not in (None, True): - raise ValueError("Cannot specify strict_number_long=False with JSONMode.RELAXED") - if datetime_representation not in (None, DatetimeRepresentation.NUMBERLONG): - raise ValueError( - "datetime_representation must be DatetimeRepresentation." - "NUMBERLONG or omitted with JSONMode.RELAXED" - ) - if strict_uuid not in (None, True): - raise ValueError("Cannot specify strict_uuid=False with JSONMode.RELAXED") - self.strict_number_long = True - self.datetime_representation = DatetimeRepresentation.NUMBERLONG - self.strict_uuid = True - else: # JSONMode.LEGACY - self.strict_number_long = False - self.datetime_representation = DatetimeRepresentation.LEGACY - self.strict_uuid = False - if strict_number_long is not None: - self.strict_number_long = strict_number_long - if datetime_representation is not None: - self.datetime_representation = datetime_representation - if strict_uuid is not None: - self.strict_uuid = strict_uuid - return self - - def _arguments_repr(self) -> str: - return ( - f"strict_number_long={self.strict_number_long!r}, " - f"datetime_representation={self.datetime_representation!r}, " - f"strict_uuid={self.strict_uuid!r}, json_mode={self.json_mode!r}, {super()._arguments_repr()}" - ) - - def with_options(self, **kwargs: Any) -> JSONOptions: - """ - Make a copy of this JSONOptions, overriding some options:: - - >>> from bson.json_util import CANONICAL_JSON_OPTIONS - >>> CANONICAL_JSON_OPTIONS.tz_aware - True - >>> json_options = CANONICAL_JSON_OPTIONS.with_options(tz_aware=False, tzinfo=None) - >>> json_options.tz_aware - False - - .. versionadded:: 3.12 - """ - opts = self._asdict() - for opt in ("strict_number_long", "datetime_representation", "strict_uuid", "json_mode"): - opts[opt] = kwargs.get(opt, getattr(self, opt)) - opts.update(kwargs) - return JSONOptions(**opts) - - -LEGACY_JSON_OPTIONS: JSONOptions = JSONOptions(json_mode=JSONMode.LEGACY) -""":class:`JSONOptions` for encoding to PyMongo's legacy JSON format. - -.. seealso:: The documentation for :const:`bson.json_util.JSONMode.LEGACY`. - -.. versionadded:: 3.5 -""" - -CANONICAL_JSON_OPTIONS: JSONOptions = JSONOptions(json_mode=JSONMode.CANONICAL) -""":class:`JSONOptions` for Canonical Extended JSON. - -.. seealso:: The documentation for :const:`bson.json_util.JSONMode.CANONICAL`. - -.. versionadded:: 3.5 -""" - -RELAXED_JSON_OPTIONS: JSONOptions = JSONOptions(json_mode=JSONMode.RELAXED) -""":class:`JSONOptions` for Relaxed Extended JSON. - -.. seealso:: The documentation for :const:`bson.json_util.JSONMode.RELAXED`. - -.. versionadded:: 3.5 -""" - -DEFAULT_JSON_OPTIONS: JSONOptions = RELAXED_JSON_OPTIONS -"""The default :class:`JSONOptions` for JSON encoding/decoding. - -The same as :const:`RELAXED_JSON_OPTIONS`. - -.. versionchanged:: 4.0 - Changed from :const:`LEGACY_JSON_OPTIONS` to - :const:`RELAXED_JSON_OPTIONS`. - -.. versionadded:: 3.4 -""" - - -def dumps(obj: Any, *args: Any, **kwargs: Any) -> str: - """Helper function that wraps :func:`json.dumps`. - - Recursive function that handles all BSON types including - :class:`~bson.binary.Binary` and :class:`~bson.code.Code`. - - :param json_options: A :class:`JSONOptions` instance used to modify the - encoding of MongoDB Extended JSON types. Defaults to - :const:`DEFAULT_JSON_OPTIONS`. - - .. versionchanged:: 4.0 - Now outputs MongoDB Relaxed Extended JSON by default (using - :const:`DEFAULT_JSON_OPTIONS`). - - .. versionchanged:: 3.4 - Accepts optional parameter `json_options`. See :class:`JSONOptions`. - """ - json_options = kwargs.pop("json_options", DEFAULT_JSON_OPTIONS) - return json.dumps(_json_convert(obj, json_options), *args, **kwargs) - - -def loads(s: str | bytes | bytearray, *args: Any, **kwargs: Any) -> Any: - """Helper function that wraps :func:`json.loads`. - - Automatically passes the object_hook for BSON type conversion. - - Raises ``TypeError``, ``ValueError``, ``KeyError``, or - :exc:`~bson.errors.InvalidId` on invalid MongoDB Extended JSON. - - :param json_options: A :class:`JSONOptions` instance used to modify the - decoding of MongoDB Extended JSON types. Defaults to - :const:`DEFAULT_JSON_OPTIONS`. - - .. versionchanged:: 4.0 - Now loads :class:`datetime.datetime` instances as naive by default. To - load timezone aware instances utilize the `json_options` parameter. - See :ref:`tz_aware_default_change` for an example. - - .. versionchanged:: 3.5 - Parses Relaxed and Canonical Extended JSON as well as PyMongo's legacy - format. Now raises ``TypeError`` or ``ValueError`` when parsing JSON - type wrappers with values of the wrong type or any extra keys. - - .. versionchanged:: 3.4 - Accepts optional parameter `json_options`. See :class:`JSONOptions`. - """ - json_options = kwargs.pop("json_options", DEFAULT_JSON_OPTIONS) - # Execution time optimization if json_options.document_class is dict - if json_options.document_class is dict: - kwargs["object_hook"] = lambda obj: object_hook(obj, json_options) - else: - kwargs["object_pairs_hook"] = lambda pairs: object_pairs_hook(pairs, json_options) - return json.loads(s, *args, **kwargs) - - -def _json_convert(obj: Any, json_options: JSONOptions = DEFAULT_JSON_OPTIONS) -> Any: - """Recursive helper method that converts BSON types so they can be - converted into json. - """ - if hasattr(obj, "items"): - return {k: _json_convert(v, json_options) for k, v in obj.items()} - elif hasattr(obj, "__iter__") and not isinstance(obj, (str, bytes)): - return [_json_convert(v, json_options) for v in obj] - try: - return default(obj, json_options) - except TypeError: - return obj - - -def object_pairs_hook( - pairs: Sequence[tuple[str, Any]], json_options: JSONOptions = DEFAULT_JSON_OPTIONS -) -> Any: - return object_hook(json_options.document_class(pairs), json_options) # type:ignore[call-arg] - - -def object_hook(dct: Mapping[str, Any], json_options: JSONOptions = DEFAULT_JSON_OPTIONS) -> Any: - match = None - for k in dct: - if k in _PARSERS_SET: - match = k - break - if match: - return _PARSERS[match](dct, json_options) - return dct - - -def _parse_legacy_regex(doc: Any, dummy0: Any) -> Any: - pattern = doc["$regex"] - # Check if this is the $regex query operator. - if not isinstance(pattern, (str, bytes)): - return doc - flags = 0 - # PyMongo always adds $options but some other tools may not. - for opt in doc.get("$options", ""): - flags |= _RE_OPT_TABLE.get(opt, 0) - return Regex(pattern, flags) - - -def _parse_legacy_uuid(doc: Any, json_options: JSONOptions) -> Binary | uuid.UUID: - """Decode a JSON legacy $uuid to Python UUID.""" - if len(doc) != 1: - raise TypeError(f"Bad $uuid, extra field(s): {doc}") - if not isinstance(doc["$uuid"], str): - raise TypeError(f"$uuid must be a string: {doc}") - if json_options.uuid_representation == UuidRepresentation.UNSPECIFIED: - return Binary.from_uuid(uuid.UUID(doc["$uuid"])) - else: - return uuid.UUID(doc["$uuid"]) - - -def _binary_or_uuid(data: Any, subtype: int, json_options: JSONOptions) -> Binary | uuid.UUID: - # special handling for UUID - if subtype in ALL_UUID_SUBTYPES: - uuid_representation = json_options.uuid_representation - binary_value = Binary(data, subtype) - if uuid_representation == UuidRepresentation.UNSPECIFIED: - return binary_value - if subtype == UUID_SUBTYPE: - # Legacy behavior: use STANDARD with binary subtype 4. - uuid_representation = UuidRepresentation.STANDARD - elif uuid_representation == UuidRepresentation.STANDARD: - # subtype == OLD_UUID_SUBTYPE - # Legacy behavior: STANDARD is the same as PYTHON_LEGACY. - uuid_representation = UuidRepresentation.PYTHON_LEGACY - return binary_value.as_uuid(uuid_representation) - - if subtype == 0: - return cast("uuid.UUID", data) - return Binary(data, subtype) - - -def _parse_legacy_binary(doc: Any, json_options: JSONOptions) -> Binary | uuid.UUID: - if isinstance(doc["$type"], int): - doc["$type"] = "{:02x}".format(doc["$type"]) - subtype = int(doc["$type"], 16) - if subtype >= 0xFFFFFF80: # Handle mongoexport values - subtype = int(doc["$type"][6:], 16) - data = base64.b64decode(doc["$binary"].encode()) - return _binary_or_uuid(data, subtype, json_options) - - -def _parse_canonical_binary(doc: Any, json_options: JSONOptions) -> Binary | uuid.UUID: - binary = doc["$binary"] - b64 = binary["base64"] - subtype = binary["subType"] - if not isinstance(b64, str): - raise TypeError(f"$binary base64 must be a string: {doc}") - if not isinstance(subtype, str) or len(subtype) > 2: - raise TypeError(f"$binary subType must be a string at most 2 characters: {doc}") - if len(binary) != 2: - raise TypeError(f'$binary must include only "base64" and "subType" components: {doc}') - - data = base64.b64decode(b64.encode()) - return _binary_or_uuid(data, int(subtype, 16), json_options) - - -def _parse_canonical_datetime( - doc: Any, json_options: JSONOptions -) -> datetime.datetime | DatetimeMS: - """Decode a JSON datetime to python datetime.datetime.""" - dtm = doc["$date"] - if len(doc) != 1: - raise TypeError(f"Bad $date, extra field(s): {doc}") - # mongoexport 2.6 and newer - if isinstance(dtm, str): - try: - # Parse offset - if dtm[-1] == "Z": - dt = dtm[:-1] - offset = "Z" - elif dtm[-6] in ("+", "-") and dtm[-3] == ":": - # (+|-)HH:MM - dt = dtm[:-6] - offset = dtm[-6:] - elif dtm[-5] in ("+", "-"): - # (+|-)HHMM - dt = dtm[:-5] - offset = dtm[-5:] - elif dtm[-3] in ("+", "-"): - # (+|-)HH - dt = dtm[:-3] - offset = dtm[-3:] - else: - dt = dtm - offset = "" - except IndexError as exc: - raise ValueError(f"time data {dtm!r} does not match ISO-8601 datetime format") from exc - - # Parse the optional factional seconds portion. - dot_index = dt.rfind(".") - microsecond = 0 - if dot_index != -1: - microsecond = int(float(dt[dot_index:]) * 1000000) - dt = dt[:dot_index] - - aware = datetime.datetime.strptime(dt, "%Y-%m-%dT%H:%M:%S").replace( - microsecond=microsecond, tzinfo=utc - ) - - if offset and offset != "Z": - if len(offset) == 6: - hours, minutes = offset[1:].split(":") - secs = int(hours) * 3600 + int(minutes) * 60 - elif len(offset) == 5: - secs = int(offset[1:3]) * 3600 + int(offset[3:]) * 60 - elif len(offset) == 3: - secs = int(offset[1:3]) * 3600 - if offset[0] == "-": - secs *= -1 - aware = aware - datetime.timedelta(seconds=secs) - - if json_options.tz_aware: - if json_options.tzinfo: - aware = aware.astimezone(json_options.tzinfo) - if json_options.datetime_conversion == DatetimeConversion.DATETIME_MS: - return DatetimeMS(aware) - return aware - else: - aware_tzinfo_none = aware.replace(tzinfo=None) - if json_options.datetime_conversion == DatetimeConversion.DATETIME_MS: - return DatetimeMS(aware_tzinfo_none) - return aware_tzinfo_none - return _millis_to_datetime(int(dtm), cast("CodecOptions[Any]", json_options)) - - -def _parse_canonical_oid(doc: Any, dummy0: Any) -> ObjectId: - """Decode a JSON ObjectId to bson.objectid.ObjectId.""" - if len(doc) != 1: - raise TypeError(f"Bad $oid, extra field(s): {doc}") - return ObjectId(doc["$oid"]) - - -def _parse_canonical_symbol(doc: Any, dummy0: Any) -> str: - """Decode a JSON symbol to Python string.""" - symbol = doc["$symbol"] - if len(doc) != 1: - raise TypeError(f"Bad $symbol, extra field(s): {doc}") - return str(symbol) - - -def _parse_canonical_code(doc: Any, dummy0: Any) -> Code: - """Decode a JSON code to bson.code.Code.""" - for key in doc: - if key not in ("$code", "$scope"): - raise TypeError(f"Bad $code, extra field(s): {doc}") - return Code(doc["$code"], scope=doc.get("$scope")) - - -def _parse_canonical_regex(doc: Any, dummy0: Any) -> Regex[str]: - """Decode a JSON regex to bson.regex.Regex.""" - regex = doc["$regularExpression"] - if len(doc) != 1: - raise TypeError(f"Bad $regularExpression, extra field(s): {doc}") - if len(regex) != 2: - raise TypeError( - f'Bad $regularExpression must include only "pattern and "options" components: {doc}' - ) - opts = regex["options"] - if not isinstance(opts, str): - raise TypeError( - f"Bad $regularExpression options, options must be string, was type {type(opts)}" - ) - return Regex(regex["pattern"], opts) - - -def _parse_canonical_dbref(doc: Any, dummy0: Any) -> Any: - """Decode a JSON DBRef to bson.dbref.DBRef.""" - if ( - isinstance(doc.get("$ref"), str) - and "$id" in doc - and isinstance(doc.get("$db"), (str, type(None))) - ): - return DBRef(doc.pop("$ref"), doc.pop("$id"), database=doc.pop("$db", None), **doc) - return doc - - -def _parse_canonical_dbpointer(doc: Any, dummy0: Any) -> Any: - """Decode a JSON (deprecated) DBPointer to bson.dbref.DBRef.""" - dbref = doc["$dbPointer"] - if len(doc) != 1: - raise TypeError(f"Bad $dbPointer, extra field(s): {doc}") - if isinstance(dbref, DBRef): - dbref_doc = dbref.as_doc() - # DBPointer must not contain $db in its value. - if dbref.database is not None: - raise TypeError(f"Bad $dbPointer, extra field $db: {dbref_doc}") - if not isinstance(dbref.id, ObjectId): - raise TypeError(f"Bad $dbPointer, $id must be an ObjectId: {dbref_doc}") - if len(dbref_doc) != 2: - raise TypeError(f"Bad $dbPointer, extra field(s) in DBRef: {dbref_doc}") - return dbref - else: - raise TypeError(f"Bad $dbPointer, expected a DBRef: {doc}") - - -def _parse_canonical_int32(doc: Any, dummy0: Any) -> int: - """Decode a JSON int32 to python int.""" - i_str = doc["$numberInt"] - if len(doc) != 1: - raise TypeError(f"Bad $numberInt, extra field(s): {doc}") - if not isinstance(i_str, str): - raise TypeError(f"$numberInt must be string: {doc}") - return int(i_str) - - -def _parse_canonical_int64(doc: Any, dummy0: Any) -> Int64: - """Decode a JSON int64 to bson.int64.Int64.""" - l_str = doc["$numberLong"] - if len(doc) != 1: - raise TypeError(f"Bad $numberLong, extra field(s): {doc}") - return Int64(l_str) - - -def _parse_canonical_double(doc: Any, dummy0: Any) -> float: - """Decode a JSON double to python float.""" - d_str = doc["$numberDouble"] - if len(doc) != 1: - raise TypeError(f"Bad $numberDouble, extra field(s): {doc}") - if not isinstance(d_str, str): - raise TypeError(f"$numberDouble must be string: {doc}") - return float(d_str) - - -def _parse_canonical_decimal128(doc: Any, dummy0: Any) -> Decimal128: - """Decode a JSON decimal128 to bson.decimal128.Decimal128.""" - d_str = doc["$numberDecimal"] - if len(doc) != 1: - raise TypeError(f"Bad $numberDecimal, extra field(s): {doc}") - if not isinstance(d_str, str): - raise TypeError(f"$numberDecimal must be string: {doc}") - return Decimal128(d_str) - - -def _parse_canonical_minkey(doc: Any, dummy0: Any) -> MinKey: - """Decode a JSON MinKey to bson.min_key.MinKey.""" - if type(doc["$minKey"]) is not int or doc["$minKey"] != 1: - raise TypeError(f"$minKey value must be 1: {doc}") - if len(doc) != 1: - raise TypeError(f"Bad $minKey, extra field(s): {doc}") - return MinKey() - - -def _parse_canonical_maxkey(doc: Any, dummy0: Any) -> MaxKey: - """Decode a JSON MaxKey to bson.max_key.MaxKey.""" - if type(doc["$maxKey"]) is not int or doc["$maxKey"] != 1: - raise TypeError("$maxKey value must be 1: %s", (doc,)) - if len(doc) != 1: - raise TypeError(f"Bad $minKey, extra field(s): {doc}") - return MaxKey() - - -def _parse_binary(doc: Any, json_options: JSONOptions) -> Binary | uuid.UUID: - if "$type" in doc: - return _parse_legacy_binary(doc, json_options) - else: - return _parse_canonical_binary(doc, json_options) - - -def _parse_timestamp(doc: Any, dummy0: Any) -> Timestamp: - if len(doc) != 1: - raise TypeError(f"Bad $timestamp, extra field(s): {doc}") - tsp = doc["$timestamp"] - if not isinstance(tsp, Mapping): - raise TypeError(f'$timestamp value must be a document with "t" and "i" components: {doc}') - if set(tsp) != {"t", "i"}: - raise TypeError(f'$timestamp must include exactly "t" and "i" components: {doc}') - return Timestamp(tsp["t"], tsp["i"]) - - -_PARSERS: dict[str, Callable[[Any, JSONOptions], Any]] = { - "$oid": _parse_canonical_oid, - "$ref": _parse_canonical_dbref, - "$date": _parse_canonical_datetime, - "$regex": _parse_legacy_regex, - "$minKey": _parse_canonical_minkey, - "$maxKey": _parse_canonical_maxkey, - "$binary": _parse_binary, - "$code": _parse_canonical_code, - "$uuid": _parse_legacy_uuid, - "$undefined": lambda _, _1: None, - "$numberLong": _parse_canonical_int64, - "$timestamp": _parse_timestamp, - "$numberDecimal": _parse_canonical_decimal128, - "$dbPointer": _parse_canonical_dbpointer, - "$regularExpression": _parse_canonical_regex, - "$symbol": _parse_canonical_symbol, - "$numberInt": _parse_canonical_int32, - "$numberDouble": _parse_canonical_double, -} -_PARSERS_SET = set(_PARSERS) - - -def _encode_binary(data: bytes, subtype: int, json_options: JSONOptions) -> Any: - if json_options.json_mode == JSONMode.LEGACY: - return {"$binary": base64.b64encode(data).decode(), "$type": f"{subtype:02x}"} - return {"$binary": {"base64": base64.b64encode(data).decode(), "subType": f"{subtype:02x}"}} - - -def _encode_datetimems(obj: Any, json_options: JSONOptions) -> dict: # type: ignore[type-arg] - if ( - json_options.datetime_representation == DatetimeRepresentation.ISO8601 - and 0 <= int(obj) <= _MAX_UTC_MS - ): - return _encode_datetime(obj.as_datetime(), json_options) - elif json_options.datetime_representation == DatetimeRepresentation.LEGACY: - return {"$date": int(obj)} - return {"$date": {"$numberLong": str(int(obj))}} - - -def _encode_code(obj: Code, json_options: JSONOptions) -> dict: # type: ignore[type-arg] - if obj.scope is None: - return {"$code": str(obj)} - else: - return {"$code": str(obj), "$scope": _json_convert(obj.scope, json_options)} - - -def _encode_int64(obj: Int64, json_options: JSONOptions) -> Any: - if json_options.strict_number_long: - return {"$numberLong": str(obj)} - else: - return int(obj) - - -def _encode_noop(obj: Any, dummy0: Any) -> Any: - return obj - - -def _encode_regex(obj: Any, json_options: JSONOptions) -> dict: # type: ignore[type-arg] - flags = "" - if obj.flags & re.IGNORECASE: - flags += "i" - if obj.flags & re.LOCALE: - flags += "l" - if obj.flags & re.MULTILINE: - flags += "m" - if obj.flags & re.DOTALL: - flags += "s" - if obj.flags & re.UNICODE: - flags += "u" - if obj.flags & re.VERBOSE: - flags += "x" - if isinstance(obj.pattern, str): - pattern = obj.pattern - else: - pattern = obj.pattern.decode("utf-8") - if json_options.json_mode == JSONMode.LEGACY: - return {"$regex": pattern, "$options": flags} - return {"$regularExpression": {"pattern": pattern, "options": flags}} - - -def _encode_int(obj: int, json_options: JSONOptions) -> Any: - if json_options.json_mode == JSONMode.CANONICAL: - if -_INT32_MAX <= obj < _INT32_MAX: - return {"$numberInt": str(obj)} - return {"$numberLong": str(obj)} - return obj - - -def _encode_float(obj: float, json_options: JSONOptions) -> Any: - if json_options.json_mode != JSONMode.LEGACY: - if math.isnan(obj): - return {"$numberDouble": "NaN"} - elif math.isinf(obj): - representation = "Infinity" if obj > 0 else "-Infinity" - return {"$numberDouble": representation} - elif json_options.json_mode == JSONMode.CANONICAL: - # repr() will return the shortest string guaranteed to produce the - # original value, when float() is called on it. - return {"$numberDouble": str(repr(obj))} - return obj - - -def _encode_datetime(obj: datetime.datetime, json_options: JSONOptions) -> dict: # type: ignore[type-arg] - if json_options.datetime_representation == DatetimeRepresentation.ISO8601: - if not obj.tzinfo: - obj = obj.replace(tzinfo=utc) - assert obj.tzinfo is not None - if obj >= EPOCH_AWARE: - off = obj.tzinfo.utcoffset(obj) - if (off.days, off.seconds, off.microseconds) == (0, 0, 0): # type: ignore - tz_string = "Z" - else: - tz_string = obj.strftime("%z") - millis = int(obj.microsecond / 1000) - fracsecs = f".{millis:03d}" if millis else "" - return { - "$date": "{}{}{}".format(obj.strftime("%Y-%m-%dT%H:%M:%S"), fracsecs, tz_string) - } - - millis = _datetime_to_millis(obj) - if json_options.datetime_representation == DatetimeRepresentation.LEGACY: - return {"$date": millis} - return {"$date": {"$numberLong": str(millis)}} - - -def _encode_bytes(obj: bytes, json_options: JSONOptions) -> dict: # type: ignore[type-arg] - return _encode_binary(obj, 0, json_options) - - -def _encode_binary_obj(obj: Binary, json_options: JSONOptions) -> dict: # type: ignore[type-arg] - return _encode_binary(obj, obj.subtype, json_options) - - -def _encode_uuid(obj: uuid.UUID, json_options: JSONOptions) -> dict: # type: ignore[type-arg] - if json_options.strict_uuid: - binval = Binary.from_uuid(obj, uuid_representation=json_options.uuid_representation) - return _encode_binary(binval, binval.subtype, json_options) - else: - return {"$uuid": obj.hex} - - -def _encode_objectid(obj: ObjectId, dummy0: Any) -> dict: # type: ignore[type-arg] - return {"$oid": str(obj)} - - -def _encode_timestamp(obj: Timestamp, dummy0: Any) -> dict: # type: ignore[type-arg] - return {"$timestamp": {"t": obj.time, "i": obj.inc}} - - -def _encode_decimal128(obj: Timestamp, dummy0: Any) -> dict: # type: ignore[type-arg] - return {"$numberDecimal": str(obj)} - - -def _encode_dbref(obj: DBRef, json_options: JSONOptions) -> dict: # type: ignore[type-arg] - return _json_convert(obj.as_doc(), json_options=json_options) - - -def _encode_minkey(dummy0: Any, dummy1: Any) -> dict: # type: ignore[type-arg] - return {"$minKey": 1} - - -def _encode_maxkey(dummy0: Any, dummy1: Any) -> dict: # type: ignore[type-arg] - return {"$maxKey": 1} - - -# Encoders for BSON types -# Each encoder function's signature is: -# - obj: a Python data type, e.g. a Python int for _encode_int -# - json_options: a JSONOptions -_ENCODERS: dict[type, Callable[[Any, JSONOptions], Any]] = { - bool: _encode_noop, - bytes: _encode_bytes, - datetime.datetime: _encode_datetime, - DatetimeMS: _encode_datetimems, - float: _encode_float, - int: _encode_int, - str: _encode_noop, - type(None): _encode_noop, - uuid.UUID: _encode_uuid, - Binary: _encode_binary_obj, - Int64: _encode_int64, - Code: _encode_code, - DBRef: _encode_dbref, - MaxKey: _encode_maxkey, - MinKey: _encode_minkey, - ObjectId: _encode_objectid, - Regex: _encode_regex, - RE_TYPE: _encode_regex, - Timestamp: _encode_timestamp, - Decimal128: _encode_decimal128, -} - -# Map each _type_marker to its encoder for faster lookup. -_MARKERS: dict[int, Callable[[Any, JSONOptions], Any]] = {} -for _typ, _encoder in _ENCODERS.items(): - if hasattr(_typ, "_type_marker"): - _MARKERS[_typ._type_marker] = _encoder - -_BUILT_IN_TYPES = tuple(t for t in _ENCODERS) - - -def default(obj: Any, json_options: JSONOptions = DEFAULT_JSON_OPTIONS) -> Any: - # First see if the type is already cached. KeyError will only ever - # happen once per subtype. - try: - return _ENCODERS[type(obj)](obj, json_options) - except KeyError: - pass - - # Second, fall back to trying _type_marker. This has to be done - # before the loop below since users could subclass one of our - # custom types that subclasses a python built-in (e.g. Binary) - if hasattr(obj, "_type_marker"): - marker = obj._type_marker - if marker in _MARKERS: - func = _MARKERS[marker] - # Cache this type for faster subsequent lookup. - _ENCODERS[type(obj)] = func - return func(obj, json_options) - - # Third, test each base type. This will only happen once for - # a subtype of a supported base type. - for base in _BUILT_IN_TYPES: - if isinstance(obj, base): - func = _ENCODERS[base] - # Cache this type for faster subsequent lookup. - _ENCODERS[type(obj)] = func - return func(obj, json_options) - - raise TypeError(f"{obj!r} is not JSON serializable") - - -def _get_str_size(obj: Any) -> int: - return len(obj) - - -def _get_datetime_size(obj: datetime.datetime) -> int: - return 5 + len(str(obj.time())) - - -def _get_regex_size(obj: Regex) -> int: # type: ignore[type-arg] - return 18 + len(obj.pattern) - - -def _get_dbref_size(obj: DBRef) -> int: - return 34 + len(obj.collection) - - -_CONSTANT_SIZE_TABLE: dict[Any, int] = { - ObjectId: 28, - int: 11, - Int64: 11, - Decimal128: 11, - Timestamp: 14, - MinKey: 8, - MaxKey: 8, -} - -_VARIABLE_SIZE_TABLE: dict[Any, Callable[[Any], int]] = { - str: _get_str_size, - bytes: _get_str_size, - datetime.datetime: _get_datetime_size, - Regex: _get_regex_size, - DBRef: _get_dbref_size, -} - - -def get_size(obj: Any, max_size: int, current_size: int = 0) -> int: - """Recursively finds size of objects""" - if current_size >= max_size: - return current_size - - obj_type = type(obj) - - # Check to see if the obj has a constant size estimate - try: - return _CONSTANT_SIZE_TABLE[obj_type] - except KeyError: - pass - - # Check to see if the obj has a variable but simple size estimate - try: - return _VARIABLE_SIZE_TABLE[obj_type](obj) - except KeyError: - pass - - # Special cases that require recursion - if obj_type == Code: - if obj.scope: - current_size += ( - 5 + get_size(obj.scope, max_size, current_size) + len(obj) - len(obj.scope) - ) - else: - current_size += 5 + len(obj) - elif obj_type is dict: - for k, v in obj.items(): - current_size += get_size(k, max_size, current_size) - current_size += get_size(v, max_size, current_size) - if current_size >= max_size: - return current_size - elif hasattr(obj, "__iter__"): - for i in obj: - current_size += get_size(i, max_size, current_size) - if current_size >= max_size: - return current_size - return current_size - - -def _truncate_documents(obj: Any, max_length: int) -> tuple[Any, int]: - """Recursively truncate documents as needed to fit inside max_length characters.""" - if max_length <= 0: - return None, 0 - remaining = max_length - if hasattr(obj, "items"): - truncated: Any = {} - for k, v in obj.items(): - truncated_v, remaining = _truncate_documents(v, remaining) - if truncated_v: - truncated[k] = truncated_v - if remaining <= 0: - break - return truncated, remaining - elif hasattr(obj, "__iter__") and not isinstance(obj, (str, bytes)): - truncated: Any = [] # type:ignore[no-redef] - for v in obj: - truncated_v, remaining = _truncate_documents(v, remaining) - if truncated_v: - truncated.append(truncated_v) - if remaining <= 0: - break - return truncated, remaining - else: - return _truncate(obj, remaining) - - -def _truncate(obj: Any, remaining: int) -> tuple[Any, int]: - size = get_size(obj, remaining) - - if size <= remaining: - return obj, remaining - size - else: - try: - truncated = obj[:remaining] - except TypeError: - truncated = obj - return truncated, remaining - size diff --git a/bson/max_key.py b/bson/max_key.py deleted file mode 100644 index 69d4a7b12e..0000000000 --- a/bson/max_key.py +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2010-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Representation for the MongoDB internal MaxKey type.""" - -from __future__ import annotations - -from typing import Any - - -class MaxKey: - """MongoDB internal MaxKey type.""" - - __slots__ = () - - _type_marker = 127 - - def __getstate__(self) -> Any: - return {} - - def __setstate__(self, state: Any) -> None: - pass - - def __eq__(self, other: object) -> bool: - return isinstance(other, MaxKey) - - def __hash__(self) -> int: - return hash(self._type_marker) - - def __ne__(self, other: object) -> bool: - return not self == other - - def __le__(self, other: Any) -> bool: - return isinstance(other, MaxKey) - - def __lt__(self, dummy: Any) -> bool: - return False - - def __ge__(self, dummy: Any) -> bool: - return True - - def __gt__(self, other: Any) -> bool: - return not isinstance(other, MaxKey) - - def __repr__(self) -> str: - return "MaxKey()" diff --git a/bson/min_key.py b/bson/min_key.py deleted file mode 100644 index 8a026129f7..0000000000 --- a/bson/min_key.py +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2010-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Representation for the MongoDB internal MinKey type.""" - -from __future__ import annotations - -from typing import Any - - -class MinKey: - """MongoDB internal MinKey type.""" - - __slots__ = () - - _type_marker = 255 - - def __getstate__(self) -> Any: - return {} - - def __setstate__(self, state: Any) -> None: - pass - - def __eq__(self, other: object) -> bool: - return isinstance(other, MinKey) - - def __hash__(self) -> int: - return hash(self._type_marker) - - def __ne__(self, other: object) -> bool: - return not self == other - - def __le__(self, dummy: Any) -> bool: - return True - - def __lt__(self, other: Any) -> bool: - return not isinstance(other, MinKey) - - def __ge__(self, other: Any) -> bool: - return isinstance(other, MinKey) - - def __gt__(self, dummy: Any) -> bool: - return False - - def __repr__(self) -> str: - return "MinKey()" diff --git a/bson/objectid.py b/bson/objectid.py deleted file mode 100644 index d4c9dce545..0000000000 --- a/bson/objectid.py +++ /dev/null @@ -1,262 +0,0 @@ -# Copyright 2009-2015 MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Tools for working with MongoDB ObjectIds.""" - -from __future__ import annotations - -import datetime -import os -import struct -import threading -import time -from random import SystemRandom -from typing import Any, NoReturn - -from bson.datetime_ms import _datetime_to_millis -from bson.errors import InvalidId -from bson.tz_util import utc - -_MAX_COUNTER_VALUE = 0xFFFFFF -_PACK_INT = struct.Struct(">I").pack -_PACK_INT_RANDOM = struct.Struct(">I5s").pack -_UNPACK_INT = struct.Struct(">I").unpack - - -def _raise_invalid_id(oid: str) -> NoReturn: - raise InvalidId( - f"{oid!r} is not a valid ObjectId, it must be a 12-byte input or a 24-character hex string" - ) - - -def _random_bytes() -> bytes: - """Get the 5-byte random field of an ObjectId.""" - return os.urandom(5) - - -class ObjectId: - """A MongoDB ObjectId.""" - - _pid = os.getpid() - - _inc = SystemRandom().randint(0, _MAX_COUNTER_VALUE) - _inc_lock = threading.Lock() - - __random = _random_bytes() - - __slots__ = ("__id",) - - _type_marker = 7 - - def __init__(self, oid: str | ObjectId | bytes | None = None) -> None: - """Initialize a new ObjectId. - - An ObjectId is a 12-byte unique identifier consisting of: - - - a 4-byte value representing the seconds since the Unix epoch, - - a 5-byte random value, - - a 3-byte counter, starting with a random value. - - By default, ``ObjectId()`` creates a new unique identifier. The - optional parameter `oid` can be an :class:`ObjectId`, or any 12 - :class:`bytes`. - - For example, the 12 bytes b'foo-bar-quux' do not follow the ObjectId - specification but they are acceptable input:: - - >>> ObjectId(b'foo-bar-quux') - ObjectId('666f6f2d6261722d71757578') - - `oid` can also be a :class:`str` of 24 hex digits:: - - >>> ObjectId('0123456789ab0123456789ab') - ObjectId('0123456789ab0123456789ab') - - Raises :class:`~bson.errors.InvalidId` if `oid` is not 12 bytes nor - 24 hex digits, or :class:`TypeError` if `oid` is not an accepted type. - - :param oid: a valid ObjectId. - - .. seealso:: The MongoDB documentation on `ObjectIds `_. - - .. versionchanged:: 3.8 - :class:`~bson.objectid.ObjectId` now implements the `ObjectID - specification version 0.2 - `_. - """ - if oid is None: - # Generate a new value for this ObjectId. - with ObjectId._inc_lock: - inc = ObjectId._inc - ObjectId._inc = (inc + 1) % (_MAX_COUNTER_VALUE + 1) - - # 4 bytes current time, 5 bytes random, 3 bytes inc. - self.__id = _PACK_INT_RANDOM(int(time.time()), ObjectId._random()) + _PACK_INT(inc)[1:4] - elif isinstance(oid, bytes) and len(oid) == 12: - self.__id = oid - elif isinstance(oid, str): - if len(oid) == 24: - try: - self.__id = bytes.fromhex(oid) - except (TypeError, ValueError): - _raise_invalid_id(oid) - # bytes.fromhex() skips ASCII whitespace, so a 24-character - # string can decode to fewer than 12 bytes. - if len(self.__id) != 12: - _raise_invalid_id(oid) - else: - _raise_invalid_id(oid) - elif isinstance(oid, ObjectId): - self.__id = oid.binary - else: - raise TypeError(f"id must be an instance of (bytes, str, ObjectId), not {type(oid)}") - - @classmethod - def from_datetime(cls: type[ObjectId], generation_time: datetime.datetime) -> ObjectId: - """Create a dummy ObjectId instance with a specific generation time. - - This method is useful for doing range queries on a field - containing :class:`ObjectId` instances. - - .. warning:: - It is not safe to insert a document containing an ObjectId - generated using this method. This method deliberately - eliminates the uniqueness guarantee that ObjectIds - generally provide. ObjectIds generated with this method - should be used exclusively in queries. - - `generation_time` will be converted to UTC. Naive datetime - instances will be treated as though they already contain UTC. - - An example using this helper to get documents where ``"_id"`` - was generated before January 1, 2010 would be: - - >>> gen_time = datetime.datetime(2010, 1, 1) - >>> dummy_id = ObjectId.from_datetime(gen_time) - >>> result = collection.find({"_id": {"$lt": dummy_id}}) - - :param generation_time: :class:`~datetime.datetime` to be used - as the generation time for the resulting ObjectId. - """ - oid = ( - _PACK_INT(_datetime_to_millis(generation_time) // 1000) - + b"\x00\x00\x00\x00\x00\x00\x00\x00" - ) - return cls(oid) - - @classmethod - def is_valid(cls: type[ObjectId], oid: Any) -> bool: - """Checks if a `oid` string is valid or not. - - :param oid: the object id to validate - - .. versionadded:: 2.3 - """ - if not oid: - return False - - try: - ObjectId(oid) - return True - except (InvalidId, TypeError): - return False - - @classmethod - def _random(cls) -> bytes: - """Generate a 5-byte random number once per process.""" - pid = os.getpid() - if pid != cls._pid: - cls._pid = pid - cls.__random = _random_bytes() - return cls.__random - - @property - def binary(self) -> bytes: - """12-byte binary representation of this ObjectId.""" - return self.__id - - @property - def generation_time(self) -> datetime.datetime: - """A :class:`datetime.datetime` instance representing the time of - generation for this :class:`ObjectId`. - - The :class:`datetime.datetime` is timezone aware, and - represents the generation time in UTC. It is precise to the - second. - """ - timestamp = _UNPACK_INT(self.__id[0:4])[0] - return datetime.datetime.fromtimestamp(timestamp, utc) - - def __getstate__(self) -> bytes: - """Return value of object for pickling. - needed explicitly because __slots__() defined. - """ - return self.__id - - def __setstate__(self, value: Any) -> None: - """Explicit state set from pickling""" - # Provide backwards compatibility with OIDs - # pickled with pymongo-1.9 or older. - if isinstance(value, dict): - oid = value["_ObjectId__id"] - else: - oid = value - # ObjectIds pickled in python 2.x used `str` for __id. - # In python 3.x this has to be converted to `bytes` - # by encoding latin-1. - if isinstance(oid, str): - self.__id = oid.encode("latin-1") - else: - self.__id = oid - - def __str__(self) -> str: - return self.__id.hex() - - def __repr__(self) -> str: - return f"ObjectId('{self!s}')" - - def __eq__(self, other: object) -> bool: - if isinstance(other, ObjectId): - return self.__id == other.binary - return NotImplemented - - def __ne__(self, other: object) -> bool: - if isinstance(other, ObjectId): - return self.__id != other.binary - return NotImplemented - - def __lt__(self, other: Any) -> bool: - if isinstance(other, ObjectId): - return self.__id < other.binary - return NotImplemented - - def __le__(self, other: Any) -> bool: - if isinstance(other, ObjectId): - return self.__id <= other.binary - return NotImplemented - - def __gt__(self, other: Any) -> bool: - if isinstance(other, ObjectId): - return self.__id > other.binary - return NotImplemented - - def __ge__(self, other: Any) -> bool: - if isinstance(other, ObjectId): - return self.__id >= other.binary - return NotImplemented - - def __hash__(self) -> int: - """Get a hash value for this :class:`ObjectId`.""" - return hash(self.__id) diff --git a/bson/py.typed b/bson/py.typed deleted file mode 100644 index 0f4057061a..0000000000 --- a/bson/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# PEP-561 Support File. -# "Package maintainers who wish to support type checking of their code MUST add a marker file named py.typed to their package supporting typing". diff --git a/bson/raw_bson.py b/bson/raw_bson.py deleted file mode 100644 index 2bc91dfa13..0000000000 --- a/bson/raw_bson.py +++ /dev/null @@ -1,227 +0,0 @@ -# Copyright 2015-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Tools for representing raw BSON documents. - -Inserting and Retrieving RawBSONDocuments -========================================= - -Example: Moving a document between different databases/collections - -.. doctest:: - - >>> import bson - >>> from pymongo import MongoClient - >>> from bson.raw_bson import RawBSONDocument - >>> client = MongoClient(document_class=RawBSONDocument) - >>> client.drop_database("db") - >>> client.drop_database("replica_db") - >>> db = client.db - >>> result = db.test.insert_many( - ... [{"_id": 1, "a": 1}, {"_id": 2, "b": 1}, {"_id": 3, "c": 1}, {"_id": 4, "d": 1}] - ... ) - >>> replica_db = client.replica_db - >>> for doc in db.test.find(): - ... print(f"raw document: {doc.raw}") - ... print(f"decoded document: {bson.decode(doc.raw)}") - ... result = replica_db.test.insert_one(doc) - ... - raw document: b'...' - decoded document: {'_id': 1, 'a': 1} - raw document: b'...' - decoded document: {'_id': 2, 'b': 1} - raw document: b'...' - decoded document: {'_id': 3, 'c': 1} - raw document: b'...' - decoded document: {'_id': 4, 'd': 1} - -For use cases like moving documents across different databases or writing binary -blobs to disk, using raw BSON documents provides better speed and avoids the -overhead of decoding or encoding BSON. -""" - -from __future__ import annotations - -import copyreg -from collections.abc import ItemsView, Iterator, Mapping -from typing import Any - -from bson import _get_object_size, _raw_as_bytes, _raw_to_dict -from bson.codec_options import _RAW_BSON_DOCUMENT_MARKER, CodecOptions -from bson.codec_options import DEFAULT_CODEC_OPTIONS as DEFAULT - - -def _inflate_bson( - bson_bytes: bytes | memoryview, - codec_options: CodecOptions[RawBSONDocument], - raw_array: bool = False, -) -> dict[str, Any]: - """Inflates the top level fields of a BSON document. - - :param bson_bytes: the BSON bytes that compose this document - :param codec_options: An instance of - :class:`~bson.codec_options.CodecOptions` whose ``document_class`` - must be :class:`RawBSONDocument`. - """ - return _raw_to_dict(bson_bytes, 4, len(bson_bytes) - 1, codec_options, {}, raw_array=raw_array) - - -class RawBSONDocument(Mapping[str, Any]): - """Representation for a MongoDB document that provides access to the raw - BSON bytes that compose it. - - Only when a field is accessed or modified within the document does - RawBSONDocument decode its bytes. - """ - - __slots__ = ("__codec_options", "__inflated_doc", "__raw") - _type_marker = _RAW_BSON_DOCUMENT_MARKER - __codec_options: CodecOptions[RawBSONDocument] - - def __init__( - self, - bson_bytes: bytes | memoryview, - codec_options: CodecOptions[RawBSONDocument] | None = None, - ) -> None: - """Create a new :class:`RawBSONDocument` - - :class:`RawBSONDocument` is a representation of a BSON document that - provides access to the underlying raw BSON bytes. Only when a field is - accessed or modified within the document does RawBSONDocument decode - its bytes. - - :class:`RawBSONDocument` implements the ``Mapping`` abstract base - class from the standard library so it can be used like a read-only - ``dict``:: - - >>> from bson import encode - >>> raw_doc = RawBSONDocument(encode({'_id': 'my_doc'})) - >>> raw_doc.raw - b'...' - >>> raw_doc['_id'] - 'my_doc' - - :param bson_bytes: the BSON bytes that compose this document - :param codec_options: An instance of - :class:`~bson.codec_options.CodecOptions` whose ``document_class`` - must be :class:`RawBSONDocument`. The default is - :attr:`DEFAULT_RAW_BSON_OPTIONS`. - - .. versionchanged:: 3.8 - :class:`RawBSONDocument` now validates that the ``bson_bytes`` - passed in represent a single bson document. - - .. versionchanged:: 3.5 - If a :class:`~bson.codec_options.CodecOptions` is passed in, its - `document_class` must be :class:`RawBSONDocument`. - """ - self.__raw = bson_bytes - self.__inflated_doc: Mapping[str, Any] | None = None - # Can't default codec_options to DEFAULT_RAW_BSON_OPTIONS in signature, - # it refers to this class RawBSONDocument. - if codec_options is None: - codec_options = DEFAULT_RAW_BSON_OPTIONS - elif not issubclass(codec_options.document_class, RawBSONDocument): - raise TypeError( - "RawBSONDocument cannot use CodecOptions with document " - f"class {codec_options.document_class}" - ) - self.__codec_options = codec_options - # Validate the bson object size. - _get_object_size(bson_bytes, 0, len(bson_bytes)) - - @property - def raw(self) -> bytes | memoryview: - """The raw BSON bytes composing this document. - - .. versionchanged:: 4.18 - Documents and subdocuments 4KB and larger decoded from an - immutable buffer are returned as read-only :class:`memoryview` - slices of that buffer instead of :class:`bytes` copies. Documents - decoded from mutable buffers such as :class:`bytearray` are - always :class:`bytes` copies. Call ``bytes(doc.raw)`` - to get an independent copy. - """ - return self.__raw - - def items(self) -> ItemsView[str, Any]: - """Lazily decode and iterate elements in this document.""" - return self.__inflated.items() - - @property - def __inflated(self) -> Mapping[str, Any]: - if self.__inflated_doc is None: - # We already validated the object's size when this document was - # created, so no need to do that again. - self.__inflated_doc = self._inflate_bson(self.__raw, self.__codec_options) - return self.__inflated_doc - - @staticmethod - def _inflate_bson( - bson_bytes: bytes | memoryview, codec_options: CodecOptions[RawBSONDocument] - ) -> Mapping[str, Any]: - return _inflate_bson(bson_bytes, codec_options) - - def __getitem__(self, item: str) -> Any: - return self.__inflated[item] - - def __iter__(self) -> Iterator[str]: - return iter(self.__inflated) - - def __len__(self) -> int: - return len(self.__inflated) - - def __eq__(self, other: object) -> bool: - if isinstance(other, RawBSONDocument): - return self.__raw == other.raw - return NotImplemented - - __hash__ = None # type: ignore[assignment] - - def __getstate__(self) -> tuple[dict[str, Any] | None, dict[str, Any]]: - slots_state: dict[str, Any] = { - name: getattr(self, name) - for name in copyreg._slotnames(type(self)) # type: ignore[attr-defined] - if hasattr(self, name) - } - slots_state["_RawBSONDocument__raw"] = _raw_as_bytes(self.__raw) - slots_state["_RawBSONDocument__inflated_doc"] = None - return getattr(self, "__dict__", None), slots_state - - def __repr__(self) -> str: - return ( - f"{self.__class__.__name__}({_raw_as_bytes(self.__raw)!r}, " - f"codec_options={self.__codec_options!r})" - ) - - -class _RawArrayBSONDocument(RawBSONDocument): - """A RawBSONDocument that only expands sub-documents and arrays when accessed.""" - - @staticmethod - def _inflate_bson( - bson_bytes: bytes | memoryview, codec_options: CodecOptions[RawBSONDocument] - ) -> Mapping[str, Any]: - return _inflate_bson(bson_bytes, codec_options, raw_array=True) - - -DEFAULT_RAW_BSON_OPTIONS: CodecOptions[RawBSONDocument] = DEFAULT.with_options( - document_class=RawBSONDocument -) -_RAW_ARRAY_BSON_OPTIONS: CodecOptions[_RawArrayBSONDocument] = DEFAULT.with_options( - document_class=_RawArrayBSONDocument -) -"""The default :class:`~bson.codec_options.CodecOptions` for -:class:`RawBSONDocument`. -""" diff --git a/bson/regex.py b/bson/regex.py deleted file mode 100644 index c20a1c5f38..0000000000 --- a/bson/regex.py +++ /dev/null @@ -1,135 +0,0 @@ -# Copyright 2013-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Tools for representing MongoDB regular expressions.""" - -from __future__ import annotations - -import re -from re import Pattern -from typing import Any, Generic, TypeVar - -from bson._helpers import _getstate_slots, _setstate_slots -from bson.son import RE_TYPE - - -def str_flags_to_int(str_flags: str) -> int: - flags = 0 - if "i" in str_flags: - flags |= re.IGNORECASE - if "l" in str_flags: - flags |= re.LOCALE - if "m" in str_flags: - flags |= re.MULTILINE - if "s" in str_flags: - flags |= re.DOTALL - if "u" in str_flags: - flags |= re.UNICODE - if "x" in str_flags: - flags |= re.VERBOSE - - return flags - - -_T = TypeVar("_T", str, bytes) - - -class Regex(Generic[_T]): - """BSON regular expression data.""" - - __slots__ = ("flags", "pattern") - - __getstate__ = _getstate_slots - __setstate__ = _setstate_slots - - _type_marker = 11 - - @classmethod - def from_native(cls: type[Regex[Any]], regex: Pattern[_T]) -> Regex[_T]: - """Convert a Python regular expression into a ``Regex`` instance. - - Note that in Python 3, a regular expression compiled from a - :class:`str` has the ``re.UNICODE`` flag set. If it is undesirable - to store this flag in a BSON regular expression, unset it first:: - - >>> pattern = re.compile('.*') - >>> regex = Regex.from_native(pattern) - >>> regex.flags ^= re.UNICODE - >>> db.collection.insert_one({'pattern': regex}) - - :param regex: A regular expression object from ``re.compile()``. - - .. warning:: - Python regular expressions use a different syntax and different - set of flags than MongoDB, which uses `PCRE`_. A regular - expression retrieved from the server may not compile in - Python, or may match a different set of strings in Python than - when used in a MongoDB query. - - .. _PCRE: http://www.pcre.org/ - """ - if not isinstance(regex, RE_TYPE): - raise TypeError(f"regex must be a compiled regular expression, not {type(regex)}") - - return Regex(regex.pattern, regex.flags) - - def __init__(self, pattern: _T, flags: str | int = 0) -> None: - """BSON regular expression data. - - This class is useful to store and retrieve regular expressions that are - incompatible with Python's regular expression dialect. - - :param pattern: string - :param flags: an integer bitmask, or a string of flag - characters like "im" for IGNORECASE and MULTILINE - """ - if not isinstance(pattern, (str, bytes)): - raise TypeError(f"pattern must be a string, not {type(pattern)}") - self.pattern: _T = pattern - - if isinstance(flags, str): - self.flags = str_flags_to_int(flags) - elif isinstance(flags, int): - self.flags = flags - else: - raise TypeError(f"flags must be a string or int, not {type(flags)}") - - def __eq__(self, other: object) -> bool: - if isinstance(other, Regex): - return self.pattern == other.pattern and self.flags == other.flags - else: - return NotImplemented - - __hash__ = None # type: ignore - - def __ne__(self, other: object) -> bool: - return not self == other - - def __repr__(self) -> str: - return f"Regex({self.pattern!r}, {self.flags!r})" - - def try_compile(self) -> Pattern[_T]: - """Compile this :class:`Regex` as a Python regular expression. - - .. warning:: - Python regular expressions use a different syntax and different - set of flags than MongoDB, which uses `PCRE`_. A regular - expression retrieved from the server may not compile in - Python, or may match a different set of strings in Python than - when used in a MongoDB query. :meth:`try_compile()` may raise - :exc:`re.error`. - - .. _PCRE: http://www.pcre.org/ - """ - return re.compile(self.pattern, self.flags) diff --git a/bson/son.py b/bson/son.py deleted file mode 100644 index 1f09bed1ae..0000000000 --- a/bson/son.py +++ /dev/null @@ -1,223 +0,0 @@ -# Copyright 2009-present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Tools for creating and manipulating SON, the Serialized Ocument Notation. - -Regular dictionaries can be used instead of SON objects, but not when the order -of keys is important. A SON object can be used just like a normal Python -dictionary. -""" - -from __future__ import annotations - -import copy -import re -import warnings -from collections.abc import Iterable, Iterator, Mapping -from collections.abc import Mapping as _Mapping -from re import Pattern -from typing import ( - Any, - TypeVar, - cast, -) - -# This sort of sucks, but seems to be as good as it gets... -# This is essentially the same as re._pattern_type -RE_TYPE: type[Pattern[Any]] = type(re.compile("")) - -_Key = TypeVar("_Key") -_Value = TypeVar("_Value") -_T = TypeVar("_T") - - -class SON(dict[_Key, _Value]): - """SON data. - - A subclass of dict that maintains ordering of keys and provides a - few extra niceties for dealing with SON. SON provides an API - similar to collections.OrderedDict. - """ - - __keys: list[Any] - - def __init__( - self, - data: Mapping[_Key, _Value] | Iterable[tuple[_Key, _Value]] | None = None, - **kwargs: Any, - ) -> None: - self.__keys = [] - dict.__init__(self) - self.update(data) - self.update(kwargs) - - def __new__(cls: type[SON[_Key, _Value]], *args: Any, **kwargs: Any) -> SON[_Key, _Value]: - instance = super().__new__(cls, *args, **kwargs) - instance.__keys = [] - return instance - - def __repr__(self) -> str: - result = [] - for key in self.__keys: - result.append(f"({key!r}, {self[key]!r})") - return "SON([{}])".format(", ".join(result)) - - def __setitem__(self, key: _Key, value: _Value) -> None: - if key not in self.__keys: - self.__keys.append(key) - dict.__setitem__(self, key, value) - - def __delitem__(self, key: _Key) -> None: - self.__keys.remove(key) - dict.__delitem__(self, key) - - def copy(self) -> SON[_Key, _Value]: - other: SON[_Key, _Value] = SON() - other.update(self) - return other - - # TODO this is all from UserDict.DictMixin. it could probably be made more - # efficient. - # second level definitions support higher levels - def __iter__(self) -> Iterator[_Key]: - yield from self.__keys - - def has_key(self, key: _Key) -> bool: - warnings.warn( - "SON.has_key() is deprecated, use the in operator instead", - DeprecationWarning, - stacklevel=2, - ) - return key in self.__keys - - def iterkeys(self) -> Iterator[_Key]: - warnings.warn( - "SON.iterkeys() is deprecated, use the keys() method instead", - DeprecationWarning, - stacklevel=2, - ) - return self.__iter__() - - # fourth level uses definitions from lower levels - def itervalues(self) -> Iterator[_Value]: - warnings.warn( - "SON.itervalues() is deprecated, use the values() method instead", - DeprecationWarning, - stacklevel=2, - ) - for _, v in self.items(): # noqa: PERF102 - yield v - - def values(self) -> list[_Value]: # type: ignore[override] - return [v for _, v in self.items()] - - def clear(self) -> None: - self.__keys = [] - super().clear() - - def setdefault(self, key: _Key, default: _Value) -> _Value: - try: - return self[key] - except KeyError: - self[key] = default - return default - - def pop(self, key: _Key, *args: _Value | _T) -> _Value | _T: - if len(args) > 1: - raise TypeError("pop expected at most 2 arguments, got " + repr(1 + len(args))) - try: - value = self[key] - except KeyError: - if args: - return args[0] - raise - del self[key] - return value - - def popitem(self) -> tuple[_Key, _Value]: - try: - k, v = next(iter(self.items())) - except StopIteration: - raise KeyError("container is empty") from None - del self[k] - return (k, v) - - def update(self, other: Any | None = None, **kwargs: _Value) -> None: - # Make progressively weaker assumptions about "other" - if other is None: - pass - elif hasattr(other, "items"): - for k, v in other.items(): - self[k] = v - elif hasattr(other, "keys"): - for k in other: - self[k] = other[k] - else: - for k, v in other: - self[k] = v - if kwargs: - self.update(kwargs) - - def get( # type: ignore[override] - self, key: _Key, default: _Value | _T | None = None - ) -> _Value | _T | None: - try: - return self[key] - except KeyError: - return default - - def __eq__(self, other: object) -> bool: - """Comparison to another SON is order-sensitive while comparison to a - regular dictionary is order-insensitive. - """ - if isinstance(other, SON): - return len(self) == len(other) and list(self.items()) == list(other.items()) - return self.to_dict() == other - - __hash__ = None - - def __ne__(self, other: object) -> bool: - return not self == other - - def __len__(self) -> int: - return len(self.__keys) - - def to_dict(self) -> dict[_Key, _Value]: - """Convert a SON document to a normal Python dictionary instance. - - This is trickier than just *dict(...)* because it needs to be - recursive. - """ - - def transform_value(value: Any) -> Any: - if isinstance(value, list): - return [transform_value(v) for v in value] - elif isinstance(value, _Mapping): - return {k: transform_value(v) for k, v in value.items()} - else: - return value - - return cast("dict[_Key, _Value]", transform_value(dict(self))) - - def __deepcopy__(self, memo: dict[int, SON[_Key, _Value]]) -> SON[_Key, _Value]: - out: SON[_Key, _Value] = SON() - val_id = id(self) - if val_id in memo: - return memo[val_id] - memo[val_id] = out - for k, v in self.items(): - if not isinstance(v, RE_TYPE): - v = copy.deepcopy(v, memo) # noqa: PLW2901 - out[k] = v - return out diff --git a/bson/time64.c b/bson/time64.c deleted file mode 100644 index a21fbb90bd..0000000000 --- a/bson/time64.c +++ /dev/null @@ -1,781 +0,0 @@ -/* - -Copyright (c) 2007-2010 Michael G Schwern - -This software originally derived from Paul Sheer's pivotal_gmtime_r.c. - -The MIT License: - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -*/ - -/* - -Programmers who have available to them 64-bit time values as a 'long -long' type can use cbson_localtime64_r() and cbson_gmtime64_r() which correctly -converts the time even on 32-bit systems. Whether you have 64-bit time -values will depend on the operating system. - -cbson_localtime64_r() is a 64-bit equivalent of localtime_r(). - -cbson_gmtime64_r() is a 64-bit equivalent of gmtime_r(). - -*/ - -#ifdef _MSC_VER - #define _CRT_SECURE_NO_WARNINGS -#endif - -/* Including Python.h fixes issues with interpreters built with -std=c99. */ -#define PY_SSIZE_T_CLEAN -#include "Python.h" - -#include -#include "time64.h" -#include "time64_limits.h" - - -/* Spec says except for stftime() and the _r() functions, these - all return static memory. Stabbings! */ -static struct TM Static_Return_Date; - -static const int days_in_month[2][12] = { - {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, - {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, -}; - -static const int julian_days_by_month[2][12] = { - {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}, - {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}, -}; - -static const int length_of_year[2] = { 365, 366 }; - -/* Some numbers relating to the gregorian cycle */ -static const Year years_in_gregorian_cycle = 400; -#define days_in_gregorian_cycle ((365 * 400) + 100 - 4 + 1) -static const Time64_T seconds_in_gregorian_cycle = days_in_gregorian_cycle * 60LL * 60LL * 24LL; - -/* Year range we can trust the time functions with */ -#define MAX_SAFE_YEAR 2037 -#define MIN_SAFE_YEAR 1971 - -/* 28 year Julian calendar cycle */ -#define SOLAR_CYCLE_LENGTH 28 - -/* Year cycle from MAX_SAFE_YEAR down. */ -static const int safe_years_high[SOLAR_CYCLE_LENGTH] = { - 2016, 2017, 2018, 2019, - 2020, 2021, 2022, 2023, - 2024, 2025, 2026, 2027, - 2028, 2029, 2030, 2031, - 2032, 2033, 2034, 2035, - 2036, 2037, 2010, 2011, - 2012, 2013, 2014, 2015 -}; - -/* Year cycle from MIN_SAFE_YEAR up */ -static const int safe_years_low[SOLAR_CYCLE_LENGTH] = { - 1996, 1997, 1998, 1971, - 1972, 1973, 1974, 1975, - 1976, 1977, 1978, 1979, - 1980, 1981, 1982, 1983, - 1984, 1985, 1986, 1987, - 1988, 1989, 1990, 1991, - 1992, 1993, 1994, 1995, -}; - -/* Let's assume people are going to be looking for dates in the future. - Let's provide some cheats so you can skip ahead. - This has a 4x speed boost when near 2008. -*/ -/* Number of days since epoch on Jan 1st, 2008 GMT */ -#define CHEAT_DAYS (1199145600 / 24 / 60 / 60) -#define CHEAT_YEARS 108 - -#define IS_LEAP(n) ((!(((n) + 1900) % 400) || (!(((n) + 1900) % 4) && (((n) + 1900) % 100))) != 0) -#define _TIME64_WRAP(a,b,m) ((a) = ((a) < 0 ) ? ((b)--, (a) + (m)) : (a)) - -#ifdef USE_SYSTEM_LOCALTIME -# define SHOULD_USE_SYSTEM_LOCALTIME(a) ( \ - (a) <= SYSTEM_LOCALTIME_MAX && \ - (a) >= SYSTEM_LOCALTIME_MIN \ -) -#else -# define SHOULD_USE_SYSTEM_LOCALTIME(a) (0) -#endif - -#ifdef USE_SYSTEM_GMTIME -# define SHOULD_USE_SYSTEM_GMTIME(a) ( \ - (a) <= SYSTEM_GMTIME_MAX && \ - (a) >= SYSTEM_GMTIME_MIN \ -) -#else -# define SHOULD_USE_SYSTEM_GMTIME(a) (0) -#endif - -/* Multi varadic macros are a C99 thing, alas */ -#ifdef TIME_64_DEBUG -# define TIME64_TRACE(format) (fprintf(stderr, format)) -# define TIME64_TRACE1(format, var1) (fprintf(stderr, format, var1)) -# define TIME64_TRACE2(format, var1, var2) (fprintf(stderr, format, var1, var2)) -# define TIME64_TRACE3(format, var1, var2, var3) (fprintf(stderr, format, var1, var2, var3)) -#else -# define TIME64_TRACE(format) ((void)0) -# define TIME64_TRACE1(format, var1) ((void)0) -# define TIME64_TRACE2(format, var1, var2) ((void)0) -# define TIME64_TRACE3(format, var1, var2, var3) ((void)0) -#endif - - -static int is_exception_century(Year year) -{ - int is_exception = ((year % 100 == 0) && !(year % 400 == 0)); - TIME64_TRACE1("# is_exception_century: %s\n", is_exception ? "yes" : "no"); - - return(is_exception); -} - - -/* Compare two dates. - The result is like cmp. - Ignores things like gmtoffset and dst -*/ -int cbson_cmp_date( const struct TM* left, const struct tm* right ) { - if( left->tm_year > right->tm_year ) - return 1; - else if( left->tm_year < right->tm_year ) - return -1; - - if( left->tm_mon > right->tm_mon ) - return 1; - else if( left->tm_mon < right->tm_mon ) - return -1; - - if( left->tm_mday > right->tm_mday ) - return 1; - else if( left->tm_mday < right->tm_mday ) - return -1; - - if( left->tm_hour > right->tm_hour ) - return 1; - else if( left->tm_hour < right->tm_hour ) - return -1; - - if( left->tm_min > right->tm_min ) - return 1; - else if( left->tm_min < right->tm_min ) - return -1; - - if( left->tm_sec > right->tm_sec ) - return 1; - else if( left->tm_sec < right->tm_sec ) - return -1; - - return 0; -} - - -/* Check if a date is safely inside a range. - The intention is to check if its a few days inside. -*/ -int cbson_date_in_safe_range( const struct TM* date, const struct tm* min, const struct tm* max ) { - if( cbson_cmp_date(date, min) == -1 ) - return 0; - - if( cbson_cmp_date(date, max) == 1 ) - return 0; - - return 1; -} - - -/* timegm() is not in the C or POSIX spec, but it is such a useful - extension I would be remiss in leaving it out. Also I need it - for cbson_localtime64() -*/ -Time64_T cbson_timegm64(const struct TM *date) { - Time64_T days = 0; - Time64_T seconds = 0; - Year year; - Year orig_year = (Year)date->tm_year; - int cycles = 0; - - if( orig_year > 100 ) { - cycles = (int)((orig_year - 100) / 400); - orig_year -= cycles * 400; - days += (Time64_T)cycles * days_in_gregorian_cycle; - } - else if( orig_year < -300 ) { - cycles = (int)((orig_year - 100) / 400); - orig_year -= cycles * 400; - days += (Time64_T)cycles * days_in_gregorian_cycle; - } - TIME64_TRACE3("# timegm/ cycles: %d, days: %lld, orig_year: %lld\n", cycles, days, orig_year); - - if( orig_year > 70 ) { - year = 70; - while( year < orig_year ) { - days += length_of_year[IS_LEAP(year)]; - year++; - } - } - else if ( orig_year < 70 ) { - year = 69; - do { - days -= length_of_year[IS_LEAP(year)]; - year--; - } while( year >= orig_year ); - } - - days += julian_days_by_month[IS_LEAP(orig_year)][date->tm_mon]; - days += date->tm_mday - 1; - - seconds = days * 60 * 60 * 24; - - seconds += date->tm_hour * 60 * 60; - seconds += date->tm_min * 60; - seconds += date->tm_sec; - - return(seconds); -} - - -#ifndef NDEBUG -static int check_tm(struct TM *tm) -{ - /* Don't forget leap seconds */ - assert(tm->tm_sec >= 0); - assert(tm->tm_sec <= 61); - - assert(tm->tm_min >= 0); - assert(tm->tm_min <= 59); - - assert(tm->tm_hour >= 0); - assert(tm->tm_hour <= 23); - - assert(tm->tm_mday >= 1); - assert(tm->tm_mday <= days_in_month[IS_LEAP(tm->tm_year)][tm->tm_mon]); - - assert(tm->tm_mon >= 0); - assert(tm->tm_mon <= 11); - - assert(tm->tm_wday >= 0); - assert(tm->tm_wday <= 6); - - assert(tm->tm_yday >= 0); - assert(tm->tm_yday <= length_of_year[IS_LEAP(tm->tm_year)]); - -#ifdef HAS_TM_TM_GMTOFF - assert(tm->tm_gmtoff >= -24 * 60 * 60); - assert(tm->tm_gmtoff <= 24 * 60 * 60); -#endif - - return 1; -} -#endif - - -/* The exceptional centuries without leap years cause the cycle to - shift by 16 -*/ -static Year cycle_offset(Year year) -{ - const Year start_year = 2000; - Year year_diff = year - start_year; - Year exceptions; - - if( year > start_year ) - year_diff--; - - exceptions = year_diff / 100; - exceptions -= year_diff / 400; - - TIME64_TRACE3("# year: %lld, exceptions: %lld, year_diff: %lld\n", - year, exceptions, year_diff); - - return exceptions * 16; -} - -/* For a given year after 2038, pick the latest possible matching - year in the 28 year calendar cycle. - - A matching year... - 1) Starts on the same day of the week. - 2) Has the same leap year status. - - This is so the calendars match up. - - Also the previous year must match. When doing Jan 1st you might - wind up on Dec 31st the previous year when doing a -UTC time zone. - - Finally, the next year must have the same start day of week. This - is for Dec 31st with a +UTC time zone. - It doesn't need the same leap year status since we only care about - January 1st. -*/ -static int safe_year(const Year year) -{ - int safe_year = 0; - Year year_cycle; - - if( year >= MIN_SAFE_YEAR && year <= MAX_SAFE_YEAR ) { - return (int)year; - } - - year_cycle = year + cycle_offset(year); - - /* safe_years_low is off from safe_years_high by 8 years */ - if( year < MIN_SAFE_YEAR ) - year_cycle -= 8; - - /* Change non-leap xx00 years to an equivalent */ - if( is_exception_century(year) ) - year_cycle += 11; - - /* Also xx01 years, since the previous year will be wrong */ - if( is_exception_century(year - 1) ) - year_cycle += 17; - - year_cycle %= SOLAR_CYCLE_LENGTH; - if( year_cycle < 0 ) - year_cycle = SOLAR_CYCLE_LENGTH + year_cycle; - - assert( year_cycle >= 0 ); - assert( year_cycle < SOLAR_CYCLE_LENGTH ); - if( year < MIN_SAFE_YEAR ) - safe_year = safe_years_low[year_cycle]; - else if( year > MAX_SAFE_YEAR ) - safe_year = safe_years_high[year_cycle]; - else - assert(0); - - TIME64_TRACE3("# year: %lld, year_cycle: %lld, safe_year: %d\n", - year, year_cycle, safe_year); - - assert(safe_year <= MAX_SAFE_YEAR && safe_year >= MIN_SAFE_YEAR); - - return safe_year; -} - - -void pymongo_copy_tm_to_TM64(const struct tm *src, struct TM *dest) { - if( src == NULL ) { - memset(dest, 0, sizeof(*dest)); - } - else { -# ifdef USE_TM64 - dest->tm_sec = src->tm_sec; - dest->tm_min = src->tm_min; - dest->tm_hour = src->tm_hour; - dest->tm_mday = src->tm_mday; - dest->tm_mon = src->tm_mon; - dest->tm_year = (Year)src->tm_year; - dest->tm_wday = src->tm_wday; - dest->tm_yday = src->tm_yday; - dest->tm_isdst = src->tm_isdst; - -# ifdef HAS_TM_TM_GMTOFF - dest->tm_gmtoff = src->tm_gmtoff; -# endif - -# ifdef HAS_TM_TM_ZONE - dest->tm_zone = src->tm_zone; -# endif - -# else - /* They're the same type */ - memcpy(dest, src, sizeof(*dest)); -# endif - } -} - - -void cbson_copy_TM64_to_tm(const struct TM *src, struct tm *dest) { - if( src == NULL ) { - memset(dest, 0, sizeof(*dest)); - } - else { -# ifdef USE_TM64 - dest->tm_sec = src->tm_sec; - dest->tm_min = src->tm_min; - dest->tm_hour = src->tm_hour; - dest->tm_mday = src->tm_mday; - dest->tm_mon = src->tm_mon; - dest->tm_year = (int)src->tm_year; - dest->tm_wday = src->tm_wday; - dest->tm_yday = src->tm_yday; - dest->tm_isdst = src->tm_isdst; - -# ifdef HAS_TM_TM_GMTOFF - dest->tm_gmtoff = src->tm_gmtoff; -# endif - -# ifdef HAS_TM_TM_ZONE - dest->tm_zone = src->tm_zone; -# endif - -# else - /* They're the same type */ - memcpy(dest, src, sizeof(*dest)); -# endif - } -} - - -/* Simulate localtime_r() to the best of our ability */ -struct tm * cbson_fake_localtime_r(const time_t *time, struct tm *result) { - const struct tm *static_result = localtime(time); - - assert(result != NULL); - - if( static_result == NULL ) { - memset(result, 0, sizeof(*result)); - return NULL; - } - else { - memcpy(result, static_result, sizeof(*result)); - return result; - } -} - - -/* Simulate gmtime_r() to the best of our ability */ -struct tm * cbson_fake_gmtime_r(const time_t *time, struct tm *result) { - const struct tm *static_result = gmtime(time); - - assert(result != NULL); - - if( static_result == NULL ) { - memset(result, 0, sizeof(*result)); - return NULL; - } - else { - memcpy(result, static_result, sizeof(*result)); - return result; - } -} - - -static Time64_T seconds_between_years(Year left_year, Year right_year) { - int increment = (left_year > right_year) ? 1 : -1; - Time64_T seconds = 0; - int cycles; - - if( left_year > 2400 ) { - cycles = (int)((left_year - 2400) / 400); - left_year -= cycles * 400; - seconds += cycles * seconds_in_gregorian_cycle; - } - else if( left_year < 1600 ) { - cycles = (int)((left_year - 1600) / 400); - left_year += cycles * 400; - seconds += cycles * seconds_in_gregorian_cycle; - } - - while( left_year != right_year ) { - seconds += length_of_year[IS_LEAP(right_year - 1900)] * 60 * 60 * 24; - right_year += increment; - } - - return seconds * increment; -} - - -Time64_T cbson_mktime64(const struct TM *input_date) { - struct tm safe_date; - struct TM date; - Time64_T time; - Year year = input_date->tm_year + 1900; - - if( cbson_date_in_safe_range(input_date, &SYSTEM_MKTIME_MIN, &SYSTEM_MKTIME_MAX) ) - { - cbson_copy_TM64_to_tm(input_date, &safe_date); - return (Time64_T)mktime(&safe_date); - } - - /* Have to make the year safe in date else it won't fit in safe_date */ - date = *input_date; - date.tm_year = safe_year(year) - 1900; - cbson_copy_TM64_to_tm(&date, &safe_date); - - time = (Time64_T)mktime(&safe_date); - - time += seconds_between_years(year, (Year)(safe_date.tm_year + 1900)); - - return time; -} - - -/* Because I think mktime() is a crappy name */ -Time64_T timelocal64(const struct TM *date) { - return cbson_mktime64(date); -} - - -struct TM *cbson_gmtime64_r (const Time64_T *in_time, struct TM *p) -{ - int v_tm_sec, v_tm_min, v_tm_hour, v_tm_mon, v_tm_wday; - Time64_T v_tm_tday; - int leap; - Time64_T m; - Time64_T time = *in_time; - Year year = 70; - int cycles = 0; - - assert(p != NULL); - -#ifdef USE_SYSTEM_GMTIME - /* Use the system gmtime() if time_t is small enough */ - if( SHOULD_USE_SYSTEM_GMTIME(*in_time) ) { - time_t safe_time = (time_t)*in_time; - struct tm safe_date; - GMTIME_R(&safe_time, &safe_date); - - pymongo_copy_tm_to_TM64(&safe_date, p); - assert(check_tm(p)); - - return p; - } -#endif - -#ifdef HAS_TM_TM_GMTOFF - p->tm_gmtoff = 0; -#endif - p->tm_isdst = 0; - -#ifdef HAS_TM_TM_ZONE - p->tm_zone = "UTC"; -#endif - - v_tm_sec = (int)(time % 60); - time /= 60; - v_tm_min = (int)(time % 60); - time /= 60; - v_tm_hour = (int)(time % 24); - time /= 24; - v_tm_tday = time; - - _TIME64_WRAP (v_tm_sec, v_tm_min, 60); - _TIME64_WRAP (v_tm_min, v_tm_hour, 60); - _TIME64_WRAP (v_tm_hour, v_tm_tday, 24); - - v_tm_wday = (int)((v_tm_tday + 4) % 7); - if (v_tm_wday < 0) - v_tm_wday += 7; - m = v_tm_tday; - - if (m >= CHEAT_DAYS) { - year = CHEAT_YEARS; - m -= CHEAT_DAYS; - } - - if (m >= 0) { - /* Gregorian cycles, this is huge optimization for distant times */ - cycles = (int)(m / (Time64_T) days_in_gregorian_cycle); - if( cycles ) { - m -= (cycles * (Time64_T) days_in_gregorian_cycle); - year += (cycles * years_in_gregorian_cycle); - } - - /* Years */ - leap = IS_LEAP (year); - while (m >= (Time64_T) length_of_year[leap]) { - m -= (Time64_T) length_of_year[leap]; - year++; - leap = IS_LEAP (year); - } - - /* Months */ - v_tm_mon = 0; - while (m >= (Time64_T) days_in_month[leap][v_tm_mon]) { - m -= (Time64_T) days_in_month[leap][v_tm_mon]; - v_tm_mon++; - } - } else { - year--; - - /* Gregorian cycles */ - cycles = (int)((m / (Time64_T) days_in_gregorian_cycle) + 1); - if( cycles ) { - m -= (cycles * (Time64_T) days_in_gregorian_cycle); - year += (cycles * years_in_gregorian_cycle); - } - - /* Years */ - leap = IS_LEAP (year); - while (m < (Time64_T) -length_of_year[leap]) { - m += (Time64_T) length_of_year[leap]; - year--; - leap = IS_LEAP (year); - } - - /* Months */ - v_tm_mon = 11; - while (m < (Time64_T) -days_in_month[leap][v_tm_mon]) { - m += (Time64_T) days_in_month[leap][v_tm_mon]; - v_tm_mon--; - } - m += (Time64_T) days_in_month[leap][v_tm_mon]; - } - - p->tm_year = (int)year; - if( p->tm_year != year ) { -#ifdef EOVERFLOW - errno = EOVERFLOW; -#endif - return NULL; - } - - /* At this point m is less than a year so casting to an int is safe */ - p->tm_mday = (int) m + 1; - p->tm_yday = julian_days_by_month[leap][v_tm_mon] + (int)m; - p->tm_sec = v_tm_sec; - p->tm_min = v_tm_min; - p->tm_hour = v_tm_hour; - p->tm_mon = v_tm_mon; - p->tm_wday = v_tm_wday; - - assert(check_tm(p)); - - return p; -} - - -struct TM *cbson_localtime64_r (const Time64_T *time, struct TM *local_tm) -{ - time_t safe_time; - struct tm safe_date; - struct TM gm_tm; - Year orig_year; - int month_diff; - - assert(local_tm != NULL); - -#ifdef USE_SYSTEM_LOCALTIME - /* Use the system localtime() if time_t is small enough */ - if( SHOULD_USE_SYSTEM_LOCALTIME(*time) ) { - safe_time = (time_t)*time; - - TIME64_TRACE1("Using system localtime for %lld\n", *time); - - LOCALTIME_R(&safe_time, &safe_date); - - pymongo_copy_tm_to_TM64(&safe_date, local_tm); - assert(check_tm(local_tm)); - - return local_tm; - } -#endif - - if( cbson_gmtime64_r(time, &gm_tm) == NULL ) { - TIME64_TRACE1("cbson_gmtime64_r returned null for %lld\n", *time); - return NULL; - } - - orig_year = gm_tm.tm_year; - - if (gm_tm.tm_year > (2037 - 1900) || - gm_tm.tm_year < (1970 - 1900) - ) - { - TIME64_TRACE1("Mapping tm_year %lld to safe_year\n", (Year)gm_tm.tm_year); - gm_tm.tm_year = safe_year((Year)(gm_tm.tm_year + 1900)) - 1900; - } - - safe_time = (time_t)cbson_timegm64(&gm_tm); - if( LOCALTIME_R(&safe_time, &safe_date) == NULL ) { - TIME64_TRACE1("localtime_r(%d) returned NULL\n", (int)safe_time); - return NULL; - } - - pymongo_copy_tm_to_TM64(&safe_date, local_tm); - - local_tm->tm_year = (int)orig_year; - if( local_tm->tm_year != orig_year ) { - TIME64_TRACE2("tm_year overflow: tm_year %lld, orig_year %lld\n", - (Year)local_tm->tm_year, (Year)orig_year); - -#ifdef EOVERFLOW - errno = EOVERFLOW; -#endif - return NULL; - } - - - month_diff = local_tm->tm_mon - gm_tm.tm_mon; - - /* When localtime is Dec 31st previous year and - gmtime is Jan 1st next year. - */ - if( month_diff == 11 ) { - local_tm->tm_year--; - } - - /* When localtime is Jan 1st, next year and - gmtime is Dec 31st, previous year. - */ - if( month_diff == -11 ) { - local_tm->tm_year++; - } - - /* GMT is Jan 1st, xx01 year, but localtime is still Dec 31st - in a non-leap xx00. There is one point in the cycle - we can't account for which the safe xx00 year is a leap - year. So we need to correct for Dec 31st coming out as - the 366th day of the year. - */ - if( !IS_LEAP(local_tm->tm_year) && local_tm->tm_yday == 365 ) - local_tm->tm_yday--; - - assert(check_tm(local_tm)); - - return local_tm; -} - - -int cbson_valid_tm_wday( const struct TM* date ) { - if( 0 <= date->tm_wday && date->tm_wday <= 6 ) - return 1; - else - return 0; -} - -int cbson_valid_tm_mon( const struct TM* date ) { - if( 0 <= date->tm_mon && date->tm_mon <= 11 ) - return 1; - else - return 0; -} - - -/* Non-thread safe versions of the above */ -struct TM *cbson_localtime64(const Time64_T *time) { -#ifdef _MSC_VER - _tzset(); -#else - tzset(); -#endif - return cbson_localtime64_r(time, &Static_Return_Date); -} - -struct TM *cbson_gmtime64(const Time64_T *time) { - return cbson_gmtime64_r(time, &Static_Return_Date); -} diff --git a/bson/time64.h b/bson/time64.h deleted file mode 100644 index 6321eb307e..0000000000 --- a/bson/time64.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef TIME64_H -# define TIME64_H - -#include -#include "time64_config.h" - -/* Set our custom types */ -typedef INT_64_T Int64; -typedef Int64 Time64_T; -typedef Int64 Year; - - -/* A copy of the tm struct but with a 64 bit year */ -struct TM64 { - int tm_sec; - int tm_min; - int tm_hour; - int tm_mday; - int tm_mon; - Year tm_year; - int tm_wday; - int tm_yday; - int tm_isdst; - -#ifdef HAS_TM_TM_GMTOFF - long tm_gmtoff; -#endif - -#ifdef HAS_TM_TM_ZONE - char *tm_zone; -#endif -}; - - -/* Decide which tm struct to use */ -#ifdef USE_TM64 -#define TM TM64 -#else -#define TM tm -#endif - - -/* Declare public functions */ -struct TM *cbson_gmtime64_r (const Time64_T *, struct TM *); -struct TM *cbson_localtime64_r (const Time64_T *, struct TM *); -struct TM *cbson_gmtime64 (const Time64_T *); -struct TM *cbson_localtime64 (const Time64_T *); - -Time64_T cbson_timegm64 (const struct TM *); -Time64_T cbson_mktime64 (const struct TM *); -Time64_T timelocal64 (const struct TM *); - - -/* Not everyone has gm/localtime_r(), provide a replacement */ -#ifdef HAS_LOCALTIME_R -# define LOCALTIME_R(clock, result) localtime_r(clock, result) -#else -# define LOCALTIME_R(clock, result) cbson_fake_localtime_r(clock, result) -#endif -#ifdef HAS_GMTIME_R -# define GMTIME_R(clock, result) gmtime_r(clock, result) -#else -# define GMTIME_R(clock, result) cbson_fake_gmtime_r(clock, result) -#endif - - -#endif diff --git a/bson/time64_config.h b/bson/time64_config.h deleted file mode 100644 index 9d4c111c95..0000000000 --- a/bson/time64_config.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Configuration - ------------- - Define as appropriate for your system. - Sensible defaults provided. -*/ - - -#ifndef TIME64_CONFIG_H -# define TIME64_CONFIG_H - -/* Debugging - TIME_64_DEBUG - Define if you want debugging messages -*/ -/* #define TIME_64_DEBUG */ - - -/* INT_64_T - A 64 bit integer type to use to store time and others. - Must be defined. -*/ -#define INT_64_T long long - - -/* USE_TM64 - Should we use a 64 bit safe replacement for tm? This will - let you go past year 2 billion but the struct will be incompatible - with tm. Conversion functions will be provided. -*/ -/* #define USE_TM64 */ - - -/* Availability of system functions. - - HAS_GMTIME_R - Define if your system has gmtime_r() - - HAS_LOCALTIME_R - Define if your system has localtime_r() - - HAS_TIMEGM - Define if your system has timegm(), a GNU extension. -*/ -#if !defined(WIN32) && !defined(_MSC_VER) -#define HAS_GMTIME_R -#define HAS_LOCALTIME_R -#endif -/* #define HAS_TIMEGM */ - - -/* Details of non-standard tm struct elements. - - HAS_TM_TM_GMTOFF - True if your tm struct has a "tm_gmtoff" element. - A BSD extension. - - HAS_TM_TM_ZONE - True if your tm struct has a "tm_zone" element. - A BSD extension. -*/ -/* #define HAS_TM_TM_GMTOFF */ -/* #define HAS_TM_TM_ZONE */ - - -/* USE_SYSTEM_LOCALTIME - USE_SYSTEM_GMTIME - USE_SYSTEM_MKTIME - USE_SYSTEM_TIMEGM - Should we use the system functions if the time is inside their range? - Your system localtime() is probably more accurate, but our gmtime() is - fast and safe. -*/ -#define USE_SYSTEM_LOCALTIME -/* #define USE_SYSTEM_GMTIME */ -#define USE_SYSTEM_MKTIME -/* #define USE_SYSTEM_TIMEGM */ - -#endif /* TIME64_CONFIG_H */ diff --git a/bson/time64_limits.h b/bson/time64_limits.h deleted file mode 100644 index 1d30607bae..0000000000 --- a/bson/time64_limits.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - Maximum and minimum inputs your system's respective time functions - can correctly handle. time64.h will use your system functions if - the input falls inside these ranges and corresponding USE_SYSTEM_* - constant is defined. -*/ - -#ifndef TIME64_LIMITS_H -#define TIME64_LIMITS_H - -/* Max/min for localtime() */ -#define SYSTEM_LOCALTIME_MAX 2147483647 -#define SYSTEM_LOCALTIME_MIN -2147483647-1 - -/* Max/min for gmtime() */ -#define SYSTEM_GMTIME_MAX 2147483647 -#define SYSTEM_GMTIME_MIN -2147483647-1 - -/* Max/min for mktime() */ -static const struct tm SYSTEM_MKTIME_MAX = { - 7, - 14, - 19, - 18, - 0, - 138, - 1, - 17, - 0 -#ifdef HAS_TM_TM_GMTOFF - ,-28800 -#endif -#ifdef HAS_TM_TM_ZONE - ,"PST" -#endif -}; - -static const struct tm SYSTEM_MKTIME_MIN = { - 52, - 45, - 12, - 13, - 11, - 1, - 5, - 346, - 0 -#ifdef HAS_TM_TM_GMTOFF - ,-28800 -#endif -#ifdef HAS_TM_TM_ZONE - ,"PST" -#endif -}; - -/* Max/min for timegm() */ -#ifdef HAS_TIMEGM -static const struct tm SYSTEM_TIMEGM_MAX = { - 7, - 14, - 3, - 19, - 0, - 138, - 2, - 18, - 0 - #ifdef HAS_TM_TM_GMTOFF - ,0 - #endif - #ifdef HAS_TM_TM_ZONE - ,"UTC" - #endif -}; - -static const struct tm SYSTEM_TIMEGM_MIN = { - 52, - 45, - 20, - 13, - 11, - 1, - 5, - 346, - 0 - #ifdef HAS_TM_TM_GMTOFF - ,0 - #endif - #ifdef HAS_TM_TM_ZONE - ,"UTC" - #endif -}; -#endif /* HAS_TIMEGM */ - -#endif /* TIME64_LIMITS_H */ diff --git a/bson/timestamp.py b/bson/timestamp.py deleted file mode 100644 index c346623604..0000000000 --- a/bson/timestamp.py +++ /dev/null @@ -1,124 +0,0 @@ -# Copyright 2010-2015 MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Tools for representing MongoDB internal Timestamps.""" - -from __future__ import annotations - -import calendar -import datetime -from typing import Any - -from bson._helpers import _getstate_slots, _setstate_slots -from bson.tz_util import utc - -UPPERBOUND = 4294967296 - - -class Timestamp: - """MongoDB internal timestamps used in the opLog.""" - - __slots__ = ("__inc", "__time") - - __getstate__ = _getstate_slots - __setstate__ = _setstate_slots - - _type_marker = 17 - - def __init__(self, time: datetime.datetime | int, inc: int) -> None: - """Create a new :class:`Timestamp`. - - This class is only for use with the MongoDB opLog. If you need - to store a regular timestamp, please use a - :class:`~datetime.datetime`. - - Raises :class:`TypeError` if `time` is not an instance of - :class: `int` or :class:`~datetime.datetime`, or `inc` is not - an instance of :class:`int`. Raises :class:`ValueError` if - `time` or `inc` is not in [0, 2**32). - - :param time: time in seconds since epoch UTC, or a naive UTC - :class:`~datetime.datetime`, or an aware - :class:`~datetime.datetime` - :param inc: the incrementing counter - """ - if isinstance(time, datetime.datetime): - offset = time.utcoffset() - if offset is not None: - time = time - offset - time = int(calendar.timegm(time.timetuple())) - if not isinstance(time, int): - raise TypeError(f"time must be an instance of int, not {type(time)}") - if not isinstance(inc, int): - raise TypeError(f"inc must be an instance of int, not {type(inc)}") - if not 0 <= time < UPPERBOUND: - raise ValueError("time must be contained in [0, 2**32)") - if not 0 <= inc < UPPERBOUND: - raise ValueError("inc must be contained in [0, 2**32)") - - self.__time = time - self.__inc = inc - - @property - def time(self) -> int: - """Get the time portion of this :class:`Timestamp`.""" - return self.__time - - @property - def inc(self) -> int: - """Get the inc portion of this :class:`Timestamp`.""" - return self.__inc - - def __eq__(self, other: object) -> bool: - if isinstance(other, Timestamp): - return self.__time == other.time and self.__inc == other.inc - else: - return NotImplemented - - def __hash__(self) -> int: - return hash(self.time) ^ hash(self.inc) - - def __ne__(self, other: object) -> bool: - return not self == other - - def __lt__(self, other: Any) -> bool: - if isinstance(other, Timestamp): - return (self.time, self.inc) < (other.time, other.inc) - return NotImplemented - - def __le__(self, other: Any) -> bool: - if isinstance(other, Timestamp): - return (self.time, self.inc) <= (other.time, other.inc) - return NotImplemented - - def __gt__(self, other: Any) -> bool: - if isinstance(other, Timestamp): - return (self.time, self.inc) > (other.time, other.inc) - return NotImplemented - - def __ge__(self, other: Any) -> bool: - if isinstance(other, Timestamp): - return (self.time, self.inc) >= (other.time, other.inc) - return NotImplemented - - def __repr__(self) -> str: - return f"Timestamp({self.__time}, {self.__inc})" - - def as_datetime(self) -> datetime.datetime: - """Return a :class:`~datetime.datetime` instance corresponding - to the time portion of this :class:`Timestamp`. - - The returned datetime's timezone is UTC. - """ - return datetime.datetime.fromtimestamp(self.__time, utc) diff --git a/bson/typings.py b/bson/typings.py deleted file mode 100644 index 593cf2c73d..0000000000 --- a/bson/typings.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2023-Present MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Type aliases used by bson""" - -from __future__ import annotations - -from collections.abc import Mapping, MutableMapping -from typing import TYPE_CHECKING, Any, TypeVar, Union - -if TYPE_CHECKING: - from array import array - from mmap import mmap - - from bson.raw_bson import RawBSONDocument - - -# Common Shared Types. -_DocumentOut = Union[MutableMapping[str, Any], "RawBSONDocument"] -_DocumentType = TypeVar("_DocumentType", bound=Mapping[str, Any]) # noqa: PYI018 -_DocumentTypeArg = TypeVar("_DocumentTypeArg", bound=Mapping[str, Any]) # noqa: PYI018 -_ReadableBuffer = Union[bytes, memoryview, bytearray, "mmap", "array"] # type: ignore[type-arg] diff --git a/bson/tz_util.py b/bson/tz_util.py deleted file mode 100644 index 249f1aa38a..0000000000 --- a/bson/tz_util.py +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2010-2015 MongoDB, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Timezone related utilities for BSON.""" - -from __future__ import annotations - -from datetime import datetime, timedelta, tzinfo - -ZERO: timedelta = timedelta(0) - - -class FixedOffset(tzinfo): - """Fixed offset timezone, in minutes east from UTC. - - Implementation based from the Python `standard library documentation - `_. - Defining __getinitargs__ enables pickling / copying. - """ - - def __init__(self, offset: float | timedelta, name: str) -> None: - if isinstance(offset, timedelta): - self.__offset = offset - else: - self.__offset = timedelta(minutes=offset) - self.__name = name - - def __getinitargs__(self) -> tuple[timedelta, str]: - return self.__offset, self.__name - - def __repr__(self) -> str: - return f"{self.__class__.__name__}({self.__offset!r}, {self.__name!r})" - - def utcoffset(self, dt: datetime | None) -> timedelta: - return self.__offset - - def tzname(self, dt: datetime | None) -> str: - return self.__name - - def dst(self, dt: datetime | None) -> timedelta: - return ZERO - - -utc: FixedOffset = FixedOffset(0, "UTC") -"""Fixed offset timezone representing UTC.""" diff --git a/doc/Makefile b/doc/Makefile deleted file mode 100644 index d4bb2cbb9e..0000000000 --- a/doc/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line, and also -# from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/doc/__init__.py b/doc/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/doc/_templates/layout.html b/doc/_templates/layout.html deleted file mode 100644 index 6141284a48..0000000000 --- a/doc/_templates/layout.html +++ /dev/null @@ -1,18 +0,0 @@ -{% extends "!layout.html" %} - -{%- block extrahead %} - - {% if theme_googletag %} - - - - - - {% endif %} -{%- endblock -%} diff --git a/doc/api/bson/binary.rst b/doc/api/bson/binary.rst deleted file mode 100644 index 7084a45b4e..0000000000 --- a/doc/api/bson/binary.rst +++ /dev/null @@ -1,35 +0,0 @@ -:mod:`binary` -- Tools for representing binary data to be stored in MongoDB -=========================================================================== - -.. automodule:: bson.binary - :synopsis: Tools for representing binary data to be stored in MongoDB - - .. autodata:: BINARY_SUBTYPE - .. autodata:: FUNCTION_SUBTYPE - .. autodata:: OLD_BINARY_SUBTYPE - .. autodata:: OLD_UUID_SUBTYPE - .. autodata:: UUID_SUBTYPE - .. autodata:: STANDARD - .. autodata:: PYTHON_LEGACY - .. autodata:: JAVA_LEGACY - .. autodata:: CSHARP_LEGACY - .. autodata:: MD5_SUBTYPE - .. autodata:: COLUMN_SUBTYPE - .. autodata:: SENSITIVE_SUBTYPE - .. autodata:: VECTOR_SUBTYPE - .. autodata:: USER_DEFINED_SUBTYPE - - .. autoclass:: UuidRepresentation - :members: - - .. autoclass:: BinaryVectorDtype - :members: - :show-inheritance: - - .. autoclass:: BinaryVector - :members: - - - .. autoclass:: Binary(data, subtype=BINARY_SUBTYPE) - :members: - :show-inheritance: diff --git a/doc/api/bson/code.rst b/doc/api/bson/code.rst deleted file mode 100644 index 9050196d6a..0000000000 --- a/doc/api/bson/code.rst +++ /dev/null @@ -1,9 +0,0 @@ -:mod:`code` -- Tools for representing JavaScript code -===================================================== - -.. automodule:: bson.code - :synopsis: Tools for representing JavaScript code - - .. autoclass:: Code(code, scope=None, **kwargs) - :members: - :show-inheritance: diff --git a/doc/api/bson/codec_options.rst b/doc/api/bson/codec_options.rst deleted file mode 100644 index bea1358f5f..0000000000 --- a/doc/api/bson/codec_options.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`codec_options` -- Tools for specifying BSON codec options -=============================================================== - -.. automodule:: bson.codec_options - :synopsis: Tools for specifying BSON codec options. - :members: diff --git a/doc/api/bson/datetime_ms.rst b/doc/api/bson/datetime_ms.rst deleted file mode 100644 index 1afaad69fc..0000000000 --- a/doc/api/bson/datetime_ms.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`datetime_ms` -- Support for BSON UTC Datetime -=================================================== - -.. automodule:: bson.datetime_ms - :synopsis: Support for BSON UTC datetimes. - :members: diff --git a/doc/api/bson/dbref.rst b/doc/api/bson/dbref.rst deleted file mode 100644 index 07d50f1b60..0000000000 --- a/doc/api/bson/dbref.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`dbref` -- Tools for manipulating DBRefs (references to documents stored in MongoDB) -========================================================================================= - -.. automodule:: bson.dbref - :synopsis: Tools for manipulating DBRefs (references to documents stored in MongoDB) - :members: diff --git a/doc/api/bson/decimal128.rst b/doc/api/bson/decimal128.rst deleted file mode 100644 index 60ac953046..0000000000 --- a/doc/api/bson/decimal128.rst +++ /dev/null @@ -1,4 +0,0 @@ -:mod:`decimal128` -- Support for BSON Decimal128 -================================================ -.. automodule:: bson.decimal128 - :members: diff --git a/doc/api/bson/errors.rst b/doc/api/bson/errors.rst deleted file mode 100644 index f20174f468..0000000000 --- a/doc/api/bson/errors.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`errors` -- Exceptions raised by the :mod:`bson` package -============================================================= - -.. automodule:: bson.errors - :synopsis: Exceptions raised by the bson package - :members: diff --git a/doc/api/bson/index.rst b/doc/api/bson/index.rst deleted file mode 100644 index d5b69607de..0000000000 --- a/doc/api/bson/index.rst +++ /dev/null @@ -1,29 +0,0 @@ -:mod:`bson` -- BSON (Binary JSON) Encoding and Decoding -======================================================= - -.. automodule:: bson - :synopsis: BSON (Binary JSON) Encoding and Decoding - :members: BSON, decode, decode_all, decode_file_iter, decode_iter, encode, gen_list_name, has_c, is_valid - -Sub-modules: - -.. toctree:: - :maxdepth: 2 - - binary - code - codec_options - datetime_ms - dbref - decimal128 - errors - int64 - json_util - max_key - min_key - objectid - raw_bson - regex - son - timestamp - tz_util diff --git a/doc/api/bson/int64.rst b/doc/api/bson/int64.rst deleted file mode 100644 index a06962d4f0..0000000000 --- a/doc/api/bson/int64.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`int64` -- Tools for representing BSON int64 -================================================= -.. versionadded:: 3.0 - -.. automodule:: bson.int64 - :synopsis: Tools for representing BSON int64 - :members: diff --git a/doc/api/bson/json_util.rst b/doc/api/bson/json_util.rst deleted file mode 100644 index f8dd50e0d3..0000000000 --- a/doc/api/bson/json_util.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`json_util` -- Tools for using Python's :mod:`json` module with BSON documents -=================================================================================== -.. automodule:: bson.json_util - :synopsis: Tools for using Python's json module with BSON documents - :members: - :undoc-members: - :member-order: bysource diff --git a/doc/api/bson/max_key.rst b/doc/api/bson/max_key.rst deleted file mode 100644 index 96ab58d1d6..0000000000 --- a/doc/api/bson/max_key.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`max_key` -- Representation for the MongoDB internal MaxKey type -===================================================================== -.. automodule:: bson.max_key - :synopsis: Representation for the MongoDB internal MaxKey type - :members: diff --git a/doc/api/bson/min_key.rst b/doc/api/bson/min_key.rst deleted file mode 100644 index 7539bbb403..0000000000 --- a/doc/api/bson/min_key.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`min_key` -- Representation for the MongoDB internal MinKey type -===================================================================== -.. automodule:: bson.min_key - :synopsis: Representation for the MongoDB internal MinKey type - :members: diff --git a/doc/api/bson/objectid.rst b/doc/api/bson/objectid.rst deleted file mode 100644 index 8f8ef066d9..0000000000 --- a/doc/api/bson/objectid.rst +++ /dev/null @@ -1,27 +0,0 @@ -:mod:`objectid` -- Tools for working with MongoDB ObjectIds -=========================================================== - -.. automodule:: bson.objectid - :synopsis: Tools for working with MongoDB ObjectIds - - .. autoclass:: bson.objectid.ObjectId(oid=None) - :members: - - .. describe:: str(o) - - Get a hex encoded version of :class:`ObjectId` `o`. - - The following property always holds: - - .. testsetup:: - - from bson.objectid import ObjectId - - .. doctest:: - - >>> o = ObjectId() - >>> o == ObjectId(str(o)) - True - - This representation is useful for urls or other places where - ``o.binary`` is inappropriate. diff --git a/doc/api/bson/raw_bson.rst b/doc/api/bson/raw_bson.rst deleted file mode 100644 index d4f9fbbb5b..0000000000 --- a/doc/api/bson/raw_bson.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`raw_bson` -- Tools for representing raw BSON documents. -============================================================= -.. automodule:: bson.raw_bson - :synopsis: Tools for representing raw BSON documents. - :members: diff --git a/doc/api/bson/regex.rst b/doc/api/bson/regex.rst deleted file mode 100644 index 3a56037741..0000000000 --- a/doc/api/bson/regex.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`regex` -- Tools for representing MongoDB regular expressions -================================================================== -.. versionadded:: 2.7 - -.. automodule:: bson.regex - :synopsis: Tools for representing MongoDB regular expressions - :members: diff --git a/doc/api/bson/son.rst b/doc/api/bson/son.rst deleted file mode 100644 index eae68e86f7..0000000000 --- a/doc/api/bson/son.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`son` -- Tools for working with SON, an ordered mapping -============================================================ - -.. automodule:: bson.son - :synopsis: Tools for working with SON, an ordered mapping - :members: diff --git a/doc/api/bson/timestamp.rst b/doc/api/bson/timestamp.rst deleted file mode 100644 index 375d3dc9cd..0000000000 --- a/doc/api/bson/timestamp.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`timestamp` -- Tools for representing MongoDB internal Timestamps -====================================================================== -.. automodule:: bson.timestamp - :synopsis: Tools for representing MongoDB internal Timestamps - :members: diff --git a/doc/api/bson/tz_util.rst b/doc/api/bson/tz_util.rst deleted file mode 100644 index 653367fd11..0000000000 --- a/doc/api/bson/tz_util.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`tz_util` -- Utilities for dealing with timezones in Python -================================================================ - -.. automodule:: bson.tz_util - :synopsis: Utilities for dealing with timezones in Python - :members: diff --git a/doc/api/gridfs/asynchronous/grid_file.rst b/doc/api/gridfs/asynchronous/grid_file.rst deleted file mode 100644 index fbf34adc8a..0000000000 --- a/doc/api/gridfs/asynchronous/grid_file.rst +++ /dev/null @@ -1,19 +0,0 @@ -:mod:`grid_file` -- Async tools for representing files stored in GridFS -======================================================================= - -.. automodule:: gridfs.asynchronous.grid_file - :synopsis: Async tools for representing files stored in GridFS - - .. autoclass:: AsyncGridIn - :members: - - .. autoattribute:: _id - - .. autoclass:: AsyncGridOut - :members: - - .. autoattribute:: _id - .. automethod:: __aiter__ - - .. autoclass:: AsyncGridOutCursor - :members: diff --git a/doc/api/gridfs/asynchronous/index.rst b/doc/api/gridfs/asynchronous/index.rst deleted file mode 100644 index 7b6ebb28b8..0000000000 --- a/doc/api/gridfs/asynchronous/index.rst +++ /dev/null @@ -1,14 +0,0 @@ -:mod:`gridfs async` -- Async tools for working with GridFS -========================================================== - - -.. automodule:: gridfs.asynchronous - :synopsis: Async tools for working with GridFS - :members: AsyncGridFS, AsyncGridFSBucket - -Sub-modules: - -.. toctree:: - :maxdepth: 2 - - grid_file diff --git a/doc/api/gridfs/errors.rst b/doc/api/gridfs/errors.rst deleted file mode 100644 index a7c41f6b90..0000000000 --- a/doc/api/gridfs/errors.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`errors` -- Exceptions raised by the :mod:`gridfs` package -================================================================= - -.. automodule:: gridfs.errors - :synopsis: Exceptions raised by the gridfs package - :members: diff --git a/doc/api/gridfs/grid_file.rst b/doc/api/gridfs/grid_file.rst deleted file mode 100644 index 59f4d03f5d..0000000000 --- a/doc/api/gridfs/grid_file.rst +++ /dev/null @@ -1,19 +0,0 @@ -:mod:`grid_file` -- Tools for representing files stored in GridFS -================================================================= - -.. automodule:: gridfs.grid_file - :synopsis: Tools for representing files stored in GridFS - - .. autoclass:: GridIn - :members: - - .. autoattribute:: _id - - .. autoclass:: GridOut - :members: - - .. autoattribute:: _id - .. automethod:: __iter__ - - .. autoclass:: GridOutCursor - :members: diff --git a/doc/api/gridfs/index.rst b/doc/api/gridfs/index.rst deleted file mode 100644 index 190c561d05..0000000000 --- a/doc/api/gridfs/index.rst +++ /dev/null @@ -1,15 +0,0 @@ -:mod:`gridfs` -- Tools for working with GridFS -============================================== - -.. automodule:: gridfs - :synopsis: Tools for working with GridFS - :members: GridFS, GridFSBucket - -Sub-modules: - -.. toctree:: - :maxdepth: 3 - - asynchronous/index - errors - grid_file diff --git a/doc/api/index.rst b/doc/api/index.rst deleted file mode 100644 index 339f5843bf..0000000000 --- a/doc/api/index.rst +++ /dev/null @@ -1,17 +0,0 @@ -API Documentation -================= - -The PyMongo distribution contains three top-level packages for -interacting with MongoDB. :mod:`bson` is an implementation of the -`BSON format `_, :mod:`pymongo` is a -full-featured driver for MongoDB, and :mod:`gridfs` is a set of tools -for working with the `GridFS -`_ storage -specification. - -.. toctree:: - :maxdepth: 2 - - bson/index - pymongo/index - gridfs/index diff --git a/doc/api/pymongo/asynchronous/change_stream.rst b/doc/api/pymongo/asynchronous/change_stream.rst deleted file mode 100644 index 8d13586c3f..0000000000 --- a/doc/api/pymongo/asynchronous/change_stream.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`change_stream` -- Watch changes on a collection, database, or cluster -=========================================================================== - - -.. automodule:: pymongo.asynchronous.change_stream - :members: - :inherited-members: diff --git a/doc/api/pymongo/asynchronous/client_session.rst b/doc/api/pymongo/asynchronous/client_session.rst deleted file mode 100644 index 0c784c45d0..0000000000 --- a/doc/api/pymongo/asynchronous/client_session.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`client_session` -- Logical sessions for sequential operations -=================================================================== - - -.. automodule:: pymongo.asynchronous.client_session - :members: - :inherited-members: diff --git a/doc/api/pymongo/asynchronous/collection.rst b/doc/api/pymongo/asynchronous/collection.rst deleted file mode 100644 index 779295ced1..0000000000 --- a/doc/api/pymongo/asynchronous/collection.rst +++ /dev/null @@ -1,62 +0,0 @@ -:mod:`collection` -- Collection level operations -================================================ - - -.. automodule:: pymongo.asynchronous.collection - :synopsis: Collection level operations - - .. autoclass:: pymongo.asynchronous.collection.ReturnDocument - - .. autoclass:: pymongo.asynchronous.collection.AsyncCollection(database, name, create=False, **kwargs) - - .. describe:: c[name] || c.name - - Get the `name` sub-collection of :class:`AsyncCollection` `c`. - - Raises :class:`~pymongo.asynchronous.errors.InvalidName` if an invalid - collection name is used. - - .. autoattribute:: full_name - .. autoattribute:: name - .. autoattribute:: database - .. autoattribute:: codec_options - .. autoattribute:: read_preference - .. autoattribute:: write_concern - .. autoattribute:: read_concern - .. automethod:: with_options - .. automethod:: bulk_write - .. automethod:: insert_one - .. automethod:: insert_many - .. automethod:: replace_one - .. automethod:: update_one - .. automethod:: update_many - .. automethod:: delete_one - .. automethod:: delete_many - .. automethod:: aggregate - .. automethod:: aggregate_raw_batches - .. automethod:: watch - .. automethod:: find(filter=None, projection=None, skip=0, limit=0, no_cursor_timeout=False, cursor_type=CursorType.NON_TAILABLE, sort=None, allow_partial_results=False, oplog_replay=False, batch_size=0, collation=None, hint=None, max_scan=None, max_time_ms=None, max=None, min=None, return_key=False, show_record_id=False, snapshot=False, comment=None, session=None, allow_disk_use=None) - .. automethod:: find_raw_batches(filter=None, projection=None, skip=0, limit=0, no_cursor_timeout=False, cursor_type=CursorType.NON_TAILABLE, sort=None, allow_partial_results=False, oplog_replay=False, batch_size=0, collation=None, hint=None, max_scan=None, max_time_ms=None, max=None, min=None, return_key=False, show_record_id=False, snapshot=False, comment=None, session=None, allow_disk_use=None) - .. automethod:: find_one(filter=None, *args, **kwargs) - .. automethod:: find_one_and_delete - .. automethod:: find_one_and_replace(filter, replacement, projection=None, sort=None, return_document=ReturnDocument.BEFORE, hint=None, session=None, **kwargs) - .. automethod:: find_one_and_update(filter, update, projection=None, sort=None, return_document=ReturnDocument.BEFORE, array_filters=None, hint=None, session=None, **kwargs) - .. automethod:: count_documents - .. automethod:: estimated_document_count - .. automethod:: distinct - .. automethod:: create_index - .. automethod:: create_indexes - .. automethod:: drop_index - .. automethod:: drop_indexes - .. automethod:: list_indexes - .. automethod:: index_information - .. automethod:: create_search_index - .. automethod:: create_search_indexes - .. automethod:: drop_search_index - .. automethod:: list_search_indexes - .. automethod:: update_search_index - .. automethod:: drop - .. automethod:: rename - .. automethod:: options - .. automethod:: __getitem__ - .. automethod:: __getattr__ diff --git a/doc/api/pymongo/asynchronous/command_cursor.rst b/doc/api/pymongo/asynchronous/command_cursor.rst deleted file mode 100644 index 73488d1dab..0000000000 --- a/doc/api/pymongo/asynchronous/command_cursor.rst +++ /dev/null @@ -1,8 +0,0 @@ -:mod:`command_cursor` -- Tools for iterating over MongoDB command results -========================================================================= - - -.. automodule:: pymongo.asynchronous.command_cursor - :synopsis: Tools for iterating over MongoDB command results - :members: - :inherited-members: diff --git a/doc/api/pymongo/asynchronous/cursor.rst b/doc/api/pymongo/asynchronous/cursor.rst deleted file mode 100644 index 635805c2af..0000000000 --- a/doc/api/pymongo/asynchronous/cursor.rst +++ /dev/null @@ -1,19 +0,0 @@ -:mod:`cursor` -- Tools for iterating over MongoDB query results -=============================================================== - - -.. automodule:: pymongo.asynchronous.cursor - :synopsis: Tools for iterating over MongoDB query results - - .. autoclass:: pymongo.asynchronous.cursor.AsyncCursor(collection, filter=None, projection=None, skip=0, limit=0, no_cursor_timeout=False, cursor_type=CursorType.NON_TAILABLE, sort=None, allow_partial_results=False, oplog_replay=False, batch_size=0, collation=None, hint=None, max_scan=None, max_time_ms=None, max=None, min=None, return_key=False, show_record_id=False, snapshot=False, comment=None, session=None, allow_disk_use=None) - :members: - :inherited-members: - - - .. describe:: c[index] - - See :meth:`__getitem__` and read the warning. - - .. automethod:: __getitem__ - - .. autoclass:: pymongo.asynchronous.cursor.AsyncRawBatchCursor(collection, filter=None, projection=None, skip=0, limit=0, no_cursor_timeout=False, cursor_type=CursorType.NON_TAILABLE, sort=None, allow_partial_results=False, oplog_replay=False, batch_size=0, collation=None, hint=None, max_scan=None, max_time_ms=None, max=None, min=None, return_key=False, show_record_id=False, snapshot=False, comment=None, allow_disk_use=None) diff --git a/doc/api/pymongo/asynchronous/database.rst b/doc/api/pymongo/asynchronous/database.rst deleted file mode 100644 index 7b043ab0d1..0000000000 --- a/doc/api/pymongo/asynchronous/database.rst +++ /dev/null @@ -1,27 +0,0 @@ -:mod:`database` -- Database level operations -============================================ - - -.. automodule:: pymongo.asynchronous.database - :synopsis: Database level operations - - .. autoclass:: pymongo.asynchronous.database.AsyncDatabase - :members: - - .. describe:: db[collection_name] || db.collection_name - - Get the `collection_name` :class:`~pymongo.asynchronous.collection.AsyncCollection` of - :class:`AsyncDatabase` `db`. - - Raises :class:`~pymongo.errors.InvalidName` if an invalid collection - name is used. - - .. note:: Use dictionary style access if `collection_name` is an - attribute of the :class:`AsyncDatabase` class eg: db[`collection_name`]. - - .. automethod:: __getitem__ - .. automethod:: __getattr__ - .. autoattribute:: codec_options - .. autoattribute:: read_preference - .. autoattribute:: write_concern - .. autoattribute:: read_concern diff --git a/doc/api/pymongo/asynchronous/index.rst b/doc/api/pymongo/asynchronous/index.rst deleted file mode 100644 index b7fc985415..0000000000 --- a/doc/api/pymongo/asynchronous/index.rst +++ /dev/null @@ -1,23 +0,0 @@ -:mod:`pymongo async` -- Async Python driver for MongoDB -======================================================= - - -.. automodule:: pymongo.asynchronous - :synopsis: Asynchronous Python driver for MongoDB - - .. data:: AsyncMongoClient - - Alias for :class:`pymongo.asynchronous.mongo_client.MongoClient`. - -Sub-modules: - -.. toctree:: - :maxdepth: 2 - - change_stream - client_session - collection - command_cursor - cursor - database - mongo_client diff --git a/doc/api/pymongo/asynchronous/mongo_client.rst b/doc/api/pymongo/asynchronous/mongo_client.rst deleted file mode 100644 index 899ca687d5..0000000000 --- a/doc/api/pymongo/asynchronous/mongo_client.rst +++ /dev/null @@ -1,41 +0,0 @@ -:mod:`mongo_client` -- Tools for connecting to MongoDB -====================================================== - - -.. automodule:: pymongo.asynchronous.mongo_client - :synopsis: Tools for connecting to MongoDB - - .. autoclass:: pymongo.asynchronous.mongo_client.AsyncMongoClient(host='localhost', port=27017, document_class=dict, tz_aware=False, connect=True, **kwargs) - - .. automethod:: close - - .. describe:: c[db_name] || c.db_name - - Get the `db_name` :class:`~pymongo.asynchronous.database.AsyncDatabase` on :class:`AsyncMongoClient` `c`. - - Raises :class:`~pymongo.errors.InvalidName` if an invalid database name is used. - - .. autoattribute:: topology_description - .. autoattribute:: address - .. autoattribute:: primary - .. autoattribute:: secondaries - .. autoattribute:: arbiters - .. autoattribute:: is_primary - .. autoattribute:: is_mongos - .. autoattribute:: nodes - .. autoattribute:: codec_options - .. autoattribute:: read_preference - .. autoattribute:: write_concern - .. autoattribute:: read_concern - .. autoattribute:: options - .. automethod:: start_session - .. automethod:: list_databases - .. automethod:: list_database_names - .. automethod:: drop_database - .. automethod:: get_default_database - .. automethod:: get_database - .. automethod:: server_info - .. automethod:: watch - .. automethod:: bulk_write - .. automethod:: __getitem__ - .. automethod:: __getattr__ diff --git a/doc/api/pymongo/auth_oidc.rst b/doc/api/pymongo/auth_oidc.rst deleted file mode 100644 index 1466b21e9d..0000000000 --- a/doc/api/pymongo/auth_oidc.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`auth_oidc` -- MONGODB-OIDC Authentication -=========================================================================== - -.. automodule:: pymongo.auth_oidc - :members: diff --git a/doc/api/pymongo/change_stream.rst b/doc/api/pymongo/change_stream.rst deleted file mode 100644 index 16d243d318..0000000000 --- a/doc/api/pymongo/change_stream.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`change_stream` -- Watch changes on a collection, database, or cluster -=========================================================================== - -.. automodule:: pymongo.change_stream - :members: - :inherited-members: diff --git a/doc/api/pymongo/client_options.rst b/doc/api/pymongo/client_options.rst deleted file mode 100644 index 3ffc10bad6..0000000000 --- a/doc/api/pymongo/client_options.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`client_options` -- Read only configuration options for a MongoClient. -=========================================================================== - -.. automodule:: pymongo.client_options - - .. autoclass:: pymongo.client_options.ClientOptions() - :members: diff --git a/doc/api/pymongo/client_session.rst b/doc/api/pymongo/client_session.rst deleted file mode 100644 index 3c9e067b1d..0000000000 --- a/doc/api/pymongo/client_session.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`client_session` -- Logical sessions for sequential operations -=================================================================== - -.. automodule:: pymongo.client_session - :members: - :inherited-members: diff --git a/doc/api/pymongo/collation.rst b/doc/api/pymongo/collation.rst deleted file mode 100644 index 02a4aa42d7..0000000000 --- a/doc/api/pymongo/collation.rst +++ /dev/null @@ -1,19 +0,0 @@ -:mod:`collation` -- Tools for working with collations. -====================================================== - -.. automodule:: pymongo.collation - :synopsis: Tools for working with collations. - - .. autoclass:: pymongo.collation.Collation - .. autoclass:: pymongo.collation.CollationStrength - :members: - :member-order: bysource - .. autoclass:: pymongo.collation.CollationAlternate - :members: - :member-order: bysource - .. autoclass:: pymongo.collation.CollationCaseFirst - :members: - :member-order: bysource - .. autoclass:: pymongo.collation.CollationMaxVariable - :members: - :member-order: bysource diff --git a/doc/api/pymongo/collection.rst b/doc/api/pymongo/collection.rst deleted file mode 100644 index e3746c68b7..0000000000 --- a/doc/api/pymongo/collection.rst +++ /dev/null @@ -1,73 +0,0 @@ -:mod:`collection` -- Collection level operations -================================================ - -.. automodule:: pymongo.collection - :synopsis: Collection level operations - - .. autodata:: pymongo.ASCENDING - .. autodata:: pymongo.DESCENDING - .. autodata:: pymongo.GEO2D - .. autodata:: pymongo.GEOSPHERE - .. autodata:: pymongo.HASHED - .. autodata:: pymongo.TEXT - - .. autoclass:: pymongo.collection.ReturnDocument - - .. autoattribute:: BEFORE - :annotation: - .. autoattribute:: AFTER - :annotation: - - .. autoclass:: pymongo.collection.Collection(database, name, create=False, **kwargs) - - .. describe:: c[name] || c.name - - Get the `name` sub-collection of :class:`Collection` `c`. - - Raises :class:`~pymongo.errors.InvalidName` if an invalid - collection name is used. - - .. autoattribute:: full_name - .. autoattribute:: name - .. autoattribute:: database - .. autoattribute:: codec_options - .. autoattribute:: read_preference - .. autoattribute:: write_concern - .. autoattribute:: read_concern - .. automethod:: with_options - .. automethod:: bulk_write - .. automethod:: insert_one - .. automethod:: insert_many - .. automethod:: replace_one - .. automethod:: update_one - .. automethod:: update_many - .. automethod:: delete_one - .. automethod:: delete_many - .. automethod:: aggregate - .. automethod:: aggregate_raw_batches - .. automethod:: watch - .. automethod:: find(filter=None, projection=None, skip=0, limit=0, no_cursor_timeout=False, cursor_type=CursorType.NON_TAILABLE, sort=None, allow_partial_results=False, oplog_replay=False, batch_size=0, collation=None, hint=None, max_scan=None, max_time_ms=None, max=None, min=None, return_key=False, show_record_id=False, snapshot=False, comment=None, session=None, allow_disk_use=None) - .. automethod:: find_raw_batches(filter=None, projection=None, skip=0, limit=0, no_cursor_timeout=False, cursor_type=CursorType.NON_TAILABLE, sort=None, allow_partial_results=False, oplog_replay=False, batch_size=0, collation=None, hint=None, max_scan=None, max_time_ms=None, max=None, min=None, return_key=False, show_record_id=False, snapshot=False, comment=None, session=None, allow_disk_use=None) - .. automethod:: find_one(filter=None, *args, **kwargs) - .. automethod:: find_one_and_delete - .. automethod:: find_one_and_replace(filter, replacement, projection=None, sort=None, return_document=ReturnDocument.BEFORE, hint=None, session=None, **kwargs) - .. automethod:: find_one_and_update(filter, update, projection=None, sort=None, return_document=ReturnDocument.BEFORE, array_filters=None, hint=None, session=None, **kwargs) - .. automethod:: count_documents - .. automethod:: estimated_document_count - .. automethod:: distinct - .. automethod:: create_index - .. automethod:: create_indexes - .. automethod:: drop_index - .. automethod:: drop_indexes - .. automethod:: list_indexes - .. automethod:: index_information - .. automethod:: create_search_index - .. automethod:: create_search_indexes - .. automethod:: drop_search_index - .. automethod:: list_search_indexes - .. automethod:: update_search_index - .. automethod:: drop - .. automethod:: rename - .. automethod:: options - .. automethod:: __getitem__ - .. automethod:: __getattr__ diff --git a/doc/api/pymongo/command_cursor.rst b/doc/api/pymongo/command_cursor.rst deleted file mode 100644 index b6cc78905a..0000000000 --- a/doc/api/pymongo/command_cursor.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`command_cursor` -- Tools for iterating over MongoDB command results -========================================================================= - -.. automodule:: pymongo.command_cursor - :synopsis: Tools for iterating over MongoDB command results - :members: - :inherited-members: diff --git a/doc/api/pymongo/cursor.rst b/doc/api/pymongo/cursor.rst deleted file mode 100644 index 2eb14c9cb7..0000000000 --- a/doc/api/pymongo/cursor.rst +++ /dev/null @@ -1,28 +0,0 @@ -:mod:`cursor` -- Tools for iterating over MongoDB query results -=============================================================== - -.. automodule:: pymongo.cursor - :synopsis: Tools for iterating over MongoDB query results - - .. autoclass:: pymongo.cursor.CursorType - - .. autoattribute:: NON_TAILABLE - :annotation: - .. autoattribute:: TAILABLE - :annotation: - .. autoattribute:: TAILABLE_AWAIT - :annotation: - .. autoattribute:: EXHAUST - :annotation: - - .. autoclass:: pymongo.cursor.Cursor(collection, filter=None, projection=None, skip=0, limit=0, no_cursor_timeout=False, cursor_type=CursorType.NON_TAILABLE, sort=None, allow_partial_results=False, oplog_replay=False, batch_size=0, collation=None, hint=None, max_scan=None, max_time_ms=None, max=None, min=None, return_key=False, show_record_id=False, snapshot=False, comment=None, session=None, allow_disk_use=None) - :members: - :inherited-members: - - .. describe:: c[index] - - See :meth:`__getitem__` and read the warning. - - .. automethod:: __getitem__ - - .. autoclass:: pymongo.cursor.RawBatchCursor(collection, filter=None, projection=None, skip=0, limit=0, no_cursor_timeout=False, cursor_type=CursorType.NON_TAILABLE, sort=None, allow_partial_results=False, oplog_replay=False, batch_size=0, collation=None, hint=None, max_scan=None, max_time_ms=None, max=None, min=None, return_key=False, show_record_id=False, snapshot=False, comment=None, allow_disk_use=None) diff --git a/doc/api/pymongo/database.rst b/doc/api/pymongo/database.rst deleted file mode 100644 index 044e04971e..0000000000 --- a/doc/api/pymongo/database.rst +++ /dev/null @@ -1,28 +0,0 @@ -:mod:`database` -- Database level operations -============================================ - -.. automodule:: pymongo.database - :synopsis: Database level operations - - .. autodata:: pymongo.auth.MECHANISMS - - .. autoclass:: pymongo.database.Database - :members: - - .. describe:: db[collection_name] || db.collection_name - - Get the `collection_name` :class:`~pymongo.collection.Collection` of - :class:`Database` `db`. - - Raises :class:`~pymongo.errors.InvalidName` if an invalid collection - name is used. - - .. note:: Use dictionary style access if `collection_name` is an - attribute of the :class:`Database` class eg: db[`collection_name`]. - - .. automethod:: __getitem__ - .. automethod:: __getattr__ - .. autoattribute:: codec_options - .. autoattribute:: read_preference - .. autoattribute:: write_concern - .. autoattribute:: read_concern diff --git a/doc/api/pymongo/driver_info.rst b/doc/api/pymongo/driver_info.rst deleted file mode 100644 index 9e6f735577..0000000000 --- a/doc/api/pymongo/driver_info.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`driver_info` -================== - -.. automodule:: pymongo.driver_info - - .. autoclass:: pymongo.driver_info.DriverInfo(name=None, version=None, platform=None) diff --git a/doc/api/pymongo/encryption.rst b/doc/api/pymongo/encryption.rst deleted file mode 100644 index 3a8c3c5cc4..0000000000 --- a/doc/api/pymongo/encryption.rst +++ /dev/null @@ -1,5 +0,0 @@ -:mod:`encryption` -- Client-Side Field Level Encryption -======================================================= - -.. automodule:: pymongo.encryption - :members: diff --git a/doc/api/pymongo/encryption_options.rst b/doc/api/pymongo/encryption_options.rst deleted file mode 100644 index b8a886ea68..0000000000 --- a/doc/api/pymongo/encryption_options.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`encryption_options` -- Automatic Client-Side Field Level Encryption -========================================================================= - -.. automodule:: pymongo.encryption_options - :synopsis: Support for automatic client-side field level encryption - :members: diff --git a/doc/api/pymongo/errors.rst b/doc/api/pymongo/errors.rst deleted file mode 100644 index d395f9a898..0000000000 --- a/doc/api/pymongo/errors.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`errors` -- Exceptions raised by the :mod:`pymongo` package -================================================================ - -.. automodule:: pymongo.errors - :synopsis: Exceptions raised by the pymongo package - :members: diff --git a/doc/api/pymongo/event_loggers.rst b/doc/api/pymongo/event_loggers.rst deleted file mode 100644 index 9be0779c20..0000000000 --- a/doc/api/pymongo/event_loggers.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`event_loggers` -- Example loggers -=========================================== - - -.. automodule:: pymongo.event_loggers - :synopsis: A collection of simple listeners for monitoring driver events. - :members: diff --git a/doc/api/pymongo/index.rst b/doc/api/pymongo/index.rst deleted file mode 100644 index 4fb6c81568..0000000000 --- a/doc/api/pymongo/index.rst +++ /dev/null @@ -1,62 +0,0 @@ -:mod:`pymongo` -- Python driver for MongoDB -=========================================== - -.. automodule:: pymongo - :synopsis: Python driver for MongoDB - - .. autodata:: version - .. data:: MongoClient - - Alias for :class:`pymongo.mongo_client.MongoClient`. - - .. data:: AsyncMongoClient - - Alias for :class:`pymongo.asynchronous.mongo_client.AsyncMongoClient`. - - .. data:: ReadPreference - - Alias for :class:`pymongo.read_preferences.ReadPreference`. - - .. autofunction:: has_c - .. data:: MIN_SUPPORTED_WIRE_VERSION - - The minimum wire protocol version PyMongo supports. - - .. data:: MAX_SUPPORTED_WIRE_VERSION - - The maximum wire protocol version PyMongo supports. - - .. autofunction:: timeout - -Sub-modules: - -.. toctree:: - :maxdepth: 3 - - asynchronous/index - auth_oidc - change_stream - client_options - client_session - collation - collection - command_cursor - cursor - database - driver_info - encryption - encryption_options - errors - mongo_client - monitoring - operations - pool - read_concern - read_preferences - results - server_api - server_description - topology_description - uri_parser - write_concern - event_loggers diff --git a/doc/api/pymongo/mongo_client.rst b/doc/api/pymongo/mongo_client.rst deleted file mode 100644 index 0409e7ef68..0000000000 --- a/doc/api/pymongo/mongo_client.rst +++ /dev/null @@ -1,40 +0,0 @@ -:mod:`mongo_client` -- Tools for connecting to MongoDB -====================================================== - -.. automodule:: pymongo.mongo_client - :synopsis: Tools for connecting to MongoDB - - .. autoclass:: pymongo.mongo_client.MongoClient(host='localhost', port=27017, document_class=dict, tz_aware=False, connect=True, **kwargs) - - .. automethod:: close - - .. describe:: c[db_name] || c.db_name - - Get the `db_name` :class:`~pymongo.database.Database` on :class:`MongoClient` `c`. - - Raises :class:`~pymongo.errors.InvalidName` if an invalid database name is used. - - .. autoattribute:: topology_description - .. autoattribute:: address - .. autoattribute:: primary - .. autoattribute:: secondaries - .. autoattribute:: arbiters - .. autoattribute:: is_primary - .. autoattribute:: is_mongos - .. autoattribute:: nodes - .. autoattribute:: codec_options - .. autoattribute:: read_preference - .. autoattribute:: write_concern - .. autoattribute:: read_concern - .. autoattribute:: options - .. automethod:: start_session - .. automethod:: list_databases - .. automethod:: list_database_names - .. automethod:: drop_database - .. automethod:: get_default_database - .. automethod:: get_database - .. automethod:: server_info - .. automethod:: watch - .. automethod:: bulk_write - .. automethod:: __getitem__ - .. automethod:: __getattr__ diff --git a/doc/api/pymongo/monitoring.rst b/doc/api/pymongo/monitoring.rst deleted file mode 100644 index 6ee48173aa..0000000000 --- a/doc/api/pymongo/monitoring.rst +++ /dev/null @@ -1,99 +0,0 @@ -:mod:`monitoring` -- Tools for monitoring driver events. -======================================================== - -.. automodule:: pymongo.monitoring - :synopsis: Tools for monitoring driver events. - - .. autofunction:: register(listener) - .. autoclass:: CommandListener - :members: - :inherited-members: - .. autoclass:: ServerListener - :members: - :inherited-members: - .. autoclass:: ServerHeartbeatListener - :members: - :inherited-members: - .. autoclass:: TopologyListener - :members: - :inherited-members: - .. autoclass:: ConnectionPoolListener - :members: - :inherited-members: - - .. autoclass:: CommandStartedEvent - :members: - :inherited-members: - .. autoclass:: CommandSucceededEvent - :members: - :inherited-members: - .. autoclass:: CommandFailedEvent - :members: - :inherited-members: - .. autoclass:: ServerDescriptionChangedEvent - :members: - :inherited-members: - .. autoclass:: ServerOpeningEvent - :members: - :inherited-members: - .. autoclass:: ServerClosedEvent - :members: - :inherited-members: - .. autoclass:: TopologyDescriptionChangedEvent - :members: - :inherited-members: - .. autoclass:: TopologyOpenedEvent - :members: - :inherited-members: - .. autoclass:: TopologyClosedEvent - :members: - :inherited-members: - .. autoclass:: ServerHeartbeatStartedEvent - :members: - :inherited-members: - .. autoclass:: ServerHeartbeatSucceededEvent - :members: - :inherited-members: - .. autoclass:: ServerHeartbeatFailedEvent - :members: - :inherited-members: - - .. autoclass:: PoolCreatedEvent - :members: - :inherited-members: - .. autoclass:: PoolClearedEvent - :members: - :inherited-members: - .. autoclass:: PoolClosedEvent - :members: - :inherited-members: - - .. autoclass:: ConnectionCreatedEvent - :members: - :inherited-members: - .. autoclass:: ConnectionReadyEvent - :members: - :inherited-members: - - .. autoclass:: ConnectionClosedReason - :members: - - .. autoclass:: ConnectionClosedEvent - :members: - :inherited-members: - .. autoclass:: ConnectionCheckOutStartedEvent - :members: - :inherited-members: - - .. autoclass:: ConnectionCheckOutFailedReason - :members: - - .. autoclass:: ConnectionCheckOutFailedEvent - :members: - :inherited-members: - .. autoclass:: ConnectionCheckedOutEvent - :members: - :inherited-members: - .. autoclass:: ConnectionCheckedInEvent - :members: - :inherited-members: diff --git a/doc/api/pymongo/operations.rst b/doc/api/pymongo/operations.rst deleted file mode 100644 index e4ab1b9a86..0000000000 --- a/doc/api/pymongo/operations.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`operations` -- Operation class definitions -================================================ - -.. automodule:: pymongo.operations - :synopsis: Operation class definitions - :members: diff --git a/doc/api/pymongo/pool.rst b/doc/api/pymongo/pool.rst deleted file mode 100644 index 78274e8f8b..0000000000 --- a/doc/api/pymongo/pool.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`pool` -- Pool module for use with a MongoDB client. -============================================================== - -.. automodule:: pymongo.pool - - .. autoclass:: pymongo.pool.PoolOptions() - :members: diff --git a/doc/api/pymongo/read_concern.rst b/doc/api/pymongo/read_concern.rst deleted file mode 100644 index 378058abab..0000000000 --- a/doc/api/pymongo/read_concern.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`read_concern` -- Tools for working with read concern. -=========================================================== - -.. automodule:: pymongo.read_concern - :synopsis: Tools for working with read concern. - :members: - :inherited-members: diff --git a/doc/api/pymongo/read_preferences.rst b/doc/api/pymongo/read_preferences.rst deleted file mode 100644 index 7605264394..0000000000 --- a/doc/api/pymongo/read_preferences.rst +++ /dev/null @@ -1,31 +0,0 @@ -:mod:`read_preferences` -- Utilities for choosing which member of a replica set to read from. -============================================================================================= - -.. automodule:: pymongo.read_preferences - :synopsis: Utilities for choosing which member of a replica set to read from. - - .. autoclass:: pymongo.read_preferences.Primary - - .. max_staleness, min_wire_version, mongos_mode, and tag_sets don't - make sense for Primary. - - .. autoattribute:: document - .. autoattribute:: mode - .. autoattribute:: name - - .. autoclass:: pymongo.read_preferences.PrimaryPreferred - :inherited-members: - .. autoclass:: pymongo.read_preferences.Secondary - :inherited-members: - .. autoclass:: pymongo.read_preferences.SecondaryPreferred - :inherited-members: - .. autoclass:: pymongo.read_preferences.Nearest - :inherited-members: - - .. autoclass:: ReadPreference - - .. autoattribute:: PRIMARY - .. autoattribute:: PRIMARY_PREFERRED - .. autoattribute:: SECONDARY - .. autoattribute:: SECONDARY_PREFERRED - .. autoattribute:: NEAREST diff --git a/doc/api/pymongo/results.rst b/doc/api/pymongo/results.rst deleted file mode 100644 index 765e9fb25b..0000000000 --- a/doc/api/pymongo/results.rst +++ /dev/null @@ -1,7 +0,0 @@ -:mod:`results` -- Result class definitions -========================================== - -.. automodule:: pymongo.results - :synopsis: Result class definitions - :members: - :inherited-members: diff --git a/doc/api/pymongo/server_api.rst b/doc/api/pymongo/server_api.rst deleted file mode 100644 index de74411aa4..0000000000 --- a/doc/api/pymongo/server_api.rst +++ /dev/null @@ -1,11 +0,0 @@ -:mod:`server_api` -- Support for MongoDB Stable API -====================================================== - -.. automodule:: pymongo.server_api - :synopsis: Support for MongoDB Stable API - - .. autoclass:: pymongo.server_api.ServerApi - :members: - - .. autoclass:: pymongo.server_api.ServerApiVersion - :members: diff --git a/doc/api/pymongo/server_description.rst b/doc/api/pymongo/server_description.rst deleted file mode 100644 index fc6b55ec74..0000000000 --- a/doc/api/pymongo/server_description.rst +++ /dev/null @@ -1,9 +0,0 @@ -:orphan: - -:mod:`server_description` -- An object representation of a server the driver is connected to. -============================================================================================= - -.. automodule:: pymongo.server_description - - .. autoclass:: pymongo.server_description.ServerDescription() - :members: diff --git a/doc/api/pymongo/topology_description.rst b/doc/api/pymongo/topology_description.rst deleted file mode 100644 index 24353db2a9..0000000000 --- a/doc/api/pymongo/topology_description.rst +++ /dev/null @@ -1,9 +0,0 @@ -:orphan: - -:mod:`topology_description` -- An object representation of a deployment of MongoDB servers. -=========================================================================================== - -.. automodule:: pymongo.topology_description - - .. autoclass:: pymongo.topology_description.TopologyDescription() - :members: diff --git a/doc/api/pymongo/uri_parser.rst b/doc/api/pymongo/uri_parser.rst deleted file mode 100644 index 54102d7df8..0000000000 --- a/doc/api/pymongo/uri_parser.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`uri_parser` -- Tools to parse and validate a MongoDB URI -============================================================== - -.. automodule:: pymongo.uri_parser - :synopsis: Tools to parse and validate a MongoDB URI. - :members: diff --git a/doc/api/pymongo/write_concern.rst b/doc/api/pymongo/write_concern.rst deleted file mode 100644 index 5c7b4b39f6..0000000000 --- a/doc/api/pymongo/write_concern.rst +++ /dev/null @@ -1,6 +0,0 @@ -:mod:`write_concern` -- Tools for specifying write concern -========================================================== - -.. automodule:: pymongo.write_concern - :synopsis: Tools for specifying write concern. - :members: diff --git a/doc/changelog.rst b/doc/changelog.rst deleted file mode 100644 index 6985dca50f..0000000000 --- a/doc/changelog.rst +++ /dev/null @@ -1,4804 +0,0 @@ -Changelog -========= - -Changes in Version 4.20.0 (2026/XX/XX) --------------------------------------- - -- The client handshake metadata now reports a detected coding agent in - ``client.env.agent`` (`PYTHON-5929`_). -- Removed the beta ``QueryType.PREFIXPREVIEW``, ``QueryType.SUFFIXPREVIEW``, - and ``QueryType.SUBSTRINGPREVIEW`` query types. Use - :attr:`~pymongo.encryption.QueryType.PREFIX`, - :attr:`~pymongo.encryption.QueryType.SUFFIX`, and - :attr:`~pymongo.encryption.QueryType.SUBSTRING` instead (requires MongoDB - 9.0+ and pymongocrypt 1.21.0+) (`PYTHON-5959`_). -- Removed the deprecated ``text_opts`` parameter of - :meth:`~pymongo.encryption.ClientEncryption.encrypt` and - :meth:`~pymongo.asynchronous.encryption.AsyncClientEncryption.encrypt`, and - the ``TextOpts`` class. Use ``string_opts`` and - :class:`~pymongo.encryption_options.StringOpts` instead (`PYTHON-5959`_). - -Bug fixes -......... - -- Fixed a disagreement between the C extension and pure-Python BSON decoders - for binary elements with UUID subtypes (3 and 4) whose payload is not 16 - bytes. Both now decode them to :class:`~bson.binary.Binary` under the - default ``UNSPECIFIED`` UUID representation, and raise - :class:`~bson.errors.InvalidBSON` when UUID conversion is requested - (`PYTHON-6172`_). -- Fixed a bug where ``MongoClient(maxPoolSize=0, minPoolSize>0)`` raised - ``ValueError``, even though ``maxPoolSize=0`` means "no limit". The - ``minPoolSize <= maxPoolSize`` validation now treats both ``0`` and ``None`` - as unlimited (`PYTHON-6149`_). -- Fixed a bug where :class:`~bson.objectid.ObjectId` accepted a 24-character - string containing whitespace and created an ObjectId shorter than 12 bytes - from it. It now raises :class:`~bson.errors.InvalidId`, and - :meth:`~bson.objectid.ObjectId.is_valid` returns ``False`` for such a string - (`PYTHON-5873`_). -- Fixed the type annotation of the ``let`` argument of - :class:`~pymongo.cursor.Cursor` and - :class:`~pymongo.asynchronous.cursor.AsyncCursor` to be - ``Optional[Mapping[str, Any]]`` instead of ``Optional[bool]``, matching what - the argument accepts at runtime (`PYTHON-6145`_). -- Disabled TLS session reuse on Python 3.11 - due to a CPython memory leak bug (`python/cpython#116810 `_). - The bug was fixed in Python 3.12.7 and Python 3.13.1. - Users of Python 3.12 and 3.13 should upgrade to at least those versions (`PYTHON-6182`_). -- Fixed a bug where ``AsyncMongoClient`` could not recover after a replica set - member removed itself from the topology with its own ``hello`` response (for - example, during a node restart): the monitor's executor cancelled its own - task, so the monitor never ran again (`PYTHON-6226`_). -- Fixed undefined behavior in the C extension's BSON buffer growth: growing - an encode buffer past 1GiB doubled a signed integer past its limit. - Over-limit encodes still raise ``ValueError`` (`PYTHON-6252`_). - -.. _PYTHON-5929: https://jira.mongodb.org/browse/PYTHON-5929 -.. _PYTHON-5959: https://jira.mongodb.org/browse/PYTHON-5959 -.. _PYTHON-6172: https://jira.mongodb.org/browse/PYTHON-6172 -.. _PYTHON-6149: https://jira.mongodb.org/browse/PYTHON-6149 -.. _PYTHON-5873: https://jira.mongodb.org/browse/PYTHON-5873 -.. _PYTHON-6145: https://jira.mongodb.org/browse/PYTHON-6145 -.. _PYTHON-6182: https://jira.mongodb.org/browse/PYTHON-6182 -.. _PYTHON-6226: https://jira.mongodb.org/browse/PYTHON-6226 -.. _PYTHON-6252: https://jira.mongodb.org/browse/PYTHON-6252 - -Changes in Version 4.19.0 (2026/10/14) --------------------------------------- - -PyMongo 4.19 brings a number of changes including: - -.. warning:: PyMongo 4.19 drops support for Python 3.9 and 3.10 and removes - PyPy support: Python 3.11+ is now required. - -- Added support for Python 3.15. -- Dropped support for Python 3.9 and 3.10. -- Removed support for PyPy. -- Removed the deprecated ``Algorithm.RANGEPREVIEW`` and - ``QueryType.RANGEPREVIEW`` members (`PYTHON-6009`_). -- Added support for running the synchronous and asynchronous clients in - subinterpreters, including inside - ``concurrent.futures.InterpreterPoolExecutor`` (Python 3.14+). Only in - subinterpreters, which do not allow daemon threads, the synchronous - client's monitor threads now start as non-daemon threads and are stopped - and joined when the interpreter is torn down. Monitor threads in the main - interpreter remain daemon threads and shutdown behavior is unchanged. - Note that because these threads are non-daemon, a subinterpreter may block - on teardown until any in-flight monitor work completes. -- Added support for routing Key Management Service (KMS) requests for - Client-Side Field Level Encryption and Queryable Encryption through an HTTP - proxy, using the new ``kms_connect_callback`` option on - :class:`~pymongo.encryption_options.AutoEncryptionOpts`, - :class:`~pymongo.encryption.ClientEncryption`, and - :class:`~pymongo.asynchronous.encryption.AsyncClientEncryption`. The callback - opens the connection and the driver performs the KMS TLS handshake over it, so - verification still targets the KMS host rather than the proxy. For an ordinary - HTTP proxy, pass :class:`~pymongo.encryption_options.HTTPProxyKMSConnect` or - :class:`~pymongo.encryption_options.AsyncHTTPProxyKMSConnect` instead of - writing a callback. Both helpers accept custom ``CONNECT`` headers, e.g. - ``Proxy-Authorization`` for proxies that require authentication. -- Added the ``srv_host_validator`` keyword argument to - :class:`~pymongo.synchronous.mongo_client.MongoClient` and - :class:`~pymongo.asynchronous.mongo_client.AsyncMongoClient`, an alternative to - ``srvAllowedHostsSuffix`` for deployments whose acceptable SRV hosts cannot be - expressed as a single suffix. The callback is invoked once per SRV-returned - host and must return a boolean: ``True`` to accept the host and ``False`` to - reject it. During initial DNS discovery a non-boolean return raises an error; - during SRV polling it is treated as a rejection. It is mutually exclusive with - ``srvAllowedHostsSuffix`` and, because it takes a callable, cannot be set in a - connection string. See the - :class:`~pymongo.synchronous.mongo_client.MongoClient` and - :class:`~pymongo.asynchronous.mongo_client.AsyncMongoClient` documentation for - security considerations. -- ``srvAllowedHostsSuffix`` may now be set to a single label reserved for - private or special use, such as ``localhost``, ``test``, or ``internal``. - -Bug fixes -......... - -- Fixed a bug where the synchronous client could permanently deadlock under - gevent when a greenlet was killed while checking a connection back into - the pool (`PYTHON-6074`_). -- ``MongoClient.append_metadata()`` and ``AsyncMongoClient.append_metadata()`` - now detect duplicates by comparing the whole - :class:`~pymongo.driver_info.DriverInfo` instead of only its name. The - comparison is exact, so drivers that differ in name case or platform are no - longer treated as duplicates (`PYTHON-6040`_). -- ``driver.name`` and ``driver.version`` in the handshake metadata are now - ``|``-delimited lists with 1:1 index correspondence, including empty version - entries for the built-in ``|c`` and ``|async`` name segments - (`PYTHON-6040`_). -- Fixed a bug where truncating the handshake metadata to 512 bytes could leave - ``driver.name`` and ``driver.version`` with different numbers of ``|`` - delimiters (`PYTHON-6040`_). -- :class:`~pymongo.driver_info.DriverInfo` now raises :class:`ValueError` when - any field contains the reserved ``|`` delimiter (`PYTHON-6040`_). -- Fixed a bug in SRV polling where invalid hosts where topology would not be - updated if one returned host was invalid. -- Fixed a bug where the C extension's BSON decoder accepted documents whose - element data overlaps the document terminator instead of raising - ``InvalidBSON`` (`PYTHON-6111`_). -- Fixed a bug where the pure-Python ``decode_all()`` accepted buffers ending - in a partial document instead of raising ``InvalidBSON``, now matching the - C extension (`PYTHON-6163`_). - -.. _PYTHON-6074: https://jira.mongodb.org/browse/PYTHON-6074 -.. _PYTHON-6040: https://jira.mongodb.org/browse/PYTHON-6040 -.. _PYTHON-6111: https://jira.mongodb.org/browse/PYTHON-6111 -.. _PYTHON-6163: https://jira.mongodb.org/browse/PYTHON-6163 -.. _PYTHON-6009: https://jira.mongodb.org/browse/PYTHON-6009 - -Issues Resolved -............... - -See the `PyMongo 4.19.0 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.19.0 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=52147 - -Changes in Version 4.18.2 (2026/09/24) --------------------------------------- - -Version 4.18.2 is a bug fix release. - -- Hardened the bson buffer size guard against signed integer overflow. (`CVE-2026-96749`_). -- Fixed connection string parsing to percent-decode each host individually. (`CVE-2026-96748`_). -- Client-side field level encryption now rejects a KMS endpoint ending in ``.sock``. (`CVE-2026-96747`_). - -.. _CVE-2026-96749: https://www.cve.org/CVERecord?id=CVE-2026-96749 -.. _CVE-2026-96748: https://www.cve.org/CVERecord?id=CVE-2026-96748 -.. _CVE-2026-96747: https://www.cve.org/CVERecord?id=CVE-2026-96747 - -Issues Resolved -............... - -See the `PyMongo 4.18.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.18.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=52896 - -Changes in Version 4.18.1 (2026/09/10) --------------------------------------- - -Version 4.18.1 is a bug fix release. - -- Use an exact match for the file ID in GridFS delete methods - (`CVE-2026-88029`_). - -.. _CVE-2026-88029: https://www.cve.org/CVERecord?id=CVE-2026-88029 - -Changes in Version 4.18.0 (2026/09/03) --------------------------------------- - -PyMongo 4.18 brings a number of changes including: - -- Added ``srvAllowedHostsSuffix`` as a URI option and keyword argument to - :class:`~pymongo.synchronous.mongo_client.MongoClient` and - :class:`~pymongo.asynchronous.mongo_client.AsyncMongoClient`. When connecting - via ``mongodb+srv://``, this option overrides the default requirement that - SRV-returned hosts share the same parent domain as the seed hostname, - allowing hosts under a different domain suffix to be accepted. The suffix must - not be a public suffix (per the `Public Suffix List - `_). See the - :class:`~pymongo.synchronous.mongo_client.MongoClient` and - :class:`~pymongo.asynchronous.mongo_client.AsyncMongoClient` documentation for - security considerations. -- Dropped support for MongoDB 4.2. -- Added support for MongoDB 9.0. -- PyPy support is deprecated and will be removed in a future release. -- Improved TLS connection performance by reusing TLS sessions across connections - to the same server, avoiding a full handshake on each new connection. - Session resumption is supported on all Python versions for synchronous clients - and on Python 3.11+ for async clients. -- Improved performance for MongoDB 9.0's Intelligent Workload Management (IWM) by only retrying overload errors when doing so is expected to not worsen server conditions. -- Added support for exhaust cursors (:attr:`~pymongo.cursor.CursorType.EXHAUST`) - against mongos 7.1+. An older mongos still raises - :class:`~pymongo.errors.InvalidOperation`, now on the first iteration of the - cursor rather than from - :meth:`~pymongo.synchronous.collection.Collection.find`, since the requirement - is checked against the connection in use. Separately, async cursors combining - ``limit`` with :attr:`~pymongo.cursor.CursorType.EXHAUST` now raise at ``find`` - rather than on first iteration, matching the synchronous API. -- Redacted potentially sensitive authentication mechanism properties, including - AWS session tokens, from the representations of - :class:`~pymongo.synchronous.mongo_client.MongoClient` and - :class:`~pymongo.asynchronous.mongo_client.AsyncMongoClient`. -- Command monitoring events and command log messages for a single logical - operation now share one stable ``operation_id`` across all of its retry - attempts, so consumers can correlate a retried operation's events. As a - result, ``operation_id`` is no longer equal to the per-attempt ``request_id`` - for these operations. -- Added validation of OP_COMPRESSED decompressed message size against - ``max_message_size`` to prevent memory exhaustion from maliciously crafted - compressed server responses. -- Improved the performance and memory usage of decoding large documents to - :class:`~bson.raw_bson.RawBSONDocument`. Documents and subdocuments that are 4KB or greater - and decoded from an immutable buffer are now exposed as read-only :class:`memoryview` - slices instead of :class:`bytes` copies. Documents decoded from mutable buffers such as a - :class:`bytearray` are always :class:`bytes` copies. -- :func:`bson.get_data_and_view` now returns a view of a private :class:`bytes` copy - for buffer-protocol inputs other than :class:`bytes` or :class:`bytearray`. -- Improved the performance of lazily decoding a - :class:`~bson.raw_bson.RawBSONDocument` when the C extension is available. -- Fixed a potential out-of-bounds read in the C extension when decoding an - array of BSON documents. An embedded document whose declared length exceeds - the bytes remaining in the array now raises - :class:`~bson.errors.InvalidBSON` instead of reading past the end of the - buffer. -- Fixed :func:`bson.json_util.loads` to reject ``$timestamp`` values containing - fields other than ``t`` and ``i``. -- Fixed a bug on Windows, and on macOS when using PyOpenSSL, where - ``SSL_CERT_FILE``/``SSL_CERT_DIR`` were merged with, rather than replacing, - the OS/certifi certificate store. -- Added general availability support for Queryable Encryption prefix, suffix, - and substring queries against MongoDB 9.0+. These queries require - libmongocrypt 1.20.0 or later: - - - Added :attr:`~pymongo.encryption.Algorithm.STRING` and - :class:`~pymongo.encryption_options.StringOpts`, replacing - ``Algorithm.TEXTPREVIEW`` and ``TextOpts``, which are now deprecated. - - Added :attr:`~pymongo.encryption.QueryType.PREFIX`, - :attr:`~pymongo.encryption.QueryType.SUFFIX`, and - :attr:`~pymongo.encryption.QueryType.SUBSTRING`. The corresponding - ``PREFIXPREVIEW``, ``SUFFIXPREVIEW``, and ``SUBSTRINGPREVIEW`` query types - remain for experimental use with MongoDB versions before 9.0. - - Added the ``string_opts`` parameter to - :meth:`~pymongo.encryption.ClientEncryption.encrypt` and - :meth:`~pymongo.asynchronous.encryption.AsyncClientEncryption.encrypt`, - deprecating ``text_opts``. pymongocrypt added ``text_opts`` in 1.16 and - renamed it to ``string_opts`` in 1.19, and accepts only one of the two - names per release, so passing ``text_opts`` with pymongocrypt 1.19 or - later, ``string_opts`` with pymongocrypt 1.16 through 1.18, or both names - at once, raises :exc:`~pymongo.errors.ConfigurationError`. -- Aggregation helpers now raise :exc:`~pymongo.errors.ConfigurationError` when - passed an ``aggregate`` or ``pipeline`` keyword argument. Previously these - keys silently replaced the target namespace and pipeline of the generated - ``aggregate`` command. This affects - :meth:`~pymongo.asynchronous.collection.AsyncCollection.aggregate` and - :meth:`~pymongo.synchronous.collection.Collection.aggregate`, - :meth:`~pymongo.asynchronous.collection.AsyncCollection.aggregate_raw_batches` - and :meth:`~pymongo.synchronous.collection.Collection.aggregate_raw_batches`, - :meth:`~pymongo.asynchronous.database.AsyncDatabase.aggregate` and - :meth:`~pymongo.synchronous.database.Database.aggregate`, and - :meth:`~pymongo.asynchronous.collection.AsyncCollection.list_search_indexes` - and :meth:`~pymongo.synchronous.collection.Collection.list_search_indexes`. - -Changes in Version 4.17.0 (2026/04/20) --------------------------------------- - -PyMongo 4.17 brings a number of changes including: - -- ``has_key``, ``iterkeys`` and ``itervalues`` in :class:`bson.son.SON` have - been deprecated and will be removed in PyMongo 5.0. These methods were - deprecated in favor of the standard dictionary containment operator ``in`` - and the ``keys()`` and ``values()`` methods, respectively. -- Added the :meth:`~pymongo.asynchronous.client_session.AsyncClientSession.bind` and :meth:`~pymongo.client_session.ClientSession.bind` methods - that allow users to bind a session to all database operations within the scope of a context manager instead of having to explicitly pass the session to each individual operation. - See the `Transactions docs `_ for examples and more information. -- Added support for MongoDB's `Intelligent Workload Management `_ (IWM) and ingress connection rate limiting features in MongoDB server version 9.0. - The driver will gracefully handle write-blocking scenarios and optimizes connection establishment during high-load conditions to maintain application availability. - -Changes in Version 4.16.0 (2026/01/07) --------------------------------------- - -PyMongo 4.16 brings a number of changes including: - -- Removed invalid documents from :class:`bson.errors.InvalidDocument` error messages as - doing so may leak sensitive user data. - Instead, invalid documents are stored in :attr:`bson.errors.InvalidDocument.document`. -- PyMongo now requires ``dnspython>=2.6.1``, since ``dnspython`` 1.0 is no longer maintained. - The minimum version is ``2.6.1`` to account for `CVE-2023-29483 `_. -- Removed support for Eventlet. - Eventlet is actively being sunset by its maintainers and has compatibility issues with PyMongo's dnspython dependency. -- Use Zstandard support from the standard library for Python 3.14+, and use ``backports.zstd`` for older versions. -- Fixed return type annotation for ``find_one_and_*`` methods on :class:`~pymongo.asynchronous.collection.AsyncCollection` - and :class:`~pymongo.synchronous.collection.Collection` to include ``None``. -- Added support for NumPy 1D-arrays in :class:`bson.binary.BinaryVector`. -- Prevented :class:`~pymongo.encryption.ClientEncryption` from loading the crypt - shared library to fix "MongoCryptError: An existing crypt_shared library is - loaded by the application" unless the linked library search path is set. - -Changes in Version 4.15.5 (2025/12/02) --------------------------------------- - -Version 4.15.5 is a bug fix release. - -- Fixed a bug that could cause ``AutoReconnect("connection pool paused")`` errors when cursors fetched more documents from the database after SDAM heartbeat failures. - -Changes in Version 4.15.4 (2025/10/21) --------------------------------------- - -Version 4.15.4 is a bug fix release. - -- Relaxed the callback type of :meth:`~pymongo.asynchronous.client_session.AsyncClientSession.with_transaction` to allow the broader Awaitable type rather than only Coroutine objects. -- Added the missing Python 3.14 trove classifier to the package metadata. - -Issues Resolved -............... - -See the `PyMongo 4.15.4 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.15.4 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=47237 - -Changes in Version 4.15.3 (2025/10/07) --------------------------------------- - -Version 4.15.3 is a bug fix release. - -- Fixed a memory leak when raising :class:`bson.errors.InvalidDocument` with C extensions. -- Fixed the return type of the :meth:`~pymongo.asynchronous.collection.AsyncCollection.distinct`, - :meth:`~pymongo.synchronous.collection.Collection.distinct`, :meth:`pymongo.asynchronous.cursor.AsyncCursor.distinct`, - and :meth:`pymongo.asynchronous.cursor.AsyncCursor.distinct` methods. - -Issues Resolved -............... - -See the `PyMongo 4.15.3 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.15.3 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=47293 - -Changes in Version 4.15.2 (2025/10/01) --------------------------------------- - -Version 4.15.2 is a bug fix release. - -- Add wheels for Python 3.14 and 3.14t that were missing from 4.15.0 release. Drop the 3.13t wheel. - -Issues Resolved -............... - -See the `PyMongo 4.15.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.15.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=47186 - -Changes in Version 4.15.1 (2025/09/16) --------------------------------------- - -Version 4.15.1 is a bug fix release. - -- Fixed a bug in :meth:`~pymongo.synchronous.encryption.ClientEncryption.encrypt` - and :meth:`~pymongo.asynchronous.encryption.AsyncClientEncryption.encrypt` - that would cause a ``TypeError`` when using ``pymongocrypt<1.16`` by passing - an unsupported ``type_opts`` parameter even if Queryable Encryption text - queries beta was not used. - -- Fixed a bug in ``AsyncMongoClient`` that caused a ``ServerSelectionTimeoutError`` - when used with ``uvicorn``, ``FastAPI``, or ``uvloop``. - -Issues Resolved -............... - -See the `PyMongo 4.15.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.15.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=46486 - -Changes in Version 4.15.0 (2025/09/10) --------------------------------------- - -PyMongo 4.15 brings a number of changes including: - -- Added :class:`~pymongo.encryption_options.TextOpts`, - :attr:`~pymongo.encryption.Algorithm.TEXTPREVIEW`, - :attr:`~pymongo.encryption.QueryType.PREFIXPREVIEW`, - :attr:`~pymongo.encryption.QueryType.SUFFIXPREVIEW`, - :attr:`~pymongo.encryption.QueryType.SUBSTRINGPREVIEW`, - as part of the experimental Queryable Encryption text queries beta. - ``pymongocrypt>=1.16`` is required for text query support. -- Added :class:`bson.decimal128.DecimalEncoder` and - :class:`bson.decimal128.DecimalDecoder` - to support encoding and decoding of BSON Decimal128 values to - decimal.Decimal values using the TypeRegistry API. -- Added support for Windows ``arm64`` wheels. - -Changes in Version 4.14.1 (2025/08/19) --------------------------------------- - -Version 4.14.1 is a bug fix release. - -- Fixed a bug in ``MongoClient.append_metadata()`` and - ``AsyncMongoClient.append_metadata()`` - that allowed duplicate ``DriverInfo.name`` to be appended to the metadata. - -Issues Resolved -............... - -See the `PyMongo 4.14.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.14.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=45256 - -Changes in Version 4.14.0 (2025/08/06) --------------------------------------- - -.. warning:: PyMongo 4.14 drops support for MongoDB 4.0. PyMongo now supports - MongoDB 4.2+. - -PyMongo 4.14 brings a number of changes including: - -- Dropped support for MongoDB 4.0. -- Added preliminary support for Python 3.14 and 3.14 with free-threading. We do - not yet support the following with Python 3.14: - - - Subinterpreters (``concurrent.interpreters``) - - Free-threading with Encryption - - mod_wsgi - -- Removed experimental support for free-threading support in Python 3.13. -- Added :attr:`bson.codec_options.TypeRegistry.codecs` and - :attr:`bson.codec_options.TypeRegistry.fallback_encoder` properties - to allow users to directly access the type codecs and fallback encoder for a - given :class:`bson.codec_options.TypeRegistry`. -- Added - :meth:`pymongo.asynchronous.mongo_client.AsyncMongoClient.append_metadata` and - :meth:`pymongo.mongo_client.MongoClient.append_metadata` to allow instantiated - MongoClients to send client metadata on-demand -- Improved performance of selecting a server with the Primary selector. -- Introduces a minor breaking change. When encoding - :class:`bson.binary.BinaryVector`, a ``ValueError`` will be raised if the - 'padding' metadata field is < 0 or > 7, or non-zero for any type other than - PACKED_BIT. -- Changed :meth:`~pymongo.uri_parser.parse_uri`'s ``options`` return value to be - type ``dict`` instead of ``_CaseInsensitiveDictionary``. - -Issues Resolved -............... - -See the `PyMongo 4.14 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.14 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=43041 - -Changes in Version 4.13.2 (2025/06/17) --------------------------------------- - -Version 4.13.2 is a bug fix release. - -- Fixed a bug where ``AsyncMongoClient`` would block the event loop while creating new connections, - potentially significantly increasing latency for ongoing operations. - -Issues Resolved -............... - -See the `PyMongo 4.13.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.13.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=43937 - - -Changes in Version 4.13.1 (2025/06/10) --------------------------------------- - -Version 4.13.1 is a bug fix release. - -- Fixed a bug that could raise ``ServerSelectionTimeoutError`` when using timeouts with ``AsyncMongoClient``. -- Fixed a bug that could raise ``NetworkTimeout`` errors on Windows. - -Issues Resolved -............... - -See the `PyMongo 4.13.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.13.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=43924 - -Changes in Version 4.13.0 (2025/05/14) --------------------------------------- - -PyMongo 4.13 brings a number of changes including: - -- The asynchronous API is now stable and no longer in beta. - See the :mod:`pymongo.asynchronous` docs - or the `migration guide `_ for more information. -- Fixed a bug where :class:`pymongo.write_concern.WriteConcern` repr was not eval-able - when using ``w="majority"``. -- When padding is set, ignored bits in a BSON BinaryVector of PACKED_BIT dtype should be set to zero. - When encoding, this is enforced and is a breaking change. - It is not yet enforced when decoding, so reading from the database will not fail, however a warning will be triggered. - From PyMongo 5.0, this rule will be enforced for both encoding and decoding. - -Issues Resolved -............... - -See the `PyMongo 4.13 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.13 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=42509 - -Changes in Version 4.12.1 (2025/04/29) --------------------------------------- - -Version 4.12.1 is a bug fix release. - -- Fixed a bug that could raise ``UnboundLocalError`` when creating asynchronous connections over SSL. -- Fixed a bug causing SRV hostname validation to fail when resolver and resolved hostnames are identical with three domain levels. -- Fixed a bug that caused direct use of ``pymongo.uri_parser`` to raise an ``AttributeError``. -- Fixed a bug where clients created with connect=False and a "mongodb+srv://" connection string - could cause public ``pymongo.MongoClient`` and ``pymongo.AsyncMongoClient`` attributes (topology_description, - nodes, address, primary, secondaries, arbiters) to incorrectly return a Database, leading to type - errors such as: "NotImplementedError: Database objects do not implement truth value testing or bool()". -- Removed Eventlet testing against Python versions newer than 3.9 since - Eventlet is actively being sunset by its maintainers and has compatibility issues with PyMongo's dnspython dependency. -- Fixed a bug where MongoDB cluster topology changes could cause asynchronous operations to take much longer to complete - due to holding the Topology lock while closing stale connections. -- Fixed a bug that would cause AsyncMongoClient to attempt to use PyOpenSSL when available, resulting in errors such as - "pymongo.errors.ServerSelectionTimeoutError: 'SSLContext' object has no attribute 'wrap_bio'". - -Issues Resolved -............... - -See the `PyMongo 4.12.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.12.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=43094 - -Changes in Version 4.12.0 (2025/04/08) --------------------------------------- - -.. warning:: Driver support for MongoDB 4.0 reached end of life in April 2025. - PyMongo 4.12 will be the last release to support MongoDB 4.0. - -PyMongo 4.12 brings a number of changes including: - -- Support for configuring DEK cache lifetime via the ``key_expiration_ms`` argument to - :class:`~pymongo.encryption_options.AutoEncryptionOpts`. -- Support for $lookup in CSFLE and QE supported on MongoDB 8.1+. -- pymongocrypt>=1.13 is now required for `In-Use Encryption `_ support. -- Added :meth:`gridfs.asynchronous.grid_file.AsyncGridFSBucket.rename_by_name` and :meth:`gridfs.grid_file.GridFSBucket.rename_by_name` - for more performant renaming of a file with multiple revisions. -- Added :meth:`gridfs.asynchronous.grid_file.AsyncGridFSBucket.delete_by_name` and :meth:`gridfs.grid_file.GridFSBucket.delete_by_name` - for more performant deletion of a file with multiple revisions. -- AsyncMongoClient no longer performs DNS resolution for "mongodb+srv://" connection strings on creation. - To avoid blocking the asyncio loop, the resolution is now deferred until the client is first connected. -- Added index hinting support to the - :meth:`~pymongo.asynchronous.collection.AsyncCollection.distinct` and - :meth:`~pymongo.collection.Collection.distinct` commands. -- Deprecated the ``hedge`` parameter for - :class:`~pymongo.read_preferences.PrimaryPreferred`, - :class:`~pymongo.read_preferences.Secondary`, - :class:`~pymongo.read_preferences.SecondaryPreferred`, - :class:`~pymongo.read_preferences.Nearest`. Support for ``hedge`` will be removed in PyMongo 5.0. -- Removed PyOpenSSL support from the asynchronous API due to limitations of the CPython asyncio.Protocol SSL implementation. -- Allow valid SRV hostnames with less than 3 parts. - -Issues Resolved -............... - -See the `PyMongo 4.12 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.12 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=41916 - -Changes in Version 4.11.2 (2025/03/05) --------------------------------------- - -Version 4.11.2 is a bug fix release. - -- Fixed a bug where :meth:`~pymongo.database.Database.command` would fail when attempting to run the bulkWrite command. - -Issues Resolved -............... - -See the `PyMongo 4.11.2 release notes in JIRA`_ for the list of resolved issues in this release. - -.. _PyMongo 4.11.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=42506 - -Changes in Version 4.11.1 (2025/02/10) --------------------------------------- - -- Fixed support for prebuilt ``ppc64le`` and ``s390x`` wheels. - -Changes in Version 4.11.0 (2025/01/28) --------------------------------------- - -.. warning:: PyMongo 4.11 drops support for Python 3.8 and PyPy 3.9: Python 3.9+ or PyPy 3.10+ is now required. -.. warning:: PyMongo 4.11 drops support for MongoDB 3.6. PyMongo now supports MongoDB 4.0+. - Driver support for MongoDB 3.6 reached end of life in April 2024. -.. warning:: Driver support for MongoDB 4.0 reaches end of life in April 2025. - A future minor release of PyMongo will raise the minimum supported MongoDB Server version from 4.0 to 4.2. - This is in accordance with [MongoDB Software Lifecycle Schedules](https://www.mongodb.com/legal/support-policy/lifecycles). - **Support for MongoDB Server 4.0 will be dropped in a future release!** -.. warning:: This version does not include wheels for ``ppc64le`` or ``s390x`` architectures, see `PYTHON-5058`_ for more information. - -PyMongo 4.11 brings a number of changes including: - -- Dropped support for Python 3.8 and PyPy 3.9. -- Dropped support for MongoDB 3.6. -- Dropped support for the MONGODB-CR authenticate mechanism, which is no longer supported by MongoDB 4.0+. -- pymongocrypt>=1.12 is now required for `In-Use Encryption `_ support. -- Added support for free-threaded Python with the GIL disabled. For more information see: - `Free-threaded CPython `_. - We do not yet support free-threaded Python on Windows (`PYTHON-5027`_) or with In-Use Encryption (`PYTHON-5024`_). -- :attr:`~pymongo.asynchronous.mongo_client.AsyncMongoClient.address` and - :attr:`~pymongo.mongo_client.MongoClient.address` now correctly block when called on unconnected clients - until either connection succeeds or a server selection timeout error is raised. -- Added :func:`repr` support to :class:`pymongo.operations.IndexModel`. -- Added :func:`repr` support to :class:`pymongo.operations.SearchIndexModel`. -- Added ``sort`` parameter to - :meth:`~pymongo.collection.Collection.update_one`, :meth:`~pymongo.collection.Collection.replace_one`, - :class:`~pymongo.operations.UpdateOne`, and - :class:`~pymongo.operations.UpdateMany`, -- :meth:`~pymongo.mongo_client.MongoClient.bulk_write` and - :meth:`~pymongo.asynchronous.mongo_client.AsyncMongoClient.bulk_write` now throw an error - when ``ordered=True`` or ``verboseResults=True`` are used with unacknowledged writes. - These are unavoidable breaking changes. -- Fixed a bug in :const:`bson.json_util.dumps` where a :class:`bson.datetime_ms.DatetimeMS` would - be incorrectly encoded as ``'{"$date": "X"}'`` instead of ``'{"$date": X}'`` when using the - legacy MongoDB Extended JSON datetime representation. -- Fixed a bug where :const:`bson.json_util.loads` would raise an IndexError when parsing an invalid - ``"$date"`` instead of a ValueError. - -Issues Resolved -............... - -See the `PyMongo 4.11 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.11 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=40784 -.. _PYTHON-5027: https://jira.mongodb.org/browse/PYTHON-5027 -.. _PYTHON-5024: https://jira.mongodb.org/browse/PYTHON-5024 -.. _PYTHON-5058: https://jira.mongodb.org/browse/PYTHON-5058 - -Changes in Version 4.10.1 (2024/10/01) --------------------------------------- - -Version 4.10.1 is a bug fix release. - -- Fixed a bug where :meth:`~pymongo.results.UpdateResult.did_upsert` would raise a ``TypeError``. -- Fixed Binary BSON subtype (9) support on big-endian operating systems (such as zSeries). - -Issues Resolved -............... - -See the `PyMongo 4.10.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.10.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=40788 - - -Changes in Version 4.10.0 (2024/09/30) --------------------------------------- - -- Added provisional **(BETA)** support for a new Binary BSON subtype (9) used for efficient storage and retrieval of vectors: - densely packed arrays of numbers, all of the same type. - This includes new methods :meth:`~bson.binary.Binary.from_vector` and :meth:`~bson.binary.Binary.as_vector`. -- Added C extension use to client metadata, for example: ``{"driver": {"name": "PyMongo|c", "version": "4.10.0"}, ...}`` -- Fixed a bug where :class:`~pymongo.asynchronous.mongo_client.AsyncMongoClient` could deadlock. -- Fixed a bug where PyMongo could fail to import on Windows if ``asyncio`` is misconfigured. - -Issues Resolved -............... - -See the `PyMongo 4.10 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.10 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=40553 - -Changes in Version 4.9.2 (2024/10/02) -------------------------------------- - -- Fixed a bug where :class:`~pymongo.asynchronous.mongo_client.AsyncMongoClient` could deadlock. -- Fixed a bug where PyMongo could fail to import on Windows if ``asyncio`` is misconfigured. -- Fixed a bug where :meth:`~pymongo.results.UpdateResult.did_upsert` would raise a ``TypeError``. - -Issues Resolved -............... - -See the `PyMongo 4.9.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.9.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=40732 - - -Changes in Version 4.9.1 (2024/09/18) -------------------------------------- - -- Add missing documentation about the fact the async API is in beta state. - -Issues Resolved -............... - -See the `PyMongo 4.9.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.9.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=40720 - - -Changes in Version 4.9 (2024/09/18) ------------------------------------ - -.. warning:: Driver support for MongoDB 3.6 reached end of life in April 2024. - PyMongo 4.9 will be the last release to support MongoDB 3.6. - -.. warning:: PyMongo 4.9 refactors a large portion of internal APIs to support the new asynchronous API beta. - As a result, versions of Motor older than 3.6 are not compatible with PyMongo 4.9. - Existing users of these versions must either upgrade to Motor 3.6 and PyMongo 4.9, - or cap their PyMongo version to ``< 4.9``. - Any applications that use private APIs may also break as a result of these internal changes. - -PyMongo 4.9 brings a number of improvements including: - -- Added support for MongoDB 8.0. -- Added support for Python 3.13. -- A new beta asynchronous API with full asyncio support. - This new asynchronous API is a work-in-progress that may change during the beta period before the full release. -- Added support for In-Use Encryption range queries with MongoDB 8.0. - Added :attr:`~pymongo.encryption.Algorithm.RANGE`. - ``sparsity`` and ``trim_factor`` are now optional in :class:`~pymongo.encryption_options.RangeOpts`. -- Added support for the "delegated" option for the KMIP ``master_key`` in - :meth:`~pymongo.encryption.ClientEncryption.create_data_key`. -- pymongocrypt>=1.10 is now required for `In-Use Encryption `_ support. -- Added :meth:`~pymongo.cursor.Cursor.to_list` to :class:`~pymongo.cursor.Cursor`, - :class:`~pymongo.command_cursor.CommandCursor`, - :class:`~pymongo.asynchronous.cursor.AsyncCursor`, - and :class:`~pymongo.asynchronous.command_cursor.AsyncCommandCursor` - as an asynchronous-friendly alternative to ``list(cursor)``. -- Added :meth:`~pymongo.mongo_client.MongoClient.bulk_write` to :class:`~pymongo.mongo_client.MongoClient` - and :class:`~pymongo.asynchronous.mongo_client.AsyncMongoClient`, - enabling users to perform insert, update, and delete operations - against mixed namespaces in a minimized number of round trips. - Please see `Client Bulk Write `_ for more information. -- Added support for the ``namespace`` parameter to the - :class:`~pymongo.operations.InsertOne`, - :class:`~pymongo.operations.ReplaceOne`, - :class:`~pymongo.operations.UpdateOne`, - :class:`~pymongo.operations.UpdateMany`, - :class:`~pymongo.operations.DeleteOne`, and - :class:`~pymongo.operations.DeleteMany` operations, so - they can be used in the new :meth:`~pymongo.mongo_client.MongoClient.bulk_write`. -- Added :func:`repr` support to :class:`bson.tz_util.FixedOffset`. -- Fixed a bug where PyMongo would raise ``InvalidBSON: unhashable type: 'tzfile'`` - when using :attr:`~bson.codec_options.DatetimeConversion.DATETIME_CLAMP` or - :attr:`~bson.codec_options.DatetimeConversion.DATETIME_AUTO` with a timezone from dateutil. -- Fixed a bug where PyMongo would raise ``InvalidBSON: date value out of range`` - when using :attr:`~bson.codec_options.DatetimeConversion.DATETIME_CLAMP` or - :attr:`~bson.codec_options.DatetimeConversion.DATETIME_AUTO` with a non-UTC timezone. -- Added a warning to unclosed MongoClient instances - telling users to explicitly close clients when finished with them to avoid leaking resources. - For example: - - .. code-block:: - - sys:1: ResourceWarning: Unclosed MongoClient opened at: - File "/Users//my_file.py", line 8, in `` - client = MongoClient() - Call MongoClient.close() to safely shut down your client and free up resources. -- The default value for ``connect`` in ``MongoClient`` is changed to ``False`` when running on - unction-as-a-service (FaaS) like AWS Lambda, Google Cloud Functions, and Microsoft Azure Functions. - On some FaaS systems, there is a ``fork()`` operation at function - startup. By delaying the connection to the first operation, we avoid a deadlock. See - `multiple forks `_ for more information. - - -Issues Resolved -............... - -See the `PyMongo 4.9 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.9 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=39940 - - -Changes in Version 4.8.0 (2024/06/26) -------------------------------------- - -.. warning:: PyMongo 4.8 drops support for Python 3.7 and PyPy 3.8: Python 3.8+ or PyPy 3.9+ is now required. - -PyMongo 4.8 brings a number of improvements including: - -- The handshake metadata for "os.name" on Windows has been simplified to "Windows" to improve import time. -- The repr of ``bson.binary.Binary`` is now redacted when the subtype is SENSITIVE_SUBTYPE(8). -- Secure Software Development Life Cycle automation for release process. - GitHub Releases now include a Software Bill of Materials, and signature - files corresponding to the distribution files released on PyPI. -- Fixed a bug in change streams where both ``startAtOperationTime`` and ``resumeToken`` - could be added to a retry attempt, which caused the retry to fail. -- Fallback to stdlib ``ssl`` module when ``pyopenssl`` import fails with AttributeError. -- Improved performance of MongoClient operations, especially when many operations are being run concurrently. - -Unavoidable breaking changes -............................ - -- Since we are now using ``hatch`` as our build backend, we no longer have a usable ``setup.py`` file - and require installation using ``pip``. Attempts to invoke the ``setup.py`` file will raise an exception. - Additionally, ``pip`` >= 21.3 is now required for editable installs. -- We no longer support the ``srv`` extra, since ``dnspython`` is included as a dependency in PyMongo 4.7+. - Instead of ``pip install pymongo[srv]``, use ``pip install pymongo``. -- We no longer support the ``tls`` extra, which was only valid for Python 2. - Instead of ``pip install pymongo[tls]``, use ``pip install pymongo``. - -Issues Resolved -............... - -See the `PyMongo 4.8 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.8 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=37057 - -Changes in Version 4.7.3 (2024/06/04) -------------------------------------- - -Version 4.7.3 has further fixes for lazily loading modules. - -- Use deferred imports instead of importlib lazy module loading. -- Improve import time on Windows. -- Reduce verbosity of "Waiting for suitable server to become available" log message from info to debug. - -Issues Resolved -............... - -See the `PyMongo 4.7.3 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.7.3 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=39865 - -Changes in Version 4.7.2 (2024/05/07) -------------------------------------- - -Version 4.7.2 fixes a bug introduced in 4.7.0: - -- Fixed a bug where PyMongo could not be used with the Nuitka compiler. - -Issues Resolved -............... - -See the `PyMongo 4.7.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.7.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=39710 - - -Changes in Version 4.7.1 (2024/04/30) -------------------------------------- - -Version 4.7.1 fixes a bug introduced in 4.7.0: - -- Fixed a bug where PyMongo would cause an ``AttributeError`` if ``dns.resolver`` was imported and referenced - after PyMongo was imported. -- Clarified the behavior of the ``TOKEN_RESOURCE`` auth mechanism property for ``MONGODB-OIDC``. - -Issues Resolved -............... - -See the `PyMongo 4.7.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.7.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=39680 - -Changes in Version 4.7.0 (2024/04/24) -------------------------------------- - -PyMongo 4.7 brings a number of improvements including: - -- Added support for ``MONGODB-OIDC`` authentication. The MONGODB-OIDC mechanism authenticates - using an OpenID Connect (OIDC) access token. - The driver supports OIDC for workload identity, defined as an identity you assign to a software workload - (such as an application, service, script, or container) to authenticate and access other services and resources. - Please see `Authentication `_ for more information. -- Added support for Python's `native logging library `_, - enabling developers to customize the verbosity of log messages for their applications. - Please see `Logging `_ for more information. -- Significantly improved the performance of encoding BSON documents to JSON. -- Added support for named KMS providers for client side field level encryption. - Previously supported KMS providers were only: aws, azure, gcp, kmip, and local. - The KMS provider is now expanded to support name suffixes (e.g. local:myname). - Named KMS providers enables more than one of each KMS provider type to be configured. - See the docstring for :class:`~pymongo.encryption_options.AutoEncryptionOpts`. - Note that named KMS providers requires pymongocrypt >=1.9 and libmongocrypt >=1.9. -- Added the :class:`pymongo.hello.Hello.connection_id`, - :attr:`pymongo.monitoring.CommandStartedEvent.server_connection_id`, - :attr:`pymongo.monitoring.CommandSucceededEvent.server_connection_id`, and - :attr:`pymongo.monitoring.CommandFailedEvent.server_connection_id` properties. -- Fixed a bug where inflating a :class:`~bson.raw_bson.RawBSONDocument` containing a :class:`~bson.code.Code` would cause an error. -- :meth:`~pymongo.encryption.ClientEncryption.encrypt` and - :meth:`~pymongo.encryption.ClientEncryption.encrypt_expression` now allow ``key_id`` - to be passed in as a :class:`uuid.UUID`. -- Fixed a bug where :class:`~bson.int64.Int64` instances could not always be encoded by `orjson`_. The following now - works:: - - >>> import orjson - >>> from bson import json_util - >>> orjson.dumps({'a': Int64(1)}, default=json_util.default, option=orjson.OPT_PASSTHROUGH_SUBCLASS) - -.. _orjson: https://github.com/ijl/orjson - -- Fixed a bug appearing in Python 3.12 where "RuntimeError: can't create new thread at interpreter shutdown" - could be written to stderr when a MongoClient's thread starts as the python interpreter is shutting down. -- Added a warning when connecting to DocumentDB and CosmosDB clusters. - For more information regarding feature compatibility and support please visit - `mongodb.com/supportability/documentdb `_ and - `mongodb.com/supportability/cosmosdb `_. -- Added the :attr:`pymongo.monitoring.ConnectionCheckedOutEvent.duration`, - :attr:`pymongo.monitoring.ConnectionCheckOutFailedEvent.duration`, and - :attr:`pymongo.monitoring.ConnectionReadyEvent.duration` properties. -- Added the ``type`` and ``kwargs`` arguments to :class:`~pymongo.operations.SearchIndexModel` to enable - creating vector search indexes in MongoDB Atlas. -- Fixed a bug where ``read_concern`` and ``write_concern`` were improperly added to - :meth:`~pymongo.collection.Collection.list_search_indexes` queries. -- Deprecated :attr:`pymongo.write_concern.WriteConcern.wtimeout` and :attr:`pymongo.mongo_client.MongoClient.wTimeoutMS`. - Use :meth:`~pymongo.timeout` instead. - -.. warning:: PyMongo depends on ``dnspython``, which released version 2.6.1 with a fix for - `CVE-2023-29483 `_. We do not explicitly require - that version, but we strongly recommend that you install at least that version in your environment. - -Unavoidable breaking changes -............................ - -- Replaced usage of :class:`bson.son.SON` on all internal classes and commands to dict, - :attr:`options.pool_options.metadata` is now of type ``dict`` as opposed to :class:`bson.son.SON`. - Here's some examples of how this changes expected output as well as how to convert from :class:`dict` to :class:`bson.son.SON`:: - - # Before - >>> from pymongo import MongoClient - >>> client = MongoClient() - >>> client.options.pool_options.metadata - SON([('driver', SON([('name', 'PyMongo'), ('version', '4.7.0.dev0')])), ('os', SON([('type', 'Darwin'), ('name', 'Darwin'), ('architecture', 'arm64'), ('version', '14.3')])), ('platform', 'CPython 3.11.6.final.0')]) - - # After - >>> client.options.pool_options.metadata - {'driver': {'name': 'PyMongo', 'version': '4.7.0.dev0'}, 'os': {'type': 'Darwin', 'name': 'Darwin', 'architecture': 'arm64', 'version': '14.3'}, 'platform': 'CPython 3.11.6.final.0'} - - # To convert from dict to SON - # This will only convert the first layer of the dictionary - >>> data_as_dict = client.options.pool_options.metadata - >>> SON(data_as_dict) - SON([('driver', {'name': 'PyMongo', 'version': '4.7.0.dev0'}), ('os', {'type': 'Darwin', 'name': 'Darwin', 'architecture': 'arm64', 'version': '14.3'}), ('platform', 'CPython 3.11.6.final.0')]) - - # To convert from dict to SON on a nested dictionary - >>> def dict_to_SON(data_as_dict: dict[Any, Any]): - ... data_as_SON = SON() - ... for key, value in data_as_dict.items(): - ... data_as_SON[key] = dict_to_SON(value) if isinstance(value, dict) else value - ... return data_as_SON - >>> - >>> dict_to_SON(data_as_dict) - SON([('driver', SON([('name', 'PyMongo'), ('version', '4.7.0.dev0')])), ('os', SON([('type', 'Darwin'), ('name', 'Darwin'), ('architecture', 'arm64'), ('version', '14.3')])), ('platform', 'CPython 3.11.6.final.0')]) - -- PyMongo now uses `lazy imports `_ for external dependencies. - If you are relying on any kind of monkey-patching of the standard library, you may need to explicitly import those external libraries in addition - to ``pymongo`` before applying the patch. Note that we test with ``gevent`` and ``eventlet`` patching, and those continue to work. - -- The "aws" extra now requires minimum version of ``1.1.0`` for ``pymongo_auth_aws``. - -Changes in Version 4.6.3 (2024/03/27) -------------------------------------- - -PyMongo 4.6.3 fixes the following bug: - -- Fixed a potential memory access violation when decoding invalid bson. - -Issues Resolved -............... - -See the `PyMongo 4.6.3 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.6.3 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=38360 - -Changes in Version 4.6.2 (2024/02/21) -------------------------------------- - -PyMongo 4.6.2 fixes the following bug: - -- Fixed a bug appearing in Python 3.12 where "RuntimeError: can't create new thread at interpreter shutdown" - could be written to stderr when a MongoClient's thread starts as the python interpreter is shutting down. - -Issues Resolved -............... - -See the `PyMongo 4.6.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.6.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=37906 - -Changes in Version 4.6.1 (2023/11/29) -------------------------------------- - -PyMongo 4.6.1 fixes the following bug: - -- Ensure retryable read ``OperationFailure`` errors re-raise exception when 0 or NoneType error code is provided. - -Issues Resolved -............... - -See the `PyMongo 4.6.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.6.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=37138 - -Changes in Version 4.6.0 (2023/11/01) -------------------------------------- - -PyMongo 4.6 brings a number of improvements including: - -- Added the ``serverMonitoringMode`` URI and keyword argument to :class:`~pymongo.mongo_client.MongoClient`. -- Improved client performance and reduced connection requirements in Function-as-a-service (FaaS) - environments like AWS Lambda, Google Cloud Functions, and Microsoft Azure Functions. -- Added the :attr:`pymongo.monitoring.CommandSucceededEvent.database_name` property. -- Added the :attr:`pymongo.monitoring.CommandFailedEvent.database_name` property. -- Allow passing a ``dict`` to sort/create_index/hint. -- Added :func:`repr` support to the write result classes: - :class:`~pymongo.results.BulkWriteResult`, - :class:`~pymongo.results.DeleteResult`, - :class:`~pymongo.results.InsertManyResult`, - :class:`~pymongo.results.InsertOneResult`, - :class:`~pymongo.results.UpdateResult`, and - :class:`~pymongo.encryption.RewrapManyDataKeyResult`. For example: - - >>> client.t.t.insert_one({}) - InsertOneResult(ObjectId('65319acdd55bb3a27ab5502b'), acknowledged=True) - >>> client.t.t.insert_many([{} for _ in range(3)]) - InsertManyResult([ObjectId('6532f85e826f2b6125d6ce39'), ObjectId('6532f85e826f2b6125d6ce3a'), ObjectId('6532f85e826f2b6125d6ce3b')], acknowledged=True) - -- :meth:`~pymongo.uri_parser.parse_uri` now considers the delimiting slash (``/``) - between hosts and connection options optional. For example, - "mongodb://example.com?tls=true" is now a valid URI. -- Fixed a bug where PyMongo would incorrectly promote all cursors to exhaust cursors - when connected to load balanced MongoDB clusters or Serverless clusters. -- Added the `network compression `_ documentation page. -- Added more timeout information to network errors. - -Issues Resolved -............... - -See the `PyMongo 4.6 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.6 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=36542 - -Changes in Version 4.5.0 (2023/08/22) -------------------------------------- - -PyMongo 4.5 brings a number of improvements including: - -- Added new helper methods for Atlas Search Index (requires MongoDB Server 7.0+): - :meth:`~pymongo.collection.Collection.list_search_indexes`, - :meth:`~pymongo.collection.Collection.create_search_index`, - :meth:`~pymongo.collection.Collection.create_search_indexes`, - :meth:`~pymongo.collection.Collection.drop_search_index`, - :meth:`~pymongo.collection.Collection.update_search_index` -- Added :meth:`~pymongo.database.Database.cursor_command` - and :meth:`~pymongo.command_cursor.CommandCursor.try_next` to support - executing an arbitrary command that returns a cursor. -- ``cryptography`` 2.5 or later is now required for `OCSP `_ support. -- Improved bson encoding and decoding performance by up to 134%(`PYTHON-3729`_, `PYTHON-3797`_, `PYTHON-3816`_, `PYTHON-3817`_, `PYTHON-3820`_, `PYTHON-3824`_, and `PYTHON-3846`_). - -.. warning:: PyMongo no longer supports PyPy3 versions older than 3.8. Users - must upgrade to PyPy3.8+. - -Issues Resolved -............... - -See the `PyMongo 4.5 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.5 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=35492 - -.. _PYTHON-3729: https://jira.mongodb.org/browse/PYTHON-3729 -.. _PYTHON-3797: https://jira.mongodb.org/browse/PYTHON-3797 -.. _PYTHON-3816: https://jira.mongodb.org/browse/PYTHON-3816 -.. _PYTHON-3817: https://jira.mongodb.org/browse/PYTHON-3817 -.. _PYTHON-3820: https://jira.mongodb.org/browse/PYTHON-3820 -.. _PYTHON-3824: https://jira.mongodb.org/browse/PYTHON-3824 -.. _PYTHON-3846: https://jira.mongodb.org/browse/PYTHON-3846 - -Changes in Version 4.4.1 (2023/07/13) -------------------------------------- - -Version 4.4.1 fixes the following bugs: - -- Fixed a bug where pymongo would raise a ``ConfigurationError: Invalid SRV host`` - error when connecting to a "mongodb+srv://" URI that included capital letters - in the SRV hosts returned from DNS. (`PYTHON-3800`_). -- Fixed a minor reference counting bug in the C extension (`PYTHON-3798`_). - -Issues Resolved -............... - -See the `PyMongo 4.4.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PYTHON-3798: https://jira.mongodb.org/browse/PYTHON-3798 -.. _PYTHON-3800: https://jira.mongodb.org/browse/PYTHON-3800 -.. _PyMongo 4.4.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=36329 - -Changes in Version 4.4.0 (2023/06/21) -------------------------------------- - -PyMongo 4.4 brings a number of improvements including: - -- Added support for MongoDB 7.0. -- Added support for Python 3.11. -- Added support for passing a list containing (key, direction) pairs - or keys to :meth:`~pymongo.collection.Collection.create_index`. -- Improved bson encoding performance (`PYTHON-3717`_ and `PYTHON-3718`_). -- Improved support for Pyright to improve typing support for IDEs like Visual Studio Code - or Visual Studio. -- Improved support for type-checking with MyPy "strict" mode (`--strict`). -- Added :meth:`~pymongo.encryption.ClientEncryption.create_encrypted_collection`, - :class:`~pymongo.errors.EncryptedCollectionError`, - :meth:`~pymongo.encryption.ClientEncryption.encrypt_expression`, - :class:`~pymongo.encryption_options.RangeOpts`, - and :attr:`~pymongo.encryption.Algorithm.RANGEPREVIEW` as part of the experimental - Queryable Encryption beta. -- pymongocrypt 1.6.0 or later is now required for `In-Use Encryption `_ support. MongoDB - Server 7.0 introduced a backwards breaking change to the QE protocol. Users taking - advantage of the Queryable Encryption beta must now upgrade to MongoDB 7.0+ and - PyMongo 4.4+. -- Previously, PyMongo's docs recommended using :meth:`datetime.datetime.utcnow` and - :meth:`datetime.datetime.utcfromtimestamp`. utcnow and utcfromtimestamp are deprecated - in Python 3.12, for reasons explained `in this Github issue`_. Instead, users should - use :meth:`datetime.datetime.now(tz=timezone.utc)` and - :meth:`datetime.datetime.fromtimestamp(tz=timezone.utc)` instead. - -.. _in this Github issue: https://github.com/python/cpython/issues/103857 - -Issues Resolved -............... - -See the `PyMongo 4.4 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.4 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=34354 - -.. _PYTHON-3717: https://jira.mongodb.org/browse/PYTHON-3717 -.. _PYTHON-3718: https://jira.mongodb.org/browse/PYTHON-3718 - -Changes in Version 4.3.3 (2022/11/17) -------------------------------------- - -Version 4.3.3 documents support for the following: - -- `CSFLE on-demand credentials `_ for cloud KMS providers. -- Authentication support for `EKS Clusters `_. -- Added the `timeout `_ example page to improve the documentation - for :func:`pymongo.timeout`. - -Bug Fixes -......... -- Fixed a performance regression in :meth:`~gridfs.GridFSBucket.download_to_stream` - and :meth:`~gridfs.GridFSBucket.download_to_stream_by_name` by reading in chunks - instead of line by line (`PYTHON-3502`_). -- Improved performance of :meth:`gridfs.grid_file.GridOut.read` and - :meth:`gridfs.grid_file.GridOut.readline` (`PYTHON-3508`_). - -Issues Resolved -............... - -See the `PyMongo 4.3.3 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PYTHON-3502: https://jira.mongodb.org/browse/PYTHON-3502 -.. _PYTHON-3508: https://jira.mongodb.org/browse/PYTHON-3508 -.. _PyMongo 4.3.3 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=34709 - -Changes in Version 4.3.2 (2022/10/18) -------------------------------------- - -Note: We withheld uploading tags 4.3.0 and 4.3.1 to PyPI due to a -version handling error and a necessary documentation update. - -`dnspython `_ is now a required -dependency. This change makes PyMongo easier to install for use with "mongodb+srv://" -connection strings and `MongoDB Atlas `_. - -PyMongo 4.3 brings a number of improvements including: - -- Added support for decoding BSON datetimes outside of the range supported - by Python's :class:`~datetime.datetime` builtin. See - `handling out of range datetimes `_ for examples, as well as - :class:`bson.datetime_ms.DatetimeMS`, - :class:`bson.codec_options.DatetimeConversion`, and - :class:`bson.codec_options.CodecOptions`'s ``datetime_conversion`` - parameter for more details (`PYTHON-1824`_). -- PyMongo now resets its locks and other shared state in the child process - after a :py:func:`os.fork` to reduce the frequency of deadlocks. Note that - deadlocks are still possible because libraries that PyMongo depends like - OpenSSL cannot be made fork() safe in multithreaded applications. - (`PYTHON-2484`_). For more info see `multiple forks `_. -- When used with MongoDB 6.0+, :class:`~pymongo.change_stream.ChangeStream` s - now allow for new types of events (such as DDL and C2C replication events) - to be recorded with the new parameter ``show_expanded_events`` - that can be passed to methods such as :meth:`~pymongo.collection.Collection.watch`. -- PyMongo now internally caches AWS credentials that it fetches from AWS - endpoints, to avoid rate limitations. The cache is cleared when the - credentials expire or an error is encountered. -- When using the ``MONGODB-AWS`` authentication mechanism with the - ``aws`` extra, the behavior of credential fetching has changed with - ``pymongo_auth_aws>=1.1.0``. Please see `Authentication `_ for - more information. - -Bug fixes -......... - -- Fixed a bug where :class:`~pymongo.change_stream.ChangeStream` - would allow an app to retry calling ``next()`` or ``try_next()`` even - after non-resumable errors (`PYTHON-3389`_). -- Fixed a bug where the client could be unable to discover the new primary - after a simultaneous replica set election and reconfig (`PYTHON-2970`_). - -Issues Resolved -............... - -See the `PyMongo 4.3 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PYTHON-1824: https://jira.mongodb.org/browse/PYTHON-1824 -.. _PYTHON-2484: https://jira.mongodb.org/browse/PYTHON-2484 -.. _PYTHON-2970: https://jira.mongodb.org/browse/PYTHON-2970 -.. _PYTHON-3389: https://jira.mongodb.org/browse/PYTHON-3389 -.. _PyMongo 4.3 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=33425 - -Changes in Version 4.2.0 (2022/07/20) -------------------------------------- - -.. warning:: PyMongo 4.2 drops support for Python 3.6: Python 3.7+ is now required. - -PyMongo 4.2 brings a number of improvements including: - -- Support for MongoDB 6.0. -- Support for the Queryable Encryption beta with MongoDB 6.0. Note that backwards-breaking - changes may be made before the final release. See `automatic queryable client-side encryption `_ for example usage. -- Provisional (beta) support for :func:`pymongo.timeout` to apply a single timeout - to an entire block of pymongo operations. See `timeout `_ for examples. -- Added the ``timeoutMS`` URI and keyword argument to :class:`~pymongo.mongo_client.MongoClient`. -- Added the :attr:`pymongo.errors.PyMongoError.timeout` property which is ``True`` when - the error was caused by a timeout. -- Added the ``check_exists`` argument to :meth:`~pymongo.database.Database.create_collection` - that when True (the default) runs an additional ``listCollections`` command to verify that the - collection does not exist already. -- Added the following key management APIs to :class:`~pymongo.encryption.ClientEncryption`: - - - :meth:`~pymongo.encryption.ClientEncryption.get_key` - - :meth:`~pymongo.encryption.ClientEncryption.get_keys` - - :meth:`~pymongo.encryption.ClientEncryption.delete_key` - - :meth:`~pymongo.encryption.ClientEncryption.add_key_alt_name` - - :meth:`~pymongo.encryption.ClientEncryption.get_key_by_alt_name` - - :meth:`~pymongo.encryption.ClientEncryption.remove_key_alt_name` - - :meth:`~pymongo.encryption.ClientEncryption.rewrap_many_data_key` - - :class:`~pymongo.encryption.RewrapManyDataKeyResult` - -- Support for the ``crypt_shared`` library to replace ``mongocryptd`` using the new - ``crypt_shared_lib_path`` and ``crypt_shared_lib_required`` arguments to - :class:`~pymongo.encryption_options.AutoEncryptionOpts`. - -Bug fixes -......... - -- Fixed a bug where :meth:`~pymongo.collection.Collection.estimated_document_count` - would fail with a "CommandNotSupportedOnView" error on views (`PYTHON-2885`_). -- Fixed a bug where invalid UTF-8 strings could be passed as patterns for :class:`~bson.regex.Regex` - objects. :func:`bson.encode` now correctly raises :class:`bson.errors.InvalidStringData` (`PYTHON-3048`_). -- Fixed a bug that caused ``AutoReconnect("connection pool paused")`` errors in the child - process after fork (`PYTHON-3257`_). -- Fixed a bug where :meth:`~pymongo.collection.Collection.count_documents` and - :meth:`~pymongo.collection.Collection.distinct` would fail in a transaction with - ``directConnection=True`` (`PYTHON-3333`_). -- GridFS no longer uploads an incomplete files collection document after encountering an - error in the middle of an upload fork. This results in fewer - :class:`~gridfs.errors.CorruptGridFile` errors (`PYTHON-1552`_). -- Renamed PyMongo's internal C extension methods to avoid crashing due to name conflicts - with mpi4py and other shared libraries (`PYTHON-2110`_). -- Fixed tight CPU loop for network I/O when using PyOpenSSL (`PYTHON-3187`_). - -Unavoidable breaking changes -............................ - -- pymongocrypt 1.3.0 or later is now required for client side field level - encryption support. -- :meth:`~pymongo.collection.Collection.estimated_document_count` now always uses - the `count`_ command. Due to an oversight in versions 5.0.0-5.0.8 of MongoDB, - the count command was not included in V1 of the `Stable API `_. - Users of the Stable API with estimated_document_count are recommended to upgrade - their server version to 5.0.9+ or set :attr:`pymongo.server_api.ServerApi.strict` - to ``False`` to avoid encountering errors (`PYTHON-3167`_). -- Removed generic typing from :class:`~pymongo.client_session.ClientSession` to improve - support for Pyright (`PYTHON-3283`_). -- Added ``__all__`` to the bson, pymongo, and gridfs packages. This could be a breaking - change for apps that relied on ``from bson import *`` to import APIs not present in - ``__all__`` (`PYTHON-3311`_). - -.. _count: https://mongodb.com/docs/manual/reference/command/count/ - -Issues Resolved -............... - -See the `PyMongo 4.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PYTHON-3048: https://jira.mongodb.org/browse/PYTHON-3048 -.. _PYTHON-2885: https://jira.mongodb.org/browse/PYTHON-2885 -.. _PYTHON-3167: https://jira.mongodb.org/browse/PYTHON-3167 -.. _PYTHON-3257: https://jira.mongodb.org/browse/PYTHON-3257 -.. _PYTHON-3333: https://jira.mongodb.org/browse/PYTHON-3333 -.. _PYTHON-1552: https://jira.mongodb.org/browse/PYTHON-1552 -.. _PYTHON-2110: https://jira.mongodb.org/browse/PYTHON-2110 -.. _PYTHON-3283: https://jira.mongodb.org/browse/PYTHON-3283 -.. _PYTHON-3311: https://jira.mongodb.org/browse/PYTHON-3311 -.. _PYTHON-3187: https://jira.mongodb.org/browse/PYTHON-3187 -.. _PyMongo 4.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=33196 - -Changes in Version 4.1.1 (2022/04/13) -------------------------------------- - -Version 4.1.1 fixes a number of bugs: - -- Fixed a memory leak bug when calling :func:`~bson.decode_all` without a - ``codec_options`` argument (`PYTHON-3222`_). -- Fixed a bug where :func:`~bson.decode_all` did not accept ``codec_options`` - as a keyword argument (`PYTHON-3222`_). -- Fixed an oversight where type markers (py.typed files) were not included - in our release distributions (`PYTHON-3214`_). -- Fixed a bug where pymongo would raise a "NameError: name sys is not defined" - exception when attempting to parse a "mongodb+srv://" URI when the dnspython - dependency was not installed (`PYTHON-3198`_). - -Issues Resolved -............... - -See the `PyMongo 4.1.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PYTHON-3198: https://jira.mongodb.org/browse/PYTHON-3198 -.. _PYTHON-3214: https://jira.mongodb.org/browse/PYTHON-3214 -.. _PYTHON-3222: https://jira.mongodb.org/browse/PYTHON-3222 -.. _PyMongo 4.1.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=33290 - -Changes in Version 4.1 (2021/12/07) ------------------------------------ - -.. warning:: PyMongo 4.1 drops support for Python 3.6.0 and 3.6.1, Python 3.6.2+ is now required. - -PyMongo 4.1 brings a number of improvements including: - -- Type Hinting support (formerly provided by `pymongo-stubs`_). See `Type Hints `_ for more information. -- Added support for the ``comment`` parameter to all helpers. For example see - :meth:`~pymongo.collection.Collection.insert_one`. -- Added support for the ``let`` parameter to - :meth:`~pymongo.collection.Collection.update_one`, - :meth:`~pymongo.collection.Collection.update_many`, - :meth:`~pymongo.collection.Collection.delete_one`, - :meth:`~pymongo.collection.Collection.delete_many`, - :meth:`~pymongo.collection.Collection.replace_one`, - :meth:`~pymongo.collection.Collection.aggregate`, - :meth:`~pymongo.collection.Collection.find_one_and_delete`, - :meth:`~pymongo.collection.Collection.find_one_and_replace`, - :meth:`~pymongo.collection.Collection.find_one_and_update`, - :meth:`~pymongo.collection.Collection.find`, - :meth:`~pymongo.collection.Collection.find_one`, - and :meth:`~pymongo.collection.Collection.bulk_write`. - ``let`` is a map of parameter names and values. - Parameters can then be accessed as variables in an aggregate expression - context. -- :meth:`~pymongo.collection.Collection.aggregate` now supports - $merge and $out executing on secondaries on MongoDB >=5.0. - aggregate() now always obeys the collection's :attr:`read_preference` on - MongoDB >= 5.0. -- :meth:`gridfs.grid_file.GridOut.seek` now returns the new position in the file, to - conform to the behavior of :meth:`io.IOBase.seek`. -- Improved reuse of implicit sessions (`PYTHON-2956`_). - -Bug fixes -......... - -- Fixed bug that would cause SDAM heartbeat timeouts and connection churn on - AWS Lambda and other FaaS environments (`PYTHON-3186`_). -- Fixed bug where :class:`~pymongo.mongo_client.MongoClient`, - :class:`~pymongo.database.Database`, and :class:`~pymongo.collection.Collection` - mistakenly implemented :class:`typing.Iterable` (`PYTHON-3084`_). - -Issues Resolved -............... - -See the `PyMongo 4.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=30619 -.. _PYTHON-2956: https://jira.mongodb.org/browse/PYTHON-2956 -.. _PYTHON-3084: https://jira.mongodb.org/browse/PYTHON-3084 -.. _PYTHON-3186: https://jira.mongodb.org/browse/PYTHON-3186 -.. _pymongo-stubs: https://github.com/mongodb-labs/pymongo-stubs - -Changes in Version 4.0.2 (2022/03/03) -------------------------------------- - -- No changes - -Changes in Version 4.0.1 (2021/12/07) -------------------------------------- - -- No changes - -Changes in Version 4.0 (2021/11/29) ------------------------------------ - -.. warning:: PyMongo 4.0 drops support for Python 2.7, 3.4, and 3.5. - -.. warning:: PyMongo 4.0 drops support for MongoDB 2.6, 3.0, 3.2, and 3.4. - -.. warning:: PyMongo 4.0 changes the default value of the ``directConnection`` URI option and - keyword argument to :class:`~pymongo.mongo_client.MongoClient` - to ``False`` instead of ``None``, allowing for the automatic - discovery of replica sets. This means that if you - want a direct connection to a single server you must pass - ``directConnection=True`` as a URI option or keyword argument. - For more details, see the relevant section of the PyMongo 4.x migration - guide: :ref:`pymongo4-migration-direct-connection`. - -PyMongo 4.0 brings a number of improvements as well as some backward breaking -changes. For example, all APIs deprecated in PyMongo 3.X have been removed. -Be sure to read the changes listed below and the :doc:`migrate-to-pymongo4` -before upgrading from PyMongo 3.x. - -Breaking Changes in 4.0 -....................... - -- Removed support for Python 2.7, 3.4, and 3.5. Python 3.6.2+ is now required. -- The default uuid_representation for :class:`~bson.codec_options.CodecOptions`, - :class:`~bson.json_util.JSONOptions`, and - :class:`~pymongo.mongo_client.MongoClient` has been changed from - :data:`bson.binary.UuidRepresentation.PYTHON_LEGACY` to - :data:`bson.binary.UuidRepresentation.UNSPECIFIED`. Attempting to encode a - :class:`uuid.UUID` instance to BSON or JSON now produces an error by default. - See `UUID representations `_ for details. -- Removed the ``waitQueueMultiple`` keyword argument to - :class:`~pymongo.mongo_client.MongoClient` and removed - :exc:`pymongo.errors.ExceededMaxWaiters`. -- Removed the ``socketKeepAlive`` keyword argument to - :class:`~pymongo.mongo_client.MongoClient`. -- Removed :meth:`pymongo.mongo_client.MongoClient.fsync`, - :meth:`pymongo.mongo_client.MongoClient.unlock`, and - :attr:`pymongo.mongo_client.MongoClient.is_locked`. -- Removed :meth:`pymongo.mongo_client.MongoClient.database_names`. -- Removed :attr:`pymongo.mongo_client.MongoClient.max_bson_size`. -- Removed :attr:`pymongo.mongo_client.MongoClient.max_message_size`. -- Removed :attr:`pymongo.mongo_client.MongoClient.max_write_batch_size`. -- Removed :attr:`pymongo.mongo_client.MongoClient.event_listeners`. -- Removed :attr:`pymongo.mongo_client.MongoClient.max_pool_size`. -- Removed :attr:`pymongo.mongo_client.MongoClient.max_idle_time_ms`. -- Removed :attr:`pymongo.mongo_client.MongoClient.local_threshold_ms`. -- Removed :attr:`pymongo.mongo_client.MongoClient.server_selection_timeout`. -- Removed :attr:`pymongo.mongo_client.MongoClient.retry_writes`. -- Removed :attr:`pymongo.mongo_client.MongoClient.retry_reads`. -- Removed :meth:`pymongo.database.Database.eval`, - :data:`pymongo.database.Database.system_js` and - :class:`pymongo.database.SystemJS`. -- Removed :meth:`pymongo.database.Database.collection_names`. -- Removed :meth:`pymongo.database.Database.current_op`. -- Removed :meth:`pymongo.database.Database.authenticate` and - :meth:`pymongo.database.Database.logout`. -- Removed :meth:`pymongo.database.Database.error`, - :meth:`pymongo.database.Database.last_status`, - :meth:`pymongo.database.Database.previous_error`, - :meth:`pymongo.database.Database.reset_error_history`. -- Removed :meth:`pymongo.database.Database.add_user` and - :meth:`pymongo.database.Database.remove_user`. -- Removed support for database profiler helpers - :meth:`~pymongo.database.Database.profiling_level`, - :meth:`~pymongo.database.Database.set_profiling_level`, - and :meth:`~pymongo.database.Database.profiling_info`. Instead, users - should run the `profile command`_ with the - :meth:`~pymongo.database.Database.command` helper directly. -- Removed :attr:`pymongo.OFF`, :attr:`pymongo.SLOW_ONLY`, and - :attr:`pymongo.ALL`. -- Removed :meth:`pymongo.collection.Collection.parallel_scan`. -- Removed :meth:`pymongo.collection.Collection.ensure_index`. -- Removed :meth:`pymongo.collection.Collection.reindex`. -- Removed :meth:`pymongo.collection.Collection.save`. -- Removed :meth:`pymongo.collection.Collection.insert`. -- Removed :meth:`pymongo.collection.Collection.update`. -- Removed :meth:`pymongo.collection.Collection.remove`. -- Removed :meth:`pymongo.collection.Collection.find_and_modify`. -- Removed :meth:`pymongo.collection.Collection.count`. -- Removed :meth:`pymongo.collection.Collection.initialize_ordered_bulk_op`, - :meth:`pymongo.collection.Collection.initialize_unordered_bulk_op`, and - :class:`pymongo.bulk.BulkOperationBuilder`. Use - :meth:`pymongo.collection.Collection.bulk_write` instead. -- Removed :meth:`pymongo.collection.Collection.group`. -- Removed :meth:`pymongo.collection.Collection.map_reduce` and - :meth:`pymongo.collection.Collection.inline_map_reduce`. -- Removed the ``useCursor`` option for - :meth:`~pymongo.collection.Collection.aggregate`. -- Removed :meth:`pymongo.mongo_client.MongoClient.close_cursor`. Use - :meth:`pymongo.cursor.Cursor.close` instead. -- Removed :meth:`pymongo.mongo_client.MongoClient.kill_cursors`. -- Removed :class:`pymongo.cursor_manager.CursorManager` and - :mod:`pymongo.cursor_manager`. -- Removed :meth:`pymongo.mongo_client.MongoClient.set_cursor_manager`. -- Removed :meth:`pymongo.cursor.Cursor.count`. -- Removed :mod:`pymongo.thread_util`. -- Removed :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`. -- Removed :class:`~pymongo.ismaster.IsMaster`. - Use :class:`~pymongo.hello.Hello` instead. -- Removed :mod:`pymongo.son_manipulator`, - :class:`pymongo.son_manipulator.SONManipulator`, - :class:`pymongo.son_manipulator.ObjectIdInjector`, - :class:`pymongo.son_manipulator.ObjectIdShuffler`, - :class:`pymongo.son_manipulator.AutoReference`, - :class:`pymongo.son_manipulator.NamespaceInjector`, - :meth:`pymongo.database.Database.add_son_manipulator`, - :attr:`pymongo.database.Database.outgoing_copying_manipulators`, - :attr:`pymongo.database.Database.outgoing_manipulators`, - :attr:`pymongo.database.Database.incoming_copying_manipulators`, and - :attr:`pymongo.database.Database.incoming_manipulators`. -- Removed the ``manipulate`` and ``modifiers`` parameters from - :meth:`~pymongo.collection.Collection.find`, - :meth:`~pymongo.collection.Collection.find_one`, - :meth:`~pymongo.collection.Collection.find_raw_batches`, and - :meth:`~pymongo.cursor.Cursor`. -- Removed :meth:`pymongo.message.delete`, :meth:`pymongo.message.get_more`, - :meth:`pymongo.message.insert`, :meth:`pymongo.message.kill_cursors`, - :meth:`pymongo.message.query`, and :meth:`pymongo.message.update`. -- Removed :exc:`pymongo.errors.NotMasterError`. - Use :exc:`pymongo.errors.NotPrimaryError` instead. -- Removed :exc:`pymongo.errors.CertificateError`. -- Removed :attr:`pymongo.GEOHAYSTACK`. -- Removed :class:`bson.binary.UUIDLegacy`. -- Removed :const:`bson.json_util.STRICT_JSON_OPTIONS`. Use - :const:`~bson.json_util.RELAXED_JSON_OPTIONS` or - :const:`~bson.json_util.CANONICAL_JSON_OPTIONS` instead. -- Changed the default JSON encoding representation from legacy to relaxed. - The json_mode parameter for :const:`bson.json_util.dumps` now defaults to - :const:`~bson.json_util.RELAXED_JSON_OPTIONS`. -- Changed the BSON and JSON decoding behavior of :class:`~bson.dbref.DBRef` - to match the behavior outlined in the `DBRef specification`_ version 1.0. - Specifically, PyMongo now only decodes a subdocument into a - :class:`~bson.dbref.DBRef` if and only if, it contains both ``$ref`` and - ``$id`` fields and the ``$ref``, ``$id``, and ``$db`` fields are of the - correct type. Otherwise the document is returned as normal. Previously, any - subdocument containing a ``$ref`` field would be decoded as a - :class:`~bson.dbref.DBRef`. -- The "tls" install extra is no longer necessary or supported and will be - ignored by pip. -- The ``tz_aware`` argument to :class:`~bson.json_util.JSONOptions` - now defaults to ``False`` instead of ``True``. :meth:`bson.json_util.loads` now - decodes datetime as naive by default. See :ref:`tz_aware_default_change` for more info. -- ``directConnection`` URI option and keyword argument to :class:`~pymongo.mongo_client.MongoClient` - defaults to ``False`` instead of ``None``, allowing for the automatic - discovery of replica sets. This means that if you - want a direct connection to a single server you must pass - ``directConnection=True`` as a URI option or keyword argument. -- The ``hint`` option is now required when using ``min`` or ``max`` queries - with :meth:`~pymongo.collection.Collection.find`. -- ``name`` is now a required argument for the :class:`pymongo.driver_info.DriverInfo` class. -- When providing a "mongodb+srv://" URI to - :class:`~pymongo.mongo_client.MongoClient` constructor you can now use the - ``srvServiceName`` URI option to specify your own SRV service name. -- :meth:`~bson.son.SON.items` now returns a ``dict_items`` object rather - than a list. -- Removed :meth:`bson.son.SON.iteritems`. -- :class:`~pymongo.collection.Collection` and :class:`~pymongo.database.Database` - now raises an error upon evaluating as a Boolean, please use the - syntax ``if collection is not None:`` or ``if database is not None:`` as - opposed to - the previous syntax which was simply ``if collection:`` or ``if database:``. - You must now explicitly compare with None. -- :class:`~pymongo.mongo_client.MongoClient` cannot execute any operations - after being closed. The previous behavior would simply reconnect. However, - now you must create a new instance. -- Classes :class:`~bson.int64.Int64`, :class:`~bson.min_key.MinKey`, - :class:`~bson.max_key.MaxKey`, :class:`~bson.timestamp.Timestamp`, - :class:`~bson.regex.Regex`, and :class:`~bson.dbref.DBRef` all implement - ``__slots__`` now. This means that their attributes are fixed, and new - attributes cannot be added to them at runtime. -- Empty projections (eg {} or []) for - :meth:`~pymongo.collection.Collection.find`, and - :meth:`~pymongo.collection.Collection.find_one` - are passed to the server as-is rather than the previous behavior which - substituted in a projection of ``{"_id": 1}``. This means that an empty - projection will now return the entire document, not just the ``"_id"`` field. -- :class:`~pymongo.mongo_client.MongoClient` now raises a - :exc:`~pymongo.errors.ConfigurationError` when more than one URI is passed - into the ``hosts`` argument. -- :class:`~pymongo.mongo_client.MongoClient`` now raises an - :exc:`~pymongo.errors.InvalidURI` exception - when it encounters unescaped percent signs in username and password when - parsing MongoDB URIs. -- Comparing two :class:`~pymongo.mongo_client.MongoClient` instances now - uses a set of immutable properties rather than - :attr:`~pymongo.mongo_client.MongoClient.address` which can change. -- Removed the ``disable_md5`` parameter for :class:`~gridfs.GridFSBucket` and - :class:`~gridfs.GridFS`. See :ref:`removed-gridfs-checksum` for details. -- pymongocrypt 1.2.0 or later is now required for client side field level - encryption support. - -Notable improvements -.................... - -- Enhanced connection pooling to create connections more efficiently and - avoid connection storms. -- Added the ``maxConnecting`` URI and - :class:`~pymongo.mongo_client.MongoClient` keyword argument. -- :class:`~pymongo.mongo_client.MongoClient` now accepts a URI and keyword - argument ``srvMaxHosts`` that limits the number of mongos-like hosts a client - will connect to. More specifically, when a mongodb+srv:// connection string - resolves to more than ``srvMaxHosts`` number of hosts, the client will randomly - choose a ``srvMaxHosts`` sized subset of hosts. -- Added :attr:`pymongo.mongo_client.MongoClient.options` for read-only access - to a client's configuration options. -- Support for the "kmip" KMS provider for client side field level encryption. - See the docstring for :class:`~pymongo.encryption_options.AutoEncryptionOpts` - and :mod:`~pymongo.encryption`. - -Issues Resolved -............... - -See the `PyMongo 4.0 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4.0 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=18463 -.. _DBRef specification: https://github.com/mongodb/specifications/blob/master/source/dbref/dbref.md - -Changes in Version 3.13.0 (2022/11/01) --------------------------------------- - -Version 3.13 provides an upgrade path to PyMongo 4.x. Most of the API changes -from PyMongo 4.0 have been backported in a backward compatible way, allowing -applications to be written against PyMongo >= 3.13, rather then PyMongo 3.x or -PyMongo 4.x. See the `PyMongo 4 Migration Guide`_ for detailed examples. - -Notable improvements -.................... -- Added :attr:`pymongo.mongo_client.MongoClient.options` for read-only access - to a client's configuration options. - - -Issues Resolved -............... - -PyMongo 3.13 drops support for Python 3.4. - -Bug fixes -......... - -- Fixed a memory leak bug when calling :func:`~bson.decode_all` without a - ``codec_options`` argument (`PYTHON-3222`_). -- Fixed a bug where :func:`~bson.decode_all` did not accept ``codec_options`` - as a keyword argument (`PYTHON-3222`_). - -Deprecations -............ -- Deprecated :meth:`~pymongo.collection.Collection.map_reduce` and - :meth:`~pymongo.collection.Collection.inline_map_reduce`. - Use :meth:`~pymongo.collection.Collection.aggregate` instead. -- Deprecated :attr:`pymongo.mongo_client.MongoClient.event_listeners`. - Use :attr:`~pymongo.mongo_client.options.event_listeners` instead. -- Deprecated :attr:`pymongo.mongo_client.MongoClient.max_pool_size`. - Use :attr:`~pymongo.mongo_client.options.pool_options.max_pool_size` instead. -- Deprecated :attr:`pymongo.mongo_client.MongoClient.max_idle_time_ms`. - Use :attr:`~pymongo.mongo_client.options.pool_options.max_idle_time_seconds` instead. -- Deprecated :attr:`pymongo.mongo_client.MongoClient.local_threshold_ms`. - Use :attr:`~pymongo.mongo_client.options.local_threshold_ms` instead. -- Deprecated :attr:`pymongo.mongo_client.MongoClient.server_selection_timeout`. - Use :attr:`~pymongo.mongo_client.options.server_selection_timeout` instead. -- Deprecated :attr:`pymongo.mongo_client.MongoClient.retry_writes`. - Use :attr:`~pymongo.mongo_client.options.retry_writes` instead. -- Deprecated :attr:`pymongo.mongo_client.MongoClient.retry_reads`. - Use :attr:`~pymongo.mongo_client.options.retry_reads` instead. -- Deprecated :attr:`pymongo.mongo_client.MongoClient.max_bson_size`, - :attr:`pymongo.mongo_client.MongoClient.max_message_size`, and - :attr:`pymongo.mongo_client.MongoClient.max_write_batch_size`. These helpers - were incorrect when in ``loadBalanced=true mode`` and ambiguous in clusters - with mixed versions. Use the `hello command`_ to get the authoritative - value from the remote server instead. Code like this:: - - max_bson_size = client.max_bson_size - max_message_size = client.max_message_size - max_write_batch_size = client.max_write_batch_size - -can be changed to this:: - - doc = client.admin.command('hello') - max_bson_size = doc['maxBsonObjectSize'] - max_message_size = doc['maxMessageSizeBytes'] - max_write_batch_size = doc['maxWriteBatchSize'] - -.. _hello command: https://docs.mongodb.com/manual/reference/command/hello/ - -See the `PyMongo 3.13.0 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 4 Migration Guide: https://pymongo.readthedocs.io/en/stable/migrate-to-pymongo4.html -.. _PYTHON-3222: https://jira.mongodb.org/browse/PYTHON-3222 -.. _PyMongo 3.13.0 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=31570 - -Changes in Version 3.12.3 (2021/12/07) --------------------------------------- - -Issues Resolved -............... - -Version 3.12.3 fixes a bug that prevented :meth:`bson.json_util.loads` from -decoding a document with a non-string "$regex" field (`PYTHON-3028`_). - -See the `PyMongo 3.12.3 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PYTHON-3028: https://jira.mongodb.org/browse/PYTHON-3028 -.. _PyMongo 3.12.3 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=32505 - -Changes in Version 3.12.2 (2021/11/29) --------------------------------------- - -Issues Resolved -............... - -Version 3.12.2 fixes a number of bugs: - -- Fixed a bug that prevented PyMongo from retrying bulk writes - after a ``writeConcernError`` on MongoDB 4.4+ (`PYTHON-2984`_). -- Fixed a bug that could cause the driver to hang during automatic - client side field level encryption (`PYTHON-3017`_). - -See the `PyMongo 3.12.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PYTHON-2984: https://jira.mongodb.org/browse/PYTHON-2984 -.. _PYTHON-3017: https://jira.mongodb.org/browse/PYTHON-3017 -.. _PyMongo 3.12.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=32310 - -Changes in Version 3.12.1 (2021/10/19) --------------------------------------- - -Issues Resolved -............... - -Version 3.12.1 fixes a number of bugs: - -- Fixed a bug that caused a multi-document transaction to fail when the first - operation was large bulk write (>48MB) that required splitting a batched - write command (`PYTHON-2915`_). -- Fixed a bug that caused the ``tlsDisableOCSPEndpointCheck`` URI option to - be applied incorrectly (`PYTHON-2866`_). - -See the `PyMongo 3.12.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PYTHON-2915: https://jira.mongodb.org/browse/PYTHON-2915 -.. _PYTHON-2866: https://jira.mongodb.org/browse/PYTHON-2866 -.. _PyMongo 3.12.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=31527 - -Changes in Version 3.12.0 (2021/07/13) --------------------------------------- - -.. warning:: PyMongo 3.12.0 deprecates support for Python 2.7, 3.4 and 3.5. - These Python versions will not be supported by PyMongo 4. - -.. warning:: PyMongo now allows insertion of documents with keys that include - dots ('.') or start with dollar signs ('$'). - -- pymongocrypt 1.1.0 or later is now required for client side field level - encryption support. -- Iterating over :class:`gridfs.grid_file.GridOut` now moves through - the file line by line instead of chunk by chunk, and does not - restart at the top for subsequent iterations on the same object. - Call ``seek(0)`` to reset the iterator. - -Notable improvements -.................... - -- Added support for MongoDB 5.0. -- Support for MongoDB Stable API, see :class:`~pymongo.server_api.ServerApi`. -- Support for snapshot reads on secondaries (see `snapshot reads `_). -- Support for Azure and GCP KMS providers for client side field level - encryption. See the docstring for :class:`~pymongo.mongo_client.MongoClient`, - :class:`~pymongo.encryption_options.AutoEncryptionOpts`, - and :mod:`~pymongo.encryption`. -- Support AWS authentication with temporary credentials when connecting to KMS - in client side field level encryption. -- Support for connecting to load balanced MongoDB clusters via the new - ``loadBalanced`` URI option. -- Support for creating timeseries collections via the ``timeseries`` and - ``expireAfterSeconds`` arguments to - :meth:`~pymongo.database.Database.create_collection`. -- Added :attr:`pymongo.mongo_client.MongoClient.topology_description`. -- Added hash support to :class:`~pymongo.mongo_client.MongoClient`, - :class:`~pymongo.database.Database` and - :class:`~pymongo.collection.Collection` (`PYTHON-2466`_). -- Improved the error message returned by - :meth:`~pymongo.collection.Collection.insert_many` when supplied with an - argument of incorrect type (`PYTHON-1690`_). -- Added session and read concern support to - :meth:`~pymongo.collection.Collection.find_raw_batches` - and :meth:`~pymongo.collection.Collection.aggregate_raw_batches`. - -Bug fixes -......... - -- Fixed a bug that could cause the driver to deadlock during automatic - client side field level encryption (`PYTHON-2472`_). -- Fixed a potential deadlock when garbage collecting an unclosed exhaust - :class:`~pymongo.cursor.Cursor`. -- Fixed an bug where using gevent.Timeout to timeout an operation could - lead to a deadlock. -- Fixed the following bug with Atlas Data Lake. When closing cursors, - pymongo now sends killCursors with the namespace returned the cursor's - initial command response. -- Fixed a bug in :class:`~pymongo.cursor.RawBatchCursor` that caused it to - return an empty bytestring when the cursor contained no results. It now - raises :exc:`StopIteration` instead. - -Deprecations -............ - -- Deprecated support for Python 2.7, 3.4 and 3.5. -- Deprecated support for database profiler helpers - :meth:`~pymongo.database.Database.profiling_level`, - :meth:`~pymongo.database.Database.set_profiling_level`, - and :meth:`~pymongo.database.Database.profiling_info`. Instead, users - should run the `profile command`_ with the - :meth:`~pymongo.database.Database.command` helper directly. -- Deprecated :exc:`~pymongo.errors.NotMasterError`. Users should - use :exc:`~pymongo.errors.NotPrimaryError` instead. -- Deprecated :class:`~pymongo.ismaster.IsMaster` and :mod:`~pymongo.ismaster` - which will be removed in PyMongo 4.0 and are replaced by - :class:`~pymongo.hello.Hello` and :mod:`~pymongo.hello` which provide the - same API. -- Deprecated the :mod:`pymongo.messeage` module. -- Deprecated the ``ssl_keyfile`` and ``ssl_certfile`` URI options in favor - of ``tlsCertificateKeyFile`` (see `TLS `_). - -.. _PYTHON-2466: https://jira.mongodb.org/browse/PYTHON-2466 -.. _PYTHON-1690: https://jira.mongodb.org/browse/PYTHON-1690 -.. _PYTHON-2472: https://jira.mongodb.org/browse/PYTHON-2472 -.. _profile command: https://mongodb.com/docs/manual/reference/command/profile/ - -Issues Resolved -............... - -See the `PyMongo 3.12.0 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.12.0 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=29594 - -Changes in Version 3.11.3 (2021/02/02) --------------------------------------- - -Issues Resolved -............... - -Version 3.11.3 fixes a bug that prevented PyMongo from retrying writes after -a ``writeConcernError`` on MongoDB 4.4+ (`PYTHON-2452`_) - -See the `PyMongo 3.11.3 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PYTHON-2452: https://jira.mongodb.org/browse/PYTHON-2452 -.. _PyMongo 3.11.3 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=30355 - -Changes in Version 3.11.2 (2020/12/02) --------------------------------------- - -Issues Resolved -............... - -Version 3.11.2 includes a number of bugfixes. Highlights include: - -- Fixed a memory leak caused by failing SDAM monitor checks on Python 3 (`PYTHON-2433`_). -- Fixed a regression that changed the string representation of - :exc:`~pymongo.errors.BulkWriteError` (`PYTHON-2438`_). -- Fixed a bug that made it impossible to use - :meth:`bson.codec_options.CodecOptions.with_options` and - :meth:`~bson.json_util.JSONOptions.with_options` on some early versions of - Python 3.4 and Python 3.5 due to a bug in the standard library implementation - of :meth:`collections.namedtuple._asdict` (`PYTHON-2440`_). -- Fixed a bug that resulted in a :exc:`TypeError` exception when a PyOpenSSL - socket was configured with a timeout of ``None`` (`PYTHON-2443`_). - -See the `PyMongo 3.11.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PYTHON-2433: https://jira.mongodb.org/browse/PYTHON-2433 -.. _PYTHON-2438: https://jira.mongodb.org/browse/PYTHON-2438 -.. _PYTHON-2440: https://jira.mongodb.org/browse/PYTHON-2440 -.. _PYTHON-2443: https://jira.mongodb.org/browse/PYTHON-2443 -.. _PyMongo 3.11.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=30315 - -Changes in Version 3.11.1 (2020/11/17) --------------------------------------- - -Version 3.11.1 adds support for Python 3.9 and includes a number of bugfixes. -Highlights include: - -- Support for Python 3.9. -- Initial support for Azure and GCP KMS providers for client side field level - encryption is in beta. See the docstring for - :class:`~pymongo.mongo_client.MongoClient`, - :class:`~pymongo.encryption_options.AutoEncryptionOpts`, - and :mod:`~pymongo.encryption`. **Note: Backwards-breaking changes may be - made before the final release.** -- Fixed a bug where the :class:`bson.json_util.JSONOptions` API did not match - the :class:`bson.codec_options.CodecOptions` API due to the absence of - a :meth:`bson.json_util.JSONOptions.with_options` method. This method has now - been added. -- Fixed a bug which made it impossible to serialize - :class:`~pymongo.errors.BulkWriteError` instances using :mod:`pickle`. -- Fixed a bug wherein PyMongo did not always discard an implicit session after - encountering a network error. -- Fixed a bug where connections created in the background were not - authenticated. -- Fixed a memory leak in the :mod:`bson` module when using a - :class:`~bson.codec_options.TypeRegistry`. - -Issues Resolved -............... - -See the `PyMongo 3.11.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.11.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=29997 - -Changes in Version 3.11.0 (2020/07/30) --------------------------------------- - -Version 3.11 adds support for MongoDB 4.4 and includes a number of bug fixes. -Highlights include: - -- Support for `OCSP `_ (Online Certificate Status Protocol). -- Support for `PyOpenSSL `_ as an - alternative TLS implementation. PyOpenSSL is required for `OCSP `_ - support. It will also be installed when using the "tls" extra if the - version of Python in use is older than 2.7.9. -- Support for the `MONGODB-AWS `_ authentication mechanism. -- Support for the ``directConnection`` URI option and kwarg to - :class:`~pymongo.mongo_client.MongoClient`. -- Support for speculative authentication attempts in connection handshakes - which reduces the number of network roundtrips needed to authenticate new - connections on MongoDB 4.4+. -- Support for creating collections in multi-document transactions with - :meth:`~pymongo.database.Database.create_collection` on MongoDB 4.4+. -- Added index hinting support to the - :meth:`~pymongo.collection.Collection.replace_one`, - :meth:`~pymongo.collection.Collection.update_one`, - :meth:`~pymongo.collection.Collection.update_many`, - :meth:`~pymongo.collection.Collection.find_one_and_replace`, - :meth:`~pymongo.collection.Collection.find_one_and_update`, - :meth:`~pymongo.collection.Collection.delete_one`, - :meth:`~pymongo.collection.Collection.delete_many`, and - :meth:`~pymongo.collection.Collection.find_one_and_delete` commands. -- Added index hinting support to the - :class:`~pymongo.operations.ReplaceOne`, - :class:`~pymongo.operations.UpdateOne`, - :class:`~pymongo.operations.UpdateMany`, - :class:`~pymongo.operations.DeleteOne`, and - :class:`~pymongo.operations.DeleteMany` bulk operations. -- Added support for :data:`bson.binary.UuidRepresentation.UNSPECIFIED` and - ``MongoClient(uuidRepresentation='unspecified')`` which will become the - default UUID representation starting in PyMongo 4.0. See - `UUID representations `_ for details. -- New methods :meth:`bson.binary.Binary.from_uuid` and - :meth:`bson.binary.Binary.as_uuid`. -- Added the ``background`` parameter to - :meth:`pymongo.database.Database.validate_collection`. For a description - of this parameter see the MongoDB documentation for the `validate command`_. -- Added the ``allow_disk_use`` parameters to - :meth:`pymongo.collection.Collection.find`. -- Added the ``hedge`` parameter to - :class:`~pymongo.read_preferences.PrimaryPreferred`, - :class:`~pymongo.read_preferences.Secondary`, - :class:`~pymongo.read_preferences.SecondaryPreferred`, - :class:`~pymongo.read_preferences.Nearest` to support disabling - (or explicitly enabling) hedged reads in MongoDB 4.4+. -- Fixed a bug in change streams that could cause PyMongo to miss some change - documents when resuming a stream that was started without a resume token and - whose first batch did not contain any change documents. -- Fixed an bug where using gevent.Timeout to timeout an operation could - lead to a deadlock. - -Deprecations: - -- Deprecated the ``oplog_replay`` parameter to - :meth:`pymongo.collection.Collection.find`. Starting in MongoDB 4.4, the - server optimizes queries against the oplog collection without requiring - the user to set this flag. -- Deprecated :meth:`pymongo.collection.Collection.reindex`. Use - :meth:`~pymongo.database.Database.command` to run the ``reIndex`` command - instead. -- Deprecated :meth:`pymongo.mongo_client.MongoClient.fsync`. Use - :meth:`~pymongo.database.Database.command` to run the ``fsync`` command - instead. -- Deprecated :meth:`pymongo.mongo_client.MongoClient.unlock`. Use - :meth:`~pymongo.database.Database.command` to run the ``fsyncUnlock`` command - instead. See the documentation for more information. -- Deprecated :attr:`pymongo.mongo_client.MongoClient.is_locked`. Use - :meth:`~pymongo.database.Database.command` to run the ``currentOp`` command - instead. See the documentation for more information. -- Deprecated :class:`bson.binary.UUIDLegacy`. Use - :meth:`bson.binary.Binary.from_uuid` instead. - -Unavoidable breaking changes: - -- :class:`~gridfs.GridFSBucket` and :class:`~gridfs.GridFS` do not support - multi-document transactions. Running a GridFS operation in a transaction - now always raises the following error: - ``InvalidOperation: GridFS does not support multi-document transactions`` - -.. _validate command: https://mongodb.com/docs/manual/reference/command/validate/ - -Issues Resolved -............... - -See the `PyMongo 3.11.0 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.11.0 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=24799 - -Changes in Version 3.10.1 (2020/01/07) --------------------------------------- - -Version 3.10.1 fixes the following issues discovered since the release of -3.10.0: - -- Fix a TypeError logged to stderr that could be triggered during server - maintenance or during :meth:`pymongo.mongo_client.MongoClient.close`. -- Avoid creating new connections during - :meth:`pymongo.mongo_client.MongoClient.close`. - -Issues Resolved -............... - -See the `PyMongo 3.10.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.10.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=25039 - -Changes in Version 3.10.0 (2019/12/10) --------------------------------------- - -Version 3.10 includes a number of improvements and bug fixes. Highlights -include: - -- Support for Client-Side Field Level Encryption with MongoDB 4.2. See - `Client-Side Field Level Encryption `_ for examples. -- Support for Python 3.8. -- Added :attr:`pymongo.client_session.ClientSession.in_transaction`. -- Do not hold the Topology lock while creating connections in a MongoClient's - background thread. This change fixes a bug where application operations would - block while the background thread ensures that all server pools have - minPoolSize connections. -- Fix a UnicodeDecodeError bug when coercing a PyMongoError with a non-ascii - error message to unicode on Python 2. -- Fix an edge case bug where PyMongo could exceed the server's - maxMessageSizeBytes when generating a compressed bulk write command. - -Issues Resolved -............... - -See the `PyMongo 3.10 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.10 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=23944 - -Changes in Version 3.9.0 (2019/08/13) -------------------------------------- - -Version 3.9 adds support for MongoDB 4.2. Highlights include: - -- Support for MongoDB 4.2 sharded transactions. Sharded transactions have - the same API as replica set transactions. See `Transactions `_. -- New method :meth:`pymongo.client_session.ClientSession.with_transaction` to - support conveniently running a transaction in a session with automatic - retries and at-most-once semantics. -- Initial support for client side field level encryption. See the docstring for - :class:`~pymongo.mongo_client.MongoClient`, - :class:`~pymongo.encryption_options.AutoEncryptionOpts`, - and :mod:`~pymongo.encryption` for details. **Note: Support for client side - encryption is in beta. Backwards-breaking changes may be made before the - final release.** -- Added the ``max_commit_time_ms`` parameter to - :meth:`~pymongo.client_session.ClientSession.start_transaction`. -- Implement the `URI options specification`_ in the - :meth:`~pymongo.mongo_client.MongoClient` constructor. Consequently, there are - a number of changes in connection options: - - - The ``tlsInsecure`` option has been added. - - The ``tls`` option has been added. The older ``ssl`` option has been retained - as an alias to the new ``tls`` option. - - ``wTimeout`` has been deprecated in favor of ``wTimeoutMS``. - - ``wTimeoutMS`` now overrides ``wTimeout`` if the user provides both. - - ``j`` has been deprecated in favor of ``journal``. - - ``journal`` now overrides ``j`` if the user provides both. - - ``ssl_cert_reqs`` has been deprecated in favor of ``tlsAllowInvalidCertificates``. - Instead of ``ssl.CERT_NONE``, ``ssl.CERT_OPTIONAL`` and ``ssl.CERT_REQUIRED``, the - new option expects a boolean value - ``True`` is equivalent to ``ssl.CERT_NONE``, - while ``False`` is equivalent to ``ssl.CERT_REQUIRED``. - - ``ssl_match_hostname`` has been deprecated in favor of ``tlsAllowInvalidHostnames``. - - ``ssl_ca_certs`` has been deprecated in favor of ``tlsCAFile``. - - ``ssl_certfile`` has been deprecated in favor of ``tlsCertificateKeyFile``. - - ``ssl_pem_passphrase`` has been deprecated in favor of ``tlsCertificateKeyFilePassword``. - - ``waitQueueMultiple`` has been deprecated without replacement. This option - was a poor solution for putting an upper bound on queuing since it didn't - affect queuing in other parts of the driver. -- The ``retryWrites`` URI option now defaults to ``True``. Supported write - operations that fail with a retryable error will automatically be retried one - time, with at-most-once semantics. -- Support for retryable reads and the ``retryReads`` URI option which is - enabled by default. See the :class:`~pymongo.mongo_client.MongoClient` - documentation for details. Now that supported operations are retried - automatically and transparently, users should consider adjusting any custom - retry logic to prevent an application from inadvertently retrying for too - long. -- Support zstandard for wire protocol compression. -- Support for periodically polling DNS SRV records to update the mongos proxy - list without having to change client configuration. -- New method :meth:`pymongo.database.Database.aggregate` to support running - database level aggregations. -- Support for publishing Connection Monitoring and Pooling events via the new - :class:`~pymongo.monitoring.ConnectionPoolListener` class. See - :mod:`~pymongo.monitoring` for an example. -- :meth:`pymongo.collection.Collection.aggregate` and - :meth:`pymongo.database.Database.aggregate` now support the ``$merge`` pipeline - stage and use read preference - :attr:`~pymongo.read_preferences.ReadPreference.PRIMARY` if the ``$out`` or - ``$merge`` pipeline stages are used. -- Support for specifying a pipeline or document in - :meth:`~pymongo.collection.Collection.update_one`, - :meth:`~pymongo.collection.Collection.update_many`, - :meth:`~pymongo.collection.Collection.find_one_and_update`, - :meth:`~pymongo.operations.UpdateOne`, and - :meth:`~pymongo.operations.UpdateMany`. -- New BSON utility functions :func:`~bson.encode` and :func:`~bson.decode` -- :class:`~bson.binary.Binary` now supports any bytes-like type that implements - the buffer protocol. -- Resume tokens can now be accessed from a ``ChangeStream`` cursor using the - :attr:`~pymongo.change_stream.ChangeStream.resume_token` attribute. -- Connections now survive primary step-down when using MongoDB 4.2+. - Applications should expect less socket connection turnover during - replica set elections. - -Unavoidable breaking changes: - -- Applications that use MongoDB with the MMAPv1 storage engine must now - explicitly disable retryable writes via the connection string - (e.g. ``MongoClient("mongodb://my.mongodb.cluster/db?retryWrites=false")``) or - the :class:`~pymongo.mongo_client.MongoClient` constructor's keyword argument - (e.g. ``MongoClient("mongodb://my.mongodb.cluster/db", retryWrites=False)``) - to avoid running into :class:`~pymongo.errors.OperationFailure` exceptions - during write operations. The MMAPv1 storage engine is deprecated and does - not support retryable writes which are now turned on by default. -- In order to ensure that the ``connectTimeoutMS`` URI option is honored when - connecting to clusters with a ``mongodb+srv://`` connection string, the - minimum required version of the optional ``dnspython`` dependency has been - bumped to 1.16.0. This is a breaking change for applications that use - PyMongo's SRV support with a version of ``dnspython`` older than 1.16.0. - -.. _URI options specification: https://github.com/mongodb/specifications/blob/master/source/uri-options/uri-options.md - - -Issues Resolved -............... - -See the `PyMongo 3.9 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.9 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=21787 - -Changes in Version 3.8.0 (2019/04/22) -------------------------------------- - -.. warning:: PyMongo no longer supports Python 2.6. RHEL 6 users should install - Python 2.7 or newer from Red Hat Software Collections. - CentOS 6 users should install Python 2.7 or newer from `SCL - `_ - -.. warning:: PyMongo no longer supports PyPy3 versions older than 3.5. Users - must upgrade to PyPy3.5+. - -- :class:`~bson.objectid.ObjectId` now implements the `ObjectID specification - version 0.2 `_. -- For better performance and to better follow the GridFS spec, - :class:`~gridfs.grid_file.GridOut` now uses a single cursor to read all the - chunks in the file. Previously, each chunk in the file was queried - individually using :meth:`~pymongo.collection.Collection.find_one`. -- :meth:`gridfs.grid_file.GridOut.read` now only checks for extra chunks after - reading the entire file. Previously, this method would check for extra - chunks on every call. -- :meth:`~pymongo.database.Database.current_op` now always uses the - ``Database``'s :attr:`~pymongo.database.Database.codec_options` - when decoding the command response. Previously the codec_options - was only used when the MongoDB server version was <= 3.0. -- Undeprecated :meth:`~pymongo.mongo_client.MongoClient.get_default_database` - and added the ``default`` parameter. -- TLS Renegotiation is now disabled when possible. -- Custom types can now be directly encoded to, and decoded from MongoDB using - the :class:`~bson.codec_options.TypeCodec` and - :class:`~bson.codec_options.TypeRegistry` APIs. For more information, see - `Custom Types `_. -- Attempting a multi-document transaction on a sharded cluster now raises a - :exc:`~pymongo.errors.ConfigurationError`. -- :meth:`pymongo.cursor.Cursor.distinct` and - :meth:`pymongo.cursor.Cursor.count` now send the Cursor's - :meth:`~pymongo.cursor.Cursor.comment` as the "comment" top-level - command option instead of "$comment". Also, note that "comment" must be a - string. -- Add the ``filter`` parameter to - :meth:`~pymongo.database.Database.list_collection_names`. -- Changes can now be requested from a ``ChangeStream`` cursor without blocking - indefinitely using the new - :meth:`pymongo.change_stream.ChangeStream.try_next` method. -- Fixed a reference leak bug when splitting a batched write command based on - maxWriteBatchSize or the max message size. -- Deprecated running find queries that set :meth:`~pymongo.cursor.Cursor.min` - and/or :meth:`~pymongo.cursor.Cursor.max` but do not also set a - :meth:`~pymongo.cursor.Cursor.hint` of which index to use. The find command - is expected to require a :meth:`~pymongo.cursor.Cursor.hint` when using - min/max starting in MongoDB 4.2. -- Documented support for the uuidRepresentation URI option, which has been - supported since PyMongo 2.7. Valid values are ``pythonLegacy`` (the default), - ``javaLegacy``, ``csharpLegacy`` and ``standard``. New applications should consider - setting this to ``standard`` for cross language compatibility. -- :class:`~bson.raw_bson.RawBSONDocument` now validates that the ``bson_bytes`` - passed in represent a single bson document. Earlier versions would mistakenly - accept multiple bson documents. -- Iterating over a :class:`~bson.raw_bson.RawBSONDocument` now maintains the - same field order of the underlying raw BSON document. -- Applications can now register a custom server selector. For more information - see `Customize Server Selection `_. -- The connection pool now implements a LIFO policy. - -Unavoidable breaking changes: - -- In order to follow the ObjectID Spec version 0.2, an ObjectId's 3-byte - machine identifier and 2-byte process id have been replaced with a single - 5-byte random value generated per process. This is a breaking change for any - application that attempts to interpret those bytes. - -Issues Resolved -............... - -See the `PyMongo 3.8 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.8 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=19904 - -Changes in Version 3.7.2 (2018/10/10) -------------------------------------- - -Version 3.7.2 fixes a few issues discovered since the release of 3.7.1. - -- Fixed a bug in retryable writes where a previous command's "txnNumber" - field could be sent leading to incorrect results. -- Fixed a memory leak of a few bytes on some insert, update, or delete - commands when running against MongoDB 3.6+. -- Fixed a bug that caused :meth:`pymongo.collection.Collection.ensure_index` - to only cache a single index per database. -- Updated the documentation examples to use - :meth:`pymongo.collection.Collection.count_documents` instead of - :meth:`pymongo.collection.Collection.count` and - :meth:`pymongo.cursor.Cursor.count`. - -Issues Resolved -............... - -See the `PyMongo 3.7.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.7.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=21519 - -Changes in Version 3.7.1 (2018/07/16) -------------------------------------- - -Version 3.7.1 fixes a few issues discovered since the release of 3.7.0. - -- Calling :meth:`~pymongo.database.Database.authenticate` more than once - with the same credentials results in OperationFailure. -- Authentication fails when SCRAM-SHA-1 is used to authenticate users with - only MONGODB-CR credentials. -- A millisecond rounding problem when decoding datetimes in the pure Python - BSON decoder on 32 bit systems and AWS lambda. - -Issues Resolved -............... - -See the `PyMongo 3.7.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.7.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=21096 - -Changes in Version 3.7.0 (2018/06/26) -------------------------------------- - -Version 3.7 adds support for MongoDB 4.0. Highlights include: - -- Support for single replica set multi-document ACID transactions. - See `transactions `_. -- Support for wire protocol compression via the new ``compressors`` URI and keyword argument to - :meth:`~pymongo.mongo_client.MongoClient`. See `network compression `_ for details. -- Support for Python 3.7. -- New count methods, :meth:`~pymongo.collection.Collection.count_documents` - and :meth:`~pymongo.collection.Collection.estimated_document_count`. - :meth:`~pymongo.collection.Collection.count_documents` is always - accurate when used with MongoDB 3.6+, or when used with older standalone - or replica set deployments. With older sharded clusters is it always - accurate when used with Primary read preference. It can also be used in - a transaction, unlike the now deprecated - :meth:`pymongo.collection.Collection.count` and - :meth:`pymongo.cursor.Cursor.count` methods. -- Support for watching changes on all collections in a database using the - new :meth:`pymongo.database.Database.watch` method. -- Support for watching changes on all collections in all databases using the - new :meth:`pymongo.mongo_client.MongoClient.watch` method. -- Support for watching changes starting at a user provided timestamp using the - new ``start_at_operation_time`` parameter for the ``watch()`` helpers. -- Better support for using PyMongo in a FIPS 140-2 environment. Specifically, - the following features and changes allow PyMongo to function when MD5 support - is disabled in OpenSSL by the FIPS Object Module: - - - Support for the `SCRAM-SHA-256 `_ - authentication mechanism. The `GSSAPI `_, - `PLAIN `_, and `MONGODB-X509 `_ - mechanisms can also be used to avoid issues with OpenSSL in FIPS - environments. - - MD5 checksums are now optional in GridFS. See the ``disable_md5`` option - of :class:`~gridfs.GridFS` and :class:`~gridfs.GridFSBucket`. - - :class:`~bson.objectid.ObjectId` machine bytes are now hashed using - `FNV-1a - `_ - instead of MD5. - -- The :meth:`~pymongo.database.Database.list_collection_names` and - :meth:`~pymongo.database.Database.collection_names` methods use - the nameOnly option when supported by MongoDB. -- The :meth:`pymongo.collection.Collection.watch` method now returns an - instance of the :class:`~pymongo.change_stream.CollectionChangeStream` - class which is a subclass of :class:`~pymongo.change_stream.ChangeStream`. -- SCRAM client and server keys are cached for improved performance, following - `RFC 5802 `_. -- If not specified, the authSource for the `PLAIN `_ - authentication mechanism defaults to $external. -- wtimeoutMS is once again supported as a URI option. -- When using unacknowledged write concern and connected to MongoDB server - version 3.6 or greater, the ``bypass_document_validation`` option is now - supported in the following write helpers: - :meth:`~pymongo.collection.Collection.insert_one`, - :meth:`~pymongo.collection.Collection.replace_one`, - :meth:`~pymongo.collection.Collection.update_one`, - :meth:`~pymongo.collection.Collection.update_many`. - -Deprecations: - -- Deprecated :meth:`pymongo.collection.Collection.count` and - :meth:`pymongo.cursor.Cursor.count`. These two methods use the ``count`` - command and `may or may not be accurate - `_, - depending on the options used and connected MongoDB topology. Use - :meth:`~pymongo.collection.Collection.count_documents` instead. -- Deprecated the snapshot option of :meth:`~pymongo.collection.Collection.find` - and :meth:`~pymongo.collection.Collection.find_one`. The option was - deprecated in MongoDB 3.6 and removed in MongoDB 4.0. -- Deprecated the max_scan option of :meth:`~pymongo.collection.Collection.find` - and :meth:`~pymongo.collection.Collection.find_one`. The option was - deprecated in MongoDB 4.0. Use ``maxTimeMS`` instead. -- Deprecated :meth:`~pymongo.mongo_client.MongoClient.close_cursor`. Use - :meth:`~pymongo.cursor.Cursor.close` instead. -- Deprecated :meth:`~pymongo.mongo_client.MongoClient.database_names`. Use - :meth:`~pymongo.mongo_client.MongoClient.list_database_names` instead. -- Deprecated :meth:`~pymongo.database.Database.collection_names`. Use - :meth:`~pymongo.database.Database.list_collection_names` instead. -- Deprecated :meth:`~pymongo.collection.Collection.parallel_scan`. MongoDB 4.2 - will remove the parallelCollectionScan command. - -Unavoidable breaking changes: - -- Commands that fail with server error codes 10107, 13435, 13436, 11600, - 11602, 189, 91 (NotMaster, NotMasterNoSlaveOk, NotMasterOrSecondary, - InterruptedAtShutdown, InterruptedDueToReplStateChange, - PrimarySteppedDown, ShutdownInProgress respectively) now always raise - :class:`~pymongo.errors.NotMasterError` instead of - :class:`~pymongo.errors.OperationFailure`. -- :meth:`~pymongo.collection.Collection.parallel_scan` no longer uses an - implicit session. Explicit sessions are still supported. -- Unacknowledged writes (``w=0``) with an explicit ``session`` parameter now - raise a client side error. Since PyMongo does not wait for a response for an - unacknowledged write, two unacknowledged writes run serially by the client - may be executed simultaneously on the server. However, the server requires a - single session must not be used simultaneously by more than one operation. - Therefore explicit sessions cannot support unacknowledged writes. - Unacknowledged writes without a ``session`` parameter are still supported. - - -Issues Resolved -............... - -See the `PyMongo 3.7 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.7 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=19287 - -Changes in Version 3.6.1 (2018/03/01) -------------------------------------- - -Version 3.6.1 fixes bugs reported since the release of 3.6.0: - -- Fix regression in PyMongo 3.5.0 that causes idle sockets to be closed almost - instantly when ``maxIdleTimeMS`` is set. Idle sockets are now closed after - ``maxIdleTimeMS`` milliseconds. -- :attr:`pymongo.mongo_client.MongoClient.max_idle_time_ms` now returns - milliseconds instead of seconds. -- Properly import and use the - `monotonic `_ - library for monotonic time when it is installed. -- :meth:`~pymongo.collection.Collection.aggregate` now ignores the - ``batchSize`` argument when running a pipeline with a ``$out`` stage. -- Always send handshake metadata for new connections. - -Issues Resolved -............... - -See the `PyMongo 3.6.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.6.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=19438 - - -Changes in Version 3.6.0 (2017/08/23) -------------------------------------- - -Version 3.6 adds support for MongoDB 3.6, drops support for CPython 3.3 (PyPy3 -is still supported), and drops support for MongoDB versions older than 2.6. If -connecting to a MongoDB 2.4 server or older, PyMongo now throws a -:exc:`~pymongo.errors.ConfigurationError`. - -Highlights include: - -- Support for change streams. See the - :meth:`~pymongo.collection.Collection.watch` method for details. -- Support for array_filters in - :meth:`~pymongo.collection.Collection.update_one`, - :meth:`~pymongo.collection.Collection.update_many`, - :meth:`~pymongo.collection.Collection.find_one_and_update`, - :meth:`~pymongo.operations.UpdateOne`, and - :meth:`~pymongo.operations.UpdateMany`. -- New Session API, see :meth:`~pymongo.mongo_client.MongoClient.start_session`. -- New methods :meth:`~pymongo.collection.Collection.find_raw_batches` and - :meth:`~pymongo.collection.Collection.aggregate_raw_batches` for use with - external libraries that can parse raw batches of BSON data. -- New methods :meth:`~pymongo.mongo_client.MongoClient.list_databases` and - :meth:`~pymongo.mongo_client.MongoClient.list_database_names`. -- New methods :meth:`~pymongo.database.Database.list_collections` and - :meth:`~pymongo.database.Database.list_collection_names`. -- Support for mongodb+srv:// URIs. See - :class:`~pymongo.mongo_client.MongoClient` for details. -- Index management helpers - (:meth:`~pymongo.collection.Collection.create_index`, - :meth:`~pymongo.collection.Collection.create_indexes`, - :meth:`~pymongo.collection.Collection.drop_index`, - :meth:`~pymongo.collection.Collection.drop_indexes`, - :meth:`~pymongo.collection.Collection.reindex`) now support maxTimeMS. -- Support for retryable writes and the ``retryWrites`` URI option. See - :class:`~pymongo.mongo_client.MongoClient` for details. - -Deprecations: - -- The ``useCursor`` option for :meth:`~pymongo.collection.Collection.aggregate` - is deprecated. The option was only necessary when upgrading from MongoDB - 2.4 to MongoDB 2.6. MongoDB 2.4 is no longer supported. -- The :meth:`~pymongo.database.Database.add_user` and - :meth:`~pymongo.database.Database.remove_user` methods are deprecated. See - the method docstrings for alternatives. - -Unavoidable breaking changes: - -- Starting in MongoDB 3.6, the deprecated methods - :meth:`~pymongo.database.Database.authenticate` and - :meth:`~pymongo.database.Database.logout` now invalidate all cursors created - prior. Instead of using these methods to change credentials, pass credentials - for one user to the :class:`~pymongo.mongo_client.MongoClient` at construction - time, and either grant access to several databases to one user account, or use - a distinct client object for each user. -- BSON binary subtype 4 is decoded using RFC-4122 byte order regardless - of the UUID representation. This is a change in behavior for applications - that use UUID representation :data:`bson.binary.JAVA_LEGACY` or - :data:`bson.binary.CSHARP_LEGACY` to decode BSON binary subtype 4. Other - UUID representations, :data:`bson.binary.PYTHON_LEGACY` (the default) and - :data:`bson.binary.STANDARD`, and the decoding of BSON binary subtype 3 - are unchanged. - - -Issues Resolved -............... - -See the `PyMongo 3.6 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.6 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=18043 - -Changes in Version 3.5.1 (2017/08/23) -------------------------------------- - -Version 3.5.1 fixes bugs reported since the release of 3.5.0: - -- Work around socket.getsockopt issue with NetBSD. -- :meth:`pymongo.command_cursor.CommandCursor.close` now closes - the cursor synchronously instead of deferring to a background - thread. -- Fix documentation build warnings with Sphinx 1.6.x. - -Issues Resolved -............... - -See the `PyMongo 3.5.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.5.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=18721 - -Changes in Version 3.5.0 (2017/08/08) -------------------------------------- - -Version 3.5 implements a number of improvements and bug fixes: - -Highlights include: - -- Username and password can be passed to - :class:`~pymongo.mongo_client.MongoClient` as keyword arguments. Before, the - only way to pass them was in the URI. -- Increased the performance of using :class:`~bson.raw_bson.RawBSONDocument`. -- Increased the performance of - :meth:`~pymongo.mongo_client.MongoClient.database_names` by using the - ``nameOnly`` option for listDatabases when available. -- Increased the performance of - :meth:`~pymongo.collection.Collection.bulk_write` by reducing the memory - overhead of :class:`~pymongo.operations.InsertOne`, - :class:`~pymongo.operations.DeleteOne`, and - :class:`~pymongo.operations.DeleteMany`. -- Added the ``collation`` option to :class:`~pymongo.operations.DeleteOne`, - :class:`~pymongo.operations.DeleteMany`, - :class:`~pymongo.operations.ReplaceOne`, - :class:`~pymongo.operations.UpdateOne`, and - :class:`~pymongo.operations.UpdateMany`. -- Implemented the `MongoDB Extended JSON - `_ - specification. -- :class:`~bson.decimal128.Decimal128` now works when cdecimal is installed. -- PyMongo is now tested against a wider array of operating systems and CPU - architectures (including s390x, ARM64, and POWER8). - -Changes and Deprecations: - -- :meth:`~pymongo.collection.Collection.find` has new options ``return_key``, - ``show_record_id``, ``snapshot``, ``hint``, ``max_time_ms``, ``max_scan``, ``min``, ``max``, - and ``comment``. Deprecated the option ``modifiers``. -- Deprecated :meth:`~pymongo.collection.Collection.group`. The group command - was deprecated in MongoDB 3.4 and is expected to be removed in MongoDB 3.6. - Applications should use :meth:`~pymongo.collection.Collection.aggregate` - with the ``$group`` pipeline stage instead. -- Deprecated :meth:`~pymongo.database.Database.authenticate`. Authenticating - multiple users conflicts with support for logical sessions in MongoDB 3.6. - To authenticate as multiple users, create multiple instances of - :class:`~pymongo.mongo_client.MongoClient`. -- Deprecated :meth:`~pymongo.database.Database.eval`. The eval command - was deprecated in MongoDB 3.0 and will be removed in a future server version. -- Deprecated :class:`~pymongo.database.SystemJS`. -- Deprecated :meth:`~pymongo.mongo_client.MongoClient.get_default_database`. - Applications should use - :meth:`~pymongo.mongo_client.MongoClient.get_database` without the ```name``` - parameter instead. -- Deprecated the MongoClient option ``socketKeepAlive```. It now defaults to true - and disabling it is not recommended, see `does TCP keepalive time affect - MongoDB Deployments? - `_ -- Deprecated :meth:`~pymongo.collection.Collection.initialize_ordered_bulk_op`, - :meth:`~pymongo.collection.Collection.initialize_unordered_bulk_op`, and - :class:`~pymongo.bulk.BulkOperationBuilder`. Use - :meth:`~pymongo.collection.Collection.bulk_write` instead. -- Deprecated :const:`~bson.json_util.STRICT_JSON_OPTIONS`. Use - :const:`~bson.json_util.RELAXED_JSON_OPTIONS` or - :const:`~bson.json_util.CANONICAL_JSON_OPTIONS` instead. -- If a custom :class:`~bson.codec_options.CodecOptions` is passed to - :class:`RawBSONDocument`, its ``document_class``` must be - :class:`RawBSONDocument`. -- :meth:`~pymongo.collection.Collection.list_indexes` no longer raises - OperationFailure when the collection (or database) does not exist on - MongoDB >= 3.0. Instead, it returns an empty - :class:`~pymongo.command_cursor.CommandCursor` to make the behavior - consistent across all MongoDB versions. -- In Python 3, :meth:`~bson.json_util.loads` now automatically decodes JSON - $binary with a subtype of 0 into :class:`bytes` instead of - :class:`~bson.binary.Binary`. -- :meth:`~bson.json_util.loads` now raises ``TypeError`` or ``ValueError`` - when parsing JSON type wrappers with values of the wrong type or any - extra keys. -- :meth:`pymongo.cursor.Cursor.close` and - :meth:`pymongo.mongo_client.MongoClient.close` - now kill cursors synchronously instead of deferring to a background thread. -- :meth:`~pymongo.uri_parser.parse_uri` now returns the original value - of the ``readPreference`` MongoDB URI option instead of the validated read - preference mode. - -Issues Resolved -............... - -See the `PyMongo 3.5 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.5 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=17590 - -Changes in Version 3.4.0 (2016/11/29) -------------------------------------- - -Version 3.4 implements the new server features introduced in MongoDB 3.4 -and a whole lot more: - -Highlights include: - -- Complete support for MongoDB 3.4: - - - Unicode aware string comparison using `Collation `_. - - Support for the new :class:`~bson.decimal128.Decimal128` BSON type. - - A new maxStalenessSeconds read preference option. - - A username is no longer required for the MONGODB-X509 authentication - mechanism when connected to MongoDB >= 3.4. - - :meth:`~pymongo.collection.Collection.parallel_scan` supports maxTimeMS. - - :attr:`~pymongo.write_concern.WriteConcern` is automatically - applied by all helpers for commands that write to the database when - connected to MongoDB 3.4+. This change affects the following helpers: - - - :meth:`~pymongo.mongo_client.MongoClient.drop_database` - - :meth:`~pymongo.database.Database.create_collection` - - :meth:`~pymongo.database.Database.drop_collection` - - :meth:`~pymongo.collection.Collection.aggregate` (when using $out) - - :meth:`~pymongo.collection.Collection.create_indexes` - - :meth:`~pymongo.collection.Collection.create_index` - - :meth:`~pymongo.collection.Collection.drop_indexes` - - :meth:`~pymongo.collection.Collection.drop_indexes` - - :meth:`~pymongo.collection.Collection.drop_index` - - :meth:`~pymongo.collection.Collection.map_reduce` (when output is not - "inline") - - :meth:`~pymongo.collection.Collection.reindex` - - :meth:`~pymongo.collection.Collection.rename` - -- Improved support for logging server discovery and monitoring events. See - :mod:`~pymongo.monitoring` for examples. -- Support for matching iPAddress subjectAltName values for TLS certificate - verification. -- TLS compression is now explicitly disabled when possible. -- The Server Name Indication (SNI) TLS extension is used when possible. -- Finer control over JSON encoding/decoding with - :class:`~bson.json_util.JSONOptions`. -- Allow :class:`~bson.code.Code` objects to have a scope of ``None``, - signifying no scope. Also allow encoding Code objects with an empty scope - (i.e. ``{}``). - -.. warning:: Starting in PyMongo 3.4, :attr:`bson.code.Code.scope` may return - ``None``, as the default scope is ``None`` instead of ``{}``. - -.. note:: PyMongo 3.4+ attempts to create sockets non-inheritable when possible - (i.e. it sets the close-on-exec flag on socket file descriptors). Support - is limited to a subset of POSIX operating systems (not including Windows) and - the flag usually cannot be set in a single atomic operation. CPython 3.4+ - implements `PEP 446`_, creating all file descriptors non-inheritable by - default. Users that require this behavior are encouraged to upgrade to - CPython 3.4+. - -Since 3.4rc0, the max staleness option has been renamed from ``maxStalenessMS`` -to ``maxStalenessSeconds``, its smallest value has changed from twice -``heartbeatFrequencyMS`` to 90 seconds, and its default value has changed from -``None`` or 0 to -1. - -.. _PEP 446: https://www.python.org/dev/peps/pep-0446/ - -Issues Resolved -............... - -See the `PyMongo 3.4 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.4 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=16594 - -Changes in Version 3.3.1 (2016/10/27) -------------------------------------- - -Version 3.3.1 fixes a memory leak when decoding elements inside of a -:class:`~bson.raw_bson.RawBSONDocument`. - -Issues Resolved -............... - -See the `PyMongo 3.3.1 release notes in Jira`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.3.1 release notes in Jira: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=17636 - -Changes in Version 3.3.0 (2016/07/12) -------------------------------------- - -Version 3.3 adds the following major new features: - -- C extensions support on big endian systems. -- Kerberos authentication support on Windows using `WinKerberos - `_. -- A new ``ssl_clrfile`` option to support certificate revocation lists. -- A new ``ssl_pem_passphrase`` option to support encrypted key files. -- Support for publishing server discovery and monitoring events. See - :mod:`~pymongo.monitoring` for details. -- New connection pool options ``minPoolSize`` and ``maxIdleTimeMS``. -- New ``heartbeatFrequencyMS`` option controls the rate at which background - monitoring threads re-check servers. Default is once every 10 seconds. - -.. warning:: PyMongo 3.3 drops support for MongoDB versions older than 2.4. - It also drops support for python 3.2 (pypy3 continues to be supported). - -Issues Resolved -............... - -See the `PyMongo 3.3 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.3 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=16005 - -Changes in Version 3.2.2 (2016/03/15) -------------------------------------- - -Version 3.2.2 fixes a few issues reported since the release of 3.2.1, including -a fix for using the ``connect`` option in the MongoDB URI and support for setting -the batch size for a query to 1 when using MongoDB 3.2+. - -Issues Resolved -............... - -See the `PyMongo 3.2.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.2.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=16538 - - -Changes in Version 3.2.1 (2016/02/02) -------------------------------------- - -Version 3.2.1 fixes a few issues reported since the release of 3.2, including -running the mapreduce command twice when calling the -:meth:`~pymongo.collection.Collection.inline_map_reduce` method and a -:exc:`TypeError` being raised when calling -:meth:`~gridfs.GridFSBucket.download_to_stream`. This release also -improves error messaging around BSON decoding. - -Issues Resolved -............... - -See the `PyMongo 3.2.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.2.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=16312 - -Changes in Version 3.2 (2015/12/07) ------------------------------------ - -Version 3.2 implements the new server features introduced in MongoDB 3.2. - -Highlights include: - -- Full support for MongoDB 3.2 including: - - - Support for :class:`~pymongo.read_concern.ReadConcern` - - :class:`~pymongo.write_concern.WriteConcern` is now applied to - :meth:`~pymongo.collection.Collection.find_one_and_replace`, - :meth:`~pymongo.collection.Collection.find_one_and_update`, and - :meth:`~pymongo.collection.Collection.find_one_and_delete`. - - Support for the new ``bypassDocumentValidation`` option in write - helpers. - -- Support for reading and writing raw BSON with - :class:`~bson.raw_bson.RawBSONDocument` - -.. note:: Certain :class:`~pymongo.mongo_client.MongoClient` properties now - block until a connection is established or raise - :exc:`~pymongo.errors.ServerSelectionTimeoutError` if no server is available. - See :class:`~pymongo.mongo_client.MongoClient` for details. - -Issues Resolved -............... - -See the `PyMongo 3.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=15612 - -Changes in Version 3.1.1 (2015/11/17) -------------------------------------- - -Version 3.1.1 fixes a few issues reported since the release of 3.1, including a -regression in error handling for oversize command documents and interrupt -handling issues in the C extensions. - -Issues Resolved -............... - -See the `PyMongo 3.1.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.1.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=16211 - -Changes in Version 3.1 (2015/11/02) ------------------------------------ - -Version 3.1 implements a few new features and fixes bugs reported since the release -of 3.0.3. - -Highlights include: - -- Command monitoring support. See :mod:`~pymongo.monitoring` for details. -- Configurable error handling for :exc:`UnicodeDecodeError`. See the - ``unicode_decode_error_handler`` option of - :class:`~bson.codec_options.CodecOptions`. -- Optional automatic timezone conversion when decoding BSON datetime. See the - ``tzinfo`` option of :class:`~bson.codec_options.CodecOptions`. -- An implementation of :class:`~gridfs.GridFSBucket` from the new GridFS spec. -- Compliance with the new Connection String spec. -- Reduced idle CPU usage in Python 2. - -Changes in internal classes -........................... - -The private ``PeriodicExecutor`` class no longer takes a ``condition_class`` -option, and the private ``thread_util.Event`` class is removed. - -Issues Resolved -............... - -See the `PyMongo 3.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=14796 - -Changes in Version 3.0.3 (2015/06/30) -------------------------------------- - -Version 3.0.3 fixes issues reported since the release of 3.0.2, including a -feature breaking bug in the GSSAPI implementation. - -Issues Resolved -............... - -See the `PyMongo 3.0.3 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.0.3 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=15528 - -Changes in Version 3.0.2 (2015/05/12) -------------------------------------- - -Version 3.0.2 fixes issues reported since the release of 3.0.1, most -importantly a bug that could route operations to replica set members -that are not in primary or secondary state when using -:class:`~pymongo.read_preferences.PrimaryPreferred` or -:class:`~pymongo.read_preferences.Nearest`. It is a recommended upgrade for -all users of PyMongo 3.0.x. - -Issues Resolved -............... - -See the `PyMongo 3.0.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.0.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=15430 - -Changes in Version 3.0.1 (2015/04/21) -------------------------------------- - -Version 3.0.1 fixes issues reported since the release of 3.0, most -importantly a bug in GridFS.delete that could prevent file chunks from -actually being deleted. - -Issues Resolved -............... - -See the `PyMongo 3.0.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.0.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=15322 - -Changes in Version 3.0 (2015/04/07) ------------------------------------ - -PyMongo 3.0 is a partial rewrite of PyMongo bringing a large number of -improvements: - -- A unified client class. MongoClient is the one and only client class for - connecting to a standalone mongod, replica set, or sharded cluster. Migrating - from a standalone, to a replica set, to a sharded cluster can be accomplished - with only a simple URI change. -- MongoClient is much more responsive to configuration changes in your MongoDB - deployment. All connected servers are monitored in a non-blocking manner. - Slow to respond or down servers no longer block server discovery, reducing - application startup time and time to respond to new or reconfigured - servers and replica set failovers. -- A unified CRUD API. All official MongoDB drivers now implement a standard - CRUD API allowing polyglot developers to move from language to language - with ease. -- Single source support for Python 2.x and 3.x. PyMongo no longer relies on - 2to3 to support Python 3. -- A rewritten pure Python BSON implementation, improving performance - with pypy and cpython deployments without support for C extensions. -- Better support for greenlet based async frameworks including eventlet. -- Immutable client, database, and collection classes, avoiding a host of thread - safety issues in client applications. - -PyMongo 3.0 brings a large number of API changes. Be sure to read the changes -listed below before upgrading from PyMongo 2.x. - -.. warning:: PyMongo no longer supports Python 2.4, 2.5, or 3.1. If you - must use PyMongo with these versions of Python the 2.x branch of PyMongo - will be minimally supported for some time. - -SONManipulator changes -...................... - -The :class:`~pymongo.son_manipulator.SONManipulator` API has limitations as a -technique for transforming your data. Instead, it is more flexible and -straightforward to transform outgoing documents in your own code before passing -them to PyMongo, and transform incoming documents after receiving them from -PyMongo. - -Thus the :meth:`~pymongo.database.Database.add_son_manipulator` method is -deprecated. PyMongo 3's new CRUD API does **not** apply SON manipulators to -documents passed to :meth:`~pymongo.collection.Collection.bulk_write`, -:meth:`~pymongo.collection.Collection.insert_one`, -:meth:`~pymongo.collection.Collection.insert_many`, -:meth:`~pymongo.collection.Collection.update_one`, or -:meth:`~pymongo.collection.Collection.update_many`. SON manipulators are **not** -applied to documents returned by the new methods -:meth:`~pymongo.collection.Collection.find_one_and_delete`, -:meth:`~pymongo.collection.Collection.find_one_and_replace`, and -:meth:`~pymongo.collection.Collection.find_one_and_update`. - -SSL/TLS changes -............... - -When ``ssl`` is ``True`` the ``ssl_cert_reqs`` option now defaults to -:attr:`ssl.CERT_REQUIRED` if not provided. PyMongo will attempt to load OS -provided CA certificates to verify the server, raising -:exc:`~pymongo.errors.ConfigurationError` if it cannot. - -Gevent Support -.............. - -In previous versions, PyMongo supported Gevent in two modes: you could call -``gevent.monkey.patch_socket()`` and pass ``use_greenlets=True`` to -:class:`~pymongo.mongo_client.MongoClient`, or you could simply call -``gevent.monkey.patch_all()`` and omit the ``use_greenlets`` argument. - -In PyMongo 3.0, the ``use_greenlets`` option is gone. To use PyMongo with -Gevent simply call ``gevent.monkey.patch_all()``. - -For more information, -see `Gevent `_. - -:class:`~pymongo.mongo_client.MongoClient` changes -.................................................. - -:class:`~pymongo.mongo_client.MongoClient` is now the one and only -client class for a standalone server, mongos, or replica set. -It includes the functionality that had been split into -``MongoReplicaSetClient``: it can connect to a replica set, discover all its -members, and monitor the set for stepdowns, elections, and reconfigs. -:class:`~pymongo.mongo_client.MongoClient` now also supports the full -:class:`~pymongo.read_preferences.ReadPreference` API. - -The obsolete classes ``MasterSlaveConnection``, ``Connection``, and -``ReplicaSetConnection`` are removed. - -The :class:`~pymongo.mongo_client.MongoClient` constructor no -longer blocks while connecting to the server or servers, and it no -longer raises :class:`~pymongo.errors.ConnectionFailure` if they -are unavailable, nor :class:`~pymongo.errors.ConfigurationError` -if the user's credentials are wrong. Instead, the constructor -returns immediately and launches the connection process on -background threads. The ``connect`` option is added to control whether -these threads are started immediately, or when the client is first used. - -Therefore the ``alive`` method is removed since it no longer provides meaningful -information; even if the client is disconnected, it may discover a server in -time to fulfill the next operation. - -In PyMongo 2.x, :class:`~pymongo.mongo_client.MongoClient` accepted a list of -standalone MongoDB servers and used the first it could connect to:: - - MongoClient(['host1.com:27017', 'host2.com:27017']) - -A list of multiple standalones is no longer supported; if multiple servers -are listed they must be members of the same replica set, or mongoses in the -same sharded cluster. - -The behavior for a list of mongoses is changed from "high availability" to -"load balancing". Before, the client connected to the lowest-latency mongos in -the list, and used it until a network error prompted it to re-evaluate all -mongoses' latencies and reconnect to one of them. In PyMongo 3, the client -monitors its network latency to all the mongoses continuously, and distributes -operations evenly among those with the lowest latency. -See `load balancing `_ for more information. - -The client methods ``start_request``, ``in_request``, and ``end_request`` -are removed, and so is the ``auto_start_request`` option. Requests were -designed to make read-your-writes consistency more likely with the ``w=0`` -write concern. Additionally, a thread in a request used the same member for -all secondary reads in a replica set. To ensure read-your-writes consistency -in PyMongo 3.0, do not override the default write concern with ``w=0``, and -do not override the default `read preference `_ of -PRIMARY. - -Support for the ``slaveOk`` (or ``slave_okay``), ``safe``, and -``network_timeout`` options has been removed. Use -:attr:`~pymongo.read_preferences.ReadPreference.SECONDARY_PREFERRED` instead of -slave_okay. Accept the default write concern, acknowledged writes, instead of -setting safe=True. Use socketTimeoutMS in place of network_timeout (note that -network_timeout was in seconds, where as socketTimeoutMS is milliseconds). - -The ``max_pool_size`` option has been removed. It is replaced by the -``maxPoolSize`` MongoDB URI option. ``maxPoolSize`` is now a supported URI -option in PyMongo and can be passed as a keyword argument. - -The ``copy_database`` method is removed, see `Copy and Clone Databases `_ for alternatives. - -The ``disconnect`` method is removed. Use -:meth:`~pymongo.mongo_client.MongoClient.close` instead. - -The ``get_document_class`` method is removed. Use -:attr:`~pymongo.mongo_client.MongoClient.codec_options` instead. - -The ``get_lasterror_options``, ``set_lasterror_options``, and -``unset_lasterror_options`` methods are removed. Write concern options -can be passed to :class:`~pymongo.mongo_client.MongoClient` as keyword -arguments or MongoDB URI options. - -The :meth:`~pymongo.mongo_client.MongoClient.get_database` method is added for -getting a Database instance with its options configured differently than the -MongoClient's. - -The following read-only attributes have been added: - -- :attr:`~pymongo.mongo_client.MongoClient.codec_options` - -The following attributes are now read-only: - -- :attr:`~pymongo.mongo_client.MongoClient.read_preference` -- :attr:`~pymongo.mongo_client.MongoClient.write_concern` - -The following attributes have been removed: - -- :attr:`~pymongo.mongo_client.MongoClient.document_class` - (use :attr:`~pymongo.mongo_client.MongoClient.codec_options` instead) -- :attr:`~pymongo.mongo_client.MongoClient.host` - (use :attr:`~pymongo.mongo_client.MongoClient.address` instead) -- :attr:`~pymongo.mongo_client.MongoClient.min_wire_version` -- :attr:`~pymongo.mongo_client.MongoClient.max_wire_version` -- :attr:`~pymongo.mongo_client.MongoClient.port` - (use :attr:`~pymongo.mongo_client.MongoClient.address` instead) -- :attr:`~pymongo.mongo_client.MongoClient.safe` - (use :attr:`~pymongo.mongo_client.MongoClient.write_concern` instead) -- :attr:`~pymongo.mongo_client.MongoClient.slave_okay` - (use :attr:`~pymongo.mongo_client.MongoClient.read_preference` instead) -- :attr:`~pymongo.mongo_client.MongoClient.tag_sets` - (use :attr:`~pymongo.mongo_client.MongoClient.read_preference` instead) -- :attr:`~pymongo.mongo_client.MongoClient.tz_aware` - (use :attr:`~pymongo.mongo_client.MongoClient.codec_options` instead) - -The following attributes have been renamed: - -- :attr:`~pymongo.mongo_client.MongoClient.secondary_acceptable_latency_ms` is - now :attr:`~pymongo.mongo_client.MongoClient.local_threshold_ms` and is now - read-only. - -:class:`~pymongo.cursor.Cursor` changes -....................................... - -The ``conn_id`` property is renamed to :attr:`~pymongo.cursor.Cursor.address`. - -Cursor management changes -......................... - -:class:`~pymongo.cursor_manager.CursorManager` and -:meth:`~pymongo.mongo_client.MongoClient.set_cursor_manager` are no longer -deprecated. If you subclass :class:`~pymongo.cursor_manager.CursorManager` -your implementation of :meth:`~pymongo.cursor_manager.CursorManager.close` -must now take a second parameter, ``address``. The ``BatchCursorManager`` class -is removed. - -The second parameter to :meth:`~pymongo.mongo_client.MongoClient.close_cursor` -is renamed from ``_conn_id`` to ``address``. -:meth:`~pymongo.mongo_client.MongoClient.kill_cursors` now accepts an ``address`` -parameter. - -:class:`~pymongo.database.Database` changes -........................................... - -The ``connection`` property is renamed to -:attr:`~pymongo.database.Database.client`. - -The following read-only attributes have been added: - -- :attr:`~pymongo.database.Database.codec_options` - -The following attributes are now read-only: - -- :attr:`~pymongo.database.Database.read_preference` -- :attr:`~pymongo.database.Database.write_concern` - -Use :meth:`~pymongo.mongo_client.MongoClient.get_database` for getting a -Database instance with its options configured differently than the -MongoClient's. - -The following attributes have been removed: - -- :attr:`~pymongo.database.Database.safe` -- :attr:`~pymongo.database.Database.secondary_acceptable_latency_ms` -- :attr:`~pymongo.database.Database.slave_okay` -- :attr:`~pymongo.database.Database.tag_sets` - -The following methods have been added: - -- :meth:`~pymongo.database.Database.get_collection` - -The following methods have been changed: - -- :meth:`~pymongo.database.Database.command`. Support for ``as_class``, - ``uuid_subtype``, ``tag_sets``, and ``secondary_acceptable_latency_ms`` have been - removed. You can instead pass an instance of - :class:`~bson.codec_options.CodecOptions` as ``codec_options`` and an instance - of a read preference class from :mod:`~pymongo.read_preferences` as - ``read_preference``. The ``fields`` and ``compile_re`` options are also removed. - The ``fields`` options was undocumented and never really worked. Regular - expressions are always decoded to :class:`~bson.regex.Regex`. - -The following methods have been deprecated: - -- :meth:`~pymongo.database.Database.add_son_manipulator` - -The following methods have been removed: - -The ``get_lasterror_options``, ``set_lasterror_options``, and -``unset_lasterror_options`` methods have been removed. Use -:class:`~pymongo.write_concern.WriteConcern` with -:meth:`~pymongo.mongo_client.MongoClient.get_database` instead. - -:class:`~pymongo.collection.Collection` changes -............................................... - -The following read-only attributes have been added: - -- :attr:`~pymongo.collection.Collection.codec_options` - -The following attributes are now read-only: - -- :attr:`~pymongo.collection.Collection.read_preference` -- :attr:`~pymongo.collection.Collection.write_concern` - -Use :meth:`~pymongo.database.Database.get_collection` or -:meth:`~pymongo.collection.Collection.with_options` for getting a Collection -instance with its options configured differently than the Database's. - -The following attributes have been removed: - -- :attr:`~pymongo.collection.Collection.safe` -- :attr:`~pymongo.collection.Collection.secondary_acceptable_latency_ms` -- :attr:`~pymongo.collection.Collection.slave_okay` -- :attr:`~pymongo.collection.Collection.tag_sets` - -The following methods have been added: - -- :meth:`~pymongo.collection.Collection.bulk_write` -- :meth:`~pymongo.collection.Collection.insert_one` -- :meth:`~pymongo.collection.Collection.insert_many` -- :meth:`~pymongo.collection.Collection.update_one` -- :meth:`~pymongo.collection.Collection.update_many` -- :meth:`~pymongo.collection.Collection.replace_one` -- :meth:`~pymongo.collection.Collection.delete_one` -- :meth:`~pymongo.collection.Collection.delete_many` -- :meth:`~pymongo.collection.Collection.find_one_and_delete` -- :meth:`~pymongo.collection.Collection.find_one_and_replace` -- :meth:`~pymongo.collection.Collection.find_one_and_update` -- :meth:`~pymongo.collection.Collection.with_options` -- :meth:`~pymongo.collection.Collection.create_indexes` -- :meth:`~pymongo.collection.Collection.list_indexes` - -The following methods have changed: - -- :meth:`~pymongo.collection.Collection.aggregate` now **always** returns an - instance of :class:`~pymongo.command_cursor.CommandCursor`. See the - documentation for all options. -- :meth:`~pymongo.collection.Collection.count` now optionally takes a filter - argument, as well as other options supported by the count command. -- :meth:`~pymongo.collection.Collection.distinct` now optionally takes a filter - argument. -- :meth:`~pymongo.collection.Collection.create_index` no longer caches - indexes, therefore the ``cache_for`` parameter has been removed. It also - no longer supports the ``bucket_size`` and ``drop_dups`` aliases for ``bucketSize`` - and ``dropDups``. - -The following methods are deprecated: - -- :meth:`~pymongo.collection.Collection.save` -- :meth:`~pymongo.collection.Collection.insert` -- :meth:`~pymongo.collection.Collection.update` -- :meth:`~pymongo.collection.Collection.remove` -- :meth:`~pymongo.collection.Collection.find_and_modify` -- :meth:`~pymongo.collection.Collection.ensure_index` - -The following methods have been removed: - -The ``get_lasterror_options``, ``set_lasterror_options``, and -``unset_lasterror_options`` methods have been removed. Use -:class:`~pymongo.write_concern.WriteConcern` with -:meth:`~pymongo.collection.Collection.with_options` instead. - -Changes to :meth:`~pymongo.collection.Collection.find` and :meth:`~pymongo.collection.Collection.find_one` -`````````````````````````````````````````````````````````````````````````````````````````````````````````` - -The following find/find_one options have been renamed: - -These renames only affect your code if you passed these as keyword arguments, -like find(fields=['fieldname']). If you passed only positional parameters these -changes are not significant for your application. - -- spec -> filter -- fields -> projection -- partial -> allow_partial_results - -The following find/find_one options have been added: - -- cursor_type (see :class:`~pymongo.cursor.CursorType` for values) -- oplog_replay -- modifiers - -The following find/find_one options have been removed: - -- network_timeout (use :meth:`~pymongo.cursor.Cursor.max_time_ms` instead) -- slave_okay (use one of the read preference classes from - :mod:`~pymongo.read_preferences` and - :meth:`~pymongo.collection.Collection.with_options` instead) -- read_preference (use :meth:`~pymongo.collection.Collection.with_options` - instead) -- tag_sets (use one of the read preference classes from - :mod:`~pymongo.read_preferences` and - :meth:`~pymongo.collection.Collection.with_options` instead) -- secondary_acceptable_latency_ms (use the ``localThresholdMS`` URI option - instead) -- max_scan (use the new ``modifiers`` option instead) -- snapshot (use the new ``modifiers`` option instead) -- tailable (use the new ``cursor_type`` option instead) -- await_data (use the new ``cursor_type`` option instead) -- exhaust (use the new ``cursor_type`` option instead) -- as_class (use :meth:`~pymongo.collection.Collection.with_options` with - :class:`~bson.codec_options.CodecOptions` instead) -- compile_re (BSON regular expressions are always decoded to - :class:`~bson.regex.Regex`) - -The following find/find_one options are deprecated: - -- manipulate - -The following renames need special handling. - -- timeout -> no_cursor_timeout - - The default for ``timeout`` was True. The default for ``no_cursor_timeout`` is - False. If you were previously passing False for ``t`imeout`` you must pass - **True** for ``no_cursor_timeout`` to keep the previous behavior. - -:mod:`~pymongo.errors` changes -.............................. - -The exception classes ``UnsupportedOption`` and ``TimeoutError`` are deleted. - -:mod:`~gridfs` changes -...................... - -Since PyMongo 1.6, methods ``open`` and ``close`` of :class:`~gridfs.GridFS` -raised an ``UnsupportedAPI`` exception, as did the entire ``GridFile`` class. -The unsupported methods, the class, and the exception are all deleted. - -:mod:`~bson` changes -.................... - -The ``compile_re`` option is removed from all methods -that accepted it in :mod:`~bson` and :mod:`~bson.json_util`. Additionally, it -is removed from :meth:`~pymongo.collection.Collection.find`, -:meth:`~pymongo.collection.Collection.find_one`, -:meth:`~pymongo.collection.Collection.aggregate`, -:meth:`~pymongo.database.Database.command`, and so on. -PyMongo now always represents BSON regular expressions as -:class:`~bson.regex.Regex` objects. This prevents errors for incompatible -patterns, see `PYTHON-500`_. Use :meth:`~bson.regex.Regex.try_compile` to -attempt to convert from a BSON regular expression to a Python regular -expression object. - -PyMongo now decodes the int64 BSON type to :class:`~bson.int64.Int64`, a -trivial wrapper around long (in python 2.x) or int (in python 3.x). This -allows BSON int64 to be round tripped without losing type information in -python 3. Note that if you store a python long (or a python int larger than -4 bytes) it will be returned from PyMongo as :class:`~bson.int64.Int64`. - -The ``as_class``, ``tz_aware``, and ``uuid_subtype`` options are removed from all -BSON encoding and decoding methods. Use -:class:`~bson.codec_options.CodecOptions` to configure these options. The -APIs affected are: - -- :func:`~bson.decode_all` -- :func:`~bson.decode_iter` -- :func:`~bson.decode_file_iter` -- :meth:`~bson.BSON.encode` -- :meth:`~bson.BSON.decode` - -This is a breaking change for any application that uses the BSON API directly -and changes any of the named parameter defaults. No changes are required for -applications that use the default values for these options. The behavior -remains the same. - -.. _PYTHON-500: https://jira.mongodb.org/browse/PYTHON-500 - -Issues Resolved -............... - -See the `PyMongo 3.0 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 3.0 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=12501 - -Changes in Version 2.9.5 (2017/06/30) -------------------------------------- - -Version 2.9.5 works around ssl module deprecations in Python 3.6, and expected -future ssl module deprecations. It also fixes bugs found since the release of -2.9.4. - -- Use ssl.SSLContext and ssl.PROTOCOL_TLS_CLIENT when available. -- Fixed a C extensions build issue when the interpreter was built with -std=c99 -- Fixed various build issues with MinGW32. -- Fixed a write concern bug in :meth:`~pymongo.database.Database.add_user` and - :meth:`~pymongo.database.Database.remove_user` when connected to MongoDB 3.2+ -- Fixed various test failures related to changes in gevent, MongoDB, and our CI - test environment. - -Issues Resolved -............... - -See the `PyMongo 2.9.5 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.9.5 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=17605 - -Changes in Version 2.9.4 (2016/09/30) -------------------------------------- - -Version 2.9.4 fixes issues reported since the release of 2.9.3. - -- Fixed __repr__ for closed instances of :class:`~pymongo.mongo_client.MongoClient`. -- Fixed :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient` handling of - uuidRepresentation. -- Fixed building and testing the documentation with python 3.x. -- New documentation for `TLS `_ and `Atlas `_. - -Issues Resolved -............... - -See the `PyMongo 2.9.4 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.9.4 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=16885 - -Changes in Version 2.9.3 (2016/03/15) -------------------------------------- - -Version 2.9.3 fixes a few issues reported since the release of 2.9.2 including -thread safety issues in :meth:`~pymongo.collection.Collection.ensure_index`, -:meth:`~pymongo.collection.Collection.drop_index`, and -:meth:`~pymongo.collection.Collection.drop_indexes`. - -Issues Resolved -............... - -See the `PyMongo 2.9.3 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.9.3 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=16539 - -Changes in Version 2.9.2 (2016/02/16) -------------------------------------- - -Version 2.9.2 restores Python 3.1 support, which was broken in PyMongo 2.8. It -improves an error message when decoding BSON as well as fixes a couple other -issues including :meth:`~pymongo.collection.Collection.aggregate` ignoring -:attr:`~pymongo.collection.Collection.codec_options` and -:meth:`~pymongo.database.Database.command` raising a superfluous -``DeprecationWarning``. - -Issues Resolved -............... - -See the `PyMongo 2.9.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.9.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=16303 - -Changes in Version 2.9.1 (2015/11/17) -------------------------------------- - -Version 2.9.1 fixes two interrupt handling issues in the C extensions and -adapts a test case for a behavior change in MongoDB 3.2. - -Issues Resolved -............... - -See the `PyMongo 2.9.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.9.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=16208 - -Changes in Version 2.9 (2015/09/30) ------------------------------------ - -Version 2.9 provides an upgrade path to PyMongo 3.x. Most of the API changes -from PyMongo 3.0 have been backported in a backward compatible way, allowing -applications to be written against PyMongo >= 2.9, rather then PyMongo 2.x or -PyMongo 3.x. See the `PyMongo 3 Migration Guide -`_ for -detailed examples. - -.. note:: There are a number of new deprecations in this release for features - that were removed in PyMongo 3.0. - - :class:`~pymongo.mongo_client.MongoClient`: - - :attr:`~pymongo.mongo_client.MongoClient.host` - - :attr:`~pymongo.mongo_client.MongoClient.port` - - :attr:`~pymongo.mongo_client.MongoClient.use_greenlets` - - :attr:`~pymongo.mongo_client.MongoClient.document_class` - - :attr:`~pymongo.mongo_client.MongoClient.tz_aware` - - :attr:`~pymongo.mongo_client.MongoClient.secondary_acceptable_latency_ms` - - :attr:`~pymongo.mongo_client.MongoClient.tag_sets` - - :attr:`~pymongo.mongo_client.MongoClient.uuid_subtype` - - :meth:`~pymongo.mongo_client.MongoClient.disconnect` - - :meth:`~pymongo.mongo_client.MongoClient.alive` - - :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`: - - :attr:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient.use_greenlets` - - :attr:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient.document_class` - - :attr:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient.tz_aware` - - :attr:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient.secondary_acceptable_latency_ms` - - :attr:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient.tag_sets` - - :attr:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient.uuid_subtype` - - :meth:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient.alive` - - :class:`~pymongo.database.Database`: - - :attr:`~pymongo.database.Database.secondary_acceptable_latency_ms` - - :attr:`~pymongo.database.Database.tag_sets` - - :attr:`~pymongo.database.Database.uuid_subtype` - - :class:`~pymongo.collection.Collection`: - - :attr:`~pymongo.collection.Collection.secondary_acceptable_latency_ms` - - :attr:`~pymongo.collection.Collection.tag_sets` - - :attr:`~pymongo.collection.Collection.uuid_subtype` - -.. warning:: - In previous versions of PyMongo, changing the value of - :attr:`~pymongo.mongo_client.MongoClient.document_class` changed - the behavior of all existing instances of - :class:`~pymongo.collection.Collection`:: - - >>> coll = client.test.test - >>> coll.find_one() - {u'_id': ObjectId('5579dc7cfba5220cc14d9a18')} - >>> from bson.son import SON - >>> client.document_class = SON - >>> coll.find_one() - SON([(u'_id', ObjectId('5579dc7cfba5220cc14d9a18'))]) - - The document_class setting is now configurable at the client, - database, collection, and per-operation level. This required breaking - the existing behavior. To change the document class per operation in a - forward compatible way use - :meth:`~pymongo.collection.Collection.with_options`:: - - >>> coll.find_one() - {u'_id': ObjectId('5579dc7cfba5220cc14d9a18')} - >>> from bson.codec_options import CodecOptions - >>> coll.with_options(CodecOptions(SON)).find_one() - SON([(u'_id', ObjectId('5579dc7cfba5220cc14d9a18'))]) - -Issues Resolved -............... - -See the `PyMongo 2.9 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.9 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=14795 - -Changes in Version 2.8.1 (2015/05/11) -------------------------------------- - -Version 2.8.1 fixes a number of issues reported since the release of PyMongo -2.8. It is a recommended upgrade for all users of PyMongo 2.x. - -Issues Resolved -............... - -See the `PyMongo 2.8.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.8.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=15324 - -Changes in Version 2.8 (2015/01/28) ------------------------------------ - -Version 2.8 is a major release that provides full support for MongoDB 3.0 and -fixes a number of bugs. - -Special thanks to Don Mitchell, Ximing, Can Zhang, Sergey Azovskov, and Heewa -Barfchin for their contributions to this release. - -Highlights include: - -- Support for the SCRAM-SHA-1 authentication mechanism (new in MongoDB 3.0). -- JSON decoder support for the new $numberLong and $undefined types. -- JSON decoder support for the $date type as an ISO-8601 string. -- Support passing an index name to :meth:`~pymongo.cursor.Cursor.hint`. -- The :meth:`~pymongo.cursor.Cursor.count` method will use a hint if one - has been provided through :meth:`~pymongo.cursor.Cursor.hint`. -- A new socketKeepAlive option for the connection pool. -- New generator based BSON decode functions, :func:`~bson.decode_iter` - and :func:`~bson.decode_file_iter`. -- Internal changes to support alternative storage engines like wiredtiger. - -.. note:: There are a number of deprecations in this release for features that - will be removed in PyMongo 3.0. These include: - - - :meth:`~pymongo.mongo_client.MongoClient.start_request` - - :meth:`~pymongo.mongo_client.MongoClient.in_request` - - :meth:`~pymongo.mongo_client.MongoClient.end_request` - - :meth:`~pymongo.mongo_client.MongoClient.copy_database` - - :meth:`~pymongo.database.Database.error` - - :meth:`~pymongo.database.Database.last_status` - - :meth:`~pymongo.database.Database.previous_error` - - :meth:`~pymongo.database.Database.reset_error_history` - - :class:`~pymongo.master_slave_connection.MasterSlaveConnection` - - The JSON format for :class:`~bson.timestamp.Timestamp` has changed from - '{"t": , "i": }' to '{"$timestamp": {"t": , "i": }}'. - This new format will be decoded to an instance of - :class:`~bson.timestamp.Timestamp`. The old format will continue to be - decoded to a python dict as before. Encoding to the old format is no - longer supported as it was never correct and loses type information. - -Issues Resolved -............... - -See the `PyMongo 2.8 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.8 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=14223 - -Changes in Version 2.7.2 (2014/07/29) -------------------------------------- - -Version 2.7.2 includes fixes for upsert reporting in the bulk API for MongoDB -versions previous to 2.6, a regression in how son manipulators are applied in -:meth:`~pymongo.collection.Collection.insert`, a few obscure connection pool -semaphore leaks, and a few other minor issues. See the list of issues resolved -for full details. - -Issues Resolved -............... - -See the `PyMongo 2.7.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.7.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=14005 - -Changes in Version 2.7.1 (2014/05/23) -------------------------------------- - -Version 2.7.1 fixes a number of issues reported since the release of 2.7, -most importantly a fix for creating indexes and manipulating users through -mongos versions older than 2.4.0. - -Issues Resolved -............... - -See the `PyMongo 2.7.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.7.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=13823 - -Changes in Version 2.7 (2014/04/03) ------------------------------------ - -PyMongo 2.7 is a major release with a large number of new features and bug -fixes. Highlights include: - -- Full support for MongoDB 2.6. -- A new `bulk write operations API `_. -- Support for server side query timeouts using - :meth:`~pymongo.cursor.Cursor.max_time_ms`. -- Support for writing :meth:`~pymongo.collection.Collection.aggregate` - output to a collection. -- A new :meth:`~pymongo.collection.Collection.parallel_scan` helper. -- :class:`~pymongo.errors.OperationFailure` and its subclasses now include - a :attr:`~pymongo.errors.OperationFailure.details` attribute with complete - error details from the server. -- A new GridFS :meth:`~gridfs.GridFS.find` method that returns a - :class:`~gridfs.grid_file.GridOutCursor`. -- Greatly improved `support for mod_wsgi `_ when using - PyMongo's C extensions. Read `Jesse's blog post - `_ for details. -- Improved C extension support for ARM little endian. - -Breaking changes -................ - -Version 2.7 drops support for replica sets running MongoDB versions older -than 1.6.2. - -Issues Resolved -............... - -See the `PyMongo 2.7 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.7 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=12892 - -Changes in Version 2.6.3 (2013/10/11) -------------------------------------- - -Version 2.6.3 fixes issues reported since the release of 2.6.2, most -importantly a semaphore leak when a connection to the server fails. - -Issues Resolved -............... - -See the `PyMongo 2.6.3 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.6.3 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=13098 - -Changes in Version 2.6.2 (2013/09/06) -------------------------------------- - -Version 2.6.2 fixes a :exc:`TypeError` problem when max_pool_size=None -is used in Python 3. - -Issues Resolved -............... - -See the `PyMongo 2.6.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.6.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=12910 - -Changes in Version 2.6.1 (2013/09/03) -------------------------------------- - -Version 2.6.1 fixes a reference leak in -the :meth:`~pymongo.collection.Collection.insert` method. - -Issues Resolved -............... - -See the `PyMongo 2.6.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.6.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=12905 - -Changes in Version 2.6 (2013/08/19) ------------------------------------ - -Version 2.6 includes some frequently requested improvements and adds -support for some early MongoDB 2.6 features. - -Special thanks go to Justin Patrin for his work on the connection pool -in this release. - -Important new features: - -- The ``max_pool_size`` option for :class:`~pymongo.mongo_client.MongoClient` - and :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient` now - actually caps the number of sockets the pool will open concurrently. - Once the pool has reaches max_pool_size - operations will block waiting for a socket to become available. If - ``waitQueueTimeoutMS`` is set, an operation that blocks waiting for a socket - will raise :exc:`~pymongo.errors.ConnectionFailure` after the timeout. By - default ``waitQueueTimeoutMS`` is not set. - See `connection pooling `_ for more information. -- The :meth:`~pymongo.collection.Collection.insert` method automatically splits - large batches of documents into multiple insert messages based on - :attr:`~pymongo.mongo_client.MongoClient.max_message_size` -- Support for the exhaust cursor flag. - See :meth:`~pymongo.collection.Collection.find` for details and caveats. -- Support for the PLAIN and MONGODB-X509 authentication mechanisms. - See `the authentication docs `_ for more - information. -- Support aggregation output as a :class:`~pymongo.cursor.Cursor`. See - :meth:`~pymongo.collection.Collection.aggregate` for details. - -.. warning:: SIGNIFICANT BEHAVIOR CHANGE in 2.6. Previously, ``max_pool_size`` - would limit only the idle sockets the pool would hold onto, not the - number of open sockets. The default has also changed, from 10 to 100. - If you pass a value for ``max_pool_size`` make sure it is large enough for - the expected load. (Sockets are only opened when needed, so there is no cost - to having a ``max_pool_size`` larger than necessary. Err towards a larger - value.) If your application accepts the default, continue to do so. - - See `connection pooling `_ for more information. - -Issues Resolved -............... - -See the `PyMongo 2.6 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.6 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=12380 - -Changes in Version 2.5.2 (2013/06/01) -------------------------------------- - -Version 2.5.2 fixes a NULL pointer dereference issue when decoding -an invalid :class:`~bson.dbref.DBRef`. - -Issues Resolved -............... - -See the `PyMongo 2.5.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.5.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=12581 - -Changes in Version 2.5.1 (2013/05/13) -------------------------------------- - -Version 2.5.1 is a minor release that fixes issues discovered after the -release of 2.5. Most importantly, this release addresses some race -conditions in replica set monitoring. - -Issues Resolved -............... - -See the `PyMongo 2.5.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.5.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=12484 - -Changes in Version 2.5 (2013/03/22) ------------------------------------ - -Version 2.5 includes changes to support new features in MongoDB 2.4. - -Important new features: - -- Support for `GSSAPI (Kerberos) `_. -- Support for SSL certificate validation with hostname matching. -- Support for delegated and role based authentication. -- New GEOSPHERE (2dsphere) and HASHED index constants. - -.. note:: :meth:`~pymongo.database.Database.authenticate` now raises a - subclass of :class:`~pymongo.errors.PyMongoError` if authentication - fails due to invalid credentials or configuration issues. - -Issues Resolved -............... - -See the `PyMongo 2.5 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.5 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=11981 - -Changes in Version 2.4.2 (2013/01/23) -------------------------------------- - -Version 2.4.2 is a minor release that fixes issues discovered after the -release of 2.4.1. Most importantly, PyMongo will no longer select a replica -set member for read operations that is not in primary or secondary state. - -Issues Resolved -............... - -See the `PyMongo 2.4.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.4.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=12299 - -Changes in Version 2.4.1 (2012/12/06) -------------------------------------- - -Version 2.4.1 is a minor release that fixes issues discovered after the -release of 2.4. Most importantly, this release fixes a regression using -:meth:`~pymongo.collection.Collection.aggregate`, and possibly other commands, -with mongos. - -Issues Resolved -............... - -See the `PyMongo 2.4.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.4.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=12286 - -Changes in Version 2.4 (2012/11/27) ------------------------------------ - -Version 2.4 includes a few important new features and a large number of bug -fixes. - -Important new features: - -- New :class:`~pymongo.mongo_client.MongoClient` and - :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient` classes - - these connection classes do acknowledged write operations (previously referred - to as 'safe' writes) by default. :class:`~pymongo.connection.Connection` and - :class:`~pymongo.replica_set_connection.ReplicaSetConnection` are deprecated - but still support the old default fire-and-forget behavior. -- A new write concern API implemented as a - :attr:`~pymongo.collection.Collection.write_concern` attribute on the connection, - :class:`~pymongo.database.Database`, or :class:`~pymongo.collection.Collection` - classes. -- :class:`~pymongo.mongo_client.MongoClient` (and :class:`~pymongo.connection.Connection`) - now support Unix Domain Sockets. -- :class:`~pymongo.cursor.Cursor` can be copied with functions from the :mod:`copy` - module. -- The :meth:`~pymongo.database.Database.set_profiling_level` method now supports - a ``slow_ms`` option. -- The replica set monitor task (used by - :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient` and - :class:`~pymongo.replica_set_connection.ReplicaSetConnection`) is a daemon thread - once again, meaning you won't have to call - :meth:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient.close` before - exiting the python interactive shell. - -.. warning:: - - The constructors for :class:`~pymongo.mongo_client.MongoClient`, - :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`, - :class:`~pymongo.connection.Connection`, and - :class:`~pymongo.replica_set_connection.ReplicaSetConnection` now raise - :exc:`~pymongo.errors.ConnectionFailure` instead of its subclass - :exc:`~pymongo.errors.AutoReconnect` if the server is unavailable. Applications - that expect to catch :exc:`~pymongo.errors.AutoReconnect` should now catch - :exc:`~pymongo.errors.ConnectionFailure` while creating a new connection. - -Issues Resolved -............... - -See the `PyMongo 2.4 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.4 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=11485 - -Changes in Version 2.3 (2012/08/29) ------------------------------------ - -Version 2.3 adds support for new features and behavior changes in MongoDB -2.2. - -Important New Features: - -- Support for expanded read preferences including directing reads to tagged - servers - See `secondary reads `_ for more information. -- Support for mongos failover. -- A new :meth:`~pymongo.collection.Collection.aggregate` method to support - MongoDB's new `aggregation framework - `_. -- Support for legacy Java and C# byte order when encoding and decoding UUIDs. -- Support for connecting directly to an arbiter. - -.. warning:: - - Starting with MongoDB 2.2 the getLastError command requires authentication - when the server's `authentication features - `_ are enabled. - Changes to PyMongo were required to support this behavior change. Users of - authentication must upgrade to PyMongo 2.3 (or newer) for "safe" write operations - to function correctly. - -Issues Resolved -............... - -See the `PyMongo 2.3 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.3 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=11146 - -Changes in Version 2.2.1 (2012/07/06) -------------------------------------- - -Version 2.2.1 is a minor release that fixes issues discovered after the -release of 2.2. Most importantly, this release fixes an incompatibility -with mod_wsgi 2.x that could cause connections to leak. Users of mod_wsgi -2.x are strongly encouraged to upgrade from PyMongo 2.2. - -Issues Resolved -............... - -See the `PyMongo 2.2.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.2.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=11185 - -Changes in Version 2.2 (2012/04/30) ------------------------------------ - -Version 2.2 adds a few more frequently requested features and fixes a -number of bugs. - -Special thanks go to Alex Grönholm for his contributions to Python 3 -support and maintaining the original pymongo3 port. Christoph Simon, -Wouter Bolsterlee, Mike O'Brien, and Chris Tompkinson also contributed -to this release. - -Important New Features: - -- Support for Python 3. - See `Python 3 `_ for more information. -- Support for Gevent - - See `Gevent `_ for more information. -- Improved connection pooling. - See `PYTHON-287 `_. - -.. warning:: - - A number of methods and method parameters that were deprecated in - PyMongo 1.9 or older versions have been removed in this release. - The full list of changes can be found in the following JIRA ticket: - - https://jira.mongodb.org/browse/PYTHON-305 - - BSON module aliases from the pymongo package that were deprecated in - PyMongo 1.9 have also been removed in this release. See the following - JIRA ticket for details: - - https://jira.mongodb.org/browse/PYTHON-304 - - As a result of this cleanup some minor code changes may be required - to use this release. - -Issues Resolved -............... - -See the `PyMongo 2.2 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=10584 - -Changes in Version 2.1.1 (2012/01/04) -------------------------------------- - -Version 2.1.1 is a minor release that fixes a few issues -discovered after the release of 2.1. You can now use -:class:`~pymongo.replica_set_connection.ReplicaSetConnection` -to run inline map reduce commands on secondaries. See -:meth:`~pymongo.collection.Collection.inline_map_reduce` for details. - -Special thanks go to Samuel Clay and Ross Lawley for their contributions -to this release. - -Issues Resolved -............... - -See the `PyMongo 2.1.1 release notes in JIRA`_ for the list of resolved issues -in this release. - -.. _PyMongo 2.1.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?version=11081&styleName=Html&projectId=10004 - -Changes in Version 2.1 (2011/12/07) ------------------------------------ - -Version 2.1 adds a few frequently requested features and includes the usual -round of bug fixes and improvements. - -Special thanks go to Alexey Borzenkov, Dan Crosta, Kostya Rybnikov, -Flavio Percoco Premoli, Jonas Haag, and Jesse Davis for their contributions -to this release. - -Important New Features: - -- ReplicaSetConnection - - :class:`~pymongo.replica_set_connection.ReplicaSetConnection` - can be used to distribute reads to secondaries in a replica set. It supports - automatic failover handling and periodically checks the state of the - replica set to handle issues like primary stepdown or secondaries - being removed for backup operations. Read preferences are defined through - :class:`~pymongo.read_preferences.ReadPreference`. -- PyMongo supports the new BSON binary subtype 4 for UUIDs. The default - subtype to use can be set through - :attr:`~pymongo.collection.Collection.uuid_subtype` - The current default remains :attr:`~bson.binary.OLD_UUID_SUBTYPE` but will - be changed to :attr:`~bson.binary.UUID_SUBTYPE` in a future release. -- The getLastError option 'w' can be set to a string, allowing for options - like "majority" available in newer version of MongoDB. -- Added support for the MongoDB URI options socketTimeoutMS and connectTimeoutMS. -- Added support for the ContinueOnError insert flag. -- Added basic SSL support. -- Added basic support for Jython. -- Secondaries can be used for :meth:`~pymongo.cursor.Cursor.count`, - :meth:`~pymongo.cursor.Cursor.distinct`, :meth:`~pymongo.collection.Collection.group`, - and querying :class:`~gridfs.GridFS`. -- Added document_class and tz_aware options to - :class:`~pymongo.master_slave_connection.MasterSlaveConnection` - -Issues Resolved -............... - -See the `PyMongo 2.1 release notes in JIRA`_ for the list of resolved issues in this release. - -.. _PyMongo 2.1 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=10583 - -Changes in Version 2.0.1 (2011/08/15) -------------------------------------- - -Version 2.0.1 fixes a regression in :class:`~gridfs.grid_file.GridIn` when -writing pre-chunked strings. Thanks go to Alexey Borzenkov for reporting the -issue and submitting a patch. - -Issues Resolved -............... - -- `PYTHON-271 `_: - Regression in GridFS leads to serious loss of data. - -Changes in Version 2.0 (2011/08/05) ------------------------------------ - -Version 2.0 adds a large number of features and fixes a number of issues. - -Special thanks go to James Murty, Abhay Vardhan, David Pisoni, Ryan Smith-Roberts, -Andrew Pendleton, Mher Movsisyan, Reed O'Brien, Michael Schurter, Josip Delic -and Jonas Haag for their contributions to this release. - -Important New Features: - -- PyMongo now performs automatic per-socket database authentication. You no - longer have to re-authenticate for each new thread or after a replica set - failover. Authentication credentials are cached by the driver until the - application calls :meth:`~pymongo.database.Database.logout`. -- slave_okay can be set independently at the connection, database, collection - or query level. Each level will inherit the slave_okay setting from the - previous level and each level can override the previous level's setting. -- safe and getLastError options (e.g. w, wtimeout, etc.) can be set - independently at the connection, database, collection or query level. Each - level will inherit settings from the previous level and each level can - override the previous level's setting. -- PyMongo now supports the ``await_data`` and ``partial`` cursor flags. If the - ``await_data`` flag is set on a ``tailable`` cursor the server will block for - some extra time waiting for more data to return. The ``partial`` flag tells - a mongos to return partial data for a query if not all shards are available. -- :meth:`~pymongo.collection.Collection.map_reduce` will accept a ``dict`` or - instance of :class:`~bson.son.SON` as the ``out`` parameter. -- The URI parser has been moved into its own module and can be used directly - by application code. -- AutoReconnect exception now provides information about the error that - actually occurred instead of a generic failure message. -- A number of new helper methods have been added with options for setting and - unsetting cursor flags, re-indexing a collection, fsync and locking a server, - and getting the server's current operations. - -API changes: - -- If only one host:port pair is specified :class:`~pymongo.connection.Connection` - will make a direct connection to only that host. Please note that ``slave_okay`` - must be ``True`` in order to query from a secondary. -- If more than one host:port pair is specified or the ``replicaset`` option is - used PyMongo will treat the specified host:port pair(s) as a seed list and - connect using replica set behavior. - -.. warning:: - - The default subtype for :class:`~bson.binary.Binary` has changed - from :const:`~bson.binary.OLD_BINARY_SUBTYPE` (2) to - :const:`~bson.binary.BINARY_SUBTYPE` (0). - -Issues Resolved -............... - -See the `PyMongo 2.0 release notes in JIRA`_ for the list of resolved issues in this release. - -.. _PyMongo 2.0 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=10274 - -Changes in Version 1.11 (2011/05/05) ------------------------------------- - -Version 1.11 adds a few new features and fixes a few more bugs. - -New Features: - -- Basic IPv6 support: pymongo prefers IPv4 but will try IPv6. You can - also specify an IPv6 address literal in the ``host`` parameter or a - MongoDB URI provided it is enclosed in '[' and ']'. -- max_pool_size option: previously pymongo had a hard coded pool size - of 10 connections. With this change you can specify a different pool - size as a parameter to :class:`~pymongo.connection.Connection` - (max_pool_size=) or in the MongoDB URI (maxPoolSize=). -- Find by metadata in GridFS: You can know specify query fields as - keyword parameters for :meth:`~gridfs.GridFS.get_version` and - :meth:`~gridfs.GridFS.get_last_version`. -- Per-query slave_okay option: slave_okay=True is now a valid keyword - argument for :meth:`~pymongo.collection.Collection.find` and - :meth:`~pymongo.collection.Collection.find_one`. - -API changes: - -- :meth:`~pymongo.database.Database.validate_collection` now returns a - dict instead of a string. This change was required to deal with an - API change on the server. This method also now takes the optional - ``scandata`` and ``full`` parameters. See the documentation for more - details. - -.. warning:: The ``pool_size``, ``auto_start_request```, and ``timeout`` parameters - for :class:`~pymongo.connection.Connection` have been completely - removed in this release. They were deprecated in pymongo-1.4 and - have had no effect since then. Please make sure that your code - doesn't currently pass these parameters when creating a - Connection instance. - -Issues resolved -............... - -- `PYTHON-241 `_: - Support setting slaveok at the cursor level. -- `PYTHON-240 `_: - Queries can sometimes permanently fail after a replica set fail over. -- `PYTHON-238 `_: - error after few million requests -- `PYTHON-237 `_: - Basic IPv6 support. -- `PYTHON-236 `_: - Restore option to specify pool size in Connection. -- `PYTHON-212 `_: - pymongo does not recover after stale config -- `PYTHON-138 `_: - Find method for GridFS - -Changes in Version 1.10.1 (2011/04/07) --------------------------------------- - -Version 1.10.1 is primarily a bugfix release. It fixes a regression in -version 1.10 that broke pickling of ObjectIds. A number of other bugs -have been fixed as well. - -There are two behavior changes to be aware of: - -- If a read slave raises :class:`~pymongo.errors.AutoReconnect` - :class:`~pymongo.master_slave_connection.MasterSlaveConnection` will now - retry the query on each slave until it is successful or all slaves have - raised :class:`~pymongo.errors.AutoReconnect`. Any other exception will - immediately be raised. The order that the slaves are tried is random. - Previously the read would be sent to one randomly chosen slave and - :class:`~pymongo.errors.AutoReconnect` was immediately raised in case - of a connection failure. -- A Python ``long`` is now always BSON encoded as an int64. Previously the - encoding was based only on the value of the field and a ``long`` with a - value less than ``2147483648`` or greater than ``-2147483649`` would always - be BSON encoded as an int32. - -Issues resolved -............... - -- `PYTHON-234 `_: - Fix setup.py to raise exception if any when building extensions -- `PYTHON-233 `_: - Add information to build and test with extensions on windows -- `PYTHON-232 `_: - Traceback when hashing a DBRef instance -- `PYTHON-231 `_: - Traceback when pickling a DBRef instance -- `PYTHON-230 `_: - Pickled ObjectIds are not compatible between pymongo 1.9 and 1.10 -- `PYTHON-228 `_: - Cannot pickle bson.ObjectId -- `PYTHON-227 `_: - Traceback when calling find() on system.js -- `PYTHON-216 `_: - MasterSlaveConnection is missing disconnect() method -- `PYTHON-186 `_: - When storing integers, type is selected according to value instead of type -- `PYTHON-173 `_: - as_class option is not propagated by Cursor.clone -- `PYTHON-113 `_: - Redunducy in MasterSlaveConnection - -Changes in Version 1.10 (2011/03/30) ------------------------------------- - -Version 1.10 includes changes to support new features in MongoDB 1.8.x. -Highlights include a modified map/reduce API including an inline map/reduce -helper method, a new find_and_modify helper, and the ability to query the -server for the maximum BSON document size it supports. - -- added :meth:`~pymongo.collection.Collection.find_and_modify`. -- added :meth:`~pymongo.collection.Collection.inline_map_reduce`. -- changed :meth:`~pymongo.collection.Collection.map_reduce`. - -.. warning:: MongoDB versions greater than 1.7.4 no longer generate temporary - collections for map/reduce results. An output collection name must be - provided and the output will replace any existing output collection with - the same name. :meth:`~pymongo.collection.Collection.map_reduce` now - requires the ``out`` parameter. - -Issues resolved -............... - -- PYTHON-225: :class:`~pymongo.objectid.ObjectId` class definition should use __slots__. -- PYTHON-223: Documentation fix. -- PYTHON-220: Documentation fix. -- PYTHON-219: KeyError in :meth:`~pymongo.collection.Collection.find_and_modify` -- PYTHON-213: Query server for maximum BSON document size. -- PYTHON-208: Fix :class:`~pymongo.connection.Connection` __repr__. -- PYTHON-207: Changes to Map/Reduce API. -- PYTHON-205: Accept slaveOk in the URI to match the URI docs. -- PYTHON-203: When slave_okay=True and we only specify one host don't autodetect other set members. -- PYTHON-194: Show size when whining about a document being too large. -- PYTHON-184: Raise :class:`~pymongo.errors.DuplicateKeyError` for duplicate keys in capped collections. -- PYTHON-178: Don't segfault when trying to encode a recursive data structure. -- PYTHON-177: Don't segfault when decoding dicts with broken iterators. -- PYTHON-172: Fix a typo. -- PYTHON-170: Add :meth:`~pymongo.collection.Collection.find_and_modify`. -- PYTHON-169: Support deepcopy of DBRef. -- PYTHON-167: Duplicate of PYTHON-166. -- PYTHON-166: Fixes a concurrency issue. -- PYTHON-158: Add code and err string to ``db assertion`` messages. - -Changes in Version 1.9 (2010/09/28) ------------------------------------ - -Version 1.9 adds a new package to the PyMongo distribution, -:mod:`bson`. :mod:`bson` contains all of the `BSON -`_ encoding and decoding logic, and the BSON -types that were formerly in the :mod:`pymongo` package. The following -modules have been renamed: - - - :mod:`pymongo.bson` -> :mod:`bson` - - :mod:`pymongo._cbson` -> :mod:`bson._cbson` and - :mod:`pymongo._cmessage` - - :mod:`pymongo.binary` -> :mod:`bson.binary` - - :mod:`pymongo.code` -> :mod:`bson.code` - - :mod:`pymongo.dbref` -> :mod:`bson.dbref` - - :mod:`pymongo.json_util` -> :mod:`bson.json_util` - - :mod:`pymongo.max_key` -> :mod:`bson.max_key` - - :mod:`pymongo.min_key` -> :mod:`bson.min_key` - - :mod:`pymongo.objectid` -> :mod:`bson.objectid` - - :mod:`pymongo.son` -> :mod:`bson.son` - - :mod:`pymongo.timestamp` -> :mod:`bson.timestamp` - - :mod:`pymongo.tz_util` -> :mod:`bson.tz_util` - -In addition, the following exception classes have been renamed: - - - :class:`pymongo.errors.InvalidBSON` -> - :class:`bson.errors.InvalidBSON` - - :class:`pymongo.errors.InvalidStringData` -> - :class:`bson.errors.InvalidStringData` - - :class:`pymongo.errors.InvalidDocument` -> - :class:`bson.errors.InvalidDocument` - - :class:`pymongo.errors.InvalidId` -> - :class:`bson.errors.InvalidId` - -The above exceptions now inherit from :class:`bson.errors.BSONError` -rather than :class:`pymongo.errors.PyMongoError`. - -.. note:: All of the renamed modules and exceptions above have aliases - created with the old names, so these changes should not break - existing code. The old names will eventually be deprecated and then - removed, so users should begin migrating towards the new names now. - -.. warning:: - - The change to the exception hierarchy mentioned above is - possibly breaking. If your code is catching - :class:`~pymongo.errors.PyMongoError`, then the exceptions raised - by :mod:`bson` will not be caught, even though they would have been - caught previously. Before upgrading, it is recommended that users - check for any cases like this. - -- the C extension now shares buffer.c/h with the Ruby driver -- :mod:`bson` no longer raises :class:`~pymongo.errors.InvalidName`, - all occurrences have been replaced with - :class:`~bson.errors.InvalidDocument`. -- renamed :meth:`bson._to_dicts` to :meth:`~bson.decode_all`. -- renamed :meth:`~bson.BSON.from_dict` to :meth:`~bson.BSON.encode` - and :meth:`~bson.BSON.to_dict` to :meth:`~bson.BSON.decode`. -- added :meth:`~pymongo.cursor.Cursor.batch_size`. -- allow updating (some) file metadata after a - :class:`~gridfs.grid_file.GridIn` instance has been closed. -- performance improvements for reading from GridFS. -- special cased slice with the same start and stop to return an empty - cursor. -- allow writing :class:`unicode` to GridFS if an :attr:`encoding` - attribute has been specified for the file. -- added :meth:`gridfs.GridFS.get_version`. -- scope variables for :class:`~bson.code.Code` can now be specified as - keyword arguments. -- added :meth:`~gridfs.grid_file.GridOut.readline` to - :class:`~gridfs.grid_file.GridOut`. -- make a best effort to transparently auto-reconnect if a - :class:`~pymongo.connection.Connection` has been idle for a while. -- added :meth:`~pymongo.database.SystemJS.list` to - :class:`~pymongo.database.SystemJS`. -- added ``file_document`` argument to :meth:`~gridfs.grid_file.GridOut` - to allow initializing from an existing file document. -- raise :class:`~pymongo.errors.TimeoutError` even if the - ``getLastError`` command was run manually and not through "safe" - mode. -- added :class:`uuid` support to :mod:`~bson.json_util`. - -Changes in Version 1.8.1 (2010/08/13) -------------------------------------- - -- fixed a typo in the C extension that could cause safe-mode - operations to report a failure (:class:`SystemError`) even when none - occurred. -- added a :meth:`__ne__` implementation to any class where we define - :meth:`__eq__`. - -Changes in Version 1.8 (2010/08/05) ------------------------------------ - -Version 1.8 adds support for connecting to replica sets, specifying -per-operation values for ``w`` and ``wtimeout``, and decoding to -timezone-aware datetimes. - -- fixed a reference leak in the C extension when decoding a - :class:`~bson.dbref.DBRef`. -- added support for ``w``, ``wtimeout``, and ``fsync`` (and any other - options for ``getLastError``) to "safe mode" operations. -- added :attr:`~pymongo.connection.Connection.nodes` property. -- added a maximum pool size of 10 sockets. -- added support for replica sets. -- DEPRECATED :meth:`~pymongo.connection.Connection.from_uri` and - :meth:`~pymongo.connection.Connection.paired`, both are supplanted - by extended functionality in :meth:`~pymongo.connection.Connection`. -- added tz aware support for datetimes in - :class:`~bson.objectid.ObjectId`, - :class:`~bson.timestamp.Timestamp` and :mod:`~bson.json_util` - methods. -- added :meth:`~pymongo.collection.Collection.drop` helper. -- reuse the socket used for finding the master when a - :class:`~pymongo.connection.Connection` is first created. -- added support for :class:`~bson.min_key.MinKey`, - :class:`~bson.max_key.MaxKey` and - :class:`~bson.timestamp.Timestamp` to :mod:`~bson.json_util`. -- added support for decoding datetimes as aware (UTC) - it is highly - recommended to enable this by setting the ``tz_aware`` parameter to - :meth:`~pymongo.connection.Connection` to ``True``. -- added ``network_timeout`` option for individual calls to - :meth:`~pymongo.collection.Collection.find` and - :meth:`~pymongo.collection.Collection.find_one`. -- added :meth:`~gridfs.GridFS.exists` to check if a file exists in - GridFS. -- added support for additional keys in :class:`~bson.dbref.DBRef` - instances. -- added :attr:`~pymongo.errors.OperationFailure.code` attribute to - :class:`~pymongo.errors.OperationFailure` exceptions. -- fixed serialization of int and float subclasses in the C extension. - -Changes in Version 1.7 (2010/06/17) ------------------------------------ - -Version 1.7 is a recommended upgrade for all PyMongo users. The full -release notes are below, and some more in depth discussion of the -highlights is `here -`_. - -- no longer attempt to build the C extension on big-endian systems. -- added :class:`~bson.min_key.MinKey` and - :class:`~bson.max_key.MaxKey`. -- use unsigned for :class:`~bson.timestamp.Timestamp` in BSON - encoder/decoder. -- support ``True`` as ``"ok"`` in command responses, in addition to - ``1.0`` - necessary for server versions **>= 1.5.X** -- BREAKING change to - :meth:`~pymongo.collection.Collection.index_information` to add - support for querying unique status and other index information. -- added :attr:`~pymongo.connection.Connection.document_class`, to - specify class for returned documents. -- added ``as_class`` argument for - :meth:`~pymongo.collection.Collection.find`, and in the BSON decoder. -- added support for creating :class:`~bson.timestamp.Timestamp` - instances using a :class:`~datetime.datetime`. -- allow ``dropTarget`` argument for - :class:`~pymongo.collection.Collection.rename`. -- handle aware :class:`~datetime.datetime` instances, by converting to - UTC. -- added support for :class:`~pymongo.cursor.Cursor.max_scan`. -- raise :class:`~gridfs.errors.FileExists` exception when creating a - duplicate GridFS file. -- use `y2038 `_ for time handling in - the C extension - eliminates 2038 problems when extension is - installed. -- added ``sort`` parameter to - :meth:`~pymongo.collection.Collection.find` -- finalized deprecation of changes from versions **<= 1.4** -- take any non-:class:`dict` as an ``"_id"`` query for - :meth:`~pymongo.collection.Collection.find_one` or - :meth:`~pymongo.collection.Collection.remove` -- added ability to pass a :class:`dict` for ``fields`` argument to - :meth:`~pymongo.collection.Collection.find` (supports ``"$slice"`` - and field negation) -- simplified code to find master, since paired setups don't always have - a remote -- fixed bug in C encoder for certain invalid types (like - :class:`~pymongo.collection.Collection` instances). -- don't transparently map ``"filename"`` key to :attr:`name` attribute - for GridFS. - -Changes in Version 1.6 (2010/04/14) ------------------------------------ - -The biggest change in version 1.6 is a complete re-implementation of -:mod:`gridfs` with a lot of improvements over the old -implementation. There are many details and examples of using the new -API in `this blog post -`_. The -old API has been removed in this version, so existing code will need -to be modified before upgrading to 1.6. - -- fixed issue where connection pool was being shared across - :class:`~pymongo.connection.Connection` instances. -- more improvements to Python code caching in C extension - should - improve behavior on mod_wsgi. -- added :meth:`~bson.objectid.ObjectId.from_datetime`. -- complete rewrite of :mod:`gridfs` support. -- improvements to the :meth:`~pymongo.database.Database.command` API. -- fixed :meth:`~pymongo.collection.Collection.drop_indexes` behavior - on non-existent collections. -- disallow empty bulk inserts. - -Changes in Version 1.5.2 (2010/03/31) -------------------------------------- -- fixed response handling to ignore unknown response flags in queries. -- handle server versions containing '-pre-'. - -Changes in Version 1.5.1 (2010/03/17) -------------------------------------- -- added :data:`~gridfs.grid_file.GridFile._id` property for - :class:`~gridfs.grid_file.GridFile` instances. -- fix for making a :class:`~pymongo.connection.Connection` (with - ``slave_okay`` set) directly to a slave in a replica pair. -- accept kwargs for - :meth:`~pymongo.collection.Collection.create_index` and - :meth:`~pymongo.collection.Collection.ensure_index` to support all - indexing options. -- add :data:`pymongo.GEO2D` and support for geo indexing. -- improvements to Python code caching in C extension - should improve - behavior on mod_wsgi. - -Changes in Version 1.5 (2010/03/10) ------------------------------------ -- added subtype constants to :mod:`~bson.binary` module. -- DEPRECATED ``options`` argument to - :meth:`~pymongo.collection.Collection` and - :meth:`~pymongo.database.Database.create_collection` in favor of - kwargs. -- added :meth:`~pymongo.has_c` to check for C extension. -- added :meth:`~pymongo.connection.Connection.copy_database`. -- added :data:`~pymongo.cursor.Cursor.alive` to tell when a cursor - might have more data to return (useful for tailable cursors). -- added :class:`~bson.timestamp.Timestamp` to better support - dealing with internal MongoDB timestamps. -- added ``name`` argument for - :meth:`~pymongo.collection.Collection.create_index` and - :meth:`~pymongo.collection.Collection.ensure_index`. -- fixed connection pooling w/ fork -- :meth:`~pymongo.connection.Connection.paired` takes all kwargs that - are allowed for :meth:`~pymongo.connection.Connection`. -- :meth:`~pymongo.collection.Collection.insert` returns list for bulk - inserts of size one. -- fixed handling of :class:`datetime.datetime` instances in - :mod:`~bson.json_util`. -- added :meth:`~pymongo.connection.Connection.from_uri` to support - MongoDB connection uri scheme. -- fixed chunk number calculation when unaligned in :mod:`gridfs`. -- :meth:`~pymongo.database.Database.command` takes a string for simple - commands. -- added :data:`~pymongo.database.Database.system_js` helper for - dealing with server-side JS. -- don't wrap queries containing ``"$query"`` (support manual use of - ``"$min"``, etc.). -- added :class:`~gridfs.errors.GridFSError` as base class for - :mod:`gridfs` exceptions. - -Changes in Version 1.4 (2010/01/17) ------------------------------------ - -Perhaps the most important change in version 1.4 is that we have -decided to **no longer support Python 2.3**. The most immediate reason -for this is to allow some improvements to connection pooling. This -will also allow us to use some new (as in Python 2.4 ;) idioms and -will help begin the path towards supporting Python 3.0. If you need to -use Python 2.3 you should consider using version 1.3 of this driver, -although that will no longer be actively supported. - -Other changes: - -- move ``"_id"`` to front only for top-level documents (fixes some - corner cases). -- :meth:`~pymongo.collection.Collection.update` and - :meth:`~pymongo.collection.Collection.remove` return the entire - response to the *lastError* command when safe is ``True``. -- completed removal of things that were deprecated in version 1.2 or - earlier. -- enforce that collection names do not contain the NULL byte. -- fix to allow using UTF-8 collection names with the C extension. -- added :class:`~pymongo.errors.PyMongoError` as base exception class - for all :mod:`~pymongo.errors`. this changes the exception hierarchy - somewhat, and is a BREAKING change if you depend on - :class:`~pymongo.errors.ConnectionFailure` being a :class:`IOError` - or :class:`~bson.errors.InvalidBSON` being a :class:`ValueError`, - for example. -- added :class:`~pymongo.errors.DuplicateKeyError` for calls to - :meth:`~pymongo.collection.Collection.insert` or - :meth:`~pymongo.collection.Collection.update` with ``safe`` set to - ``True``. -- removed :mod:`~pymongo.thread_util`. -- added :meth:`~pymongo.database.Database.add_user` and - :meth:`~pymongo.database.Database.remove_user` helpers. -- fix for :meth:`~pymongo.database.Database.authenticate` when using - non-UTF-8 names or passwords. -- minor fixes for - :class:`~pymongo.master_slave_connection.MasterSlaveConnection`. -- clean up all cases where :class:`~pymongo.errors.ConnectionFailure` - is raised. -- simplification of connection pooling - makes driver ~2x faster for - simple benchmarks. see `connection pooling `_ for more information. -- DEPRECATED ``pool_size``, ``auto_start_request`` and ``timeout`` - parameters to :class:`~pymongo.connection.Connection`. DEPRECATED - :meth:`~pymongo.connection.Connection.start_request`. -- use :meth:`socket.sendall`. -- removed :meth:`~bson.son.SON.from_xml` as it was only being used - for some internal testing - also eliminates dependency on - :mod:`elementtree`. -- implementation of :meth:`~pymongo.message.update` in C. -- deprecate :meth:`~pymongo.database.Database._command` in favor of - :meth:`~pymongo.database.Database.command`. -- send all commands without wrapping as ``{"query": ...}``. -- support string as ``key`` argument to - :meth:`~pymongo.collection.Collection.group` (keyf) and run all - groups as commands. -- support for equality testing for :class:`~bson.code.Code` - instances. -- allow the NULL byte in strings and disallow it in key names or regex - patterns - -Changes in Version 1.3 (2009/12/16) ------------------------------------ -- DEPRECATED running :meth:`~pymongo.collection.Collection.group` as - :meth:`~pymongo.database.Database.eval`, also changed default for - :meth:`~pymongo.collection.Collection.group` to running as a command -- remove :meth:`pymongo.cursor.Cursor.__len__`, which was deprecated - in 1.1.1 - needed to do this aggressively due to it's presence - breaking **Django** template *for* loops -- DEPRECATED :meth:`~pymongo.connection.Connection.host`, - :meth:`~pymongo.connection.Connection.port`, - :meth:`~pymongo.database.Database.connection`, - :meth:`~pymongo.database.Database.name`, - :meth:`~pymongo.collection.Collection.database`, - :meth:`~pymongo.collection.Collection.name` and - :meth:`~pymongo.collection.Collection.full_name` in favor of - :attr:`~pymongo.connection.Connection.host`, - :attr:`~pymongo.connection.Connection.port`, - :attr:`~pymongo.database.Database.connection`, - :attr:`~pymongo.database.Database.name`, - :attr:`~pymongo.collection.Collection.database`, - :attr:`~pymongo.collection.Collection.name` and - :attr:`~pymongo.collection.Collection.full_name`, respectively. The - deprecation schedule for this change will probably be faster than - usual, as it carries some performance implications. -- added :meth:`~pymongo.connection.Connection.disconnect` - -Changes in Version 1.2.1 (2009/12/10) -------------------------------------- -- added :doc:`changelog` to docs -- added ``setup.py doc --test`` to run doctests for tutorial, examples -- moved most examples to Sphinx docs (and remove from *examples/* - directory) -- raise :class:`~bson.errors.InvalidId` instead of - :class:`TypeError` when passing a 24 character string to - :class:`~bson.objectid.ObjectId` that contains non-hexadecimal - characters -- allow :class:`unicode` instances for :class:`~bson.objectid.ObjectId` init - -Changes in Version 1.2 (2009/12/09) ------------------------------------ -- ``spec`` parameter for :meth:`~pymongo.collection.Collection.remove` is - now optional to allow for deleting all documents in a - :class:`~pymongo.collection.Collection` -- always wrap queries with ``{query: ...}`` even when no special options - - get around some issues with queries on fields named ``query`` -- enforce 4MB document limit on the client side -- added :meth:`~pymongo.collection.Collection.map_reduce` helper - see - `Aggregation `_ -- added :meth:`~pymongo.cursor.Cursor.distinct` method on - :class:`~pymongo.cursor.Cursor` instances to allow distinct with - queries -- fix for :meth:`~pymongo.cursor.Cursor.__getitem__` after - :meth:`~pymongo.cursor.Cursor.skip` -- allow any UTF-8 string in :class:`~bson.BSON` encoder, not - just ASCII subset -- added :attr:`~bson.objectid.ObjectId.generation_time` -- removed support for legacy :class:`~bson.objectid.ObjectId` - format - pretty sure this was never used, and is just confusing -- DEPRECATED :meth:`~bson.objectid.ObjectId.url_encode` and - :meth:`~bson.objectid.ObjectId.url_decode` in favor of :meth:`str` - and :meth:`~bson.objectid.ObjectId`, respectively -- allow *oplog.$main* as a valid collection name -- some minor fixes for installation process -- added support for datetime and regex in :mod:`~bson.json_util` - -Changes in Version 1.1.2 (2009/11/23) -------------------------------------- -- improvements to :meth:`~pymongo.collection.Collection.insert` speed - (using C for insert message creation) -- use random number for request_id -- fix some race conditions with :class:`~pymongo.errors.AutoReconnect` - -Changes in Version 1.1.1 (2009/11/14) -------------------------------------- -- added ``multi`` parameter for - :meth:`~pymongo.collection.Collection.update` -- fix unicode regex patterns with C extension -- added :meth:`~pymongo.collection.Collection.distinct` -- added ``database`` support for :class:`~bson.dbref.DBRef` -- added :mod:`~bson.json_util` with helpers for encoding / decoding - special types to JSON -- DEPRECATED :meth:`pymongo.cursor.Cursor.__len__` in favor of - :meth:`~pymongo.cursor.Cursor.count` with ``with_limit_and_skip`` set - to ``True`` due to performance regression -- switch documentation to Sphinx - -Changes in Version 1.1 (2009/10/21) ------------------------------------ -- added :meth:`__hash__` for :class:`~bson.dbref.DBRef` and - :class:`~bson.objectid.ObjectId` -- bulk :meth:`~pymongo.collection.Collection.insert` works with any - iterable -- fix :class:`~bson.objectid.ObjectId` generation when using - :mod:`multiprocessing` -- added :attr:`~pymongo.cursor.Cursor.collection` -- added ``network_timeout`` parameter for - :meth:`~pymongo.connection.Connection` -- DEPRECATED ``slave_okay`` parameter for individual queries -- fix for ``safe`` mode when multi-threaded -- added ``safe`` parameter for :meth:`~pymongo.collection.Collection.remove` -- added ``tailable`` parameter for :meth:`~pymongo.collection.Collection.find` - -Changes in Version 1.0 (2009/09/30) ------------------------------------ -- fixes for - :class:`~pymongo.master_slave_connection.MasterSlaveConnection` -- added ``finalize`` parameter for :meth:`~pymongo.collection.Collection.group` -- improvements to :meth:`~pymongo.collection.Collection.insert` speed -- improvements to :mod:`gridfs` speed -- added :meth:`~pymongo.cursor.Cursor.__getitem__` and - :meth:`~pymongo.cursor.Cursor.__len__` for - :class:`~pymongo.cursor.Cursor` instances - -Changes in Version 0.16 (2009/09/16) ------------------------------------- -- support for encoding/decoding :class:`uuid.UUID` instances -- fix for :meth:`~pymongo.cursor.Cursor.explain` with limits - -Changes in Version 0.15.2 (2009/09/09) --------------------------------------- -- documentation changes only - -Changes in Version 0.15.1 (2009/09/02) --------------------------------------- -- various performance improvements -- API CHANGE no longer need to specify direction for - :meth:`~pymongo.collection.Collection.create_index` and - :meth:`~pymongo.collection.Collection.ensure_index` when indexing a - single key -- support for encoding :class:`tuple` instances as :class:`list` - instances - -Changes in Version 0.15 (2009/08/26) ------------------------------------- -- fix string representation of :class:`~bson.objectid.ObjectId` - instances -- added ``timeout`` parameter for - :meth:`~pymongo.collection.Collection.find` -- allow scope for ``reduce`` function in - :meth:`~pymongo.collection.Collection.group` - -Changes in Version 0.14.2 (2009/08/24) --------------------------------------- -- minor bugfixes - -Changes in Version 0.14.1 (2009/08/21) --------------------------------------- -- :meth:`~gridfs.grid_file.GridFile.seek` and - :meth:`~gridfs.grid_file.GridFile.tell` for (read mode) - :class:`~gridfs.grid_file.GridFile` instances - -Changes in Version 0.14 (2009/08/19) ------------------------------------- -- support for long in :class:`~bson.BSON` -- added :meth:`~pymongo.collection.Collection.rename` -- added ``snapshot`` parameter for - :meth:`~pymongo.collection.Collection.find` - -Changes in Version 0.13 (2009/07/29) ------------------------------------- -- better - :class:`~pymongo.master_slave_connection.MasterSlaveConnection` - support -- API CHANGE :meth:`~pymongo.collection.Collection.insert` and - :meth:`~pymongo.collection.Collection.save` both return inserted - ``_id`` -- DEPRECATED passing an index name to - :meth:`~pymongo.cursor.Cursor.hint` - -Changes in Version 0.12 (2009/07/08) ------------------------------------- -- improved :class:`~bson.objectid.ObjectId` generation -- added :class:`~pymongo.errors.AutoReconnect` exception for when - reconnection is possible -- make :mod:`gridfs` thread-safe -- fix for :mod:`gridfs` with non :class:`~bson.objectid.ObjectId` ``_id`` - -Changes in Version 0.11.3 (2009/06/18) --------------------------------------- -- don't allow NULL bytes in string encoder -- fixes for Python 2.3 - -Changes in Version 0.11.2 (2009/06/08) --------------------------------------- -- PEP 8 -- updates for :meth:`~pymongo.collection.Collection.group` -- VS build - -Changes in Version 0.11.1 (2009/06/04) --------------------------------------- -- fix for connection pooling under Python 2.5 - -Changes in Version 0.11 (2009/06/03) ------------------------------------- -- better build failure detection -- driver support for selecting fields in sub-documents -- disallow insertion of invalid key names -- added ``timeout`` parameter for :meth:`~pymongo.connection.Connection` - -Changes in Version 0.10.3 (2009/05/27) --------------------------------------- -- fix bug with large :meth:`~pymongo.cursor.Cursor.limit` -- better exception when modules get reloaded out from underneath the C - extension -- better exception messages when calling a - :class:`~pymongo.collection.Collection` or - :class:`~pymongo.database.Database` instance - -Changes in Version 0.10.2 (2009/05/22) --------------------------------------- -- support subclasses of :class:`dict` in C encoder - -Changes in Version 0.10.1 (2009/05/18) --------------------------------------- -- alias :class:`~pymongo.connection.Connection` as - :attr:`pymongo.Connection` -- raise an exception rather than silently overflowing in encoder - -Changes in Version 0.10 (2009/05/14) ------------------------------------- -- added :meth:`~pymongo.collection.Collection.ensure_index` - -Changes in Version 0.9.7 (2009/05/13) -------------------------------------- -- allow sub-collections of *$cmd* as valid - :class:`~pymongo.collection.Collection` names -- add version as :attr:`pymongo.version` -- add ``--no_ext`` command line option to *setup.py* diff --git a/doc/conf.py b/doc/conf.py deleted file mode 100644 index ee16cc65ef..0000000000 --- a/doc/conf.py +++ /dev/null @@ -1,222 +0,0 @@ -# -# PyMongo documentation build configuration file -# -# This file is execfile()d with the current directory set to its containing dir. -from __future__ import annotations - -import os -import sys -from pathlib import Path - -sys.path[0:0] = [Path("..").resolve()] - -import pymongo # noqa: E402 - -# -- General configuration ----------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.doctest", - "sphinx.ext.coverage", - "sphinx.ext.todo", - "sphinx.ext.intersphinx", -] - - -# Add optional extensions -try: - import sphinxcontrib.shellcheck # noqa: F401 - - extensions += ["sphinxcontrib.shellcheck"] -except ImportError: - pass - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# The suffix of source filenames. -source_suffix = ".rst" - -# The master toctree document. -master_doc = "index" - -# General information about the project. -project = "PyMongo" -copyright = "MongoDB, Inc. 2008-present. MongoDB, Mongo, and the leaf logo are registered trademarks of MongoDB, Inc" -html_show_sphinx = False - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = pymongo.version -# The full version, including alpha/beta/rc tags. -release = pymongo.version - -# List of documents that shouldn't be included in the build. -unused_docs = [] - -# List of directories, relative to source directory, that shouldn't be searched -# for source files. -exclude_trees = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all documents. -# default_role = None - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -add_module_names = True - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# Options for link checking -# The anchors on the rendered markdown page are created after the fact, -# so those link results in a 404. -# wiki.centos.org has been flaky. -# sourceforge.net is giving a 403 error, but is still accessible from the browser. -# Links to release notes in jira give 401 error: unauthorized. PYTHON-5585 -linkcheck_ignore = [ - r"https://wiki.centos.org/[\w/]*", - r"https://sourceforge.net/", - r"https://jira\.mongodb\.org/secure/ReleaseNote\.jspa.*", -] - -# Allow for flaky links. -linkcheck_retries = 3 -# Serialize requests to dochub.mongodb.org to avoid rate-limiting (PYTHON-5847). -linkcheck_workers = 1 -# Give slow redirects more time before retrying. -linkcheck_timeout = 60 -# Ignore anchors in links -linkcheck_anchors = False - -# Pass GitHub token to avoid rate-limiting on GitHub links. -if github_token := os.environ.get("GITHUB_TOKEN"): - linkcheck_request_headers = { - "https://github.com/": {"Authorization": f"token {github_token}"}, - "https://api.github.com/": {"Authorization": f"token {github_token}"}, - } - - -# -- Options for extensions ---------------------------------------------------- -autoclass_content = "init" - -autodoc_typehints = "description" - -doctest_path = [Path("..").resolve()] - -doctest_test_doctest_blocks = "" - -doctest_global_setup = """ -from pymongo.mongo_client import MongoClient -client = MongoClient() -client.drop_database("doctest_test") -db = client.doctest_test -server_major_version = int(client.server_info()['version'].split()[-1][0]) -""" - -# -- Options for HTML output --------------------------------------------------- - -try: - import furo # noqa: F401 - - html_theme = "furo" -except ImportError: - # Theme gratefully vendored from CPython source. - html_theme = "pydoctheme" - html_theme_path = ["."] - html_theme_options = {"collapsiblesidebar": True, "googletag": False} - - # Additional static files. - html_static_path = ["static"] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -# html_static_path = ['_static'] - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = '' - -# Output file base name for HTML help builder. -htmlhelp_basename = "PyMongo" + release.replace(".", "_") - - -# -- Options for LaTeX output -------------------------------------------------- - -# The paper size ('letter' or 'a4'). -# latex_paper_size = 'letter' - -# The font size ('10pt', '11pt' or '12pt'). -# latex_font_size = '10pt' - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ("index", "PyMongo.tex", "PyMongo Documentation", "Michael Dirolf", "manual"), -] - -# The name of an image file (relative to this directory) to place at the top -# of the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# Additional stuff for the LaTeX preamble. -# latex_preamble = '' - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_use_modindex = True - - -intersphinx_mapping = { - "gevent": ("https://www.gevent.org/", None), - "py": ("https://docs.python.org/3/", None), -} diff --git a/doc/contributors.rst b/doc/contributors.rst deleted file mode 100644 index 4caa90eebe..0000000000 --- a/doc/contributors.rst +++ /dev/null @@ -1,113 +0,0 @@ -Contributors -============ -The following is a list of people who have contributed to -**PyMongo**. If you belong here and are missing please let us know -(or send a pull request after adding yourself to the list): - -- Mike Dirolf (mdirolf) -- Jeff Jenkins (jeffjenkins) -- Jim Jones -- Eliot Horowitz (erh) -- Michael Stephens (mikejs) -- Joakim Sernbrant (serbaut) -- Alexander Artemenko (svetlyak40wt) -- Mathias Stearn (RedBeard0531) -- Fajran Iman Rusadi (fajran) -- Brad Clements (bkc) -- Andrey Fedorov (andreyf) -- Joshua Roesslein (joshthecoder) -- Gregg Lind (gregglind) -- Michael Schurter (schmichael) -- Daniel Lundin -- Michael Richardson (mtrichardson) -- Dan McKinley (mcfunley) -- David Wolever (wolever) -- Carlos Valiente (carletes) -- Jehiah Czebotar (jehiah) -- Drew Perttula (drewp) -- Carl Baatz (c-w-b) -- Johan Bergstrom (jbergstroem) -- Jonas Haag (jonashaag) -- Kristina Chodorow (kchodorow) -- Andrew Sibley (sibsibsib) -- Flavio Percoco Premoli (FlaPer87) -- Ken Kurzweil (kurzweil) -- Christian Wyglendowski (dowski) -- James Murty (jmurty) -- Brendan W. McAdams (bwmcadams) -- Bernie Hackett (behackett) -- Reed O'Brien (reedobrien) -- Francisco Souza (fsouza) -- Alexey I. Froloff (raorn) -- Steve Lacy (slacy) -- Richard Shea (shearic) -- Vladimir Sidorenko (gearheart) -- Aaron Westendorf (awestendorf) -- Dan Crosta (dcrosta) -- Ryan Smith-Roberts (rmsr) -- David Pisoni (gefilte) -- Abhay Vardhan (abhayv) -- Alexey Borzenkov (snaury) -- Kostya Rybnikov (k-bx) -- A Jesse Jiryu Davis (ajdavis) -- Samuel Clay (samuelclay) -- Ross Lawley (rozza) -- Wouter Bolsterlee (wbolster) -- Alex Grönholm (agronholm) -- Christoph Simon (kalanzun) -- Chris Tompkinson (tompko) -- Mike O'Brien (mpobrien) -- T Dampier (dampier) -- Michael Henson (hensom) -- Craig Hobbs (craigahobbs) -- Emily Stolfo (estolfo) -- Sam Helman (shelman) -- Justin Patrin (reversefold) -- Xiuming Chen (cxmcc) -- Tyler Jones (thomascirca) -- Amalia Hawkins (hawka) -- Yuchen Ying (yegle) -- Kyle Erf (3rf) -- Luke Lovett (lovett89) -- Jaroslav Semančík (girogiro) -- Don Mitchell (dmitchell) -- Ximing (armnotstrong) -- Can Zhang (cannium) -- Sergey Azovskov (last-g) -- Heewa Barfchin (heewa) -- Anna Herlihy (aherlihy) -- Len Buckens (buckensl) -- ultrabug -- Shane Harvey (ShaneHarvey) -- Cao Siyang (caosiyang) -- Zhecong Kwok (gzcf) -- TaoBeier(tao12345666333) -- Jagrut Trivedi(Jagrut) -- Shrey Batra(shreybatra) -- Felipe Rodrigues(fbidu) -- Terence Honles (terencehonles) -- Paul Fisher (thetorpedodog) -- Julius Park (juliusgeo) -- Khanh Nguyen (KN99HN) -- Henri Froese (henrifroese) -- Ishmum Jawad Khan (ishmum123) -- Arie Bovenberg (ariebovenberg) -- Ben Warner (bcwarner) -- Jean-Christophe Fillion-Robin (jcfr) -- Sean Cheah (thalassemia) -- Dainis Gorbunovs (DainisGorbunovs) -- Iris Ho (sleepyStick) -- Stephan Hof (stephan-hof) -- Casey Clements (caseyclements) -- Ivan Lukyanchikov (ilukyanchikov) -- Terry Patterson -- Romain Morotti -- Navjot Singh (navjots18) -- Jib Adegunloye (Jibola) -- Jeffrey A. Clark (aclark4life) -- Steven Silvester (blink1073) -- Noah Stapp (NoahStapp) -- Cal Jacobson (cj81499) -- Sophia Yang (sophiayangDB) -- Madan Kumar (winklemad) -- Junyao Dong (carsontung666) diff --git a/doc/index.rst b/doc/index.rst deleted file mode 100644 index 385cd6ec16..0000000000 --- a/doc/index.rst +++ /dev/null @@ -1,71 +0,0 @@ -PyMongo |release| Documentation -=============================== - -.. note:: The PyMongo documentation has been migrated to the - `MongoDB Documentation site `_. - This site contains only the detailed changelog and API docs, while the - rest of the documentation appears on the MongoDB Documentation site. - -Overview --------- -**PyMongo** is a Python distribution containing tools for working with -`MongoDB `_, and is the recommended way to -work with MongoDB from Python. - -:doc:`api/index` - The complete API documentation, organized by module. - -:doc:`changelog` - A full list of changes to PyMongo. - - -Getting Help ------------- -If you're having trouble or have questions about PyMongo, ask your question on -one of the platforms listed on `Technical Support `_. -You may also want to consider a -`commercial support subscription `_. -Once you get an answer, it'd be great if you could work it back into this -documentation and contribute! - -Issues ------- -All issues should be reported (and can be tracked / voted for / -commented on) at the main `MongoDB JIRA bug tracker -`_, in the "Python Driver" -project. - -Feature Requests / Feedback ---------------------------- -Use our `feedback engine `_ -to send us feature requests and general feedback about PyMongo. - -Contributing ------------- -**PyMongo** has a large :doc:`community ` and -contributions are always encouraged. Contributions can be as simple as -minor tweaks to this documentation. To contribute, fork the project on -`GitHub `_ and send a -pull request. - -About This Documentation ------------------------- -This documentation is generated using the `Sphinx -`_ documentation generator. The source files -for the documentation are located in the *doc/* directory of the -**PyMongo** distribution. See the PyMongo `contributing guide `_ -for instructions on building the docs from source. - -Indices and tables ------------------- - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - -.. toctree:: - :hidden: - - api/index - changelog - contributors diff --git a/doc/make.bat b/doc/make.bat deleted file mode 100644 index aa1adb91a6..0000000000 --- a/doc/make.bat +++ /dev/null @@ -1,35 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=. -set BUILDDIR=_build - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.https://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd diff --git a/doc/migrate-to-pymongo4.rst b/doc/migrate-to-pymongo4.rst deleted file mode 100644 index fda3e2e129..0000000000 --- a/doc/migrate-to-pymongo4.rst +++ /dev/null @@ -1,995 +0,0 @@ -:orphan: - -.. _pymongo4-migration-guide: - -PyMongo 4 Migration Guide -========================= - -.. testsetup:: - - from pymongo import MongoClient, ReadPreference - - client = MongoClient() - database = client.my_database - collection = database.my_collection - -PyMongo 4.0 brings a number of improvements as well as some backward breaking -changes. This guide provides a roadmap for migrating an existing application -from PyMongo 3.x to 4.x or writing libraries that will work with both -PyMongo 3.x and 4.x. - -PyMongo 3 ---------- - -The first step in any successful migration involves upgrading to, or -requiring, at least that latest version of PyMongo 3.x. If your project has a -requirements.txt file, add the line "pymongo >= 3.12, < 4.0" until you have -completely migrated to PyMongo 4. Most of the key new methods and options from -PyMongo 4.0 are backported in PyMongo 3.12 making migration much easier. - -.. note:: Users of PyMongo 2.X who wish to upgrade to 4.x must first upgrade - to PyMongo 3.x by following the `PyMongo 3 Migration Guide - `_. - -Python 3.6+ ------------ - -PyMongo 4.0 drops support for Python 2.7, 3.4, and 3.5. Users who wish to -upgrade to 4.x must first upgrade to Python 3.6.2+. Users upgrading from -Python 2 should consult `Python 3 `_. - -Enable Deprecation Warnings ---------------------------- - -:exc:`DeprecationWarning` is raised by most methods removed in PyMongo 4.0. -Make sure you enable runtime warnings to see where deprecated functions and -methods are being used in your application:: - - python -Wd - -Warnings can also be changed to errors:: - - python -Wd -Werror - -.. note:: Not all deprecated features raise :exc:`DeprecationWarning` when - used. See `Removed features with no migration path`_. - -MongoReplicaSetClient ---------------------- - -Removed :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`. -Since PyMongo 3.0, ``MongoReplicaSetClient`` has been identical to -:class:`pymongo.mongo_client.MongoClient`. Applications can simply replace -``MongoReplicaSetClient`` with :class:`pymongo.mongo_client.MongoClient` and -get the same behavior. - -MongoClient ------------ - -.. _pymongo4-migration-direct-connection: - -``directConnection`` defaults to False -...................................... - -``directConnection`` URI option and keyword argument to :class:`~pymongo -.mongo_client.MongoClient` defaults to ``False`` instead of ``None``, -allowing for the automatic discovery of replica sets. This means that if you -want a direct connection to a single server you must pass -``directConnection=True`` as a URI option or keyword argument. - -If you see any :exc:`~pymongo.errors.ServerSelectionTimeoutError`'s after upgrading from PyMongo 3 to 4.x, you likely -need to add ``directConnection=True`` when creating the client. -Here are some example errors: - -.. code-block:: - - pymongo.errors.ServerSelectionTimeoutError: mongo_node2: [Errno 8] nodename nor servname - provided, or not known,mongo_node1:27017 - -.. code-block:: - - ServerSelectionTimeoutError: No servers match selector "Primary()", Timeout: 30s, - Topology Description: ... - - -Additionally, the "isWritablePrimary" attribute of a hello command sent back by the server will -always be True if ``directConnection=False``:: - - >>> client.admin.command('hello')['isWritablePrimary'] - True - - -The waitQueueMultiple parameter is removed -.......................................... - -Removed the ``waitQueueMultiple`` keyword argument to -:class:`~pymongo.mongo_client.MongoClient` and removed -:exc:`pymongo.errors.ExceededMaxWaiters`. Instead of using -``waitQueueMultiple`` to bound queuing, limit the size of the thread -pool in your application. - -The socketKeepAlive parameter is removed -.......................................... - -Removed the ``socketKeepAlive`` keyword argument to -:class:`~pymongo.mongo_client.MongoClient`. PyMongo now always enables TCP -keepalive. For more information see the `documentation `_. - -Renamed URI options -................... - -Several deprecated URI options have been renamed to the standardized -option names defined in the -`URI options specification `_. -The old option names and their renamed equivalents are summarized in the table -below. Some renamed options have different semantics from the option being -replaced as noted in the 'Migration Notes' column. - -+--------------------+-------------------------------+--------------------------------------------------------+ -| Old URI Option | Renamed URI Option | Migration Notes | -+====================+===============================+========================================================+ -| ssl_pem_passphrase | tlsCertificateKeyFilePassword | - | -+--------------------+-------------------------------+--------------------------------------------------------+ -| ssl_ca_certs | tlsCAFile | - | -+--------------------+-------------------------------+--------------------------------------------------------+ -| ssl_crlfile | tlsCRLFile | - | -+--------------------+-------------------------------+--------------------------------------------------------+ -| ssl_match_hostname | tlsAllowInvalidHostnames | ``ssl_match_hostname=True`` is equivalent to | -| | | ``tlsAllowInvalidHostnames=False`` and vice-versa. | -+--------------------+-------------------------------+--------------------------------------------------------+ -| ssl_cert_reqs | tlsAllowInvalidCertificates | Instead of ``ssl.CERT_NONE``, ``ssl.CERT_OPTIONAL`` | -| | | and ``ssl.CERT_REQUIRED``, the new option expects | -| | | a boolean value - ``True`` is equivalent to | -| | | ``ssl.CERT_NONE``, while ``False`` is equivalent to | -| | | ``ssl.CERT_REQUIRED``. | -+--------------------+-------------------------------+--------------------------------------------------------+ -| ssl_certfile | tlsCertificateKeyFile | Instead of using ``ssl_certfile`` and ``ssl_keyfile`` | -| | | to specify the certificate and private key files | -+--------------------+ | respectively, use ``tlsCertificateKeyFile`` to pass | -| ssl_keyfile | | a single file containing both the client certificate | -| | | and the private key. | -+--------------------+-------------------------------+--------------------------------------------------------+ -| j | journal | - | -+--------------------+-------------------------------+--------------------------------------------------------+ -| wtimeout | wTimeoutMS | - | -+--------------------+-------------------------------+--------------------------------------------------------+ - -MongoClient.fsync is removed -............................ - -Removed :meth:`pymongo.mongo_client.MongoClient.fsync`. Run the -`fsync command`_ directly with :meth:`~pymongo.database.Database.command` -instead. For example:: - - client.admin.command('fsync', lock=True) - -.. _fsync command: https://mongodb.com/docs/manual/reference/command/fsync/ - -MongoClient.unlock is removed -............................. - -Removed :meth:`pymongo.mongo_client.MongoClient.unlock`. Run the -`fsyncUnlock command`_ directly with -:meth:`~pymongo.database.Database.command` instead. For example:: - - client.admin.command('fsyncUnlock') - -.. _fsyncUnlock command: https://mongodb.com/docs/manual/reference/command/fsyncUnlock/ - -MongoClient.is_locked is removed -................................ - -Removed :attr:`pymongo.mongo_client.MongoClient.is_locked`. Run the -`currentOp command`_ directly with -:meth:`~pymongo.database.Database.command` instead. For example:: - - is_locked = client.admin.command('currentOp').get('fsyncLock') - -.. _currentOp command: https://mongodb.com/docs/manual/reference/command/currentOp/ - -MongoClient.database_names is removed -..................................... - -Removed :meth:`pymongo.mongo_client.MongoClient.database_names`. Use -:meth:`~pymongo.mongo_client.MongoClient.list_database_names` instead. Code like -this:: - - names = client.database_names() - -can be changed to this:: - - names = client.list_database_names() - -MongoClient.max_bson_size/max_message_size/max_write_batch_size are removed -........................................................................... - -Removed :attr:`pymongo.mongo_client.MongoClient.max_bson_size`, -:attr:`pymongo.mongo_client.MongoClient.max_message_size`, and -:attr:`pymongo.mongo_client.MongoClient.max_write_batch_size`. These helpers -were incorrect when in ``loadBalanced=true mode`` and ambiguous in clusters -with mixed versions. Use the `hello command`_ to get the authoritative -value from the remote server instead. Code like this:: - - max_bson_size = client.max_bson_size - max_message_size = client.max_message_size - max_write_batch_size = client.max_write_batch_size - -can be changed to this:: - - doc = client.admin.command('hello') - max_bson_size = doc['maxBsonObjectSize'] - max_message_size = doc['maxMessageSizeBytes'] - max_write_batch_size = doc['maxWriteBatchSize'] - -.. _hello command: https://mongodb.com/docs/manual/reference/command/hello/ - -MongoClient.event_listeners and other configuration option helpers are removed -.............................................................................. - -The following client configuration option helpers are removed: -- :attr:`pymongo.mongo_client.MongoClient.event_listeners`. -- :attr:`pymongo.mongo_client.MongoClient.max_pool_size`. -- :attr:`pymongo.mongo_client.MongoClient.max_idle_time_ms`. -- :attr:`pymongo.mongo_client.MongoClient.local_threshold_ms`. -- :attr:`pymongo.mongo_client.MongoClient.server_selection_timeout`. -- :attr:`pymongo.mongo_client.MongoClient.retry_writes`. -- :attr:`pymongo.mongo_client.MongoClient.retry_reads`. - -These helpers have been replaced by -:attr:`pymongo.mongo_client.MongoClient.options`. Code like this:: - - client.event_listeners - client.local_threshold_ms - client.server_selection_timeout - client.max_pool_size - client.min_pool_size - client.max_idle_time_ms - -can be changed to this:: - - client.options.event_listeners - client.options.local_threshold_ms - client.options.server_selection_timeout - client.options.pool_options.max_pool_size - client.options.pool_options.min_pool_size - client.options.pool_options.max_idle_time_seconds - -.. _tz_aware_default_change: - -``tz_aware`` defaults to ``False`` -.................................. - -The ``tz_aware`` argument to :class:`~bson.json_util.JSONOptions` -now defaults to ``False`` instead of ``True``. :meth:`bson.json_util.loads` -now decodes datetime as naive by default:: - - >>> from bson import json_util - >>> s = '{"dt": {"$date": "2022-05-09T17:54:00Z"}}' - >>> json_util.loads(s) - {'dt': datetime.datetime(2022, 5, 9, 17, 54)} - -To retain the PyMongo 3 behavior set ``tz_aware=True``, for example:: - - >>> from bson import json_util - >>> opts = json_util.JSONOptions(tz_aware=True) - >>> s = '{"dt": {"$date": "2022-05-09T17:54:00Z"}}' - >>> json_util.loads(s, json_options=opts) - {'dt': datetime.datetime(2022, 5, 9, 17, 54, tzinfo=)} - -This change was made to match the default behavior of -:class:`~bson.codec_options.CodecOptions` and :class:`bson.decode`. - -MongoClient cannot execute operations after ``close()`` -....................................................... - -:class:`~pymongo.mongo_client.MongoClient` cannot execute any operations -after being closed. The previous behavior would simply reconnect. However, -now you must create a new instance. - -MongoClient raises exception when given more than one URI -......................................................... - -:class:`~pymongo.mongo_client.MongoClient` now raises a :exc:`~pymongo.errors.ConfigurationError` -when more than one URI is passed into the ``hosts`` argument. - -MongoClient raises exception when given unescaped percent sign in login info -............................................................................ - -:class:`~pymongo.mongo_client.MongoClient` now raises an -:exc:`~pymongo.errors.InvalidURI` exception -when it encounters unescaped percent signs in username and password. - -Database --------- - -Database.authenticate and Database.logout are removed -..................................................... - -Removed :meth:`pymongo.database.Database.authenticate` and -:meth:`pymongo.database.Database.logout`. Authenticating multiple users -on the same client conflicts with support for logical sessions in MongoDB 3.6+. -To authenticate as multiple users, create multiple instances of -:class:`~pymongo.mongo_client.MongoClient`. Code like this:: - - client = MongoClient() - client.admin.authenticate('user1', 'pass1') - client.admin.authenticate('user2', 'pass2') - -can be changed to this:: - - client1 = MongoClient(username='user1', password='pass1') - client2 = MongoClient(username='user2', password='pass2') - -Alternatively, create a single user that contains all the authentication privileges -required by your application. - -Database.collection_names is removed -.................................... - -Removed :meth:`pymongo.database.Database.collection_names`. Use -:meth:`~pymongo.database.Database.list_collection_names` instead. Code like -this:: - - names = client.db.collection_names() - non_system_names = client.db.collection_names(include_system_collections=False) - -can be changed to this:: - - names = client.db.list_collection_names() - non_system_names = client.db.list_collection_names(filter={"name": {"$regex": "^(?!system\\.)"}}) - -Database.current_op is removed -.............................. - -Removed :meth:`pymongo.database.Database.current_op`. Use -:meth:`~pymongo.database.Database.aggregate` instead with the -`$currentOp aggregation pipeline stage`_. Code like -this:: - - ops = client.admin.current_op()['inprog'] - -can be changed to this:: - - ops = list(client.admin.aggregate([{'$currentOp': {}}])) - -.. _$currentOp aggregation pipeline stage: https://mongodb.com/docs/manual/reference/operator/aggregation/currentOp/ - -Database.add_user is removed -............................ - -Removed :meth:`pymongo.database.Database.add_user` which was deprecated in -PyMongo 3.6. Use the `createUser command`_ or `updateUser command`_ instead. -To create a user:: - - db.command("createUser", "admin", pwd="password", roles=["dbAdmin"]) - -To create a read-only user:: - - db.command("createUser", "user", pwd="password", roles=["read"]) - -To change a password:: - - db.command("updateUser", "user", pwd="newpassword") - -Or change roles:: - - db.command("updateUser", "user", roles=["readWrite"]) - -.. _createUser command: https://mongodb.com/docs/manual/reference/command/createUser/ -.. _updateUser command: https://mongodb.com/docs/manual/reference/command/updateUser/ - -Database.remove_user is removed -............................... - -Removed :meth:`pymongo.database.Database.remove_user` which was deprecated in -PyMongo 3.6. Use the `dropUser command`_ instead:: - - db.command("dropUser", "user") - -.. _dropUser command: https://mongodb.com/docs/manual/reference/command/createUser/ - -Database.profiling_level is removed -................................... - -Removed :meth:`pymongo.database.Database.profiling_level` which was deprecated in -PyMongo 3.12. Use the `profile command`_ instead. Code like this:: - - level = db.profiling_level() - -Can be changed to this:: - - profile = db.command('profile', -1) - level = profile['was'] - -.. _profile command: https://mongodb.com/docs/manual/reference/command/profile/ - -Database.set_profiling_level is removed -....................................... - -Removed :meth:`pymongo.database.Database.set_profiling_level` which was deprecated in -PyMongo 3.12. Use the `profile command`_ instead. Code like this:: - - db.set_profiling_level(pymongo.ALL, filter={'op': 'query'}) - -Can be changed to this:: - - res = db.command('profile', 2, filter={'op': 'query'}) - -Database.profiling_info is removed -.................................. - -Removed :meth:`pymongo.database.Database.profiling_info` which was deprecated in -PyMongo 3.12. Query the `'system.profile' collection`_ instead. Code like this:: - - profiling_info = db.profiling_info() - -Can be changed to this:: - - profiling_info = list(db['system.profile'].find()) - -.. _'system.profile' collection: https://mongodb.com/docs/manual/reference/database-profiler/ - -Database.__bool__ raises NotImplementedError -............................................ -:class:`~pymongo.database.Database` now raises an error upon evaluating as a -Boolean. Code like this:: - - if database: - -Can be changed to this:: - - if database is not None: - -You must now explicitly compare with None. - -Collection ----------- - -The useCursor option for Collection.aggregate is removed -........................................................ - -Removed the ``useCursor`` option for -:meth:`~pymongo.collection.Collection.aggregate` which was deprecated in -PyMongo 3.6. The option was only necessary when upgrading from MongoDB 2.4 -to MongoDB 2.6. - -Collection.insert is removed -............................ - -Removed :meth:`pymongo.collection.Collection.insert`. Use -:meth:`~pymongo.collection.Collection.insert_one` or -:meth:`~pymongo.collection.Collection.insert_many` instead. - -Code like this:: - - collection.insert({'doc': 1}) - collection.insert([{'doc': 2}, {'doc': 3}]) - -Can be changed to this:: - - collection.insert_one({'my': 'document'}) - collection.insert_many([{'doc': 2}, {'doc': 3}]) - -Collection.save is removed -.......................... - -Removed :meth:`pymongo.collection.Collection.save`. Applications will -get better performance using :meth:`~pymongo.collection.Collection.insert_one` -to insert a new document and :meth:`~pymongo.collection.Collection.update_one` -to update an existing document. Code like this:: - - doc = collection.find_one({"_id": "some id"}) - doc["some field"] = - db.collection.save(doc) - -Can be changed to this:: - - result = collection.update_one({"_id": "some id"}, {"$set": {"some field": }}) - -If performance is not a concern and refactoring is untenable, ``save`` can be -implemented like so:: - - def save(doc): - if '_id' in doc: - collection.replace_one({'_id': doc['_id']}, doc, upsert=True) - return doc['_id'] - else: - res = collection.insert_one(doc) - return res.inserted_id - -Collection.update is removed -............................ - -Removed :meth:`pymongo.collection.Collection.update`. Use -:meth:`~pymongo.collection.Collection.update_one` -to update a single document or -:meth:`~pymongo.collection.Collection.update_many` to update multiple -documents. Code like this:: - - collection.update({}, {'$set': {'a': 1}}) - collection.update({}, {'$set': {'b': 1}}, multi=True) - -Can be changed to this:: - - collection.update_one({}, {'$set': {'a': 1}}) - collection.update_many({}, {'$set': {'b': 1}}) - -Collection.remove is removed -............................ - -Removed :meth:`pymongo.collection.Collection.remove`. Use -:meth:`~pymongo.collection.Collection.delete_one` -to delete a single document or -:meth:`~pymongo.collection.Collection.delete_many` to delete multiple -documents. Code like this:: - - collection.remove({'a': 1}, multi=False) - collection.remove({'b': 1}) - -Can be changed to this:: - - collection.delete_one({'a': 1}) - collection.delete_many({'b': 1}) - -Collection.find_and_modify is removed -..................................... - -Removed :meth:`pymongo.collection.Collection.find_and_modify`. Use -:meth:`~pymongo.collection.Collection.find_one_and_update`, -:meth:`~pymongo.collection.Collection.find_one_and_replace`, or -:meth:`~pymongo.collection.Collection.find_one_and_delete` instead. -Code like this:: - - updated_doc = collection.find_and_modify({'a': 1}, {'$set': {'b': 1}}) - replaced_doc = collection.find_and_modify({'b': 1}, {'c': 1}) - deleted_doc = collection.find_and_modify({'c': 1}, remove=True) - -Can be changed to this:: - - updated_doc = collection.find_one_and_update({'a': 1}, {'$set': {'b': 1}}) - replaced_doc = collection.find_one_and_replace({'b': 1}, {'c': 1}) - deleted_doc = collection.find_one_and_delete({'c': 1}) - -Collection.count and Cursor.count is removed -............................................ - -Removed :meth:`pymongo.collection.Collection.count` and -:meth:`pymongo.cursor.Cursor.count`. Use -:meth:`~pymongo.collection.Collection.count_documents` or -:meth:`~pymongo.collection.Collection.estimated_document_count` instead. -Code like this:: - - ntotal = collection.count({}) - nmatched = collection.count({'price': {'$gte': 10}}) - # Or via the Cursor.count api: - ntotal = collection.find({}).count() - nmatched = collection.find({'price': {'$gte': 10}}).count() - -Can be changed to this:: - - ntotal = collection.estimated_document_count() - nmatched = collection.count_documents({'price': {'$gte': 10}}) - -.. note:: When migrating from :meth:`count` to :meth:`count_documents` - the following query operators must be replaced: - - +-------------+--------------------------------------------------------------+ - | Operator | Replacement | - +=============+==============================================================+ - | $where | `$expr`_ | - +-------------+--------------------------------------------------------------+ - | $near | `$geoWithin`_ with `$center`_; i.e. | - | | ``{'$geoWithin': {'$center': [[,], ]}}`` | - +-------------+--------------------------------------------------------------+ - | $nearSphere | `$geoWithin`_ with `$centerSphere`_; i.e. | - | | ``{'$geoWithin': {'$centerSphere': [[,], ]}}`` | - +-------------+--------------------------------------------------------------+ - -.. _$expr: https://mongodb.com/docs/manual/reference/operator/query/expr/ -.. _$geoWithin: https://mongodb.com/docs/manual/reference/operator/query/geoWithin/ -.. _$center: https://mongodb.com/docs/manual/reference/operator/query/center/ -.. _$centerSphere: https://mongodb.com/docs/manual/reference/operator/query/centerSphere/ - -Collection.initialize_ordered_bulk_op and initialize_unordered_bulk_op is removed -................................................................................. - -Removed :meth:`pymongo.collection.Collection.initialize_ordered_bulk_op` -and :class:`pymongo.bulk.BulkOperationBuilder`. Use -:meth:`pymongo.collection.Collection.bulk_write` instead. Code like this:: - - batch = coll.initialize_ordered_bulk_op() - batch.insert({'a': 1}) - batch.find({'a': 1}).update_one({'$set': {'b': 1}}) - batch.find({'a': 2}).upsert().replace_one({'b': 2}) - batch.find({'a': 3}).remove() - result = batch.execute() - -Can be changed to this:: - - coll.bulk_write([ - InsertOne({'a': 1}), - UpdateOne({'a': 1}, {'$set': {'b': 1}}), - ReplaceOne({'a': 2}, {'b': 2}, upsert=True), - DeleteOne({'a': 3}), - ]) - -Collection.initialize_unordered_bulk_op is removed -.................................................. - -Removed :meth:`pymongo.collection.Collection.initialize_unordered_bulk_op`. -Use :meth:`pymongo.collection.Collection.bulk_write` instead. Code like this:: - - batch = coll.initialize_unordered_bulk_op() - batch.insert({'a': 1}) - batch.find({'a': 1}).update_one({'$set': {'b': 1}}) - batch.find({'a': 2}).upsert().replace_one({'b': 2}) - batch.find({'a': 3}).remove() - result = batch.execute() - -Can be changed to this:: - - coll.bulk_write([ - InsertOne({'a': 1}), - UpdateOne({'a': 1}, {'$set': {'b': 1}}), - ReplaceOne({'a': 2}, {'b': 2}, upsert=True), - DeleteOne({'a': 3}), - ], ordered=False) - -Collection.group is removed -........................... - -Removed :meth:`pymongo.collection.Collection.group`. This method was -deprecated in PyMongo 3.5. MongoDB 4.2 removed the group command. -Use :meth:`~pymongo.collection.Collection.aggregate` with the ``$group`` stage -instead. - -Collection.map_reduce and Collection.inline_map_reduce are removed -.................................................................. - -Removed :meth:`pymongo.collection.Collection.map_reduce` and -:meth:`pymongo.collection.Collection.inline_map_reduce`. -Migrate to :meth:`~pymongo.collection.Collection.aggregate` or run the -`mapReduce command`_ directly with :meth:`~pymongo.database.Database.command` -instead. For more guidance on this migration see: - -- https://mongodb.com/docs/manual/reference/map-reduce-to-aggregation-pipeline/ -- https://mongodb.com/docs/manual/reference/aggregation-commands-comparison/ - -.. _mapReduce command: https://mongodb.com/docs/manual/reference/command/mapReduce/ - -Collection.ensure_index is removed -.................................. - -Removed :meth:`pymongo.collection.Collection.ensure_index`. Use -:meth:`~pymongo.collection.Collection.create_index` or -:meth:`~pymongo.collection.Collection.create_indexes` instead. Note that -``ensure_index`` maintained an in memory cache of recently created indexes -whereas the newer methods do not. Applications should avoid frequent calls -to :meth:`~pymongo.collection.Collection.create_index` or -:meth:`~pymongo.collection.Collection.create_indexes`. Code like this:: - - def persist(self, document): - collection.ensure_index('a', unique=True) - collection.insert_one(document) - -Can be changed to this:: - - def persist(self, document): - if not self.created_index: - collection.create_index('a', unique=True) - self.created_index = True - collection.insert_one(document) - -Collection.reindex is removed -............................. - -Removed :meth:`pymongo.collection.Collection.reindex`. Run the -`reIndex command`_ directly instead. Code like this:: - - >>> result = database.my_collection.reindex() - -can be changed to this:: - - >>> result = database.command('reIndex', 'my_collection') - -.. _reIndex command: https://mongodb.com/docs/manual/reference/command/reIndex/ - -The modifiers parameter is removed -.................................. - -Removed the ``modifiers`` parameter from -:meth:`~pymongo.collection.Collection.find`, -:meth:`~pymongo.collection.Collection.find_one`, -:meth:`~pymongo.collection.Collection.find_raw_batches`, and -:meth:`~pymongo.cursor.Cursor`. Pass the options directly to the method -instead. Code like this:: - - cursor = coll.find({}, modifiers={ - "$comment": "comment", - "$hint": {"_id": 1}, - "$min": {"_id": 0}, - "$max": {"_id": 6}, - "$maxTimeMS": 6000, - "$returnKey": False, - "$showDiskLoc": False, - }) - -can be changed to this:: - - cursor = coll.find( - {}, - comment="comment", - hint={"_id": 1}, - min={"_id": 0}, - max={"_id": 6}, - max_time_ms=6000, - return_key=False, - show_record_id=False, - ) - -The hint parameter is required with min/max -........................................... - -The ``hint`` option is now required when using ``min`` or ``max`` queries -with :meth:`~pymongo.collection.Collection.find` to ensure the query utilizes -the correct index. For example, code like this:: - - cursor = coll.find({}, min={'x', min_value}) - -can be changed to this:: - - cursor = coll.find({}, min={'x', min_value}, hint=[('x', ASCENDING)]) - -Collection.__bool__ raises NotImplementedError -.............................................. -:class:`~pymongo.collection.Collection` now raises an error upon evaluating -as a Boolean. Code like this:: - - if collection: - -Can be changed to this:: - - if collection is not None: - -You must now explicitly compare with None. - -Collection.find returns entire document with empty projection -............................................................. -Empty projections (eg {} or []) for -:meth:`~pymongo.collection.Collection.find`, and -:meth:`~pymongo.collection.Collection.find_one` -are passed to the server as-is rather than the previous behavior which -substituted in a projection of ``{"_id": 1}``. This means that an empty -projection will now return the entire document, not just the ``"_id"`` field. -To ensure that behavior remains consistent, code like this:: - - coll.find({}, projection={}) - -Can be changed to this:: - - coll.find({}, projection={"_id":1}) - -SONManipulator is removed -------------------------- - -Removed :mod:`pymongo.son_manipulator`, -:class:`pymongo.son_manipulator.SONManipulator`, -:class:`pymongo.son_manipulator.ObjectIdInjector`, -:class:`pymongo.son_manipulator.ObjectIdShuffler`, -:class:`pymongo.son_manipulator.AutoReference`, -:class:`pymongo.son_manipulator.NamespaceInjector`, -:meth:`pymongo.database.Database.add_son_manipulator`, -:attr:`pymongo.database.Database.outgoing_copying_manipulators`, -:attr:`pymongo.database.Database.outgoing_manipulators`, -:attr:`pymongo.database.Database.incoming_copying_manipulators`, and -:attr:`pymongo.database.Database.incoming_manipulators`. - -Removed the ``manipulate`` parameter from -:meth:`~pymongo.collection.Collection.find`, -:meth:`~pymongo.collection.Collection.find_one`, and -:meth:`~pymongo.cursor.Cursor`. - -The :class:`pymongo.son_manipulator.SONManipulator` API has limitations as a -technique for transforming your data and was deprecated in PyMongo 3.0. -Instead, it is more flexible and straightforward to transform outgoing -documents in your own code before passing them to PyMongo, and transform -incoming documents after receiving them from PyMongo. - -Alternatively, if your application uses the ``SONManipulator`` API to convert -custom types to BSON, the :class:`~bson.codec_options.TypeCodec` and -:class:`~bson.codec_options.TypeRegistry` APIs may be a suitable alternative. -For more information, see `Custom Types `_. - -``SON().items()`` now returns ``dict_items`` object. ----------------------------------------------------- -:meth:`~bson.son.SON.items` now returns a ``dict_items`` object rather than -a list. - -``SON().iteritems()`` removed. ------------------------------- -``SON.iteritems()`` now removed. Code that looks like this:: - - for k, v in son.iteritems(): - -Can now be replaced by code that looks like:: - - for k, v in son.items(): - -IsMaster is removed -------------------- - -Removed :class:`pymongo.ismaster.IsMaster`. -Use :class:`pymongo.hello.Hello` instead. - -NotMasterError is removed -------------------------- - -Removed :exc:`~pymongo.errors.NotMasterError`. -Use :exc:`~pymongo.errors.NotPrimaryError` instead. - -CertificateError is removed ---------------------------- - -Removed :exc:`~pymongo.errors.CertificateError`. Since PyMongo 3.0 this error -is handled internally and is never raised to the application. - -pymongo.GEOHAYSTACK is removed ------------------------------- - -Removed :attr:`pymongo.GEOHAYSTACK`. Replace with "geoHaystack" or create a -2d index and use $geoNear or $geoWithin instead. - -UUIDLegacy is removed ---------------------- - -Removed :class:`bson.binary.UUIDLegacy`. Use -:meth:`bson.binary.Binary.from_uuid` instead. Code like this:: - - uu = uuid.uuid4() - uuid_legacy = UUIDLegacy(uu) - -can be changed to this:: - - uu = uuid.uuid4() - uuid_legacy = Binary.from_uuid(uu, PYTHON_LEGACY) - -Default JSONMode changed from LEGACY to RELAXED ------------------------------------------------ - -Changed the default JSON encoding representation from legacy to relaxed. -The json_mode parameter for :const:`bson.json_util.dumps` now defaults to -:const:`~bson.json_util.RELAXED_JSON_OPTIONS`. - -GridFS changes --------------- - -.. _removed-gridfs-checksum: - -disable_md5 parameter is removed -................................ - -Removed the ``disable_md5`` option for :class:`~gridfs.GridFSBucket` and -:class:`~gridfs.GridFS`. GridFS no longer generates checksums. -Applications that desire a file digest should implement it outside GridFS -and store it with other file metadata. For example:: - - import hashlib - my_db = MongoClient().test - fs = GridFSBucket(my_db) - with fs.open_upload_stream("test_file") as grid_in: - file_data = b'...' - sha356 = hashlib.sha256(file_data).hexdigest() - grid_in.write(file_data) - grid_in.sha356 = sha356 # Set the custom 'sha356' field - -Note that for large files, the checksum may need to be computed in chunks -to avoid the excessive memory needed to load the entire file at once. - -Removed features with no migration path ---------------------------------------- - -cursor_manager support is removed -................................. - -Removed :class:`pymongo.cursor_manager.CursorManager`, -:mod:`pymongo.cursor_manager`, and -:meth:`pymongo.mongo_client.MongoClient.set_cursor_manager`. - -MongoClient.close_cursor is removed -................................... - -Removed :meth:`pymongo.mongo_client.MongoClient.close_cursor` and -:meth:`pymongo.mongo_client.MongoClient.kill_cursors`. Instead, close cursors -with :meth:`pymongo.cursor.Cursor.close` or -:meth:`pymongo.command_cursor.CommandCursor.close`. - -.. _killCursors command: https://mongodb.com/docs/manual/reference/command/killCursors/ - -Database.eval, Database.system_js, and SystemJS are removed -........................................................... - -Removed :meth:`~pymongo.database.Database.eval`, -:data:`~pymongo.database.Database.system_js` and -:class:`~pymongo.database.SystemJS`. The eval command was deprecated in -MongoDB 3.0 and removed in MongoDB 4.2. There is no replacement for eval with -MongoDB 4.2+. - -However, on MongoDB <= 4.0, code like this:: - - >>> result = database.eval('function (x) {return x;}', 3) - -can be changed to this:: - - >>> from bson.code import Code - >>> result = database.command('eval', Code('function (x) {return x;}'), args=[3]).get('retval') - -Database.error, Database.last_status, Database.previous_error, and Database.reset_error_history are removed -........................................................................................................... - -Removed :meth:`pymongo.database.Database.error`, -:meth:`pymongo.database.Database.last_status`, -:meth:`pymongo.database.Database.previous_error`, and -:meth:`pymongo.database.Database.reset_error_history`. -These methods are obsolete: all MongoDB write operations use an acknowledged -write concern and report their errors by default. These methods were -deprecated in PyMongo 2.8. - -Collection.parallel_scan is removed -................................... - -Removed :meth:`~pymongo.collection.Collection.parallel_scan`. MongoDB 4.2 -removed the parallelCollectionScan command. There is no replacement. - -pymongo.message helpers are removed -................................... - -Removed :meth:`pymongo.message.delete`, :meth:`pymongo.message.get_more`, -:meth:`pymongo.message.insert`, :meth:`pymongo.message.kill_cursors`, -:meth:`pymongo.message.query`, and :meth:`pymongo.message.update`. - - -Name is a required argument for pymongo.driver_info.DriverInfo -.............................................................. - -``name`` is now a required argument for the :class:`pymongo.driver_info.DriverInfo` class. - -DBRef BSON/JSON decoding behavior -................................. - -Changed the BSON and JSON decoding behavior of :class:`~bson.dbref.DBRef` -to match the behavior outlined in the `DBRef specification`_ version 1.0. -Specifically, PyMongo now only decodes a subdocument into a -:class:`~bson.dbref.DBRef` if and only if, it contains both ``$ref`` and -``$id`` fields and the ``$ref``, ``$id``, and ``$db`` fields are of the -correct type. Otherwise the document is returned as normal. Previously, any -subdocument containing a ``$ref`` field would be decoded as a -:class:`~bson.dbref.DBRef`. - -.. _DBRef specification: https://github.com/mongodb/specifications/blob/master/source/dbref/dbref.md - -Encoding a UUID raises an error by default -.......................................... - -The default ``uuid_representation`` for :class:`~bson.codec_options.CodecOptions`, -:class:`~bson.json_util.JSONOptions`, and -:class:`~pymongo.mongo_client.MongoClient` has been changed from -:data:`bson.binary.UuidRepresentation.PYTHON_LEGACY` to -:data:`bson.binary.UuidRepresentation.UNSPECIFIED`. Attempting to encode a -:class:`uuid.UUID` instance to BSON or JSON now produces an error by default. -If you were using UUIDs previously, you will need to set your ``uuid_representation`` to -:data:`bson.binary.UuidRepresentation.PYTHON_LEGACY` to avoid data corruption. If you do not have UUIDs, -then you should set :data:`bson.binary.UuidRepresentation.STANDARD`. If you do not explicitly set a value, -you will receive an error like this when attempting to encode a :class:`uuid.UUID`:: - - ValueError: cannot encode native uuid.UUID with UuidRepresentation.UNSPECIFIED. UUIDs can be manually converted... - -See `Handling UUIDs `_ for details. - -Additional BSON classes implement ``__slots__`` -............................................... - -:class:`~bson.int64.Int64`, :class:`~bson.min_key.MinKey`, -:class:`~bson.max_key.MaxKey`, :class:`~bson.timestamp.Timestamp`, -:class:`~bson.regex.Regex`, and :class:`~bson.dbref.DBRef` now implement -``__slots__`` to reduce memory usage. This means that their attributes are fixed, and new -attributes cannot be added to the object at runtime. diff --git a/doc/pydoctheme/static/pydoctheme.css b/doc/pydoctheme/static/pydoctheme.css deleted file mode 100644 index 50835bb92c..0000000000 --- a/doc/pydoctheme/static/pydoctheme.css +++ /dev/null @@ -1,178 +0,0 @@ -@import url("default.css"); - -body { - background-color: white; - margin-left: 1em; - margin-right: 1em; -} - -div.related { - margin-bottom: 1.2em; - padding: 0.5em 0; - border-top: 1px solid #ccc; - margin-top: 0.5em; -} - -div.related a:hover { - color: #0095C4; -} - -div.related:first-child { - border-top: 0; - border-bottom: 1px solid #ccc; -} - -div.sphinxsidebar { - background-color: #eeeeee; - border-radius: 5px; - line-height: 130%; - font-size: smaller; -} - -div.sphinxsidebar h3, div.sphinxsidebar h4 { - margin-top: 1.5em; -} - -div.sphinxsidebarwrapper > h3:first-child { - margin-top: 0.2em; -} - -div.sphinxsidebarwrapper > ul > li > ul > li { - margin-bottom: 0.4em; -} - -div.sphinxsidebar a:hover { - color: #0095C4; -} - -div.sphinxsidebar input { - font-family: 'Lucida Grande',Arial,sans-serif; - border: 1px solid #999999; - font-size: smaller; - border-radius: 3px; -} - -div.sphinxsidebar input[type=text] { - max-width: 150px; -} - -div.body { - padding: 0 0 0 1.2em; -} - -div.body p { - line-height: 140%; -} - -div.body h1, div.body h2, div.body h3, div.body h4, div.body h5, div.body h6 { - margin: 0; - border: 0; - padding: 0.3em 0; -} - -div.body hr { - border: 0; - background-color: #ccc; - height: 1px; -} - -div.body pre { - border-radius: 3px; - border: 1px solid #ac9; -} - -div.body div.admonition, div.body div.impl-detail { - border-radius: 3px; -} - -div.body div.impl-detail > p { - margin: 0; -} - -div.body div.seealso { - border: 1px solid #dddd66; -} - -div.body a { - color: #0072aa; -} - -div.body a:visited { - color: #6363bb; -} - -div.body a:hover { - color: #00B0E4; -} - -tt, code, pre { - font-family: monospace, sans-serif; - font-size: 96.5%; -} - -div.body tt, div.body code { - border-radius: 3px; -} - -div.body tt.descname, div.body code.descname { - font-size: 120%; -} - -div.body tt.xref, div.body a tt, div.body code.xref, div.body a code { - font-weight: normal; -} - -.deprecated { - border-radius: 3px; -} - -table.docutils { - border: 1px solid #ddd; - min-width: 20%; - border-radius: 3px; - margin-top: 10px; - margin-bottom: 10px; -} - -table.docutils td, table.docutils th { - border: 1px solid #ddd !important; - border-radius: 3px; -} - -table p, table li { - text-align: left !important; -} - -table.docutils th { - background-color: #eee; - padding: 0.3em 0.5em; -} - -table.docutils td { - background-color: white; - padding: 0.3em 0.5em; -} - -table.footnote, table.footnote td { - border: 0 !important; -} - -div.footer { - line-height: 150%; - margin-top: -2em; - text-align: right; - width: auto; - margin-right: 10px; -} - -div.footer a:hover { - color: #0095C4; -} - -.refcount { - color: #060; -} - -.stableabi { - color: #229; -} diff --git a/doc/pydoctheme/theme.conf b/doc/pydoctheme/theme.conf deleted file mode 100644 index 88bf38734d..0000000000 --- a/doc/pydoctheme/theme.conf +++ /dev/null @@ -1,24 +0,0 @@ -[theme] -inherit = default -stylesheet = pydoctheme.css -pygments_style = sphinx - -[options] -bodyfont = 'Lucida Grande', Arial, sans-serif -headfont = 'Lucida Grande', Arial, sans-serif -footerbgcolor = white -footertextcolor = #555555 -relbarbgcolor = white -relbartextcolor = #666666 -relbarlinkcolor = #444444 -sidebarbgcolor = white -sidebartextcolor = #444444 -sidebarlinkcolor = #444444 -bgcolor = white -textcolor = #222222 -linkcolor = #0090c0 -visitedlinkcolor = #00608f -headtextcolor = #1a1a1a -headbgcolor = white -headlinkcolor = #aaaaaa -googletag = False diff --git a/doc/static/periodic-executor-refs.dot b/doc/static/periodic-executor-refs.dot deleted file mode 100644 index 39632cfa73..0000000000 --- a/doc/static/periodic-executor-refs.dot +++ /dev/null @@ -1,17 +0,0 @@ -digraph "Monitor and PeriodicExecutor" { - // Strong references. - topology -> server - server -> monitor - monitor -> executor - executor -> "target()" - "target()" -> self_ref - thread -> "target()" - - // Weak references - edge [style="dashed"]; - - self_ref -> monitor [curved=true] - monitor -> topology - executor -> thread - _EXECUTORS -> executor -} diff --git a/doc/static/periodic-executor-refs.png b/doc/static/periodic-executor-refs.png deleted file mode 100644 index 3224b3d1d9f606ed9363d185933756c5b15c73d0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 39586 zcmXt=Wk6K@7p-9!aOk1CJEW122I=nZknS$&lJ0InI;6X#LnL27LPEMrM!1LjzxR_U z=$tdNe|xX}taXf0RhB_VAx43NgF}~-l~RX;gBOK^1NlRcfImr(%1{J;fp=Gzk$|h4 zAw7hH6N8hJ64&&BKgma2$JM$Yt&a`aAX|Cs#Q?&8S47R+TDh_jLskjFM{4~P5wo%J zmbql7IyCn2o_9aEcl4gE>&fAK>TK#npm0{GYj!x_KiKW5%TxByQibs&5Y=1Vw%#5$Omqef>&|h1ztY9?yT{KL_BqGiimw;K)x@b19H- z_T$$BL)(;Fs#$7m-!V z)Q+!Tawe1n_R<6jxu4ky^s6uKNY!^cAzbYiNl`R zTJ2g`4+n+8>kNefJHLWo0`CXjQ2b%o6n%cMxc_&*X=7@;+1n#YH7#(E=d_<~Goxn6 zJ;Pth+~)9M)O$%-E!vpq>T#4JxIG4kVV_YY?XYb#=(zXq5sUEVW}5%o#$jxy!}81} z$FJoX^RpOaf)5%ycLM8aChMKUM-~tmCOm6NDUvmP&PvjR#mec2k^+ zBk(75Et;p_8SE04u&RaX<}O@c&x+16TH;>wZ3dKjW_d2@ZP-=U?rWO_-cB7Dx=-Wz z{$p+rVd_H>YtldqiKOHRg8AI9SR{7Hko!ut&5ArtDTzGp+KCs7t!Nv0YPC&qO|~Ca z6!ubiR^8GAw_NIfkng?DQs2E}9Q0_lA)QEGi%);M>GM0@=wK#)Ba+1FPlI$WOZh5ly( z_kT(gt5Slmr})oT#?Mj*Ykl-ELIKf}OeEwB0Tlbk(;0H{sYYfHd6{&UI_QK;V4%%X8W2toP~cCzWt)pG+dTQ>KxZD;8#= z(j#wG>8VI>uQ2!qf)KZgR{hDw!rSPrtO!XQ!LY$kG7w59n9Jj5kJ$x z)|~qeCrt|j?_7;KJzQ&~qgcPdB#;(jxxsEw(~zC3Np^1nlYqvjv##@X`do*dyZ`Lj zmun69JXyvCR-e_tK`;Njy+_Hs+wJQ*z6;+jXgDQ*z;^}S^|H0V`;CnS4HYtc`7f|R ziTMdma1&Plt!4iw__KKhc2D3wGl5tCw=VvMtc;~;^T%kH-Jd+hX=lTMTXQh ze9e0^aO2xgWrM$iS29YE>7!#a9AIXdPupvBnT9(vLf48dCm13Rrr!PVZz}tY_R3eX zA0Yw%ZkNwW;@I56-e4}Jp8-`nbbI(yhCuOZw)P@eBM1*GJomqDwpssUuy-c-6>t1kY&%Pp76lY zw;Id1)TGg!{J=dcU0Q|V&U#}I20i~}$d}ma;eIn%C-6<&MI|v;S3fi>9In`E zqsx1l@l8!Knb(Thy!aD76G$rC&}-G|3@8xo;4uT|o)+SJ!e$utDH)58-K3%2B;fJ`pVK-&da?i0X&XyjxSGBeT6+FRh@u2s#kvyTh9+OyRwybP z|6x&}JtJt6y|0_Oe+1t^F@G4jqFPGvQ7beh-vVMub@A{!vD%%hI-YOCLxcJ-uPG-r zw!UF`J^1CH(}w4=r%{)e=Xvjw)2i2Mo{3)c30Tq;8>A{<+cd%K6!*5(h3}V-1#a@2 zR441rDrq=kHdZ%Ts_67ctuN78)e2aq4sBF(NbuUY*}pC74zq0vkh%XWn(lFsIfaPr zpgbv!CXkW24t*HL7m9_m=t2*92iYBm8nAKnKio*?gtu<^pZ6SP#cQF8+Y(y>KkQZC z_uSdrfC8n-+RKboZha?}*gws;c`}yj3baufH*RVI@_>s0*$FlsMm5Iwr{7XB4kz<- z%YFk*ty?f}s6<27p`{JV+&T*#lZ4B_dbpEUEIKe!d+eK{yE|H(9JpRqv|X+`-$6QS#=(!FN$$D5xj zEPZ5+HSMmJnA?OUgE%W~&L;P}sVbdOcmK&= zCs}3^efMsM15Vpr=!fh*9Vq^q?Q6-DfOfny4V*gU-b?h~sj zTccp*Jc(gHflC~?p4vrk{{UypnqqS#2PGUswE27(M`htU{8{c^OFv_7^i2vLn?{0e zd5C2+svA>&HtJE>5sKc#lH_st3!HOg>p)A^DgYWBSt>k5sMu; zyT2hzIPRX4Y+W^?(`4>boSm5XmSyuzT!^r9R8)?#VqjwNx?>DTqdQY6PC_#9P~V+M zUeuQw>rSnP?#ah0d_2Np)!^zh>yf7Go$cn$52VltTK%}tJT zij!}`GK?tOiwQ2*R5TU%GQ(KrH{o~QbAN;XczfY#iUBq2O~@nR528T}QwyJJvqC-L zQ=K20`pl6y2D46+C`^XL44*ujPq0&9J#D_$xmBpu$e?7}PC7+l^AuOye&=*ywK*sJ zwhyNn)}H9gV#Ng9@ir< zD!rReNjGU4%0JRg@Fh#I@omTfp;WR|&eT_#)aIrU0ar%@=magbwirL+;|+aPeKZZd zM&YNEX5Mg&do1>v&u$o_O&Ufil;fD<0t9qQ&nERS=C}4c!!bue5@gW*Gp{vAKCPhk z1|Kt@I7E4UIWV@){-tU(nzsPKh>>iT|ND!61hOf9HG{z2C%6hS@AXDiEz85PVJI-H zB*bvVDe-kEuMP0>O{V2YoVy$A)UWnq_LL2vVG!hm(gbFMlc{_uQADBTr`{3Im=Y1T_+}WEZ0roOA{diXrAm1qi5@#$qpHjd{}=wz({~hw z_n@mG&z*(iECfqlT=k#UDBAe$LE)KuU1dBa##1UO8ak0f%8?z!CDNa-6xe&p+%ruh zlKQeb`T?HF;_}TB-RQ4hl(^1yuRL7) zn0&jJ!qy4)5_h^T22okwe#aM*UmNjSfHKCzIgvLJA6vF)uZCR?aNClC3WNTB?VQ>= zqT!r!T61ixz1f$x)@M@pDxgw@z?Trafbi$x<3S-e3$%V<7YIWwoa?{?0XDCC#LiEY zoK*Llf0o{|0w5^~j?2wv860$MrnVI*!(5DI>a)XYzD5rL zLHf<9F~*2P22fb@Ja^IzQ$7`makf^2L9{fZ!OnmXTZW1nbA*p$*%-!UT~#CUc72C3 zhV~y-*VmyWZL_>E@Q;AQBJ^Pybo$u73XA1wECz{4F9pQp-jin^@CPGQ+PG&-0(ZeQi@1j9|J;0 zeWFM)A~57&5I$3=DXA2DK_!bcq1^>B2d3bJqMRfkHnSy%EK8vOIim_=Ju>&I8bP>g z0a}S4a`}6-TH$jN_~QwaRPLHXbNs7dPs9DT^jK|ojFow9rf*I7-h3FMz8pCTyjxuA;!l+CKOi^yMhr8^BUiE1XW4a4mQ}m#N+*|SHm9?0QVEQl zCu}=N0EHnTI8kK_(TsqL#j*l#gM9sa7LjOpCX%KNd;+L{q1@n8RnJWcH*qx12p%tx z%Bg9Mka#yS^?f&U^yUH+NA)9M3T?gH3~kH087+ApyAh1{i#44F@e z=n@C2nzzGfrLZQ+Q(auDUl|?4-=dlNzTK3y3_+pbx}H1zQFFw`##_h)dvFMXRpEoMSg+b^#y}^|7>As>6sh_~kIzJb;gd`~j{j_!c zJ5kgN*j=hg5>-SV%S?%C;1sIl%TL*TBtpH2%e6uUC#&orX%eQu@~tsyHHLMB2f?LR z%u;R0@;d#`c8AhD;W%4|RoCaYS5BeH?}pa*M4%s3&`AHdda|Jn^Vmf9=fB77bjGrs z=Y@Jfy`!f;p|TvHhnsj(f%$lH;Z7%eG^Feg_D(Jjee!AT-R@6qe-cph#xOJ*DTHIgAOM|j)e^@uEeO~R zNVVxu8Q-6GH(M7g#O;*UzB@SZUl&0S0aL58`zw?yNyBqZjm##NDKJ3|PL;$N^l|hF zL;O|^m?JRWSx5FiV14=EFvI><*!J|J0Jz(K(#U%Q&vz|`km^#E5S2Mur*)8ICC?;6 zY}GbWY#j;->nYE9S1xz?!$~7(@uoK)_`JaI=fBi}*HX;+nPvx^0F)Ci4ap)A@SvCT z*ZOzk-T$STa6L`iZ45%BwtvmXy8IU^!*bWzBJcy^bC)5_>Oo6f$(7D0+Q$XAY9>kP z1PLGih27T5+aR)kuq@VasvRk|0r9!d@Jqp2)Ii49FYrI>@QaO}Zh3b=kXzRfO9=7I$8PQ*mJuyag`U$D)*9mrJ(MtXQUAicS!x- z^Jtf?_raXcbw|q49=OUY@j{ydUsCNq5~y#}f*I9b415eqIwzTPt-;1V+lXyT`u0p_ ze>63e_PjO&z4<0to7>?LklF#}HZRU-hfNI1=;Y#ItfiDJQU(Kx^3B`r!r*6DU`u*A zsO$Y}r$o@PVjkCFQy92}^)vUK#1BEL>SH&OyCuXzBL_%$6hL8iM{Xqw48v)6Hab1s z$pk&-s5m{Y=x=EN_7{X!3znqB1vkKCF$&m$wY%+%I{TqGiu~vf&>}F6lNVy>$2br4 zh!r}3462HP9y3gWV$giYi@dJJ84f6#UhKvCS^J2^nibGO7@-&LK@k(y{6c^n?^G+5 z?kLYR?wn(4t(OM_J3n$(z7s?$0xo0IB>10JgHKIw*Lm++ZR2-h#6&)e13<8D8wXsD zSg#AF`R81rB1*FiLn|p>#~_Q5W^qa+2HDX&fHF!%<+Pr6U(dJ$sL%iBnaO#)(&J)W zk&!bbJREMKJ_)+q^;7vhp5VelV2wy35%-s`o|OmtUtmY#vvs^+38_zzLjqC z+;UFVn^&GlNmA;A1BA|TH57}7;lq&7WA7q8Gells*Y9f95RedBg9xwh`0Hz%&H$8~QLAgPOxi?yzyQARih0!-)t0KHn^pUmI@*Jvmyx z0?Qh-w5mQZ|xBim`zhUs>mP4}dH>f!Z}VTQ&(^O#MQJPbX&$Ll{3>52!OfzkHr&Ci-XD;y?*vq@!j6Rw1*0Qk-TnwGD$PRngkU zzE*9!DGF8TNNq;Cp`pXEgC(%7FwFJp`radB-#t8;9N8Uz0%ISuQ(XFwiOn_!gE z1{TiuXYHkI2~!+HXtsy3(k(-PHc4uI8peUgMd7&w_MJj~Z&jI7;L?ee;A6x{BM7&W zX=FM9v87b2k!9KnRN3ttOCJYyED+FsLdTWm@jx&C&Vx6Ss3b{~anAc*dI4f~yB_p( zT7j==h-ci0A%=x*5oa(3Y+1!aZXfGaw{)ZEKVT6${lOjij!}jVZzxySu}|DKjIGcv zi6J1B{wvqH_mFTO;5iD1B`HhRAJ4Y${Q=p!!96Qf8b{aTf4}rN4j|q?5(@MGEmZ!^ zxw6Nd_bU8CeF4B_0d=;!)3s&C&ciPWT8k`o?Gouy8Z7ub)604`WckgOA>plee|`+r zcI@X=5lVI|*~N10W#-gGkNJCB+ zuu%MgdOuujzqLQbLx8kq0jx-2XcvQj3+_$C(&Is)$;nOZ9nSaH*#dytVk-tB5EfO# z%kxtgFu+EIAGX4r!qDGE|6v|`;m+sGEBlg zwXR9U!ATkhJP_{Z?64&AD$fmbaHD-cZ}h)E+hb>TLqbX0RglBc2$DPItac^=M|%n% zRhF&;r_o+=ia49m2@c~MJe z(Tp@UftGXd^KA1H$o1CJjcczZjpSQzpqF<8WPi@L9e#<3X0jpDI_&3iea<)Ohu#Rl}ZRQ-8O z+b)2CWFCk}_s7oNO{44{m+pttD$Nm2M<|4ijabm{?Cm7uOu!HJZgPz-wB}5FR7DJPl0;4ghuKJr9 zqcPaIIf_vs8Ys330S-h$#~3h&^esMqr5KXC6K9KUigY>x%5?s>>H@dTVRNCD!82g3 zR5~%QdRE@PKVi=_3F_EKEk6B9aOi*|N$CoKxY|&P&WNR{R(fWBjM}QIuAAqgGccf> zVA1Gpp9cfT*BbyS1E+19iHl4g0@hW2R0xjE;5;wtq1sl?X-^eYATgOt*?G|^%eLd}o8Qw$VQ zf)sn+$F*&p`QE<-G#o1rj+sO?RLM-ToTWZG^HOKj&*0H3J+9h0^Y%C#d`E&GY-~`a zWJcG3+z$RAh|B`k(81)Qyml>IV%!J7ytJ8alRU(V32pM(3VB0XU2QzbxS6SS%rKtU zAXWUeO1h!9x&^G4BEO*#n^2)5GjCHeqef$$C;K;Ox5q^OC8y|1&8YsBMZ zMa|tb>4nB%YuF;<8@3t0FtD`?s4GZt7CKTzss+(`GJ0a@V()9$7Qx2wQuyVjZpyS4 z0NyF4YX~yKMGlu2K9_ZTc?PzJf&c95$r>&~E|{*p27sF-g20P4^n*~rB_0T8Prv-n z5mR`ClBnD$oml*OcN^yr!+FH? zSeD9VQ*;sjq>PuRD-iN<{B;eLVJwM12`*Tee&K8Y&>5uBAJRIOf**kb24$<(_?1#@39i#n9&lW*6@QtlTEAg}JJSv|nyHV+$KJ<{HG01q1t3tx@VD6eyqqS4)= z;Ogzdo6)rq_H6)8Y#kccNJ3^cLc(F~vzC8ZUk-$Q1wY&u73V>WO_^y}G8` zz`^txZsxy-Yb+vehm{6x%>b0o0s;gGV0_tVs8FfyVU)INU@0> z>eRYp-Ah%ktJ(|*E`B%Q$w?yD* z-gHLP_{kn%8hV;j2!7R00X&#BbV3fX)k;A129{Tf0;VzR$iWLaNF%8B#{T0#>&}zR z%^S_j-ApSs4n?kTeu>!Q*=Q^p9wGrX66~Na4qWXm;cs0Y^8qi^j9@M43Yha?>n=HN ztgKh1StK5oH#g2=fhrWZ+e^vHrW9HpH6IpP4Gd7HRjW*`a&JH%L}CBcfv}`e(ALV~ z0<-jlx7u9^Qqy@FcXWVke@>` zi&+XSc?p_Ht-?xj7*EXzqy)f4`pK8la5{-H6oHyCs(Sw{$v;zYpv^q=Aa^NrlTfw{ z6U|>})Rd56w_JW!O5I~{zo;&h1AhNw_f>3D zT>xPB6Q>X4(LDysHSk{Zx@F(d-=A?v1=ZHqC6AP)@{VNdHJ`7ruT=M>P-fzr_cGLk*)IRxiq(`{WdS31Ix2;g$|;ycV9@nsW2G?NZFv^RMna#cng#EN8;`uEvu1= z2JZJYT=Qy6)Vj`$Q;im*opnZCN2(dcwBu`qTku?px{w#_A8m9YsPHV+kC2>h|X9K>gW}LXlxegS^vvxv-cii!p(Tsny z^Xx7AOr0h~ikX1}1QpyK29+JLnLyIEcud{e?Nq9Wpj@ZUuQOCT-XF1rLHh>;!r#5# zNET6p35g{~RnE4w>CG!4HBe=)Jpxd)b~qIjAM~on>h_HR1I-N2b`Mv)Kh5NSb~74S zSNQa2MIs=LioVP_NR#RB6?}o|msiy0$B2I_J_mHc`dBgzj>ZA4_QL+{T@q9 zu@npd&e=0d^W7+RNPAZgG)hs38$&=0@dC}SkcXEsGQTTMSrUfs5tg?F#Wu0 zsi0IKS1*66%f}Q2HX^g*Qg#6K+z_sjp@rmNMOUw(u5N8zDKuqWDY%{MZD=IIEoe9J znz)VAHQKV^{=L9Vd7&K#{JQZT8&79s@Xr2S=wcMWk77n=iESY~m?7;QJz{N$Axx}4 zncu?T^D#Cn4uR=?D5KOQdhUHaAlfnl2vQrU2jFsRh;vt?lf9R zD8#2NQ<_1*4_I(E012=MthIZgxAOlf|4+=<1JIRc=yY#U$HWtee^~7J!e9uN6SFjC zg^^;R(2q!K08=PW*LItF|3zH!vAmd|7X59ESm}nbvHxky0-CR{sp4bH?(BEsd?YaO z;oa5d%ky&bw~y&s+HwdU{~>7veLa-7m#wCnlWoiVQ7U7v*vQnU?LSe|6Dg*M1zdc@ zig73W;U6FkV`kTq(WCYL=ipMB0T)j&dv^uIL%LoAM1Xc*^ZYYMwXmcJWVgQR zoxl;&yo20cHVmSLe5Vn^Fyi`p3T$*|02*@J47iSGW@7CFQe8h=?3e2<(_>%AqDYu8 z&uOcRsZ?=807LMn5rA^4wwyW->7(|d9;nVSMPXaOU`QxgZo7gfxodShH(0}o>jyGk z^^$9NI)*=rZ=$;|V%fXYUZ==i-<>cjd^4=6zo9--OdZ-kdj8sFj<~+PrPmFjkHF%X ztmj~BU4};Uf`DK~rbVO0)wse-xY8ru`SW>*MHAn?F$;xYg#Zi5`fEfAQ2}k}${)z3kv<377B@~HO{AH;Bfi^!%2I-Wt=)?N zAd~|+%l41r#+^XItP2RpRhd4@{j&Yv(cuF>NA*)hk?tf2->u|Pah$Q=&O8>w2=BhA z0rk+RQ>z5j!^`u({KQ+tPr!5;ji(UpwPtO<18xX7$lRe`#Z;yc9<&f3GB)pdyfm%E zIfCmq>z77R-91Ip)Q}?0ImsU1W9Mk62Uhh1cv;u02*C|Q#-U&Mj3{ZmVmP1Dz(@g! zyBL#^dVT?-XdZRpk0~&8{lZs72mFPn+AW6R#Bk!rq*95(ZZ%(3R~g2;aoTH-pGpT` z^1bx`O+BC8PxJg#{Oba|S2b+Gxj}yqQNPW2mE*xv3%{;t_dxgRGVbvcfME7M|Fv%e zMCF0dD4-d-eiK;@1t+Q$$P~1l#9#f_=6v3|VvfoOXy(J~4|x}_xO8|!P^SXleWt&1J&GwIa1%!x-kVz1 zRx9b_Ro`Dsf*#9fu79AcYp5y;WyY~K$H|oJZ?K8#7%6JZ6gG({4V-yHL!C z`}mfkxprC`01MfzI}kUF?NTQ#VBQ1x(xw2R&1$s2B?-6n=U(JKpbnGV80#@wmEEM+%!DuS0(h*~3w6N*CH(rB}{_pfL;eqp~)95*a27M{xS_fxr{U zJ?UCYZs+n~!v9U8Vsv+Lc%Ah64&9c;O;@otmm>tTx|RSIw6Vmqrb48Pju^iK=#6z6 zr}7V>I6`>)n#RZ(f+qd${T%zMZKz&(6+3_S1ZH)78`&D*@zt}a*T`R5$iUX3DJ}<5 z+4FoUeIzg6No`+leQPomE&=;8JrIB~uYi{Lg+0-M#T+16Zr$UnSqN9oKBe-p`^e@} z7dvt6f>{PDzkn1PSw^U^yDzI)k*=zj(6K8vt3*&Lpb0{mj{uGTs~E~jUdgSz>d^3m zqr|Rc*x-?qXSY^jiLr0MWIvr$n^;upSJ3n5;bxGlKV#0yIPXSI6yb-lZY*~EzaddM z+v#n@YOzAYJ}=G5n<1I;a<>puCE>^2RC$#TW5l!k+7H&bj$hXP9@n2|Z7P+Rc8CD> zKXII*5SKO$l58Tmu!jgX!x6n~cNzsMde&{$L-*rr@G}3WMDp97oB15>G>SD8mYO2@ zM2bSW-&p<3mUS@%Se%8r^xYee@D}J-kv0ZE_qk1#b59+FT(}Jg?=2ZPYq8{Yx4$O2 z)_`!RdOG`18+lmd0g`qO5OMloQm5G1z}O5JXUAhxg(R0Y?&%b%H!8xnY5q4qWHxYA zgo=wU5X?jIuM7AA9BW5` zF(4lxPPXw09$|r4-(>)C1F(v}$R}bcvLMf*$-4l1gWahUU~yyA4I(|@V?>>G7E^0W zP!{|N(M1f=^$7X=gh14Z1n_Xwv-aN!VnH0}wTT<7f?&%P(sdwy8q)m(!M7__o)tPm z;Bh!lm!!KO7CHZ8LnxANGR~;bHM>iLb=L|Sjfgu&YJz6Jw!$1^Bk3}P&IdL>VSLvl zhAjlFd1~6`y1NsJ34yT7QG_4+AvKJ4LzdkXH-|qNpz#y|z!X(`H#d=h1=h&!FsgkQaI;CN+Gy&{y?% z{o|`fg&4j{$wxhp36)6E0U%FI8l9N^P9m~yV4R_lbZqbgE_x#uP9z-rhhha3VAUCe zLyXp9jH4R>_#MGmiTt3xMt3KdD6sqs<75kH9EZp8404>Bq&+h;oWuUx2atKHCh!yM-C3*|Ff*&<2aFM#+uq%v%p1V zOCKm4Xu6ys`RQ>0&=QD37d{YEcv%nmj!EL6ycl16w+qXLi0(gInGK7d@Z4ioP>y_v zv@2j7n|j}p<~WQ}@as?i=zpXm0U<&OInAXgdtC%GBefV^%MfSmU~DmMi-L}T5%_M( z5e}yKHku}oa=U5(0C@V7WGp&CJLC2LX$w7s0icr2RAPA;5LO^;KLSJG6ojaHA!75G z91l_GFVfKqLa9Taevv`!WjTB)X)}g$}!~c&b&Vt@&;I|ZIS0~74JGrktsD&dtN^) zD44L@2E2ZtFk2v;ZvLh<<-~FdR1_v$n&ZEliJr=a#-mG@_GWSlXhB~xxWeH$=44lt zpRFcbwzEG{dJ(?&a@Z%WY;X8hT)@nr>IsyDmq3LYg)FtHRfrOTIYh5=qWG3M@-05P zXXJT9RzIAi13j+A1xVr}+#70eR)KQQN{iVk!N>uI(1qCO0U%iMv>WLrLohx+zs9fg z`Ry}>_+s9?Zh!G#0YUfA!sH(U27mu}K!cl)#FBmpZsO@kBh*na;Nc=5e)Zdn-tADJ z7-P%gW|WrbF*ZA;0%aHLk31UMWZ!Tk?EAe!%6KC>JMpQ@Pl&|;&u4*tD7r5Sno8fHmf}J1G%sM>L^e#B0Rv^zNiO>P zGdJj&;BTQAZqhGF@(I(;!28ADBu?#Sl<-%bP&#?-e>(yBx~{m9P*1!80bCP-Un&3B zMIwfpZAW;;%`eLNA4SLrXQZLA^Ri|7i{8vhKHp4LH2gy%d+&t?xRf~YBeVfZvS{C& zzO^MwbaSwAN+Iz`UmXG z)+B$dWyL&&PVu6(glYHHwI_p59>q6R)0S+)J(-}hj)T7%+=YwlVOlQq##R_5TbP)8 z(uUk9)2R35%8UmRp(%N0kwjdm3KFikTax>TdlR=Q^^5286jW?*5KnWhv^VXly3p91 zOoLX?u3+dXQ|5&fd$$xL!7@F5Zxdn)$^?}Yp8+Lzzd*;2Q1d7$D!Wm0W3Tp>x#w>v zKX@O5x)_Oe(ta}%f~7LG7$XRTcH?W;Un=t4Vqq9N3?;a++OgXi!%_RBnJe;S*fHwf zgXF0KUemll=-jB7N`dztdaM}LnKqQfZep5-uM(`}wVRlX1HLQ_>U*)wLS0NY(Je9L zM^`|WG`?!3ehuuVB+W;erm!p8imA*#mN0Tfp|<44Sj8wrfF&8SxEUr1+F?>^_VX1d z{{UUmis9dU&%4vr-p44}qFa>wE8#0LL}vS!Lbce3!s!vlQUs;Xn&USL+#JaSg;$C} z^t9dSvbl@K4j>vdXbF{8-D9vLqsOl?w2xRu^+OZ8&ZNx z0-(k_T;?v_-BfTh1p7YQC}~Ut3>tWU=O;v>d~Fl1=R?!9cg}Cy`d?P5wT+Qvn!4po z!)A0QzlC<~#IoGb{hnp_R&kr0!;oT?@djelAL}rK0|^UV;C7JVGA%z)i|&&qe}E&q z<6y_rF(X$Xu5h%l1!n%5^v?r`?FW#r$(a1$v8n?u<$nw7ie&Z7%O4+M{{+vgTyBz{`# zos9dS!1C3+qH!4Now}T;W=@N?b`@Dge{_>d7rNUYn2gEMMb&dA#>T&DX& z5GD&u&d7fWk6_A8;IDkb381i^-NWmw6*d0&E1A_B&0_COr4#4WHmA3qtZeF-Y9!N} z$b9VM+DGjyOozya;-XQiSV6H772`d|VFqUEH+2N-@lZXz`z{_^f+4keL`op_{{*`| z!Ksr{Vy652Up7@!;ppU-sZ7LL(tGB*x9?8(4vGaT=KcM2nD#f5PyCM)lAbRV397xH z-~KoC$jSbFq^v+8C+WrtP+BbdjzRq}{>$dy@ce)Q>Y-Nj2N4ltcXMc#9si1f)y3C3 zGZD;K&eKfMG!=mtaOpWw5XRy`;rxCueV)~a|2)su zSI0T3ZF`-kMlVAxesMBm5fJ1j##O;!Zm9o?vNt7U+1Qp+|GLVLnLL+gZ-RqrN5UVi zCMu<1?t0V0R>TrDDg8bSUbaj<_rbcsKS zE@Mld6Nj9-A=_xl32TR}4mPElb*B0jV;@A|&;C#t{poNLQ=^f;3mJ z1#C|X`Dg+{J*;D_`kSV7`-S_OFTG_$yZ7x!Rn^*F*+L759}JB=nl#AoLPv8uQf1L? zjjXSDy4V!GetXVNu!U;SFZ>BA;e9cjFe{d-89b3BMpr)+9(G$8cb>_dt9qAEY#RNO z9c^Tl8oyPVHu^TL$AAEpc8V>j*kk7TBskh(JE&#}4<|)>yjv%?bs&NPvsO_2;JsKX zcZl1_&Lore7c>u1mbq0mt{SA+Tm|JcgzBNaqYMon*_VdS@hWqwirXZoWDT@9!yAni z2~yz)tNO?twAtPhEgyXHrdbO*W8-%@tW(Q!xasQs&5->FMEJVNFQK8nIW~0uSV@SO zO{bRuG_Z{J1e?6;N|W;Yv^mM1rFy}q&hXoD6kggU%a9t?|LX4kq9U&*w@-=f!&yj@ zGP&!*SC?^_d=cBx9~c^)cq>3LyfgPNyzj@M5UGe2b-{}<)x5M|Jf5OpDmq^R@N9|p zPbO`5%tV4hM%r}|Rfv>j!BPd{6qz`gC@Zk76jvqc7$jg4`p0%O}lEHzk{0FZqdcy(3wuCz&_qP&vJ*#a-R#; zt8Y=6HfeSAy~fWt0ppiqMoq!}&pxzWnPJ#*!Rl zS@`)Q*Ds12z9)!T_yj7G_bd<|()Yb@Pw13R{+j5&C9iSfodj<>pSd%U=-z-b9IiR} zbuQ6cUEuC53B1eiC~;D*vbeo)3Kl0?UAAzg4^+DLLLSc{=*Q%%y(wIym5xcpI=Uk| zni#Qgn@X&Q(xa;>+3}fjL4>*=@Dl&f7BB?WbG;ArH*Kh#|QW3IsNBT%O$XM9fFp8H{%SqEDTf#@O zzSv)k;kukQEru|v+xs7tPyYoze-KN1oeVLerKx7^)q_2@K3#53upeyP1}*^vkE+dkaUZ;sD3;uRDfwPv@bhWq`PJH z!mupVt!yW340XoF0AVNAYm1&))>tkx-Li<9z#H-uabIDKJuHi7@BT}K`QF(=a3$fE zpaJaJ%4V_%YiO+Nj6-F}PNENkW`I;K`f(;IH&m?|NT;b4&#YGt*jE9gF!kjOe*A)~ z$zEiS|?QmFDxe32?n;QmkUr;q|1mvBSkxrH-UDadwAnq^ERW zw8<{U2~wp#7%OxQwIhY0ym1trJtjLIVl7<3CogLr?I-IKxbCa)K9GE z4}CZZA0XJ0`VtJ;_~QvCjt`EOA#e< zO>AEe>>nYRYU;@lUvsLS8_Tj?u?YBZ(zb@$q;su#Rl9;!S!UA+>CjJTI{9c;WHmgy zav|eLer(aIbZnY@56_m2IOG3PRT&@Sso>Mi8umxh30;(E=}d512Daqj_Yy=RL{;2_B$|di-Cp5yjmbm``0_jf$n&zmqq0UpVbwEb9gvHaqCZ6{ zS0wV7tDE%)Km$OTRusoaryREn5NcNm*D;J~L>Qgd} z&o63jTWpf=HYmlces4#-$4KC-5i~3RapIwSeDT!{+%xw7|1SXEKk#*ZA)JixpMAG2 z9+TdQ1+3n5&|7P{m3|b|oRuUBJ6h62{IiEFNwWb@vK<36R=Y{rEHwws=QtTZlsqu^ zN!;!gn-Y#Rgv3)&mF2-8SfM#)wR@vu^k?ss_c1+akeYvppGW)$9Ss!9V&t#EoRy8I zn?acP?i!wnVT;kA3PYmtEGDINb+ExcqD}pm{) zXK5=>r7tmpgk0j!Zd{<7C_ZTTyn2gaRMmJPes^)TaCLM1#{fNxRrd7DtmkTI#D04B z%Pt}%`E@pUoiRA|J54_i=sHlS6nNg7O`dGjJ&q2MS2#8j3p)F5R&bU?QZD6d^N)IL z-*n%gMq1xUUne3&D`!KM|H4k<571C&L=6HC?uY+11*`0g7o%h+=4v+Pr_>_1}EAdOYLY z-o;RWE}-(b(KESR=TV3{@vjdm=P1T7q1I=0yP3ns+7O`Dl5a=MG=E@AI?1Gy&qxMk zFdhow01t#5ow7RT`$mj0IL}Jp8{LVV9lsq4I8Ne{O=e0HwuASHOHui?M1Lp-ryxI1 z$Y}CKs-qn+=LDL}Sgv=T5obv2+Ae&)>*~_R5X5P(E>W`U;gYkf_Esn=K900Vc6p!I zX;Gw(kR2gu{z?9gLN6sd+u@sQ!}|K z>v$G;#IfE_19%~*PKp-2;xtH!E#<}`dnogi$IPsh4L`B2mFYAO5C{w~uWj`nYA}s2 zHR4%qG~lqfq=b8=PgRu`&F>A2wCd-^-XKcWdKCU^)%7hoerIQpkL92K#e^-_nxRV) zLqtQ8nZz(g?fPX$@*rlOU`+_73cfkW>R=eZ*0mvsRnZZ{=2H6410LfCurV%}4V(kmq?>;>nPyM6pGq4w2L}{{B+P^1O&U<<&jH;*n{irLX&H1t<8!UeZpK5OC=?HY9nB-PF~(4r z_vnjZ3T`E4!U3kt)$v;Ejhs7;8a(;O9jp&Jp%1~uXtII{EY2r?K>Pa`G^gcUxot~Y z(Y)-$D|8pS;9Uo)!mPtJY7Zw%uW4bo03N{|5D7Gk+_aPuzTX@uuyg_Cb)$LXvaM5K z3)vIrpe85+r{(C;cb4j`s8nN+@~fz`tOMUJgf3C`?I}QD=)`rs)STsml;n)$^l^{X z>P5;P^uwN@oZTU#|%Yc)Z)*52I61F6)seXfDrSJ{mg^Q#Ru8Z7Wgw@tqV4Q8`{ zc~lL86~Ew8|BhICL_DAJOa?x|><6_vEmYMLdNY1YY&KX_hY9{|)WXCt_ec(oY1Z@t z92j+9q$BOn4hUp$2QC4&&Yh=L+I`<>QQrMH@L$V>6Qm6*PDl9*2+&tKZC>92A-@6f zeop!n*<|RC^3OFvK^XHm2^TMolZ{~SQcns1G=nRECq_HT<(zWM1hjn?&?I2hy-yGG z8SKoGjS>&^ma3)wbqo-ZWHsJWQ{m>w*-?S_+Fdr*YhgA4+rTQZU3u=(sY>9t8@=;t zj@^ayhxPc1em++S2@yu&+a&aOvrV=c2>PaC3Z~-uLvuoF?`P`m?;I9aY795@(ELEJ zjI3-2fM~vW9hMZW>e*Gy={>`>W{pUapVG%`qS0&}JyX#1&@(&3qLf_1k|EvX1%Qgi z%}^3SL?p%2hbZh--wOL%AW3?vr#bTTU4>sw*jS(;fVrnseGhD)AtYSp;jMsJunN=^ ziC$_bPgcW~Awr^PN=^&kvn-Le2OPMN0)Vx5zM}1H*b!K1v?T(;8K)>{y@3lZ_!T7$ zF^uo3iXjl0YNW|vuccx#y_Glyzz*@+;y8_Pd-I)f9-F9VzR|o#4pC8myP*eExAD4NgW|u7o$Jy=M|18js+Ch2Kn&9Y`SKz>poBhtz)m zuK!Z}ZV6Krh(FGBU$%jy?amOggAV6#wb_kOx~S!|mbUNSVSM}m$#0A&9v!39#jqIk z0AGLCg%{nU*DfdHV!kD@s}4Lu^B>bW2h;gD5&YG&eA%@yHY+@g1Vdg zl~~xbD)eu?zz_G?kY^J^z*kWmk*@bja?QE+{_s=qmK&#lNGJxy`Zo!ehI`=C%!#a+ z%%qk4DX^E?qm#UHVa+e(3&hs-bwevFK%~kpEiyrpi8o~*QG2!mcIq`?ZqkX34WK&F zHuAB+B3a5J+VTijj019%*S%^9nu&~^=9k(_%Uk!YK*3zR%}wvMzh6VZdjl^~1_6lT zFY}M3%5iI~NetFz*8s)J?c2TDwT@60{dp9ei-xaR|7RDUyQ>PskD;BxRcXOd{*0pg z$agZqQMF075!SgUc2h+C z@1B+SkS{yguGOiEQ8Y#h_O+@br0uixdV07fD{I>xh?$rrFAOm?t$voyJSd_Kd{vsp z!Uqfu5ay~}vJ$b~6?l0i!luoG!~*WT!FtpC)=6a{f!_ilq#$>L=xqnE0peW@07c7r zV(>HCgAfD^7U8|yoc(2>1uy`o@2ht6+&)adET8#ke{J6iMN8Y^%By|)X=azJkdhss z;~uqteP#mm9BR^VQAp!IfKyNFG?|Qt4&n7H0V@s0HW$QFF^d5ncJvY zosHtTes)s(Kh37L$6f!e9zA0~N#6GZ@mNUoS;xXe# z-U1JnYSO=hsr*YBnY&LH2f00~z}P5~_N7*j9uMraUycRJo57(v0Zs^|f44vZV`uMp zeZ0og$l_*ULlBN!<(Run-yQU^A7a=LND%fno(XF#-@ShGhkJLSc-;8MPk<3{2S)NF z!M~=LCz4jKexT1{ufb#LK@mFChMH5`0zS~If-m;(Ip$d!S6!>iDm58+z%~`t!kqRb z2wIWvt)p5IZ_TcktSAi8zWiI4W2OjH%l!ILylX3v2jW8=T1_vTUVagQ#a|)OBxna) znC+5DJJ5cRMAIxcMZ_vs4u3s;)qcfW%T#C7NqNG1=7Lb7CK-MxI?-=tp3x*zs z%_B#iFz_esy}#O$fE$>s-4CcXY=dD%B|@9B;!x(h?TKG|aDypwH)67h^!PCEhXF#$wk7)iS#RLJQu4%;EsD4!N=%`^zOp^ZA zd0Lk5VQAHTlSG&Wti-<~4XlD4VhbYrWSU*QHN!H-BSQ&AB+?4GyZ*beh)i?hD20b* zGkci)70s*6+j9fpipGR~tR^saF#U)+xBzH1d7`fqg1=cjz!4$yKIH;;B$fau_e6Y% zKPrTa(^m7kd6f&M_r8E(=>lrRwLd_8EWh3|DS^^gZb!0sD86N!u~p8*bqC zGP)rr-p~jRNbdk3p_Z#^&9@J~ru*U^{+td_Oa#aN5RyHP1wI+wzi2P0=Hb|b!A+Bi zvZ5xlw6$(4rZ5;zPL9*E2h z-}VzMG53 z9`=dlNVFzCEx)&iZDUwL7`DfLk-2lnl?#YO4;VfB!&t!<7?r;YA|odCSF=hWY%G2` zh2heJ*zD|5`g$`MXBCnb_Kb`ooD~`fu&9ZZwg7URIU5e`4q@qhH+QOt$+&YCszb;3 z$LFXeE`p)!zX55^8SIIb#eC2TGQqN41Pjf@Kx+SnEDAe; zk6`1jBiGU8B1m!j)ar0%lts+ zfJJG@AeX0S2twc+cn*!8HCp@U2EI8Ag}|7*KP!b#u)3RKl)W_Yw4dn~J)i5e(Qyo{ z@an{@eiGnMEJ>f489|6n@Sn;ed#pohEJFZl)f(r?R9Te$Nq*$iFXyjJNl*W(EEUcw zkVS5sZR+=NguxWeNv_~#^uE>SErv18LOAPLm>cDAVvMB2^uRPEjNN$?fJz1D;()aC zhqP+=x3sA?oGRNt_Pf40DQ#`q)8=DlZFCe=iI!3nbnGYM@G?cp)1iQ-Qh0-?a8nE# zn@?TxTxGT8=usg#3z;B!4PX#9EQozUk15D5@-@lK96b3bI_Aa}t5K-CK_Ct>Adp(* z1L#av1zD)bJnUILYgl+nxba;#~p?lsmpq|RM10XHw6 zW8alCSD3QC0D!+a7C`kuA6GP;K->T@l6WaKDz{VGh=f)IEku{092 z;AeT0o3hst=M7BSE_KltujSZDHzcN@tWjsT&Vd6M?d>x*swQ<~2Qk=ZYe_&p>j|_NiJBz) zw)X_*WKASS`8OL_63FGEx>GTJ7B9c&GIkQfSgyl2;OPYAs?Zn7Fg`UAJDH{6iT{K^ zol>!4I+1=&Dt=!u*F8>Wo zE7y0pmcKM_tC9rBL`8-1g7Ml$(@I3`hbyNHN2NqAG$&;@iQz7>g5RfoipsU)=Fr{^qY$qdJL4g#qzP4rpxFHDI;q=?q^53{u z&EG_mmS|j=o4j-lMx)>rKAoXHd1?n|L<^zRo%MdD2uF)aB#o@)?@mAU$tq?sTwr!QqV|LMzZ!J7-nqyoy>ntoB7h=3Y1 z^h9BDslF;KDl_CtYJN$fh{0%0E!{p~N2ILd!qJOm?BsVR^|gv~PxEFwXyC3=cU>KomJqM$F{cR39H4RFqe+OAD!ALpB2nJ z?Eu8n4%3u%@^`h%z`cR;dC|A;!<%Wv!z!%4tt8ZBTnP?Qx#Sa`3lbE@oq0;X(2Zal zU7Us3w$LvTPQ2c~Qr%uwqmgVh7o9x*ie&z3ud<$>TFbW=gBg0Dz}8&AWS+mirj zyGoO`q!=IK-*}*O`>^7)x06}E-*~uu)|F6#f-V85OjyIF)+45XRBNF6R@L1B2h;da z;w+;HpeyQ#q+jIfoGAPzgrAWM|C3b(_8Yx$U*%hCH`sv%v z1ED+P6M^1ZnYF}b{5HhuU} z4*Sbr*N+_UPLUc^M}X^6bM_XPJWw=mUF^z54d_PymF2xWnq8za9%gqp#C{i2HA<<8 zHglHmzW%SL;!S)}sJ0375T-RHY{T-3SQUv6vn(92Ld&2r_h?T-6h$t?MO&xmk+{B8 z4apq*>fVe;26k#|h>KN?j)>d(&xW1AjvM8KP+^HC?H^8YbFcUaRg2`m!tZT`zu?_X znMVJfs~g(`e=uFOQ+m}*{~Bf ze#yVkv)_x=W}y&leV_ zG0fV>^njMNT70mb&jsp@R#LT+aJG+OIz2#TPwoz$e02A>k~!GWZXc-DJ$?%w3ZAb{ zwWVJ!2PRjv@H6J%+&AQ*3>8TpNpK%Z43L@Q)A$ss9%Zd;Oc8sDz-4qf<d%f~ew} zW5ieUDi*CkA&v|_Mmnt5dp?Vfn6`3I<5#m7Ist=>Mhndol!9i7dHPfKK8yq- z;V9nj{s0s#j98i{h4f*NZ-}@jZvaQlF#un4jhwF(grU4i0l4$@vyq;SL?d!axyS37 zx1w{017m0BsuUnwsW^S$*@Q70j9RSXBLL>mW>1=bqM>aJ=^(Qab^lY9y0P~GN*WW5 z94SDxwD0BA(-$%!Exe7Lgn>%^v43{!`MXJ9U2b=;#P5A+n=fmhO2v#p4c8IWYb&-Q z`?K{1|J{KC0u+lLLm5%O*0+%3D^QF1O`WRi+nn_}jV2q()nmy|PTClx=pKKT>)k+* zr*EI(3~C2uc|q>K<7CKPin83(Yn0VDf!Ayf0vc6Uv}&?wBBDB_lq1q z9Fpa}JOmjM{%h=_4%9q6^?xSHC)zh%dsb#(i&$W*I%?2I`y`cDijFfzUgu*Dg^I7W3b zn0lF$J!g<79EsFpDodn@8t?|}G?l8dGTvYLnMD)Vfgp1YBz}6>A<%KO<052@7#snX z6~~mlsjiEbFL^QwTT>UnV7WYQ@P6gD$q0^l_AwLK{`OB$ls$oG6?;9P;~#^l_s+L8 zOX5!EWQZ&FO$elODDz(^im@E=gTL)%HDN<7g=45X-u$@^GR@M8M4d%#dmB-Cz7_mM z1F3*<1?&QhzXO*vfBDOHoKZ5l$TeXILIWb&)#o_+rw(v( zhC(N>Vvv8cWms;z4?M)vWx&4@1=;;@=F)*5aS@I96@$9fAjaqdJDd!Iku#kPxY{U1 zjGYasG_Dvf)qv??xOEtPeh!SjvuMvnrPX~m-E$l7?$rub^%%4%_&h?j^=m*{ISfSz`hbEm`t-2z^o!n}R$YlFiS5i; zBuWG#24?^R95=~oD2+;(5^=otxD&1TZQL+!*)r(S{P#dyiL!L2S*9~`UWR>0AB+L} zlddR4O_vE@hoDP$vfZyh(Y+X3AE4JS-9m{hRcL?VtwF3WdCZW5Bx;;{2KmH20O>9t zoeF-Sl8VcD25NwsYY-C45J_qIy*N)6Dn9QH>*rL)&h91}NA_X%XqR?!S>Isj?vwD? zCOQI)ddRdBEBL&n;h;3RnQY)HS3ixfV+^CI@wog+w3;x2T%4!_EYMQ>3E%@kYwn@e z1Dlm$3Y+13Nvb@J8EPG$x`_f-*#7+m`~<1vO&BAqtPiBoy)Iax20dXI+P*))cBPgy z3>s#ef*!|5P%#xM_&0%Um9L_O=FAtgzY?`E9mR3E%JKla+C#+a>OI&Ox94CBD~>4UzI2^Hrn-n|p18o9^15>H%^njcNH8;pV!^-6tJ_u)AgL1Jc)4Ff2ip;DaYs zRSOw?z)_$yajhcCHQ?p`w-8PARes1&;m|9;hw%C|)YRw19l`i)m+aHPyrNO`3p9Qd z3A{j_vdqwu^NkB+dp3pzw_s7&w!HpBpbI?vpZJ+}2Tqc2MM#rxIib!8qc}^Or5MAH z_g$bCb8v#vyCryk($mu_{)HB6iw~5zOOy1>uu3{WLr}gY#f0#*!UUPhZPe-X78uio zy2lkGUpfQ!@WDO3hGB40E@B2FgQzUIA~J+194iL>`sv~f@Q$~p(Rue!ZLj6`$UV7< z!O2>^9l=;RV!;dG`E(j0?fAe~Fbw0=@GOM(iikd3s2k=g2A4w!0pb!BH|aArnmXi^ zG)}Yr9a0-yB*}55k$Xw|_qeB1H}VpjPN49dmo^)rO`@O2OLO;wFDCr6p4-PZ;C6_{ z4Wqe5lB}YEZ1!0v1555TLv(KX4)sY~G6AjfOTvQ zT=$%#VJYRCX4&HXhzjY`9^Pkr2rFFsBiGtv$$|hd2hML-4(a0vdqUCF`%rOs zKb&5V3sjH$RWShR!oR`c%Gyt?Ud_6`jK4lrp7ehq(RPdKk0vWCDBvN8^`Md}QoMP| zK#nL;>*j8ZclCSWt+uqBuH4};$T@!BGN4Q=W3##dcLAfko)g1O=r#?+hgEnQxU;!rwt1)(Vm+SSZv+-9&<=)@!dkhUGMsRk?-ft8`hBgm9_S}wP0hS|<0Dj9CdBI$Fy4FMQ z?6JyJD=h-xu|lmMa9n&JgT9AD5Pd7 zEj=6B4~7DunVxxryO%j!${%={!frCh-D;5d$25xdn~iYowajf+8 zQN>{2i6GrA(efM<3-Zaf6$};2=`hVoURjZScfXDpr8}<|Oc2*lO@AI57G9NJEn%Q% z)Z3>xQIHj(`jJpIHJ1aX{+A}rJ#wy%l6fb~Fdv&B5c%=O(s;8xCp^~p7`|@tHdWG4SwR z{ZxGatMoXgjNZ+5TAR}LBEUrCO=?Q3;`33uM>N$iM2C`>JYYyitcDQRUlid*dE8_Q?`iLb1tbd+>zmO8gyjyXqA|A zMmE*}os>_}I~9{B0$K^Q=~64*Of@%f&n37k_Xj8WW1Gd=vo+tHvZI=#b7G>fVwQ0k zUkalN998we>NX+uVx#3ZMGilEaq55?tdW~{u76Qr()LA3EzsY2@K=m3%a?S08s>yj zet^)uP9GWU#I&Hr*L*x~c_Luu^aQA7*y@Yr#1L3azs^zLLrN{nJ-;XE)VEywa_^%y z$cE|J_-hU@2M^yf>}u+T^SAtVqnsf~dN&=p4<-_D{kiO}w;T*>9fl}SH^InP@u}ev zuGpu+c=3I0M!xT*5i}XSB8|o%@ytr*NH=0LPn*h%sv!a`Z*vV^q_ww5b#reT5Q2a-v9j(UZp=JhSh3?{mff~$h(q4Fl06E8kX zlpx1LDy|F&JHTV{F?cYPBauS68zPhcN*0hcT%u(Pv3DH9j32U+ z8GeXdl}3kB$(e@SRx|j%}Esi$+6Jg zZZD+DN*vxt5(DMz%3F1qozE}l&#(PcvBd@*+Vbkar zsDwGB!5m84=oh2h69=y(R}XD38DqdzIU}S!Mm^XV>cP62vd<#&W;Qg3CF z4#vJ4f-&C}hNO3}Nas=i=5rI@b}AUSQ6?JXCZ=pjgetw+HqDQypw6Z0%AokY12{o5 z?_+cE3{1pdv+e+I`8VN@O@3XSVeF(NoP#cyO;4%h#y8RIFR_RVmS`ewA?Z}IJ?WvY z4Owb}Fu2`G6IIi8dKYa#=b^TG&OoH2&`m>Mfxrg)M-F9Zm_yP9QJP913Dq_|JUp{G zcvm`W8#YjF?@$NnnuL-2bk1zIMInVv(5V^d^;-DpG%Mk~wjxxw>P8A^zyT!Rop2Ha zO%sDMXC5PagZl|e1+i0MD%8q1pe-E?~O7&7R-TpPeyu|eUrA)Nq%?!!M zOMn3r9n`CCf$NyPqhE zlT|U_xZV9=QXJ<;QMC_M!%(78xN(0CL$1?8F{^`44hI^sDCcB zijV37CCuLtjC(cf%19j4=kS7QMTDwTbuMX(9Q1mN8qAyQOc7@z!MfLrQ<(gK>O)&m z$VN$1yewUI$O@3u(o{8Yc%ax;2^$;li;VLVnir_XPTS5pyTL39Sfsgp84Cb#HP+K% z;?XZbjY!cUaK9SQ#(Sjn38O#%5rh#_7;y`Ep#OQu#sx5mgMaZZ(b{&cde)2Mls#_2 zw1KtGw0Ty5%uLrj0_~%*BZWhP%6p(xo+bY*)2?*emrp^g7Ulc!kMV~ME=>`dP1lp7 zY0rAMwPY2s<#BSihup+Fb>CmVMrv3Cwqr8Cj}6o7Hw5Bk`|pOG*Q)SodP>`6zIm7Q z#+m;cf|A##>FET#hHbzU*Vvk(srAjdw;#+{+3XdKA>mUtOLL1^^y`D_l&EQm#~b#w zW2C1Yat)6vz730Ucm5LSFg;^HHjv`g^~elevb@QH>nzVhsps6gDJyOO zvz>J8-`8Kj1=T}C)l0{h0Z4oe9Ql6-72>3-O`KNVL1?uPMY_HY)r<`TiAJ2}YHeRX zn}M1@GNgOtxmB4?x9wSP5DDFVK~%n@WaBk?g)0R%U~!%4PB)N-Ys(iyY6O=r_29R$ z^_+2+RkE@bUJ-r;I!-m;BhYG|@ov@e2kC=@sUCpouYA`7zZ_7?LJD`t)qQC<<*vnD zbuNyUW}qIe;|Ob`#zr$u-QwQ;@)dU34c#1-anJhUiTv8q!`-!q8BO&Bqy# zL%iRSfUWl7TFR&y6h?c=TzawOKVXP>WA}!(%N-QnEKDUD-QO{s5kqW^7PW9}#XwNt zL~6%<5(Mw_qmX{r1IijguJ`Mp8gUHJ;F0&fm+M`j?U&Tn3n1JQ^+LxD063R^P8(k^ zsgHkJx?dMWzWeKP%4>?Zv_+NFmA`;CIZv)<=o!8hxSp9_^a3Biwa@H`Z2JbZ#i^i1 zIrARU?7i$Xs^9}vM>bcGk~ss%$M~AfQxa6|*A3VE9SjN&qY&xbF-GLd8E6jxQPQbr zebuoUYz(U)X~<}ud1MAM#LgPb`gtUEMb7{9!a;vyq+|Ib(Y)NeEC6aAf<2G^f4}x` zFo=l9Hy>e7e*rn0*$aR0!qy$ozy<996glaqw6ikAZ}UPCv5mCJI^A(6_kc_ujrWZA zC~KCCgJ05CERZST5L$#}?^xZgz@VxUUq7d|(@>#@iy5;yN0KY$L-agXW9J5wzch+W z50=A~Y6W^HZD5c>|BrjvU7t*@jcDa)ldU8AfVEWqSa4E<|o@feLkC zHh};>!y<47IvQ68vAFl|@*yS2cM=t97RuJ2e1xjg)9VS>*Wiq>W55Q7RihUWWAj+O z_$c%(-InQ#7!jz9W$?S0TKa{dlaXe+SI~i~#Cw3(cU4qR)d=e{=Q1JI@QBD-i$wfP zDxfCtB>Nd+RP&<3vP=ZPy(pbN=Nt1iKb1BYw}jACawdhRf2tr3rU|gYs>dEbd0@JI<|z5w2$Ah>(fY#XYQe3X^FL#*5D&5N!9b95)*`tN1Gf{UG}2Wx3XVt@pcArGZdNcD^DH5jV=8snZlo z;q-xqp90A0kABZddGviu?)61c*jN=*Z2;kY_J(HPH{sQo97=UYG#E|a!p-ECqSRlT zN2BEW4uKf!kWFNTmDaFlj;_(s`|jV>AAPlta-P;xdD51T_qTEf^1A<2?)aKnl&0nL z!^OaA8wC+48#n9Kl5I^#-n~}2j>)}c;Nzior!BzcCaL=0T$#9xYlf@#vK8~jIW>Rz zVz2ste|flwn9q^r{jZS}c7g@$MB~@uoFar`gsV11Szxxs=^v6;)+!x`>Tb$OUmJ6^ zcK6XbHD0e3DiEB5CQqaVftlnnz-$GZ^g5A?-9N1Qbb^&ei2c1tSL600iI1l5`ia7y znbEH2807Zr-sehgpw>0=nMEII>-+^(z}M+KX_OgIkzkA$oM8b$I8>y_X7dv9MoL`l zg7f@$K!8|o(5#mDv&Ld%hsKeyDOW>7!`nrDyp>hIAr)u4Z&*aZJ}?id zWGv@OHM^T|MwAm9r;NXK!0^7IH>fz*~3T3Y5NW^%g zD!zmc_-qE&Cn;Xw88=Us9XCZ~hI@|60gA6mvuXlNi!uddrT5fanAP^r6-GeMe^4=l zcZ{RVbmI@GDiKVpGkn)+=$Gc8%z;;3mr~~NvcUHQcA`iHC7`$7n#OamGC?dpV@9QK zACdO=5lOC1pnuB?0p(0Ok*KEtcvRAQrZA4c*5IqS;e-dt zq{Wvx!|Yd*glaFUYD`B7fwtfy5DC+iV8Q3HU?h~IF7nX?f1d0B+3zf-O}FnJz)71s z|I>oIn(WlH`MkQO29=c4H28-~EU!r#hRbho)-fkrmM?=?xIDo| z(1E|NpfjnT%}fI~pbc>}TV$oW!#o;I+YK6+Gw^S7x1HUAUi5YcXF%;r$Q}Pc#}&b9 zxe+}L`S+x z2+Md3JvaLWThJB)9<$jQh-TkZ(v|-C_b`aZVv8RU=7_KvSPffdAwb>p?gfg+lQ8UL z0u7%V8rx{ozXzpf=g}rd3Y5a1(|XzcZWZJ(qb=Mj+pi*hI=hdanRoz)Lwy>zRdgDk zQ?}ISHgEt1yb9QLUnX+6f2Ni6m4cza2{jzfS$k7PVap{xzAQ2N*{xDIDODw>i5uA0 z-G7D5ozN%>f=_OQrhWN77rOJfCGhJ5ukjRKC96U{k$WAS#j(j&skXB~1e9R!O#q9- zBcSRe7GKBC{H}TXQAQ)_D`3CqcWY`J(tdR3wC{4x+oFISOXo>gdc|!=So}ck9#Zlg zp?KuoU$esD38BzxmH>-mASUQDA()22d%{`-o!GI_H0}@|5Ro{Z7Q!aCg^%C2^_2Yg zV&;G)#38@%A!xLv*}@|~58-tRkasVwf~YM1*|6OTr#q%;QSOI#adpD+>rs=~TcOXW z^!T|p0DjNKuBGyi#qABKH7lfzP6oyUoE%c+CeMPwc5@^|^_sDq2q|oPrs>Og2ODdE zC}RM7uA5w_3HBhm5nowNEZ1iV&&Wa!8h<{Qw7&p@tZA5f6>h<9@dTxesHS5)(@@ zdeu)=r=?Q^D|tA?`EB+ zY2*cnJy^ez)W^byg_xIA`xRdU;{*O>9a$%D_SV@isdeuZ!&yii5FmXoN_ z7fz{?D)^yvavh@EPYZwF^ph=T*_YK%8$nmXMHsdPqp8$ShDx5#}`va8$rndu@ z=5FP#iN7J>?hJsZ4}`7@BrDEV6RnaeB>W`>-H7N9!^vLdrtgnlXPtvoL@3#Mw))N_ z+HiQdK7H9dr9pY4!)G_!+pnA}iFe7H=9bM%&JAw?DjU$%o|xe zV$p|wgT&tLLJ%yYw@I!bYN8kRKbAWd-)ydNToY7%?oPz!?aBKx?Hr6t5Sl04)N!{S z=qGG#6a-y?yp#Q0**M_M6q=t}2+*HMqLK`i{iu-45~qHUF4M2gLsZaN;|NuhZ&08I<56?_%38+;FA9HI6J1^`9(WEH#RpS zkUW5RYqf;)k_qJFI@g<` zSC$-1KYmF#0bIYtk8~R(SFkog8?XWJ@#f2Zot!8&!kWGUR%IT~o)JsQNr`KS=aKxV z8IpZtZ;csWVa@QhrHU;9tpY@B*hylf)y&7)#F6a!g6>BQj{L$XO1KiGa=7VsSs})F z+GMT46TWrJcSpRNE3&Ce!2hH5r{f5xDZ!k1{mAa!dTUdweCJ{fV!}3sl%Wq>!)o1n zC3r4gzJ0g6JCgEZ`nSEbBm&SzWWnFy$cJ^8l$Wy|Lmd3ri<8=ELlj6s5#MI#!HQv<`{n@lA!45Sf6mX$oUGltDJ? zH!1!?jzX3$krfC9dFG3$i(FTFEITHA~F zdqxweefk1y<&QrJGt?IUnl@a3Q2%DxGC7C;ZEew;`;s!_;xM1r*n#W@O_R`p8@-fL z<}V7y`!G3}IH5B!T%k0_Sm}i3Ju{$UTO!sO1$q~@IO5SrSys7GF7#1Z$Bg1iFw@@h z@^H?PbMBpsKix1~w4`W=VA`!Xl~!bx(QtO|_`SS%WvJCXXQnlyi-a+xq0JKK*FyR? zZ*O2=-|bpGxb-b?v8}@uy{s}TR{#$WZ>z=>Ni@r1BspSk&X+X{#8^VSJLA>zZ?p3a zlMyvo@(nyN?82SNJ%7S9hl$RIQ$ILY>I;5!@p5q*T%c?HOMkg!QRk(fq@9tXv+7=& zd9fL!IUkQSQLjayzXKed2rtSvnK~$QzO!|75!OnaaQE!?(QTa8@465DTGV})#N{Ts z-Kd@79FsK_;gplbDsXeYM4QjhF<+r?l~|yU{yHdmfBZpbm&YhWrMF;f6c0DyLxFp_ z+lOP?w_pF1YvZQSzGY}8y?-f}RI)_^4q@*gE=vSRJzMSN5^c!#=KC%XquYLoTyn*X zoT*EBv(hd%z$RKYip@Cj#)E&JVY~3ab|UXS?N-kt+jb#RKzzkMQGqk&puPTO&PT65 z@r+3lHDrq!NPIz?H1eh?z1{v2I;780uMjz>#SkN>Uakb{%eT5ze*|&i7*HU*yyayu z8%^bWUgm1}+P`l$>=eF3>WUS~?wtDQzy>I~xSqpIHeNabZ~G$Qo<2YioaRD6(n*!|Wxt~$DuL|)=L$ zut2fGmX_c^xA)BAzkXzzZrjra1}-qjt>RMXBPPfGh`qZ3VOv?hDGsgu%sRfNug%l* z#m62?#qYY^EjiKMMB0U(@QBU7K}@IH>{@v9O3yT83uTI4LJ}NY)+#cs)TDu&OeaAW zd!|Hc)K-WQOo9B;fPSopO4qx776X4Qo@5QhfXmxBw!aZ2&6=-3;5l*>qr#C#r(yf1 zYuaka9cF21aJpYKRxJX>_PcZ?d;mzwC{@0EOsnEDL!|0G0;bT|LQ+xNBz8>y-1JNe z6$kNTV z9VdUpQM(0#Bu&e~x1ta4bBN~3g_M(;_FirOwc60Uy^XMh9SIca>rYDmc)mAO9!euh zC~N<@f}euEYGkgZH=Deii=!qsIMbWP9^=F|t)y)2?>-VDbZE{(XFD1fnEA6?JXuS{#;M2GlLrAsmTxc?AX9`;U_ot-;?^ zVPBkSX6&-|@Pw1=D#9r!un z)ld{AyG3m_Y5ftIt62U7^Ihl{5yZ;iji+^D)<|6$v+rZvNi0B2X zz^9t=;{p?&`z28BvG7YOtc_Q-A%(qG%;SwLxk2(IgNW-f^$i0sVuV;;9W7OVX{t)RtWolRn;ZFrSp1{M zPqDrik+LhE@QFX3NL-^d4{?VwCs9kl|6m}Pvg`3DXrYc3$R!+(&Sb>0+3`h6iDhL* z!7Dn&V8HG?^kpHasp3gf5`Z(NIs9P17o2Lhphn8g%ld7HNm+5A?j_h}hbIUK>tlzxIT0y)XCI$E`RUFQVEjT)cKXgDecd1K$;-{Qlbg)e__6O@iG2N{*Ly0jk7Z@ zw0;Fqzrh(2*`x3`nh_SWwp$qP`W{C2&0Xw=&LZrz8LeWTwO?{z(uermKdS1Y`Y&&0R z1frAR097!4Wl&GL4%7cnh{fMJo0+^hjuqk?WI12ub(|z)EEW2FQY@nDo)I;g_1BKlcqNHVK_IuW;}MrW~A{Ad61 z`*`7&<;E5)<0~24K`@13&Zl-gjsbplj#jm&B#RM008|X*l{X;G&7#cZV=A=O?!gt0 zU59q1bX?GKd*3*7e>l`Q2Q#2PGLQDmtTZ@qgYx(SQSl4ZC?Aa^qw4Tq4-t~aCqI9L z4#t3Ss3{drgzvIFw~!>KX_K5WRdxx`$MqC~u@*tAZFIu-iaX+Zt=ddRSFgo-ih2h8 zG*hlyTQmE$UtaUJ&}FuMVh*$EW-AIU(rGx6aqfGF3#?HO=-G#=Ce5D;fb;sIEC*2s zKAqRWR_C$%QYP=5V;77bX$%-D1Xvdnt&D#y8n=ay%sJ1R5RGsAcbjW!rbY0Ee*<9% zB`UYzISRtDB5mnCm&!p#-Af2So|d32IP{rJh*yJQ@$XA@eeeY(EBO8-m7FQu@rm6T zA;4s2=f-^%_47?S7x$ff=%AdcXtqalDkCCkk5_{S1vlF7>`mFhR4a{6d^flCwsTCM z59^{QFeguVALtlhn-MwgGDN%@ZbytB#ELX0ax$h&IOw3)#l|&wLOLLSXVi-j-l_PgZ z*(#!(xv%h0b0sxlG(6w!zrFVRYp>ty`}us|ClL3<{-k5DV2c%}^B(Mb;*SiL(%^Z% z+L8-UbUdrD=cdt>DR_jCP5Np#IP5{fck1c?K(j$a55dTF})+5NwSNo5T_6)*7TY{|ETmMM= ze9z_{3s*r1W8ss5675SkqI1C8L7FqAu_gpyM~u-0^D;;RI=aUr#zO*H8cRvP4SeDK zpmksXbTRd}cJ3&Kf6KAJgMJ$2@K~VRVJZcVqB9+i=IJq%MhHpqym1#^Ws}3tjCb zoCPX!@Lc*-iBXHyXBUG-HG&@$%|e*PB-l6>NWs#nTa^1c=Ip_ou$>8mTKf@iJ6CYROP{O z;FZ^Mzf>|23e2fY9M1U5HO`VvYJN^gzEd_J1;KYM{U%)QeMX)OGV2RMbA|K;@3IPZ z(IAi+bA#T#>Y{H!7*O#~l_LsqaP+8%{!@K=Y1Pq$5GpzyTQP#RZLj;fTdr!!PYZ+jX*95A5;M#bBu@tvN^ko z#%5-{bzcK2#7wW&o*sg0M1ty!a_R^zSr)?AKSqNyqyk$39$2=z)cuDgW|D>NHq>KW zwX}j1jU<2V5s%&d&T0K)Vlo61GB^O<0fQa2)3`l=$O>rUOOO6M^8@J@l|Z)Y2TopI zZ{D%OE`nR;ue3hP0NrW{!>B2s{`c02SVycO#6e~9Hejwl!7k^E?j%#;SunjBdgKEc z_!~Og7w@olY2`k`t7R&KV|4j>&zm8-V5N=V2D*1s#5xpi+XJ?eW8bj9L(qBKwb|eM zW48DWdb`QHDnM0{0ik29Sllc}By|R2Lb+M$6R_cD)eLBVoImqic;cW1)e2cw(*p56 zA2PV_VAaVosPC7lk>**Eknw}ku_h7|ffj-^<+9OZTt>b+A>lOw8Ugk}7tcXHr?)Z5c| zv~%z6R(G51mk^!5m8NOjQWn6}wACrP$@F(vM_S_-#8gpAh|$Y+ZM?cbAu`?JA}b6M z#VQ$@c=Z9oj+M+m#*)2Aw8NO3VIdWzq8ovymrQ?U&X}#LNlVp-eYaLg%m6gLl(Dsf z%zE~jqJS|AWbNh$@l1l??-wZUsRBVIH{^feJ!0Xu=dK0%*|z;>s0TteVyuwDF#$$4 z+&i#a!$y9fZkP;0FO=y4^?zhnWcSc&Pd)8F^$aj?)4;ky9;@?QXi(A~nFs6m!u}-jh(BsJ`Q_vRL`TEZ zYVi155Ag6a$kJ^DUxA%%r=#Yt~y?%C?^lCJ# z@LlzMczQW&My^(s%GM}Y6|s1|v=GBEwr%#hZ)Azio#F+WU!~lxa4D$3Y`VE@o-Y0q zj9W71r)b-D?`q1iWY*L}nG3nDcISVajsiAnZgxBV2#8oXDmbXBgOBxGcR4IFguE{{ zpKIyPj^5UgSwS2pUR=sx7T(B}siNg-l(VjK{eTZorXJ6#eO0-$)eb>mh^Q^1hP2?MzpL^D!*f5qp-}Gr4u1874x13-;GJ z4@%^SWjqs<`{s+H3)GZvFBK2o>A(_SuK{$nAdP2ttt?6$q&uC*{wBSiEX3p5B2Kwe zd^PX9k0X?YwMcu)_DarGp{rvHt|ZvizHJbH|1E++)^+5j$~N2!8J;U~JOC zI-KG7A!8f7_i9>d1+L{I0)B5?Uj?gFuvnHqr`Rk#|Mjnjh(wo4f#61$0%HB^2va$eaI)+sU$-%`L&|6gu8YY`k!9ZS0bLzMg@z zIV}(D*hTH(E7mzaY9H|T?P12{TYyQoz;*X?*8XQy=wnG+#$a0kC9t;?n5&4edyffv zRNQ1Q_y>l)@AWl;@ZeQwT|xBM*MZS3DeTiRU6VHeDfwdURa9wqPK0?eUW)ODN6F|* zcikRdG3vwyV1nlxm`*ZRpLOz(5>kkCucU#IZf%-;XmR*_m2io%-}ufjn!3llaHoe@giCQz{oMVhq(XfgY`C znn*QnvwVEYfvM~bUk#Pf%6&KG7j{I>+9Gjk60p;jkh=uwLuMBphxt;U^q{AhF0K*t z+NiV2Gt!P#Et)eY@(w2AHiJALN(=q20|q0Gu6^wt30H>DeWTwlFyn{NZdsF;pY4hJ zITneBD$aR;AeV?qP{5*TMv1o|6(>(?1Q#}R5y*l>D%Rj+PZ@Y6RD=-M%X88=ctz+k zp%jG>x>-Q^1yX|mXNci+Wg{LRZgoFX(S6ze$6&7KWfRgfZx*O!4JOUC~O|c7axhsH7m7oiF<$O|TR;P}3-N}@ ze3x>Il{2RyK#tJa6e%H$>+37Bg!(+jL<(BruJ*IA0>vG^SI^lr%4kCS+MTW>Q+ z*+j0Ub6ORXOilE8ayvhGozUf^VHIv}gmv2SIjw&ysr+JR<>@UhlcbeCq>`pAO8b%> zkKhdx=}F}# zr`@fKvD{5nr!oOjSuQ!s%$rUE;DV3&$+voHa-31e+>gJ)+}zFkG5ID-S*XHS5v>2rDuIgmD#FG z+i`lI!teNfg*^jfDaB*BpJVk8HZM;3gvm{M)7i&Hv4XisKRohcVPIpvy!9)v{ViqP zQAM*d0@NdkRE4dCLJFUJbrHMwKp57f8(G<-5C7b!SIA>LxHu><43n(ekpo|D^9-|OQ