@@ -946,8 +946,8 @@ _parse_array_unicode(PyScannerObject *s, PyObject *memo, PyObject *pystr, Py_ssi
946946 goto bail ;
947947 }
948948 * next_idx_ptr = idx + 1 ;
949- /* if array_hook is not None: rval = array_hook(rval) */
950- if (s -> array_hook != Py_None ) {
949+ /* if array_hook is not None: return array_hook(rval) */
950+ if (! Py_IsNone ( s -> array_hook ) ) {
951951 val = PyObject_CallOneArg (s -> array_hook , rval );
952952 Py_DECREF (rval );
953953 return val ;
@@ -1247,8 +1247,9 @@ scanner_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
12471247 PyObject * strict ;
12481248 static char * kwlist [] = {"context" , NULL };
12491249
1250- if (!PyArg_ParseTupleAndKeywords (args , kwds , "O:make_scanner" , kwlist , & ctx ))
1250+ if (!PyArg_ParseTupleAndKeywords (args , kwds , "O:make_scanner" , kwlist , & ctx )) {
12511251 return NULL ;
1252+ }
12521253
12531254 s = (PyScannerObject * )type -> tp_alloc (type , 0 );
12541255 if (s == NULL ) {
@@ -1257,30 +1258,38 @@ scanner_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
12571258
12581259 /* All of these will fail "gracefully" so we don't need to verify them */
12591260 strict = PyObject_GetAttrString (ctx , "strict" );
1260- if (strict == NULL )
1261+ if (strict == NULL ) {
12611262 goto bail ;
1263+ }
12621264 s -> strict = PyObject_IsTrue (strict );
12631265 Py_DECREF (strict );
1264- if (s -> strict < 0 )
1266+ if (s -> strict < 0 ) {
12651267 goto bail ;
1268+ }
12661269 s -> object_hook = PyObject_GetAttrString (ctx , "object_hook" );
1267- if (s -> object_hook == NULL )
1270+ if (s -> object_hook == NULL ) {
12681271 goto bail ;
1272+ }
12691273 s -> object_pairs_hook = PyObject_GetAttrString (ctx , "object_pairs_hook" );
1270- if (s -> object_pairs_hook == NULL )
1274+ if (s -> object_pairs_hook == NULL ) {
12711275 goto bail ;
1276+ }
12721277 s -> array_hook = PyObject_GetAttrString (ctx , "array_hook" );
1273- if (s -> array_hook == NULL )
1278+ if (s -> array_hook == NULL ) {
12741279 goto bail ;
1280+ }
12751281 s -> parse_float = PyObject_GetAttrString (ctx , "parse_float" );
1276- if (s -> parse_float == NULL )
1282+ if (s -> parse_float == NULL ) {
12771283 goto bail ;
1284+ }
12781285 s -> parse_int = PyObject_GetAttrString (ctx , "parse_int" );
1279- if (s -> parse_int == NULL )
1286+ if (s -> parse_int == NULL ) {
12801287 goto bail ;
1288+ }
12811289 s -> parse_constant = PyObject_GetAttrString (ctx , "parse_constant" );
1282- if (s -> parse_constant == NULL )
1290+ if (s -> parse_constant == NULL ) {
12831291 goto bail ;
1292+ }
12841293
12851294 return (PyObject * )s ;
12861295
0 commit comments