fontforge/fontforge — pull request #1154 by graphicore (2014-01-29 15:45:07+00:00)
Title:  IPython expects at least one item in sys.argv

I wanted to see the python console, that I wrote back then and that is now included in fontforge. What is fantastic by the way, thanks!

So I built fontforge on my Xubuntu 13.10 and executet it. A python warning regarding the python
console appeared. The traceback was not complete so I made my own by manipulating the python
files in /usr/local/share/fontforge/python/graphicore

This is not the traceback from then, but it shows the relevant part and the same error message:

Traceback (most recent call last):
File "", line 1, in
File "shell.py", line 31, in
from ipython_view import *
File "ipython_view.py", line 23, in
import IPython
File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 43, in
from .config.loader import Config
File "/usr/lib/python2.7/dist-packages/IPython/config/__init__.py", line 16, in
from .application import *
File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 67, in
""".strip().format(app=os.path.basename(sys.argv[0]))
IndexError: list index out of range

Then I executed a line of python from the "Execute Script..." dialogue in fontforge:

import sys
print sys.argv
# output> []

Fontforge starts Python without items in the sys.argv list but IPython expects
at least one item there.

A workaround for is adding an empty string to sys.argv when it is empty.

Before importing ipython_view I added in shell.py:

if len(sys.argv) == 0:
# some versions of IPython need content in sys.argv
sys.argv.append('')

Solved the problem for me :-)