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 @@ -313,6 +313,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(all_interpreters)
STRUCT_FOR_ID(all_threads)
STRUCT_FOR_ID(allow_code)
STRUCT_FOR_ID(allow_nan)
STRUCT_FOR_ID(alphabet)
STRUCT_FOR_ID(any)
STRUCT_FOR_ID(append)
Expand Down Expand Up @@ -460,6 +461,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(element_factory)
STRUCT_FOR_ID(emptyerror)
STRUCT_FOR_ID(encode)
STRUCT_FOR_ID(encoder)
STRUCT_FOR_ID(encoding)
STRUCT_FOR_ID(end)
STRUCT_FOR_ID(end_col_offset)
Expand Down Expand Up @@ -563,6 +565,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(in_fd)
STRUCT_FOR_ID(include_aliases)
STRUCT_FOR_ID(incoming)
STRUCT_FOR_ID(indent)
STRUCT_FOR_ID(index)
STRUCT_FOR_ID(indexgroup)
STRUCT_FOR_ID(inf)
Expand Down Expand Up @@ -596,6 +599,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(isolation_level)
STRUCT_FOR_ID(istext)
STRUCT_FOR_ID(item)
STRUCT_FOR_ID(item_separator)
STRUCT_FOR_ID(items)
STRUCT_FOR_ID(iter)
STRUCT_FOR_ID(iterable)
Expand All @@ -605,6 +609,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(jump)
STRUCT_FOR_ID(keepends)
STRUCT_FOR_ID(key)
STRUCT_FOR_ID(key_separator)
STRUCT_FOR_ID(keyfile)
STRUCT_FOR_ID(keys)
STRUCT_FOR_ID(kind)
Expand Down Expand Up @@ -638,6 +643,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(loop)
STRUCT_FOR_ID(manual_reset)
STRUCT_FOR_ID(mapping)
STRUCT_FOR_ID(markers)
STRUCT_FOR_ID(mask)
STRUCT_FOR_ID(match)
STRUCT_FOR_ID(max_length)
Expand Down Expand Up @@ -827,9 +833,11 @@ struct _Py_global_strings {
STRUCT_FOR_ID(sizehint)
STRUCT_FOR_ID(skip_file_prefixes)
STRUCT_FOR_ID(skip_non_matching_threads)
STRUCT_FOR_ID(skipkeys)
STRUCT_FOR_ID(sleep)
STRUCT_FOR_ID(sock)
STRUCT_FOR_ID(sort)
STRUCT_FOR_ID(sort_keys)
STRUCT_FOR_ID(source)
STRUCT_FOR_ID(source_traceback)
STRUCT_FOR_ID(spam)
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.

41 changes: 25 additions & 16 deletions Modules/_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@

/*[clinic input]
module _json
class _json.make_encoder "PyEncoderObject *" ""
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=549fa53592c925b2]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=f3373cb3d646c5f1]*/

typedef struct _PyScannerObject {
PyObject_HEAD
Expand Down Expand Up @@ -98,8 +99,6 @@ scanner_dealloc(PyObject *self);
static int
scanner_clear(PyObject *self);

static PyObject *
encoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
static void
encoder_dealloc(PyObject *self);
static int
Expand Down Expand Up @@ -1306,21 +1305,30 @@ static PyType_Spec PyScannerType_spec = {
.slots = PyScannerType_slots,
};

/*[clinic input]
@vectorcall
@classmethod
_json.make_encoder.__new__ as encoder_new

markers: object
default as defaultfn: object
encoder: object
indent: object
key_separator: unicode
item_separator: unicode
sort_keys: bool
skipkeys: bool
allow_nan: bool
[clinic start generated code]*/

static PyObject *
encoder_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
encoder_new_impl(PyTypeObject *type, PyObject *markers, PyObject *defaultfn,
PyObject *encoder, PyObject *indent,
PyObject *key_separator, PyObject *item_separator,
int sort_keys, int skipkeys, int allow_nan)
/*[clinic end generated code: output=46071d17c87596ef input=d3e48f5426deb209]*/
{
static char *kwlist[] = {"markers", "default", "encoder", "indent", "key_separator", "item_separator", "sort_keys", "skipkeys", "allow_nan", NULL};

PyEncoderObject *s;
PyObject *markers, *defaultfn, *encoder, *indent, *key_separator;
PyObject *item_separator;
int sort_keys, skipkeys, allow_nan;

if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOUUppp:make_encoder", kwlist,
&markers, &defaultfn, &encoder, &indent,
&key_separator, &item_separator,
&sort_keys, &skipkeys, &allow_nan))
return NULL;

if (markers != Py_None && !PyDict_Check(markers)) {
PyErr_Format(PyExc_TypeError,
Expand Down Expand Up @@ -2042,14 +2050,15 @@ static PyType_Slot PyEncoderType_slots[] = {
{Py_tp_clear, encoder_clear},
{Py_tp_members, encoder_members},
{Py_tp_new, encoder_new},
{Py_tp_vectorcall, encoder_vectorcall},
{0, 0}
};

static PyType_Spec PyEncoderType_spec = {
.name = "_json.Encoder",
.basicsize = sizeof(PyEncoderObject),
.itemsize = 0,
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE,
.slots = PyEncoderType_slots
};

Expand Down
Loading
Loading