diff --git a/bson/__init__.py b/bson/__init__.py index 8f8d58562..972b18401 100644 --- a/bson/__init__.py +++ b/bson/__init__.py @@ -663,9 +663,8 @@ def _make_c_string(string: Union[str, bytes]) -> bytes: def _make_name(string: str) -> bytes: """Make a 'C' string suitable for a BSON key.""" - # Keys can only be text in python 3. if "\x00" in string: - raise InvalidDocument("BSON keys / regex patterns must not contain a NUL character") + raise InvalidDocument("BSON keys must not contain a NUL character") return _utf_8_encode(string)[0] + b"\x00" diff --git a/bson/_cbsonmodule.c b/bson/_cbsonmodule.c index 9fcb1b9e3..3fce1f9d7 100644 --- a/bson/_cbsonmodule.c +++ b/bson/_cbsonmodule.c @@ -3211,7 +3211,6 @@ PyInit__cbson(void) (void *) buffer_write_int32_at_position; _cbson_API[_cbson_downcast_and_check_INDEX] = (void *) _downcast_and_check; - /* PyCapsule is new in python 3.1 */ c_api_object = PyCapsule_New((void *) _cbson_API, "_cbson._C_API", NULL); if (c_api_object == NULL) INITERROR; diff --git a/bson/binary.py b/bson/binary.py index 77e3a3d47..9a0c06138 100644 --- a/bson/binary.py +++ b/bson/binary.py @@ -197,12 +197,11 @@ class Binary(bytes): what should be considered a string when we encode to BSON. Raises TypeError if `data` is not an instance of :class:`bytes` - (:class:`str` in python 2) or `subtype` is not an instance of - :class:`int`. Raises ValueError if `subtype` is not in [0, 256). + or `subtype` is not an instance of :class:`int`. + Raises ValueError if `subtype` is not in [0, 256). .. note:: - In python 3 instances of Binary with subtype 0 will be decoded - directly to :class:`bytes`. + Instances of Binary with subtype 0 will be decoded directly to :class:`bytes`. :Parameters: - `data`: the binary data to represent. Can be any bytes-like type diff --git a/pymongo/auth.py b/pymongo/auth.py index b4d04f8d1..b41e88542 100644 --- a/pymongo/auth.py +++ b/pymongo/auth.py @@ -189,7 +189,7 @@ def _build_credentials_tuple( def _xor(fir: bytes, sec: bytes) -> bytes: - """XOR two byte strings together (python 3.x).""" + """XOR two byte strings together.""" return b"".join([bytes([x ^ y]) for x, y in zip(fir, sec)]) diff --git a/pymongo/mongo_client.py b/pymongo/mongo_client.py index 96b5a5158..c8a265622 100644 --- a/pymongo/mongo_client.py +++ b/pymongo/mongo_client.py @@ -518,12 +518,11 @@ class MongoClient(common.BaseObject, Generic[_DocumentType]): - `tlsCertificateKeyFile`: A file containing the client certificate and private key. Implies ``tls=True``. Defaults to ``None``. - `tlsCRLFile`: A file containing a PEM or DER formatted - certificate revocation list. Only supported by python 2.7.9+ - (pypy 2.5.1+). Implies ``tls=True``. Defaults to ``None``. + certificate revocation list. Implies ``tls=True``. Defaults to + ``None``. - `tlsCertificateKeyFilePassword`: The password or passphrase for decrypting the private key in ``tlsCertificateKeyFile``. Only - necessary if the private key is encrypted. Only supported by - python 2.7.9+ (pypy 2.5.1+) and 3.3+. Defaults to ``None``. + necessary if the private key is encrypted. Defaults to ``None``. - `tlsDisableOCSPEndpointCheck`: (boolean) If ``True``, disables certificate revocation status checking via the OCSP responder specified on the server certificate. diff --git a/test/test_bson.py b/test/test_bson.py index 12fbea92f..bde0e0815 100644 --- a/test/test_bson.py +++ b/test/test_bson.py @@ -529,8 +529,8 @@ class TestBSON(unittest.TestCase): def test_bytes_as_keys(self): doc = {b"foo": "bar"} # Since `bytes` are stored as Binary you can't use them - # as keys in python 3.x. Using binary data as a key makes - # no sense in BSON anyway and little sense in python. + # as keys. Using binary data as a key makes no sense in BSON + # anyway and little sense in python. self.assertRaises(InvalidDocument, encode, doc) def test_datetime_encode_decode(self):