summaryrefslogtreecommitdiffstats
path: root/Modules/_csv.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_csv.c')
-rw-r--r--Modules/_csv.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c
index b428279..7a78541 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -60,10 +60,10 @@ typedef enum {
typedef struct {
QuoteStyle style;
- char *name;
+ const char *name;
} StyleDesc;
-static StyleDesc quote_styles[] = {
+static const StyleDesc quote_styles[] = {
{ QUOTE_MINIMAL, "QUOTE_MINIMAL" },
{ QUOTE_ALL, "QUOTE_ALL" },
{ QUOTE_NONNUMERIC, "QUOTE_NONNUMERIC" },
@@ -286,7 +286,7 @@ _set_str(const char *name, PyObject **target, PyObject *src, const char *dflt)
static int
dialect_check_quoting(int quoting)
{
- StyleDesc *qs;
+ const StyleDesc *qs;
for (qs = quote_styles; qs->name; qs++) {
if ((int)qs->style == quoting)
@@ -518,15 +518,13 @@ static PyTypeObject Dialect_Type = {
static PyObject *
_call_dialect(PyObject *dialect_inst, PyObject *kwargs)
{
- PyObject *ctor_args;
- PyObject *dialect;
-
- ctor_args = Py_BuildValue(dialect_inst ? "(O)" : "()", dialect_inst);
- if (ctor_args == NULL)
- return NULL;
- dialect = PyObject_Call((PyObject *)&Dialect_Type, ctor_args, kwargs);
- Py_DECREF(ctor_args);
- return dialect;
+ PyObject *type = (PyObject *)&Dialect_Type;
+ if (dialect_inst) {
+ return _PyObject_FastCallDict(type, &dialect_inst, 1, kwargs);
+ }
+ else {
+ return _PyObject_FastCallDict(type, NULL, 0, kwargs);
+ }
}
/*
@@ -1648,7 +1646,7 @@ PyMODINIT_FUNC
PyInit__csv(void)
{
PyObject *module;
- StyleDesc *style;
+ const StyleDesc *style;
if (PyType_Ready(&Dialect_Type) < 0)
return NULL;