From 52400e11a1ac69bcc89dfe5a034df00a4a7f690c Mon Sep 17 00:00:00 2001 From: Noah Stapp Date: Mon, 6 Oct 2025 09:25:57 -0400 Subject: [PATCH 1/4] PYTHON-5571 - Fix memory leak when raising InvalidDocument with C extensions (#2573) --- bson/_cbsonmodule.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bson/_cbsonmodule.c b/bson/_cbsonmodule.c index bee719856..7d184641c 100644 --- a/bson/_cbsonmodule.c +++ b/bson/_cbsonmodule.c @@ -1657,26 +1657,28 @@ void handle_invalid_doc_error(PyObject* dict) { } if (evalue && PyErr_GivenExceptionMatches(etype, InvalidDocument)) { - PyObject *msg = PyObject_Str(evalue); + msg = PyObject_Str(evalue); if (msg) { const char * msg_utf8 = PyUnicode_AsUTF8(msg); if (msg_utf8 == NULL) { goto cleanup; } - PyObject *new_msg = PyUnicode_FromFormat("Invalid document: %s", msg_utf8); + 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 *new_evalue = PyObject_CallFunctionObjArgs(InvalidDocument, new_msg, dict, NULL); + new_evalue = PyObject_CallFunctionObjArgs(InvalidDocument, new_msg, dict, 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); From 16a2fea21928d47ad8c81912bd19ba2768fa9155 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Oct 2025 10:31:00 -0500 Subject: [PATCH 2/4] Bump the actions group with 3 updates (#2574) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Steven Silvester --- .github/workflows/codeql.yml | 4 ++-- .github/workflows/test-python.yml | 16 ++++++++-------- .github/workflows/zizmor.yml | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0c1f2f6d4..b138324bf 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -46,7 +46,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3 + uses: github/codeql-action/init@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # v3 with: languages: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} @@ -63,6 +63,6 @@ jobs: pip install -e . - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3 + uses: github/codeql-action/analyze@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # v3 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 0ed23b9d8..a057570f3 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -26,7 +26,7 @@ jobs: with: persist-credentials: false - name: Install uv - uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v5 + uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6 with: enable-cache: true python-version: "3.10" @@ -68,7 +68,7 @@ jobs: with: persist-credentials: false - name: Install uv - uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v5 + uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6 with: enable-cache: true python-version: ${{ matrix.python-version }} @@ -87,7 +87,7 @@ jobs: with: persist-credentials: false - name: Install uv - uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v5 + uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6 with: enable-cache: true python-version: "3.10" @@ -112,7 +112,7 @@ jobs: with: persist-credentials: false - name: Install uv - uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v5 + uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6 with: enable-cache: true python-version: "3.10" @@ -131,7 +131,7 @@ jobs: with: persist-credentials: false - name: Install uv - uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v5 + uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6 with: enable-cache: true python-version: "3.10" @@ -153,7 +153,7 @@ jobs: with: persist-credentials: false - name: Install uv - uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v5 + uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6 with: enable-cache: true python-version: "${{matrix.python}}" @@ -174,7 +174,7 @@ jobs: with: persist-credentials: false - name: Install uv - uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v5 + uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6 with: enable-cache: true python-version: "3.10" @@ -264,7 +264,7 @@ jobs: with: persist-credentials: false - name: Install uv - uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 # v5 + uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6 with: python-version: "3.10" - id: setup-mongodb diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml index a3eb5d550..c991de2e6 100644 --- a/.github/workflows/zizmor.yml +++ b/.github/workflows/zizmor.yml @@ -18,4 +18,4 @@ jobs: with: persist-credentials: false - name: Run zizmor 🌈 - uses: zizmorcore/zizmor-action@0696496a48b64e0568faa46ddaf5f6fe48b83b04 + uses: zizmorcore/zizmor-action@da5ac40c5419dcf7f21630fb2f95e725ae8fb9d5 From 406bed041832a4371a8b933c57daf1e99a009b98 Mon Sep 17 00:00:00 2001 From: "Jeffrey A. Clark" Date: Mon, 6 Oct 2025 13:10:31 -0400 Subject: [PATCH 3/4] PYTHON-5597 Upgrade to macos-latest (#2578) --- .github/workflows/dist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index acbfc6cfe..84bf1ba89 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -99,7 +99,7 @@ jobs: make_sdist: name: Make SDist - runs-on: macos-13 + runs-on: macos-latest steps: - uses: actions/checkout@v5 with: From 46974363b4bd42405c7a8f3285997f9688094440 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Oct 2025 13:02:53 -0500 Subject: [PATCH 4/4] PYTHON-5538 Fix lock file handling and bump pyright from 1.1.405 to 1.1.406 (#2575) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Steven Silvester --- .evergreen/scripts/setup-dev-env.sh | 5 +++++ pyproject.toml | 2 +- uv.lock | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.evergreen/scripts/setup-dev-env.sh b/.evergreen/scripts/setup-dev-env.sh index 1204848e7..209857d54 100755 --- a/.evergreen/scripts/setup-dev-env.sh +++ b/.evergreen/scripts/setup-dev-env.sh @@ -7,6 +7,11 @@ HERE="$( cd -- "$HERE" > /dev/null 2>&1 && pwd )" ROOT=$(dirname "$(dirname $HERE)") pushd $ROOT > /dev/null +# Bail early if running on GitHub Actions. +if [ -n "${GITHUB_ACTION:-}" ]; then + exit 0 +fi + # Source the env files to pick up common variables. if [ -f $HERE/env.sh ]; then . $HERE/env.sh diff --git a/pyproject.toml b/pyproject.toml index b06e6401a..623eb6c16 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ mockupdb = [ perf = ["simplejson>=3.17.0"] typing = [ "mypy==1.18.2", - "pyright==1.1.405", + "pyright==1.1.406", "typing_extensions", "pip" ] diff --git a/uv.lock b/uv.lock index 273a7b6ad..480f64c26 100644 --- a/uv.lock +++ b/uv.lock @@ -1199,7 +1199,7 @@ pip = [{ name = "pip" }] typing = [ { name = "mypy", specifier = "==1.18.2" }, { name = "pip" }, - { name = "pyright", specifier = "==1.1.405" }, + { name = "pyright", specifier = "==1.1.406" }, { name = "typing-extensions" }, ] @@ -1249,15 +1249,15 @@ wheels = [ [[package]] name = "pyright" -version = "1.1.405" +version = "1.1.406" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "nodeenv" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/fb/6c/ba4bbee22e76af700ea593a1d8701e3225080956753bee9750dcc25e2649/pyright-1.1.405.tar.gz", hash = "sha256:5c2a30e1037af27eb463a1cc0b9f6d65fec48478ccf092c1ac28385a15c55763", size = 4068319, upload-time = "2025-09-04T03:37:06.776Z" } +sdist = { url = "https://files.pythonhosted.org/packages/f7/16/6b4fbdd1fef59a0292cbb99f790b44983e390321eccbc5921b4d161da5d1/pyright-1.1.406.tar.gz", hash = "sha256:c4872bc58c9643dac09e8a2e74d472c62036910b3bd37a32813989ef7576ea2c", size = 4113151, upload-time = "2025-10-02T01:04:45.488Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/d5/1a/524f832e1ff1962a22a1accc775ca7b143ba2e9f5924bb6749dce566784a/pyright-1.1.405-py3-none-any.whl", hash = "sha256:a2cb13700b5508ce8e5d4546034cb7ea4aedb60215c6c33f56cec7f53996035a", size = 5905038, upload-time = "2025-09-04T03:37:04.913Z" }, + { url = "https://files.pythonhosted.org/packages/f6/a2/e309afbb459f50507103793aaef85ca4348b66814c86bc73908bdeb66d12/pyright-1.1.406-py3-none-any.whl", hash = "sha256:1d81fb43c2407bf566e97e57abb01c811973fdb21b2df8df59f870f688bdca71", size = 5980982, upload-time = "2025-10-02T01:04:43.137Z" }, ] [[package]]