[Zope-dev] raising exceptiosn [was: SVN: Zope/branches/2.9/lib/python/Products/PythonScripts/ Raise SyntaxError when encountering invalid PythonScript headers.]

Philipp von Weitershausen philipp at weitershausen.de
Thu Feb 22 05:56:59 EST 2007


Stefan H. Holek wrote:
> Log message for revision 72754:
>   Raise SyntaxError when encountering invalid PythonScript headers.
>   
> 
> Changed:
>   U   Zope/branches/2.9/lib/python/Products/PythonScripts/PythonScript.py
>   U   Zope/branches/2.9/lib/python/Products/PythonScripts/tests/testPythonScript.py
>   A   Zope/branches/2.9/lib/python/Products/PythonScripts/tests/tscripts/ns_bind_invalid.ps
> 
> -=-
> Modified: Zope/branches/2.9/lib/python/Products/PythonScripts/PythonScript.py
> ===================================================================
> --- Zope/branches/2.9/lib/python/Products/PythonScripts/PythonScript.py	2007-02-22 05:58:28 UTC (rev 72753)
> +++ Zope/branches/2.9/lib/python/Products/PythonScripts/PythonScript.py	2007-02-22 10:17:20 UTC (rev 72754)
> @@ -416,7 +416,7 @@
>                  k = k.strip().lower()
>                  v = v.strip()
>                  if not mdata.has_key(k):
> -                    SyntaxError, 'Unrecognized header line "%s"' % line
> +                    raise SyntaxError, 'Unrecognized header line "%s"' % line
>                  if v == mdata[k]:
>                      # Unchanged value
>                      continue

Stefan,

thanks for the fix. Just note that according to PEP8 and PEP3100, this 
style of raising exceptions will go away (see 
http://mail.python.org/pipermail/python-dev/2005-August/055190.html). 
The whole Zope code base has already been converted to the new style 
long ago, new code should also adhere to it.

-- 
http://worldcookery.com -- Professional Zope documentation and training
Next Zope 3 training at Camp5: http://trizpug.org/boot-camp/camp5


More information about the Zope-Dev mailing list