Problem with win32com

didier.rano didier.rano at wanadoo.fr
Thu Aug 10 17:19:44 EDT 2000


1. I had already test with dbEngine in global variable, and it is the same
problem...
2. Python haven't garbage collector, only a reference counter.

It is possible that object is reference one more time when variable database
is reused after "return", and this new reference cannot be used correctly ?

Bug ?

"Alex Martelli" <alex at magenta.com> a écrit dans le message news:
8mv1t00m3a at news1.newsguy.com...
> "didier.rano" <didier.rano at wanadoo.fr> wrote in message
> news:8muoq0$pi4$1 at wanadoo.fr...
> > Hello,
> >
> > I have a problem with win32com.
> >
> > This example is ok :
> >
> > from win32com.client import Dispatch
> > dbEngine = Dispatch( "DAO.DBEngine")
> >
> > database = dbEngine.OpenDatabase( "c:\temp\essai.mdb")
> > defs = database.TableDefs
> >
> > But, this other example is not ok:
> >
> > def fct():
> >   from win32com.client import Dispatch
> >   dbEngine = Dispatch( "DAO.DBEngine")
> >
> >   database = dbEngine.OpenDatabase( "c:\temp\essai.mdb")
> >   return database
> >
> > database = fct()
> > defs = database.TableDefs
>
> I don't know enough DAO to be sure, but a problem could
> be that in the second case, dbEngine being a local
> variable, it will have been garbage-collected and
> deallocated right after fct returns.  Don't know if
> this IS a problem (it shouldn't be, if DAO is a well
> designed COM Object-Model... but don't take the fact
> that it's Microsoft-designed as proof it's good COM!-);
> but it's the only substantial difference I can see
> off-hand between the two cases.
>
> Adding a 'global dbEngine' as the first statement in
> fct would remove this semantic difference; try that --
> it will help your diagnosis to see if it makes the
> problem go away, or not...
>
>
> Alex
>
>
>





More information about the Python-list mailing list