diff options
-rw-r--r-- | coverage/backward.py | 6 | ||||
-rw-r--r-- | coverage/config.py | 23 |
2 files changed, 11 insertions, 18 deletions
diff --git a/coverage/backward.py b/coverage/backward.py index 5dbb411d..340dc130 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -19,6 +19,12 @@ try: except ImportError: from io import StringIO +# In py3, ConfigParser was renamed to the more-standard configparser +try: + import configparser +except ImportError: + import ConfigParser as configparser + # What's a string called? try: string_class = basestring diff --git a/coverage/config.py b/coverage/config.py index c64be6c3..4b50712f 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -4,17 +4,10 @@ """Config file for coverage.py""" import os, re, sys -from coverage.backward import string_class, iitems +from coverage.backward import configparser, iitems, string_class from coverage.misc import CoverageException -# In py3, ConfigParser was renamed to the more-standard configparser -try: - import configparser -except ImportError: - import ConfigParser as configparser - - class HandyConfigParser(configparser.RawConfigParser): """Our specialization of ConfigParser.""" @@ -114,10 +107,8 @@ class HandyConfigParser(configparser.RawConfigParser): re.compile(value) except re.error as e: raise CoverageException( - "Invalid [%s].%s value %r: %s" % ( - section, option, value, e - ) - ) + "Invalid [%s].%s value %r: %s" % (section, option, value, e) + ) if value: value_list.append(value) return value_list @@ -218,9 +209,7 @@ class CoverageConfig(object): try: files_read = cp.read(filename) except configparser.Error as err: - raise CoverageException( - "Couldn't read config file %s: %s" % (filename, err) - ) + raise CoverageException("Couldn't read config file %s: %s" % (filename, err)) if not files_read: return False @@ -230,9 +219,7 @@ class CoverageConfig(object): for option_spec in self.CONFIG_FILE_OPTIONS: self._set_attr_from_config_option(cp, *option_spec) except ValueError as err: - raise CoverageException( - "Couldn't read config file %s: %s" % (filename, err) - ) + raise CoverageException("Couldn't read config file %s: %s" % (filename, err)) # [paths] is special if cp.has_section('paths'): |