[apparmor] [patch] [utils] Fix make check failure due to raw_input in ui.py

Kshitij Gupta kgupta8592 at gmail.com
Sun Sep 14 19:21:28 UTC 2014


Hello,

The make check for utils was failing due to the raw_input being
present as a function (which it is not in Python3, even though it was
under an if else python version check).

The following patch:
- checks the __builtins__ module for existence of raw_input and sets
it up for Python3

Tested in aa-logprof and also with make check.
=== modified file 'utils/apparmor/ui.py'
--- utils/apparmor/ui.py    2014-09-14 18:17:00 +0000
+++ utils/apparmor/ui.py    2014-09-14 19:22:56 +0000
@@ -28,6 +28,9 @@
 # The operating mode: yast or text, text by default
 UI_mode = 'text'

+# If Python3 wrap input in raw_input so make check passes
+if not 'raw_input' in dir(__builtins__): raw_input = input
+
 ARROWS = {'A': 'UP', 'B': 'DOWN', 'C': 'RIGHT', 'D': 'LEFT'}

 def getkey():
@@ -173,10 +176,7 @@
     if UI_mode == 'text':
         readline.set_startup_hook(lambda: readline.insert_text(default))
         try:
-            if sys.version_info[0] >= 3:
-                string = input('\n' + text)
-            else:
-                string = raw_input('\n' + text)
+            string = raw_input('\n' + text)
         except EOFError:
             string = ''
         finally:


Regards,

Kshitij Gupta



More information about the AppArmor mailing list