A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-March/021833.html below:

[Python-Dev] Deprecating string exceptions

[Python-Dev] Deprecating string exceptions [Python-Dev] Deprecating string exceptionsGuido van Rossum guido@python.org
Thu, 28 Mar 2002 00:50:01 -0500
> >>>>> "SM" == Skip Montanaro <skip@pobox.com> writes:
> 
>     SM> Taking a quick peek at my own code, the only place I see that
>     SM> strings are raised is in code that works with ZServer
>     SM> (e.g. "raise 'redirect'").
> ---------------^^^^^^^^^^^^^^^
> 
> That's kind of scary Skip!  I.e. I belive the following is /not/
> guaranteed to work in any version of Python that I'm aware of:
> 
>     try:
> 	raise 'foo'
>     except 'foo':
> 	print 'foo caught'
> 
> because 'foo' is not (necessarily) 'foo'.
> 
> Much better to use:
> 
>     FOOEXC = 'foo'
>     try:
> 	raise FOOEXC
>     except FOOEXC:
> 	print 'foo caught'
> 
> -Barry

Barry, he's doing what Zope tells him to do -- AFAIK Zope doesn't make
identifiers available for these magic exceptions.  It happens to work
because string literals that look like identifiers are always
intern()ed -- but the language doesn't guarantee this!

--Guido van Rossum (home page: http://www.python.org/~guido/)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4