some py3 fixes, both needed and recommended; we should pass 2to3 as cleanly as possible now

This commit is contained in:
Filippo Valsorda 2012-12-20 14:18:23 +01:00
parent 0eaf520d77
commit 1a2c3c0f3e
3 changed files with 9 additions and 12 deletions

View file

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