diff --git a/requirements.txt b/requirements.txt index f29662f..e0ec043 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,6 @@ kitchen==1.2.4 mailcap-fix==0.1.3 requests==2.11.0 six==1.10.0 -pytest==3.0.7 +pytest==3.2.3 vcrpy==1.10.5 pylint==1.6.5 \ No newline at end of file diff --git a/rtv/terminal.py b/rtv/terminal.py index 4a7b8d4..0f6078f 100644 --- a/rtv/terminal.py +++ b/rtv/terminal.py @@ -513,9 +513,21 @@ class Terminal(object): # can re-use the webbrowser instance that has been patched # by RTV. It's also safer because it doesn't inject # python code through the command line. - null = open(os.devnull, 'ab+', 0) - sys.stdout, sys.stderr = null, null - webbrowser.open_new_tab(url) + + # Surpress stdout/stderr from the browser, see + # https://stackoverflow.com/questions/2323080. We can't + # depend on replacing sys.stdout & sys.stderr because + # webbrowser uses Popen(). + stdout, stderr = os.dup(1), os.dup(2) + null = os.open(os.devnull, os.O_RDWR) + try: + os.dup2(null, 1) + os.dup2(null, 2) + webbrowser.open_new_tab(url) + finally: + null.close() + os.dup2(stdout, 1) + os.dup2(stderr, 2) p = Process(target=open_url_silent, args=(url,)) p.start()