Issue1452

classification
Title: pydoc help() function fails because sys.executable is None in stand-alone Jython
Type: crash Severity: normal
Components: Library Versions: 2.5.1
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: otmarhumbel Nosy List: dhandy, fwierzbicki, otmarhumbel
Priority: high Keywords:

Created on 2009-09-01.23:00:25 by dhandy, last changed 2010-10-04.19:54:24 by otmarhumbel.

Files
File name Uploaded Description Edit Remove
1452patch.txt otmarhumbel, 2010-10-04.19:51:55 eclipse workspace diff
Messages
msg5081 (view) Author: David Handy (dhandy) Date: 2009-09-01.23:00:24
The built-in help() function fails with an exception. I traced the cause
to code in pydoc.py failing because sys.executable is None for the
stand-alone Jython.

C:\tools\jython2.5.1rc1>java -jar jython.jar
Jython 2.5.1rc1 (Release_2_5_1rc1:6736:6741, Sep 1 2009, 10:37:37)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_06
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
>>> help()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\home\davhan\tools\jython2.5.1rc1\jython.jar\Lib\site.py",
line 348, in __call__
  File "C:\home\davhan\tools\jython2.5.1rc1\jython.jar\Lib\pydoc.py",
line 1812, in <module>
  File "C:\home\davhan\tools\jython2.5.1rc1\jython.jar\Lib\pydoc.py",
line 1626, in __init__
  File "C:\home\davhan\tools\jython2.5.1rc1\jython.jar\Lib\ntpath.py",
line 209, in dirname
  File "C:\home\davhan\tools\jython2.5.1rc1\jython.jar\Lib\ntpath.py",
line 166, in split
  File "C:\home\davhan\tools\jython2.5.1rc1\jython.jar\Lib\ntpath.py",
line 121, in splitdrive
TypeError: 'NoneType' object is unsubscriptable

In a non-standalone Jython installation, sys.executable is set to the
path to jython.bat file, and the help() function works.

Here is a patch to pydoc.py that fixes this problem:
1626c1626,1629
<         execdir = os.path.dirname(sys.executable)
---
>         if sys.executable is None:
>             execdir = os.getcwd()
>         else:
>             execdir = os.path.dirname(sys.executable)
msg6139 (view) Author: Oti Humbel (otmarhumbel) Date: 2010-10-04.19:51:54
the full diff to fix this issue
msg6140 (view) Author: Oti Humbel (otmarhumbel) Date: 2010-10-04.19:54:24
Fixed in revision 7134.
Tested on Mac OS X and Windows.
History
Date User Action Args
2010-10-04 19:54:24otmarhumbelsetstatus: open -> closed
resolution: fixed
messages: + msg6140
2010-10-04 19:51:55otmarhumbelsetfiles: + 1452patch.txt
messages: + msg6139
2010-09-29 19:01:02otmarhumbelsetassignee: otmarhumbel
nosy: + otmarhumbel
2009-10-24 04:34:34pjenveysetpriority: high
2009-09-11 20:07:32fwierzbickisetnosy: + fwierzbicki
2009-09-01 23:21:40dhandysettype: crash
2009-09-01 23:16:13dhandysetcomponents: + Library
versions: + 2.5.1
2009-09-01 23:00:25dhandycreate