Index: Modules/structmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/structmodule.c,v retrieving revision 2.61 diff -u -c -r2.61 structmodule.c *** Modules/structmodule.c 19 Nov 2003 22:52:23 -0000 2.61 --- Modules/structmodule.c 18 Aug 2004 06:29:00 -0000 *************** *** 518,531 **** static int np_void_p(char *p, PyObject *v, const formatdef *f) { ! void *x = PyLong_AsVoidPtr(v); ! if (x == NULL && PyErr_Occurred()) { ! /* ### hrm. PyLong_AsVoidPtr raises SystemError */ ! if (PyErr_ExceptionMatches(PyExc_TypeError)) ! PyErr_SetString(StructError, ! "required argument is not an integer"); return -1; - } memcpy(p, (char *)&x, sizeof x); return 0; } --- 518,533 ---- static int np_void_p(char *p, PyObject *v, const formatdef *f) { ! void *x; ! ! v = get_pylong(v); ! if (v == NULL) ! return -1; ! assert(PyLong_Check(v)); ! x = PyLong_AsVoidPtr(v); ! Py_DECREF(v); ! if (x == NULL && PyErr_Occurred()) return -1; memcpy(p, (char *)&x, sizeof x); return 0; } Index: Lib/test/test_struct.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_struct.py,v retrieving revision 1.18 diff -u -c -r1.18 test_struct.py *** Lib/test/test_struct.py 12 Feb 2004 17:35:11 -0000 1.18 --- Lib/test/test_struct.py 18 Aug 2004 06:29:00 -0000 *************** *** 54,59 **** --- 54,60 ---- simple_err(struct.pack, 'iii', 3) simple_err(struct.pack, 'i', 3, 3, 3) simple_err(struct.pack, 'i', 'foo') + simple_err(struct.pack, 'P', 'foo') simple_err(struct.unpack, 'd', 'flap') s = struct.pack('ii', 1, 2) simple_err(struct.unpack, 'iii', s)