Issue 27165: Skip callables when displaying exception fields in cgitb (original) (raw)

Issue27165

Created on 2016-05-31 10:05 by Adam.Bielański, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cgitb.patch Adam.Bielański,2016-06-02 08:42 Patch for Python 3.5.1/Lib/cgitb.py
Pull Requests
URL Status Linked Edit
PR 9695 closed python-dev,2018-10-04 08:31
PR 9699 closed Adam.Bielański,2018-10-04 13:15
Messages (4)
msg266749 - (view) Author: Adam Bielański (Adam.Bielański) * Date: 2016-05-31 10:05
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'
msg268647 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2016-06-16 07:27
Hi Adam, Thanks for the patch. I reviewed it. It's a good change. As you mentioned in the comments, making both HTML and Text formatter behave consistently and skip, underscores, callables, _callables will be a good idea. Please include change. Also, if there is a test coverage for this change, it will be great. Thanks!
msg327016 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2018-10-03 23:38
Hi Adam, Are you interested in converting your patch to a GitHub pull request? Thanks!
msg415919 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-03-24 00:39
cgi/cgitb are deprecated as per PEP 594, so there won't be further enhancements to them.
History
Date User Action Args
2022-04-11 14:58:31 admin set github: 71352
2022-03-24 00:39:23 iritkatriel set status: open -> closednosy: + iritkatrielmessages: + resolution: wont fixstage: patch review -> resolved
2018-10-04 13:15:12 Adam.Bielański set pull_requests: + <pull%5Frequest9085>
2018-10-04 11:47:07 xtreak set nosy: + xtreak
2018-10-04 08:31:16 python-dev set stage: patch reviewpull_requests: + <pull%5Frequest9082>
2018-10-03 23:38:04 cheryl.sabella set nosy: + cheryl.sabellamessages: + versions: + Python 3.8, - Python 3.5, Python 3.6
2016-06-16 07:27:46 orsenthil set nosy: + orsenthilmessages: +
2016-06-02 08:43:23 Adam.Bielański set files: - cgitb.diff
2016-06-02 08:42:53 Adam.Bielański set files: + cgitb.patch
2016-05-31 10:05:11 Adam.Bielański create