Utilities/__init__.py

changeset 141
c76f1ec28766
parent 114
f6e7cec11168
child 159
2e79b9c72e59
--- 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 = ""

eric ide

mercurial