Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(7)

Unified Diff: Lib/dbm/dumb.py

Issue 19385: dbm.dumb should be consistent when the database is closed
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/dbm/dumb.py Sun May 25 13:04:13 2014 +0300
+++ b/Lib/dbm/dumb.py Sun May 25 14:21:18 2014 +0300
@@ -216,8 +216,10 @@
self._commit()
def keys(self):
- self._verify_open()
- return list(self._index.keys())
+ try:
+ return list(self._index)
+ except TypeError:
+ raise error('DBM object has already been closed') from None
def items(self):
self._verify_open()
@@ -226,17 +228,26 @@
def __contains__(self, key):
if isinstance(key, str):
key = key.encode('utf-8')
- self._verify_open()
- return key in self._index
+ try:
+ return key in self._index
+ except TypeError:
+ if self._index is None:
+ raise error('DBM object has already been closed') from None
+ else:
+ raise
def iterkeys(self):
- self._verify_open()
- return iter(self._index.keys())
+ try:
+ return iter(self._index)
+ except TypeError:
+ raise error('DBM object has already been closed') from None
__iter__ = iterkeys
def __len__(self):
- self._verify_open()
- return len(self._index)
+ try:
+ return len(self._index)
+ except TypeError:
+ raise error('DBM object has already been closed') from None
def close(self):
self._commit()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+