[pypy-svn] r73446 - pypy/branch/cpython-extension/pypy/module/cpyext/src
fijal at codespeak.net
fijal at codespeak.net
Tue Apr 6 07:27:53 CEST 2010
Author: fijal
Date: Tue Apr 6 07:27:51 2010
New Revision: 73446
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/src/getargs.c
Log:
Try a bit harder to report unsupported cases instead of random stack
corruption due to not calling va_arg correctly - does not work so far
sre still segfaults.
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/src/getargs.c
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/src/getargs.c (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/src/getargs.c Tue Apr 6 07:27:51 2010
@@ -135,13 +135,12 @@
PyMem_FREE(ptr);
}
-#if 0 //YYY
static void
cleanup_buffer(void *ptr)
{
- PyBuffer_Release((Py_buffer *) ptr);
+ Py_FatalError("cleanup_buffer(void *ptr) unimplemented\n");
+ //PyBuffer_Release((Py_buffer *) ptr);
}
-#endif
static int
addcleanup(void *ptr, PyObject **freelist, void (*destr)(void *))
@@ -556,8 +555,9 @@
switch (c) {
-#if 0
case 'b': { /* unsigned byte -- very short int */
+ Py_FatalError("'b' unimplemented for PyArg_*\n");
+#if 0
char *p = va_arg(*p_va, char *);
long ival;
if (float_argument_error(arg))
@@ -578,10 +578,13 @@
else
*p = (unsigned char) ival;
break;
+#endif
}
case 'B': {/* byte sized bitfield - both signed and unsigned
values allowed */
+ Py_FatalError("'B' unimplemented for PyArg_*\n");
+#if 0
char *p = va_arg(*p_va, char *);
long ival;
if (float_argument_error(arg))
@@ -592,9 +595,12 @@
else
*p = (unsigned char) ival;
break;
+#endif
}
case 'h': {/* signed short int */
+ Py_FatalError("'h' unimplemented for PyArg_*\n");
+#if 0
short *p = va_arg(*p_va, short *);
long ival;
if (float_argument_error(arg))
@@ -615,10 +621,13 @@
else
*p = (short) ival;
break;
+#endif
}
case 'H': { /* short int sized bitfield, both signed and
unsigned allowed */
+ Py_FatalError("'H' unimplemented for PyArg_*\n");
+#if 0
unsigned short *p = va_arg(*p_va, unsigned short *);
long ival;
if (float_argument_error(arg))
@@ -629,8 +638,8 @@
else
*p = (unsigned short) ival;
break;
- }
#endif
+ }
case 'i': {/* signed int */
int *p = va_arg(*p_va, int *);
long ival;
@@ -653,9 +662,10 @@
*p = ival;
break;
}
-#if 0
case 'I': { /* int sized bitfield, both signed and
unsigned allowed */
+ Py_FatalError("'I' unimplemented for PyArg_*\n");
+#if 0
unsigned int *p = va_arg(*p_va, unsigned int *);
unsigned int ival;
if (float_argument_error(arg))
@@ -666,8 +676,8 @@
else
*p = ival;
break;
- }
#endif
+ }
case 'n': /* Py_ssize_t */
#if SIZEOF_SIZE_T != SIZEOF_LONG
{
@@ -696,8 +706,9 @@
break;
}
-#if 0
case 'k': { /* long sized bitfield */
+ Py_FatalError("'k' unimplemented for PyArg_*\n");
+#if 0
unsigned long *p = va_arg(*p_va, unsigned long *);
unsigned long ival;
if (PyInt_Check(arg))
@@ -708,10 +719,13 @@
return converterr("integer<k>", arg, msgbuf, bufsize);
*p = ival;
break;
+#endif
}
#ifdef HAVE_LONG_LONG
case 'L': {/* PY_LONG_LONG */
+ Py_FatalError("'L' unimplemented for PyArg_*\n");
+#if 0
PY_LONG_LONG *p = va_arg( *p_va, PY_LONG_LONG * );
PY_LONG_LONG ival = PyLong_AsLongLong( arg );
if (ival == (PY_LONG_LONG)-1 && PyErr_Occurred() ) {
@@ -720,9 +734,12 @@
*p = ival;
}
break;
+#endif
}
case 'K': { /* long long sized bitfield */
+ Py_FatalError("'K' unimplemented for PyArg_*\n");
+#if 0
unsigned PY_LONG_LONG *p = va_arg(*p_va, unsigned PY_LONG_LONG *);
unsigned PY_LONG_LONG ival;
if (PyInt_Check(arg))
@@ -733,10 +750,13 @@
return converterr("integer<K>", arg, msgbuf, bufsize);
*p = ival;
break;
- }
-#endif
-
+#endif
+ }
+#endif // HAVE_LONG_LONG
+
case 'f': {/* float */
+ Py_FatalError("'f' unimplemented for PyArg_*\n");
+#if 0
float *p = va_arg(*p_va, float *);
double dval = PyFloat_AsDouble(arg);
if (PyErr_Occurred())
@@ -744,9 +764,12 @@
else
*p = (float) dval;
break;
+#endif
}
case 'd': {/* double */
+ Py_FatalError("'d' unimplemented for PyArg_*\n");
+#if 0
double *p = va_arg(*p_va, double *);
double dval = PyFloat_AsDouble(arg);
if (PyErr_Occurred())
@@ -754,10 +777,13 @@
else
*p = dval;
break;
+#endif
}
#ifndef WITHOUT_COMPLEX
case 'D': {/* complex double */
+ Py_FatalError("'D' unimplemented for PyArg_*\n");
+#if 0
Py_complex *p = va_arg(*p_va, Py_complex *);
Py_complex cval;
cval = PyComplex_AsCComplex(arg);
@@ -766,6 +792,7 @@
else
*p = cval;
break;
+#endif
}
#endif /* WITHOUT_COMPLEX */
@@ -777,9 +804,10 @@
return converterr("char", arg, msgbuf, bufsize);
break;
}
-
case 's': {/* string */
if (*format == '*') {
+ Py_FatalError("* format unsupported for strings in PyArg_*\n");
+#if 0
Py_buffer *p = (Py_buffer *)va_arg(*p_va, Py_buffer *);
if (PyString_Check(arg)) {
@@ -809,6 +837,7 @@
arg, msgbuf, bufsize);
}
format++;
+#endif
} else if (*format == '#') {
void **p = (void **)va_arg(*p_va, char **);
FETCH_SIZE;
@@ -860,6 +889,8 @@
case 'z': {/* string, may be NULL (None) */
if (*format == '*') {
+ Py_FatalError("'*' format not supported in PyArg_*\n");
+#if 0
Py_buffer *p = (Py_buffer *)va_arg(*p_va, Py_buffer *);
if (arg == Py_None)
@@ -891,6 +922,7 @@
arg, msgbuf, bufsize);
}
format++;
+#endif
} else if (*format == '#') { /* any buffer-like object */
void **p = (void **)va_arg(*p_va, char **);
FETCH_SIZE;
@@ -957,8 +989,9 @@
}
break;
}
-
case 'e': {/* encoded string */
+ Py_FatalError("'e' unimplemented for PyArg_*\n");
+#if 0
char **buffer;
const char *encoding;
PyObject *s;
@@ -971,7 +1004,7 @@
if (encoding == NULL)
encoding = PyUnicode_GetDefaultEncoding();
#endif
-
+
/* Get output buffer parameter:
's' (recode all objects via Unicode) or
't' (only recode non-string objects)
@@ -1122,6 +1155,7 @@
}
Py_DECREF(s);
break;
+#endif
}
#ifdef Py_USING_UNICODE
@@ -1168,7 +1202,6 @@
break;
}
#endif
-#endif
case 'O': { /* object */
PyTypeObject *type;
PyObject **p;
@@ -1209,8 +1242,9 @@
break;
}
-#if 0
case 'w': { /* memory buffer, read-write access */
+ Py_FatalError("'w' unsupported\n");
+#if 0
void **p = va_arg(*p_va, void **);
void *res;
PyBufferProcs *pb = arg->ob_type->tp_as_buffer;
@@ -1261,9 +1295,12 @@
}
}
break;
+#endif
}
case 't': { /* 8-bit character buffer, read-only access */
+ Py_FatalError("'t' unsupported");
+#if 0
char **p = va_arg(*p_va, char **);
PyBufferProcs *pb = arg->ob_type->tp_as_buffer;
Py_ssize_t count;
@@ -1298,8 +1335,8 @@
STORE_SIZE(count);
}
break;
- }
#endif
+ }
default:
return converterr("impossible<bad format char>", arg, msgbuf, bufsize);
@@ -1378,7 +1415,7 @@
va_list va;
if ((args == NULL || !PyTuple_Check(args)) ||
- (keywords != NULL && !PyDict_Check(keywords)) ||
+ (keywords != NULL && !PyDict_Check(keywords)) ||
format == NULL ||
kwlist == NULL)
{
More information about the Pypy-commit
mailing list