[PySide] Unicode strings in QApplication constructor kill python interpreter

Pavel Roskin proski at gnu.org
Mon Jan 12 23:02:56 CET 2015


I'm checking if PySide is better than PyQt at handling this issue with
QApplication initialization:


It turns out it has it's own set of bugs. In Python 2, unicode
arguments kill the interpreter:

$ python
Python 2.7.8 (default, Oct 20 2014, 15:05:29)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from PySide.QtGui import QApplication
>>> QApplication([u"test"])
Segmentation fault (core dumped)

The backtrace:

#0  __strlen_ia32 () at ../sysdeps/i386/i686/multiarch/../../i586/strlen.S:94
#1  0xf7e630cd in __GI___strdup (s=0x0) at strdup.c:41
#2  0xf736ae78 in Shiboken::sequenceToArgcArgv(_object*, int*,
char***, char const*) ()
   from /usr/lib/i386-linux-gnu/libshiboken-python2.7.so.1.2
#3  0xf62eaba6 in ?? () from /usr/lib/python2.7/dist-packages/PySide/QtGui.so
#4  0x080f9d91 in type_call.lto_priv () at ../Objects/typeobject.c:745
#5  0x081082cf in PyObject_Call (kw=<optimized out>, arg=<optimized
out>, func=<optimized out>)
    at ../Objects/abstract.c:2529
#6  do_call (nk=<optimized out>, na=<optimized out>,
pp_stack=<optimized out>, func=<optimized out>)
    at ../Python/ceval.c:4239
#7  call_function (oparg=<optimized out>, pp_stack=<optimized out>) at
#8  PyEval_EvalFrameEx () at ../Python/ceval.c:2667
#9  0x08106535 in PyEval_EvalCodeEx () at ../Python/ceval.c:3253
#10 0x0813b96c in PyEval_EvalCode (
    locals={'__builtins__': <module at remote 0xf7d3c11c>, '__name__':
'__main__', 'QApplication': <Shiboken.ObjectType at remote
0xf6c8c8a0>, '__doc__': None, '__package__': None},
    globals={'__builtins__': <module at remote 0xf7d3c11c>,
'__name__': '__main__', 'QApplication': <Shiboken.ObjectType at remote
0xf6c8c8a0>, '__doc__': None, '__package__': None}, co=0xf7cdaec0) at
#11 run_mod.lto_priv () at ../Python/pythonrun.c:1371
#12 0x0808d601 in PyRun_InteractiveOneFlags (fp=0xf7f92c20
<_IO_2_1_stdin_>, filename=0x8237988 "<stdin>",
    flags=0xffffcfd8) at ../Python/pythonrun.c:858
#13 0x0808d399 in PyRun_InteractiveLoopFlags (fp=0xf7f92c20
<_IO_2_1_stdin_>, filename=0x8237988 "<stdin>",
    flags=0xffffcfd8) at ../Python/pythonrun.c:778
#14 0x0806f7f0 in PyRun_AnyFileExFlags (fp=0xf7f92c20
<_IO_2_1_stdin_>, filename=0x8237988 "<stdin>", closeit=0,
    flags=0xffffcfd8) at ../Python/pythonrun.c:747
#15 0x080daed1 in Py_Main () at ../Modules/main.c:640
#16 0x080da93b in main (argc=1, argv=0xffffd124) at ../Modules/python.c:23

Conversely, non-Unicode arguments become empty strings in Python 3:

#! /usr/bin/python3
from PySide.QtGui import QApplication
app = QApplication(["string1", b"bytes", "string2"])

The output is:
['string1', '', 'string2']

I'm using Ubuntu 14.10 i386 with

python 2.7.8-1
python3 3.4.2-1
python-pyside 1.2.2-1
python3-pyside 1.2.2-1

Pavel Roskin

More information about the PySide mailing list