diff --git a/pymongo/asynchronous/encryption.py b/pymongo/asynchronous/encryption.py index b302631108..662f2abd5b 100644 --- a/pymongo/asynchronous/encryption.py +++ b/pymongo/asynchronous/encryption.py @@ -935,7 +935,8 @@ async def _encrypt_helper( contention_factor=contention_factor, range_opts=range_opts_bytes, is_expression=is_expression, - text_opts=text_opts_bytes, + # For compatibility with pymongocrypt < 1.16: + **{"text_opts": text_opts_bytes} if text_opts_bytes else {}, ) return decode(encrypted_doc)["v"] diff --git a/pymongo/synchronous/encryption.py b/pymongo/synchronous/encryption.py index 752026af84..518a16ff2d 100644 --- a/pymongo/synchronous/encryption.py +++ b/pymongo/synchronous/encryption.py @@ -928,7 +928,8 @@ def _encrypt_helper( contention_factor=contention_factor, range_opts=range_opts_bytes, is_expression=is_expression, - text_opts=text_opts_bytes, + # For compatibility with pymongocrypt < 1.16: + **{"text_opts": text_opts_bytes} if text_opts_bytes else {}, ) return decode(encrypted_doc)["v"]