[Python-checkins] python/dist/src/Modules _csv.c,1.20,1.21

andrewmcnamara at users.sourceforge.net andrewmcnamara at users.sourceforge.net
Mon Jan 10 13:22:51 CET 2005


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5700/Modules

Modified Files:
	_csv.c 
Log Message:
Where a string is desired, test for PyBaseString_Type derived type,
rather than using PyString_Check/PyUnicode_Check.


Index: _csv.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- _csv.c	10 Jan 2005 02:09:41 -0000	1.20
+++ _csv.c	10 Jan 2005 12:22:48 -0000	1.21
@@ -39,6 +39,9 @@
 #endif
 /* end 2.2 compatibility macros */
 
+#define IS_BASESTRING(o) \
+	PyObject_TypeCheck(o, &PyBaseString_Type)
+
 static PyObject *error_obj;	/* CSV exception */
 static PyObject *dialects;      /* Dialect registry */
 
@@ -230,11 +233,7 @@
 	else {
 		if (src == Py_None)
 			*target = NULL;
-		else if (!PyString_Check(src)
-#ifdef Py_USING_UNICODE
-		    && !PyUnicode_Check(src)
-#endif
-		) {
+		else if (!IS_BASESTRING(src)) {
 			PyErr_Format(PyExc_TypeError, 
 				     "\"%s\" must be an string", name);
 			return -1;
@@ -298,11 +297,7 @@
 {
 	Py_INCREF(dialect);
 	/* If dialect is a string, look it up in our registry */
-	if (PyString_Check(dialect)
-#ifdef Py_USING_UNICODE
-		|| PyUnicode_Check(dialect)
-#endif
-		) {
+	if (IS_BASESTRING(dialect)) {
 		PyObject * new_dia;
 		new_dia = get_dialect_from_registry(dialect);
 		Py_DECREF(dialect);
@@ -1372,11 +1367,7 @@
 
 	if (!PyArg_UnpackTuple(args, "", 2, 2, &name_obj, &dialect_obj))
                 return NULL;
-        if (!PyString_Check(name_obj)
-#ifdef Py_USING_UNICODE
-&& !PyUnicode_Check(name_obj)
-#endif
-) {
+        if (!IS_BASESTRING(name_obj)) {
                 PyErr_SetString(PyExc_TypeError, 
                                 "dialect name must be a string or unicode");
                 return NULL;



More information about the Python-checkins mailing list