Skip to content

Commit a1e93e8

Browse files
author
Andrew MacIntyre
committed
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.
1 parent c4bf893 commit a1e93e8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Lib/whichdb.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
import struct
5+
import sys
56

67
try:
78
import dbm
@@ -29,8 +30,10 @@ def whichdb(filename):
2930
try:
3031
f = open(filename + os.extsep + "pag", "rb")
3132
f.close()
32-
f = open(filename + os.extsep + "dir", "rb")
33-
f.close()
33+
# dbm linked with gdbm on OS/2 doesn't have .dir file
34+
if not (dbm.library == "GNU gdbm" and sys.platform == "os2emx"):
35+
f = open(filename + os.extsep + "dir", "rb")
36+
f.close()
3437
return "dbm"
3538
except IOError:
3639
# some dbm emulations based on Berkeley DB generate a .db file

0 commit comments

Comments
 (0)