You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this results in TypeError: __str__ returned non-string (type bytes)
a simple fix that works for both py2 and 3 is to append .decode() as shown to ensure a string representation is returned for both versions.
class_LazyHexFormatter(object):
""" This is used to avoid calling binascii.hexlify() on data given to log.debug() calls unless debug is active (for example). Like:: self.log.debug( "Some data: {octets}", octets=_LazyHexFormatter(os.urandom(32)), ) """__slots__= ('obj',)
def__init__(self, obj):
self.obj=objdef__str__(self):
returnbinascii.hexlify(self.obj).decode()
The text was updated successfully, but these errors were encountered:
this results in
TypeError: __str__ returned non-string (type bytes)
a simple fix that works for both py2 and 3 is to append .decode() as shown to ensure a string representation is returned for both versions.
The text was updated successfully, but these errors were encountered: