You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: