@@ -490,17 +490,20 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
490
490
}
491
491
492
492
/* Since dialect is now a heap type, it inherits pickling method for
493
- * protocol 0 and 1 from object, therefore it needs to be overrided */
493
+ * protocol 0 and 1 from object, therefore it needs to be overriden */
494
+
495
+ PyDoc_STRVAR (dialect_reduce_doc , "raises an exception to avoid pickling" );
494
496
495
497
static PyObject *
496
- _csv_dialect__reduce_ex__ (PyObject * self , PyObject * args ) {
497
- PyErr_SetString (PyExc_TypeError ,
498
- "Dialect object cannot be pickled." );
498
+ Dialect_reduce (PyObject * self , PyObject * args ) {
499
+ PyErr_Format (PyExc_TypeError ,
500
+ " cannot pickle '%.100s' instances" , _PyType_Name ( Py_TYPE ( self )) );
499
501
return NULL ;
500
502
}
501
503
502
504
static struct PyMethodDef dialect_methods [] = {
503
- {"__reduce_ex__" , _csv_dialect__reduce_ex__ , METH_VARARGS , NULL },
505
+ {"__reduce__" , Dialect_reduce , METH_VARARGS , dialect_reduce_doc },
506
+ {"__reduce_ex__" , Dialect_reduce , METH_VARARGS , dialect_reduce_doc },
504
507
{NULL , NULL }
505
508
};
506
509
0 commit comments