diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2019-06-17 22:01:04 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2019-06-17 22:01:04 -0400 |
commit | ee236052e3ed65ea388aa82958d0ce474aa42b33 (patch) | |
tree | f02b3d4ebd430ea8794465ddee53f331943dbe7e /coverage/bytecode.py | |
parent | 21bb447e266831ed44388d9fb9a5327effddee19 (diff) | |
download | python-coveragepy-git-ee236052e3ed65ea388aa82958d0ce474aa42b33.tar.gz |
This class was simpler as a function
Diffstat (limited to 'coverage/bytecode.py')
-rw-r--r-- | coverage/bytecode.py | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/coverage/bytecode.py b/coverage/bytecode.py index 943f29e1..ceb18cf3 100644 --- a/coverage/bytecode.py +++ b/coverage/bytecode.py @@ -6,17 +6,14 @@ import types -class CodeObjects(object): +def code_objects(code): """Iterate over all the code objects in `code`.""" - def __init__(self, code): - self.stack = [code] - - def __iter__(self): - while self.stack: - # We're going to return the code object on the stack, but first - # push its children for later returning. - code = self.stack.pop() - for c in code.co_consts: - if isinstance(c, types.CodeType): - self.stack.append(c) - yield code + stack = [code] + while stack: + # We're going to return the code object on the stack, but first + # push its children for later returning. + code = stack.pop() + for c in code.co_consts: + if isinstance(c, types.CodeType): + stack.append(c) + yield code |