# Coverage for utils/codeobj.py : 100%

## 7 statements 7 run 0 missing 0 excluded 0 partial

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 -*-

2 from __future__ import annotations

3

4# -- stdlib --

5 import types

6

7# -- third party --

8# -- own --

9

10# -- code --

11 CO_FIELDS = [s[3:] for s in dir(types.CodeType) if s.startswith('co_')]

12

13

14 def 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 )