Fix LOAD_GLOBAL and cell var references in Python 3.11+

This commit is contained in:
Michael Hansen
2023-01-19 13:05:06 -08:00
parent 379c0c94d0
commit 5d855f0bd2
4 changed files with 30 additions and 12 deletions

View File

@@ -87,3 +87,13 @@ void PycCode::load(PycData* stream, PycModule* mod)
else
m_exceptTable = new PycString;
}
PycRef<PycString> PycCode::getCellVar(PycModule* mod, int idx) const
{
if (mod->verCompare(3, 11) >= 0)
return getLocal(idx);
return (idx >= m_cellVars->size())
? m_freeVars->get(idx - m_cellVars->size()).cast<PycString>()
: m_cellVars->get(idx).cast<PycString>();
}