PyMongo 4.20.0 is now available on PyPI. Install or upgrade with:
python -m pip install --upgrade pymongo
Highlights
Coding agent detection in handshake metadata
The client handshake metadata now reports a detected coding agent in client.env.agent. This helps
server-side telemetry identify AI-assisted clients (PYTHON-5929).
Query types out of preview
The beta query types QueryType.PREFIXPREVIEW, QueryType.SUFFIXPREVIEW, and QueryType.SUBSTRINGPREVIEW
are removed. Use the stable QueryType.PREFIX, QueryType.SUFFIX, and QueryType.SUBSTRING members
instead. These require MongoDB 9.0 or later and pymongocrypt 1.21.0 or later (PYTHON-5959).
String options replace text options
The deprecated text_opts parameter of ClientEncryption.encrypt and AsyncClientEncryption.encrypt is
removed, along with the TextOpts class. Use string_opts and StringOpts instead (PYTHON-5959).
Bug fixes
- Fixed a disagreement between the C extension and the pure-Python BSON decoders for binary elements with
UUID subtypes 3 and 4 when the payload is not 16 bytes (PYTHON-6172). - Fixed a
ValueErrorraised byMongoClient(maxPoolSize=0, minPoolSize>0). Both0andNonenow mean
unlimited (PYTHON-6149). ObjectIdnow rejects 24-character strings that contain whitespace, andObjectId.is_validreturns
Falsefor them (PYTHON-5873).- Fixed the type annotation of the
letargument ofCursorandAsyncCursortoOptional[Mapping[str, Any]](PYTHON-6145). - Disabled TLS session reuse on Python 3.11 because of a CPython memory leak. Users of Python 3.12 and 3.13
should upgrade to 3.12.7 and 3.13.1 or later (PYTHON-6182). - Fixed a bug where
AsyncMongoClientcould not recover after a replica set member removed itself from the
topology (PYTHON-6226). - Fixed undefined behavior in the C extension’s BSON buffer growth past 1 GiB (PYTHON-6252).
Resources
Thank you to everyone who contributed to this release. Report issues on
GitHub or in the MongoDB Community
Forums.