[apparmor] [patch] Remove re.LOCALE flag

Christian Boltz apparmor at cboltz.de
Thu Feb 16 21:38:30 UTC 2017


Hello,

starting with python 3.6, the re.LOCALE flag can only be used with byte
patterns, and errors out if used with str. This patch removes the flag
in get_translated_hotkey().


References: https://bugs.launchpad.net/apparmor/+bug/1661766


I propose this patch for trunk, 2.10 and 2.9.


[ 01-re-locale.diff ]

=== modified file 'utils/apparmor/ui.py'
--- utils/apparmor/ui.py        2016-10-03 19:01:29 +0000
+++ utils/apparmor/ui.py        2017-02-16 21:29:22 +0000
@@ -64,8 +64,8 @@
     msg = 'PromptUser: ' + _('Invalid hotkey for')
 
     # Originally (\S) was used but with translations it would not work :(
-    if re.search('\((\S+)\)', translated, re.LOCALE):
-        return re.search('\((\S+)\)', translated, re.LOCALE).groups()[0]
+    if re.search('\((\S+)\)', translated):                                                                                                                                                                                                                                    
+        return re.search('\((\S+)\)', translated).groups()[0]                                                                                                                                                                                                                 
     else:                                                                                                                                                                                                                                                                     
         if cmsg:                                                                                                                                                                                                                                                              
             raise AppArmorException(cmsg)                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                               


Regards,

Christian Boltz
-- 
>Weil es sehr weit verbreitet ist, eingespielt und "überall drauf".
Die weite Verbreitung ist allenfalls geeignet, die kaputte Syntax
auszugleichen, ein Erfordernis also, kein Pluspunkt.
[> Ratti und Thorsten Haude in suse-linux zur Frage "Warum procmail?"]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20170216/71f00973/attachment.pgp>


More information about the AppArmor mailing list