From bfa6389b74866d5406f68a06c589193b12f83c38 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Thu, 20 Dec 2012 13:25:54 +0100 Subject: [PATCH] Clean up legacy code --- youtube_dl/FileDownloader.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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 -- 2.40.0