Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,13 @@ struct _Py_global_strings {
STRUCT_FOR_ID(default)
STRUCT_FOR_ID(defaultaction)
STRUCT_FOR_ID(delete)
STRUCT_FOR_ID(delimiter)
STRUCT_FOR_ID(depth)
STRUCT_FOR_ID(desired_access)
STRUCT_FOR_ID(detect_types)
STRUCT_FOR_ID(deterministic)
STRUCT_FOR_ID(device)
STRUCT_FOR_ID(dialect)
STRUCT_FOR_ID(dict)
STRUCT_FOR_ID(difference_update)
STRUCT_FOR_ID(digest)
Expand All @@ -454,6 +456,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(doc)
STRUCT_FOR_ID(done)
STRUCT_FOR_ID(dont_inherit)
STRUCT_FOR_ID(doublequote)
STRUCT_FOR_ID(dst)
STRUCT_FOR_ID(dst_dir_fd)
STRUCT_FOR_ID(duration_sec)
Expand All @@ -473,6 +476,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(env)
STRUCT_FOR_ID(error_rate)
STRUCT_FOR_ID(errors)
STRUCT_FOR_ID(escapechar)
STRUCT_FOR_ID(event)
STRUCT_FOR_ID(eventmask)
STRUCT_FOR_ID(exc)
Expand Down Expand Up @@ -636,6 +640,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(line)
STRUCT_FOR_ID(line_buffering)
STRUCT_FOR_ID(lineno)
STRUCT_FOR_ID(lineterminator)
STRUCT_FOR_ID(little)
STRUCT_FOR_ID(lo)
STRUCT_FOR_ID(locale)
Expand Down Expand Up @@ -768,7 +773,9 @@ struct _Py_global_strings {
STRUCT_FOR_ID(qualname)
STRUCT_FOR_ID(query)
STRUCT_FOR_ID(queuetype)
STRUCT_FOR_ID(quotechar)
STRUCT_FOR_ID(quotetabs)
STRUCT_FOR_ID(quoting)
STRUCT_FOR_ID(random_func)
STRUCT_FOR_ID(raw)
STRUCT_FOR_ID(read)
Expand Down Expand Up @@ -834,6 +841,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(sizehint)
STRUCT_FOR_ID(skip_file_prefixes)
STRUCT_FOR_ID(skip_non_matching_threads)
STRUCT_FOR_ID(skipinitialspace)
STRUCT_FOR_ID(skipkeys)
STRUCT_FOR_ID(sleep)
STRUCT_FOR_ID(sock)
Expand Down
8 changes: 8 additions & 0 deletions Include/internal/pycore_runtime_init_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Include/internal/pycore_unicodeobject_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 47 additions & 60 deletions Modules/_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,19 +457,6 @@ Dialect_dealloc(PyObject *self)
Py_DECREF(tp);
}

static char *dialect_kws[] = {
"dialect",
"delimiter",
"doublequote",
"escapechar",
"lineterminator",
"quotechar",
"quoting",
"skipinitialspace",
"strict",
NULL
};

static _csvstate *
_csv_state_from_type(PyTypeObject *type, const char *name)
{
Expand All @@ -486,44 +473,54 @@ _csv_state_from_type(PyTypeObject *type, const char *name)
return module_state;
}

/*[clinic input]
@vectorcall
@classmethod
_csv.Dialect.__new__ as dialect_new
dialect: object = NULL
delimiter: object = NULL
doublequote: object = NULL
escapechar: object = NULL
lineterminator: object = NULL
quotechar: object = NULL
quoting: object = NULL
skipinitialspace: object = NULL
strict: object = NULL
[clinic start generated code]*/

static PyObject *
dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
dialect_new_impl(PyTypeObject *type, PyObject *dialect, PyObject *delimiter,
PyObject *doublequote, PyObject *escapechar,
PyObject *lineterminator, PyObject *quotechar,
PyObject *quoting, PyObject *skipinitialspace,
PyObject *strict)
/*[clinic end generated code: output=123393bdc71ddaa6 input=469f47d5890022f7]*/
{
DialectObj *self;
DialectObj *self = NULL;
PyObject *ret = NULL;
PyObject *dialect = NULL;
PyObject *delimiter = NULL;
PyObject *doublequote = NULL;
PyObject *escapechar = NULL;
PyObject *lineterminator = NULL;
PyObject *quotechar = NULL;
PyObject *quoting = NULL;
PyObject *skipinitialspace = NULL;
PyObject *strict = NULL;

if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"|OOOOOOOOO", dialect_kws,
&dialect,
&delimiter,
&doublequote,
&escapechar,
&lineterminator,
&quotechar,
&quoting,
&skipinitialspace,
&strict))
return NULL;

/* vectorcall passes borrowed references; hold strong references before
get_dialect_from_registry() can run arbitrary Python. */
Py_XINCREF(delimiter);
Py_XINCREF(doublequote);
Py_XINCREF(escapechar);
Py_XINCREF(lineterminator);
Py_XINCREF(quotechar);
Py_XINCREF(quoting);
Py_XINCREF(skipinitialspace);
Py_XINCREF(strict);

_csvstate *module_state = _csv_state_from_type(type, "dialect_new");
if (module_state == NULL) {
return NULL;
goto err;
}

if (dialect != NULL) {
if (PyUnicode_Check(dialect)) {
dialect = get_dialect_from_registry(dialect, module_state);
if (dialect == NULL)
return NULL;
if (dialect == NULL) {
goto err;
}
}
else
Py_INCREF(dialect);
Expand All @@ -536,25 +533,17 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
quotechar == NULL &&
quoting == NULL &&
skipinitialspace == NULL &&
strict == NULL)
return dialect;
strict == NULL) {
ret = Py_NewRef(dialect);
goto err;
}
}

self = (DialectObj *)type->tp_alloc(type, 0);
if (self == NULL) {
Py_CLEAR(dialect);
return NULL;
goto err;
}
self->lineterminator = NULL;

Py_XINCREF(delimiter);
Py_XINCREF(doublequote);
Py_XINCREF(escapechar);
Py_XINCREF(lineterminator);
Py_XINCREF(quotechar);
Py_XINCREF(quoting);
Py_XINCREF(skipinitialspace);
Py_XINCREF(strict);
if (dialect != NULL) {
#define DIALECT_GETATTR(v, n) \
do { \
Expand Down Expand Up @@ -676,13 +665,10 @@ static PyObject *
_csv_Dialect___replace___impl(DialectObj *self, PyObject *changes)
/*[clinic end generated code: output=8f692c2c63a61b50 input=154beb565fbabd4c]*/
{
PyObject *newargs = PyTuple_Pack(1, self);
if (newargs == NULL) {
return NULL;
}
PyObject *result = dialect_new(Py_TYPE(self), newargs, changes);
Py_DECREF(newargs);
return result;
PyObject *const args[1] = {(PyObject *)self};
return dialect_new_helper(Py_TYPE(self), args, 1,
changes ? PyDict_GET_SIZE(changes) : 0,
changes, NULL);
}

static struct PyMethodDef dialect_methods[] = {
Expand Down Expand Up @@ -719,6 +705,7 @@ static PyType_Slot Dialect_Type_slots[] = {
{Py_tp_members, Dialect_memberlist},
{Py_tp_getset, Dialect_getsetlist},
{Py_tp_new, dialect_new},
{Py_tp_vectorcall, dialect_vectorcall},
{Py_tp_methods, dialect_methods},
{Py_tp_dealloc, Dialect_dealloc},
{Py_tp_clear, Dialect_clear},
Expand Down
Loading
Loading