Author: janne.t.harkonen
Date: Tue Mar 24 17:01:09 2009
New Revision: 1520

Modified:
   trunk/src/robot/output/readers.py
   trunk/src/robot/running/testlibraries.py
   trunk/src/robot/running/timeouts.py
   trunk/src/robot/serializing/templating.py
   trunk/src/robot/utils/__init__.py
   trunk/src/robot/utils/abstractxmlwriter.py
   trunk/src/robot/utils/error.py
   trunk/src/robot/utils/htmlwriter.py
   trunk/src/robot/utils/misc.py

Log:
Merge branch 'excepts'

Conflicts:

        src/robot/output/readers.py

Modified: trunk/src/robot/output/readers.py
==============================================================================
--- trunk/src/robot/output/readers.py   (original)
+++ trunk/src/robot/output/readers.py   Tue Mar 24 17:01:09 2009
@@ -21,12 +21,6 @@
 from robot.output import SYSLOG


-RERAISE = (KeyboardInterrupt, SystemExit, MemoryError)
-if utils.is_jython:
-    from java.lang import OutOfMemoryError
-    RERAISE += (OutOfMemoryError,)
-
-
 def process_outputs(paths, settings):
     if not paths:
         raise DataError('No output files given.')
@@ -52,7 +46,7 @@
     SYSLOG.info("Processing output file '%s'." % path)
     try:
         root = utils.DomWrapper(path)
-    except RERAISE:
+    except utils.RERAISED_EXCEPTIONS:
         raise
     except:
         raise DataError("File '%s' is not a valid XML file." % path)
@@ -247,7 +241,7 @@
         try:
             seps = (' ', ':', '.', '-', '_')
             secs = utils.timestamp_to_secs(timestamp, seps, millis=True)
-        except:
+        except DataError:
             return 'N/A'
         return utils.secs_to_timestamp(secs, millis=True)


Modified: trunk/src/robot/running/testlibraries.py
==============================================================================
--- trunk/src/robot/running/testlibraries.py    (original)
+++ trunk/src/robot/running/testlibraries.py    Tue Mar 24 17:01:09 2009
@@ -248,6 +248,8 @@
                 if not (cls is Object or
                         cls.getName().startswith('org.python.proxies.')):
                     return True
+            except utils.RERAISED_EXCEPTIONS:
+                raise
             except:
                 return True
         return False

Modified: trunk/src/robot/running/timeouts.py
==============================================================================
--- trunk/src/robot/running/timeouts.py (original)
+++ trunk/src/robot/running/timeouts.py Tue Mar 24 17:01:09 2009
@@ -88,7 +88,9 @@
             return runner.get_result()
         try:
             thread.stop()
-        except:
+        except utils.RERAISED_EXCEPTIONS:
+            raise
+        except:
             pass
         raise TimeoutError(self.get_message())


Modified: trunk/src/robot/serializing/templating.py
==============================================================================
--- trunk/src/robot/serializing/templating.py   (original)
+++ trunk/src/robot/serializing/templating.py   Tue Mar 24 17:01:09 2009
@@ -132,11 +132,8 @@
     def _handle_if(self, expression, block_lines):
         expression = self._handle_variables(expression)
         if_block, else_block = self._get_if_and_else_blocks(block_lines)
-        try:
-            result = eval(expression) and if_block or else_block
-        except:
-            result = if_block
-        if len(result) == 0:
+        result = eval(expression) and if_block or else_block
+        if not result:
             return None
         return self._process('\n'.join(result))


Modified: trunk/src/robot/utils/__init__.py
==============================================================================
--- trunk/src/robot/utils/__init__.py   (original)
+++ trunk/src/robot/utils/__init__.py   Tue Mar 24 17:01:09 2009
@@ -19,7 +19,7 @@
 from argumentparser import ArgumentParser
 from domwrapper import DomWrapper
 from escaping import escape, unescape, escape_file_name
-from error import get_error_message, get_error_details
+from error import get_error_message, get_error_details, RERAISED_EXCEPTIONS
 from htmlutils import html_escape, html_attr_escape
 from htmlwriter import HtmlWriter
 from importing import simple_import, import_

Modified: trunk/src/robot/utils/abstractxmlwriter.py
==============================================================================
--- trunk/src/robot/utils/abstractxmlwriter.py  (original)
+++ trunk/src/robot/utils/abstractxmlwriter.py  Tue Mar 24 17:01:09 2009
@@ -16,10 +16,6 @@
 from robottypes import unic


-BINARY_DATA_ERROR = ('[ Logged data seems to be binary and it is ignored. '
-     'Contact developers if you assume the data was valid and should have '
-     'been logged. ]')
-
 # See http://www.spamagogo.com/wiki/index.php/Illegal_XML_characters
_ILLEGAL_CHARS_IN_XML = [ u'\x00', u'\x01', u'\x02', u'\x03', u'\x04', u'\x05', u'\x06', u'\x07', u'\x08', u'\x0b', u'\x0c', u'\x0e',
@@ -48,10 +44,7 @@
         raise NotImplementedError

     def _encode(self, message):
-        try:
-            message = unic(message)
-        except:
-            message = BINARY_DATA_ERROR
+        message = unic(message)
         for char in _ILLEGAL_CHARS_IN_XML:
             message = message.replace(char, '')
         return message

Modified: trunk/src/robot/utils/error.py
==============================================================================
--- trunk/src/robot/utils/error.py      (original)
+++ trunk/src/robot/utils/error.py      Tue Mar 24 17:01:09 2009
@@ -17,14 +17,16 @@
 import sys
 import re
 import traceback
-if sys.platform.startswith('java'):
-    from java.io import StringWriter, PrintWriter
-    from java.lang import Throwable, OutOfMemoryError

 from match import eq
 from robottypes import is_str, unic
 from robot.errors import DataError, TimeoutError, RemoteError

+RERAISED_EXCEPTIONS = (KeyboardInterrupt, SystemExit, MemoryError)
+if sys.platform.startswith('java'):
+    from java.io import StringWriter, PrintWriter
+    from java.lang import Throwable, OutOfMemoryError
+    RERAISED_EXCEPTIONS += (OutOfMemoryError,)

 _java_trace_re = re.compile('^\s+at (\w.+)')
 _ignored_java_trace = ('org.python.', 'robot.running.', 'robot$py.',
@@ -131,7 +133,7 @@
     name = _get_name(exc_type)
     try:
         msg = unic(exc_value)
-    except:    # Happens at least if exception message is unicode
+ except UnicodeError: # Happens at least if exception message is unicode
         msg = unic(exc_value.args[0])
     return _format_message(name, msg)


Modified: trunk/src/robot/utils/htmlwriter.py
==============================================================================
--- trunk/src/robot/utils/htmlwriter.py (original)
+++ trunk/src/robot/utils/htmlwriter.py Tue Mar 24 17:01:09 2009
@@ -15,7 +15,7 @@

 from types import UnicodeType

-from abstractxmlwriter import AbstractXmlWriter, BINARY_DATA_ERROR
+from abstractxmlwriter import AbstractXmlWriter
 from htmlutils import html_escape, html_attr_escape
 from robottypes import unic

@@ -85,10 +85,7 @@

     def _escape_content(self, content):
         if type(content) is not UnicodeType:
-            try:
-                content = unic(content)
-            except:
-                content = BINARY_DATA_ERROR
+            content = unic(content)
         return html_escape(content)

     def _write(self, text):

Modified: trunk/src/robot/utils/misc.py
==============================================================================
--- trunk/src/robot/utils/misc.py       (original)
+++ trunk/src/robot/utils/misc.py       Tue Mar 24 17:01:09 2009
@@ -30,9 +30,9 @@
 def get_doc(obj):
     try:
         doc = obj.__doc__
-    except:
+    except AttributeError:
         doc = ''
-    if doc is None or doc == '':
+    if not doc:
         return ''
     return '\n'.join([ line.strip() for line in doc.strip().splitlines() ])

Reply via email to