We are pleased to announce the 4.18.0 release of PyMongo - MongoDB’s Python Driver.
Changes in 4.19.0
PyMongo 4.19 brings a number of changes including:
-
Added support for Python 3.15.
-
Dropped support for Python 3.9 and 3.10.
-
Removed support for PyPy.
-
Removed the deprecated
Algorithm.RANGEPREVIEWandQueryType.RANGEPREVIEWmembers (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_callbackoption 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 customCONNECTheaders, e.g.Proxy-Authorizationfor proxies that require authentication. -
Added the
srv_host_validatorkeyword argument to :class:`~pymongo.synchronous.mongo_client.MongoClient` and :class:`~pymongo.asynchronous.mongo_client.AsyncMongoClient`, an alternative tosrvAllowedHostsSuffixfor 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:Trueto accept the host andFalseto 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 withsrvAllowedHostsSuffixand, 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. -
srvAllowedHostsSuffixmay now be set to a single label reserved for private or special use, such aslocalhost,test, orinternal.
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()andAsyncMongoClient.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.nameanddriver.versionin the handshake metadata are now|-delimited lists with 1:1 index correspondence, including empty version entries for the built-in|cand|asyncname segments (PYTHON-6040). -
Fixed a bug where truncating the handshake metadata to 512 bytes could leave
driver.nameanddriver.versionwith 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 raisingInvalidBSON, now matching the C extension (PYTHON-6163).
Issues Resolved
See the PyMongo 4.19.0 release notes in JIRA for the list of resolved issues in this release.