From 0e7dab4c2fb5a0527bc28fc8b17b9e386d6caad9 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 12 Oct 2020 14:50:59 -0700 Subject: [PATCH] python: fix raw_input()/input() problem --- py/Boinc/tools.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/py/Boinc/tools.py b/py/Boinc/tools.py index 621ecaee71..bbea249e33 100644 --- a/py/Boinc/tools.py +++ b/py/Boinc/tools.py @@ -64,19 +64,23 @@ def file_size(path): f.seek(0,2) return f.tell() +# workaround for dubious function change in python3 +# +from sys import version_info +def input_aux(): + if version_info.major == 3: + return input() + return raw_input() + def query_yesno(str): '''Query user; default Yes''' print (str, "[Y/n] ", end="") - try: input = raw_input - except NameError: pass - return not input().strip().lower().startswith('n') + return not input_aux().strip().lower().startswith('n') def query_noyes(str): '''Query user; default No''' print (str, "[y/N] ", end="") - try: input = raw_input - except NameError: pass - return input().strip().lower().startswith('y') + return input_aux().strip().lower().startswith('y') def get_output_file_path(filename): """ Return the filename's path in the upload directory