@@ -1932,10 +1932,12 @@ _PyCode_SetUnboundVarCounts(PyThreadState *tstate,
19321932
19331933 // Fill in unbound.globals and unbound.numattrs.
19341934 struct co_unbound_counts unbound = {0 };
1935- if (identify_unbound_names (
1935+ Py_BEGIN_CRITICAL_SECTION (co );
1936+ res = identify_unbound_names (
19361937 tstate , co , globalnames , attrnames , globalsns , builtinsns ,
1937- & unbound ) < 0 )
1938- {
1938+ & unbound );
1939+ Py_END_CRITICAL_SECTION ();
1940+ if (res < 0 ) {
19391941 goto finally ;
19401942 }
19411943 assert (unbound .numunknown == 0 );
@@ -1956,8 +1958,8 @@ _PyCode_SetUnboundVarCounts(PyThreadState *tstate,
19561958/* Here "value" means a non-None value, since a bare return is identical
19571959 * to returning None explicitly. Likewise a missing return statement
19581960 * at the end of the function is turned into "return None". */
1959- int
1960- _PyCode_ReturnsOnlyNone (PyCodeObject * co )
1961+ static int
1962+ code_returns_only_none (PyCodeObject * co )
19611963{
19621964 // Look up None in co_consts.
19631965 Py_ssize_t nconsts = PyTuple_Size (co -> co_consts );
@@ -1994,6 +1996,16 @@ _PyCode_ReturnsOnlyNone(PyCodeObject *co)
19941996 return 1 ;
19951997}
19961998
1999+ int
2000+ _PyCode_ReturnsOnlyNone (PyCodeObject * co )
2001+ {
2002+ int res ;
2003+ Py_BEGIN_CRITICAL_SECTION (co );
2004+ res = code_returns_only_none (co );
2005+ Py_END_CRITICAL_SECTION ();
2006+ return res ;
2007+ }
2008+
19972009
19982010#ifdef _Py_TIER2
19992011
0 commit comments