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.

classification
Title: logging.Handler.handlerError() may raise AttributeError in traceback.print_exception()
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: ThomasRyschawy, abingham, eric.araujo, python-dev, vinay.sajip
Priority: normal Keywords:

Created on 2012-01-17 16:00 by ThomasRyschawy, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
traceback.txt ThomasRyschawy, 2012-01-17 16:07 Traceback
Messages (6)
msg151462 - (view) Author: Thomas Ryschawy (ThomasRyschawy) Date: 2012-01-17 16:00
It seems to be known that in case of a Windows GUI app that isn’t connected to a console sys.stderr can be None. See the Note on http://docs.python.org/py3k/library/sys.html: Under some conditions stdin, stdout and stderr as well as the original values __stdin__, __stdout__ and __stderr__ can be None. It is usually the case for Windows GUI apps that aren’t connected to a console and Python apps started with pythonw.
In combination with logging this leads to an issue similar to issue #5971. In my case sys.stderr is None and File: lib\logging\__init__.py, Class: Handler, Method: handleError raises AttributeError: 'NoneType' object has no attribute 'write'.
A 'simple' solution would be to check if sys.stderr is not None. In case it is None handleError must not call traceback.print_exception() and not directly write to sys.stderr.
msg151686 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-01-20 11:32
New changeset b60c789c4ccd by Vinay Sajip in branch '2.7':
Closes #13807: Now checks for sys.stderr being there before writing to it.
http://hg.python.org/cpython/rev/b60c789c4ccd

New changeset 73dad4940b88 by Vinay Sajip in branch '3.1':
Closes #13807: Now checks for sys.stderr being there before writing to it.
http://hg.python.org/cpython/rev/73dad4940b88

New changeset 6a1a33a1fe93 by Vinay Sajip in branch '3.2':
Closes #13807: Merged fix from 3.1.
http://hg.python.org/cpython/rev/6a1a33a1fe93

New changeset de85a9c7fe94 by Vinay Sajip in branch 'default':
Closes #13807: Merged fix from 3.2.
http://hg.python.org/cpython/rev/de85a9c7fe94
msg152522 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-03 15:15
As said on python-checkins/-dev, this bug fix should be reverted in 3.1 (in security mode).
msg152546 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-02-03 18:24
New changeset 813a34170ac5 by Vinay Sajip in branch '3.1':
Revert fix for #13807 mistakenly applied in this branch.
http://hg.python.org/cpython/rev/813a34170ac5
msg152779 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-02-06 21:25
New changeset 6b951f27f6a8 by Vinay Sajip in branch '3.2':
Null merge for reverted fix for #13807.
http://hg.python.org/cpython/rev/6b951f27f6a8

New changeset 140f7de4d2a5 by Vinay Sajip in branch 'default':
Null merge for reverted fix for #13807.
http://hg.python.org/cpython/rev/140f7de4d2a5
msg152859 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-08 14:24
Thanks for the prompt action!
History
Date User Action Args
2022-04-11 14:57:25adminsetgithub: 58015
2012-02-08 14:24:47eric.araujosetmessages: + msg152859
2012-02-06 21:25:55python-devsetmessages: + msg152779
2012-02-03 18:24:37python-devsetmessages: + msg152546
2012-02-03 15:15:05eric.araujosetnosy: + eric.araujo

messages: + msg152522
versions: - Python 2.6, Python 3.1, Python 3.4
2012-01-20 11:32:13python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg151686

resolution: fixed
stage: resolved
2012-01-20 03:07:28vinay.sajipsetassignee: vinay.sajip

nosy: + vinay.sajip
2012-01-18 09:36:31abinghamsetnosy: + abingham
2012-01-17 16:07:04ThomasRyschawysetfiles: + traceback.txt
2012-01-17 16:03:46ThomasRyschawysetfiles: - traceback.txt
2012-01-17 16:00:13ThomasRyschawycreate