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:
parent
3c685c197c
commit
0c7783ed1a
11
pep-0278.txt
11
pep-0278.txt
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue