Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fca2fc0

Browse files
Issue #20604: Added missed invalid mode in error message of socket.makefile().
Based on patch by Franck Michea.
1 parent db118f5 commit fca2fc0

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

Lib/socket.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,8 @@ def makefile(self, mode="r", buffering=None, *,
201201
except the only mode characters supported are 'r', 'w' and 'b'.
202202
The semantics are similar too. (XXX refactor to share code?)
203203
"""
204-
for c in mode:
205-
if c not in {"r", "w", "b"}:
206-
raise ValueError("invalid mode %r (only r, w, b allowed)")
204+
if not set(mode) <= {"r", "w", "b"}:
205+
raise ValueError("invalid mode %r (only r, w, b allowed)" % (mode,))
207206
writing = "w" in mode
208207
reading = "r" in mode or not writing
209208
assert reading or writing

0 commit comments

Comments
 (0)