From a361ff3897736917544da1a4e28d8db6457f0fcc Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 1 Aug 2019 09:42:54 -0400 Subject: Add num_in_numbits --- coverage/backward.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'coverage/backward.py') diff --git a/coverage/backward.py b/coverage/backward.py index 0df2a41e..34ab2f1a 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -114,6 +114,10 @@ if env.PY3: """Produce a byte string with the ints from `byte_values`.""" return bytes(byte_values) + def byte_to_int(byte): + """Turn a byte indexed from a bytes object into an int.""" + return byte + def bytes_to_ints(bytes_value): """Turn a bytes object into a sequence of ints.""" # In Python 3, iterating bytes gives ints. @@ -132,6 +136,10 @@ else: """Produce a byte string with the ints from `byte_values`.""" return "".join(chr(b) for b in byte_values) + def byte_to_int(byte): + """Turn a byte indexed from a bytes object into an int.""" + return ord(byte) + def bytes_to_ints(bytes_value): """Turn a bytes object into a sequence of ints.""" for byte in bytes_value: -- cgit v1.2.1