summaryrefslogtreecommitdiff
path: root/coverage/bytecode.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2013-09-28 10:07:55 -0400
committerNed Batchelder <ned@nedbatchelder.com>2013-09-28 10:07:55 -0400
commita9739749d841818a31ae956fe02e0b3f03a82a31 (patch)
tree807180ce6c7df203b926d414322c9d0c84b71dff /coverage/bytecode.py
parent702d355f9bd2c218a7932e33fe3f587a8f7e3035 (diff)
downloadpython-coveragepy-a9739749d841818a31ae956fe02e0b3f03a82a31.tar.gz
More abstractions for bytes objects. Cleans up some version checks in the real code.
Diffstat (limited to 'coverage/bytecode.py')
-rw-r--r--coverage/bytecode.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/coverage/bytecode.py b/coverage/bytecode.py
index 06bc1df..8536063 100644
--- a/coverage/bytecode.py
+++ b/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."""
@@ -31,12 +33,8 @@ class ByteCodes(object):
def __init__(self, code):
self.code = code
- 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):
offset = 0