From 0482bd06bcde5601ea2ab3b01b774e03f92160b7 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 12 Jul 2010 13:50:49 +0000 Subject: - New internal exception: ``repoze.bfg.exceptions.URLDecodeError``. This URL is a subclass of the built-in Python exception named ``UnicodeDecodeError``. - When decoding a URL segment to Unicode fails, the exception raised is now ``repoze.bfg.exceptions.URLDecodeError`` instead of ``UnicodeDecodeError``. This makes it possible to register an exception view invoked specifically when ``repoze.bfg`` cannot decode a URL. --- repoze/bfg/tests/test_urldispatch.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'repoze/bfg/tests/test_urldispatch.py') diff --git a/repoze/bfg/tests/test_urldispatch.py b/repoze/bfg/tests/test_urldispatch.py index 69bd3d971..c5fa37758 100644 --- a/repoze/bfg/tests/test_urldispatch.py +++ b/repoze/bfg/tests/test_urldispatch.py @@ -224,6 +224,11 @@ class TestCompileRoute(unittest.TestCase): self.assertEqual(matcher('foo/baz/biz/buz/bar'), None) self.assertEqual(generator({'baz':1, 'buz':2}), '/foo/1/biz/2/bar') + def test_url_decode_error(self): + from repoze.bfg.exceptions import URLDecodeError + matcher, generator = self._callFUT('/:foo') + self.assertRaises(URLDecodeError, matcher, '/%FF%FE%8B%00') + class TestCompileRouteMatchFunctional(unittest.TestCase): def matches(self, pattern, path, result): from repoze.bfg.urldispatch import _compile_route -- cgit v1.2.3