Don't go through loop if not Python 3; fixed typo

This commit is contained in:
Doug Blank 2013-12-23 15:19:18 -05:00
parent 6e325a9190
commit a72c6eac96

View File

@ -1281,11 +1281,12 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
""" """
if isinstance(key, tuple): if isinstance(key, tuple):
#create a byte string key, first validity check in python 3! #create a byte string key, first validity check in python 3!
for val in key: if sys.version_info[0] >= 3:
if sys.version_info[0] >= 3 and isinstance(val, bytes): for val in key:
raise DbError(_('An attempt is made to safe a reference key ' if isinstance(val, bytes):
'which is partly bytecode, this is not allowed.\n' raise DbError(_('An attempt is made to save a reference key '
'Key is %s') % str(key)) 'which is partly bytecode, this is not allowed.\n'
'Key is %s') % str(key))
key = str(key) key = str(key)
if isinstance(key, UNITYPE): if isinstance(key, UNITYPE):
key = key.encode('utf-8') key = key.encode('utf-8')