@@ -1691,7 +1691,7 @@ PyCode_GetFreevars(PyCodeObject *code)
16911691
16921692
16931693static int
1694- identify_unbound_names (PyCodeObject * co ,
1694+ identify_unbound_names (PyThreadState * tstate , PyCodeObject * co ,
16951695 PyObject * globalnames , PyObject * attrnames ,
16961696 PyObject * globalsns , PyObject * builtinsns ,
16971697 struct co_unbound_counts * counts )
@@ -1715,7 +1715,7 @@ identify_unbound_names(PyCodeObject *co,
17151715 PyObject * name = PyTuple_GET_ITEM (co -> co_names , inst .op .arg >>1 );
17161716 if (counts != NULL ) {
17171717 if (PySet_Contains (attrnames , name )) {
1718- if (PyErr_Occurred ( )) {
1718+ if (_PyErr_Occurred ( tstate )) {
17191719 return -1 ;
17201720 }
17211721 continue ;
@@ -1731,7 +1731,7 @@ identify_unbound_names(PyCodeObject *co,
17311731 PyObject * name = PyTuple_GET_ITEM (co -> co_names , inst .op .arg >>1 );
17321732 if (counts != NULL ) {
17331733 if (PySet_Contains (globalnames , name )) {
1734- if (PyErr_Occurred ( )) {
1734+ if (_PyErr_Occurred ( tstate )) {
17351735 return -1 ;
17361736 }
17371737 continue ;
@@ -1740,14 +1740,14 @@ identify_unbound_names(PyCodeObject *co,
17401740 counts -> globals .total += 1 ;
17411741 counts -> globals .numunknown += 1 ;
17421742 if (globalsns != NULL && PyDict_Contains (globalsns , name )) {
1743- if (PyErr_Occurred ( )) {
1743+ if (_PyErr_Occurred ( tstate )) {
17441744 return -1 ;
17451745 }
17461746 counts -> globals .numglobal += 1 ;
17471747 counts -> globals .numunknown -= 1 ;
17481748 }
17491749 if (builtinsns != NULL && PyDict_Contains (builtinsns , name )) {
1750- if (PyErr_Occurred ( )) {
1750+ if (_PyErr_Occurred ( tstate )) {
17511751 return -1 ;
17521752 }
17531753 counts -> globals .numbuiltin += 1 ;
@@ -1866,7 +1866,8 @@ _PyCode_GetVarCounts(PyCodeObject *co, _PyCode_var_counts_t *counts)
18661866}
18671867
18681868int
1869- _PyCode_SetUnboundVarCounts (PyCodeObject * co , _PyCode_var_counts_t * counts ,
1869+ _PyCode_SetUnboundVarCounts (PyThreadState * tstate ,
1870+ PyCodeObject * co , _PyCode_var_counts_t * counts ,
18701871 PyObject * globalnames , PyObject * attrnames ,
18711872 PyObject * globalsns , PyObject * builtinsns )
18721873{
@@ -1881,7 +1882,7 @@ _PyCode_SetUnboundVarCounts(PyCodeObject *co, _PyCode_var_counts_t *counts,
18811882 globalnames = globalnames_owned ;
18821883 }
18831884 else if (!PySet_Check (globalnames )) {
1884- PyErr_Format ( PyExc_TypeError ,
1885+ _PyErr_Format ( tstate , PyExc_TypeError ,
18851886 "expected a set for \"globalnames\", got %R" , globalnames );
18861887 goto finally ;
18871888 }
@@ -1893,14 +1894,15 @@ _PyCode_SetUnboundVarCounts(PyCodeObject *co, _PyCode_var_counts_t *counts,
18931894 attrnames = attrnames_owned ;
18941895 }
18951896 else if (!PySet_Check (attrnames )) {
1896- PyErr_Format ( PyExc_TypeError ,
1897+ _PyErr_Format ( tstate , PyExc_TypeError ,
18971898 "expected a set for \"attrnames\", got %R" , attrnames );
18981899 goto finally ;
18991900 }
19001901
19011902 struct co_unbound_counts unbound = {0 };
19021903 if (identify_unbound_names (
1903- co , globalnames , attrnames , globalsns , builtinsns , & unbound ) < 0 )
1904+ tstate , co , globalnames , attrnames , globalsns , builtinsns ,
1905+ & unbound ) < 0 )
19041906 {
19051907 goto finally ;
19061908 }
0 commit comments