summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pool <mbp@samba.org>2002-11-05 21:26:35 +0000
committerMartin Pool <mbp@samba.org>2002-11-05 21:26:35 +0000
commitd7eac6c356879d31823750de3a3d8611c622340d (patch)
tree8a9812458aa205c9fb533b6c8667c18d1bd416d8
parent17356de9211fdcf49a54ebfa143c3c9519a74edf (diff)
downloadsamba-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)
-rw-r--r--source3/python/py_tdbpack.c12
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;