@@ -645,7 +645,7 @@ scanstring_unicode(PyObject *pystr, Py_ssize_t end, int strict, Py_ssize_t *next
645645
646646/*[clinic input]
647647_json.scanstring as py_scanstring
648- pystr: object
648+ pystr: unicode
649649 end: Py_ssize_t
650650 strict: bool = True
651651 /
@@ -664,74 +664,41 @@ after the end quote.
664664static PyObject *
665665py_scanstring_impl (PyObject * module , PyObject * pystr , Py_ssize_t end ,
666666 int strict )
667- /*[clinic end generated code: output=961740cfae07cdb3 input=9d46d7df7ac749b0 ]*/
667+ /*[clinic end generated code: output=961740cfae07cdb3 input=cff59e47498f4d8e ]*/
668668{
669- PyObject * rval ;
670669 Py_ssize_t next_end = -1 ;
671- if (PyUnicode_Check (pystr )) {
672- rval = scanstring_unicode (pystr , end , strict , & next_end );
673- }
674- else {
675- PyErr_Format (PyExc_TypeError ,
676- "first argument must be a string, not %.80s" ,
677- Py_TYPE (pystr )-> tp_name );
678- return NULL ;
679- }
670+ PyObject * rval = scanstring_unicode (pystr , end , strict , & next_end );
680671 return _build_rval_index_tuple (rval , next_end );
681672}
682673
683674/*[clinic input]
684675_json.encode_basestring_ascii as py_encode_basestring_ascii
685- pystr: object
676+ pystr: unicode
686677 /
687678
688679Return an ASCII-only JSON representation of a Python string
689680[clinic start generated code]*/
690681
691682static PyObject *
692- py_encode_basestring_ascii (PyObject * module , PyObject * pystr )
693- /*[clinic end generated code: output=a8afcd88eba0b572 input=f4085ccd5928ea55 ]*/
683+ py_encode_basestring_ascii_impl (PyObject * module , PyObject * pystr )
684+ /*[clinic end generated code: output=7b3841287cf211df input=4f3609498aff2de5 ]*/
694685{
695- PyObject * rval ;
696- /* Return an ASCII-only JSON representation of a Python string */
697- /* METH_O */
698- if (PyUnicode_Check (pystr )) {
699- rval = ascii_escape_unicode (pystr );
700- }
701- else {
702- PyErr_Format (PyExc_TypeError ,
703- "first argument must be a string, not %.80s" ,
704- Py_TYPE (pystr )-> tp_name );
705- return NULL ;
706- }
707- return rval ;
686+ return ascii_escape_unicode (pystr );
708687}
709688
710689/*[clinic input]
711690_json.encode_basestring as py_encode_basestring
712- pystr: object
691+ pystr: unicode
713692 /
714693
715694Return a JSON representation of a Python string
716695[clinic start generated code]*/
717696
718697static PyObject *
719- py_encode_basestring (PyObject * module , PyObject * pystr )
720- /*[clinic end generated code: output=c87752300776d3b1 input=c3c7ef6e72624f6e ]*/
698+ py_encode_basestring_impl (PyObject * module , PyObject * pystr )
699+ /*[clinic end generated code: output=900950f95df3f1c9 input=d42ef714b2c07386 ]*/
721700{
722- PyObject * rval ;
723- /* Return a JSON representation of a Python string */
724- /* METH_O */
725- if (PyUnicode_Check (pystr )) {
726- rval = escape_unicode (pystr );
727- }
728- else {
729- PyErr_Format (PyExc_TypeError ,
730- "first argument must be a string, not %.80s" ,
731- Py_TYPE (pystr )-> tp_name );
732- return NULL ;
733- }
734- return rval ;
701+ return escape_unicode (pystr );
735702}
736703
737704static void
0 commit comments