diff --git a/bson/binary.py b/bson/binary.py index be33464462..5fe1bacd16 100644 --- a/bson/binary.py +++ b/bson/binary.py @@ -364,4 +364,7 @@ def __ne__(self, other: Any) -> bool: return not self == other def __repr__(self) -> str: - return f"Binary({bytes.__repr__(self)}, {self.__subtype})" + if self.__subtype == SENSITIVE_SUBTYPE: + return f"" + else: + return f"Binary({bytes.__repr__(self)}, {self.__subtype})" diff --git a/doc/changelog.rst b/doc/changelog.rst index c9d1a927c4..28dd7cff54 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -6,6 +6,8 @@ Changes in Version 4.8.0 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). + .. warning:: PyMongo 4.8 drops support for Python 3.7 and PyPy 3.8: Python 3.8+ or PyPy 3.9+ is now required. Changes in Version 4.7.2 diff --git a/doc/contributors.rst b/doc/contributors.rst index d7f1030322..49fb2d844d 100644 --- a/doc/contributors.rst +++ b/doc/contributors.rst @@ -100,3 +100,4 @@ The following is a list of people who have contributed to - Stephan Hof (stephan-hof) - Casey Clements (caseyclements) - Ivan Lukyanchikov (ilukyanchikov) +- Terry Patterson