summaryrefslogtreecommitdiff
path: root/logilab
diff options
context:
space:
mode:
authorSimon Chabot <simon.chabot@logilab.fr>2019-11-28 18:57:56 +0100
committerSimon Chabot <simon.chabot@logilab.fr>2019-11-28 18:57:56 +0100
commite57d20105ecf9a17552eaddd74368a84ba839457 (patch)
treeaaeda39b24e0aa49b40418a08b1780335a82baf4 /logilab
parent181715113d104f59d31d93fe0bd246fa815e6d4c (diff)
downloadlogilab-common-e57d20105ecf9a17552eaddd74368a84ba839457.tar.gz
[shellutils, fix] Deprecate 'input' as argument of RawInput in favor of 'input_function'
When no parameter was given to the class, None was used as the `input`. It used to work because when `input` (the argument) was None `raw_input` of six was used instead. (-> self._input = input or raw_input). Now that six has been dropped, we cannot have `input=None` in the arguments list anymore and use the builtin `input` at the same time. This patch suggests to deprecate this argument in favor of a new one called `input_function`. If no `input_function`, let's use the `input` builtin. For backward compatibility, if `input` should be given, it's caught in the `kwargs` and used as `input_function`, and a deprecation warning is shown.
Diffstat (limited to 'logilab')
-rw-r--r--logilab/common/shellutils.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/logilab/common/shellutils.py b/logilab/common/shellutils.py
index 44f34ef..792ae45 100644
--- a/logilab/common/shellutils.py
+++ b/logilab/common/shellutils.py
@@ -35,6 +35,7 @@ import errno
import string
import random
import subprocess
+import warnings
from os.path import exists, isdir, islink, basename, join
from logilab.common import STD_BLACKLIST, _handle_blacklist
@@ -338,8 +339,15 @@ class progress(object):
class RawInput(object):
- def __init__(self, input=None, printer=None):
- self._input = input
+ def __init__(self, input_function=None, printer=None, **kwargs):
+ if 'input' in kwargs:
+ input_function = kwargs.pop('input')
+ warnings.warn(
+ "'input' argument is deprecated,"
+ "use 'input_function' instead",
+ DeprecationWarning,
+ )
+ self._input = input_function or input
self._print = printer
def ask(self, question, options, default):