]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Deprecate bsddb for removal in Python 3.0.
authorBrett Cannon <bcannon@gmail.com>
Fri, 5 Sep 2008 18:33:51 +0000 (18:33 +0000)
committerBrett Cannon <bcannon@gmail.com>
Fri, 5 Sep 2008 18:33:51 +0000 (18:33 +0000)
Closes issue 3776.
Review by Nick Coghlan.

Doc/library/bsddb.rst
Doc/library/dbhash.rst
Lib/bsddb/__init__.py
Lib/dbhash.py
Lib/test/test_py3kwarn.py
Lib/test/test_warnings.py
Lib/warnings.py
Misc/NEWS

index ed45619847d556b598398cb8ee5f86a0aefc43ef..52ff38a04042118946fce5c3759ab863a02ce2b3 100644 (file)
@@ -6,6 +6,9 @@
    :synopsis: Interface to Berkeley DB database library
 .. sectionauthor:: Skip Montanaro <skip@pobox.com>
 
+.. deprecated:: 2.6
+    The :mod:`bsddb` module has been deprecated for removal in Python 3.0.
+
 
 The :mod:`bsddb` module provides an interface to the Berkeley DB library.  Users
 can create hash, btree or record based library files using the appropriate open
index bedfad4267212ae3b7d7a84e54ea7d4bcac8c9a8..6f9a24f52caded9228872cb414f62f940d31bdb5 100644 (file)
@@ -5,10 +5,8 @@
    :synopsis: DBM-style interface to the BSD database library.
 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
 
-.. note::
-   The :mod:`dbhash` module has been renamed to :mod:`dbm.bsd` in Python 3.0.
-   The :term:`2to3` tool will automatically adapt imports when converting your
-   sources to 3.0.
+.. deprecated:: 2.6
+    The :mod:`dbhash` module has been deprecated for removal in Python 3.0.
 
 .. index:: module: bsddb
 
index 0e5169cbc4fdd78a783c7adc6d51b10676a0f2ee..0af679f730ff19be931a0d94b49bf3e4dac3fc75 100644 (file)
@@ -42,6 +42,12 @@ instead.  It mirrors the Oracle Berkeley DB C API.
 import sys
 absolute_import = (sys.version_info[0] >= 3)
 
+if sys.py3kwarning:
+    import warnings
+    warnings.warnpy3k("in 3.x, bsddb has been removed; "
+                      "please use the pybsddb project instead",
+                      DeprecationWarning, 2)
+
 try:
     if __name__ == 'bsddb3':
         # import _pybsddb binary as it should be the more recent version from
index 9f8a9c3f28bb27e1d67a8bb8c3253feb31ecb894..5ca0bc1913af7741b245cd54bf4744198d40c7ef 100644 (file)
@@ -1,6 +1,9 @@
 """Provide a (g)dbm-compatible interface to bsddb.hashopen."""
 
 import sys
+if sys.py3kwarning:
+    import warnings
+    warnings.warnpy3k("in 3.x, dbhash has been removed", DeprecationWarning, 2)
 try:
     import bsddb
 except ImportError:
index 7bfe1e5be4ed12901593d6f4b75d530256c03ff2..780de740676e5e845c93599a36716f730cc9f0d2 100644 (file)
@@ -305,7 +305,7 @@ class TestStdlibRemovals(unittest.TestCase):
                            'sunos5' : ('sunaudiodev', 'SUNAUDIODEV'),
                           }
     optional_modules = ('bsddb185', 'Canvas', 'dl', 'linuxaudiodev', 'imageop',
-                        'sv', 'cPickle')
+                        'sv', 'cPickle', 'bsddb', 'dbhash')
 
     def check_removal(self, module_name, optional=False):
         """Make sure the specified module, when imported, raises a
index 1520bf2b350a95ecef01d1ca75f6dbe10d08b399..9980f2497d66bb804d6040342c281c24eb36e013 100644 (file)
@@ -508,6 +508,7 @@ class CatchWarningTests(BaseTest):
         wmod = self.module
         with wmod.catch_warnings(module=wmod, record=True) as w:
             self.assertEqual(w, [])
+            self.assertRaises(AttributeError, getattr, w, 'message')
             wmod.simplefilter("always")
             wmod.warn("foo")
             self.assertEqual(str(w.message), "foo")
index b699c439cf7c972ab1e0fca78aa992c10fa38bff..9ec04be274b97fc9d7cb87921e182152bf5bfe1d 100644 (file)
@@ -314,7 +314,14 @@ class WarningsRecorder(list):
         self.append(WarningMessage(*args, **kwargs))
 
     def __getattr__(self, attr):
-        return getattr(self[-1], attr)
+        """Return attributes from the last caught warning, or raise
+        AttributeError."""
+        try:
+            return getattr(self[-1], attr)
+        except IndexError:
+            raise AttributeError("no recorded warning to read "
+                                    "{0!r} attribute from".format(attr))
+
 
     def reset(self):
         del self[:]
index dd703ee3a13a0fd533732de28c8fea11b463e01a..8c246538a8274cd7ce30fe57cae7e28827f77466 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -56,6 +56,8 @@ C-API
 Library
 -------
 
+- Issue 3776: Deprecate the bsddb package for removal in 3.0.
+
 - Issue #3762: platform.architecture() fails if python is lanched via
   its symbolic link.