From: Philipp Hagemeister Date: Thu, 20 Dec 2012 12:25:54 +0000 (+0100) Subject: Clean up legacy code X-Git-Url: http://git.oshgnacknak.de/?a=commitdiff_plain;h=bfa6389b74866d5406f68a06c589193b12f83c38;p=youtube-dl Clean up legacy code --- diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py index a7f3e1064..a861086c3 100644 --- a/youtube_dl/FileDownloader.py +++ b/youtube_dl/FileDownloader.py @@ -421,11 +421,8 @@ class FileDownloader(object): try: descfn = filename + u'.description' self.report_writedescription(descfn) - descfile = open(encodeFilename(descfn), 'wb') - try: - descfile.write(info_dict['description'].encode('utf-8')) - finally: - descfile.close() + with io.open(encodeFilename(descfn), 'w', encoding='utf-8') as descfile: + descfile.write(info_dict['description']) except (OSError, IOError): self.trouble(u'ERROR: Cannot write description file ' + descfn) return