Mercurial > cpython-lru_cache-weakref
annotate Lib/dbhash.py @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | a6f8b2fa2e20 |
| children | 4c139168648c |
| rev | line source |
|---|---|
|
3357
1a17ba50bd68
backward compatible interface for bsddb
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 """Provide a (g)dbm-compatible interface to bsdhash.hashopen.""" |
|
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 |
|
c41dd2204b9c
fail more completely by deleting dbhash from sys.modules if bsddb can't be
Skip Montanaro <skip@pobox.com>
parents:
16070
diff
changeset
|
4 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
|
5 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
|
6 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
|
7 # 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
|
8 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
|
9 raise |
|
3357
1a17ba50bd68
backward compatible interface for bsddb
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 |
|
16070
b5345e99596b
added __all__ lists to a number of Python modules
Skip Montanaro <skip@pobox.com>
parents:
10821
diff
changeset
|
11 __all__ = ["error","open"] |
|
b5345e99596b
added __all__ lists to a number of Python modules
Skip Montanaro <skip@pobox.com>
parents:
10821
diff
changeset
|
12 |
|
10821
d3c6e9a126b2
Clarify why we define error. Suggested by Andrew Dalke.
Guido van Rossum <guido@python.org>
parents:
8624
diff
changeset
|
13 error = bsddb.error # Exported for anydbm |
|
3357
1a17ba50bd68
backward compatible interface for bsddb
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 |
|
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
|
15 def open(file, flag = 'r', mode=0666): |
|
3357
1a17ba50bd68
backward compatible interface for bsddb
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 return bsddb.hashopen(file, flag, mode) |
