[Zodb-checkins] CVS: Zope3/lib/python/Persistence/BTrees - intkeymacros.h:1.1.2.2

Jeremy Hylton jeremy@zope.com
Sat, 2 Mar 2002 00:14:43 -0500


Update of /cvs-repository/Zope3/lib/python/Persistence/BTrees
In directory cvs.zope.org:/tmp/cvs-serv22888

Modified Files:
      Tag: Zope-3x-branch
	intkeymacros.h 
Log Message:
Spread COPY_KEY_FROM_ARG() macro across many lines, and add more
verbose (and expensive) error message when it fails.


=== Zope3/lib/python/Persistence/BTrees/intkeymacros.h 1.1.2.1 => 1.1.2.2 ===
 #define COPY_KEY_TO_OBJECT(O, K) O=PyInt_FromLong(K)
 #define COPY_KEY_FROM_ARG(TARGET, ARG, STATUS) \
-  if (PyInt_Check(ARG)) TARGET=PyInt_AS_LONG(ARG); else { \
-      PyErr_SetString(PyExc_TypeError, "expected integer key"); \
-      (STATUS)=0; (TARGET)=0; } 
+    if (PyInt_Check(ARG)) \
+	TARGET = PyInt_AS_LONG(ARG); \
+    else { \
+	PyErr_Format(PyExc_TypeError, "expected integer key, found %s", \
+		     (ARG)->ob_type->tp_name); \
+	(STATUS) = 0; \
+	(TARGET) = 0; \
+    } 
 #define KEY_IF_OBJECT(K) NULL