changeset 5444:167f0d25ea8e

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.
author Joseph Myers <jsm@polyomino.org.uk>
date Wed, 25 Jul 2018 12:31:32 +0000
parents 447a7647f237
children 46317fe544ec
files roundup/backends/back_anydbm.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py	Wed Jul 25 12:30:25 2018 +0000
+++ b/roundup/backends/back_anydbm.py	Wed Jul 25 12:31:32 2018 +0000
@@ -25,6 +25,7 @@
 import os, marshal, re, weakref, string, copy, time, shutil, logging
 
 from roundup.anypy.dbm_ import anydbm, whichdb
+from roundup.anypy.strings import b2s
 
 from roundup import hyperdb, date, password, roundupdb, security, support
 from roundup.backends import locking
@@ -675,7 +676,7 @@
             db_type = self.determine_db_type(path)
             db = self.opendb(db_name, 'w')
 
-            for key in db.keys():
+            for key in map(b2s, db.keys()):
                 # get the journal for this db entry
                 journal = marshal.loads(db[key])
                 l = []
@@ -1659,7 +1660,7 @@
             db = self.db.getclassdb(self.classname)
             must_close = True
         try:
-            res.extend(db.keys())
+            res.extend(map(b2s, db.keys()))
 
             # remove the uncommitted, destroyed nodes
             if self.classname in self.db.destroyednodes:

Roundup Issue Tracker: http://roundup-tracker.org/