# What changed in pymongo

> 19 changes in pymongo 4 from its official release notes, upgrade guides and advisories: 3 breaking, 2 deprecations, 4 security, 1 new APIs and options. Each one cited. Sources checked 2026-10-22. HTML: https://unstale.sh/pypi/pymongo/

To see which of these apply to a repository, run `npx @unstale/cli init` in it.

## pymongo 4

### Breaking changes

- Client-side field level encryption now rejects KMS endpoints ending in .sock. (4.18.2) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.2), [security advisory](https://github.com/advisories/GHSA-QX36-8MW2-4R3X)
- Support for MongoDB 4.2 was dropped. (4.18.0) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.0)
- Server selection deprioritization now applies only to overload errors on replica sets. (4.17.0) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.17.0)

### Security

- The release notes reference CVE-2026-106435 but provide no details about the security change. (4.18.3) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.3)
- PyMongo: PYTHON-5986 Host injection in PyMongo connection string parsing via percent-encoded delimiters (4.18.2) — [security advisory](https://github.com/advisories/GHSA-VP6J-J7W5-5XJJ), [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.2)
- PyMongo: PYTHON-5996 Heap out-of-bounds write via signed size overflow in BSON document encoding (4.18.2) — [security advisory](https://github.com/advisories/GHSA-V4X9-3549-CRWV), [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.2)
- GridFS delete_many now matches the file ID exactly, fixing inexact matches. (4.18.1) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.1), [security advisory](https://github.com/advisories/GHSA-8FVV-FGR5-F8CH)

### Deprecations

- PyPy support is deprecated and will be removed in a future release. (4.18.0) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.0)
- Python 2 methods in SON are deprecated. (4.17.0) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.17.0)

### New APIs and options

- Added as a URI option and MongoClient keyword argument; for mongodb+srv:// connections, it allows SRV-returned hosts under a different domain suffix, provided the suffix is not a public suffix. (4.18.0) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.0)

### Performance

- Improved MongoDB 9.0’s IWM performance by retrying overload errors only when doing so is not expected to worsen server conditions. (4.18.0) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.0)
- TLS sessions are reused across connections to the same server to improve connection performance. (4.18.0) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.0)
- BSON encoding and decoding performance improvements may benefit applications that process BSON data. (4.17.0) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.17.0)

### Behavior and default changes

- General availability support was added for prefix, suffix, and substring queries against MongoDB 9.0+; requires libmongocrypt 1.20.0 or later. (4.18.0) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.0)
- Simple collation is now included in index information. (4.17.0) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.17.0)
- The callback type now accepts the broader Awaitable type rather than only Coroutine objects. (4.15.4) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.15.4)

### Fixes and other changes

- Added support for MongoDB 9.0. (4.18.0) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.18.0)
- The sessions API was improved; the notes do not specify the details. (4.17.0) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.17.0)
- Fixes a bug that could cause AutoReconnect("connection pool paused") errors when cursors fetched more documents after SDAM heartbeat failures. (4.15.5) — [release notes](https://github.com/mongodb/mongo-python-driver/releases/tag/4.15.5)
