
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2014-12-09 01:27 bystockbsd, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| warnings_stderr_none.patch | serhiy.storchaka,2014-12-09 11:49 | review | ||
| Messages (10) | |||
|---|---|---|---|
| msg232342 -(view) | Author: stockbsd Li (stockbsd) | Date: 2014-12-09 01:27 | |
in py3k, the following simple code will throw an uncatched exception when executed with pythonw:import warningswarnings.warn('test')the problem occurs in showarning function: in py3k's pythonw , stderr/stdout is set to None, so the file.write(...) statement will thorw AttributeError uncatched. I think a catch-all except(delete 'OSError') can solve this.def showwarning(message, category, filename, lineno, file=None, line=None): """Hook to write a warning to a file; replace if you like.""" if file is None: file = sys.stderr try: file.write(formatwarning(message, category, filename, lineno, line)) except OSError: pass # the file (probably stderr) is invalid - this warning gets lost. | |||
| msg232369 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2014-12-09 11:49 | |
Here is a patch. 2.7 is affected too. | |||
| msg232371 -(view) | Author: stockbsd Li (stockbsd) | Date: 2014-12-09 12:21 | |
1. py2 is unaffected, because stderr/stdout is not None in py2's pythonw and the catch works correctly.2. as to py3, I prefer this patch:- execpt OSError:+ execpt: | |||
| msg232374 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2014-12-09 13:10 | |
+ execpt:Please never use that, but "except Exception:" instead to not catch SystemExit or KeyboardInterrupt. | |||
| msg232391 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2014-12-09 16:41 | |
I afraid this will silence unexpected errors. | |||
| msg232424 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2014-12-10 13:09 | |
warnings_stderr_none.patch looks good to me. It can be applied on Python 2.7, 3.4 and 3.5. | |||
| msg232443 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2014-12-10 21:12 | |
New changesetd04dab84388f by Serhiy Storchaka in branch '3.4':Issue#23016: A warning no longer produces AttributeError when the programhttps://hg.python.org/cpython/rev/d04dab84388fNew changeset0050e770b34c by Serhiy Storchaka in branch 'default':Issue#23016: A warning no longer produces an AttributeError when the programhttps://hg.python.org/cpython/rev/0050e770b34cNew changesetaeeec8a4b9b8 by Serhiy Storchaka in branch '2.7':Issue#23016: A warning no longer produces an AttributeError when sys.stderrhttps://hg.python.org/cpython/rev/aeeec8a4b9b8 | |||
| msg232631 -(view) | Author: Arfrever Frehtes Taifersar Arahesis (Arfrever)*![]() | Date: 2014-12-14 08:15 | |
> + # sys.stderr is None when ran with pythonw.exe - warnings get losts/ran/run/ | |||
| msg232632 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2014-12-14 08:58 | |
New changeset70b6fe58c425 by Serhiy Storchaka in branch '3.4':Fixed a typo in a comment (issue#23016).https://hg.python.org/cpython/rev/70b6fe58c425New changesetda1ec8e0e068 by Serhiy Storchaka in branch 'default':Fixed a typo in a comment (issue#23016).https://hg.python.org/cpython/rev/da1ec8e0e068 | |||
| msg232633 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2014-12-14 08:58 | |
Thanks Arfrever. | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:10 | admin | set | github: 67205 |
| 2014-12-14 08:58:48 | serhiy.storchaka | set | messages: +msg232633 |
| 2014-12-14 08:58:06 | python-dev | set | messages: +msg232632 |
| 2014-12-14 08:15:09 | Arfrever | set | nosy: +Arfrever messages: +msg232631 |
| 2014-12-10 22:08:57 | serhiy.storchaka | set | status: open -> closed assignee:serhiy.storchaka resolution: fixed stage: patch review -> resolved |
| 2014-12-10 21:12:49 | python-dev | set | nosy: +python-dev messages: +msg232443 |
| 2014-12-10 14:58:24 | r.david.murray | set | title: uncatched exception in lib/warnings.py when executed with pythonw -> uncaught exception in lib/warnings.py when executed with pythonw |
| 2014-12-10 13:09:22 | vstinner | set | messages: +msg232424 |
| 2014-12-09 16:41:40 | serhiy.storchaka | set | messages: +msg232391 |
| 2014-12-09 13:10:45 | vstinner | set | nosy: +vstinner messages: +msg232374 |
| 2014-12-09 12:21:16 | stockbsd | set | messages: +msg232371 |
| 2014-12-09 11:49:40 | serhiy.storchaka | set | files: +warnings_stderr_none.patch type: crash -> behavior versions: + Python 2.7, Python 3.5, - Python 3.2, Python 3.3 keywords: +patch nosy: +serhiy.storchaka messages: +msg232369 stage: patch review |
| 2014-12-09 01:27:03 | stockbsd | create | |