[python-win32] gencache module and read-only access to python dir

Ross McKerchar it at crummock.com
Mon Jun 18 10:58:31 CEST 2007


I've noticed that the GetModuleForTypelib always (or at least once per 
program-run) calls AddModuleToCache (both in win32com.client.gencache).

This results in an attempt to write to the pickled dictionary 
gen_py/dicts.dat. Unfortunately the program I'm writing that uses 
GetModuleForLib is run by users who dont have write access to the Python 
directory. I've ensured early binding for the type library I'm 
interested in by setting it up in the application installer, so from my 
limited understanding of win32com dicts.dat cache should already contain 
my module.

My program appears to run fine as a normal user with a nasty hack 
("win32com.client.gencache.AddModuleToCache.func_defaults=(1,False)") 
that prevents the cache getting written to.

So, I'd be grateful of anyone with a more solid understanding than me could
a) Confirm that disabling the dicts.dat cache write will work fine and 
not break randomly in the future
b) Let me know if there's a more robust way of preventing the cache 
write (there appears to be code supporting freezing functionality that 
should help but I couldn't figure out a neat way of using it)

Many thanks again.

-ross



More information about the Python-win32 mailing list