Author Łukasz.Kucharski
Recipients barry, r.david.murray, Łukasz.Kucharski
Date 2014-05-12.02:58:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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)

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:
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.Kucharskisetrecipients: + Łukasz.Kucharski, barry, r.david.murray
2014-05-12 02:58:05Łukasz.Kucharskisetmessageid: <>
2014-05-12 02:58:05Łukasz.Kucharskilinkissue21476 messages
2014-05-12 02:58:04Łukasz.Kucharskicreate