Writing an Extension: 2 questions (so far)

Tyler W. Wilson tyler.w.wilson at gte.net
Thu Jan 3 11:07:47 EST 2002


I would expect _some_ kind of destructor-like facility at the
extension-level. In my case, I have to call some Windows init functions
(CoInitialize) on init, and then call the corresponding cleanup functions
(CoUninitialize). Should I:

1) Write the standard DLL entrypoint and handle cleanup there?

2) Add an explicit 'close' method on the module interface?

Thanks,
Tyler

"Steve Holden" <sholden at holdenweb.com> wrote in message
news:J9%Y7.64758$a56.28336 at atlpnn01.usenetserver.com...
> "Tyler W. Wilson" <tyler.w.wilson at gte.net> wrote in message
> news:WW_Y7.101$nu1.55992 at dfiatx1-snr1.gtei.net...
> > 1) I have the basic skeleton working for an extension. Now I want to
know
> on
> > the C side when the user does a del <module>. What entry in the
> PhMethodDef
> > structure should I add, or is there a global function that is called?
> >
> > I noticed that after I do import <module> then a del <module>, my DLL is
> > still in memory. Is this expected. I would have expected it to
> > reference-counted like everything else, and cleaned up when no longer
> used.
> >
> Only one answer: someone else can take care of the second question.
>
> Extension modules CANNOT be deleted or reloaded, so it isn't possible to
> reclaim the memory occupied by a shared library module containing such an
> extension (without terminating the interpreter, which limits you somewhat
> :-).
>
> Sorry.
>
> > 2) I am writing one function which takes a string, either multibyte or
> > Unicode. I want to call PyArg_ParseTuple once, and have it convert the
> > string passed into my desired output (n this case, Unicode). Some thing
> > like: ParseTuple(args, "u", &ustr); But it appears that the interpreter
> will
> > not automatically do this for, or is there a way?
> >
>
> regards
>  Steve
> --
> http://www.holdenweb.com/
>
>
>
>
>





More information about the Python-list mailing list