Coverage for utils/codeobj.py : 100%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- coding: utf-8 -*-
2from __future__ import annotations
4# -- stdlib --
5import types
7# -- third party --
8# -- own --
10# -- code --
11CO_FIELDS = [s[3:] for s in dir(types.CodeType) if s.startswith('co_')]
14def adjust(code, **kw):
15 content = {k: getattr(code, f'co_{k}') for k in CO_FIELDS}
16 content.update(kw)
17 return types.CodeType(
18 content["argcount"],
19 content["kwonlyargcount"],
20 content["nlocals"],
21 content["stacksize"],
22 content["flags"],
23 content["code"],
24 content["consts"],
25 content["names"],
26 content["varnames"],
27 content["filename"],
28 content["name"],
29 content["firstlineno"],
30 content["lnotab"],
31 content["freevars"],
32 content["cellvars"],
33 )