Issue 10271: warnings.showwarning should allow any callable object (original) (raw)

Created on 2010-10-31 18:53 by lekma, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
Issue10271.diff lekma,2011-02-02 13:19 patch against py3k review
Issue10271.33.fix.diff lekma,2011-04-17 13:50 fix issue10271 review
Issue10271.33.test.diff lekma,2011-04-17 13:51 test for issue10271 review
Messages (11)
msg120080 - (view) Author: (lekma) * Date: 2010-10-31 18:53
Overriding warnings.showwarning() with a c/python module function (from a c/python module) doesn't work because warn_explicit() only allow PyFunction or PyMethod objects to be called (unfortunately c/python module functions are of type PyCFunction). Suggested changes in _warnings.c (from py3k) - not tested at all: from: 412 if (!PyMethod_Check(show_fxn) && !PyFunction_Check(show_fxn)) { 413 PyErr_SetString(PyExc_TypeError, 414 "warnings.showwarning() must be set to a " 415 "function or method"); to: 412 if (!PyCallable_Check(show_fxn)) { 413 PyErr_SetString(PyExc_TypeError, 414 "warnings.showwarning() must be set to a " 415 "callable");
msg127883 - (view) Author: (lekma) * Date: 2011-02-04 10:46
brett, is there any chance for this to make it in?
msg127936 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-02-04 20:20
Not for 3.2.0, no as it's such a minor "fix". Chance this can go into 3.2.1, though. Definitely for 3.3.
msg133927 - (view) Author: (lekma) * Date: 2011-04-17 13:50
- split the patch between the actual fix and the test - rewrote the test a little bit (I'm not sure it's even needed, hence the split) - rediff against 3.3 (should still apply cleanly on top of 3.2 (modulo offset))
msg136215 - (view) Author: (lekma) * Date: 2011-05-18 09:29
Is there anything else I should be doing?
msg136230 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-05-18 11:52
Brett's been very busy with real life. Maybe someone else can commit this.
msg136420 - (view) Author: (lekma) * Date: 2011-05-21 06:14
how should we go about that?
msg140556 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-07-18 02:18
New changeset aaced3dcb858 by Brett Cannon in branch 'default': Make warnings accept a callable for showwarnings instead of http://hg.python.org/cpython/rev/aaced3dcb858
msg140557 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-07-18 02:19
Committed in 3.3. This cannot be backported as it widens the API and those could lead to subtle incompatibilities.
msg140558 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-07-18 02:26
New changeset eaefb34fc3a1 by Brett Cannon in branch 'default': Add Misc/NEWS entry and relevant doc change for issue 10271. http://hg.python.org/cpython/rev/eaefb34fc3a1
msg140788 - (view) Author: (lekma) * Date: 2011-07-21 06:07
Thank you very much for your help
History
Date User Action Args
2022-04-11 14:57:08 admin set github: 54480
2011-07-21 06:07:49 lekma set messages: +
2011-07-18 02:26:00 python-dev set messages: +
2011-07-18 02:19:13 brett.cannon set status: open -> closedresolution: fixedmessages: +
2011-07-18 02🔞11 python-dev set nosy: + python-devmessages: +
2011-07-16 09:49:04 ncoghlan set nosy: + ncoghlan
2011-05-21 06:14:59 lekma set messages: +
2011-05-18 11:52:46 r.david.murray set nosy: + r.david.murraymessages: +
2011-05-18 11:44:08 daniel.urban set nosy: + daniel.urban
2011-05-18 09:29:59 lekma set messages: +
2011-04-17 13:51:15 lekma set files: + Issue10271.33.test.diff
2011-04-17 13:50:38 lekma set files: + Issue10271.33.fix.diffmessages: + versions: + Python 3.3
2011-02-04 20:20:14 brett.cannon set nosy:brett.cannon, lekmamessages: +
2011-02-04 10:46:32 lekma set nosy:brett.cannon, lekmamessages: +
2011-02-02 13:19:06 lekma set files: + Issue10271.diffnosy:brett.cannon, lekmakeywords: + patch
2010-10-31 19:03:29 brett.cannon set versions: - Python 2.6, Python 3.1, Python 2.7
2010-10-31 19:03:15 brett.cannon set assignee: brett.cannonnosy: + brett.cannon
2010-10-31 18:53:34 lekma create