From e1d40d89f0c6ed1ca894e1aa3c4b01040e626cd9 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 26 May 2021 18:03:13 +0200 Subject: [PATCH] examples: fix usage of input() with Python2 input() in Python2 evaluated the string and was thus unsafe. On Python2, the right choice is raw_input. In Python3, input does what raw_input did. Work around this. The main "problem" is that lgtm.com flags this as error. The fix in the example is not important, but getting a low number of warnings is. --- examples/python/dbus/checkpoint.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/python/dbus/checkpoint.py b/examples/python/dbus/checkpoint.py index 4aa7add6f9..869bfce761 100755 --- a/examples/python/dbus/checkpoint.py +++ b/examples/python/dbus/checkpoint.py @@ -54,6 +54,12 @@ for arg in sys.argv[2:]: checkpoint = manager.CheckpointCreate(devList, interval, 1) # DESTROY_ALL +try: + # Workaround for Python2 + input = raw_input +except NameError: + pass + choice = input("Do you want to rollback [y/n]? ").lower() if choice == "y": print("Rollback checkpoint")