MCPcopy Create free account
hub / github.com/simplejson/simplejson / encoder_encode_string

Function encoder_encode_string

simplejson/_speedups.c:2833–2856  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2831}
2832
2833static PyObject *
2834encoder_encode_string(PyEncoderObject *s, PyObject *obj)
2835{
2836 /* Return the JSON representation of a string */
2837 PyObject *encoded;
2838
2839 if (s->fast_encode) {
2840 return py_encode_basestring_ascii(NULL, obj);
2841 }
2842 encoded = PyObject_CallOneArg(s->encoder, obj);
2843 if (encoded != NULL &&
2844#if PY_MAJOR_VERSION < 3
2845 !PyString_Check(encoded) &&
2846#endif /* PY_MAJOR_VERSION < 3 */
2847 !PyUnicode_Check(encoded))
2848 {
2849 PyErr_Format(PyExc_TypeError,
2850 "encoder() must return a string, not %.80s",
2851 Py_TYPE(encoded)->tp_name);
2852 Py_DECREF(encoded);
2853 return NULL;
2854 }
2855 return encoded;
2856}
2857
2858static int
2859_steal_accumulate(_speedups_state *state, JSON_Accu *accu, PyObject *stolen)

Callers 2

encoder_listencode_objFunction · 0.85
encoder_encode_dict_keyFunction · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…