Sat, 13 Mar 2010 15:48:41 +0000
Added code to handle syntax warnings during the compile much better.
--- a/Documentation/Help/source.qhp Wed Mar 10 18:16:31 2010 +0000 +++ b/Documentation/Help/source.qhp Sat Mar 13 15:48:41 2010 +0000 @@ -2424,6 +2424,7 @@ <keyword name="TemplatePropertiesDialog.setSelectedGroup" id="TemplatePropertiesDialog.setSelectedGroup" ref="eric5.Templates.TemplatePropertiesDialog.html#TemplatePropertiesDialog.setSelectedGroup" /> <keyword name="Utilities (Package)" id="Utilities (Package)" ref="index-eric5.Utilities.html" /> <keyword name="CodingError" id="CodingError" ref="eric5.Utilities.__init__.html#CodingError" /> + <keyword name="__showwarning" id="__showwarning" ref="eric5.Utilities.__init__.html#__showwarning" /> <keyword name="_percentReplacementFunc" id="_percentReplacementFunc" ref="eric5.Utilities.__init__.html#_percentReplacementFunc" /> <keyword name="compactPath" id="compactPath" ref="eric5.Utilities.__init__.html#compactPath" /> <keyword name="compile" id="compile" ref="eric5.Utilities.__init__.html#compile" />
--- a/Documentation/Source/eric5.Utilities.__init__.html Wed Mar 10 18:16:31 2010 +0000 +++ b/Documentation/Source/eric5.Utilities.__init__.html Sat Mar 13 15:48:41 2010 +0000 @@ -38,6 +38,9 @@ <h3>Functions</h3> <table> <tr> +<td><a href="#__showwarning">__showwarning</a></td> +<td>Module function to raise a SyntaxError for a SyntaxWarning.</td> +</tr><tr> <td><a href="#_percentReplacementFunc">_percentReplacementFunc</a></td> <td>Protected function called for replacing % codes.</td> </tr><tr> @@ -257,6 +260,39 @@ </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> +<a NAME="__showwarning" ID="__showwarning"></a> +<h2>__showwarning</h2> +<b>__showwarning</b>(<i>message, category, filename, lineno, file = None, line = ""</i>) +<p> + Module function to raise a SyntaxError for a SyntaxWarning. +</p><dl> +<dt><i>message</i></dt> +<dd> +warning object +</dd><dt><i>category</i></dt> +<dd> +type object of the warning +</dd><dt><i>filename</i></dt> +<dd> +name of the file causing the warning (string) +</dd><dt><i>lineno</i></dt> +<dd> +line number causing the warning (integer) +</dd><dt><i>file</i></dt> +<dd> +file to write the warning message to (ignored) +</dd><dt><i>line</i></dt> +<dd> +line causing the warning (ignored) +</dd> +</dl><dl> +<dt>Raises <b>SyntaxError</b>:</dt> +<dd> + +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> <a NAME="_percentReplacementFunc" ID="_percentReplacementFunc"></a> <h2>_percentReplacementFunc</h2> <b>_percentReplacementFunc</b>(<i>matchobj</i>)
--- a/Utilities/__init__.py Wed Mar 10 18:16:31 2010 +0000 +++ b/Utilities/__init__.py Sat Mar 13 15:48:41 2010 +0000 @@ -16,8 +16,26 @@ import base64 import getpass +def __showwarning(message, category, filename, lineno, file = None, line = ""): + """ + Module function to raise a SyntaxError for a SyntaxWarning. + + @param message warning object + @param category type object of the warning + @param filename name of the file causing the warning (string) + @param lineno line number causing the warning (integer) + @param file file to write the warning message to (ignored) + @param line line causing the warning (ignored) + @raise SyntaxError + """ + if category is SyntaxWarning: + err = SyntaxError(str(message)) + err.filename = filename + err.lineno = lineno + raise err + import warnings -warnings.filterwarnings("error", category=SyntaxWarning) +warnings.showwarning = __showwarning from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF32 @@ -957,7 +975,7 @@ line = detail.lineno error = detail.msg except AttributeError: - fn = "" + fn = file line = 1 error = str(detail) code = ""