diff options
author | Martin Pool <mbp@samba.org> | 2002-11-05 21:26:35 +0000 |
---|---|---|
committer | Martin Pool <mbp@samba.org> | 2002-11-05 21:26:35 +0000 |
commit | d7eac6c356879d31823750de3a3d8611c622340d (patch) | |
tree | 8a9812458aa205c9fb533b6c8667c18d1bd416d8 /source3/python | |
parent | 17356de9211fdcf49a54ebfa143c3c9519a74edf (diff) | |
download | samba-d7eac6c356879d31823750de3a3d8611c622340d.tar.gz samba-d7eac6c356879d31823750de3a3d8611c622340d.tar.bz2 samba-d7eac6c356879d31823750de3a3d8611c622340d.zip |
pytdbpack_pack_data: Allow first argument to be any kind of Number,
not just an Integer. Coerce appropriately.
(This used to be commit 248067931a2a8eeee86ea343bddf96d2bd727dbf)
Diffstat (limited to 'source3/python')
-rw-r--r-- | source3/python/py_tdbpack.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c index 1b3cbbceea..d29ada6741 100644 --- a/source3/python/py_tdbpack.c +++ b/source3/python/py_tdbpack.c @@ -661,14 +661,20 @@ pytdbpack_pack_data(const char *format_str, long size; char *sval; - if (!PyInt_Check(val_obj)) { - pytdbpack_bad_type(ch, "Integer", val_obj); + if (!PyNumber_Check(val_obj)) { + pytdbpack_bad_type(ch, "Number", val_obj); return NULL; } - size = PyInt_AsLong(val_obj); + if (!(val_obj = PyNumber_Long(val_obj))) + return NULL; + + size = PyLong_AsLong(val_obj); pack_uint32(size, &packed); + /* Release the new reference created by the cast */ + Py_DECREF(val_obj); + val_obj = PySequence_GetItem(val_seq, val_i++); if (!val_obj) return NULL; |