[Xcb] [PATCH libxcb 04/18] c_client.py: use print as a function for python3 compatibility

Christian Linhart chris at DemoRecorder.com
Sun Mar 15 02:33:15 PDT 2015


Hi again Ran,

Thank you for this patch, too.

I have tested it and it does not change the generated code.

The rewritten print statement is nicer and it is consensus on Stackoverflow that
it is the right way to do it:
http://stackoverflow.com/questions/5574702/how-to-print-to-stderr-in-python

Therefore, after a long delay:
Reviewed-by: Christian Linhart <chris at demorecorder.com>

Chris

P.S.: I am going to push this patch now because it really had more than enough time for being reviewed or for raising objections.


On 10/12/14 20:58, Ran Benita wrote:
> This works for all python>=2.6, which is what configure requires.
>
> Signed-off-by: Ran Benita <ran234 at gmail.com>
> ---
>  src/c_client.py | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/c_client.py b/src/c_client.py
> index 5860fb5..63bb7d6 100644
> --- a/src/c_client.py
> +++ b/src/c_client.py
> @@ -1,4 +1,5 @@
>  #!/usr/bin/env python
> +from __future__ import print_function
>  from functools import reduce
>  import getopt
>  import os
> @@ -2335,8 +2336,7 @@ def _man_request(self, name, cookie_type, void, aux):
>                  for field in b.type.fields:
>                      _c_complex_field(self, field, space)
>                  if b.type.has_name:
> -                    print >> sys.stderr, 'ERROR: New unhandled documentation case'
> -                    pass
> +                    print('ERROR: New unhandled documentation case\n', file=sys.stderr)
>  
>          f.write('} \\fB%s\\fP;\n' % self.reply.c_type)
>          f.write('.fi\n')
> @@ -2668,7 +2668,7 @@ def _man_event(self, name):
>              spacing = ' ' * (maxtypelen - len(field.c_field_type))
>              f.write('%s    %s%s \\fI%s\\fP%s;\n' % (space, field.c_field_type, spacing, field.c_field_name, field.c_subscript))
>          else:
> -            print >> sys.stderr, 'ERROR: New unhandled documentation case'
> +            print('ERROR: New unhandled documentation case', file=sys.stderr)
>  
>      if not self.is_switch:
>          for field in struct_fields:
> @@ -2681,7 +2681,7 @@ def _man_event(self, name):
>              for field in b.type.fields:
>                  _c_complex_field(self, field, space)
>              if b.type.has_name:
> -                print >> sys.stderr, 'ERROR: New unhandled documentation case'
> +                print('ERROR: New unhandled documentation case', file=sys.stderr)
>                  pass
>  
>      f.write('} \\fB%s\\fP;\n' % self.c_type)



More information about the Xcb mailing list