Commit 780a3726 authored by Hanno Schlichting's avatar Hanno Schlichting

Merged c101882 from 2.12 branch

parent c07f53d0
...@@ -23,6 +23,7 @@ from Acquisition import aq_parent ...@@ -23,6 +23,7 @@ from Acquisition import aq_parent
from App.config import getConfiguration from App.config import getConfiguration
from time import asctime from time import asctime
from types import StringType, ListType from types import StringType, ListType
from zExceptions import upgradeException
from zExceptions import Redirect from zExceptions import Redirect
from zExceptions import Unauthorized from zExceptions import Unauthorized
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
...@@ -167,8 +168,10 @@ class ZPublisherExceptionHook: ...@@ -167,8 +168,10 @@ class ZPublisherExceptionHook:
def __call__(self, published, REQUEST, t, v, traceback): def __call__(self, published, REQUEST, t, v, traceback):
try: try:
t, v = upgradeException(t, v)
if t is SystemExit or issubclass(t, Redirect): if t is SystemExit or issubclass(t, Redirect):
raise raise t, v, traceback
if issubclass(t, ConflictError): if issubclass(t, ConflictError):
self.logConflicts(v, REQUEST) self.logConflicts(v, REQUEST)
......
...@@ -115,19 +115,21 @@ class ExceptionHookTestCase(unittest.TestCase): ...@@ -115,19 +115,21 @@ class ExceptionHookTestCase(unittest.TestCase):
class ExceptionHookTest(ExceptionHookTestCase): class ExceptionHookTest(ExceptionHookTestCase):
def testStringException1(self): def testStringException1(self):
from zExceptions import Unauthorized
def f(): def f():
raise 'unauthorized', 'x' raise 'Unauthorized', 'x'
if sys.version_info < (2, 6): if sys.version_info < (2, 6):
self.assertRaises('unauthorized', self.call, None, None, f) self.assertRaises(Unauthorized, self.call, None, None, f)
else: else:
# Raising a string exception causes a TypeError on Python 2.6 # Raising a string exception causes a TypeError on Python 2.6
self.assertRaises(TypeError, self.call, None, None, f) self.assertRaises(TypeError, self.call, None, None, f)
def testStringException2(self): def testStringException2(self):
from zExceptions import Redirect
def f(): def f():
raise 'redirect', 'x' raise 'Redirect', 'x'
if sys.version_info < (2, 6): if sys.version_info < (2, 6):
self.assertRaises('redirect', self.call, None, None, f) self.assertRaises(Redirect, self.call, None, None, f)
else: else:
# Raising a string exception causes a TypeError on Python 2.6 # Raising a string exception causes a TypeError on Python 2.6
self.assertRaises(TypeError, self.call, None, None, f) self.assertRaises(TypeError, self.call, None, None, f)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment