[apparmor] [patch] rewrite set_profile_flags() to use write_header()

Seth Arnold seth.arnold at canonical.com
Thu Apr 2 19:09:21 UTC 2015


On Thu, Apr 02, 2015 at 12:03:40PM -0700, Steve Beattie wrote:
> > The difference is this:
> > 
> > $ python2.7 -c "print(len('   ')/2)"
> > 1
> > $ python3 -c "print(len('   ')/2)"
> > 1.5

Argh. I still can't believe that made it into a relese..

> So importing division from __future__ gives floating point division
> by default in python 2.7, to match the behavior of division in python3.
> Adding it to apparmor/aa.py lets the tests that were failing only under
> python 2.7 pass, but I'm a little leery of adding it, as grepping for
> division in aa.py gives at least:
> 
>                 data += write_methods[segs](prof_data, int(depth / 2))
>                         data += write_header(write_prof_data[name], int(depth / 2), name, False, include_flags)
>                     depth = int(len(line) - len(line.lstrip()) / 2) + 1
>                     depth = int((len(line) - len(line.lstrip())) / 2)
> 
> so I'm concerned we'd be introducing other changes by doing
> so... though getting consistent behavior across python2 and python3
> would be a benefit, I'd say.

It looks like those other cases are prepared for it, the int() wrappers
look like they are bringing back the usual truncation on division.

I think importing division from future makes sense here.

Thanks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150402/cc2a6ad6/attachment.pgp>


More information about the AppArmor mailing list