Skip to content

Commit

Permalink
Various small fixes suggested in review.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Fulton committed Jul 4, 2016
1 parent 0a2670a commit 7886065
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/ZODB/Connection.py
Expand Up @@ -794,7 +794,7 @@ def tpc_vote(self, transaction):
raise

if s:
if type(s[0]) is bytes:
if type(next(iter(s))) is bytes:
for oid in s:
self._handle_serial(oid)
return
Expand Down
4 changes: 2 additions & 2 deletions src/ZODB/DB.py
Expand Up @@ -1012,8 +1012,8 @@ def commit(self, transaction):
def tpc_vote(self, transaction):
result = self._storage.tpc_vote(transaction)
if result:
if isinstance(result[0], bytes):
self._oids.update(set(result))
if isinstance(next(iter(result)), bytes):
self._oids.update(result)
else:
for oid, _ in result:
self._oids.add(oid)
Expand Down
6 changes: 3 additions & 3 deletions src/ZODB/multicommitadapter.py
Expand Up @@ -11,7 +11,7 @@ def __init__(self, storage):
self._storage = storage
ifaces = zope.interface.providedBy(storage)
zope.interface.alsoProvides(self, ifaces)
self._resolved = set()
self._resolved = set() # {OID}, here to make linters happy

def __getattr__(self, name):
v = getattr(self._storage, name)
Expand Down Expand Up @@ -39,15 +39,15 @@ def storeBlob(self, oid, *args):
def undo(self, transaction_id, transaction):
r = self._storage.undo(transaction_id, transaction)
if r:
self._resolved.update(set(r[1]))
self._resolved.update(r[1])

def tpc_vote(self, *args):
s = self._storage.tpc_vote(*args)
for (oid, serial) in (s or ()):
if serial == ResolvedSerial:
self._resolved.add(oid)

return list(self._resolved)
return self._resolved

def tpc_finish(self, transaction, f=lambda tid: None):

Expand Down
2 changes: 1 addition & 1 deletion src/ZODB/tests/TransactionalUndoStorage.py
Expand Up @@ -113,7 +113,7 @@ def _begin_undos_vote(self, t, *tids):
oids.extend(undo_result[1])
v = self._storage.tpc_vote(t)
if v:
if isinstance(v[0], bytes):
if isinstance(next(iter(v)), bytes):
oids.extend(v)
else:
oids.extend(oid for (oid, _) in v)
Expand Down
5 changes: 0 additions & 5 deletions src/ZODB/tests/blob_transaction.txt
Expand Up @@ -411,11 +411,6 @@ Similarly, the new object wasn't added to the storage:
...
POSKeyError: 0x...

>>> blob_storage.loadBlob(blob._p_oid, s2)
Traceback (most recent call last):
...
POSKeyError: 'No blob file at <BLOB STORAGE PATH>'

.. clean up

>>> tm1.abort()
Expand Down

0 comments on commit 7886065

Please sign in to comment.