bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25145)
* test_asyncio
* test_bz2
* test_math
* test_cmath
* test_cmd_line
* test_cmd_line_script
* test_compile
* test_contextlib
* test_profile
* ctypes/test/test_find
* test_multiprocessing
* test_configparser
* test_csv
* test_dbm_dumb
* test_decimal
* test_difflib
* os.fdopen() calls io.text_encoding() to emit EncodingWarning for right place.
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index a6f6483..3d12874 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -130,7 +130,7 @@ def parse_mtestfile(fname):
id fn arg -> expected [flag]*
"""
- with open(fname) as fp:
+ with open(fname, encoding="utf-8") as fp:
for line in fp:
# strip comments, and skip blank lines
if '--' in line:
@@ -153,7 +153,7 @@ def parse_testfile(fname):
Empty lines or lines starting with -- are ignored
yields id, fn, arg_real, arg_imag, exp_real, exp_imag
"""
- with open(fname) as fp:
+ with open(fname, encoding="utf-8") as fp:
for line in fp:
# skip comment lines and blank lines
if line.startswith('--') or not line.strip():