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: Silent abort on XP help document display
Type: behavior Stage: commit review
Components: IDLE Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: amaury.forgeotdarc, loewis, scott_daniels, terry.reedy
Priority: normal Keywords: patch

Created on 2009-06-14 23:26 by scott_daniels, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
z6285.diff terry.reedy, 2011-01-01 02:34 catch
Messages (10)
msg89378 - (view) Author: Scott David Daniels (scott_daniels) * Date: 2009-06-14 23:26
When running Idle on Windows XP, Python 3.1rc2, 
a failure to find an entry in the help documents causes Idle to exit
(with no visible indication of why).  The reason is in a failure of the
call to os.startfile, and apparenly the exception causes Idle to exit
silently.  Here is a patch to .../Lib/idlelib/EditorWindow.py:

@@ -436,20 +436,24 @@ class EditorWindow(object):
     def config_dialog(self, event=None):
         configDialog.ConfigDialog(self.top,'Settings')

     def help_dialog(self, event=None):
        
fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt')
         textView.view_file(self.top,'Help',fn)

     def python_docs(self, event=None):
-        if sys.platform[:3] == 'win':
-            os.startfile(self.help_url)
-        else:
-            webbrowser.open(self.help_url)
+        try:
+            if sys.platform[:3] == 'win':
+                os.startfile(self.help_url)
+            else:
+                webbrowser.open(self.help_url)
+        except EnvironmentError as why:
+            tkMessageBox.showerror(title='Document Start Failure',
+                                   message=str(why), parent=self.text)
         return "break"

     def cut(self,event):
         self.text.event_generate("<<Cut>>")
         return "break"

     def copy(self,event):
         if not self.text.tag_ranges("sel"):
@@ -741,20 +745,25 @@ class EditorWindow(object):
         # and update the menu dictionary
         self.menudict['help'] = helpmenu

     def __extra_help_callback(self, helpfile):
         "Create a callback with the helpfile value frozen at definition
time"
         def display_extra_help(helpfile=helpfile):
             if not helpfile.startswith(('www', 'http')):
                 url = os.path.normpath(helpfile)
-            if sys.platform[:3] == 'win':
-                os.startfile(helpfile)
-            else:
-                webbrowser.open(helpfile)
+            try:
+                if sys.platform[:3] == 'win':
+                    os.startfile(helpfile)
+                else:
+                    webbrowser.open(helpfile)
+            except EnvironmentError as why:
+                tkMessageBox.showerror(title='Document Start Failure',
+                                   message=str(why), parent=self.text)
+            return "break"
         return display_extra_help

     def update_recent_files_list(self, new_file=None):
         "Load and update the recent files list and menus"
         rf_list = []
         if os.path.exists(self.recent_files_path):
             rf_list_file = open(self.recent_files_path,'r')
             try:
msg89390 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-06-15 05:31
How exactly did you trigger the error that you are fixing?
msg89391 - (view) Author: Scott David Daniels (scott_daniels) * Date: 2009-06-15 05:40
I uninstalled 3.1rc1, installed 3.1rc2, was exercising, and went to look
up something in the docs, and Idle disappeared.  I tried again, same
result.  So I opened a command window, and ran Idle as:
     python -m idlelib.idle
Tried it again and got an error message that I chased down.
Figured out it was an oncovered exception, and ....

--Scott David Daniels
Scott.Daniels@Acm.Org
msg89393 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-06-15 05:49
> I uninstalled 3.1rc1, installed 3.1rc2, was exercising, and went to look
> up something in the docs

What does that mean? What exactly did you do to "look up something in
the docs"? (I assume "was exercising" didn't cause IDLE to crash)
msg89394 - (view) Author: Scott David Daniels (scott_daniels) * Date: 2009-06-15 06:17
Help  /  Python31

Instead of docs showing up, all Idle windows closed.
To demonstrate for yourself, edit ~/.idlerc/config-main.cfg
add a line at the end (where additional docs show up), like:
4 = Python31c1;C:/Python31/Doc/python31c1.chm

(where the 4 is just over what you have already).  In my case, I
had a line much like the above left over from the previous candidate.

--Scott David Daniels
Scott.Daniels@Acm.Org
msg89525 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2009-06-19 16:37
Like Martin, I am puzzled as to what you actually did to cause a problem.
3.1rc2 on WinXP
"Help  /  Python31" means what?

Menu: Help / IDLE Help: brings up help box
Menu: Help / Python Docs: brings up doc window same as from Start menu

>>> help('Python31')
no Python documentation found for 'Python31'
>>> help()
...
help> Python31
no Python documentation found for 'Python31'

>>> help(Python31)
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    help(Python31)
NameError: name 'Python31' is not defined

???
msg89606 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-06-22 18:57
I reproduce the same problem:
In IDLE, add a new entry in "Options/Configure/General/Additional Help 
Sources", and browse to the C:\Python31\Docs\Python31*.chm file.
This new entry appears in the "Help" menu.

Now, if you un-install this version and install another, the file you have 
chosen is no more present, but still listed in the preferences.
This causes errors if you try to open it...

The proposed patch is correct, except that an error in webbrowser is more 
likely to display some 404 error and not raise an exception.
msg124951 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-12-31 04:24
webbrowser appears to be designed to return True/False if it does/or not open a browser window (regardless of site response). (I opened #10799 for a doc addition.) I believe an exception would likely indicate a bug therein. So I only wrapped the Windows startfile call (and only catch WindowsError), which could fail with any bad entry, and not just one left over from a previous install.

This patch should make the behavior on Windows much like on other systems: display message and move on. I have (yet) not tested this (but may try to), but take Scott's and Amaury's claims that the message call is correct. I will commit in a week if there are no objections.
msg124987 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-01-01 02:34
I verified the bug by creating a copy of idlelib/help.txt, making the new help entry, testing it, deleting the copy, and retesting -- IDLE silently disappears. (A copy is necessary because IDLE checks that the file exists and gives a similar message as in the patch before posting the new menu item.) I decided that since a file can get renamed, moved, or deleted for various reasons, failure to open it should be caught.

I them tested my patch, found and fixed an typo-error (yes, testing is good even for simple patches!), found and fixed another bug in one of the two functions, and committed.
r87598, r97599, r87600
msg124989 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-01-01 02:56
Bug and fix also apply to missing Idlelib/help.txt.
r87601 News entry for 3.2. Thanks Scott.
History
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50534
2011-01-01 02:56:00terry.reedysetnosy: loewis, terry.reedy, scott_daniels, amaury.forgeotdarc
messages: + msg124989
2011-01-01 02:34:57terry.reedysetstatus: open -> closed
files: + z6285.diff
nosy: loewis, terry.reedy, scott_daniels, amaury.forgeotdarc
messages: + msg124987

resolution: fixed
2011-01-01 02:18:20terry.reedysetfiles: - z6285.diff
nosy: loewis, terry.reedy, scott_daniels, amaury.forgeotdarc
2010-12-31 04:24:01terry.reedysetfiles: + z6285.diff

type: behavior
assignee: terry.reedy
versions: + Python 2.7, Python 3.2
keywords: + patch
nosy: loewis, terry.reedy, scott_daniels, amaury.forgeotdarc
messages: + msg124951
stage: commit review
2009-06-22 18:57:21amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg89606
2009-06-19 16:37:32terry.reedysetnosy: + terry.reedy
messages: + msg89525
2009-06-15 06:17:34scott_danielssetmessages: + msg89394
2009-06-15 05:49:47loewissetmessages: + msg89393
2009-06-15 05:40:17scott_danielssetmessages: + msg89391
2009-06-15 05:31:30loewissetnosy: + loewis
messages: + msg89390
2009-06-14 23:26:46scott_danielscreate