From 7a3a2cc47894fbf7d85569d68496a5ddc21bff91 Mon Sep 17 00:00:00 2001 From: gecong1973 Date: Fri, 23 Sep 2016 14:03:41 +0800 Subject: [PATCH] Use ConfigParser instead of SafeConfigParser in Python 3 The SafeConfigParser class has been renamed to ConfigParser in Python 3.2 [1]. The alias SafeConfigParser maybe removed in future versions of Python 3. Use ConfigParser instead of SafeConfigParser in Python 3 [1] http://bugs.python.org/issue10627 Change-Id: I1354b9fde203c9478bd77b71ec74a69304428385 --- freezer/utils/config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/freezer/utils/config.py b/freezer/utils/config.py index 1de90153..93acb0b4 100644 --- a/freezer/utils/config.py +++ b/freezer/utils/config.py @@ -15,6 +15,7 @@ import os import re +import six from six.moves import configparser from six.moves import cStringIO @@ -36,7 +37,11 @@ class Config(object): " found".format(config_path)) raise Exception("Configuration file {0} not found !".format( config_path)) - config = configparser.SafeConfigParser() + # SafeConfigParser was deprecated in Python 3.2 + if six.PY3: + config = configparser.ConfigParser() + else: + config = configparser.SafeConfigParser() config.read([config_path]) sections = config.sections() storages = []