#388 Silence Python3 SafeConfigParser warnings
Merged 5 years ago by onosek. Opened 5 years ago by merlinm.

file modified
+7 -1
@@ -55,6 +55,12 @@

      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 @@

  

      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)

  

file modified
+6 -1
@@ -54,11 +54,16 @@

  - 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')

This PR silences the following warning:

DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead.

Maybe it can just use ConfigParser. For py2/3 compatibility, it's six.moves.configparser.ConfigParser.

Commit cc26575 fixes this pull-request

Pull-Request has been merged by onosek

5 years ago

Pull-Request has been merged by onosek

5 years ago