win32 python as a dll?

Scott Wolford wolford at enews.nrl.navy.mil
Thu Jul 8 11:01:31 EDT 1999


Here's the smallest case that gives me problems:
#include "Python.h"
#include <stdio.h>
int main(int argc, char **argv)
{
//  return Py_Main(argc, argv);
  FILE *file = fopen(argv[0], "rt");
  PyRun_AnyFile(file, argv[0]);
}

I just modified python.c to run the script like I do in my application. I
get the following error:
Fatal Python error: PyThreadState_Get: no current thread

The Py_Main line works fine. Any takers?

Thanks in advance,
Scott

Gordon McMillan wrote:

> Scott Wolford writes:
>
> > Now I'm a little confused.
>
> I was trying to figure out how to tell you that politely...

Thanks for doing so.

> > Python does seem to be a dll (?); I found
> > python15.dll in winnt/system32 directory.
>
> Correct. That's 99.999+% of python. python.exe does nothing but load
> it and call Py_Main.

I knew that; brain fart. I've written my own makefile for python and my
application works fine when I build it myself.

> > But I can't find
> > python15_d.dll anywhere. Was that supposed to be installed?
>
> Nope, you have to build it.
>
> > I think
> > python15.dll bombs because it was compiled as optimized using the M$
> > compiler and that optimizer has problems (at least w/ O2; I've been
> > pretty successfull w/ O1).
>
> Probably not. It's been pretty thoroughly tested at this point.

I agree, but in the *normal* fashion.

> > So I want to use python15_d but I can't
> > find the dll.
> >
> > Any help would be appreciated,
>
> Probably the most common mistake of Windows embedders is to link to
> the wrong C runtime lib. Python uses Multithreaded DLL.

Nope, I use msvcrt and msvcrtd. You say Multithreaded *DLL* so that's what
you mean (and not libcmt.lib), right?

> But you might have done something more creative. Telling us how and
> when it bombs complete with messages and as small a code sample as
> possible will get you more and better answers.

see top of post.

> - Gordon





More information about the Python-list mailing list