aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/FileDownloader.py
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo.valsorda@gmail.com>2012-12-20 14:18:23 +0100
committerFilippo Valsorda <filippo.valsorda@gmail.com>2012-12-20 14:20:24 +0100
commit1a2c3c0f3ee8f91d650a2a252d2795ea88203ca0 (patch)
tree6a48ae4d58816f95390a0c952648804239ebaeea /youtube_dl/FileDownloader.py
parent0eaf520d7758d57c61afe1832c1db9a4fb2ccc88 (diff)
downloadyoutube-dl-1a2c3c0f3ee8f91d650a2a252d2795ea88203ca0.tar.xz
some py3 fixes, both needed and recommended; we should pass 2to3 as cleanly as possible now
Diffstat (limited to 'youtube_dl/FileDownloader.py')
-rw-r--r--youtube_dl/FileDownloader.py7
1 files changed, 2 insertions, 5 deletions
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