[Python-Dev] [Python-3000] Universal newlines support in Python 3.0

Stephen J. Turnbull stephen at xemacs.org
Fri Aug 10 21:15:45 CEST 2007


Guido van Rossum writes:

 > However, the old universal newlines feature also set an attibute named
 > 'newlines' on the file object to a tuple of up to three elements
 > giving the actual line endings that were observed on the file so far
 > (\r, \n, or \r\n). This feature is not in PEP 3116, and it is not
 > implemented. I'm tempted to kill it. Does anyone have a use case for
 > this?

I have run into files that intentionally have more than one newline
convention used (mbox and Babyl mail folders, with messages received
from various platforms).  However, most of the time multiple newline
conventions is a sign that the file is either corrupt or isn't text.
If so, then saving the file may corrupt it.  The newlines attribute
could be used to check for this condition.

 > Has anyone even ever used this?

Not I.  When I care about such issues I prefer that the codec raise an
exception at the time of detection.



More information about the Python-Dev mailing list