revise the test for universal newline support to work even if

sys.stdout has been replaced
(closes SF bug #800828)
This commit is contained in:
Fred Drake 2004-05-06 04:17:58 +00:00
parent 3c685c197c
commit 0c7783ed1a
1 changed files with 9 additions and 2 deletions

View File

@ -169,8 +169,15 @@ Rationale
newline support is not enabled then file objects do not have the "newlines"
attribute, so testing whether the current Python has it can be done with a
simple
if hasattr(sys.stdout, 'newlines'):
print 'We have universal newline support'
if hasattr(open, 'newlines'):
print 'We have universal newline support'
Note that this test uses the open() function rather than the file
type so that it won't fail for versions of Python where the file
type was not available (the file type was added to the built-in
namespace in the same release as the universal newline feature was
added).
Reference Implementation