summaryrefslogtreecommitdiffstats
path: root/Modules/_csv.c
diff options
context:
space:
mode:
authorAndrew McNamara <andrewm@object-craft.com.au>2005-01-10 12:22:48 (GMT)
committerAndrew McNamara <andrewm@object-craft.com.au>2005-01-10 12:22:48 (GMT)
commit37d2bdfa763a8dc8928d5576903d6c2d714e2201 (patch)
treec2965816211396bca7c8c2ffa2b25801bbadcda3 /Modules/_csv.c
parent9fa094677186b4bb05e488e5bc9d5dfe7ec32812 (diff)
downloadcpython-37d2bdfa763a8dc8928d5576903d6c2d714e2201.zip
cpython-37d2bdfa763a8dc8928d5576903d6c2d714e2201.tar.gz
cpython-37d2bdfa763a8dc8928d5576903d6c2d714e2201.tar.bz2
Where a string is desired, test for PyBaseString_Type derived type,
rather than using PyString_Check/PyUnicode_Check.
Diffstat (limited to 'Modules/_csv.c')
-rw-r--r--Modules/_csv.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c
index ba49236..e7f60c1 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -39,6 +39,9 @@ module instead.
#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 @@ _set_str(const char *name, PyObject **target, PyObject *src, const char *dflt)
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 @@ dialect_instantiate(PyObject *dialect)
{
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 @@ csv_register_dialect(PyObject *module, PyObject *args)
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;