Runnable with both Python3 and Python2, with both PyQt5 and PyQt4 by using Qt.py #2250
|
@ -19,6 +19,8 @@ import six
|
||||||
from six.moves import range as xrange
|
from six.moves import range as xrange
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
from codecs import escape_decode
|
from codecs import escape_decode
|
||||||
|
if six.PY2:
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
from unqstr import ustr, unic
|
from unqstr import ustr, unic
|
||||||
from dbcompat import dbstr
|
from dbcompat import dbstr
|
||||||
|
@ -2927,6 +2929,14 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
return
|
return
|
||||||
queryreturn = sqlQuery(
|
queryreturn = sqlQuery(
|
||||||
'SELECT message FROM inbox WHERE msgid=?', msgid)
|
'SELECT message FROM inbox WHERE msgid=?', msgid)
|
||||||
|
# for compatibility
|
||||||
|
if len(queryreturn) < 1:
|
||||||
|
if six.PY3:
|
||||||
|
queryreturn = sqlQuery(
|
||||||
|
'SELECT message FROM inbox WHERE msgid=CAST(? AS TEXT)', msgid)
|
||||||
|
else: # assume six.PY2
|
||||||
|
queryreturn = sqlQuery(
|
||||||
|
'SELECT message FROM inbox WHERE msgid=?', sqlite3.Binary(msgid))
|
||||||
try:
|
try:
|
||||||
lines_raw = queryreturn[-1][0].split('\n')
|
lines_raw = queryreturn[-1][0].split('\n')
|
||||||
lines = []
|
lines = []
|
||||||
|
@ -4154,6 +4164,22 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
else ('inbox', 'msgid')
|
else ('inbox', 'msgid')
|
||||||
), msgid
|
), msgid
|
||||||
)
|
)
|
||||||
|
# for compatibility
|
||||||
|
if len(queryreturn) < 1:
|
||||||
|
if six.PY3:
|
||||||
|
queryreturn = sqlQuery(
|
||||||
|
'SELECT message FROM %s WHERE %s=CAST(? AS TEXT)' % (
|
||||||
|
('sent', 'ackdata') if folder == 'sent'
|
||||||
|
else ('inbox', 'msgid')
|
||||||
|
), msgid
|
||||||
|
)
|
||||||
|
else: # assume six.PY2
|
||||||
|
queryreturn = sqlQuery(
|
||||||
|
'SELECT message FROM %s WHERE %s=?' % (
|
||||||
|
('sent', 'ackdata') if folder == 'sent'
|
||||||
|
else ('inbox', 'msgid')
|
||||||
|
), sqlite3.Binary(msgid)
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
message = queryreturn[-1][0].decode("utf-8", "replace")
|
message = queryreturn[-1][0].decode("utf-8", "replace")
|
||||||
|
|
Reference in New Issue
Block a user