bpo-36232: Improve error message on dbm.open() when the db doesn't exist (GH-12060)

This commit is contained in:
Marco Rougeth 2019-04-30 00:23:28 +01:00 committed by Brett Cannon
parent 9bdd6d1c2a
commit 81c5a90595
3 changed files with 5 additions and 2 deletions

View File

@ -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")

View File

@ -0,0 +1,2 @@
Improve error message when trying to open existing DBM database that
actually doesn't exist. Patch by Marco Rougeth.