New submission from Łukasz Kucharski: 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. ---------- components: email files: mail_test.py messages: 218309 nosy: barry, r.david.murray, Łukasz.Kucharski priority: normal severity: normal status: open title: Inconsitent behaviour between BytesParser.parse and Parser.parse type: behavior versions: Python 3.3, Python 3.4 Added file: http://bugs.python.org/file35220/mail_test.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21476> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com