diff roundup/configuration.py @ 5517:0cdf19b82354

Fix issue2550994: breakage caused by configparser backports.
author Joseph Myers <jsm@polyomino.org.uk>
date Mon, 20 Aug 2018 00:50:16 +0000
parents b7fa56ced601
children 79da1ca2f94b
line wrap: on
line diff
--- a/roundup/configuration.py	Sun Aug 19 15:26:52 2018 +0100
+++ b/roundup/configuration.py	Mon Aug 20 00:50:16 2018 +0000
@@ -2,9 +2,15 @@
 #
 __docformat__ = "restructuredtext"
 
-try:
+# Some systems have a backport of the Python 3 configparser module to
+# Python 2: <https://pypi.org/project/configparser/>.  That breaks
+# Roundup if used with Python 2 because it generates unicode objects
+# where not expected by the Python code.  Thus, a version check is
+# used here instead of try/except.
+import sys
+if sys.version_info[0] > 2:
     import configparser			# Python 3
-except ImportError:
+else:
     import ConfigParser as configparser	# Python 2
 
 import getopt
@@ -12,7 +18,6 @@
 import logging, logging.config
 import os
 import re
-import sys
 import time
 import smtplib
 

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