@@ -1932,10 +1932,12 @@ _PyCode_SetUnboundVarCounts(PyThreadState *tstate,
1932
1932
1933
1933
// Fill in unbound.globals and unbound.numattrs.
1934
1934
struct co_unbound_counts unbound = {0 };
1935
- if (identify_unbound_names (
1935
+ Py_BEGIN_CRITICAL_SECTION (co );
1936
+ res = identify_unbound_names (
1936
1937
tstate , co , globalnames , attrnames , globalsns , builtinsns ,
1937
- & unbound ) < 0 )
1938
- {
1938
+ & unbound );
1939
+ Py_END_CRITICAL_SECTION ();
1940
+ if (res < 0 ) {
1939
1941
goto finally ;
1940
1942
}
1941
1943
assert (unbound .numunknown == 0 );
@@ -1956,8 +1958,8 @@ _PyCode_SetUnboundVarCounts(PyThreadState *tstate,
1956
1958
/* Here "value" means a non-None value, since a bare return is identical
1957
1959
* to returning None explicitly. Likewise a missing return statement
1958
1960
* 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 )
1961
1963
{
1962
1964
// Look up None in co_consts.
1963
1965
Py_ssize_t nconsts = PyTuple_Size (co -> co_consts );
@@ -1994,6 +1996,16 @@ _PyCode_ReturnsOnlyNone(PyCodeObject *co)
1994
1996
return 1 ;
1995
1997
}
1996
1998
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
+
1997
2009
1998
2010
#ifdef _Py_TIER2
1999
2011
0 commit comments