Page 1 of 1

What's __init__.py?

Posted: Sun Sep 21, 2008 9:54 pm
by chuck_starchaser
Gorbalad, at the PU forum, is reporting random crashes. Part of his stderr.txt reports,

Code: Select all

 Next To: Gemini/Freyjadot -0.000490warning: Not importing directory 'E:\Spiele\PU\bases\fixers': missing __init__.py
Asking to undock
Destruct called. If called from C++ this is death 201053840 (0xbfbd690)BASE Destruct called. If called from C++ this is death 201053840 (0xbfbd690)dot 0.561228Assumed exit on unit LOAD_FAILED(if not quitting, report error)
Assumed exit on unit tungsten(if not quitting, report error)
Now, I think I remember seeing an __init__.py, somewere, some time, long ago. But now a search returns nothing.
Morover, I did a search of *.py files containing text "__init__" and that search comes empty as well.
Is __init__.py being called from code?

Posted: Mon Sep 22, 2008 12:31 am
by ace123
__init__.py is what python looks for when you ask it to import an entire directory.
I believe python is getting confused between "fixers.py" and the "fixers" directory

Posted: Mon Sep 22, 2008 2:15 am
by chuck_starchaser
Thanks! I thought I'd search for some .py file with a statement "import ...fixers" and change it to "import ...fixers.py",
but I searched through trunk for .py files containing the word "fixers" and the only one is fixers.py :-/
(Unless it's windows' search tool acting up again...)

Posted: Mon Sep 29, 2008 11:31 am
by ace123
Yes, a lot of files contain "import fixers" or "from fixers import ..."
so it is windows acting up.

As to the __init__.py thing, if you look closely, it says "warning", not "error". So python is just making sure that we want the file to be imported and not the directory of the same name.

Unfortunately, the logs linked to in:
http://wcjunction.com/phpBB2/viewtopic. ... 3929#13929
do not seem to say anything useful about the reason for the crash.

We can try to pounce on a few things like __init__ or the load failed, but I don't think either of them caused the actual crash.

Posted: Tue Sep 30, 2008 10:26 pm
by chuck_starchaser
Thanks!