[PATCHES] bulk conversion of python except clauses to new form
Douglas Bagnall
douglas.bagnall at catalyst.net.nz
Tue Feb 13 22:30:34 UTC 2018
Last week Jim Brown wrote in response to one of my patches:
> While you are here would it make sense to change 'except Exception,
> e:' to use "as" instead of ","?
which I ignored because, well, if you follow every stylistic nit that
shows up in diff context in samba-tool code, you'll never finish
anything.
But it made me think about how easy it would be to do this
automatically, using e.g.
perl -p -i -e 's/except\s+([\w.]+)\s*,\s*(\w+)\s*:/except $1 as $2:/' <FILES>
and this morning I did that.
I have split it into a few patches, roughly by directory.
This takes the number of old style excepts from 207 to 29:
$ git grep -P 'except\s+[\w.]+\s*,\s*\w+\s*:'
python/examples/samr.py:except Exception, e:
third_party/dnspython/dns/dnssec.py: except ValidationFailure, e:
third_party/dnspython/dns/query.py: except select.error, e:
third_party/dnspython/dns/zone.py: except dns.exception.SyntaxError, detail:
third_party/waf/wafadmin/3rdparty/boost.py: except Configure.ConfigurationError, e:
third_party/waf/wafadmin/3rdparty/boost.py: except Configure.ConfigurationError, e:
third_party/waf/wafadmin/3rdparty/boost.py: except Configure.ConfigurationError, e:
third_party/waf/wafadmin/3rdparty/paranoid.py:except Exception, e:
third_party/waf/wafadmin/Build.py: except OSError, e:
third_party/waf/wafadmin/Build.py: except OSError, e:
third_party/waf/wafadmin/Configure.py: except Exception, e:
third_party/waf/wafadmin/Configure.py: except Exception, e:
third_party/waf/wafadmin/Configure.py: except Exception, e:
third_party/waf/wafadmin/Options.py: except ValueError, e:
third_party/waf/wafadmin/Runner.py: except Exception, e:
third_party/waf/wafadmin/Runner.py: except Exception, e:
third_party/waf/wafadmin/Scripting.py: except Utils.WafError, e:
third_party/waf/wafadmin/Scripting.py: except OSError, e:
third_party/waf/wafadmin/Scripting.py: except OSError, e:
third_party/waf/wafadmin/Tools/compiler_cc.py: except Configure.ConfigurationError, e:
third_party/waf/wafadmin/Tools/compiler_cxx.py: except Configure.ConfigurationError, e:
third_party/waf/wafadmin/Tools/config_c.py: except OSError, e:
third_party/waf/wafadmin/Tools/config_c.py: except Configure.ConfigurationError, e:
third_party/waf/wafadmin/Tools/config_c.py: except Configure.ConfigurationError, e:
third_party/waf/wafadmin/Tools/msvc.py: except Exception, e:
third_party/waf/wafadmin/Tools/preproc.py: except Exception, e:
third_party/waf/wafadmin/Utils.py: except OSError, e:
third_party/waf/wafadmin/Utils.py: except OSError, e:
third_party/waf/wafadmin/pproc.py: except pywintypes.error, e:
I left the python/examples/samr.py because we all know examples
directories are left around for the benefit of archaeologists. The
less we disturb them, the better.
cheers,
Douglas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: exception.patch
Type: text/x-patch
Size: 85261 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20180214/8072e895/exception.bin>
More information about the samba-technical
mailing list