diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-05-01 14:04:02 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-05-01 16:24:37 -0400 |
commit | 775c14a764ff3fd32bcd25d91f4c0f635722ed50 (patch) | |
tree | 2f73d38468b11c4b5f9723265bb121352a13271f /coverage/backward.py | |
parent | e96ef93d18831630687b6c026bed89a1f9149c90 (diff) | |
download | python-coveragepy-git-775c14a764ff3fd32bcd25d91f4c0f635722ed50.tar.gz |
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
Diffstat (limited to 'coverage/backward.py')
-rw-r--r-- | coverage/backward.py | 66 |
1 files changed, 0 insertions, 66 deletions
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 |