@@ -1569,46 +1569,43 @@ _Py_CompileString(const char *str, PyObject *filename, int start,
15691569 return NULL ;
15701570 }
15711571
1572- PyCodeObject * co ;
1573- mod_ty mod ;
15741572 PyArena * arena = _PyArena_New ();
15751573 if (arena == NULL )
15761574 return NULL ;
15771575
1576+ PyObject * result = NULL ;
15781577 PyObject * incomplete = NULL ;
1579- mod = _PyParser_ASTFromString (str , filename , start , flags , arena , module ,
1580- & incomplete );
1578+ mod_ty mod = _PyParser_ASTFromString (str , filename , start , flags , arena ,
1579+ module , & incomplete );
15811580 if (mod == NULL ) {
1582- _PyArena_Free (arena );
1583- return NULL ;
1581+ goto done ;
15841582 }
15851583 if (flags && (flags -> cf_flags & PyCF_ONLY_AST )) {
15861584 int syntax_check_only = ((flags -> cf_flags & PyCF_OPTIMIZED_AST ) == PyCF_ONLY_AST ); /* unoptiomized AST */
15871585 if (_PyCompile_AstPreprocess (mod , filename , flags , optimize , arena ,
15881586 syntax_check_only , module ) < 0 )
15891587 {
1590- Py_XDECREF (incomplete );
1591- _PyArena_Free (arena );
1592- return NULL ;
1588+ goto done ;
15931589 }
15941590 if (incomplete != NULL ) {
1595- _PyArena_Free (arena );
1596- PyErr_SetRaisedException (incomplete );
1597- return NULL ;
1591+ goto done ;
15981592 }
1599- PyObject * result = PyAST_mod2obj (mod );
1593+ result = PyAST_mod2obj (mod );
16001594 _PyArena_Free (arena );
16011595 return result ;
16021596 }
1603- co = _PyAST_Compile (mod , filename , flags , optimize , arena , module );
1597+ result = (PyObject * )_PyAST_Compile (mod , filename , flags , optimize , arena , module );
1598+
1599+ done :
16041600 _PyArena_Free (arena );
1605- if (co != NULL && incomplete != NULL ) {
1606- Py_DECREF ( co );
1601+ if (incomplete != NULL && ! PyErr_Occurred () ) {
1602+ Py_CLEAR ( result );
16071603 PyErr_SetRaisedException (incomplete );
1608- return NULL ;
16091604 }
1610- Py_XDECREF (incomplete );
1611- return (PyObject * )co ;
1605+ else {
1606+ Py_XDECREF (incomplete );
1607+ }
1608+ return result ;
16121609}
16131610
16141611PyObject *
0 commit comments