[apparmor] [patch] rewrite set_profile_flags() to use write_header()
Steve Beattie
steve at nxnw.org
Thu Apr 2 20:38:16 UTC 2015
On Thu, Apr 02, 2015 at 09:55:24PM +0200, Christian Boltz wrote:
> Am Donnerstag, 2. April 2015 schrieb Seth Arnold:
> > On Thu, Apr 02, 2015 at 12:03:40PM -0700, Steve Beattie wrote:
> > > > The difference is this:
> > > >
> > > > $ python2.7 -c "print(len(' ')/2)"
> > > > 1
>
> Seriously?
>
> if 3/2 == 1:
> print("old python inside")
To be fair, it's doing integer math when both the numerator and
denominator are integers; other things do this as well. Converting one
of them to a float makes the division operation return a float as well:
$ python2.7 -c 'print(3/2)'
1
$ python2.7 -c 'print(3.0/2)'
1.5
> > I think importing division from future makes sense here.
> Agreed. To make it more formal:
>
>
> Tell python2 about math
>
> if 3/2 == 1:
> print("python2 inside")
>
> Add "from __future__ import division" so that python2 returns the
> correct result (if needed, as float)
>
> On related news: At least python3 knows how to calculate correctly.
>
>
> I propose this patch for trunk and 2.9.
Acked-by: Steve Beattie <steve at nxnw.org> for both. Thanks.
> [ 21a-tell-python2-about-math.diff ]
>
> === modified file utils/apparmor/aa.py
> --- utils/apparmor/aa.py 2015-04-02 12:01:55.401784901 +0200
> +++ utils/apparmor/aa.py 2015-04-02 21:34:02.886805899 +0200
> @@ -13,7 +13,7 @@
> #
> #
> ----------------------------------------------------------------------
> # No old version logs, only 2.6 + supported
> -from __future__ import with_statement
> +from __future__ import division, with_statement
> import inspect
> import os
> import re
>
--
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: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150402/91e48606/attachment-0001.pgp>
More information about the AppArmor
mailing list