| 2831 | } |
| 2832 | |
| 2833 | static PyObject * |
| 2834 | encoder_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 | |
| 2858 | static int |
| 2859 | _steal_accumulate(_speedups_state *state, JSON_Accu *accu, PyObject *stolen) |
no test coverage detected
searching dependent graphs…