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 <>
> 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''

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