Re: [Zope-dev] urgent: string exceptions
That'd be fine, but it would require a code audit. And third party products might fail. On Fri, 2003-04-11 at 09:14, Christian Theune wrote:
Sorry for split-post.
OTOH as the string can't be caught anyway, and it is defined as a module variable, we could simply drop the space, hmm?
Cheers, Christian
Am Fre, 2003-04-11 um 15.07 schrieb Chris McDonough:
You can catch most string exceptions. "Bad Request" cannot be caught because (afaik) the string isn't interned because it has a space in it.
As a workaround, I'd use except: then do
try: something except: e = sys.exc_info() if e[0] == 'Bad Request': do something raise
On Fri, 2003-04-11 at 05:57, Lennart Regebro wrote:
Christian Theune wrote:
a) Remove "Bad Request" beeing a String exception and make it a class exception
Yup. Don't use String Exceptions. One reason is that you can't catch them. :)
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope ) -- Christian Theune, gocept gmbh & co. kg http://www.gocept.com - ct@gocept.com fon: 03496 3099112 fax: 03496 3099118 mobile: 0179 7808366
Chris McDonough writes:
That'd be fine, but it would require a code audit. And third party products might fail.
Another issue with string exceptions is that starting with Python 2.3, raising one will cause a PendingDeprecationWarning to be issued. Try running Python 2.3 with the -Wall option to see these: Python 2.3a2+ (#10, Mar 31 2003, 12:19:34) [GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-113)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
raise 'foo' __main__:1: PendingDeprecationWarning: raising a string exception is deprecated Traceback (most recent call last): File "<stdin>", line 1, in ? foo
I think we should be very agressive about removing string exceptions, replacing them with importable class-based exceptions derived from Exception. -Fred -- Fred L. Drake, Jr. <fred at zope.com> PythonLabs at Zope Corporation
participants (2)
-
Chris McDonough -
Fred L. Drake, Jr.