Skip to content

Commit 0549edd

Browse files
committed
Fixes
- Qt six import was broken - variable in Qt support interface rename incomplete - objectProcessor wasn't handling memoryview correctly
1 parent 8a3f1e5 commit 0549edd

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

src/bitmessageqt/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@
5656
import bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import
5757
import helper_sent
5858

59-
from six.moves import iteritems, itervalues, range as xrange
60-
from six import text_type
59+
from six import iteritems, itervalues, text_type
6160

6261
try:
6362
from plugins.plugin import get_plugin, get_plugins

src/bitmessageqt/support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def createSupportMessage(myapp):
141141
if paths.frozen:
142142
frozen = paths.frozen
143143
portablemode = "True" if state.appdata == paths.lookupExeFolder() else "False"
144-
cpow = "True" if proofofwork.bmpow else "False"
144+
cpow = "True" if proofofwork.BMPOW else "False"
145145
openclpow = str(
146146
config.safeGet('bitmessagesettings', 'opencl')
147147
) if openclEnabled() else "None"

src/class_objectProcessor.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,19 @@ def checkackdata(data):
141141
# bypass nonce and time, retain object type/version/stream + body
142142
readPosition = 16
143143

144-
if data[readPosition:] in state.ackdataForWhichImWatching:
144+
# data may be a memoryview, which is not hashable and thus
145+
# cannot be used as a dictionary key; convert the slice to bytes.
146+
ackcheckdata = bytes(data[readPosition:])
147+
148+
if ackcheckdata in state.ackdataForWhichImWatching:
145149
logger.info('This object is an acknowledgement bound for me.')
146-
del state.ackdataForWhichImWatching[data[readPosition:]]
150+
del state.ackdataForWhichImWatching[ackcheckdata]
147151
sqlExecute(
148152
"UPDATE sent SET status='ackreceived', lastactiontime=?"
149-
" WHERE ackdata=?", int(time.time()), data[readPosition:])
153+
" WHERE ackdata=?", int(time.time()), ackcheckdata)
150154
queues.UISignalQueue.put((
151155
'updateSentItemStatusByAckdata', (
152-
data[readPosition:],
156+
ackcheckdata,
153157
_translate(
154158
"MainWindow",
155159
"Acknowledgement of the message received %1"
@@ -208,7 +212,9 @@ def processgetpubkey(data):
208212

209213
myAddress = ''
210214
if requestedAddressVersionNumber <= 3:
211-
requestedHash = data[readPosition:readPosition + 20]
215+
# data may be a memoryview; convert slices to bytes so they
216+
# are hashable and can be used as dictionary keys.
217+
requestedHash = bytes(data[readPosition:readPosition + 20])
212218
if len(requestedHash) != 20:
213219
return logger.debug(
214220
'The length of the requested hash is not 20 bytes.'
@@ -220,7 +226,8 @@ def processgetpubkey(data):
220226
if requestedHash in shared.myAddressesByHash:
221227
myAddress = shared.myAddressesByHash[requestedHash]
222228
elif requestedAddressVersionNumber >= 4:
223-
requestedTag = data[readPosition:readPosition + 32]
229+
# data may be a memoryview; convert to bytes for hashability.
230+
requestedTag = bytes(data[readPosition:readPosition + 32])
224231
if len(requestedTag) != 32:
225232
return logger.debug(
226233
'The length of the requested tag is not 32 bytes.'
@@ -413,7 +420,8 @@ def processpubkey(self, data):
413420
'(within processpubkey) payloadLength less than 350.'
414421
' Sanity check failed.')
415422

416-
tag = data[readPosition:readPosition + 32]
423+
# data may be a memoryview; convert to bytes for hashability.
424+
tag = bytes(data[readPosition:readPosition + 32])
417425
if tag not in state.neededPubkeys:
418426
return logger.info(
419427
'We don\'t need this v4 pubkey. We didn\'t ask for it.')

0 commit comments

Comments
 (0)