What's __init__.py?

This is the location for all mods to collaborate. Anyone making or planning their own mod should post help requests, screen shots and news here.

Moderators: Omega, tillias, Mod Contributor

Post Reply
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

What's __init__.py?

Post 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?
ace123
Lead Network Developer
Lead Network Developer
Posts: 2560
Joined: Sun Jan 12, 2003 9:13 am
Location: Palo Alto CA
Contact:

Post 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
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post 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...)
ace123
Lead Network Developer
Lead Network Developer
Posts: 2560
Joined: Sun Jan 12, 2003 9:13 am
Location: Palo Alto CA
Contact:

Post 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.
Post Reply