Update of /cvsroot/pywin32/pywin32/com/win32com/client
In directory sc8-pr-cvs1:/tmp/cvs-serv5082
Modified Files:
gencache.py
Log Message:
Fix a subtle bug that only showed up in the test suite. Consider:
* Process A starts, with empty gencache
* Process A starts process B
* Process B creates gencache module for tlb and exits
* Process A tries to import gencache module for tlb. Now the module
exists, but Process A has never seen it.
Index: gencache.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/gencache.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** gencache.py 31 Oct 2003 03:04:02 -0000 1.23
--- gencache.py 2 Nov 2003 10:08:20 -0000 1.24
***************
*** 77,83 ****
zip_path = win32com.__gen_path__[zip_pos+5:]
zip_path = os.path.join(zip_path, "dicts.dat").replace("\\", "/")
! zf = zipfile.ZipFile(zip_file)
! f = cStringIO.StringIO(zf.read(zip_path))
! zf.close()
else:
# NOTE: IOError on file open must be caught by caller.
--- 77,97 ----
zip_path = win32com.__gen_path__[zip_pos+5:]
zip_path = os.path.join(zip_path, "dicts.dat").replace("\\", "/")
! try:
! zf = zipfile.ZipFile(zip_file)
! f = cStringIO.StringIO(zf.read(zip_path))
! zf.close()
! except IOError:
! # Our gencache is in a .zip file (and almost certainly readonly)
! # but no dicts file. That actually needn't be fatal for a frozen
! # application. Assuming they call "EnsureModule" with the same
! # typelib IDs they have been frozen with, that EnsureModule will
! # correctly re-build the dicts on the fly. However, objects that
! # rely on the gencache but have not done an EnsureModule will
! # fail (but their apps are likely to fail running from source
! # with a clean gencache anyway, as then they would be getting
! # Dynamic objects until the cache is built - so the best answer
! # for these apps is to call EnsureModule, rather than freezing
! # the dict)
! return
else:
# NOTE: IOError on file open must be caught by caller.
***************
*** 234,238 ****
"""
modName = GetGeneratedFileName(typelibCLSID, lcid, major, minor)
! return _GetModule(modName)
def MakeModuleForTypelib(typelibCLSID, lcid, major, minor, progressInstance = None, bGUIProgress = None, bForDemand = bForDemandDefault, bBuildHidden = 1):
--- 248,258 ----
"""
modName = GetGeneratedFileName(typelibCLSID, lcid, major, minor)
! mod = _GetModule(modName)
! # If the import worked, it doesn't mean we have actually added this
! # module to our cache though - check that here.
! if not mod.__dict__.has_key("_in_gencache_"):
! AddModuleToCache(typelibCLSID, lcid, major, minor)
! assert mod.__dict__.has_key("_in_gencache_")
! return mod
def MakeModuleForTypelib(typelibCLSID, lcid, major, minor, progressInstance = None, bGUIProgress = None, bForDemand = bForDemandDefault, bBuildHidden = 1):
***************
*** 516,519 ****
--- 536,542 ----
fname = GetGeneratedFileName(typelibclsid, lcid, major, minor)
mod = _GetModule(fname)
+ assert not mod.__dict__.has_key("_in_gencache_"), \
+ "This module has already been processed by this process"
+ mod._in_gencache_ = 1
dict = mod.CLSIDToClassMap
info = str(typelibclsid), lcid, major, minor
***************
*** 657,662 ****
if opt=='-q':
verbose = 0
-
- #if __name__=='__main__':
- # print "Rebuilding cache..."
- # Rebuild(1)
\ No newline at end of file
--- 680,681 ----
|