From 7210aeab5017fb169ceb841fb9dbe1e57a768e5a Mon Sep 17 00:00:00 2001 From: Merlin Mathesius Date: Oct 29 2018 16:46:13 +0000 Subject: Silence Python3 SafeConfigParser warnings Signed-off-by: Merlin Mathesius --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index cc3c6ba..63ba400 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -55,6 +55,12 @@ if not PY26: gi.require_version('Modulemd', '1.0') # raises ValueError from gi.repository import Modulemd # noqa +if six.PY2: + ConfigParser = configparser.SafeConfigParser +else: + # The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. + ConfigParser = configparser.ConfigParser + class NullHandler(logging.Handler): """Null logger to avoid spurious messages, add a handler in app code""" @@ -3011,7 +3017,7 @@ class Commands(object): def container_build_setup(self, get_autorebuild=None, set_autorebuild=None): - cfp = configparser.SafeConfigParser() + cfp = ConfigParser() if os.path.exists(self.osbs_config_filename): cfp.read(self.osbs_config_filename) diff --git a/tests/test_cli.py b/tests/test_cli.py index 745a97c..2d59941 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -54,11 +54,16 @@ package demo for testing - add new spec ''' +if six.PY2: + ConfigParser = configparser.SafeConfigParser +else: + # The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. + ConfigParser = configparser.ConfigParser class CliTestCase(CommandTestCase): def new_cli(self, cfg=None): - config = configparser.SafeConfigParser() + config = ConfigParser() config.read(cfg or config_file) client = pyrpkg.cli.cliClient(config, name='rpkg')