Skip to content

Commit

Permalink
bpo-36232: Improve error message on dbm.open() when the db doesn't ex…
Browse files Browse the repository at this point in the history
…ist (GH-12060)
  • Loading branch information
rougeth authored and brettcannon committed Apr 29, 2019
1 parent 9bdd6d1 commit 81c5a90
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Lib/dbm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def open(file, flag='r', mode=0o666):
# file doesn't exist and the new flag was used so use default type
mod = _defaultmod
else:
raise error[0]("need 'c' or 'n' flag to open new db")
raise error[0]("db file doesn't exist; "
"use 'c' or 'n' flag to create a new db")
elif result == "":
# db type cannot be determined
raise error[0]("db type could not be determined")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Calling ``stop()`` on an unstarted or stopped :func:`unittest.mock.patch`
object will now return `None` instead of raising :exc:`RuntimeError`,
making the method idempotent.
Patch byKarthikeyan Singaravelan.
Patch by Karthikeyan Singaravelan.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Improve error message when trying to open existing DBM database that
actually doesn't exist. Patch by Marco Rougeth.

0 comments on commit 81c5a90

Please sign in to comment.