[Python-checkins] cpython: Avoid matching '' or 'yn' when asking for 'y' or 'n' in interactive code

eric.araujo python-checkins at python.org
Mon Sep 19 16:55:07 CEST 2011


http://hg.python.org/cpython/rev/10fd0d0895a1
changeset:   72412:10fd0d0895a1
user:        Éric Araujo <merwok at netwok.org>
date:        Mon Sep 19 16:21:37 2011 +0200
summary:
  Avoid matching '' or 'yn' when asking for 'y' or 'n' in interactive code

files:
  Lib/packaging/command/register.py |  2 +-
  Lib/packaging/create.py           |  2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)


diff --git a/Lib/packaging/command/register.py b/Lib/packaging/command/register.py
--- a/Lib/packaging/command/register.py
+++ b/Lib/packaging/command/register.py
@@ -178,7 +178,7 @@
                         'will be faster.\n(the login will be stored in %s)',
                         get_pypirc_path())
                     choice = 'X'
-                    while choice.lower() not in 'yn':
+                    while choice.lower() not in ('y', 'n'):
                         choice = input('Save your login (y/N)?')
                         if not choice:
                             choice = 'n'
diff --git a/Lib/packaging/create.py b/Lib/packaging/create.py
--- a/Lib/packaging/create.py
+++ b/Lib/packaging/create.py
@@ -121,7 +121,7 @@
     question += ' (y/n)'
     while True:
         answer = ask(question, default, helptext, required=True)
-        if answer and answer[0].lower() in 'yn':
+        if answer and answer[0].lower() in ('y', 'n'):
             return answer[0].lower()
 
         print('\nERROR: You must select "Y" or "N".\n')

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


More information about the Python-checkins mailing list