Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'value,': 0.03; 'interpreter': 0.04; 'paths': 0.05; 'class,': 0.07; 'item.': 0.07; 'raised': 0.07; 'skip:/ 10': 0.07; 'python': 0.09; "'''": 0.09; 'arguments,': 0.09; 'assigning': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; 'def': 0.10; 'subject:error': 0.11; 'portion': 0.13; 'read.': 0.13; 'library': 0.15; '12:59': 0.16; 'doubleclick': 0.16; 'folder.': 0.16; 'iterating': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:too': 0.16; 'top-level': 0.16; 'value),': 0.16; 'xxx,': 0.16; 'wrote:': 0.17; 'example.': 0.17; 'exists': 0.17; 'instance,': 0.17; 'skip:{ 20': 0.17; 'jan': 0.18; '>>>': 0.18; '(or': 0.18; 'equivalent': 0.20; 'holds': 0.20; 'skip:" 30': 0.20; 'import': 0.21; 'error.': 0.21; 'default,': 0.22; 'environments': 0.22; 'exceptions': 0.22; 'object.': 0.22; 'apps': 0.23; 'specified': 0.23; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'common': 0.26; '(most': 0.27; 'am,': 0.27; 'done.': 0.27; 'handling': 0.27; 'module.': 0.27; 'skip:" 50': 0.27; 'header:X -Complaints-To:1': 0.28; 'post': 0.28; 'prints': 0.29; 'reporting': 0.29; 'source': 0.29; 'relative': 0.30; 'returned': 0.30; 'window': 0.30; 'function': 0.30; 'at:': 0.31; 'expect': 0.31; '(and': 0.32; 'file': 0.32; 'johnson': 0.32; 'print': 0.32; 'idle': 0.33; 'traceback': 0.33; 'problem': 0.33; 'to:addr:python- list': 0.33; 'another': 0.33; 'agree': 0.34; 'text': 0.34; 'path': 0.35; 'said,': 0.35; 'open': 0.35; 'posting': 0.35; 'something': 0.35; 'there': 0.35; 'received:org': 0.36; 'really': 0.36; 'should': 0.36; 'skip:p 20': 0.36; 'display': 0.36; 'does': 0.37; 'why': 0.37; 'item': 0.37; 'rather': 0.37; 'subject:: ': 0.38; 'easier': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'your': 0.60; 'personal': 0.62; 'customized': 0.64; 'skip:c 50': 0.66; 'believe': 0.69; 'color': 0.69; 'special': 0.73; 'complaint': 0.84; 'nice,': 0.84; 'received:fios.verizon.net': 0.84; 'red.': 0.84; 'rick': 0.91; 'yyy': 0.96 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: PyWart: Exception error paths far too verbose Date: Wed, 16 Jan 2013 04:53:55 -0500 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 80 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358330072 news.xs4all.nl 6977 [2001:888:2000:d::a6]:58599 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36889 On 1/16/2013 12:59 AM, Rick Johnson wrote: > > Python needs to trim the path to the source file from which the > exception was caught and only display the relative path starting from > your personal library folder. > > For example. Say your personal library exists in: > > C:\users\user\documents\python\lib > > ...then there is no need to post THAT portion of the path EVERY > STINKING TIME! For instance, let's say a script at: > > C:\users\user\documents\python\lib\sound\effects\echo.py > > ...throws an error. What will we see? > > Traceback (most recent call last): File > "C:\users\user\documents\python\lib\sound\effects\echo.py", line N, > in BLAH > > Why do i need to see "C:\users\user\documents\python\lib" EVERY > time? > > Since all directories *BELOW* the directory that holds your personal > Python library are /superfluous/ when posting exceptions to stderr, > trimming this bloat can really help to make exception messages easier > to read. > > Traceback (most recent call last): File > "...\sound\effects\reverb.py", line XXX, in YYY I agree with the complaint and you may have the germ of a good idea. The problem is that for some tracebacks, paths jump all over the place rather than having a common prefix. Dealing with this might require preprocessing the entire traceback before iterating and printing each item. Are you are aware of ''' sys.excepthook(type, value, traceback) This function prints out a given traceback and exception to sys.stderr. When an exception is raised and uncaught, the interpreter calls sys.excepthook with three arguments, the exception class, exception instance, and a traceback object. In an interactive session this happens just before control is returned to the prompt; in a Python program this happens just before the program exits. The handling of such top-level exceptions can be customized by assigning another three-argument function to sys.excepthook. ''' This is how some apps and environments customize exception reporting (and logging). I believe some people also put a replacement in their site module. >>> import sys; sys.excepthook I expect the default, excepthook, is something like def excepthook(typ, value, traceback): print('Traceback (most recent call last):', file=sys.stderr) for item in traceback: print(format_tb_item(item), file=sys.stderr) print('{}: {}'.format(typ.__name__, value), file=sys.stderr) (or the equivalent with sys.stderr.write) What you want to change is format_tb_item (possibly, as I said, after scanning traceback before the print loop). If you come up with something nice, I would like to see it. The only thing special that IDLE does now is to color the text red. I should sometime see how that is done. (Being able to doubleclick on an item and have IDLE open an edit window at the specified line would be really nice!) -- Terry Jan Reedy