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: Lib/logging/__init__.py assumes its stream has flush and close methods
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: bobf, vinay.sajip
Priority: normal Keywords: patch

Created on 2008-06-16 22:54 by bobf, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
__init__.py.patch bobf, 2008-06-16 22:54 Patch to Lib/logging/__init__.py
Messages (2)
msg68296 - (view) Author: Bob Farrell (bobf) Date: 2008-06-16 22:53
The documentation for the sys module says:
"stdout and stderr needn't be built-in file objects: any object is 
acceptable as long as it has a write() method that takes a string 
argument."

However, the logging module calls flush() and close() on 
StreamHandler.stream (and stream may be stdout), yet stdout does not 
apparently need to have these methods - this caused breakage for a 
program of mine that redirects stdout and can import arbitrary modules 
(it's an interactive interpreter).

The attached patch checks that these two methods exist (using hastattr) 
before calling them.
msg68313 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2008-06-17 11:05
Fix checked into SVN. Thanks for the patch.
History
Date User Action Args
2022-04-11 14:56:35adminsetgithub: 47376
2008-06-17 11:05:54vinay.sajipsetstatus: open -> closed
resolution: fixed
messages: + msg68313
2008-06-16 22:56:39benjamin.petersonsetassignee: vinay.sajip
nosy: + vinay.sajip
2008-06-16 22:54:04bobfcreate