@@ -874,6 +874,9 @@ _parse_object_str(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
874874 int strict = PyObject_IsTrue (s -> strict );
875875 Py_ssize_t next_idx ;
876876
877+ if (strict < 0 )
878+ return NULL ;
879+
877880 pairs = PyList_New (0 );
878881 if (pairs == NULL )
879882 return NULL ;
@@ -997,6 +1000,9 @@ _parse_object_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ss
9971000 int strict = PyObject_IsTrue (s -> strict );
9981001 Py_ssize_t next_idx ;
9991002
1003+ if (strict < 0 )
1004+ return NULL ;
1005+
10001006 pairs = PyList_New (0 );
10011007 if (pairs == NULL )
10021008 return NULL ;
@@ -1466,6 +1472,7 @@ scan_once_str(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_t *n
14661472 Returns a new PyObject representation of the term.
14671473 */
14681474 PyObject * res ;
1475+ int strict ;
14691476 char * str = PyString_AS_STRING (pystr );
14701477 Py_ssize_t length = PyString_GET_SIZE (pystr );
14711478 if (idx < 0 ) {
@@ -1479,10 +1486,11 @@ scan_once_str(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_t *n
14791486 switch (str [idx ]) {
14801487 case '"' :
14811488 /* string */
1489+ strict = PyObject_IsTrue (s -> strict );
1490+ if (strict < 0 )
1491+ return NULL ;
14821492 return scanstring_str (pystr , idx + 1 ,
1483- PyString_AS_STRING (s -> encoding ),
1484- PyObject_IsTrue (s -> strict ),
1485- next_idx_ptr );
1493+ PyString_AS_STRING (s -> encoding ), strict , next_idx_ptr );
14861494 case '{' :
14871495 /* object */
14881496 if (Py_EnterRecursiveCall (" while decoding a JSON object "
@@ -1557,6 +1565,7 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
15571565 Returns a new PyObject representation of the term.
15581566 */
15591567 PyObject * res ;
1568+ int strict ;
15601569 Py_UNICODE * str = PyUnicode_AS_UNICODE (pystr );
15611570 Py_ssize_t length = PyUnicode_GET_SIZE (pystr );
15621571 if (idx < 0 ) {
@@ -1570,9 +1579,10 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
15701579 switch (str [idx ]) {
15711580 case '"' :
15721581 /* string */
1573- return scanstring_unicode (pystr , idx + 1 ,
1574- PyObject_IsTrue (s -> strict ),
1575- next_idx_ptr );
1582+ strict = PyObject_IsTrue (s -> strict );
1583+ if (strict < 0 )
1584+ return NULL ;
1585+ return scanstring_unicode (pystr , idx + 1 , strict , next_idx_ptr );
15761586 case '{' :
15771587 /* object */
15781588 if (Py_EnterRecursiveCall (" while decoding a JSON object "
@@ -1825,14 +1835,19 @@ encoder_init(PyObject *self, PyObject *args, PyObject *kwds)
18251835
18261836 PyEncoderObject * s ;
18271837 PyObject * markers , * defaultfn , * encoder , * indent , * key_separator ;
1828- PyObject * item_separator , * sort_keys , * skipkeys , * allow_nan ;
1838+ PyObject * item_separator , * sort_keys , * skipkeys , * allow_nan_obj ;
1839+ int allow_nan ;
18291840
18301841 assert (PyEncoder_Check (self ));
18311842 s = (PyEncoderObject * )self ;
18321843
18331844 if (!PyArg_ParseTupleAndKeywords (args , kwds , "OOOOOOOOO:make_encoder" , kwlist ,
18341845 & markers , & defaultfn , & encoder , & indent , & key_separator , & item_separator ,
1835- & sort_keys , & skipkeys , & allow_nan ))
1846+ & sort_keys , & skipkeys , & allow_nan_obj ))
1847+ return -1 ;
1848+
1849+ allow_nan = PyObject_IsTrue (allow_nan_obj );
1850+ if (allow_nan < 0 )
18361851 return -1 ;
18371852
18381853 s -> markers = markers ;
@@ -1844,7 +1859,7 @@ encoder_init(PyObject *self, PyObject *args, PyObject *kwds)
18441859 s -> sort_keys = sort_keys ;
18451860 s -> skipkeys = skipkeys ;
18461861 s -> fast_encode = (PyCFunction_Check (s -> encoder ) && PyCFunction_GetFunction (s -> encoder ) == (PyCFunction )py_encode_basestring_ascii );
1847- s -> allow_nan = PyObject_IsTrue ( allow_nan ) ;
1862+ s -> allow_nan = allow_nan ;
18481863
18491864 Py_INCREF (s -> markers );
18501865 Py_INCREF (s -> defaultfn );
@@ -2110,6 +2125,8 @@ encoder_listencode_dict(PyEncoderObject *s, PyObject *rval, PyObject *dct, Py_ss
21102125 if (it == NULL )
21112126 goto bail ;
21122127 skipkeys = PyObject_IsTrue (s -> skipkeys );
2128+ if (skipkeys < 0 )
2129+ goto bail ;
21132130 idx = 0 ;
21142131 while ((key = PyIter_Next (it )) != NULL ) {
21152132 PyObject * encoded ;
0 commit comments