From 775c14a764ff3fd32bcd25d91f4c0f635722ed50 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 1 May 2021 14:04:02 -0400 Subject: refactor: remove more unneeded backward.py shims Gone are: - iitems - litems - iternext - to_bytes - to_string - binary_bytes - byte_to_int - bytes_to_ints - BUILTINS --- coverage/backward.py | 66 ---------------------------------------------------- 1 file changed, 66 deletions(-) (limited to 'coverage/backward.py') diff --git a/coverage/backward.py b/coverage/backward.py index 15f4e88a..26d8d0e5 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -5,72 +5,6 @@ import sys -# A function to iterate listlessly over a dict's items, and one to get the -# items as a list. -try: - {}.iteritems -except AttributeError: - # Python 3 - def iitems(d): - """Produce the items from dict `d`.""" - return d.items() - - def litems(d): - """Return a list of items from dict `d`.""" - return list(d.items()) -else: - # Python 2 - def iitems(d): - """Produce the items from dict `d`.""" - return d.iteritems() - - def litems(d): - """Return a list of items from dict `d`.""" - return d.items() - -# Getting the `next` function from an iterator is different in 2 and 3. -try: - iter([]).next -except AttributeError: - def iternext(seq): - """Get the `next` function for iterating over `seq`.""" - return iter(seq).__next__ -else: - def iternext(seq): - """Get the `next` function for iterating over `seq`.""" - return iter(seq).next - -# Python 3.x is picky about bytes and strings, so provide methods to -# get them right. -def to_bytes(s): - """Convert string `s` to bytes.""" - return s.encode('utf8') - -def to_string(b): - """Convert bytes `b` to 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): - """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. - return bytes_value - -try: - # In Python 2.x, the builtins were in __builtin__ - BUILTINS = sys.modules['__builtin__'] -except KeyError: - # In Python 3.x, they're in builtins - BUILTINS = sys.modules['builtins'] - - # imp was deprecated in Python 3.3 try: import importlib -- cgit v1.2.1