summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAndrew MacIntyre <andymac@bullseye.apana.org.au>2003-07-11 12:16:48 (GMT)
committerAndrew MacIntyre <andymac@bullseye.apana.org.au>2003-07-11 12:16:48 (GMT)
commita1e93e8dfc6daf78a8a46c41aca6e85cede74c02 (patch)
treec1c78af2a6e8f356aa3ed9510a7d13a02cd8b297 /Lib
parentc4bf893952743a89f078915583b29594690dfa12 (diff)
downloadcpython-a1e93e8dfc6daf78a8a46c41aca6e85cede74c02.zip
cpython-a1e93e8dfc6daf78a8a46c41aca6e85cede74c02.tar.gz
cpython-a1e93e8dfc6daf78a8a46c41aca6e85cede74c02.tar.bz2
patch #766650 - whichdb not identifying dbm DBs when dbm linked with gdbm
At this point, the problem appears particular to the OS/2 EMX port of gdbm (which is at v1.7.3) - this combination produces a .pag file but no .dir file. A more sophisticated patch which checks magic numbers when dbm.library indicates that dbm is linked to gdbm, and there is no .dir file, is still attached to the above patch entry for reconsideration after 2.3 is released. This checkin applies a workaround specific to the known failure case.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/whichdb.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/whichdb.py b/Lib/whichdb.py
index 6c4f61a..d60284e 100644
--- a/Lib/whichdb.py
+++ b/Lib/whichdb.py
@@ -2,6 +2,7 @@
import os
import struct
+import sys
try:
import dbm
@@ -29,8 +30,10 @@ def whichdb(filename):
try:
f = open(filename + os.extsep + "pag", "rb")
f.close()
- f = open(filename + os.extsep + "dir", "rb")
- f.close()
+ # dbm linked with gdbm on OS/2 doesn't have .dir file
+ if not (dbm.library == "GNU gdbm" and sys.platform == "os2emx"):
+ f = open(filename + os.extsep + "dir", "rb")
+ f.close()
return "dbm"
except IOError:
# some dbm emulations based on Berkeley DB generate a .db file