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.
Created on 2016年03月15日 14:32 by vstinner, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| warnings_showmsg.patch | vstinner, 2016年03月15日 14:32 | review | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 2504 | merged | vstinner, 2017年06月30日 10:46 | |
| PR 2507 | merged | vstinner, 2017年06月30日 11:00 | |
| Messages (8) | |||
|---|---|---|---|
| msg261814 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2016年03月15日 14:32 | |
Currently, the warnings.showformat() function take between 4 and 6 parameters and it's not possible to add new parameters. warnings.showformat() calls warnings.formatwarnings() with 5 parameters. Again, it's not easy to pass new parameters. I would like to add a new "source" parameter for ResourceWarning: see issue #26567 "ResourceWarning: Use tracemalloc to display the traceback where an object was allocated when a ResourceWarning is emitted". To make warnings extensible, I propose to: * Add new showmsg() and formatmsg() functions to the warnings module, these functions take a warnings.WarningMessage instance * The _warnings module calls warnings.showmsg() rather than warnings.showwarning() * For backward compatibility, warnings.showmsg() calls warnings.showwarning() if warnings.showwarning() was replaced. Same for warnings.formatmsg(): call warnings.formatwarning() if replaced. Attached patch implements these changes. With these changes, the warnings looks a little bit more like the logging module and its logging.LogRecord class. The patch is incomplete, it doesn't add much tests yet and it doesn't touch the documentation. I would prefer to get the new API (and the whole idea) approved before going too far. Note: If warnings.showwarning is deleted ("del warnings.showwarning"), showmsg() uses its own implementation. Same for formatmsg(). |
|||
| msg261823 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2016年03月15日 19:39 | |
I'm not sure about the method names showmsg() and formatmsg(). Maybe: showwarnmsg() and formatwarnmsg()? First I used warnings.show() and warnings.format(), but "format()" is already the name of a builtin function. By the way, I would prefer to use underscore between names, like show_msg() or show_warn_msg(). But I don't know if it's ok to use a different naming scheme in an existing module :-/ |
|||
| msg262008 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年03月19日 00:23 | |
New changeset 79888b970cc4 by Victor Stinner in branch 'default': Add _showwarnmsg() and _formatwarnmsg() to warnings https://hg.python.org/cpython/rev/79888b970cc4 |
|||
| msg262009 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2016年03月19日 00:26 | |
I pushed a change which adds a private _showwarnmsg(), but I'm still interested to make this new function public! I pushed the change to unblock the issue #26567. |
|||
| msg262011 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2016年03月19日 01:19 | |
New changeset 9c92352324e8 by Victor Stinner in branch 'default': Fix test_logging https://hg.python.org/cpython/rev/9c92352324e8 |
|||
| msg278976 - (view) | Author: Sebastian Berg (seberg) * | Date: 2016年10月19日 14:44 | |
To make warning testing saner, in numpy we added basically my own version of catch_warnings on steroids, which needed/will need changing because of this. Unless I missed it somewhere, this change should maybe put into the release notes to warn make it a bit easier to track down what is going on. |
|||
| msg297378 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年06月30日 10:58 | |
New changeset 7eebeb8fb84e2a9cb73903a08c59cf1d3b32cee0 by Victor Stinner in branch 'master': bpo-30812: Fix test_warnings, restore _showwarnmsg (#2504) https://github.com/python/cpython/commit/7eebeb8fb84e2a9cb73903a08c59cf1d3b32cee0 |
|||
| msg297381 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年06月30日 11:12 | |
New changeset d0aac5da59b1bbd113e6081d7c807ad5bced8a05 by Victor Stinner in branch '3.6': bpo-30812: Fix test_warnings, restore _showwarnmsg (#2504) (#2507) https://github.com/python/cpython/commit/d0aac5da59b1bbd113e6081d7c807ad5bced8a05 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:28 | admin | set | github: 70755 |
| 2018年09月19日 23:13:07 | vstinner | set | status: open -> closed resolution: fixed stage: resolved |
| 2017年12月20日 16:16:08 | THRlWiTi | set | nosy:
+ THRlWiTi |
| 2017年06月30日 11:12:14 | vstinner | set | messages: + msg297381 |
| 2017年06月30日 11:00:00 | vstinner | set | pull_requests: + pull_request2578 |
| 2017年06月30日 10:58:49 | vstinner | set | messages: + msg297378 |
| 2017年06月30日 10:46:57 | vstinner | set | pull_requests: + pull_request2568 |
| 2016年10月19日 14:44:40 | seberg | set | nosy:
+ seberg messages: + msg278976 |
| 2016年03月19日 01:19:12 | python-dev | set | messages: + msg262011 |
| 2016年03月19日 00:26:19 | vstinner | set | messages:
+ msg262009 title: Add a new warnings.showmsg() function taking a warnings.WarningMessage object -> Add a new warnings.showwarnmsg() function taking a warnings.WarningMessage object |
| 2016年03月19日 00:23:49 | python-dev | set | nosy:
+ python-dev messages: + msg262008 |
| 2016年03月15日 19:39:38 | vstinner | set | messages: + msg261823 |
| 2016年03月15日 14:32:00 | vstinner | create | |