[apparmor] [patch] Remove re.LOCALE flag

Steve Beattie steve at nxnw.org
Tue Feb 21 14:37:16 UTC 2017


On Thu, Feb 16, 2017 at 10:38:30PM +0100, Christian Boltz wrote:
> 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)

The re.LOCALE flag was introduced in commit 0.1.89; however, the regex
change added at the same time was incorrect (\S*) and was replaced with
code seen above. So it's not clear to me that the original addition of
re.LOCALE actually fixed what it claimed it fixed.

I'm assuming you've tested the utils manually in German with the patch
applied? If so, Acked-by: Steve Beattie <steve at nxnw.org> for three
branches.

Thanks.

-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20170221/d32c267b/attachment.pgp>


More information about the AppArmor mailing list