Skip to content

Commit

Permalink
Fix configparser deprecation warnings
Browse files Browse the repository at this point in the history
Use config.read_file() to read configuration from a file instead of
config.readfp(), which is deprecated. Also, use ConfigParser instead of
SafeConfigParser, which is an alias that will be removed in future
Python versions.
  • Loading branch information
boolean5 committed Aug 13, 2020
1 parent 9d868ba commit 574edcf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion publish2cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)
from packaging import version as p_version

CONFIG = configparser.SafeConfigParser(os.environ)
CONFIG = configparser.ConfigParser(os.environ)
CONFIG.read(['shavar_list_creation.ini'])
try:
REMOTE_SETTINGS_URL = ''
Expand Down
8 changes: 4 additions & 4 deletions tests/test_lists2safebrowsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def _get_entity_or_plugin_lists(chunknum, config, function, section, data):
def test_get_entity_lists(chunknum, section, version, testcase):
"""Test creating an entity list from a configuration section."""
config = configparser.ConfigParser()
config.readfp(open("sample_shavar_list_creation.ini"))
config.read_file(open("sample_shavar_list_creation.ini"))

if version:
config.set(section, "version", version)
Expand Down Expand Up @@ -587,7 +587,7 @@ def test_get_entity_lists(chunknum, section, version, testcase):
def test_get_plugin_lists(chunknum):
"""Test creating a plugin blocklist from a configuration section."""
config = configparser.ConfigParser()
config.readfp(open("sample_shavar_list_creation.ini"))
config.read_file(open("sample_shavar_list_creation.ini"))
section = "plugin-blocklist"

domains = [d[1] for d in CANONICALIZE_TESTCASES[:2]]
Expand Down Expand Up @@ -618,7 +618,7 @@ def test_get_plugin_lists(chunknum):
def test_get_plugin_lists_empty_url(chunknum):
"""Test empty blocklist URL handling in get_plugin_lists."""
config = configparser.ConfigParser()
config.readfp(open("sample_shavar_list_creation.ini"))
config.read_file(open("sample_shavar_list_creation.ini"))
section = "plugin-blocklist"

config.set(section, "blocklist", "")
Expand All @@ -635,7 +635,7 @@ def test_get_plugin_lists_empty_url(chunknum):
def test_get_tracker_lists(parser, chunknum, section, domains, testcase):
"""Test creating a tracker blocklist from a configuration section."""
config = configparser.ConfigParser()
config.readfp(open("sample_shavar_list_creation.ini"))
config.read_file(open("sample_shavar_list_creation.ini"))
version = None

if testcase == "default":
Expand Down

0 comments on commit 574edcf

Please sign in to comment.