This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients introom, itsmemattchung, vstinner
Date 2015-04-01.22:18:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1427926713.32.0.983311581307.issue23840@psf.upfronthosting.co.za>
In-reply-to
Content
> ITSM it's not the TextIOWrapper but the detect_encoding fails and throws an error.

Oh, right. But TextIOWrapper can fail for differen reasons. For example, CTRL+c may send KeyboardInterrupt.

Try for example:

    with unittest.mock.patch.object(tokenize, '_builtin_open') as mock_open:
        mock_file = mock_open.return_value
        mock_file.tell.side_effect = OSError
        mock_file.readline.return_value = b''

        tokenize.open(fn)

This example raises an OSError in TextIOWrapper on file.tell(), and file.close() is not called.
History
Date User Action Args
2015-04-01 22:18:33vstinnersetrecipients: + vstinner, introom, itsmemattchung
2015-04-01 22:18:33vstinnersetmessageid: <1427926713.32.0.983311581307.issue23840@psf.upfronthosting.co.za>
2015-04-01 22:18:33vstinnerlinkissue23840 messages
2015-04-01 22:18:33vstinnercreate