classification
Title: misstatement in example explanation using raise
Type: Stage: resolved
Components: Documentation Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: bluebloodpole, ezio.melotti, georg.brandl
Priority: low Keywords:

Created on 2009-09-11 01:35 by bluebloodpole, last changed 2009-09-16 13:33 by ezio.melotti. This issue is now closed.

Messages (4)
msg92501 - (view) Author: Gene Ratzlaff (bluebloodpole) Date: 2009-09-11 01:35
v2.6.2 Python Tutorial
http://docs.python.org/tutorial/errors.html#raising-exceptions
Section 8. Errors and Exceptions
8.4. Raising Exceptions

It appears that in the example, the original may have been:
raise(NameError('HiThere')) and was then changed to
raise NameError('HiThere') but the explanation was not changed
accordingly.  The current state and my suggested change are found below,
respectively:

Currently:
"""
>>> raise NameError('HiThere')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: HiThere

The first argument to raise names the exception to be raised. The
optional second argument specifies the exception’s argument.
Alternatively, the above could be written as
raise NameError('HiThere'). Either form works fine, but there seems to
be a growing stylistic preference for the latter.
"""

Suggest change to:
"""
>>> raise NameError('HiThere')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: HiThere

The first argument to raise names the exception to be raised. The
optional second argument specifies the exception’s argument.
Alternatively, the above could be written as
raise(NameError('HiThere')). Either form works fine, but there seems to
be a growing stylistic preference for the former.
"""
msg92662 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-09-16 02:55
The original was:
>>> raise NameError, 'HiThere'
Since now this form is deprecated, I would remove that paragraph altogether.
Instead, that paragraph should be replaced with:
"The sole argument to raise indicates the exception to be raised. This
must be either an exception instance or an exception class (a class that
derives from Exception)."
as it is now in the Py3 doc (possibly backporting r58076).
msg92664 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-09-16 07:00
Yes, that seems a good idea.
msg92686 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-09-16 13:33
Fixed in r74825 (trunk) and r74827 (release26-maint), thanks!
History
Date User Action Args
2009-09-16 13:33:34ezio.melottisetstatus: open -> closed
resolution: fixed
messages: + msg92686

stage: resolved
2009-09-16 07:00:31georg.brandlsetmessages: + msg92664
2009-09-16 02:55:32ezio.melottisetpriority: low

nosy: + ezio.melotti
messages: + msg92662

assignee: georg.brandl -> ezio.melotti
2009-09-11 01:35:44bluebloodpolecreate