From 3f9dac69487fc046b1bcc1730b3c22128311ad8c Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 4 Nov 2002 23:08:53 +0000 Subject: pytdbpack_pack_data: Allow 'd' and 'w' formats to take either Integer or Long arguments. (This used to be commit 2085595565b99295d04a6663aad1ccac5bc1b657) --- source3/python/py_tdbpack.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c index 526e187f75..446a2e5480 100644 --- a/source3/python/py_tdbpack.c +++ b/source3/python/py_tdbpack.c @@ -588,14 +588,32 @@ pytdbpack_pack_data(const char *format_str, return NULL; if (ch == 'w') { - unsigned long val_long = PyInt_AsLong(val_obj); + unsigned long val_long; + PyObject *long_obj; + + if (!(long_obj = PyNumber_Long(val_obj))) { + pytdbpack_bad_type(ch, "Long", val_obj); + return NULL; + } + + val_long = PyLong_AsUnsignedLong(long_obj); (packed)[0] = val_long & 0xff; (packed)[1] = (val_long >> 8) & 0xff; (packed) += 2; + Py_DECREF(long_obj); } else if (ch == 'd') { /* 4-byte LE number */ - pack_uint32(PyInt_AsLong(val_obj), &packed); + PyObject *long_obj; + + if (!(long_obj = PyNumber_Long(val_obj))) { + pytdbpack_bad_type(ch, "Long", val_obj); + return NULL; + } + + pack_uint32(PyLong_AsUnsignedLong(long_obj), &packed); + + Py_DECREF(long_obj); } else if (ch == 'p') { /* "Pointer" value -- in the subset of DCERPC used by Samba, -- cgit