[PyQt] problems with PY3 and QTranslator.translate()

Wolfgang Rohdewald wolfgang.kde at rohdewald.de
Wed Oct 15 06:10:08 BST 2014


The attached script works with qt4/Python2.7 but segfaults with qt5/Python3.4.

With qt4/Python3.4, it prints random exception messages with random values like

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xee in position 2: invalid continuation byte
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfe in position 1: invalid start byte
TypeError: translate() takes from 4 to 5 positional arguments but 7 were given


The same in C++ works correctly, attached too.

Qt is 5.2.1, PyQt is 5.3.2, sip is 4.16.3

The backtrace:

#0  strlen () at ../sysdeps/x86_64/strlen.S:137
#1  0x0000000000436709 in PyUnicode_FromString (u=0x7fffffffffff <error: Cannot access memory at address 0x7fffffffffff>)
    at ../Objects/unicodeobject.c:1875
#2  0x00007ffff24ee80c in ?? () from /usr/lib/python3/dist-packages/sip.cpython-34m-x86_64-linux-gnu.so
#3  0x00007ffff24eef12 in ?? () from /usr/lib/python3/dist-packages/sip.cpython-34m-x86_64-linux-gnu.so
#4  0x00007ffff5bafda8 in sipVH_QtCore_8(PyGILState_STATE, void (*)(_sipSimpleWrapper*, PyGILState_STATE), _sipSimpleWrapper*, _object*, char const*, char const*, char const*, int) () from /usr/local/lib/python3.4/dist-packages/PyQt5/QtCore.so
#5  0x00007ffff5b282b8 in sipQTranslator::translate(char const*, char const*, char const*, int) const ()
   from /usr/local/lib/python3.4/dist-packages/PyQt5/QtCore.so
#6  0x00007ffff55b924a in QCoreApplication::translate(char const*, char const*, char const*, int) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007ffff5b132ba in meth_QObject_tr () from /usr/local/lib/python3.4/dist-packages/PyQt5/QtCore.so
#8  0x000000000057c7bc in call_function (oparg=<optimized out>, pp_stack=<synthetischer Zeiger>) at ../Python/ceval.c:4227
#9  PyEval_EvalFrameEx (f=f at entry=0x7ffff7f24438, throwflag=throwflag at entry=0) at ../Python/ceval.c:2829
#10 0x000000000057d3d3 in PyEval_EvalCodeEx (_co=_co at entry=0x7ffff7e169c0, globals=globals at entry=0x7ffff7f213c8, 
    locals=locals at entry=0x7ffff7f213c8, args=args at entry=0x0, argcount=argcount at entry=0, kws=kws at entry=0x0, kwcount=kwcount at entry=0, 
    defs=defs at entry=0x0, defcount=defcount at entry=0, kwdefs=kwdefs at entry=0x0, closure=closure at entry=0x0) at ../Python/ceval.c:3578
#11 0x000000000060ba83 in PyEval_EvalCode (locals=0x7ffff7f213c8, globals=0x7ffff7f213c8, co=0x7ffff7e169c0) at ../Python/ceval.c:773
#12 run_mod (arena=0xa12610, flags=0x7fffffffd4b0, locals=0x7ffff7f213c8, globals=0x7ffff7f213c8, filename=0x7ffff7e25bf0, mod=0xacca18)
    at ../Python/pythonrun.c:2179
#13 PyRun_FileExFlags (fp=0xa4eff0, filename_str=<optimized out>, start=<optimized out>, globals=0x7ffff7f213c8, locals=0x7ffff7f213c8, 
    closeit=1, flags=0x7fffffffd4b0) at ../Python/pythonrun.c:2132
#14 0x000000000060bc85 in PyRun_SimpleFileExFlags (fp=fp at entry=0xa4eff0, filename=<optimized out>, 
    filename at entry=0x7ffff7f18b90 "qtranslator.py", closeit=closeit at entry=1, flags=flags at entry=0x7fffffffd4b0)
    at ../Python/pythonrun.c:1605
#15 0x000000000060d3ac in PyRun_AnyFileExFlags (flags=0x7fffffffd4b0, closeit=<optimized out>, filename=<optimized out>, fp=0xa4eff0)
    at ../Python/pythonrun.c:1292
#16 run_file (p_cf=0x7fffffffd4b0, filename=0x9fd290 L"qtranslator.py", fp=0xa4eff0) at ../Modules/main.c:319
#17 Py_Main (argc=argc at entry=2, argv=argv at entry=0x9fc010) at ../Modules/main.c:751
#18 0x000000000041ec0d in main (argc=2, argv=<optimized out>) at ../Modules/python.c:69

-- 
Wolfgang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qtranslator.py
Type: text/x-python
Size: 460 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20141015/2f38c096/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 801 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20141015/2f38c096/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qtranslator.pro
Type: application/vnd.nokia.qt.qmakeprofile
Size: 150 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20141015/2f38c096/attachment.bin>


More information about the PyQt mailing list