[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-06-08 Thread Vajrasky Kok
Vajrasky Kok added the comment: Here is the patch based on R. David Murray's nitpick. -- Added file: http://bugs.python.org/file35537/bytes_parser_dont_close_file_v5.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21476

[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-06-05 Thread R. David Murray
R. David Murray added the comment: I believe there are msg_NN files that have defects. I'd rather use one of those in the exception test. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21476

[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-06-01 Thread Vajrasky Kok
Vajrasky Kok added the comment: Ok, here is the updated patch based on R. David Murray's help. Thanks! -- Added file: http://bugs.python.org/file35424/bytes_parser_dont_close_file_v4.patch ___ Python tracker rep...@bugs.python.org

[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-05-31 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Could you please add a test with parse() raising an exception? Yet one nitpick. Instead of fp = openfile('msg_02.txt', 'rb') self.addCleanup(fp.close) ... you can write with openfile('msg_02.txt', 'rb') as fp:

[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-05-31 Thread Vajrasky Kok
Vajrasky Kok added the comment: Serhiy, here is the latest patch incorporating your request. -- Added file: http://bugs.python.org/file35420/bytes_parser_dont_close_file_v3.patch ___ Python tracker rep...@bugs.python.org

[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-05-31 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Sorry, I meant to test parser with invalid message, so that parse() raises an exception, and file shouldn't be closed after this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21476

[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-05-31 Thread Vajrasky Kok
Vajrasky Kok added the comment: The Parse class does not throw exception if given invalid message: Assume /tmp/a.txt contains garbage, such as: With this code: with open(/tmp/a.txt, r) as fp: msg = email.parser.Parser().parse(fp) # does not throw exception print(msg) # =

[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-05-31 Thread R. David Murray
R. David Murray added the comment: Right, part of the parser contract is to not throw exceptions. Traditionally, a bug could result in an exception, but not an invalid message. However, using the new email policies, it is possible to *request* that it raise exceptions instead of registering

[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-05-31 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If the parser itself doesn't raise exceptions, we should test with input stream raising an exception. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21476

[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-05-30 Thread R. David Murray
R. David Murray added the comment: I think the code should be using 'detach' after passing the fp to parser.parse, instead of using 'with'. -- versions: +Python 3.5 -Python 3.3 ___ Python tracker rep...@bugs.python.org

[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-05-30 Thread Vajrasky Kok
Vajrasky Kok added the comment: Here is the simple patch based on David Murray's thought. -- keywords: +patch nosy: +vajrasky Added file: http://bugs.python.org/file35413/bytes_parser_dont_close_file.patch ___ Python tracker rep...@bugs.python.org

[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-05-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Use try/finally to detach even if an exception is raised during parsing. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21476

[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-05-30 Thread Vajrasky Kok
Vajrasky Kok added the comment: Thank you, Serhiy, for the review! Here is the updated patch. -- Added file: http://bugs.python.org/file35418/bytes_parser_dont_close_file_v2.patch ___ Python tracker rep...@bugs.python.org

[issue21476] Inconsitent behaviour between BytesParser.parse and Parser.parse

2014-05-11 Thread Łukasz Kucharski
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