]> granicus.if.org Git - python/commitdiff
patch #766650 - whichdb not identifying dbm DBs when dbm linked with gdbm
authorAndrew MacIntyre <andymac@bullseye.apana.org.au>
Fri, 11 Jul 2003 12:16:48 +0000 (12:16 +0000)
committerAndrew MacIntyre <andymac@bullseye.apana.org.au>
Fri, 11 Jul 2003 12:16:48 +0000 (12:16 +0000)
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.

Lib/whichdb.py

index 6c4f61a019fe2420d7f80987cdce3bdacca92315..d60284e2e4ee528c167962fe7506bf988516c9b2 100644 (file)
@@ -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