Title: pydoc help() function fails because sys.executable is None in stand-alone Jython
Type: crash Severity: normal
Components: Library Versions: 2.5.1
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.

File name Uploaded Description Edit Remove
1452patch.txt otmarhumbel, 2010-10-04.19:51:55 eclipse workspace diff
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 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\",
line 348, in __call__
  File "C:\home\davhan\tools\jython2.5.1rc1\jython.jar\Lib\",
line 1812, in <module>
  File "C:\home\davhan\tools\jython2.5.1rc1\jython.jar\Lib\",
line 1626, in __init__
  File "C:\home\davhan\tools\jython2.5.1rc1\jython.jar\Lib\",
line 209, in dirname
  File "C:\home\davhan\tools\jython2.5.1rc1\jython.jar\Lib\",
line 166, in split
  File "C:\home\davhan\tools\jython2.5.1rc1\jython.jar\Lib\",
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 that fixes this problem:
<         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.
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