[Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-03 Thread Stefan Dirsch
Patch by "Tomas Chvatal"  with modifications
by "Michal Srb"  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

v3:
- convert bytes object to unicode in order to fix output with python3

https://lists.freedesktop.org/archives/mesa-dev/2018-March/187492.html

Signed-off-by: Stefan Dirsch 
Reviewed-by: Tomas Chvatal 
Reviewed-by: Dylan Baker 
Reviewed-by: Eric Engestrom 
---
 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..2d37a5bcc9 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].encode('unicode_escape').decode('utf-8'),
 ', '.join(str(idx) for idx in te[2])
 )
 for te in self.table
@@ -217,10 +218,10 @@ def write_tables(regs, packets):
 strings = StringTable()
 strings_offsets = IntTable("int")
 
-print '/* This file is autogenerated by egd_tables.py from evergreend.h. 
Do not edit directly. */'
-print
-print CopyRight.strip()
-print '''
+print('/* This file is autogenerated by egd_tables.py from evergreend.h. 
Do not edit directly. */')
+print('')
+print(CopyRight.strip())
+print('''
 #ifndef EG_TABLES_H
 #define EG_TABLES_H
 
@@ -242,20 +243,20 @@ struct eg_packet3 {
 unsigned name_offset;
 unsigned op;
 };
-'''
+''')
 
-print 'static const struct eg_packet3 packet3_table[] = {'
+print('static const struct eg_packet3 packet3_table[] = {')
 for pkt in packets:
-print '\t{%s, %s},' % (strings.add(pkt[5:]), pkt)
-print '};'
-print
+print('\t{%s, %s},' % (strings.add(pkt[5:]), pkt))
+print('};')
+print('')
 
-print 'static const struct eg_field egd_fields_table[] = {'
+print('static const struct eg_field egd_fields_table[] = {')
 
 fields_idx = 0
 for reg in regs:
 if len(reg.fields) and reg.own_fields:
-print '\t/* %s */' % (fields_idx)
+print('\t/* %s */' % (fields_idx))
 
 reg.fields_idx = fields_idx
 
@@ -266,34 +267,34 @@ struct eg_packet3 {
 while value[1] >= len(values_offsets):
 values_offsets.append(-1)
 values_offsets[value[1]] = 
strings.add(strip_prefix(value[0]))
-print '\t{%s, %s(~0u), %s, %s},' % (
+print('\t{%s, %s(~0u), %s, %s},' % (
 strings.add(field.name), field.s_name,
-len(values_offsets), 
strings_offsets.add(values_offsets))
+len(values_offsets), 
strings_offsets.add(values_offsets)))
 else:
-print '\t{%s, %s(~0u)},' % (strings.add(field.name), 
field.s_name)
+print('\t{%s, %s(~0u)},' % (strings.add(field.name), 
field.s_name))
 fields_idx += 1
 
-print '};'
-print
+print('};')
+print('')
 
-print 'static const struct eg_reg egd_reg_table[] = {'
+print('static const struct eg_reg egd_reg_table[] = {')
 for reg in regs:
 if len(reg.fields):
-print '\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
-len(reg.fields), reg.fields_idx if reg.own_fields else 
reg.fields_owner.fields_idx)
+print('\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
+len(reg.fields), reg.fields_idx if reg.own_fields else 
reg.fields_owner.fields_idx))
 else:
-print '\t{%s, %s},' % (strings.add(reg.name), reg.r_name)
-print '};'
-print
+print('\t{%s, %s},' % (strings.add(reg.name), reg.r_name))
+print('};')
+print('')
 
 strings.emit(sys.stdout, "egd_strings")
 
-print
+print('')
 
 strings_offsets.emit(sys.stdout, "egd_strings_offsets")
 
-print
-print '#endif'
+print('')
+print('#endif')
 
 
 def main():
-- 
2.13.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-02 Thread Eric Engestrom
On Friday, 2018-03-02 13:03:02 +, Stefan Dirsch wrote:
> On Fri, Mar 02, 2018 at 01:39:40PM +0100, Gustaw Smolarczyk wrote:
> > 2018-03-02 12:59 GMT+01:00 Stefan Dirsch :
> > 
> > On Fri, Mar 02, 2018 at 11:47:57AM +, Eric Engestrom wrote:
> > > On Friday, 2018-03-02 12:25:11 +0100, Stefan Dirsch wrote:
> > > > On Fri, Mar 02, 2018 at 11:03:53AM +, Eric Engestrom wrote:
> > > > > On Friday, 2018-03-02 11:41:00 +0100, Stefan Dirsch wrote:
> > > > > > Patch by "Tomas Chvatal"  with modifications
> > > > > > by "Michal Srb"  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 
> > > > > > Reviewed-by: Tomas Chvatal 
> > > > > > ---
> > > > > >  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.

Sure; you can add my:
Reviewed-by: Eric Engestrom 

> 
> Thanks,
> Stefan
> 
> Public Key available
> --
> Stefan Dirsch (Res. & Dev.)   SUSE LINUX GmbH
> Tel: 0911-740 53 0Maxfeldstraße 5
> FAX: 0911-740 53 479  D-90409 Nürnberg
> http://www.suse.deGermany 
> ---
> SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham
> Norton, HRB 21284 (AG Nürnberg)
> ---
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-02 Thread Dylan Baker
Quoting Stefan Dirsch (2018-03-02 02:49:37)
> On Thu, Mar 01, 2018 at 09:00:38AM -0800, Dylan Baker wrote:
> > Quoting sndir...@suse.de (2018-03-01 08:11:54)
> > > From: Stefan Dirsch 
> > > 
> > > Patch by "Tomas Chvatal"  with modifications
> > > by "Michal Srb"  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 
> > > Reviewed-by: Tomas Chvatal 
> > > Reviewed-by: Dylan Baker 
> > 
> > Process comment for you. Reviewed-by in mesa is like the kernel, it carries 
> > a
> > very specific formal meaning and you don't add Reviewed-by (or Acked-by,
> > Tested-by, etc) unless someone explicitly says that they give a Reviewed-by.
> 
> This has been a mistake. I apologize.

That's okay, just wanted you to be aware.

> > Also, please use the natural name@domain form for emails. Scripts that
> > scrape emails out of emails and git commits are not fooled by "name at
> > domain" anyway.
> 
> Yeah. I believe I copied the header from the mesa-devel mail archive. Then I
> was running out of time when sending the email, etc. Sigh.
> 
> I've sent the patch once more to the mailing list.
> 
> > Reviewed-by: Dylan Baker 
> 
> Thanks!
> 
> Stefan
> 
> Public Key available
> --
> Stefan Dirsch (Res. & Dev.)   SUSE LINUX GmbH
> Tel: 0911-740 53 0Maxfeldstraße 5
> FAX: 0911-740 53 479  D-90409 Nürnberg
> http://www.suse.deGermany 
> ---
> SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham
> Norton, HRB 21284 (AG Nürnberg)
> ---


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-02 Thread Dylan Baker
Quoting Stefan Dirsch (2018-03-02 05:02:10)
> On Fri, Mar 02, 2018 at 01:39:40PM +0100, Gustaw Smolarczyk wrote:
> > 2018-03-02 12:59 GMT+01:00 Stefan Dirsch :
> > 
> > On Fri, Mar 02, 2018 at 11:47:57AM +, Eric Engestrom wrote:
> > > On Friday, 2018-03-02 12:25:11 +0100, Stefan Dirsch wrote:
> > > > On Fri, Mar 02, 2018 at 11:03:53AM +, Eric Engestrom wrote:
> > > > > On Friday, 2018-03-02 11:41:00 +0100, Stefan Dirsch wrote:
> > > > > > Patch by "Tomas Chvatal"  with modifications
> > > > > > by "Michal Srb"  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 
> > > > > > Reviewed-by: Tomas Chvatal 
> > > > > > ---
> > > > > >  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.

Adding this should be fine for now. It makes me a little bit nervous because
we're acting on unicode strings in python 3 and byte strings in python 2,
however, It's fine for now.

Reviewed-by: Dylan Baker 


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-02 Thread Stefan Dirsch
On Fri, Mar 02, 2018 at 01:39:40PM +0100, Gustaw Smolarczyk wrote:
> 2018-03-02 12:59 GMT+01:00 Stefan Dirsch :
> 
> On Fri, Mar 02, 2018 at 11:47:57AM +, Eric Engestrom wrote:
> > On Friday, 2018-03-02 12:25:11 +0100, Stefan Dirsch wrote:
> > > On Fri, Mar 02, 2018 at 11:03:53AM +, Eric Engestrom wrote:
> > > > On Friday, 2018-03-02 11:41:00 +0100, Stefan Dirsch wrote:
> > > > > Patch by "Tomas Chvatal"  with modifications
> > > > > by "Michal Srb"  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 
> > > > > Reviewed-by: Tomas Chvatal 
> > > > > ---
> > > > >  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 0Maxfeldstraße 5
FAX: 0911-740 53 479  D-90409 Nürnberg
http://www.suse.deGermany 
---
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham
Norton, HRB 21284 (AG Nürnberg)
---
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-02 Thread Gustaw Smolarczyk
2018-03-02 12:59 GMT+01:00 Stefan Dirsch :

> On Fri, Mar 02, 2018 at 11:47:57AM +, Eric Engestrom wrote:
> > On Friday, 2018-03-02 12:25:11 +0100, Stefan Dirsch wrote:
> > > On Fri, Mar 02, 2018 at 11:03:53AM +, Eric Engestrom wrote:
> > > > On Friday, 2018-03-02 11:41:00 +0100, Stefan Dirsch wrote:
> > > > > Patch by "Tomas Chvatal"  with modifications
> > > > > by "Michal Srb"  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 
> > > > > Reviewed-by: Tomas Chvatal 
> > > > > ---
> > > > >  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')

Regards,
Gustaw Smolarczyk


> > > >
> > > > I think you still need to escape the string here.
> > >
> > > I don't know how to address this. :-( At least the output of
> > >
> > >   python2 egd_tables.py evergreend.h
> > >   python3 egd_tables.py evergreend.h
> > >
> > > is now identical. Surely this may change with changes in content of
> > > evergreend.h. :-( Ok. I've tried my best.
> >
> > I think you should already land the print() changes, leaving this line
> > as is for now. Won't be valid python3 yet, but this will be the last
> > thing to fix, which someone else might pick up :)
>
> Leaving the line as is won't run with python3.
>
> > With the string escape hunk left out, this patch is
> > Reviewed-by: Eric Engestrom 
>
> Thanks, but I'm not really interested in submitting a patch, which doesn't
> fix
> the build for python3.
>
> Stefan
>
> Public Key available
> --
> Stefan Dirsch (Res. & Dev.)   SUSE LINUX GmbH
> Tel: 0911-740 53 0Maxfeldstraße 5
> FAX: 0911-740 53 479  D-90409 Nürnberg
> http://www.suse.deGermany
> ---
> SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham
> Norton, HRB 21284 (AG Nürnberg)
> ---
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-02 Thread Stefan Dirsch
On Fri, Mar 02, 2018 at 11:47:57AM +, Eric Engestrom wrote:
> On Friday, 2018-03-02 12:25:11 +0100, Stefan Dirsch wrote:
> > On Fri, Mar 02, 2018 at 11:03:53AM +, Eric Engestrom wrote:
> > > On Friday, 2018-03-02 11:41:00 +0100, Stefan Dirsch wrote:
> > > > Patch by "Tomas Chvatal"  with modifications
> > > > by "Michal Srb"  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 
> > > > Reviewed-by: Tomas Chvatal 
> > > > ---
> > > >  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],
> > > 
> > > I think you still need to escape the string here.
> > 
> > I don't know how to address this. :-( At least the output of
> > 
> >   python2 egd_tables.py evergreend.h
> >   python3 egd_tables.py evergreend.h
> > 
> > is now identical. Surely this may change with changes in content of
> > evergreend.h. :-( Ok. I've tried my best.
> 
> I think you should already land the print() changes, leaving this line
> as is for now. Won't be valid python3 yet, but this will be the last
> thing to fix, which someone else might pick up :)

Leaving the line as is won't run with python3.

> With the string escape hunk left out, this patch is
> Reviewed-by: Eric Engestrom 

Thanks, but I'm not really interested in submitting a patch, which doesn't fix
the build for python3.

Stefan

Public Key available
--
Stefan Dirsch (Res. & Dev.)   SUSE LINUX GmbH
Tel: 0911-740 53 0Maxfeldstraße 5
FAX: 0911-740 53 479  D-90409 Nürnberg
http://www.suse.deGermany 
---
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham
Norton, HRB 21284 (AG Nürnberg)
---
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-02 Thread Eric Engestrom
On Friday, 2018-03-02 12:25:11 +0100, Stefan Dirsch wrote:
> On Fri, Mar 02, 2018 at 11:03:53AM +, Eric Engestrom wrote:
> > On Friday, 2018-03-02 11:41:00 +0100, Stefan Dirsch wrote:
> > > Patch by "Tomas Chvatal"  with modifications
> > > by "Michal Srb"  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 
> > > Reviewed-by: Tomas Chvatal 
> > > ---
> > >  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],
> > 
> > I think you still need to escape the string here.
> 
> I don't know how to address this. :-( At least the output of
> 
>   python2 egd_tables.py evergreend.h
>   python3 egd_tables.py evergreend.h
> 
> is now identical. Surely this may change with changes in content of
> evergreend.h. :-( Ok. I've tried my best.

I think you should already land the print() changes, leaving this line
as is for now. Won't be valid python3 yet, but this will be the last
thing to fix, which someone else might pick up :)

With the string escape hunk left out, this patch is
Reviewed-by: Eric Engestrom 

> 
> > The rest of the patch looks good to me :)
> 
> Thanks,
> Stefan
> 
> Public Key available
> --
> Stefan Dirsch (Res. & Dev.)   SUSE LINUX GmbH
> Tel: 0911-740 53 0Maxfeldstraße 5
> FAX: 0911-740 53 479  D-90409 Nürnberg
> http://www.suse.deGermany 
> ---
> SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham
> Norton, HRB 21284 (AG Nürnberg)
> ---
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-02 Thread Stefan Dirsch
On Fri, Mar 02, 2018 at 11:03:53AM +, Eric Engestrom wrote:
> On Friday, 2018-03-02 11:41:00 +0100, Stefan Dirsch wrote:
> > Patch by "Tomas Chvatal"  with modifications
> > by "Michal Srb"  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 
> > Reviewed-by: Tomas Chvatal 
> > ---
> >  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],
> 
> I think you still need to escape the string here.

I don't know how to address this. :-( At least the output of

  python2 egd_tables.py evergreend.h
  python3 egd_tables.py evergreend.h

is now identical. Surely this may change with changes in content of
evergreend.h. :-( Ok. I've tried my best.

> The rest of the patch looks good to me :)

Thanks,
Stefan

Public Key available
--
Stefan Dirsch (Res. & Dev.)   SUSE LINUX GmbH
Tel: 0911-740 53 0Maxfeldstraße 5
FAX: 0911-740 53 479  D-90409 Nürnberg
http://www.suse.deGermany 
---
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham
Norton, HRB 21284 (AG Nürnberg)
---
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-02 Thread Eric Engestrom
On Friday, 2018-03-02 11:41:00 +0100, Stefan Dirsch wrote:
> Patch by "Tomas Chvatal"  with modifications
> by "Michal Srb"  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 
> Reviewed-by: Tomas Chvatal 
> ---
>  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],

I think you still need to escape the string here.

The rest of the patch looks good to me :)

>  ', '.join(str(idx) for idx in te[2])
>  )
>  for te in self.table
> @@ -217,10 +218,10 @@ def write_tables(regs, packets):
>  strings = StringTable()
>  strings_offsets = IntTable("int")
>  
> -print '/* This file is autogenerated by egd_tables.py from evergreend.h. 
> Do not edit directly. */'
> -print
> -print CopyRight.strip()
> -print '''
> +print('/* This file is autogenerated by egd_tables.py from evergreend.h. 
> Do not edit directly. */')
> +print('')
> +print(CopyRight.strip())
> +print('''
>  #ifndef EG_TABLES_H
>  #define EG_TABLES_H
>  
> @@ -242,20 +243,20 @@ struct eg_packet3 {
>  unsigned name_offset;
>  unsigned op;
>  };
> -'''
> +''')
>  
> -print 'static const struct eg_packet3 packet3_table[] = {'
> +print('static const struct eg_packet3 packet3_table[] = {')
>  for pkt in packets:
> -print '\t{%s, %s},' % (strings.add(pkt[5:]), pkt)
> -print '};'
> -print
> +print('\t{%s, %s},' % (strings.add(pkt[5:]), pkt))
> +print('};')
> +print('')
>  
> -print 'static const struct eg_field egd_fields_table[] = {'
> +print('static const struct eg_field egd_fields_table[] = {')
>  
>  fields_idx = 0
>  for reg in regs:
>  if len(reg.fields) and reg.own_fields:
> -print '\t/* %s */' % (fields_idx)
> +print('\t/* %s */' % (fields_idx))
>  
>  reg.fields_idx = fields_idx
>  
> @@ -266,34 +267,34 @@ struct eg_packet3 {
>  while value[1] >= len(values_offsets):
>  values_offsets.append(-1)
>  values_offsets[value[1]] = 
> strings.add(strip_prefix(value[0]))
> -print '\t{%s, %s(~0u), %s, %s},' % (
> +print('\t{%s, %s(~0u), %s, %s},' % (
>  strings.add(field.name), field.s_name,
> -len(values_offsets), 
> strings_offsets.add(values_offsets))
> +len(values_offsets), 
> strings_offsets.add(values_offsets)))
>  else:
> -print '\t{%s, %s(~0u)},' % (strings.add(field.name), 
> field.s_name)
> +print('\t{%s, %s(~0u)},' % (strings.add(field.name), 
> field.s_name))
>  fields_idx += 1
>  
> -print '};'
> -print
> +print('};')
> +print('')
>  
> -print 'static const struct eg_reg egd_reg_table[] = {'
> +print('static const struct eg_reg egd_reg_table[] = {')
>  for reg in regs:
>  if len(reg.fields):
> -print '\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
> -len(reg.fields), reg.fields_idx if reg.own_fields else 
> reg.fields_owner.fields_idx)
> +print('\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
> +len(reg.fields), reg.fields_idx if reg.own_fields else 
> reg.fields_owner.fields_idx))
>  else:
> -print '\t{%s, %s},' % (strings.add(reg.name), reg.r_name)
> -print '};'
> -print
> +print('\t{%s, %s},' % (strings.add(reg.name), reg.r_name))
> +print('};')
> +print('')
>  
>  strings.emit(sys.stdout, "egd_strings")
>  
> -print
> +print('')
>  
>  strings_offsets.emit(sys.stdout, "egd_strings_offsets")
>  
> -print
> -print '#endif'
> +print('')
> +print('#endif')
>  
>  
>  def main():
> -- 
> 2.13.6
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> 

Re: [Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-02 Thread Stefan Dirsch
On Thu, Mar 01, 2018 at 09:00:38AM -0800, Dylan Baker wrote:
> Quoting sndir...@suse.de (2018-03-01 08:11:54)
> > From: Stefan Dirsch 
> > 
> > Patch by "Tomas Chvatal"  with modifications
> > by "Michal Srb"  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 
> > Reviewed-by: Tomas Chvatal 
> > Reviewed-by: Dylan Baker 
> 
> Process comment for you. Reviewed-by in mesa is like the kernel, it carries a
> very specific formal meaning and you don't add Reviewed-by (or Acked-by,
> Tested-by, etc) unless someone explicitly says that they give a Reviewed-by.

This has been a mistake. I apologize.

> Also, please use the natural name@domain form for emails. Scripts that
> scrape emails out of emails and git commits are not fooled by "name at
> domain" anyway.

Yeah. I believe I copied the header from the mesa-devel mail archive. Then I
was running out of time when sending the email, etc. Sigh.

I've sent the patch once more to the mailing list.

> Reviewed-by: Dylan Baker 

Thanks!

Stefan

Public Key available
--
Stefan Dirsch (Res. & Dev.)   SUSE LINUX GmbH
Tel: 0911-740 53 0Maxfeldstraße 5
FAX: 0911-740 53 479  D-90409 Nürnberg
http://www.suse.deGermany 
---
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham
Norton, HRB 21284 (AG Nürnberg)
---
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-02 Thread Stefan Dirsch
Patch by "Tomas Chvatal"  with modifications
by "Michal Srb"  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 
Reviewed-by: Tomas Chvatal 
---
 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],
 ', '.join(str(idx) for idx in te[2])
 )
 for te in self.table
@@ -217,10 +218,10 @@ def write_tables(regs, packets):
 strings = StringTable()
 strings_offsets = IntTable("int")
 
-print '/* This file is autogenerated by egd_tables.py from evergreend.h. 
Do not edit directly. */'
-print
-print CopyRight.strip()
-print '''
+print('/* This file is autogenerated by egd_tables.py from evergreend.h. 
Do not edit directly. */')
+print('')
+print(CopyRight.strip())
+print('''
 #ifndef EG_TABLES_H
 #define EG_TABLES_H
 
@@ -242,20 +243,20 @@ struct eg_packet3 {
 unsigned name_offset;
 unsigned op;
 };
-'''
+''')
 
-print 'static const struct eg_packet3 packet3_table[] = {'
+print('static const struct eg_packet3 packet3_table[] = {')
 for pkt in packets:
-print '\t{%s, %s},' % (strings.add(pkt[5:]), pkt)
-print '};'
-print
+print('\t{%s, %s},' % (strings.add(pkt[5:]), pkt))
+print('};')
+print('')
 
-print 'static const struct eg_field egd_fields_table[] = {'
+print('static const struct eg_field egd_fields_table[] = {')
 
 fields_idx = 0
 for reg in regs:
 if len(reg.fields) and reg.own_fields:
-print '\t/* %s */' % (fields_idx)
+print('\t/* %s */' % (fields_idx))
 
 reg.fields_idx = fields_idx
 
@@ -266,34 +267,34 @@ struct eg_packet3 {
 while value[1] >= len(values_offsets):
 values_offsets.append(-1)
 values_offsets[value[1]] = 
strings.add(strip_prefix(value[0]))
-print '\t{%s, %s(~0u), %s, %s},' % (
+print('\t{%s, %s(~0u), %s, %s},' % (
 strings.add(field.name), field.s_name,
-len(values_offsets), 
strings_offsets.add(values_offsets))
+len(values_offsets), 
strings_offsets.add(values_offsets)))
 else:
-print '\t{%s, %s(~0u)},' % (strings.add(field.name), 
field.s_name)
+print('\t{%s, %s(~0u)},' % (strings.add(field.name), 
field.s_name))
 fields_idx += 1
 
-print '};'
-print
+print('};')
+print('')
 
-print 'static const struct eg_reg egd_reg_table[] = {'
+print('static const struct eg_reg egd_reg_table[] = {')
 for reg in regs:
 if len(reg.fields):
-print '\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
-len(reg.fields), reg.fields_idx if reg.own_fields else 
reg.fields_owner.fields_idx)
+print('\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
+len(reg.fields), reg.fields_idx if reg.own_fields else 
reg.fields_owner.fields_idx))
 else:
-print '\t{%s, %s},' % (strings.add(reg.name), reg.r_name)
-print '};'
-print
+print('\t{%s, %s},' % (strings.add(reg.name), reg.r_name))
+print('};')
+print('')
 
 strings.emit(sys.stdout, "egd_strings")
 
-print
+print('')
 
 strings_offsets.emit(sys.stdout, "egd_strings_offsets")
 
-print
-print '#endif'
+print('')
+print('#endif')
 
 
 def main():
-- 
2.13.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-01 Thread Dylan Baker
Quoting sndir...@suse.de (2018-03-01 08:11:54)
> From: Stefan Dirsch 
> 
> Patch by "Tomas Chvatal"  with modifications
> by "Michal Srb"  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 
> Reviewed-by: Tomas Chvatal 
> Reviewed-by: Dylan Baker 

Process comment for you. Reviewed-by in mesa is like the kernel, it carries a
very specific formal meaning and you don't add Reviewed-by (or Acked-by,
Tested-by, etc) unless someone explicitly says that they give a Reviewed-by.

Also, please use the natural name@domain form for emails. Scripts that scrape 
emails
out of emails and git commits are not fooled by "name at domain" anyway.

> ---
>  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],
>  ', '.join(str(idx) for idx in te[2])
>  )
>  for te in self.table
> @@ -217,10 +218,10 @@ def write_tables(regs, packets):
>  strings = StringTable()
>  strings_offsets = IntTable("int")
>  
> -print '/* This file is autogenerated by egd_tables.py from evergreend.h. 
> Do not edit directly. */'
> -print
> -print CopyRight.strip()
> -print '''
> +print('/* This file is autogenerated by egd_tables.py from evergreend.h. 
> Do not edit directly. */')
> +print('')
> +print(CopyRight.strip())
> +print('''
>  #ifndef EG_TABLES_H
>  #define EG_TABLES_H
>  
> @@ -242,20 +243,20 @@ struct eg_packet3 {
>  unsigned name_offset;
>  unsigned op;
>  };
> -'''
> +''')
>  
> -print 'static const struct eg_packet3 packet3_table[] = {'
> +print('static const struct eg_packet3 packet3_table[] = {')
>  for pkt in packets:
> -print '\t{%s, %s},' % (strings.add(pkt[5:]), pkt)
> -print '};'
> -print
> +print('\t{%s, %s},' % (strings.add(pkt[5:]), pkt))
> +print('};')
> +print('')
>  
> -print 'static const struct eg_field egd_fields_table[] = {'
> +print('static const struct eg_field egd_fields_table[] = {')
>  
>  fields_idx = 0
>  for reg in regs:
>  if len(reg.fields) and reg.own_fields:
> -print '\t/* %s */' % (fields_idx)
> +print('\t/* %s */' % (fields_idx))
>  
>  reg.fields_idx = fields_idx
>  
> @@ -266,34 +267,34 @@ struct eg_packet3 {
>  while value[1] >= len(values_offsets):
>  values_offsets.append(-1)
>  values_offsets[value[1]] = 
> strings.add(strip_prefix(value[0]))
> -print '\t{%s, %s(~0u), %s, %s},' % (
> +print('\t{%s, %s(~0u), %s, %s},' % (
>  strings.add(field.name), field.s_name,
> -len(values_offsets), 
> strings_offsets.add(values_offsets))
> +len(values_offsets), 
> strings_offsets.add(values_offsets)))
>  else:
> -print '\t{%s, %s(~0u)},' % (strings.add(field.name), 
> field.s_name)
> +print('\t{%s, %s(~0u)},' % (strings.add(field.name), 
> field.s_name))
>  fields_idx += 1
>  
> -print '};'
> -print
> +print('};')
> +print('')
>  
> -print 'static const struct eg_reg egd_reg_table[] = {'
> +print('static const struct eg_reg egd_reg_table[] = {')
>  for reg in regs:
>  if len(reg.fields):
> -print '\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
> -len(reg.fields), reg.fields_idx if reg.own_fields else 
> reg.fields_owner.fields_idx)
> +print('\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
> +len(reg.fields), reg.fields_idx if reg.own_fields else 
> reg.fields_owner.fields_idx))
>  else:
> -print '\t{%s, %s},' % (strings.add(reg.name), reg.r_name)
> -print '};'
> -print
> +print('\t{%s, %s},' % (strings.add(reg.name), reg.r_name))
> +print('};')
> +print('')
>  
>  strings.emit(sys.stdout, "egd_strings")
>  
> -print
> +print('')
>  
>  

[Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-01 Thread sndirsch
From: Stefan Dirsch 

Patch by "Tomas Chvatal"  with modifications
by "Michal Srb"  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 
Reviewed-by: Tomas Chvatal 
Reviewed-by: Dylan Baker 
---
 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],
 ', '.join(str(idx) for idx in te[2])
 )
 for te in self.table
@@ -217,10 +218,10 @@ def write_tables(regs, packets):
 strings = StringTable()
 strings_offsets = IntTable("int")
 
-print '/* This file is autogenerated by egd_tables.py from evergreend.h. 
Do not edit directly. */'
-print
-print CopyRight.strip()
-print '''
+print('/* This file is autogenerated by egd_tables.py from evergreend.h. 
Do not edit directly. */')
+print('')
+print(CopyRight.strip())
+print('''
 #ifndef EG_TABLES_H
 #define EG_TABLES_H
 
@@ -242,20 +243,20 @@ struct eg_packet3 {
 unsigned name_offset;
 unsigned op;
 };
-'''
+''')
 
-print 'static const struct eg_packet3 packet3_table[] = {'
+print('static const struct eg_packet3 packet3_table[] = {')
 for pkt in packets:
-print '\t{%s, %s},' % (strings.add(pkt[5:]), pkt)
-print '};'
-print
+print('\t{%s, %s},' % (strings.add(pkt[5:]), pkt))
+print('};')
+print('')
 
-print 'static const struct eg_field egd_fields_table[] = {'
+print('static const struct eg_field egd_fields_table[] = {')
 
 fields_idx = 0
 for reg in regs:
 if len(reg.fields) and reg.own_fields:
-print '\t/* %s */' % (fields_idx)
+print('\t/* %s */' % (fields_idx))
 
 reg.fields_idx = fields_idx
 
@@ -266,34 +267,34 @@ struct eg_packet3 {
 while value[1] >= len(values_offsets):
 values_offsets.append(-1)
 values_offsets[value[1]] = 
strings.add(strip_prefix(value[0]))
-print '\t{%s, %s(~0u), %s, %s},' % (
+print('\t{%s, %s(~0u), %s, %s},' % (
 strings.add(field.name), field.s_name,
-len(values_offsets), 
strings_offsets.add(values_offsets))
+len(values_offsets), 
strings_offsets.add(values_offsets)))
 else:
-print '\t{%s, %s(~0u)},' % (strings.add(field.name), 
field.s_name)
+print('\t{%s, %s(~0u)},' % (strings.add(field.name), 
field.s_name))
 fields_idx += 1
 
-print '};'
-print
+print('};')
+print('')
 
-print 'static const struct eg_reg egd_reg_table[] = {'
+print('static const struct eg_reg egd_reg_table[] = {')
 for reg in regs:
 if len(reg.fields):
-print '\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
-len(reg.fields), reg.fields_idx if reg.own_fields else 
reg.fields_owner.fields_idx)
+print('\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
+len(reg.fields), reg.fields_idx if reg.own_fields else 
reg.fields_owner.fields_idx))
 else:
-print '\t{%s, %s},' % (strings.add(reg.name), reg.r_name)
-print '};'
-print
+print('\t{%s, %s},' % (strings.add(reg.name), reg.r_name))
+print('};')
+print('')
 
 strings.emit(sys.stdout, "egd_strings")
 
-print
+print('')
 
 strings_offsets.emit(sys.stdout, "egd_strings_offsets")
 
-print
-print '#endif'
+print('')
+print('#endif')
 
 
 def main():
-- 
2.13.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-03-01 Thread Stefan Dirsch
On Wed, Feb 28, 2018 at 02:16:08PM +0100, Stefan Dirsch wrote:
> On Wed, Feb 28, 2018 at 12:12:25PM +0100, Stefan Dirsch wrote:
> > Patch by "Tomas Chvatal"  with modifications
> > by "Michal Srb"  to not break python 2.
> > 
> > https://bugzilla.suse.com/show_bug.cgi?id=1082303
> > 
> > v2:
> > - open parse file in binary mode (default changed from binary to unicode
> >   text mode with python3)
> > - 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
> 
> Ok, guys. This patch is complete crap. Tested with
> 
>   python2/python3 ./egd_tables.py
> 
> (meanwhile figured out, that the parse file itself needs to be added as second
> argument)
> 
> This happens if you try to upstream and revise a patch, that you didn't write
> yourself (in a language you're not familiar with). Sigh.
> 
> So please forget about this (not so nice) try.

Meanwhile I figured out that even the patch I initially sent was already
broken. It generated lines like this:

   "b'NOP'\0" /* 0 */
   "b'DEALLOC_STATE'\0" /* 4 */

instead of (python2)

   "NOP\0" /* 0 */
   "DEALLOC_STATE\0" /* 4 */

OMG.

Stefan

Public Key available
--
Stefan Dirsch (Res. & Dev.)   SUSE LINUX GmbH
Tel: 0911-740 53 0Maxfeldstraße 5
FAX: 0911-740 53 479  D-90409 Nürnberg
http://www.suse.deGermany 
---
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham
Norton, HRB 21284 (AG Nürnberg)
---
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-02-28 Thread Stefan Dirsch
On Wed, Feb 28, 2018 at 12:12:25PM +0100, Stefan Dirsch wrote:
> Patch by "Tomas Chvatal"  with modifications
> by "Michal Srb"  to not break python 2.
> 
> https://bugzilla.suse.com/show_bug.cgi?id=1082303
> 
> v2:
> - open parse file in binary mode (default changed from binary to unicode
>   text mode with python3)
> - 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

Ok, guys. This patch is complete crap. Tested with

  python2/python3 ./egd_tables.py

(meanwhile figured out, that the parse file itself needs to be added as second
argument)

This happens if you try to upstream and revise a patch, that you didn't write
yourself (in a language you're not familiar with). Sigh.

So please forget about this (not so nice) try.

Thanks,
Stefan

Public Key available
--
Stefan Dirsch (Res. & Dev.)   SUSE LINUX GmbH
Tel: 0911-740 53 0Maxfeldstraße 5
FAX: 0911-740 53 479  D-90409 Nürnberg
http://www.suse.deGermany 
---
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham
Norton, HRB 21284 (AG Nürnberg)
---
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] r600/egd_tables.py: make the script python 2+3 compatible

2018-02-28 Thread Stefan Dirsch
Patch by "Tomas Chvatal"  with modifications
by "Michal Srb"  to not break python 2.

https://bugzilla.suse.com/show_bug.cgi?id=1082303

v2:
- open parse file in binary mode (default changed from binary to unicode
  text mode with python3)
- 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 
Reviewed-by: Dylan Baker 
---
 src/gallium/drivers/r600/egd_tables.py | 55 +-
 1 file changed, 28 insertions(+), 27 deletions(-)

diff --git a/src/gallium/drivers/r600/egd_tables.py 
b/src/gallium/drivers/r600/egd_tables.py
index d7b78c7fb1..ee62157141 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].encode('unicode_escape'),
 ', '.join(str(idx) for idx in te[2])
 )
 for te in self.table
@@ -146,7 +147,7 @@ def strip_prefix(s):
 return s[s[2:].find('_')+3:]
 
 def parse(filename, regs, packets):
-stream = open(filename)
+stream = io.open('filename', 'b')
 
 for line in stream:
 if not line.startswith('#define '):
@@ -217,10 +218,10 @@ def write_tables(regs, packets):
 strings = StringTable()
 strings_offsets = IntTable("int")
 
-print '/* This file is autogenerated by egd_tables.py from evergreend.h. 
Do not edit directly. */'
-print
-print CopyRight.strip()
-print '''
+print('/* This file is autogenerated by egd_tables.py from evergreend.h. 
Do not edit directly. */')
+print('')
+print(CopyRight.strip())
+print('''
 #ifndef EG_TABLES_H
 #define EG_TABLES_H
 
@@ -242,20 +243,20 @@ struct eg_packet3 {
 unsigned name_offset;
 unsigned op;
 };
-'''
+''')
 
-print 'static const struct eg_packet3 packet3_table[] = {'
+print('static const struct eg_packet3 packet3_table[] = {')
 for pkt in packets:
-print '\t{%s, %s},' % (strings.add(pkt[5:]), pkt)
-print '};'
-print
+print('\t{%s, %s},' % (strings.add(pkt[5:]), pkt))
+print('};')
+print('')
 
-print 'static const struct eg_field egd_fields_table[] = {'
+print('static const struct eg_field egd_fields_table[] = {')
 
 fields_idx = 0
 for reg in regs:
 if len(reg.fields) and reg.own_fields:
-print '\t/* %s */' % (fields_idx)
+print('\t/* %s */' % (fields_idx))
 
 reg.fields_idx = fields_idx
 
@@ -266,34 +267,34 @@ struct eg_packet3 {
 while value[1] >= len(values_offsets):
 values_offsets.append(-1)
 values_offsets[value[1]] = 
strings.add(strip_prefix(value[0]))
-print '\t{%s, %s(~0u), %s, %s},' % (
+print('\t{%s, %s(~0u), %s, %s},' % (
 strings.add(field.name), field.s_name,
-len(values_offsets), 
strings_offsets.add(values_offsets))
+len(values_offsets), 
strings_offsets.add(values_offsets)))
 else:
-print '\t{%s, %s(~0u)},' % (strings.add(field.name), 
field.s_name)
+print('\t{%s, %s(~0u)},' % (strings.add(field.name), 
field.s_name))
 fields_idx += 1
 
-print '};'
-print
+print('};')
+print('')
 
-print 'static const struct eg_reg egd_reg_table[] = {'
+print('static const struct eg_reg egd_reg_table[] = {')
 for reg in regs:
 if len(reg.fields):
-print '\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
-len(reg.fields), reg.fields_idx if reg.own_fields else 
reg.fields_owner.fields_idx)
+print('\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
+len(reg.fields), reg.fields_idx if reg.own_fields else 
reg.fields_owner.fields_idx))
 else:
-print '\t{%s, %s},' % (strings.add(reg.name), reg.r_name)
-print '};'
-print
+print('\t{%s, %s},' % (strings.add(reg.name), reg.r_name))
+print('};')
+print('')
 
 strings.emit(sys.stdout, "egd_strings")
 
-print
+print('')
 
 strings_offsets.emit(sys.stdout, "egd_strings_offsets")
 
-print
-print '#endif'
+print('')
+print('#endif')
 
 
 def main():
-- 
2.13.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev