From 3793b4f30e535db4599a9e695d6345968ba3b110 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Tue, 18 Jun 2024 16:54:16 +0800 Subject: [PATCH 1/2] Migrate off SafeConfigParser Signed-off-by: Luca Della Vedova --- stdeb/cli_runner.py | 7 +------ stdeb/util.py | 11 +++-------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/stdeb/cli_runner.py b/stdeb/cli_runner.py index e4cb6f9..0d32329 100644 --- a/stdeb/cli_runner.py +++ b/stdeb/cli_runner.py @@ -3,12 +3,7 @@ import shutil import subprocess import sys -try: - # python 2.x - from ConfigParser import SafeConfigParser # noqa: F401 -except ImportError: - # python 3.x - from configparser import SafeConfigParser # noqa: F401 +from configparser import ConfigParser # noqa: F401 from distutils.util import strtobool from distutils.fancy_getopt import FancyGetopt, translate_longopt from stdeb.util import stdeb_cmdline_opts, stdeb_cmd_bool_opts diff --git a/stdeb/util.py b/stdeb/util.py index 34b995a..3604201 100644 --- a/stdeb/util.py +++ b/stdeb/util.py @@ -9,12 +9,7 @@ import sys import time import codecs -try: - # Python 2.x - import ConfigParser -except ImportError: - # Python 3.x - import configparser as ConfigParser +import configparser as ConfigParser import subprocess import tempfile import stdeb # noqa: F401 @@ -732,7 +727,7 @@ def check_cfg_files(cfg_files, module_name): example. """ - cfg = ConfigParser.SafeConfigParser() + cfg = ConfigParser.ConfigParser() cfg.read(cfg_files) if cfg.has_section(module_name): section_items = cfg.items(module_name) @@ -803,7 +798,7 @@ def __init__(self, if len(cfg_files): check_cfg_files(cfg_files, module_name) - cfg = ConfigParser.SafeConfigParser(cfg_defaults) + cfg = ConfigParser.ConfigParser(cfg_defaults) for cfg_file in cfg_files: with codecs.open(cfg_file, mode='r', encoding='utf-8') as fd: cfg.readfp(fd) From 77303613b6596b60a011a9fc881e3f58685f3e50 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Tue, 18 Jun 2024 17:07:18 +0800 Subject: [PATCH 2/2] readfp -> read_file Signed-off-by: Luca Della Vedova --- stdeb/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdeb/util.py b/stdeb/util.py index 3604201..26b656e 100644 --- a/stdeb/util.py +++ b/stdeb/util.py @@ -801,7 +801,7 @@ def __init__(self, cfg = ConfigParser.ConfigParser(cfg_defaults) for cfg_file in cfg_files: with codecs.open(cfg_file, mode='r', encoding='utf-8') as fd: - cfg.readfp(fd) + cfg.read_file(fd) if sdist_dsc_command is not None: # Allow distutils commands to override config files (this lets