diff --git a/pep-0278.txt b/pep-0278.txt index 81e39eefe..80510ee07 100644 --- a/pep-0278.txt +++ b/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