SafeConfigParser has been replaced by ConfigParser.

This commit is contained in:
Itamar Turner-Trauring 2020-10-27 09:35:09 -04:00
parent c76afc9ece
commit 1a7bb06587
2 changed files with 5 additions and 5 deletions

View File

@ -184,7 +184,7 @@ def read_config(basedir, portnumfile, generated_files=[], _valid_config=None):
# (try to) read the main config file # (try to) read the main config file
config_fname = os.path.join(basedir, "tahoe.cfg") config_fname = os.path.join(basedir, "tahoe.cfg")
parser = configparser.SafeConfigParser() parser = configparser.ConfigParser()
try: try:
parser = configutil.get_config(config_fname) parser = configutil.get_config(config_fname)
except EnvironmentError as e: except EnvironmentError as e:
@ -207,7 +207,7 @@ def config_from_string(basedir, portnumfile, config_str, _valid_config=None):
_valid_config = _common_valid_config() _valid_config = _common_valid_config()
# load configuration from in-memory string # load configuration from in-memory string
parser = configparser.SafeConfigParser() parser = configparser.ConfigParser()
if isinstance(config_str, bytes): if isinstance(config_str, bytes):
config_str = config_str.decode("utf-8") config_str = config_str.decode("utf-8")
parser.read_string(config_str) parser.read_string(config_str)

View File

@ -16,7 +16,7 @@ if PY2:
# On Python 2 we use the backport package; that means we always get unicode # On Python 2 we use the backport package; that means we always get unicode
# out. # out.
from configparser import SafeConfigParser from configparser import ConfigParser
import attr import attr
@ -30,11 +30,11 @@ class UnknownConfigError(Exception):
def get_config(tahoe_cfg): def get_config(tahoe_cfg):
"""Load the config, returning a SafeConfigParser. """Load the config, returning a ConfigParser.
Configuration is returned as native strings. Configuration is returned as native strings.
""" """
config = SafeConfigParser(strict=False) config = ConfigParser(strict=False)
# Byte Order Mark is an optional garbage byte you sometimes get at the # Byte Order Mark is an optional garbage byte you sometimes get at the
# start of UTF-8 encoded files. Especially on Windows. Skip it by using # start of UTF-8 encoded files. Especially on Windows. Skip it by using
# utf-8-sig. https://en.wikipedia.org/wiki/Byte_order_mark # utf-8-sig. https://en.wikipedia.org/wiki/Byte_order_mark