# License: GPL2
# $Id$
-anydbm_module = __import__("anydbm")
+try:
+ anydbm_module = __import__("anydbm")
+except ImportError:
+ # python 3.x
+ import dbm as anydbm_module
try:
import cPickle as pickle
except ImportError:
self._db_path = os.path.join(self.location, fs_template.gen_label(self.location, self.label)+default_db)
self.__db = None
try:
- self.__db = anydbm_module.open(
- _unicode_encode(self._db_path), 'w', self._perms)
+ # dbm.open() will not work with bytes in python-3.1:
+ # TypeError: can't concat bytes to str
+ self.__db = anydbm_module.open(self._db_path,
+ 'w', self._perms)
except anydbm_module.error:
# XXX handle this at some point
try:
# try again if failed
try:
if self.__db == None:
- self.__db = anydbm_module.open(
- _unicode_encode(self._db_path), 'c', self._perms)
+ # dbm.open() will not work with bytes in python-3.1:
+ # TypeError: can't concat bytes to str
+ self.__db = anydbm_module.open(self._db_path,
+ 'c', self._perms)
except anydbm_module.error as e:
raise cache_errors.InitializationError(self.__class__, e)
self._ensure_access(self._db_path)