🐛 Handle .decode possibly applied to None

This commit is contained in:
Renato Alves
2023-07-07 00:18:01 +02:00
parent 914fc85596
commit 2c61b27e67

View File

@@ -401,7 +401,10 @@ class NSSProxy:
# Transparently handle decoding to string when returning a c_char_p
if restype == ct.c_char_p:
def _decode(result, func, *args):
return result.decode(DEFAULT_ENCODING)
try:
return result.decode(DEFAULT_ENCODING)
except AttributeError:
return result
res.errcheck = _decode
setattr(self, "_" + name, res)