diff options
Diffstat (limited to 'coverage/backward.py')
-rw-r--r-- | coverage/backward.py | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/coverage/backward.py b/coverage/backward.py index da839d71..15f4e88a 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -3,84 +3,8 @@ """Add things to old Pythons so I can pretend they are newer.""" -# This file's purpose is to provide modules to be imported from here. -# pylint: disable=unused-import - -import os import sys -from datetime import datetime - - -# Pythons 2 and 3 differ on where to get StringIO. -try: - from cStringIO import StringIO -except ImportError: - from io import StringIO - -# In py3, ConfigParser was renamed to the more-standard configparser. -# But there's a py3 backport that installs "configparser" in py2, and I don't -# want it because it has annoying deprecation warnings. So try the real py2 -# import first. -try: - import ConfigParser as configparser -except ImportError: - import configparser - -# What's a string called? -try: - string_class = basestring -except NameError: - string_class = str - -# What's a Unicode string called? -try: - unicode_class = unicode -except NameError: - unicode_class = str - -# range or xrange? -try: - range = xrange # pylint: disable=redefined-builtin -except NameError: - range = range - -try: - from itertools import zip_longest -except ImportError: - from itertools import izip_longest as zip_longest - -# Where do we get the thread id from? -try: - from thread import get_ident as get_thread_id -except ImportError: - from threading import get_ident as get_thread_id - -try: - os.PathLike -except AttributeError: - # This is Python 2 and 3 - path_types = (bytes, string_class, unicode_class) -else: - # 3.6+ - path_types = (bytes, str, os.PathLike) - -# shlex.quote is new, but there's an undocumented implementation in "pipes", -# who knew!? -try: - from shlex import quote as shlex_quote -except ImportError: - # Useful function, available under a different (undocumented) name - # in Python versions earlier than 3.3. - from pipes import quote as shlex_quote - -try: - import reprlib -except ImportError: # pragma: not covered - # We need this on Python 2, but in testing environments, a backport is - # installed, so this import isn't used. - import repr as reprlib - # A function to iterate listlessly over a dict's items, and one to get the # items as a list. try: |