79537981

Date: 2025-03-27 06:19:25
Score: 1
Natty:
Report link

Additionally, you could use pyobject.Code instead, as constructing types.CodeType is too complex and not compatible across multiple Python versions.

The pyobject library, which can be installed via pip install pyobject, provides a high-level wrapper for code objects.

For example:

>>> def f(a,b,c,*args):
...    print(a,b,c,args)
...
>>> c=Code.fromfunc(f)
>>> c.get_flags() # automatically parse them, not by manually calculating
['OPTIMIZED', 'NEWLOCALS', 'VARARGS']
>>> c.co_flags
7

The pyobject library has greatly changed, and pyobject versions since 1.2.4 has fixed the issue. pyobject ยท Github

Note: I'm the developer of pyobject.

Reasons:
  • Contains signature (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: qfcy