[Python-checkins] r58232 - in python/trunk: Lib/test/test_univnewlines.py Objects/fileobject.c
guido.van.rossum
python-checkins at python.org
Sat Sep 22 22:18:03 CEST 2007
Author: guido.van.rossum
Date: Sat Sep 22 22:18:03 2007
New Revision: 58232
Modified:
python/trunk/Lib/test/test_univnewlines.py
python/trunk/Objects/fileobject.c
Log:
Patch # 188 by Philip Jenvey.
Make tell() mark CRLF as a newline.
With unit test.
Modified: python/trunk/Lib/test/test_univnewlines.py
==============================================================================
--- python/trunk/Lib/test/test_univnewlines.py (original)
+++ python/trunk/Lib/test/test_univnewlines.py Sat Sep 22 22:18:03 2007
@@ -105,6 +105,13 @@
NEWLINE = '\r\n'
DATA = DATA_CRLF
+ def test_tell(self):
+ fp = open(test_support.TESTFN, self.READMODE)
+ self.assertEqual(repr(fp.newlines), repr(None))
+ data = fp.readline()
+ pos = fp.tell()
+ self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
+
class TestMixedNewlines(TestGenericUnivNewlines):
NEWLINE = ('\r', '\n')
DATA = DATA_MIXED
Modified: python/trunk/Objects/fileobject.c
==============================================================================
--- python/trunk/Objects/fileobject.c (original)
+++ python/trunk/Objects/fileobject.c Sat Sep 22 22:18:03 2007
@@ -718,6 +718,7 @@
int c;
c = GETC(f->f_fp);
if (c == '\n') {
+ f->f_newlinetypes |= NEWLINE_CRLF;
pos++;
f->f_skipnextlf = 0;
} else if (c != EOF) ungetc(c, f->f_fp);
More information about the Python-checkins
mailing list