Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: third_party/coverage-3.7.1/coverage/bytecode.py

Issue 225633007: Upgrade to coverage 3.7.1 and have it auto-build itself on first use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: sigh our imports are a mess Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/coverage-3.7.1/coverage/backward.py ('k') | third_party/coverage-3.7.1/coverage/cmdline.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/coverage-3.7.1/coverage/bytecode.py
diff --git a/third_party/coverage-3.6/coverage/bytecode.py b/third_party/coverage-3.7.1/coverage/bytecode.py
similarity index 52%
rename from third_party/coverage-3.6/coverage/bytecode.py
rename to third_party/coverage-3.7.1/coverage/bytecode.py
index fd5c7da26c85aa18744c4f077f690095c2d5ce68..85360638528e6bece33b1f5a1e4dd08e5c2ac3d0 100644
--- a/third_party/coverage-3.6/coverage/bytecode.py
+++ b/third_party/coverage-3.7.1/coverage/bytecode.py
@@ -1,6 +1,8 @@
"""Bytecode manipulation for coverage.py"""
-import opcode, sys, types
+import opcode, types
+
+from coverage.backward import byte_to_int
class ByteCode(object):
"""A single bytecode."""
@@ -30,42 +32,31 @@ class ByteCodes(object):
# pylint: disable=R0924
def __init__(self, code):
self.code = code
- self.offset = 0
- if sys.version_info >= (3, 0):
- def __getitem__(self, i):
- return self.code[i]
- else:
- def __getitem__(self, i):
- return ord(self.code[i])
+ def __getitem__(self, i):
+ return byte_to_int(self.code[i])
def __iter__(self):
- return self
-
- def __next__(self):
- if self.offset >= len(self.code):
- raise StopIteration
-
- bc = ByteCode()
- bc.op = self[self.offset]
- bc.offset = self.offset
-
- next_offset = self.offset+1
- if bc.op >= opcode.HAVE_ARGUMENT:
- bc.arg = self[self.offset+1] + 256*self[self.offset+2]
- next_offset += 2
+ offset = 0
+ while offset < len(self.code):
+ bc = ByteCode()
+ bc.op = self[offset]
+ bc.offset = offset
- label = -1
- if bc.op in opcode.hasjrel:
- label = next_offset + bc.arg
- elif bc.op in opcode.hasjabs:
- label = bc.arg
- bc.jump_to = label
+ next_offset = offset+1
+ if bc.op >= opcode.HAVE_ARGUMENT:
+ bc.arg = self[offset+1] + 256*self[offset+2]
+ next_offset += 2
- bc.next_offset = self.offset = next_offset
- return bc
+ label = -1
+ if bc.op in opcode.hasjrel:
+ label = next_offset + bc.arg
+ elif bc.op in opcode.hasjabs:
+ label = bc.arg
+ bc.jump_to = label
- next = __next__ # Py2k uses an old-style non-dunder name.
+ bc.next_offset = offset = next_offset
+ yield bc
class CodeObjects(object):
@@ -74,18 +65,11 @@ class CodeObjects(object):
self.stack = [code]
def __iter__(self):
- return self
-
- def __next__(self):
- if self.stack:
+ 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)
- return code
-
- raise StopIteration
-
- next = __next__
+ yield code
« no previous file with comments | « third_party/coverage-3.7.1/coverage/backward.py ('k') | third_party/coverage-3.7.1/coverage/cmdline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698