[Python-checkins] python/dist/src/Lib whichdb.py,1.16,1.17

aimacintyre@users.sourceforge.net aimacintyre@users.sourceforge.net
Fri, 11 Jul 2003 05:16:50 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv4332

Modified Files:
	whichdb.py 
Log Message:
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.


Index: whichdb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/whichdb.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** whichdb.py	21 Jun 2003 13:54:55 -0000	1.16
--- whichdb.py	11 Jul 2003 12:16:48 -0000	1.17
***************
*** 3,6 ****
--- 3,7 ----
  import os
  import struct
+ import sys
  
  try:
***************
*** 30,35 ****
          f = open(filename + os.extsep + "pag", "rb")
          f.close()
!         f = open(filename + os.extsep + "dir", "rb")
!         f.close()
          return "dbm"
      except IOError:
--- 31,38 ----
          f = open(filename + os.extsep + "pag", "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: