turn off strict config parsing in py3

This commit is contained in:
Alan Hamlett 2021-11-16 09:43:20 -08:00
parent 650bb6fa26
commit 086c700151

View File

@ -34,9 +34,10 @@ except ImportError:
import queue # py3 import queue # py3
try: try:
import ConfigParser as configparser from ConfigParser import SafeConfigParser as ConfigParser
from ConfigParser import Error as ConfigParserError
except ImportError: except ImportError:
import configparser from configparser import ConfigParser, Error as ConfigParserError
try: try:
from urllib2 import urlopen, urlretrieve, ProxyHandler, build_opener, install_opener, HTTPError from urllib2 import urlopen, urlretrieve, ProxyHandler, build_opener, install_opener, HTTPError
except ImportError: except ImportError:
@ -154,13 +155,17 @@ def parseConfigFile(configFile):
at ~/.wakatime.cfg. at ~/.wakatime.cfg.
""" """
configs = configparser.SafeConfigParser() kwargs = {} if is_py2 else {'strict': False}
configs = ConfigParser(**kwargs)
try: try:
with open(configFile, 'r', encoding='utf-8') as fh: with open(configFile, 'r', encoding='utf-8') as fh:
try: try:
if is_py2:
configs.readfp(fh) configs.readfp(fh)
else:
configs.read_file(fh)
return configs return configs
except configparser.Error: except ConfigParserError:
log(ERROR, traceback.format_exc()) log(ERROR, traceback.format_exc())
return None return None
except IOError: except IOError: