[New-bugs-announce] [issue3525] Changes to exceptions not reflected in tutorial examples.

Jim Sizelove report at bugs.python.org
Fri Aug 8 03:10:28 CEST 2008


New submission from Jim Sizelove <jimsize at gmail.com>:

PEPs 3109 and 3110 describe changes to Exceptions.  The attached patch
file makes changes to the tutorial to bring it in line with the changes
to errors and exceptions implemented in Python 3.0.

I'll make a comment about the .args of exceptions instances.  The
tutorial states "use of .args is discouraged."  I found, however, that
the alternative of unpacking the args using __getitem__ raises a
TypeError.  

    >>> try:
    ...     raise Exception('spam', 'eggs')
    ... except Exception as inst:
    ...     x, y = inst
    ... 
    Traceback (most recent call last):
      File "<stdin>", line 2, in <module>
    Exception: ('spam', 'eggs')
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<stdin>", line 4, in <module>
    TypeError: 'Exception' object is not iterable

Does that mean that now .args is encouraged?

----------
assignee: georg.brandl
components: Documentation
files: errors.diff
keywords: patch
messages: 70876
nosy: georg.brandl, jsizelove
severity: normal
status: open
title: Changes to exceptions not reflected in tutorial examples.
type: behavior
versions: Python 3.0
Added file: http://bugs.python.org/file11080/errors.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3525>
_______________________________________


More information about the New-bugs-announce mailing list