Skip to content

Commit c34594d

Browse files
committed
Merge branch 'master' of github.com:mongodb/mongo-python-driver into PYTHON-5157
2 parents d54bcc3 + 8927cfe commit c34594d

21 files changed

+731
-58
lines changed

.evergreen/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ functions:
262262
params:
263263
include_expansions_in_env: [AUTH, SSL, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
264264
AWS_SESSION_TOKEN, COVERAGE, PYTHON_BINARY, LIBMONGOCRYPT_URL, MONGODB_URI,
265-
DISABLE_TEST_COMMANDS, GREEN_FRAMEWORK, NO_EXT, COMPRESSORS, MONGODB_API_VERSION]
265+
DISABLE_TEST_COMMANDS, GREEN_FRAMEWORK, NO_EXT, COMPRESSORS, MONGODB_API_VERSION, DEBUG_LOG]
266266
binary: bash
267267
working_dir: "src"
268268
args: [.evergreen/just.sh, setup-tests, "${TEST_NAME}", "${SUB_TEST_NAME}"]

.evergreen/run-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ fi
3838
PIP_QUIET=0 uv run ${UV_ARGS} --with pip pip list
3939

4040
# Start the test runner.
41-
uv run ${UV_ARGS} .evergreen/scripts/run_tests.py
41+
uv run ${UV_ARGS} .evergreen/scripts/run_tests.py "$@"
4242

4343
popd

.evergreen/scripts/run_tests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import json
4+
import logging
45
import os
56
import platform
67
import shutil
@@ -111,8 +112,11 @@ def run() -> None:
111112
run_command(f"{DRIVERS_TOOLS}/.evergreen/auth_aws/aws_setup.sh ecs")
112113
return
113114

115+
if os.environ.get("DEBUG_LOG"):
116+
TEST_ARGS.extend(f"-o log_cli_level={logging.DEBUG} -o log_cli=1".split())
117+
114118
# Run local tests.
115-
ret = pytest.main(TEST_ARGS)
119+
ret = pytest.main(TEST_ARGS + sys.argv[:1])
116120
if ret != 0:
117121
sys.exit(ret)
118122

.evergreen/scripts/setup_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
)
2727

2828
# Passthrough environment variables.
29-
PASS_THROUGH_ENV = ["GREEN_FRAMEWORK", "NO_EXT", "MONGODB_API_VERSION"]
29+
PASS_THROUGH_ENV = ["GREEN_FRAMEWORK", "NO_EXT", "MONGODB_API_VERSION", "DEBUG_LOG"]
3030

3131
# Map the test name to a test suite.
3232
TEST_SUITE_MAP = {

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ repos:
66
- id: check-added-large-files
77
- id: check-case-conflict
88
- id: check-toml
9+
- id: check-json
910
- id: check-yaml
1011
exclude: template.yaml
1112
- id: debug-statements

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ the pages will re-render and the browser will automatically refresh.
224224
- Run the tests with `just run-tests`.
225225
- When done, run `just teardown-tests` to clean up.
226226

227+
## Enable Debug Logs
228+
- Use `-o log_cli_level="DEBUG" -o log_cli=1` with `just test` or `pytest`.
229+
- Add `log_cli_level = "DEBUG` and `log_cli = 1` to the `tool.pytest.ini_options` section in `pyproject.toml` for Evergreen patches or to enable debug logs by default on your machine.
230+
- You can also set `DEBUG_LOG=1` and run either `just setup-tests` or `just-test`.
231+
- For evergreen patch builds, you can use `evergreen patch --param DEBUG_LOG=1` to enable debug logs for the patch.
232+
227233
## Re-sync Spec Tests
228234

229235
If you would like to re-sync the copy of the specification tests in the

bson/binary.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,10 @@ def from_vector(
450450
raise ValueError(f"padding does not apply to {dtype=}")
451451
elif dtype == BinaryVectorDtype.PACKED_BIT: # pack ints in [0, 255] as unsigned uint8
452452
format_str = "B"
453+
if 0 <= padding > 7:
454+
raise ValueError(f"{padding=}. It must be in [0,1, ..7].")
455+
if padding and not vector:
456+
raise ValueError("Empty vector with non-zero padding.")
453457
elif dtype == BinaryVectorDtype.FLOAT32: # pack floats as float32
454458
format_str = "f"
455459
if padding:

doc/changelog.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ PyMongo 4.9 brings a number of improvements including:
199199
unction-as-a-service (FaaS) like AWS Lambda, Google Cloud Functions, and Microsoft Azure Functions.
200200
On some FaaS systems, there is a ``fork()`` operation at function
201201
startup. By delaying the connection to the first operation, we avoid a deadlock. See
202-
`Is PyMongo Fork-Safe`_ for more information.
202+
:ref:`pymongo-fork-safe` for more information.
203203

204204

205205
Issues Resolved
@@ -208,7 +208,6 @@ Issues Resolved
208208
See the `PyMongo 4.9 release notes in JIRA`_ for the list of resolved issues
209209
in this release.
210210

211-
.. _Is PyMongo Fork-Safe: https://www.mongodb.com/docs/languages/python/pymongo-driver/current/troubleshooting/#forking-a-process-causes-a-deadlock
212211
.. _PyMongo 4.9 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=39940
213212

214213

pymongo/asynchronous/topology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ async def open(self) -> None:
236236
warnings.warn( # type: ignore[call-overload] # noqa: B028
237237
"AsyncMongoClient opened before fork. May not be entirely fork-safe, "
238238
"proceed with caution. See PyMongo's documentation for details: "
239-
"https://www.mongodb.com/docs/languages/python/pymongo-driver/current/troubleshooting/#forking-a-process-causes-a-deadlock",
239+
"https://dochub.mongodb.org/core/pymongo-fork-deadlock",
240240
**kwargs,
241241
)
242242
async with self._lock:

pymongo/synchronous/topology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def open(self) -> None:
236236
warnings.warn( # type: ignore[call-overload] # noqa: B028
237237
"MongoClient opened before fork. May not be entirely fork-safe, "
238238
"proceed with caution. See PyMongo's documentation for details: "
239-
"https://www.mongodb.com/docs/languages/python/pymongo-driver/current/troubleshooting/#forking-a-process-causes-a-deadlock",
239+
"https://dochub.mongodb.org/core/pymongo-fork-deadlock",
240240
**kwargs,
241241
)
242242
with self._lock:

0 commit comments

Comments
 (0)