Update read_config for new API in Python 3.2

--HG--
branch : py3k
master
Dustin C. Hatch 2013-01-05 10:38:05 -06:00
parent fed7d0fb3d
commit 0064f70160
1 changed files with 8 additions and 2 deletions

View File

@ -40,8 +40,14 @@ def read_config(filename):
app.config.update(config)
'''
with open(filename) as f:
# ConfigParser API changed in Python 3.2
if hasattr(configparser.ConfigParser, 'read_file'):
cparser = configparser.ConfigParser()
cparser.read_file(f)
else:
cparser = configparser.SafeConfigParser()
cparser.readfp(open(filename))
cparser.readfp(f)
config = {}
for section in cparser.sections():