This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Py30a5: webbrowser.open() inf recursion
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, gpolo, mark
Priority: normal Keywords:

Created on 2008-05-12 09:39 by mark, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg66716 - (view) Author: Mark Summerfield (mark) * Date: 2008-05-12 09:39
There appears to be an infinite recursion in Py30a5 (doing the same
thing in Py2.5.1 works fine):

Python 3.0a5 (r30a5:62856, May  9 2008, 11:23:06) 
[GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2
Type "copyright", "credits" or "license()" for more information.
IDLE 3.0a5
>>> import webbrowser
>>> url = "http://www.python.org"
>>> webbrowser.open(url)
Traceback (most recent call last):
  File "<pyshell#9>", line 1, in <module>
    webbrowser.open(url)
  File "/home/mark/opt/python30a5/lib/python3.0/webbrowser.py", line 61,
in open
    if browser.open(url, new, autoraise):
  File "/home/mark/opt/python30a5/lib/python3.0/webbrowser.py", line
350, in open
    devnull = open(os.devnull, "r+")
  File "/home/mark/opt/python30a5/lib/python3.0/webbrowser.py", line 61,
in open
    if browser.open(url, new, autoraise):
  File "/home/mark/opt/python30a5/lib/python3.0/webbrowser.py", line
350, in open
...
    devnull = open(os.devnull, "r+")
  File "/home/mark/opt/python30a5/lib/python3.0/webbrowser.py", line 61,
in open
    if browser.open(url, new, autoraise):
msg66721 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-05-12 13:39
It doesn't happen here, I'm using Linux too (Ubuntu 8.04) and py3k rev 63074
msg66722 - (view) Author: Mark Summerfield (mark) * Date: 2008-05-12 13:54
I get the same bug on Fedora 8 (Python build 63161) and Kubuntu 8
(official Py30a5 release)---but not on Windows XP Home where the URL is
opened correctly.

Python 3.0a5+ (py3k:60668:63161, May 12 2008, 14:46:40)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import webbrowser
>>> webbrowser.open("http://www.python.org")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mark/pycore/30/Lib/webbrowser.py", line 61, in open
if browser.open(url, new, autoraise):


Python 3.0a5 (r30a5:62856, May  9 2008, 11:27:40) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "copyright", "credits" or "license()" for more information.
IDLE 3.0a5      
>>> import webbrowser
>>> webbrowser.open("http://www.python.org")
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    webbrowser.open("http://www.python.org")
...
msg66723 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-05-12 13:58
The traceback suggest a problem when using KDE: a call to file() was
renamed to open(), this clashes with webbrowser.open().
Can you try the following patch:

Index: Lib/webbrowser.py
===================================================================
--- Lib/webbrowser.py   (revision 63159)
+++ Lib/webbrowser.py   (working copy)
@@ -347,7 +347,8 @@
         else:
             action = "openURL"

-        devnull = open(os.devnull, "r+")
+        import io
+        devnull = io.open(os.devnull, "r+")
         # if possible, put browser in separate process group, so
         # keyboard interrupts don't affect browser as well as Python
         setsid = getattr(os, 'setsid', None)
msg66725 - (view) Author: Mark Summerfield (mark) * Date: 2008-05-12 14:32
On 2008-05-12, Amaury Forgeot d'Arc wrote:
> Amaury Forgeot d'Arc <amauryfa@gmail.com> added the comment:
>
> The traceback suggest a problem when using KDE: a call to file() was
> renamed to open(), this clashes with webbrowser.open().
> Can you try the following patch:
>
> Index: Lib/webbrowser.py
> ===================================================================
> --- Lib/webbrowser.py   (revision 63159)
> +++ Lib/webbrowser.py   (working copy)
> @@ -347,7 +347,8 @@
>          else:
>              action = "openURL"
>
> -        devnull = open(os.devnull, "r+")
> +        import io
> +        devnull = io.open(os.devnull, "r+")
>          # if possible, put browser in separate process group, so
>          # keyboard interrupts don't affect browser as well as Python
>          setsid = getattr(os, 'setsid', None)

That fixed it!
msg66726 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-05-12 14:41
Corrected as r63163.
History
Date User Action Args
2022-04-11 14:56:34adminsetgithub: 47084
2008-05-12 14:41:20amaury.forgeotdarcsetstatus: open -> closed
resolution: fixed
messages: + msg66726
2008-05-12 14:32:57marksetmessages: + msg66725
2008-05-12 13:58:31amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg66723
2008-05-12 13:54:52marksetmessages: + msg66722
2008-05-12 13:39:45gpolosetnosy: + gpolo
messages: + msg66721
versions: + Python 2.6, - Python 3.0
2008-05-12 09:39:30markcreate