[Python-Dev] [Python-checkins] r45321 - in python/trunk: Lib/test/test_traceback.py Lib/traceback.py Misc/NEWS

John J Lee jjl at pobox.com
Sun Apr 16 16:39:42 CEST 2006


On Sun, 16 Apr 2006, Guido van Rossum wrote:

> On 4/16/06, Paul Moore <p.f.moore at gmail.com> wrote:
>> Personally, my instinct is that having the whole traceback in a
>> doctest is at least as ugly.

You don't need the whole traceback -- e.g.:

"""
     If a URL is supplied, it must have an authority (host:port) component.
     According to RFC 3986, having an authority component means the URL must
     have two slashes after the scheme:

     >>> _parse_proxy('file:/ftp.example.com/')
     Traceback (most recent call last):
     ValueError: proxy URL with no authority: 'file:/ftp.example.com/'
"""

I think the try: ... except FooException: print 'FooException occurred' 
style is uglier and less natural than that, but I guess it's not a big 
deal.


> Well, it depends on what you use doctest for. If you use it to write
> unit tests, the try/except solution is fine, and perhaps preferable.
[...]

Preferable because depending less on irrelevant details?  I had thought 
that, apart from the issue with module traceback, IGNORE_EXCEPTION_DETAIL 
made that a non-issue in most cases, but perhaps I missed something 
(again).


John



More information about the Python-Dev mailing list