summaryrefslogtreecommitdiff
path: root/coverage/bytecode.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-06-17 22:01:04 -0400
committerNed Batchelder <ned@nedbatchelder.com>2019-06-17 22:01:04 -0400
commitee236052e3ed65ea388aa82958d0ce474aa42b33 (patch)
treef02b3d4ebd430ea8794465ddee53f331943dbe7e /coverage/bytecode.py
parent21bb447e266831ed44388d9fb9a5327effddee19 (diff)
downloadpython-coveragepy-git-ee236052e3ed65ea388aa82958d0ce474aa42b33.tar.gz
This class was simpler as a function
Diffstat (limited to 'coverage/bytecode.py')
-rw-r--r--coverage/bytecode.py23
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