comparison Modules/structmodule.c @ 33599:32df1d05cb2d legacy-trunk

Patch #1011240: SystemError generated by struct.pack('P', 'foo').
author Armin Rigo <arigo@tunes.org>
date Mon, 27 Sep 2004 19:27:51 +0000
parents 4c8160088b34
children 8a3d7f9f02cc
comparison
equal deleted inserted replaced
33598:cf1aaa7e4005 33599:32df1d05cb2d
516 } 516 }
517 517
518 static int 518 static int
519 np_void_p(char *p, PyObject *v, const formatdef *f) 519 np_void_p(char *p, PyObject *v, const formatdef *f)
520 { 520 {
521 void *x = PyLong_AsVoidPtr(v); 521 void *x;
522 if (x == NULL && PyErr_Occurred()) { 522
523 /* ### hrm. PyLong_AsVoidPtr raises SystemError */ 523 v = get_pylong(v);
524 if (PyErr_ExceptionMatches(PyExc_TypeError)) 524 if (v == NULL)
525 PyErr_SetString(StructError, 525 return -1;
526 "required argument is not an integer"); 526 assert(PyLong_Check(v));
527 return -1; 527 x = PyLong_AsVoidPtr(v);
528 } 528 Py_DECREF(v);
529 if (x == NULL && PyErr_Occurred())
530 return -1;
529 memcpy(p, (char *)&x, sizeof x); 531 memcpy(p, (char *)&x, sizeof x);
530 return 0; 532 return 0;
531 } 533 }
532 534
533 static formatdef native_table[] = { 535 static formatdef native_table[] = {