Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apsw returns bad strings in python3 (assertion « (((PyASCIIObject*)obj)->state.ready) » fails) #168

espadons opened this Issue Aug 6, 2014 · 1 comment


None yet
2 participants
Copy link

commented Aug 6, 2014

apsw 3.8.2-r1-1-ubuntu1
python3 3.4.0-0ubuntu2
python3-pyqt4 4.10.4+dfsg1-ubuntu1

the following code snippet fails with the message
python3: ../../../qpy/QtCore/qpycore_qstring.cpp :96 : QString qpycore_PyObject_AsQString(PyObject_): l'assertion « (((PyASCIIObject_)obj)->state.ready) » a échoué.


!/usr/bin/env python3

-- coding: utf-8 --

from PyQt4.QtCore import *
from PyQt4.QtGui import *
import apsw

from Ui_test3 import Ui_Test3
class Test3Dialog(QMainWindow, Ui_Test3):
def init(self):
# Set up the user interface from Designer.
self.setupUi(self) = apsw.Connection("/home/pm/.datamanager/data/datamanager.sqlite")
self.curseur.execute("SELECT DISTINCT projet FROM projets WHERE actif='True' ORDER BY projet;")
#projets=["{}".format(x[0]) for x in self.curseur.fetchall()]
projets=[x[0] for x in self.curseur.fetchall()]

if name == "main":
import sys
app = QApplication(sys.argv)

test1 =Test3Dialog()

If the statement projets=[x[0] for x in self.curseur.fetchall()]
is replaced by projets=["{}".format(x[0]) for x in self.curseur.fetchall()]

it runs ok

the "datamanager.sqlite database has been used for years in python2 without any pb.
the file is automatically generated by pyuic from a qt-designer file 👍

-- coding: utf-8 --

Form implementation generated from reading ui file '/home/pm/Apps3/datamanager/sources/test3.ui'

Created: Wed Aug 6 14:19:54 2014

by: PyQt4 UI code generator 4.10.4

WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s

_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)

class Ui_Test3(object):
def setupUi(self, Test3):
Test3.resize(156, 138)
self.centralwidget = QtGui.QWidget(Test3)
self.projectBox = QtGui.QComboBox(self.centralwidget)
self.projectBox.setGeometry(QtCore.QRect(20, 20, 82, 31))
self.menubar = QtGui.QMenuBar(Test3)
self.menubar.setGeometry(QtCore.QRect(0, 0, 156, 25))
self.statusbar = QtGui.QStatusBar(Test3)


def retranslateUi(self, Test3):
    Test3.setWindowTitle(_translate("Test3", "MainWindow", None))

if name == "main":
import sys
app = QtGui.QApplication(sys.argv)
Test3 = QtGui.QMainWindow()
ui = Ui_Test3()


This comment has been minimized.

Copy link

commented Aug 6, 2014

Technically APSW is in the right. PEP 393 changed how the CPython API for strings worked so it could use different (and usually shorter) internal representations. A call to PyUnicode_READY is required to perform that internal work.

However PEP 393 guarantees 5 years of backwards compatibility. Other extensions that care about the internal representation should be calling PyUnicode_READY themselves to ensure the backwards compatibility on received strings, and PyQt has not done so. Strings coming from the core interpreter already have it, so the PyQt authors wouldn't have noticed.

APSW will do so itself at some point, but I need to do careful compatibility testing and benchmarking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.