Replace execfile with open+compile+exec

This commit is contained in:
Daniel Martí 2016-01-04 17:01:37 +01:00
parent ca5ee87b16
commit 6819c109fe

View file

@ -20,6 +20,7 @@
# common.py is imported by all modules, so do not import third-party # common.py is imported by all modules, so do not import third-party
# libraries here as they will become a requirement for all commands. # libraries here as they will become a requirement for all commands.
import io
import os import os
import sys import sys
import re import re
@ -206,7 +207,9 @@ def read_config(opts, config_file='config.py'):
config = {} config = {}
logging.debug("Reading %s" % config_file) logging.debug("Reading %s" % config_file)
execfile(config_file, config) with io.open(config_file, "rb") as f:
code = compile(f.read(), config_file, 'exec')
exec(code, None, config)
# smartcardoptions must be a list since its command line args for Popen # smartcardoptions must be a list since its command line args for Popen
if 'smartcardoptions' in config: if 'smartcardoptions' in config: