DebugClients/Python/coverage/bytecode.py

changeset 5141
bc64243b7672
parent 5126
d28b92dabc2b
parent 5140
01484c0afbc6
child 5144
1ab536d25072
equal deleted inserted replaced
5126:d28b92dabc2b 5141:bc64243b7672
1 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2 # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt
3
4 """Bytecode manipulation for coverage.py"""
5
6 import types
7
8
9 class CodeObjects(object):
10 """Iterate over all the code objects in `code`."""
11 def __init__(self, code):
12 self.stack = [code]
13
14 def __iter__(self):
15 while self.stack:
16 # We're going to return the code object on the stack, but first
17 # push its children for later returning.
18 code = self.stack.pop()
19 for c in code.co_consts:
20 if isinstance(c, types.CodeType):
21 self.stack.append(c)
22 yield code
23
24 #
25 # eflag: FileType = Python2

eric ide

mercurial