]> granicus.if.org Git - python/commitdiff
Issue #20604: Added missed invalid mode in error message of socket.makefile().
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 19 Nov 2014 10:33:40 +0000 (12:33 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 19 Nov 2014 10:33:40 +0000 (12:33 +0200)
Based on patch by Franck Michea.

Lib/socket.py

index fd2a7d4f8c15078e82b8ab7dd14e7c592bf9df91..22d7ad567bebe6ecc2e39f4acce6cc69b6d108d6 100644 (file)
@@ -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