[Mesa-dev] [PATCH 03/26] python: Use the Python 3 exception syntax

Dylan Baker dylan at pnwbakers.com
Thu Jul 5 15:42:15 UTC 2018


Quoting Eric Engestrom (2018-07-05 06:57:59)
> On Thursday, 2018-07-05 15:17:34 +0200, Mathieu Bridon wrote:
> > This is compatible with Python versions >= 2.6.
> > 
> > Signed-off-by: Mathieu Bridon <bochecha at daitauha.fr>
> > ---
> >  src/mapi/glapi/gen/glX_XML.py       | 2 +-
> >  src/mapi/glapi/gen/gl_XML.py        | 6 +++---
> >  src/mapi/glapi/gen/gl_marshal.py    | 2 +-
> >  src/mapi/glapi/gen/gl_marshal_h.py  | 2 +-
> >  src/mesa/main/get_hash_generator.py | 2 +-
> >  5 files changed, 7 insertions(+), 7 deletions(-)
> > 
> > diff --git a/src/mapi/glapi/gen/glX_XML.py b/src/mapi/glapi/gen/glX_XML.py
> > index b6d305c879..e1aa1b3e61 100644
> > --- a/src/mapi/glapi/gen/glX_XML.py
> > +++ b/src/mapi/glapi/gen/glX_XML.py
> > @@ -470,7 +470,7 @@ class glx_function(gl_XML.gl_function):
> >      def needs_reply(self):
> >          try:
> >              x = self._needs_reply
> > -        except Exception, e:
> > +        except Exception as e:
> 
> None of these actually use `e`, might as well drop it.
> Reviewed-by: Eric Engestrom <eric.engestrom at intel.com>

I was going to say the same thing, with the unused e dropped,
Reviewed-by: Dylan Baker <dylan at pnwbakers.com>

> 
> >              x = 0
> >              if self.return_type != 'void':
> >                  x = 1
> > diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
> > index 3a191abe0d..330ca0e5a6 100644
> > --- a/src/mapi/glapi/gen/gl_XML.py
> > +++ b/src/mapi/glapi/gen/gl_XML.py
> > @@ -284,7 +284,7 @@ def classify_category(name, number):
> >  
> >      try:
> >          core_version = float(name)
> > -    except Exception,e:
> > +    except Exception as e:
> >          core_version = 0.0
> >  
> >      if core_version > 0.0:
> > @@ -365,7 +365,7 @@ class gl_enum( gl_item ):
> >          else:
> >              try:
> >                  c = int(temp)
> > -            except Exception,e:
> > +            except Exception as e:
> >                  raise RuntimeError('Invalid count value "%s" for enum "%s" in function "%s" when an integer was expected.' % (temp, self.name, n))
> >  
> >              self.default_count = c
> > @@ -426,7 +426,7 @@ class gl_parameter(object):
> >              count = int(c)
> >              self.count = count
> >              self.counter = None
> > -        except Exception,e:
> > +        except Exception as e:
> >              count = 1
> >              self.count = 0
> >              self.counter = c
> > diff --git a/src/mapi/glapi/gen/gl_marshal.py b/src/mapi/glapi/gen/gl_marshal.py
> > index e9dd2c4f78..18d7a7012b 100644
> > --- a/src/mapi/glapi/gen/gl_marshal.py
> > +++ b/src/mapi/glapi/gen/gl_marshal.py
> > @@ -353,7 +353,7 @@ if __name__ == '__main__':
> >  
> >      try:
> >          (args, trail) = getopt.getopt(sys.argv[1:], 'm:f:')
> > -    except Exception,e:
> > +    except Exception as e:
> >          show_usage()
> >  
> >      for (arg,val) in args:
> > diff --git a/src/mapi/glapi/gen/gl_marshal_h.py b/src/mapi/glapi/gen/gl_marshal_h.py
> > index 6490595a00..a7a9eda573 100644
> > --- a/src/mapi/glapi/gen/gl_marshal_h.py
> > +++ b/src/mapi/glapi/gen/gl_marshal_h.py
> > @@ -74,7 +74,7 @@ if __name__ == '__main__':
> >  
> >      try:
> >          (args, trail) = getopt.getopt(sys.argv[1:], 'm:f:')
> > -    except Exception,e:
> > +    except Exception:
> >          show_usage()
> >  
> >      for (arg,val) in args:
> > diff --git a/src/mesa/main/get_hash_generator.py b/src/mesa/main/get_hash_generator.py
> > index 86c6771066..facdccd8a5 100644
> > --- a/src/mesa/main/get_hash_generator.py
> > +++ b/src/mesa/main/get_hash_generator.py
> > @@ -201,7 +201,7 @@ def show_usage():
> >  if __name__ == '__main__':
> >     try:
> >        (opts, args) = getopt.getopt(sys.argv[1:], "f:")
> > -   except Exception,e:
> > +   except Exception:
> >        show_usage()
> >  
> >     if len(args) != 0:
> > -- 
> > 2.17.1
> > 
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180705/096de097/attachment.sig>


More information about the mesa-dev mailing list