Adjust CO_FUTURE_ flags to match Python 3.8 changes, and add some missing flags

Fixes #504
This commit is contained in:
Michael Hansen
2024-08-04 12:43:23 -07:00
parent 0b45b5fa07
commit 0942dec653
2 changed files with 30 additions and 17 deletions

View File

@@ -64,6 +64,13 @@ void PycCode::load(PycData* stream, PycModule* mod)
else
m_flags = 0;
if (mod->verCompare(3, 8) < 0) {
// Remap flags to new values introduced in 3.8
if (m_flags & 0xF0000000)
throw std::runtime_error("Cannot remap unexpected flags");
m_flags = (m_flags & 0xFFFF) | ((m_flags & 0xFFF0000) << 4);
}
m_code = LoadObject(stream, mod).cast<PycString>();
m_consts = LoadObject(stream, mod).cast<PycSequence>();
m_names = LoadObject(stream, mod).cast<PycSequence>();