Skip to content

Commit 566f319

Browse files
committed
Python 3 preparation: convert dbm keys back from bytes to strings.
The Python 3 dbm module uses bytes for keys and values, converting any passed in strings to bytes and always returning bytes when keys are listed or values extracted. Bytes for values is fine with Roundup (which uses the marshal module to produce the values stored, which produces bytes anyway in Python 3), but bytes for keys need converting back to strings when keys are enumerated.
1 parent 39f1dfe commit 566f319

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

roundup/backends/back_anydbm.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import os, marshal, re, weakref, string, copy, time, shutil, logging
2626

2727
from roundup.anypy.dbm_ import anydbm, whichdb
28+
from roundup.anypy.strings import b2s
2829

2930
from roundup import hyperdb, date, password, roundupdb, security, support
3031
from roundup.backends import locking
@@ -675,7 +676,7 @@ def pack(self, pack_before):
675676
db_type = self.determine_db_type(path)
676677
db = self.opendb(db_name, 'w')
677678

678-
for key in db.keys():
679+
for key in map(b2s, db.keys()):
679680
# get the journal for this db entry
680681
journal = marshal.loads(db[key])
681682
l = []
@@ -1659,7 +1660,7 @@ def getnodeids(self, db=None, retired=None):
16591660
db = self.db.getclassdb(self.classname)
16601661
must_close = True
16611662
try:
1662-
res.extend(db.keys())
1663+
res.extend(map(b2s, db.keys()))
16631664

16641665
# remove the uncommitted, destroyed nodes
16651666
if self.classname in self.db.destroyednodes:

0 commit comments

Comments
 (0)