From: Serhiy Storchaka Date: Wed, 19 Nov 2014 10:33:40 +0000 (+0200) Subject: Issue #20604: Added missed invalid mode in error message of socket.makefile(). X-Git-Tag: v3.4.3rc1~325 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fca2fc090c8227e8693a2b53dcdafd80bef06c1f;p=thirdparty%2FPython%2Fcpython.git Issue #20604: Added missed invalid mode in error message of socket.makefile(). Based on patch by Franck Michea. --- diff --git a/Lib/socket.py b/Lib/socket.py index fd2a7d4f8c15..22d7ad567beb 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -201,9 +201,8 @@ class socket(_socket.socket): except the only mode characters supported are 'r', 'w' and 'b'. The semantics are similar too. (XXX refactor to share code?) """ - for c in mode: - if c not in {"r", "w", "b"}: - raise ValueError("invalid mode %r (only r, w, b allowed)") + if not set(mode) <= {"r", "w", "b"}: + raise ValueError("invalid mode %r (only r, w, b allowed)" % (mode,)) writing = "w" in mode reading = "r" in mode or not writing assert reading or writing