NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI, #362 most downloaded on PyPI
PyMongo - the Official MongoDB Python driver
Latest stable
4.20.1
Last release 3 days ago
19 Nov 2026
Release timing varies
gaps range from 8 days to 4 months
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
18 years old
177 releases · first in 2009
Drag across the ruler to compare, or tap a release to open it.
Release notes: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=54018
Version 4.20.1 is a bug fix release.
Fixed a bug where getMore commands in load-balanced mode were not retried when the server returned a retryable overload error (PYTHON-6262).
Fixed a bug where a cancelled async command published a CommandStartedEvent (and its "Command started" log message) without a correlating CommandFailedEvent. A cancellation now publishes the failure before the CancelledError propagates (PYTHON-6187).
Sanitize parsing error messages. (PYTHON-6058)
Improved credential validation. (PYTHON-6073)
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-20-0-released/344893
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 ~pymongo.encryption.QueryType.PREFIX, ~pymongo.encryption.QueryType.SUFFIX, and ~pymongo.encryption.QueryType.SUBSTRING instead (requires MongoDB 9.0+ and pymongocrypt 1.21.0+) (PYTHON-5959).
Removed the deprecated text_opts parameter of ~pymongo.encryption.ClientEncryption.encrypt and ~pymongo.asynchronous.encryption.AsyncClientEncryption.encrypt, and the TextOpts class. Use string_opts and ~pymongo.encryption_options.StringOpts instead (PYTHON-5959).
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 ~bson.binary.Binary under the default UNSPECIFIED UUID representation, and raise ~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 ~bson.objectid.ObjectId accepted a 24-character string containing whitespace and created an ObjectId shorter than 12 bytes from it. It now raises ~bson.errors.InvalidId, and ~bson.objectid.ObjectId.is_valid returns False for such a string (PYTHON-5873).
Fixed the type annotation of the let argument of ~pymongo.cursor.Cursor and ~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).
See the PyMongo 4.20.0 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=52147
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 ~pymongo.encryption_options.AutoEncryptionOpts, ~pymongo.encryption.ClientEncryption, and ~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 ~pymongo.encryption_options.HTTPProxyKMSConnect or ~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 ~pymongo.synchronous.mongo_client.MongoClient and ~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 ~pymongo.synchronous.mongo_client.MongoClient and ~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.
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 ~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).
~pymongo.driver_info.DriverInfo now raises 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).
See the PyMongo 4.19.0 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-18-3-released/344145
Version 4.18.3 is a bug fix release.
Hardened BSON regex decoding against malformed documents (PYTHON-6110).
See the PyMongo 4.18.3 release notes in JIRA for the list of resolved issues in this release.
CVE-2026-96749 CVE-2026-96748 CVE-2026-96747
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-18-2-released/343732
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).
See the PyMongo 4.18.2 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-18-1-released/343338
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-18-1-released/343338
Version 4.18.1 is a bug fix release.
Use an exact match for the file ID in GridFS delete methods (CVE-2026-88029).
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-18-released/343137
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-18-released/343137
PyMongo 4.18 brings a number of changes including:
Added srvAllowedHostsSuffix as a URI option and keyword argument to ~pymongo.synchronous.mongo_client.MongoClient and ~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 ~pymongo.synchronous.mongo_client.MongoClient and ~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 (~pymongo.cursor.CursorType.EXHAUST) against mongos 7.1+. An older mongos still raises ~pymongo.errors.InvalidOperation, now on the first iteration of the cursor rather than from ~pymongo.synchronous.collection.Collection.find, since the requirement is checked against the connection in use. Separately, async cursors combining limit with ~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 ~pymongo.synchronous.mongo_client.MongoClient and ~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 ~bson.raw_bson.RawBSONDocument. Documents and subdocuments that are 4KB or greater and decoded from an immutable buffer are now exposed as read-only memoryview slices instead of bytes copies. Documents decoded from mutable buffers such as a bytearray are always bytes copies.
bson.get_data_and_view now returns a view of a private bytes copy for buffer-protocol inputs other than bytes or bytearray.
Improved the performance of lazily decoding a ~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 ~bson.errors.InvalidBSON instead of reading past the end of the buffer.
Fixed 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 ~pymongo.encryption.Algorithm.STRING and ~pymongo.encryption_options.StringOpts, replacing Algorithm.TEXTPREVIEW and TextOpts, which are now deprecated.
Added ~pymongo.encryption.QueryType.PREFIX, ~pymongo.encryption.QueryType.SUFFIX, and ~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 ~pymongo.encryption.ClientEncryption.encrypt and ~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 ~pymongo.errors.ConfigurationError.
Aggregation helpers now raise ~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 ~pymongo.asynchronous.collection.AsyncCollection.aggregate and ~pymongo.synchronous.collection.Collection.aggregate, ~pymongo.asynchronous.collection.AsyncCollection.aggregate_raw_batches and ~pymongo.synchronous.collection.Collection.aggregate_raw_batches, ~pymongo.asynchronous.database.AsyncDatabase.aggregate and ~pymongo.synchronous.database.Database.aggregate, and ~pymongo.asynchronous.collection.AsyncCollection.list_search_indexes and ~pymongo.synchronous.collection.Collection.list_search_indexes.
PYTHON-5757 Deprecate Python 2 methods in SON by @aclark4life in #2732
Full Changelog: 4.16.0...4.17.0
Full Changelog: https://github.com/mongodb/mongo-python-driver/compare/4.16.0...4.17.0
PyMongo 4.17 brings a number of changes including:
has_key, iterkeys and itervalues in 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 ~pymongo.asynchronous.client_session.AsyncClientSession.bind and ~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.
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 _.
PyMongo 4.16 brings a number of changes including:
Removed invalid documents from bson.errors.InvalidDocument error messages as doing so may leak sensitive user data. Instead, invalid documents are stored in 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 ~pymongo.asynchronous.collection.AsyncCollection and ~pymongo.synchronous.collection.Collection to include None.
Added support for NumPy 1D-arrays in bson.binary.BinaryVector.
Prevented ~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.
Nothing published for this version
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-15-5-released/332185
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.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-15-4-released/331292
Version 4.15.4 is a bug fix release.
Relaxed the callback type of ~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.
See the PyMongo 4.15.4 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-15-3-released/329778
Version 4.15.3 is a bug fix release.
Fixed a memory leak when raising bson.errors.InvalidDocument with C extensions.
Fixed the return type of the ~pymongo.asynchronous.collection.AsyncCollection.distinct, ~pymongo.synchronous.collection.Collection.distinct, pymongo.asynchronous.cursor.AsyncCursor.distinct, and pymongo.asynchronous.cursor.AsyncCursor.distinct methods.
See the PyMongo 4.15.3 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-15-2-released/329543
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.
See the PyMongo 4.15.2 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-15-1-released/328837
Version 4.15.1 is a bug fix release.
Fixed a bug in ~pymongo.synchronous.encryption.ClientEncryption.encrypt and ~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.
See the PyMongo 4.15.1 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-15-released/328574
PyMongo 4.15 brings a number of changes including:
Added ~pymongo.encryption_options.TextOpts, ~pymongo.encryption.Algorithm.TEXTPREVIEW, ~pymongo.encryption.QueryType.PREFIXPREVIEW, ~pymongo.encryption.QueryType.SUFFIXPREVIEW, ~pymongo.encryption.QueryType.SUBSTRINGPREVIEW, as part of the experimental Queryable Encryption text queries beta. pymongocrypt>=1.16 is required for text query support.
Added bson.decimal128.DecimalEncoder and 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.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-14-1-released/327511
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.
See the PyMongo 4.14.1 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-14-released/326906
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-14-released/326906
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 bson.codec_options.TypeRegistry.codecs and bson.codec_options.TypeRegistry.fallback_encoder properties to allow users to directly access the type codecs and fallback encoder for a given bson.codec_options.TypeRegistry.
Added pymongo.asynchronous.mongo_client.AsyncMongoClient.append_metadata and 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 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 ~pymongo.uri_parser.parse_uri's options return value to be type dict instead of _CaseInsensitiveDictionary.
See the PyMongo 4.14 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-13-2-released/323705
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-13-2-released/323705
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.
See the PyMongo 4.13.2 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-13-1-released/323356
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-13-1-released/323356
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.
See the PyMongo 4.13.1 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-13-0-released/321391.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-13-0-released/321391.
PyMongo 4.13 brings a number of changes including:
The asynchronous API is now stable and no longer in beta. See the pymongo.asynchronous docs or the migration guide for more information.
Fixed a bug where 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.
See the PyMongo 4.13 release notes in JIRA for the list of resolved issues in this release.
Nothing published for this version
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-12-1-released/320326
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-12-1-released/320326
Full Changelog: https://github.com/mongodb/mongo-python-driver/compare/4.12.0...4.12.1
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'".
See the PyMongo 4.12.1 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-12-released/318187
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-12-released/318187
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 ~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 gridfs.asynchronous.grid_file.AsyncGridFSBucket.rename_by_name and gridfs.grid_file.GridFSBucket.rename_by_name for more performant renaming of a file with multiple revisions.
Added gridfs.asynchronous.grid_file.AsyncGridFSBucket.delete_by_name and 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 ~pymongo.asynchronous.collection.AsyncCollection.distinct and ~pymongo.collection.Collection.distinct commands.
Deprecated the hedge parameter for ~pymongo.read_preferences.PrimaryPreferred, ~pymongo.read_preferences.Secondary, ~pymongo.read_preferences.SecondaryPreferred, ~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.
See the PyMongo 4.12 release notes in JIRA for the list of resolved issues in this release.
PYTHON-5202 WaitQueueTimeoutError should not clear the pool (#2192) [v4.11] by @mongodb-drivers-pr-bot in https://github.com/mongodb/mongo-python-driv
Full Changelog: https://github.com/mongodb/mongo-python-driver/compare/4.11.2...4.11.3
PYTHON-5166 Allow Database.command to run bulkWrite commands (#2164) [v4.11] by @ShaneHarvey in https://github.com/mongodb/mongo-python-driver/pull/21
Community notes: <link>
Full Changelog: https://github.com/mongodb/mongo-python-driver/compare/4.11.1...4.11.2
Version 4.11.2 is a bug fix release.
Fixed a bug where ~pymongo.database.Database.command would fail when attempting to run the bulkWrite command.
See the PyMongo 4.11.2 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-11-1-released/312193
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-11-1-released/312193
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-11-released/310976
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-11-released/310976
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).
~pymongo.asynchronous.mongo_client.AsyncMongoClient.address and ~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 repr support to pymongo.operations.IndexModel.
Added repr support to pymongo.operations.SearchIndexModel.
Added sort parameter to ~pymongo.collection.Collection.update_one, ~pymongo.collection.Collection.replace_one, ~pymongo.operations.UpdateOne, and ~pymongo.operations.UpdateMany,
~pymongo.mongo_client.MongoClient.bulk_write and ~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 bson.json_util.dumps where a 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 bson.json_util.loads would raise an IndexError when parsing an invalid "$date" instead of a ValueError.
See the PyMongo 4.11 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-10-1-released/299573
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-10-1-released/299573
Version 4.10.1 is a bug fix release.
Fixed a bug where ~pymongo.results.UpdateResult.did_upsert would raise a TypeError.
Fixed Binary BSON subtype (9) support on big-endian operating systems (such as zSeries).
See the PyMongo 4.10.1 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-10-0-released/299474
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-10-0-released/299474
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 ~bson.binary.Binary.from_vector and ~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 ~pymongo.asynchronous.mongo_client.AsyncMongoClient could deadlock.
Fixed a bug where PyMongo could fail to import on Windows if asyncio is misconfigured.
See the PyMongo 4.10 release notes in JIRA for the list of resolved issues in this release.
Fixed a bug where pymongo.asynchronous.mongo_client.AsyncMongoClient could deadlock.
pymongo.asynchronous.mongo_client.AsyncMongoClient could deadlock.pymongo.results.UpdateResult.did_upsert would raise a TypeError.Fixed a bug where ~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 ~pymongo.results.UpdateResult.did_upsert would raise a TypeError.
See the PyMongo 4.9.2 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-9-released/297833
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-9-released/297833
Add missing documentation about the fact the async API is in beta state.
See the PyMongo 4.9.1 release notes in JIRA for the list of resolved issues in this release.
.. 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
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 ~pymongo.encryption.Algorithm.RANGE. sparsity and trim_factor are now optional in ~pymongo.encryption_options.RangeOpts.
Added support for the "delegated" option for the KMIP master_key in ~pymongo.encryption.ClientEncryption.create_data_key.
pymongocrypt>=1.10 is now required for In-Use Encryption support.
Added ~pymongo.cursor.Cursor.to_list to ~pymongo.cursor.Cursor, ~pymongo.command_cursor.CommandCursor, ~pymongo.asynchronous.cursor.AsyncCursor, and ~pymongo.asynchronous.command_cursor.AsyncCommandCursor as an asynchronous-friendly alternative to list(cursor).
Added ~pymongo.mongo_client.MongoClient.bulk_write to ~pymongo.mongo_client.MongoClient and ~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 ~pymongo.operations.InsertOne, ~pymongo.operations.ReplaceOne, ~pymongo.operations.UpdateOne, ~pymongo.operations.UpdateMany, ~pymongo.operations.DeleteOne, and ~pymongo.operations.DeleteMany operations, so they can be used in the new ~pymongo.mongo_client.MongoClient.bulk_write.
Added repr support to bson.tz_util.FixedOffset.
Fixed a bug where PyMongo would raise InvalidBSON: unhashable type: 'tzfile' when using ~bson.codec_options.DatetimeConversion.DATETIME_CLAMP or ~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 ~bson.codec_options.DatetimeConversion.DATETIME_CLAMP or ~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:
sys:1: ResourceWarning: Unclosed MongoClient opened at:
File "/Users/<user>/my_file.py", line 8, in <module>``
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.
See the PyMongo 4.9 release notes in JIRA for the list of resolved issues in this release.
PyMongo 4.8 brings a number of improvements including:
PyMongo 4.8 brings a number of improvements including:
bson.binary.Binary is now redacted when the subtype is SENSITIVE_SUBTYPE(8).startAtOperationTime and resumeToken
could be added to a retry attempt, which caused the retry to fail.ssl module when pyopenssl import fails with AttributeError.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.See the PyMongo 4.8 release notes in JIRA for the list of resolved issues in this release.
Full Changelog: https://github.com/mongodb/mongo-python-driver/compare/4.7.1...4.8.0
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.
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.
See the PyMongo 4.8 release notes in JIRA for the list of resolved issues in this release.
Nothing published for this version
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-7-3-released/283508
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-7-3-released/283508
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.
See the PyMongo 4.7.3 release notes in JIRA for the list of resolved issues in this release.
Community Notes: https://www.mongodb.com/community/forums/t/pymongo-4-7-2-released/279584
Community Notes: https://www.mongodb.com/community/forums/t/pymongo-4-7-2-released/279584
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.
See the PyMongo 4.7.2 release notes in JIRA for the list of resolved issues in this release.
Community release note: https://www.mongodb.com/community/forums/t/pymongo-4-7-1-released/278459
Community release note: https://www.mongodb.com/community/forums/t/pymongo-4-7-1-released/278459
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.
See the PyMongo 4.7.1 release notes in JIRA for the list of resolved issues in this release.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-7-0-released/277656
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-7-0-released/277656
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 ~pymongo.encryption_options.AutoEncryptionOpts. Note that named KMS providers requires pymongocrypt >=1.9 and libmongocrypt >=1.9.
Added the pymongo.hello.Hello.connection_id, pymongo.monitoring.CommandStartedEvent.server_connection_id, pymongo.monitoring.CommandSucceededEvent.server_connection_id, and pymongo.monitoring.CommandFailedEvent.server_connection_id properties.
Fixed a bug where inflating a ~bson.raw_bson.RawBSONDocument containing a ~bson.code.Code would cause an error.
~pymongo.encryption.ClientEncryption.encrypt and ~pymongo.encryption.ClientEncryption.encrypt_expression now allow key_id to be passed in as a uuid.UUID.
Fixed a bug where ~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)
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 pymongo.monitoring.ConnectionCheckedOutEvent.duration, pymongo.monitoring.ConnectionCheckOutFailedEvent.duration, and pymongo.monitoring.ConnectionReadyEvent.duration properties.
Added the type and kwargs arguments to ~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 ~pymongo.collection.Collection.list_search_indexes queries.
Deprecated pymongo.write_concern.WriteConcern.wtimeout and pymongo.mongo_client.MongoClient.wTimeoutMS. Use ~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.
Replaced usage of bson.son.SON on all internal classes and commands to dict, options.pool_options.metadata is now of type dict as opposed to bson.son.SON. Here's some examples of how this changes expected output as well as how to convert from dict to 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.
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-6-3-release-for-cve-2024-5629/284348
Community notes: https://www.mongodb.com/community/forums/t/pymongo-4-6-3-release-for-cve-2024-5629/284348
PyMongo 4.6.3 fixes the following bug:
Fixed a potential memory access violation when decoding invalid bson.
See the PyMongo 4.6.3 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-6-2-released/267404
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-6-2-released/267404
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.
See the PyMongo 4.6.2 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-6-1-released/255752
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-6-1-released/255752
PyMongo 4.6.1 fixes the following bug:
Ensure retryable read OperationFailure errors re-raise exception when 0 or NoneType error code is provided.
See the PyMongo 4.6.1 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-6-0-released/251866
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-6-0-released/251866
PyMongo 4.6 brings a number of improvements including:
Added the serverMonitoringMode URI and keyword argument to ~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 pymongo.monitoring.CommandSucceededEvent.database_name property.
Added the pymongo.monitoring.CommandFailedEvent.database_name property.
Allow passing a dict to sort/create_index/hint.
Added repr support to the write result classes: ~pymongo.results.BulkWriteResult, ~pymongo.results.DeleteResult, ~pymongo.results.InsertManyResult, ~pymongo.results.InsertOneResult, ~pymongo.results.UpdateResult, and ~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)
~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.
See the PyMongo 4.6 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-5-0-released/240662
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-5-0-released/240662
PyMongo 4.5 brings a number of improvements including:
Added new helper methods for Atlas Search Index (requires MongoDB Server 7.0+): ~pymongo.collection.Collection.list_search_indexes, ~pymongo.collection.Collection.create_search_index, ~pymongo.collection.Collection.create_search_indexes, ~pymongo.collection.Collection.drop_search_index, ~pymongo.collection.Collection.update_search_index
Added ~pymongo.database.Database.cursor_command and ~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+.
See the PyMongo 4.5 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-4-1-released/235045
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-4-1-released/235045
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).
See the PyMongo 4.4.1 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-4-released/232211
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-4-released/232211
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 ~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 ~pymongo.encryption.ClientEncryption.create_encrypted_collection, ~pymongo.errors.EncryptedCollectionError, ~pymongo.encryption.ClientEncryption.encrypt_expression, ~pymongo.encryption_options.RangeOpts, and ~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 datetime.datetime.utcnow and datetime.datetime.utcfromtimestamp. utcnow and utcfromtimestamp are deprecated in Python 3.12, for reasons explained in this Github issue. Instead, users should use datetime.datetime.now(tz=timezone.utc) and datetime.datetime.fromtimestamp(tz=timezone.utc) instead.
See the PyMongo 4.4 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-4-0b0-release/210471
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-4-0b0-release/210471
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-3-3-release/200145
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-3-3-release/200145
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 pymongo.timeout.
Fixed a performance regression in ~gridfs.GridFSBucket.download_to_stream and ~gridfs.GridFSBucket.download_to_stream_by_name by reading in chunks instead of line by line (PYTHON-3502).
Improved performance of gridfs.grid_file.GridOut.read and gridfs.grid_file.GridOut.readline (PYTHON-3508).
See the PyMongo 4.3.3 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-3-2-released/194266
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-3-2-released/194266
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 ~datetime.datetime builtin. See handling out of range datetimes for examples, as well as bson.datetime_ms.DatetimeMS, bson.codec_options.DatetimeConversion, and 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 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+, ~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 ~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.
Fixed a bug where ~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).
See the PyMongo 4.3 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-2-0-released/176012
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-2-0-released/176012
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 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 ~pymongo.mongo_client.MongoClient.
Added the pymongo.errors.PyMongoError.timeout property which is True when the error was caused by a timeout.
Added the check_exists argument to ~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 ~pymongo.encryption.ClientEncryption:
~pymongo.encryption.ClientEncryption.get_key
~pymongo.encryption.ClientEncryption.get_keys
~pymongo.encryption.ClientEncryption.delete_key
~pymongo.encryption.ClientEncryption.add_key_alt_name
~pymongo.encryption.ClientEncryption.get_key_by_alt_name
~pymongo.encryption.ClientEncryption.remove_key_alt_name
~pymongo.encryption.ClientEncryption.rewrap_many_data_key
~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 ~pymongo.encryption_options.AutoEncryptionOpts.
Fixed a bug where ~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 ~bson.regex.Regex objects. bson.encode now correctly raises 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 ~pymongo.collection.Collection.count_documents and ~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 ~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).
pymongocrypt 1.3.0 or later is now required for client side field level encryption support.
~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 pymongo.server_api.ServerApi.strict to False to avoid encountering errors (PYTHON-3167).
Removed generic typing from ~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).
See the PyMongo 4.2 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-1-1-released/157895
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-1-1-released/157895
Version 4.1.1 fixes a number of bugs:
Fixed a memory leak bug when calling ~bson.decode_all without a codec_options argument (PYTHON-3222).
Fixed a bug where ~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).
See the PyMongo 4.1.1 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-1-0-released/156029
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-1-0-released/156029
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 ~pymongo.collection.Collection.insert_one.
Added support for the let parameter to ~pymongo.collection.Collection.update_one, ~pymongo.collection.Collection.update_many, ~pymongo.collection.Collection.delete_one, ~pymongo.collection.Collection.delete_many, ~pymongo.collection.Collection.replace_one, ~pymongo.collection.Collection.aggregate, ~pymongo.collection.Collection.find_one_and_delete, ~pymongo.collection.Collection.find_one_and_replace, ~pymongo.collection.Collection.find_one_and_update, ~pymongo.collection.Collection.find, ~pymongo.collection.Collection.find_one, and ~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.
~pymongo.collection.Collection.aggregate now supports $merge and $out executing on secondaries on MongoDB >=5.0. aggregate() now always obeys the collection's read_preference on MongoDB >= 5.0.
gridfs.grid_file.GridOut.seek now returns the new position in the file, to conform to the behavior of io.IOBase.seek.
Improved reuse of implicit sessions (PYTHON-2956).
Fixed bug that would cause SDAM heartbeat timeouts and connection churn on AWS Lambda and other FaaS environments (PYTHON-3186).
Fixed bug where ~pymongo.mongo_client.MongoClient, ~pymongo.database.Database, and ~pymongo.collection.Collection mistakenly implemented typing.Iterable (PYTHON-3084).
See the PyMongo 4.1 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-0-2-released/150457
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-0-2-released/150457
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-0-1-released/135979
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-0-1-released/135979
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-0-released/134677
Release notes: https://www.mongodb.com/community/forums/t/pymongo-4-0-released/134677
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 ~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: 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 migrate-to-pymongo4 before upgrading from PyMongo 3.x.
Removed support for Python 2.7, 3.4, and 3.5. Python 3.6.2+ is now required.
The default uuid_representation for ~bson.codec_options.CodecOptions, ~bson.json_util.JSONOptions, and ~pymongo.mongo_client.MongoClient has been changed from bson.binary.UuidRepresentation.PYTHON_LEGACY to bson.binary.UuidRepresentation.UNSPECIFIED. Attempting to encode a uuid.UUID instance to BSON or JSON now produces an error by default. See UUID representations for details.
Removed the waitQueueMultiple keyword argument to ~pymongo.mongo_client.MongoClient and removed pymongo.errors.ExceededMaxWaiters.
Removed the socketKeepAlive keyword argument to ~pymongo.mongo_client.MongoClient.
Removed pymongo.mongo_client.MongoClient.fsync, pymongo.mongo_client.MongoClient.unlock, and pymongo.mongo_client.MongoClient.is_locked.
Removed pymongo.mongo_client.MongoClient.database_names.
Removed pymongo.mongo_client.MongoClient.max_bson_size.
Removed pymongo.mongo_client.MongoClient.max_message_size.
Removed pymongo.mongo_client.MongoClient.max_write_batch_size.
Removed pymongo.mongo_client.MongoClient.event_listeners.
Removed pymongo.mongo_client.MongoClient.max_pool_size.
Removed pymongo.mongo_client.MongoClient.max_idle_time_ms.
Removed pymongo.mongo_client.MongoClient.local_threshold_ms.
Removed pymongo.mongo_client.MongoClient.server_selection_timeout.
Removed pymongo.mongo_client.MongoClient.retry_writes.
Removed pymongo.mongo_client.MongoClient.retry_reads.
Removed pymongo.database.Database.eval, pymongo.database.Database.system_js and pymongo.database.SystemJS.
Removed pymongo.database.Database.collection_names.
Removed pymongo.database.Database.current_op.
Removed pymongo.database.Database.authenticate and pymongo.database.Database.logout.
Removed pymongo.database.Database.error, pymongo.database.Database.last_status, pymongo.database.Database.previous_error, pymongo.database.Database.reset_error_history.
Removed pymongo.database.Database.add_user and pymongo.database.Database.remove_user.
Removed support for database profiler helpers ~pymongo.database.Database.profiling_level, ~pymongo.database.Database.set_profiling_level, and ~pymongo.database.Database.profiling_info. Instead, users should run the `profile command`_ with the ~pymongo.database.Database.command helper directly.
Removed pymongo.OFF, pymongo.SLOW_ONLY, and pymongo.ALL.
Removed pymongo.collection.Collection.parallel_scan.
Removed pymongo.collection.Collection.ensure_index.
Removed pymongo.collection.Collection.reindex.
Removed pymongo.collection.Collection.save.
Removed pymongo.collection.Collection.insert.
Removed pymongo.collection.Collection.update.
Removed pymongo.collection.Collection.remove.
Removed pymongo.collection.Collection.find_and_modify.
Removed pymongo.collection.Collection.count.
Removed pymongo.collection.Collection.initialize_ordered_bulk_op, pymongo.collection.Collection.initialize_unordered_bulk_op, and pymongo.bulk.BulkOperationBuilder. Use pymongo.collection.Collection.bulk_write instead.
Removed pymongo.collection.Collection.group.
Removed pymongo.collection.Collection.map_reduce and pymongo.collection.Collection.inline_map_reduce.
Removed the useCursor option for ~pymongo.collection.Collection.aggregate.
Removed pymongo.mongo_client.MongoClient.close_cursor. Use pymongo.cursor.Cursor.close instead.
Removed pymongo.mongo_client.MongoClient.kill_cursors.
Removed pymongo.cursor_manager.CursorManager and pymongo.cursor_manager.
Removed pymongo.mongo_client.MongoClient.set_cursor_manager.
Removed pymongo.cursor.Cursor.count.
Removed pymongo.thread_util.
Removed ~pymongo.mongo_replica_set_client.MongoReplicaSetClient.
Removed ~pymongo.ismaster.IsMaster. Use ~pymongo.hello.Hello instead.
Removed pymongo.son_manipulator, pymongo.son_manipulator.SONManipulator, pymongo.son_manipulator.ObjectIdInjector, pymongo.son_manipulator.ObjectIdShuffler, pymongo.son_manipulator.AutoReference, pymongo.son_manipulator.NamespaceInjector, pymongo.database.Database.add_son_manipulator, pymongo.database.Database.outgoing_copying_manipulators, pymongo.database.Database.outgoing_manipulators, pymongo.database.Database.incoming_copying_manipulators, and pymongo.database.Database.incoming_manipulators.
Removed the manipulate and modifiers parameters from ~pymongo.collection.Collection.find, ~pymongo.collection.Collection.find_one, ~pymongo.collection.Collection.find_raw_batches, and ~pymongo.cursor.Cursor.
Removed pymongo.message.delete, pymongo.message.get_more, pymongo.message.insert, pymongo.message.kill_cursors, pymongo.message.query, and pymongo.message.update.
Removed pymongo.errors.NotMasterError. Use pymongo.errors.NotPrimaryError instead.
Removed pymongo.errors.CertificateError.
Removed pymongo.GEOHAYSTACK.
Removed bson.binary.UUIDLegacy.
Removed bson.json_util.STRICT_JSON_OPTIONS. Use ~bson.json_util.RELAXED_JSON_OPTIONS or ~bson.json_util.CANONICAL_JSON_OPTIONS instead.
Changed the default JSON encoding representation from legacy to relaxed. The json_mode parameter for bson.json_util.dumps now defaults to ~bson.json_util.RELAXED_JSON_OPTIONS.
Changed the BSON and JSON decoding behavior of ~bson.dbref.DBRef to match the behavior outlined in the DBRef specification version 1.0. Specifically, PyMongo now only decodes a subdocument into a ~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 ~bson.dbref.DBRef.
The "tls" install extra is no longer necessary or supported and will be ignored by pip.
The tz_aware argument to ~bson.json_util.JSONOptions now defaults to False instead of True. bson.json_util.loads now decodes datetime as naive by default. See tz_aware_default_change for more info.
directConnection URI option and keyword argument to ~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 ~pymongo.collection.Collection.find.
name is now a required argument for the pymongo.driver_info.DriverInfo class.
When providing a "mongodb+srv://" URI to ~pymongo.mongo_client.MongoClient constructor you can now use the srvServiceName URI option to specify your own SRV service name.
~bson.son.SON.items now returns a dict_items object rather than a list.
Removed bson.son.SON.iteritems.
~pymongo.collection.Collection and ~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.
~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 ~bson.int64.Int64, ~bson.min_key.MinKey, ~bson.max_key.MaxKey, ~bson.timestamp.Timestamp, ~bson.regex.Regex, and ~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 ~pymongo.collection.Collection.find, and ~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.
~pymongo.mongo_client.MongoClient now raises a ~pymongo.errors.ConfigurationError when more than one URI is passed into the hosts argument.
~pymongo.mongo_client.MongoClient` now raises an ~pymongo.errors.InvalidURI exception when it encounters unescaped percent signs in username and password when parsing MongoDB URIs.
Comparing two ~pymongo.mongo_client.MongoClient instances now uses a set of immutable properties rather than ~pymongo.mongo_client.MongoClient.address which can change.
Removed the disable_md5 parameter for ~gridfs.GridFSBucket and ~gridfs.GridFS. See removed-gridfs-checksum for details.
pymongocrypt 1.2.0 or later is now required for client side field level encryption support.
Enhanced connection pooling to create connections more efficiently and avoid connection storms.
Added the maxConnecting URI and ~pymongo.mongo_client.MongoClient keyword argument.
~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 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 ~pymongo.encryption_options.AutoEncryptionOpts and ~pymongo.encryption.
See the PyMongo 4.0 release notes in JIRA for the list of resolved issues in this release.
Release notes https://www.mongodb.com/community/forums/t/pymongo-3-13-0-released/197141
Release notes https://www.mongodb.com/community/forums/t/pymongo-3-13-0-released/197141
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.
Added pymongo.mongo_client.MongoClient.options for read-only access to a client's configuration options.
PyMongo 3.13 drops support for Python 3.4.
Fixed a memory leak bug when calling ~bson.decode_all without a codec_options argument (PYTHON-3222).
Fixed a bug where ~bson.decode_all did not accept codec_options as a keyword argument (PYTHON-3222).
Deprecated ~pymongo.collection.Collection.map_reduce and ~pymongo.collection.Collection.inline_map_reduce. Use ~pymongo.collection.Collection.aggregate instead.
Deprecated pymongo.mongo_client.MongoClient.event_listeners. Use ~pymongo.mongo_client.options.event_listeners instead.
Deprecated pymongo.mongo_client.MongoClient.max_pool_size. Use ~pymongo.mongo_client.options.pool_options.max_pool_size instead.
Deprecated pymongo.mongo_client.MongoClient.max_idle_time_ms. Use ~pymongo.mongo_client.options.pool_options.max_idle_time_seconds instead.
Deprecated pymongo.mongo_client.MongoClient.local_threshold_ms. Use ~pymongo.mongo_client.options.local_threshold_ms instead.
Deprecated pymongo.mongo_client.MongoClient.server_selection_timeout. Use ~pymongo.mongo_client.options.server_selection_timeout instead.
Deprecated pymongo.mongo_client.MongoClient.retry_writes. Use ~pymongo.mongo_client.options.retry_writes instead.
Deprecated pymongo.mongo_client.MongoClient.retry_reads. Use ~pymongo.mongo_client.options.retry_reads instead.
Deprecated pymongo.mongo_client.MongoClient.max_bson_size, pymongo.mongo_client.MongoClient.max_message_size, and 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']
See the PyMongo 3.13.0 release notes in JIRA for the list of resolved issues in this release.
Release notes: https://www.mongodb.com/community/forums/t/pymongo-3-12-3-released/135978
Release notes: https://www.mongodb.com/community/forums/t/pymongo-3-12-3-released/135978
Version 3.12.3 fixes a bug that prevented 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.
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.
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.
Release notes: https://developer.mongodb.com/community/forums/t/pymongo-3-12-0-released/115111/
Release notes: https://developer.mongodb.com/community/forums/t/pymongo-3-12-0-released/115111/
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 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.
Added support for MongoDB 5.0.
Support for MongoDB Stable API, see ~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 ~pymongo.mongo_client.MongoClient, ~pymongo.encryption_options.AutoEncryptionOpts, and ~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 ~pymongo.database.Database.create_collection.
Added pymongo.mongo_client.MongoClient.topology_description.
Added hash support to ~pymongo.mongo_client.MongoClient, ~pymongo.database.Database and ~pymongo.collection.Collection (PYTHON-2466).
Improved the error message returned by ~pymongo.collection.Collection.insert_many when supplied with an argument of incorrect type (PYTHON-1690).
Added session and read concern support to ~pymongo.collection.Collection.find_raw_batches and ~pymongo.collection.Collection.aggregate_raw_batches.
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 ~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 ~pymongo.cursor.RawBatchCursor that caused it to return an empty bytestring when the cursor contained no results. It now raises StopIteration instead.
Deprecated support for Python 2.7, 3.4 and 3.5.
Deprecated support for database profiler helpers ~pymongo.database.Database.profiling_level, ~pymongo.database.Database.set_profiling_level, and ~pymongo.database.Database.profiling_info. Instead, users should run the profile command with the ~pymongo.database.Database.command helper directly.
Deprecated ~pymongo.errors.NotMasterError. Users should use ~pymongo.errors.NotPrimaryError instead.
Deprecated ~pymongo.ismaster.IsMaster and ~pymongo.ismaster which will be removed in PyMongo 4.0 and are replaced by ~pymongo.hello.Hello and ~pymongo.hello which provide the same API.
Deprecated the pymongo.messeage module.
Deprecated the ssl_keyfile and ssl_certfile URI options in favor of tlsCertificateKeyFile (see TLS).
See the PyMongo 3.12.0 release notes in JIRA for the list of resolved issues in this release.
One column per quarter.