From c56f478ded33e58f2f5733d56e8ed27d7eb15e4b Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 4 Nov 2002 20:22:03 +0000 Subject: pytdbpack_calc_reqd_len: Make exception be thrown correctly when a non-string is used with a string format code. (It was being generated but not thrown.) Also call checked versions of some functions rather than FAST_* versions. (This used to be commit 1b681bd524764deaef657ef41c39d037ac7dcc7b) --- source3/python/py_tdbpack.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/python/py_tdbpack.c') diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c index 06aebe61eb..95a74b00c6 100644 --- a/source3/python/py_tdbpack.c +++ b/source3/python/py_tdbpack.c @@ -293,7 +293,9 @@ pytdbpack_calc_reqd_len(char *format_str, int val_i; int val_len; - val_len = PySequence_Fast_GET_SIZE(val_seq); + val_len = PySequence_Length(val_seq); + if (val_len == -1) + return -1; for (p = format_str, val_i = 0; *p; p++, val_i++) { char ch = *p; @@ -307,7 +309,7 @@ pytdbpack_calc_reqd_len(char *format_str, } /* borrow a reference to the item */ - val_obj = PySequence_Fast_GET_ITEM(val_seq, val_i); + val_obj = PySequence_GetItem(val_seq, val_i); if (!val_obj) return -1; @@ -371,6 +373,7 @@ pytdbpack_calc_item_len(char ch, /* nul-terminated 8-bit string */ if (!PyString_Check(val_obj)) { pytdbpack_bad_type(ch, "String", val_obj); + return -1; } if (ch == 'B') { -- cgit