summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-08-11 13:26:59 (GMT)
committerGitHub <noreply@github.com>2020-08-11 13:26:59 (GMT)
commitfabd7bb8e0450f16ed5c5c0ad575aa413d65712d (patch)
tree697881ab8dd38a990ebd68a018a20f08c2ab3c67 /Lib
parent1d541c25c8019f7a0b80b3e1b437abe171e40b65 (diff)
downloadcpython-fabd7bb8e0450f16ed5c5c0ad575aa413d65712d.zip
cpython-fabd7bb8e0450f16ed5c5c0ad575aa413d65712d.tar.gz
cpython-fabd7bb8e0450f16ed5c5c0ad575aa413d65712d.tar.bz2
bpo-41521: Replace whitelist/blacklist with allowlist/denylist (GH-21822)
Automerge-Triggered-By: @tiran
Diffstat (limited to 'Lib')
-rw-r--r--Lib/codecs.py2
-rw-r--r--Lib/ipaddress.py4
-rw-r--r--Lib/test/test___all__.py12
-rw-r--r--Lib/test/test_httplib.py4
-rw-r--r--Lib/test/test_httpservers.py4
-rw-r--r--Lib/test/test_nntplib.py6
-rw-r--r--Lib/test/test_tools/test_sundry.py10
-rw-r--r--Lib/test/test_traceback.py4
8 files changed, 23 insertions, 23 deletions
diff --git a/Lib/codecs.py b/Lib/codecs.py
index 7f23e97..3935490 100644
--- a/Lib/codecs.py
+++ b/Lib/codecs.py
@@ -83,7 +83,7 @@ BOM64_BE = BOM_UTF32_BE
class CodecInfo(tuple):
"""Codec details when looking up the codec registry"""
- # Private API to allow Python 3.4 to blacklist the known non-Unicode
+ # Private API to allow Python 3.4 to denylist the known non-Unicode
# codecs in the standard library. A more general mechanism to
# reliably distinguish test encodings from other codecs will hopefully
# be defined for Python 3.5
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py
index bc662c4..160b16d 100644
--- a/Lib/ipaddress.py
+++ b/Lib/ipaddress.py
@@ -1214,7 +1214,7 @@ class _BaseV4:
"""
if not octet_str:
raise ValueError("Empty octet not permitted")
- # Whitelist the characters, since int() allows a lot of bizarre stuff.
+ # Reject non-ASCII digits.
if not (octet_str.isascii() and octet_str.isdigit()):
msg = "Only decimal digits permitted in %r"
raise ValueError(msg % octet_str)
@@ -1719,7 +1719,7 @@ class _BaseV6:
[0..FFFF].
"""
- # Whitelist the characters, since int() allows a lot of bizarre stuff.
+ # Reject non-ASCII digits.
if not cls._HEX_DIGITS.issuperset(hextet_str):
raise ValueError("Only hex digits permitted in %r" % hextet_str)
# We do the length check second, since the invalid character error
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index 0a03dd2..c6ce648 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -69,8 +69,8 @@ class AllTest(unittest.TestCase):
yield path, modpath + fn[:-3]
def test_all(self):
- # Blacklisted modules and packages
- blacklist = set([
+ # List of denied modules and packages
+ denylist = set([
# Will raise a SyntaxError when compiling the exec statement
'__future__',
])
@@ -85,13 +85,13 @@ class AllTest(unittest.TestCase):
lib_dir = os.path.dirname(os.path.dirname(__file__))
for path, modname in self.walk_modules(lib_dir, ""):
m = modname
- blacklisted = False
+ denylisted = False
while m:
- if m in blacklist:
- blacklisted = True
+ if m in denylist:
+ denylisted = True
break
m = m.rpartition('.')[0]
- if blacklisted:
+ if denylisted:
continue
if support.verbose:
print(modname)
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index 3431bb8..a3f268b 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -1434,9 +1434,9 @@ class OfflineTest(TestCase):
expected = {"responses"} # White-list documented dict() object
# HTTPMessage, parse_headers(), and the HTTP status code constants are
# intentionally omitted for simplicity
- blacklist = {"HTTPMessage", "parse_headers"}
+ denylist = {"HTTPMessage", "parse_headers"}
for name in dir(client):
- if name.startswith("_") or name in blacklist:
+ if name.startswith("_") or name in denylist:
continue
module_object = getattr(client, name)
if getattr(module_object, "__module__", None) == "http.client":
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index a7e1719..2859abb 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -1189,9 +1189,9 @@ class SimpleHTTPRequestHandlerTestCase(unittest.TestCase):
class MiscTestCase(unittest.TestCase):
def test_all(self):
expected = []
- blacklist = {'executable', 'nobody_uid', 'test'}
+ denylist = {'executable', 'nobody_uid', 'test'}
for name in dir(server):
- if name.startswith('_') or name in blacklist:
+ if name.startswith('_') or name in denylist:
continue
module_object = getattr(server, name)
if getattr(module_object, '__module__', None) == 'http.server':
diff --git a/Lib/test/test_nntplib.py b/Lib/test/test_nntplib.py
index 1df64fa..b11c19c 100644
--- a/Lib/test/test_nntplib.py
+++ b/Lib/test/test_nntplib.py
@@ -197,11 +197,11 @@ class NetworkedNNTPTestsMixin:
self.assertTrue(resp.startswith("220 "), resp)
self.check_article_resp(resp, article, art_num)
# Tolerate running the tests from behind a NNTP virus checker
- blacklist = lambda line: line.startswith(b'X-Antivirus')
+ denylist = lambda line: line.startswith(b'X-Antivirus')
filtered_head_lines = [line for line in head.lines
- if not blacklist(line)]
+ if not denylist(line)]
filtered_lines = [line for line in article.lines
- if not blacklist(line)]
+ if not denylist(line)]
self.assertEqual(filtered_lines, filtered_head_lines + [b''] + body.lines)
def test_capabilities(self):
diff --git a/Lib/test/test_tools/test_sundry.py b/Lib/test/test_tools/test_sundry.py
index 8b5a963..52369ec 100644
--- a/Lib/test/test_tools/test_sundry.py
+++ b/Lib/test/test_tools/test_sundry.py
@@ -16,18 +16,18 @@ skip_if_missing()
class TestSundryScripts(unittest.TestCase):
# At least make sure the rest don't have syntax errors. When tests are
- # added for a script it should be added to the whitelist below.
+ # added for a script it should be added to the allowlist below.
# scripts that have independent tests.
- whitelist = ['reindent', 'pdeps', 'gprof2html', 'md5sum']
+ allowlist = ['reindent', 'pdeps', 'gprof2html', 'md5sum']
# scripts that can't be imported without running
- blacklist = ['make_ctype']
+ denylist = ['make_ctype']
# scripts that use windows-only modules
windows_only = ['win_add2path']
- # blacklisted for other reasons
+ # denylisted for other reasons
other = ['analyze_dxp', '2to3']
- skiplist = blacklist + whitelist + windows_only + other
+ skiplist = denylist + allowlist + windows_only + other
def test_sundry(self):
old_modules = import_helper.modules_setup()
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index c5fbd87..730596e 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -1191,9 +1191,9 @@ class MiscTest(unittest.TestCase):
def test_all(self):
expected = set()
- blacklist = {'print_list'}
+ denylist = {'print_list'}
for name in dir(traceback):
- if name.startswith('_') or name in blacklist:
+ if name.startswith('_') or name in denylist:
continue
module_object = getattr(traceback, name)
if getattr(module_object, '__module__', None) == 'traceback':