[Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible
Stefan Dirsch
sndirsch at suse.de
Fri Mar 2 13:02:10 UTC 2018
On Fri, Mar 02, 2018 at 01:39:40PM +0100, Gustaw Smolarczyk wrote:
> 2018-03-02 12:59 GMT+01:00 Stefan Dirsch <sndirsch at suse.de>:
>
> On Fri, Mar 02, 2018 at 11:47:57AM +0000, Eric Engestrom wrote:
> > On Friday, 2018-03-02 12:25:11 +0100, Stefan Dirsch wrote:
> > > On Fri, Mar 02, 2018 at 11:03:53AM +0000, Eric Engestrom wrote:
> > > > On Friday, 2018-03-02 11:41:00 +0100, Stefan Dirsch wrote:
> > > > > Patch by "Tomas Chvatal" <tchvatal at suse.com> with modifications
> > > > > by "Michal Srb" <msrb at suse.com> to not break python 2.
> > > > >
> > > > > https://bugzilla.suse.com/show_bug.cgi?id=1082303
> > > > >
> > > > > v2:
> > > > > - no longer try to encode a unicode
> > > > > - make use of 'from __future__ import print_function', so semantics
> > > > > of print statements in python2 are closer to print functions in
> python3
> > > > >
> > > > > https://lists.freedesktop.org/archives/mesa-dev/2018-February/
> 187056.html
> > > > >
> > > > > Signed-off-by: Stefan Dirsch <sndirsch at suse.de>
> > > > > Reviewed-by: Tomas Chvatal <tchvatal at suse.com>
> > > > > ---
> > > > > src/gallium/drivers/r600/egd_tables.py | 53
> +++++++++++++++++-----------------
> > > > > 1 file changed, 27 insertions(+), 26 deletions(-)
> > > > >
> > > > > diff --git a/src/gallium/drivers/r600/egd_tables.py b/src/gallium/
> drivers/r600/egd_tables.py
> > > > > index d7b78c7fb1..4796456330 100644
> > > > > --- a/src/gallium/drivers/r600/egd_tables.py
> > > > > +++ b/src/gallium/drivers/r600/egd_tables.py
> > > > > @@ -1,3 +1,4 @@
> > > > > +from __future__ import print_function
> > > > >
> > > > > CopyRight = '''
> > > > > /*
> > > > > @@ -60,7 +61,7 @@ class StringTable:
> > > > > """
> > > > > fragments = [
> > > > > '"%s\\0" /* %s */' % (
> > > > > - te[0].encode('string_escape'),
> > > > > + te[0],
>
>
> Hi,
>
> I am not an expert in Python 3, but I have found the following answer
> experimentally.
>
> I think the original version is semi-correct, but the encode() method returns a
> bytes object which we need to convert to unicode. I think the following would
> be fine:
>
> te[0].encode('unicode_escape').decode('utf-8')
Looks good. And still the same output with python2 and python3. :-) If Dylan
and Eric agree I'll send a revised patch.
Thanks,
Stefan
Public Key available
------------------------------------------------------
Stefan Dirsch (Res. & Dev.) SUSE LINUX GmbH
Tel: 0911-740 53 0 Maxfeldstraße 5
FAX: 0911-740 53 479 D-90409 Nürnberg
http://www.suse.de Germany
---------------------------------------------------------------
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham
Norton, HRB 21284 (AG Nürnberg)
---------------------------------------------------------------
More information about the mesa-dev
mailing list