]> granicus.if.org Git - python/commitdiff
bpo-36232: Improve error message on dbm.open() when the db doesn't exist (GH-12060)
authorMarco Rougeth <marco@rougeth.com>
Mon, 29 Apr 2019 23:23:28 +0000 (00:23 +0100)
committerBrett Cannon <54418+brettcannon@users.noreply.github.com>
Mon, 29 Apr 2019 23:23:28 +0000 (16:23 -0700)
Lib/dbm/__init__.py
Misc/NEWS.d/next/Library/2019-03-20-15-13-18.bpo-36366.n0eav_.rst
Misc/NEWS.d/next/Library/2019-04-06-20-25-25.bpo-36232.SClmhb.rst [new file with mode: 0644]

index 6831a844073740d93db8c19ae1bc9a9b57625445..f65da521af4da8d8e98236e0f5b22e3053abd559 100644 (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")
index a43504839c6fffc9533751e164f74324135f981d..8d1f9d940cc61c2e41c6df6901fc295e5ae695aa 100644 (file)
@@ -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 (file)
index 0000000..25290be
--- /dev/null
@@ -0,0 +1,2 @@
+Improve error message when trying to open existing DBM database that
+actually doesn't exist. Patch by Marco Rougeth.