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

Skip to content

Commit a9568bb

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

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
@@ -209,9 +209,8 @@ def makefile(self, mode="r", buffering=None, *,
209209
except the only mode characters supported are 'r', 'w' and 'b'.
210210
The semantics are similar too. (XXX refactor to share code?)
211211
"""
212-
for c in mode:
213-
if c not in {"r", "w", "b"}:
214-
raise ValueError("invalid mode %r (only r, w, b allowed)")
212+
if not set(mode) <= {"r", "w", "b"}:
213+
raise ValueError("invalid mode %r (only r, w, b allowed)" % (mode,))
215214
writing = "w" in mode
216215
reading = "r" in mode or not writing
217216
assert reading or writing

0 commit comments

Comments
 (0)