diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-03-13 11:34:40 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-03-13 11:34:40 (GMT) |
commit | d59b41641e7f800a65f4241d05710b774cafa04f (patch) | |
tree | 1a859128a25416a27c391421f9cdae3676c240e3 /Modules/_testcapimodule.c | |
parent | fe427fee6c77f2a2b8c7c1ad0fec14d8638a9db0 (diff) | |
download | cpython-d59b41641e7f800a65f4241d05710b774cafa04f.zip cpython-d59b41641e7f800a65f4241d05710b774cafa04f.tar.gz cpython-d59b41641e7f800a65f4241d05710b774cafa04f.tar.bz2 |
Issue #8014: Fix PyLong_As<c-integer-type> methods not to produce an
internal error on non-integer input: they now raise TypeError instead.
This is needed for attributes declared via PyMemberDefs.
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 3824388..1be3c66 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -2084,6 +2084,7 @@ typedef struct { unsigned int uint_member; long long_member; unsigned long ulong_member; + Py_ssize_t pyssizet_member; float float_member; double double_member; #ifdef HAVE_LONG_LONG @@ -2107,6 +2108,7 @@ static struct PyMemberDef test_members[] = { {"T_UINT", T_UINT, offsetof(test_structmembers, structmembers.uint_member), 0, NULL}, {"T_LONG", T_LONG, offsetof(test_structmembers, structmembers.long_member), 0, NULL}, {"T_ULONG", T_ULONG, offsetof(test_structmembers, structmembers.ulong_member), 0, NULL}, + {"T_PYSSIZET", T_PYSSIZET, offsetof(test_structmembers, structmembers.pyssizet_member), 0, NULL}, {"T_FLOAT", T_FLOAT, offsetof(test_structmembers, structmembers.float_member), 0, NULL}, {"T_DOUBLE", T_DOUBLE, offsetof(test_structmembers, structmembers.double_member), 0, NULL}, #ifdef HAVE_LONG_LONG @@ -2122,13 +2124,13 @@ test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { static char *keywords[] = { "T_BOOL", "T_BYTE", "T_UBYTE", "T_SHORT", "T_USHORT", - "T_INT", "T_UINT", "T_LONG", "T_ULONG", + "T_INT", "T_UINT", "T_LONG", "T_ULONG", "T_PYSSIZET", "T_FLOAT", "T_DOUBLE", -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG "T_LONGLONG", "T_ULONGLONG", #endif NULL}; - static char *fmt = "|bbBhHiIlkfd" + static char *fmt = "|bbBhHiIlknfd" #ifdef HAVE_LONG_LONG "LK" #endif @@ -2145,9 +2147,10 @@ test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) &ob->structmembers.short_member, &ob->structmembers.ushort_member, &ob->structmembers.int_member, - &ob->structmembers.uint_member, + &ob->structmembers.uint_member, &ob->structmembers.long_member, &ob->structmembers.ulong_member, + &ob->structmembers.pyssizet_member, &ob->structmembers.float_member, &ob->structmembers.double_member #ifdef HAVE_LONG_LONG |