Message177098
| Author |
laurynas |
| Recipients |
laurynas |
| Date |
2012年12月07日.17:01:38 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1354899698.79.0.269419302823.issue16636@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年12月07日 17:01:38 | laurynas | set | recipients:
+ laurynas |
| 2012年12月07日 17:01:38 | laurynas | set | messageid: <1354899698.79.0.269419302823.issue16636@psf.upfronthosting.co.za> |
| 2012年12月07日 17:01:38 | laurynas | link | issue16636 messages |
| 2012年12月07日 17:01:38 | laurynas | create |
|