From f8d7d4086f9034b6fff0fd302699c092e65a63ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Leli=C3=A8vre?= Date: Wed, 16 Jan 2019 09:48:46 +0100 Subject: [PATCH] Use io.open in notebookapp.py to fix #4303 Following the discussion at #4340, in Python 2 we need `io.open` rather than `open` if using a file descriptor rather than a file name. --- notebook/notebookapp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 079b8716a6..6b680ed9a4 100755 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -1739,7 +1739,7 @@ def launch_browser(self): # Write a temporary file to open in the browser fd, open_file = tempfile.mkstemp(suffix='.html') - with open(fd, 'w', encoding='utf-8') as fh: + with io.open(fd, 'w', encoding='utf-8') as fh: self._write_browser_open_file(uri, fh) else: open_file = self.browser_open_file