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