]> granicus.if.org Git - python/commitdiff
Avoid matching '' or 'yn' when asking for 'y' or 'n' in interactive code
authorÉric Araujo <merwok@netwok.org>
Mon, 19 Sep 2011 14:21:37 +0000 (16:21 +0200)
committerÉric Araujo <merwok@netwok.org>
Mon, 19 Sep 2011 14:21:37 +0000 (16:21 +0200)
Lib/packaging/command/register.py
Lib/packaging/create.py

index 67cda80c8b5277073784f9bad5f276441277250d..59805f7d47d8721dddc0675e2f58464e4d8ae96a 100644 (file)
@@ -178,7 +178,7 @@ Your selection [default 1]: ''')
                         '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'
index 34a8c823b375e9a578d4144d1312c1e48d0f461e..59b448dc62eeb1edc2e8275ac87c8b376b32489f 100644 (file)
@@ -121,7 +121,7 @@ def ask_yn(question, default=None, helptext=None):
     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')