]> granicus.if.org Git - python/commitdiff
Give a better error message when a string of the wrong size is
authorJack Jansen <jack.jansen@cwi.nl>
Fri, 21 Mar 2003 16:42:36 +0000 (16:42 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Fri, 21 Mar 2003 16:42:36 +0000 (16:42 +0000)
passed to RawBitMap.

Mac/Modules/qd/_Qdmodule.c
Mac/Modules/qd/qdsupport.py

index 8187baa4b08d8326781205d1b734c80640be43c5..f2994dbca271e61d420401846d5e8caf80014351 100644 (file)
@@ -14,9 +14,9 @@
 
 /* Macro to test whether a weak-loaded CFM function exists */
 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL )  {\
-       PyErr_SetString(PyExc_NotImplementedError, \
-       "Not available in this shared library/OS version"); \
-       return NULL; \
+        PyErr_SetString(PyExc_NotImplementedError, \
+        "Not available in this shared library/OS version"); \
+        return NULL; \
     }} while(0)
 
 
@@ -6258,7 +6258,9 @@ static PyObject *Qd_RawBitMap(PyObject *_self, PyObject *_args)
        if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) )
                return NULL;
        if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) {
-               PyErr_BadArgument();
+               PyErr_Format(PyExc_TypeError, 
+                       "Argument size was %d, should be %d (sizeof BitMap) or %d (sizeof PixMap)", 
+                       PyString_Size(source), sizeof(BitMap), sizeof(PixMap));
                return NULL;
        }
        ptr = (BitMapPtr)PyString_AsString(source);
index 1e96980c1798a313827ad3a12c79e0dd616e29e7..18e628f598e0125b27996b9e4b45a580d6a87e31 100644 (file)
@@ -420,7 +420,9 @@ PyObject *source;
 if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) )
        return NULL;
 if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) {
-       PyErr_BadArgument();
+       PyErr_Format(PyExc_TypeError, 
+               "Argument size was %d, should be %d (sizeof BitMap) or %d (sizeof PixMap)", 
+               PyString_Size(source), sizeof(BitMap), sizeof(PixMap));
        return NULL;
 }
 ptr = (BitMapPtr)PyString_AsString(source);