[Python-checkins] cpython (3.4): Issue #20604: Added missed invalid mode in error message of socket.makefile().

serhiy.storchaka python-checkins at python.org
Wed Nov 19 11:36:39 CET 2014


https://hg.python.org/cpython/rev/34c7be03259b
changeset:   93510:34c7be03259b
branch:      3.4
parent:      93508:cb1d7eac601d
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Wed Nov 19 12:33:40 2014 +0200
summary:
  Issue #20604: Added missed invalid mode in error message of socket.makefile().
Based on patch by Franck Michea.

files:
  Lib/socket.py |  5 ++---
  1 files changed, 2 insertions(+), 3 deletions(-)


diff --git a/Lib/socket.py b/Lib/socket.py
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -201,9 +201,8 @@
         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

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list