Message218309
The behaviour of the method for both classes seem to be a little different. Executing `Parser.parse(fp)` does not close the file pointer passed while Executing `BytesParser.parse` does.
I think this caused by fact that `BytesParser.parse` implementation is using `with` statement. Writing this
fp = TextIOWrapper(file_pointer, encoding='ascii', errors='surrogateescape')
with fp:
return self.parser.parse(fp, headersonly)
file_pointer.seek(0)
The original `file_pointer` gets closed and the call to `seek` fails.
I am not sure whether such behaviour is intended, and whether, the `with` behaves badly, or the `TextIOWrapper`, or the `BytesParser`, thus I am unable to suggest or provide a patch. But I think the behaviour should be consistent and/or documented.
I attached a file that depicts the issue. The problem originated from SO:
http://stackoverflow.com/questions/23599457/how-to-parse-an-email-in-python-without-closing-the-file
I think it's a minor issue, but it did cause a code to fail with no apparent reason. |
|
Date |
User |
Action |
Args |
2014-05-12 02:58:05 | Łukasz.Kucharski | set | recipients:
+ Łukasz.Kucharski, barry, r.david.murray |
2014-05-12 02:58:05 | Łukasz.Kucharski | set | messageid: <1399863485.87.0.621460999738.issue21476@psf.upfronthosting.co.za> |
2014-05-12 02:58:05 | Łukasz.Kucharski | link | issue21476 messages |
2014-05-12 02:58:04 | Łukasz.Kucharski | create | |
|