s4:libcli: Fix conversion from HRESULT and WERROR to Python objects
commitf86d65117ba0c964c64fb58b5a6845561156819c
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Fri, 8 Dec 2023 02:58:32 +0000 (8 15:58 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 21 Dec 2023 20:21:34 +0000 (21 20:21 +0000)
tree2a9ba9c90e59ca4ae15990d5068286363af7cb99
parent1e67be78554b7692c96e9cfb1352f436b16be6b5
s4:libcli: Fix conversion from HRESULT and WERROR to Python objects

The inner values of HRESULT and WERROR are 32‐bit unsigned integers,
which might not be representable in type ‘int’. We must then use the ‘k’
format specifier, which corresponds to ‘unsigned long’, a type
guaranteed to be at least 32 bits in size.

Commit c81aff362fe99a65385c6f8337ffcb47c9456829 fixed
PyErr_FromNTSTATUS(), but it did not attempt to fix the other cases.

PyErr_FromHRESULT() might return a tuple like this:
(-2147024809, 'One or more arguments are invalid.')

which, after this commit, will become this:
(2147942487, 'One or more arguments are invalid.')

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/libcli/util/pyerrors.h