Skip to content
Merged
Changes from 1 commit
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
Next Next commit
port json
  • Loading branch information
kumaraditya303 authored Nov 1, 2022
commit 75a2b4aec913b267a95ef037e8b8b920539141a0
16 changes: 3 additions & 13 deletions Modules/_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif
#define NEEDS_PY_IDENTIFIER

#include "Python.h"
#include "pycore_ceval.h" // _Py_EnterRecursiveCall()
Expand Down Expand Up @@ -304,20 +303,11 @@ escape_unicode(PyObject *pystr)
static void
raise_errmsg(const char *msg, PyObject *s, Py_ssize_t end)
{
/* Use JSONDecodeError exception to raise a nice looking ValueError subclass */
_Py_static_string(PyId_decoder, "json.decoder");
PyObject *decoder = _PyImport_GetModuleId(&PyId_decoder);
if (decoder == NULL) {
return;
}

_Py_IDENTIFIER(JSONDecodeError);
PyObject *JSONDecodeError = _PyObject_GetAttrId(decoder, &PyId_JSONDecodeError);
Py_DECREF(decoder);
PyObject *JSONDecodeError =
_PyImport_GetModuleAttrString("json.decoder", "JSONDecodeError");
Comment thread
kumaraditya303 marked this conversation as resolved.
Outdated
if (JSONDecodeError == NULL) {
return;
}

PyObject *exc;
exc = PyObject_CallFunction(JSONDecodeError, "zOn", msg, s, end);
Py_DECREF(JSONDecodeError);
Expand Down Expand Up @@ -1530,7 +1520,7 @@ encoder_encode_key_value(PyEncoderObject *s, _PyUnicodeWriter *writer, bool *fir

if (*first) {
*first = false;
}
}
else {
if (_PyUnicodeWriter_WriteStr(writer, s->item_separator) < 0) {
Py_DECREF(keystr);
Expand Down