]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python:ndr: Use f-string to format exception message
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 13 Mar 2023 22:50:17 +0000 (11:50 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 20 Mar 2023 00:22:32 +0000 (00:22 +0000)
If 'object' happened to be a tuple, we would get one of the following
errors:

TypeError: not enough arguments for format string
TypeError: not all arguments converted during string formatting

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/ndr.py

index 35b2414e8ae3f253aa06e00423580e0288e05239..314e57b7f8e8e6b744a68c314743cc27cbf0df93 100644 (file)
@@ -52,7 +52,7 @@ def ndr_unpack(cls, data, allow_remaining=False):
 def ndr_print(object):
     ndr_print = getattr(object, "__ndr_print__", None)
     if ndr_print is None:
-        raise TypeError("%r is not a NDR object" % object)
+        raise TypeError(f"{object} is not a NDR object")
     return ndr_print()