Commits

Alessio Deiana committed 5702461

Reworks show warning wrapping

We now wrap showwarning as indicated in python doc.

Comments (0)

Files changed (1)

src/invenio_devserver/wsgi.py

 import traceback
+import warnings
+from functools import wraps
 
 
 def replace_error_handler():
 
 
 def wrap_warn():
-    import warnings
 
-    def wrapper(warn_fun):
-        def fun(*args, **kwargs):
-            traceback.print_stack()
-            return warn_fun(*args, **kwargs)
-        return fun
+    @wraps(warnings.showwarning)
+    def cb_showwarning(message=None, category=None, filename=None, lineno=None, file=None, line=None):
+        print "WARNING: %(category)s: %(message)s (%(file)s:%(line)s)\n" % {
+            'category': category,
+            'message': message,
+            'file': filename,
+            'line': lineno}
+        traceback.print_stack()
 
-    warnings.warn = wrapper(warnings.warn)
+    warnings.showwarning = cb_showwarning
 
 
 try: