diff options
author | ianb <devnull@localhost> | 2006-08-23 19:11:30 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2006-08-23 19:11:30 +0000 |
commit | 99d395d6b3d7a41f47e532eb2bf90197f92e69f6 (patch) | |
tree | 313a1425d2b15dad0f1582ed12824ca6db064232 | |
parent | 823a63518e5979091cfae393e0c01758c74ef822 (diff) | |
download | paste-99d395d6b3d7a41f47e532eb2bf90197f92e69f6.tar.gz |
Fixed a bug in the registry test (not code), since str(registered_object) never fails anymore. Fixed some formatting because of new-style exceptions in Python 2.5
-rw-r--r-- | docs/news.txt | 6 | ||||
-rw-r--r-- | paste/exceptions/collector.py | 4 | ||||
-rw-r--r-- | paste/exceptions/formatter.py | 5 | ||||
-rw-r--r-- | tests/test_exceptions/test_error_middleware.py | 2 | ||||
-rw-r--r-- | tests/test_exceptions/test_reporter.py | 2 | ||||
-rw-r--r-- | tests/test_registry.py | 5 |
6 files changed, 17 insertions, 7 deletions
diff --git a/docs/news.txt b/docs/news.txt index ab20cfb..80a4c22 100644 --- a/docs/news.txt +++ b/docs/news.txt @@ -31,6 +31,12 @@ News * Better exception if you try to put a non-str into environ when using ``paste.auth.cookie`` +* ``paste.exceptions.collector`` produces an + ``exc_data.exception_type`` that is a class, not a string. This + helps it get formatted better in Python 2.5. + +* All the tests pass on Python 2.5! + 0.9.7 ----- diff --git a/paste/exceptions/collector.py b/paste/exceptions/collector.py index 2b454e5..93eee4c 100644 --- a/paste/exceptions/collector.py +++ b/paste/exceptions/collector.py @@ -95,7 +95,7 @@ class ExceptionCollector: ``exception_formatted``: The formatted exception, generally a full traceback ``exception_type``: - The string type of the exception, like ``'ValueError'`` + The type of the exception, like ``ValueError`` ``exception_value``: The string value of the exception, like ``'x not in list'`` ``identification_code``: @@ -346,7 +346,7 @@ class ExceptionCollector: result = CollectedException( frames=frames, exception_formatted=self.collectExceptionOnly(etype, value), - exception_type=str(etype), + exception_type=etype, exception_value=str(value), identification_code=ident, date=time.localtime(), diff --git a/paste/exceptions/formatter.py b/paste/exceptions/formatter.py index 4aa876b..2b51b38 100644 --- a/paste/exceptions/formatter.py +++ b/paste/exceptions/formatter.py @@ -75,8 +75,11 @@ class AbstractFormatter(object): if source: lines.append(self.format_long_source( source, long_source)) + etype = exc_data.exception_type + if not isinstance(etype, basestring): + etype = etype.__name__ exc_info = self.format_exception_info( - exc_data.exception_type, + etype, exc_data.exception_value) data_by_importance = {'important': [], 'normal': [], 'supplemental': [], 'extra': []} diff --git a/tests/test_exceptions/test_error_middleware.py b/tests/test_exceptions/test_error_middleware.py index 658d887..428f2f4 100644 --- a/tests/test_exceptions/test_error_middleware.py +++ b/tests/test_exceptions/test_error_middleware.py @@ -87,7 +87,7 @@ def test_start_res(): def test_after_start(): res = do_request(after_start_response_app, 200) res = strip_html(str(res)) - #print res + print res assert 'ValueError: error2' in res assert ':53' in res diff --git a/tests/test_exceptions/test_reporter.py b/tests/test_exceptions/test_reporter.py index da6c470..66f2266 100644 --- a/tests/test_exceptions/test_reporter.py +++ b/tests/test_exceptions/test_reporter.py @@ -28,7 +28,7 @@ def test_logger(): content = open(fn).read() assert len(content.splitlines()) == 4 assert 'ValueError' in content - assert 'int(): a' in content + assert 'int' in content assert 'test_reporter.py' in content assert 'test_logger' in content diff --git a/tests/test_registry.py b/tests/test_registry.py index f2ec717..c2538e3 100644 --- a/tests/test_registry.py +++ b/tests/test_registry.py @@ -19,7 +19,7 @@ def simpleapp_withregistry(environ, start_response): status = '200 OK' response_headers = [('Content-type','text/plain')] start_response(status, response_headers) - return ['Hello world!Value is %s\n' % testobj] + return ['Hello world!Value is %s\n' % testobj.keys()] def simpleapp_withregistry_default(environ, start_response): status = '200 OK' @@ -74,7 +74,8 @@ class RegistryMiddleMan(object): response = [] for line in app_iter: response.append(line) - app_iter.close() + if hasattr(app_iter, 'close'): + app_iter.close() app_response.extend(response) app_response.extend(['\nAppended by middleware!\nAppendValue at \ depth %s is %s' % (self.depth, str(testobj))]) |