New submission from Laurynas Speicys: codecs.readlines() does not read to the end of the file if called after codecs.readline().
Skimmed through tasks containing codecs in title and could not find a candidate that sounded identical. Repro follows: $ cat sample_text.txt Subject: Incorrect email address RATER EMAIL rejected an invitation from SUBJECT NAME <SUBJECT EMAIL> in the PROJECT TITLE project. Notification was sent to <RECIPIENT EMAIL>, but the email address was no longer valid. $ python Python 2.7.3 (default, Sep 26 2012, 21:53:58) [GCC 4.7.2] on linux2 >>> >>> import codecs >>> >>> # No problem if readlines() are run at the beginning: >>> >>> f_in = codecs.open('sample_text.txt', 'rb', 'utf-8') >>> f_in.readlines() [u'Subject: Incorrect email address\n', u'\n', u'RATER EMAIL rejected an invitation from SUBJECT NAME <SUBJECT EMAIL> in\n', u'the PROJECT TITLE project. Notification was sent to <RECIPIENT EMAIL>,\n', u'but the email address was no longer valid.'] >>> f_in.close() >>> >>> # Let us try to read the first line separately, >>> # and then read the remainder of the file: >>> >>> f_in = codecs.open('sample_text.txt', 'rb', 'utf-8') >>> f_in.readline() u'Subject: Incorrect email address\n' >>> f_in.readlines() [u'\n', u'RATER EMAIL rejected an invitation fro'] The first readlines() does not read to the end. Subsequent readlines() returns what's left to read. sample_text.txt attached. ---------- files: sample_text.txt messages: 177098 nosy: laurynas priority: normal severity: normal status: open title: codecs: readline() followed by readlines() returns trunkated results type: behavior versions: Python 2.7 Added file: http://bugs.python.org/file28242/sample_text.txt _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16636> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com