summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_socket.py
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2021-04-27 04:16:28 (GMT)
committerGitHub <noreply@github.com>2021-04-27 04:16:28 (GMT)
commitcfe523b49280cdc8c239c807121ad3f33552f638 (patch)
treeca00ebc35f6401b27bd7276288bfc99716d362a9 /Lib/test/test_socket.py
parent743e2bae10d2010fd1e29b772c9da64efc7c9c47 (diff)
downloadcpython-cfe523b49280cdc8c239c807121ad3f33552f638.zip
cpython-cfe523b49280cdc8c239c807121ad3f33552f638.tar.gz
cpython-cfe523b49280cdc8c239c807121ad3f33552f638.tar.bz2
bpo-43651: PEP 597: Fix `socket.makefile()` (GH-25645)
Diffstat (limited to 'Lib/test/test_socket.py')
-rwxr-xr-xLib/test/test_socket.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 43a1d5b..3c45278 100755
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1678,7 +1678,8 @@ class GeneralModuleTests(unittest.TestCase):
for mode in 'r', 'rb', 'rw', 'w', 'wb':
with self.subTest(mode=mode):
with socket.socket() as sock:
- with sock.makefile(mode) as fp:
+ encoding = None if "b" in mode else "utf-8"
+ with sock.makefile(mode, encoding=encoding) as fp:
self.assertEqual(fp.mode, mode)
def test_makefile_invalid_mode(self):
@@ -5625,7 +5626,7 @@ def isTipcAvailable():
if not hasattr(socket, "AF_TIPC"):
return False
try:
- f = open("/proc/modules")
+ f = open("/proc/modules", encoding="utf-8")
except (FileNotFoundError, IsADirectoryError, PermissionError):
# It's ok if the file does not exist, is a directory or if we
# have not the permission to read it.
@@ -6222,7 +6223,7 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
meth = self.meth_from_sock(s)
self.assertRaisesRegex(
ValueError, "SOCK_STREAM", meth, file)
- with open(os_helper.TESTFN, 'rt') as file:
+ with open(os_helper.TESTFN, encoding="utf-8") as file:
with socket.socket() as s:
meth = self.meth_from_sock(s)
self.assertRaisesRegex(