Index: third_party/coverage-3.7.1/coverage/backward.py |
diff --git a/third_party/coverage-3.6/coverage/backward.py b/third_party/coverage-3.7.1/coverage/backward.py |
similarity index 77% |
rename from third_party/coverage-3.6/coverage/backward.py |
rename to third_party/coverage-3.7.1/coverage/backward.py |
index 2c015af2ba1bcdb9897a78f291929c21397398fd..7d2685459782c85c59ff7b78cf8d02adf4b2ca89 100644 |
--- a/third_party/coverage-3.6/coverage/backward.py |
+++ b/third_party/coverage-3.7.1/coverage/backward.py |
@@ -24,6 +24,15 @@ except NameError: |
lst.sort() |
return lst |
+# Python 2.3 doesn't have `reversed`. |
+try: |
+ reversed = reversed |
+except NameError: |
+ def reversed(iterable): |
+ """A 2.3-compatible implementation of `reversed`.""" |
+ lst = list(iterable) |
+ return lst[::-1] |
+ |
# rpartition is new in 2.5 |
try: |
"".rpartition |
@@ -66,14 +75,16 @@ except NameError: |
range = range |
# A function to iterate listlessly over a dict's items. |
-if "iteritems" in dir({}): |
+try: |
+ {}.iteritems |
+except AttributeError: |
def iitems(d): |
"""Produce the items from dict `d`.""" |
- return d.iteritems() |
+ return d.items() |
else: |
def iitems(d): |
"""Produce the items from dict `d`.""" |
- return d.items() |
+ return d.iteritems() |
# Exec is a statement in Py2, a function in Py3 |
if sys.version_info >= (3, 0): |
@@ -129,6 +140,19 @@ if sys.version_info >= (3, 0): |
"""Convert bytes `b` to a string.""" |
return b.decode('utf8') |
+ def binary_bytes(byte_values): |
+ """Produce a byte string with the ints from `byte_values`.""" |
+ return bytes(byte_values) |
+ |
+ def byte_to_int(byte_value): |
+ """Turn an element of a bytes object into an int.""" |
+ return byte_value |
+ |
+ def bytes_to_ints(bytes_value): |
+ """Turn a bytes object into a sequence of ints.""" |
+ # In Py3, iterating bytes gives ints. |
+ return bytes_value |
+ |
else: |
def to_bytes(s): |
"""Convert string `s` to bytes (no-op in 2.x).""" |
@@ -138,6 +162,19 @@ else: |
"""Convert bytes `b` to a string (no-op in 2.x).""" |
return b |
+ def binary_bytes(byte_values): |
+ """Produce a byte string with the ints from `byte_values`.""" |
+ return "".join([chr(b) for b in byte_values]) |
+ |
+ def byte_to_int(byte_value): |
+ """Turn an element of a bytes object into an int.""" |
+ return ord(byte_value) |
+ |
+ def bytes_to_ints(bytes_value): |
+ """Turn a bytes object into a sequence of ints.""" |
+ for byte in bytes_value: |
+ yield ord(byte) |
+ |
# Md5 is available in different places. |
try: |
import hashlib |