changeset 5246:c5dd7b151ec2

Make an import work with either Python 2 or 3.
author Eric S. Raymond <esr@thyrsus.com>
date Thu, 24 Aug 2017 17:41:38 -0400
parents bc16d91b7a50
children 7f00a47b3559
files roundup/configuration.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/configuration.py	Thu Aug 24 17:27:49 2017 -0400
+++ b/roundup/configuration.py	Thu Aug 24 17:41:38 2017 -0400
@@ -2,7 +2,11 @@
 #
 __docformat__ = "restructuredtext"
 
-import ConfigParser
+try:
+    import configparser			# Python 3
+except ImportError:
+    import ConfigParser as configparser	# Python 2
+
 import getopt
 import imp
 import logging, logging.config
@@ -1373,7 +1377,7 @@
         config_defaults = {"HOME": home_dir}
         if defaults:
             config_defaults.update(defaults)
-        config = ConfigParser.ConfigParser(config_defaults)
+        config = configparser.ConfigParser(config_defaults)
         config.read([config_path])
         # .ini file loaded ok.
         self.HOME = home_dir

Roundup Issue Tracker: http://roundup-tracker.org/