[Spice-devel] [PATCH] Make spice_codegen.py work on both Python 2 and 3

Christophe Fergeau cfergeau at redhat.com
Tue Mar 31 09:40:13 PDT 2015


On Tue, Mar 31, 2015 at 11:23:40AM -0500, Alexander Wauck wrote:
> On Tue, 31 Mar 2015 17:57:59 +0200
> Christophe Fergeau <cfergeau at redhat.com> wrote:
> 
> 
> > From a quick glance, the changes look sane to me (split patch would have
> > been even more straightforward to review ;)
> 
> Duly noted.  I'll keep that in mind for the future.
> 
> > First time I hear about six.py, so I don't know about that :(
> 
> six.py is a collection of helpers for Python 2/3 compatibility.  It's generally
> installable from the distribution's repositories, hence my ambivalence about
> bundling it.  Bundling is easy (at least in this case), but I know Debian would
> throw a fit over it.

We don't bundle pyparsing for example, and six.py is indeed available
from distros (fedora has it too), so I don't think it should be bundled
here.

> > 
> > I also had to use this patch or the file generation would first error
> > out, and then would contain some *ptr += 1.0; rather than *ptr += 1;
> > With these changes, the files are the same when generated with python2
> > or python3 on my system (python3-3.4.2-4.fc22.x86_64)
> 
> Ah, yes.  That's one of the other big changes in python3: integer division.
> The proper python3 way to do it is the // operator, which has apparently been
> available in python2 since 2.2:
> 
> https://docs.python.org/release/2.2.3/whatsnew/node7.html

Ah thanks for the explanation, // looks better than my int() hack :)

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150331/e5baf7c0/attachment.sig>


More information about the Spice-devel mailing list