annotate Lib/dbhash.py @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents 39efd3fc59ef
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28977
Skip Montanaro <skip@pobox.com>
parents: 18038
diff changeset
1 """Provide a (g)dbm-compatible interface to bsddb.hashopen."""
3357
1a17ba50bd68 backward compatible interface for bsddb
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
16246
c41dd2204b9c fail more completely by deleting dbhash from sys.modules if bsddb can't be
Skip Montanaro <skip@pobox.com>
parents: 16070
diff changeset
3 import sys
60257
Benjamin Peterson <benjamin@python.org>
parents: 63528
diff changeset
4 import warnings
60262
39efd3fc59ef spelling
Benjamin Peterson <benjamin@python.org>
parents: 60259
diff changeset
5 warnings.warnpy3k("in 3.x, the dbhash module has been removed", stacklevel=2)
16246
c41dd2204b9c fail more completely by deleting dbhash from sys.modules if bsddb can't be
Skip Montanaro <skip@pobox.com>
parents: 16070
diff changeset
6 try:
c41dd2204b9c fail more completely by deleting dbhash from sys.modules if bsddb can't be
Skip Montanaro <skip@pobox.com>
parents: 16070
diff changeset
7 import bsddb
c41dd2204b9c fail more completely by deleting dbhash from sys.modules if bsddb can't be
Skip Montanaro <skip@pobox.com>
parents: 16070
diff changeset
8 except ImportError:
c41dd2204b9c fail more completely by deleting dbhash from sys.modules if bsddb can't be
Skip Montanaro <skip@pobox.com>
parents: 16070
diff changeset
9 # prevent a second import of this module from spuriously succeeding
c41dd2204b9c fail more completely by deleting dbhash from sys.modules if bsddb can't be
Skip Montanaro <skip@pobox.com>
parents: 16070
diff changeset
10 del sys.modules[__name__]
c41dd2204b9c fail more completely by deleting dbhash from sys.modules if bsddb can't be
Skip Montanaro <skip@pobox.com>
parents: 16070
diff changeset
11 raise
3357
1a17ba50bd68 backward compatible interface for bsddb
Guido van Rossum <guido@python.org>
parents:
diff changeset
12
16070
b5345e99596b added __all__ lists to a number of Python modules
Skip Montanaro <skip@pobox.com>
parents: 10821
diff changeset
13 __all__ = ["error","open"]
b5345e99596b added __all__ lists to a number of Python modules
Skip Montanaro <skip@pobox.com>
parents: 10821
diff changeset
14
10821
d3c6e9a126b2 Clarify why we define error. Suggested by Andrew Dalke.
Guido van Rossum <guido@python.org>
parents: 8624
diff changeset
15 error = bsddb.error # Exported for anydbm
3357
1a17ba50bd68 backward compatible interface for bsddb
Guido van Rossum <guido@python.org>
parents:
diff changeset
16
18038
a6f8b2fa2e20 Fix bug #422702: Make flag argument to open optional, and document it that way.
Martin v. Löwis <martin@v.loewis.de>
parents: 16246
diff changeset
17 def open(file, flag = 'r', mode=0666):
3357
1a17ba50bd68 backward compatible interface for bsddb
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 return bsddb.hashopen(file, flag, mode)