Simplify and improve version setting for marshalled code objects:

* Use a simpler check for validity -- the reverse magic number mapping was
  unnecessary and missed some cases (2.2, 3.2).
* Set the version directly after it is checked for validity.
* Fix unicode flag setting on Python 3.x.
This commit is contained in:
Michael Hansen
2022-10-04 14:51:23 -07:00
parent 4951905f83
commit 8590d67d29
2 changed files with 21 additions and 55 deletions

View File

@@ -37,8 +37,6 @@ enum PycMagic {
INVALID = 0,
};
PycMagic version_to_magic(int major, int minor);
class PycModule {
public:
PycModule() : m_maj(-1), m_min(-1), m_unicode(false) { }
@@ -72,6 +70,8 @@ public:
void refObject(PycRef<PycObject> str) { m_refs.push_back(str); }
PycRef<PycObject> getRef(int ref) const;
static bool isSupportedVersion(int major, int minor);
private:
void setVersion(unsigned int magic);