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

Brett Cannon webhook-mailer at python.org
Mon Apr 29 19:23:32 EDT 2019


https://github.com/python/cpython/commit/81c5a905951aaf46f292eb459c32649c0b74ef61
commit: 81c5a905951aaf46f292eb459c32649c0b74ef61
branch: master
author: Marco Rougeth <marco at rougeth.com>
committer: Brett Cannon <54418+brettcannon at users.noreply.github.com>
date: 2019-04-29T16:23:28-07:00
summary:

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

files:
A Misc/NEWS.d/next/Library/2019-04-06-20-25-25.bpo-36232.SClmhb.rst
M Lib/dbm/__init__.py
M Misc/NEWS.d/next/Library/2019-03-20-15-13-18.bpo-36366.n0eav_.rst

diff --git a/Lib/dbm/__init__.py b/Lib/dbm/__init__.py
index 6831a8440737..f65da521af4d 100644
--- a/Lib/dbm/__init__.py
+++ b/Lib/dbm/__init__.py
@@ -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")
diff --git a/Misc/NEWS.d/next/Library/2019-03-20-15-13-18.bpo-36366.n0eav_.rst b/Misc/NEWS.d/next/Library/2019-03-20-15-13-18.bpo-36366.n0eav_.rst
index a43504839c6f..8d1f9d940cc6 100644
--- a/Misc/NEWS.d/next/Library/2019-03-20-15-13-18.bpo-36366.n0eav_.rst
+++ b/Misc/NEWS.d/next/Library/2019-03-20-15-13-18.bpo-36366.n0eav_.rst
@@ -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.
diff --git a/Misc/NEWS.d/next/Library/2019-04-06-20-25-25.bpo-36232.SClmhb.rst b/Misc/NEWS.d/next/Library/2019-04-06-20-25-25.bpo-36232.SClmhb.rst
new file mode 100644
index 000000000000..25290be7c9c5
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-04-06-20-25-25.bpo-36232.SClmhb.rst
@@ -0,0 +1,2 @@
+Improve error message when trying to open existing DBM database that
+actually doesn't exist. Patch by Marco Rougeth.



More information about the Python-checkins mailing list