summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-04-03 01:40:24 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-04-03 01:40:24 (GMT)
commit80d8fd85a932ad6ec66922f41078965bd94bf645 (patch)
tree46337d278e20eb5cd5024b0153ce667fd1aa64e9 /Modules/_testcapimodule.c
parenta811c16a261b9ec1718960d6acc90fad55e612af (diff)
downloadcpython-80d8fd85a932ad6ec66922f41078965bd94bf645.zip
cpython-80d8fd85a932ad6ec66922f41078965bd94bf645.tar.gz
cpython-80d8fd85a932ad6ec66922f41078965bd94bf645.tar.bz2
Merged revisions 79642,79644 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r79642 | benjamin.peterson | 2010-04-02 20:08:34 -0500 (Fri, 02 Apr 2010) | 1 line split out large test function ........ r79644 | benjamin.peterson | 2010-04-02 20:28:57 -0500 (Fri, 02 Apr 2010) | 1 line give TypeError when trying to set T_STRING_INPLACE ........
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 1be3c66..87f9d8b 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -2087,6 +2087,7 @@ typedef struct {
Py_ssize_t pyssizet_member;
float float_member;
double double_member;
+ char inplace_member[5];
#ifdef HAVE_LONG_LONG
PY_LONG_LONG longlong_member;
unsigned PY_LONG_LONG ulonglong_member;
@@ -2111,6 +2112,7 @@ static struct PyMemberDef test_members[] = {
{"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},
+ {"T_STRING_INPLACE", T_STRING_INPLACE, offsetof(test_structmembers, structmembers.inplace_member), 0, NULL},
#ifdef HAVE_LONG_LONG
{"T_LONGLONG", T_LONGLONG, offsetof(test_structmembers, structmembers.longlong_member), 0, NULL},
{"T_ULONGLONG", T_ULONGLONG, offsetof(test_structmembers, structmembers.ulonglong_member), 0, NULL},
@@ -2125,17 +2127,19 @@ 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_PYSSIZET",
- "T_FLOAT", "T_DOUBLE",
+ "T_FLOAT", "T_DOUBLE", "T_INPLACE_STRING",
#ifdef HAVE_LONG_LONG
"T_LONGLONG", "T_ULONGLONG",
#endif
NULL};
- static char *fmt = "|bbBhHiIlknfd"
+ static char *fmt = "|bbBhHiIlknfds#"
#ifdef HAVE_LONG_LONG
"LK"
#endif
;
test_structmembers *ob;
+ const char *s;
+ Py_ssize_t string_len = 0;
ob = PyObject_New(test_structmembers, type);
if (ob == NULL)
return NULL;
@@ -2152,7 +2156,8 @@ test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
&ob->structmembers.ulong_member,
&ob->structmembers.pyssizet_member,
&ob->structmembers.float_member,
- &ob->structmembers.double_member
+ &ob->structmembers.double_member,
+ &s, &string_len
#ifdef HAVE_LONG_LONG
, &ob->structmembers.longlong_member,
&ob->structmembers.ulonglong_member
@@ -2161,6 +2166,12 @@ test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
Py_DECREF(ob);
return NULL;
}
+ if (string_len > 5) {
+ Py_DECREF(ob);
+ PyErr_SetString(PyExc_ValueError, "string too long");
+ return NULL;
+ }
+ strcpy(ob->structmembers.inplace_member, s);
return (PyObject *)ob;
}