From 1a2c3c0f3ee8f91d650a2a252d2795ea88203ca0 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Thu, 20 Dec 2012 14:18:23 +0100 Subject: some py3 fixes, both needed and recommended; we should pass 2to3 as cleanly as possible now --- youtube_dl/FileDownloader.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'youtube_dl/FileDownloader.py') diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py index a861086c3..d9a4ecd3a 100644 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@ -433,11 +433,8 @@ class FileDownloader(object): try: srtfn = filename.rsplit('.', 1)[0] + u'.srt' self.report_writesubtitles(srtfn) - srtfile = open(encodeFilename(srtfn), 'wb') - try: - srtfile.write(info_dict['subtitles'].encode('utf-8')) - finally: - srtfile.close() + with io.open(encodeFilename(srtfn), 'w', encoding='utf-8') as srtfile: + srtfile.write(info_dict['subtitles']) except (OSError, IOError): self.trouble(u'ERROR: Cannot write subtitles file ' + descfn) return -- cgit v1.2.3