[Python-Dev] Redirecting warnings.showwarning to logging (original) (raw)
Vinay Sajip vinay_sajip at yahoo.co.uk
Sun Nov 23 02:53:35 CET 2008
- Previous message: [Python-Dev] Redirecting warnings.showwarning to logging
- Next message: [Python-Dev] Redirecting warnings.showwarning to logging
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Sidnei da Silva <sidnei enfoldsystems.com> writes:
I do have one suggestion for improvement: instead of requiring the person to do this monkey patching, add a new 'log' action to the warnings filter as described by PEP 230 [1] (see: 'The Warnings Filter' section). This way, changing the behavior of how warnings are displayed (or not) is kept consistent and documented.
I see from PEP-230 the following under "Rejected Concerns" stated by GvR:
"Paul Prescod, Barry Warsaw and Fred Drake have brought up several additional concerns that I feel aren't critical. I address them here (the concerns are paraphrased, not exactly their words):"
[other concerns omitted]
- Barry: I'd like to add my own warning action. Maybe if `action'
could be a callable as well as a string. Then in my IDE, I
could set that to "mygui.popupWarningsDialog".
Response: For that purpose you would override warnings.showwarning().
[other concerns omitted]
So, monkey-patching appears to be the suggested approach. Indeed, ISTM that the showwarning function is there specifically for the purpose of being monkey-patched out.
Regards,
Vinay Sajip
- Previous message: [Python-Dev] Redirecting warnings.showwarning to logging
- Next message: [Python-Dev] Redirecting warnings.showwarning to logging
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]