This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Adam.Bielański
Recipients Adam.Bielański
Date 2016-05-31.10:05:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464689112.02.0.764355408735.issue27165@psf.upfronthosting.co.za>
In-reply-to
Content
Issue: cgitb text formatter outputs all members of exception object, using standard dir() to get their names.

My patch changes its behaviour to skip fields which are callable, since printing them only clutters the output but is rarely helpful.


HTML formatter skips members starting with underscore (_), which is slightly different behaviour and I can alter my patch to make both formatters behave in the same way, should the need be. Both can skip members starting with underscore, callables, or callables and values starting with underscore - any option will be better than printing them all.


Current change alters output for exception value Exception("123412312") from:

<type 'exceptions.Exception'>: 123412312
    __class__ = <type 'exceptions.Exception'>
    __delattr__ = <method-wrapper '__delattr__' of exceptions.Exception object>
    __dict__ = {}
    __doc__ = 'Common base class for all non-exit exceptions.'
    __format__ = <built-in method __format__ of exceptions.Exception object>
    __getattribute__ = <method-wrapper '__getattribute__' of exceptions.Exception object>
    __getitem__ = <method-wrapper '__getitem__' of exceptions.Exception object>
    __getslice__ = <method-wrapper '__getslice__' of exceptions.Exception object>
    __hash__ = <method-wrapper '__hash__' of exceptions.Exception object>
    __init__ = <method-wrapper '__init__' of exceptions.Exception object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of exceptions.Exception object>
    __reduce_ex__ = <built-in method __reduce_ex__ of exceptions.Exception object>
    __repr__ = <method-wrapper '__repr__' of exceptions.Exception object>
    __setattr__ = <method-wrapper '__setattr__' of exceptions.Exception object>
    __setstate__ = <built-in method __setstate__ of exceptions.Exception object>
    __sizeof__ = <built-in method __sizeof__ of exceptions.Exception object>
    __str__ = <method-wrapper '__str__' of exceptions.Exception object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __unicode__ = <built-in method __unicode__ of exceptions.Exception object>
    args = ('123412312',)
    message = '123412312'


to:

<type 'exceptions.Exception'>: 123412312
    __dict__ = {}
    __doc__ = 'Common base class for all non-exit exceptions.'
    args = ('123412312',)
    message = '123412312'
History
Date User Action Args
2016-05-31 10:05:12Adam.Bielańskisetrecipients: + Adam.Bielański
2016-05-31 10:05:12Adam.Bielańskisetmessageid: <1464689112.02.0.764355408735.issue27165@psf.upfronthosting.co.za>
2016-05-31 10:05:11Adam.Bielańskilinkissue27165 messages
2016-05-31 10:05:11Adam.Bielańskicreate