Skip to contentSkip to conversation

qmp: make qmp-shell work with python3

PATCH Applied Igor Mammedov 2 participants 2 messages Jun 20, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 qmp: make qmp-shell work with python3

python3 doesn't have raw_input(), so qmp-shell breaks. Use input() instead and override it with raw_input() if running on python2.

---
v2:
use sys.version_info[0] instead try/except
(Cleber Rosa <[email protected]>)

 scripts/qmp/qmp-shell | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/qmp/qmp-shell +4 -1
index 7776c7b141..f1cddeafbc 100755
@@ -78,6 +78,9 @@ import re
 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
 from qemu import qmp
 
+if sys.version_info[0] == 2:
+    input = raw_input
+
 class QMPCompleter(list):
     def complete(self, text, state):
         for cmd in self:
@@ -308,7 +311,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
         @return True if execution was ok, return False if disconnected.
         """
         try:
-            cmdline = raw_input(prompt)
+            cmdline = input(prompt)
         except EOFError:
             print()
             return False
Signature · 1 line
2.18.1
#1 lore raw
Quoted 5 lines · Igor Mammedov

python3 doesn't have raw_input(), so qmp-shell breaks. Use input() instead and override it with raw_input() if running on python2.

Queued, thanks.

Signature · 1 line
Eduardo