New submission from Bob Farrell <[EMAIL PROTECTED]>:

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.

----------
components: Library (Lib)
files: __init__.py.patch
keywords: patch
messages: 68296
nosy: bobf
severity: normal
status: open
title: Lib/logging/__init__.py assumes its stream has flush and close methods
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file10640/__init__.py.patch

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3126>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to