BugInit error

Joined
Jul 5, 2004
Messages
23,562
Location
Canberra, Australia
I am getting the following error in PythonErr.log.

Code:
Traceback (most recent call last):
  File "BugInit", line 93, in callInits
  File "UnitUtil", line 72, in init
AttributeError: 'NoneType' object has no attribute 'getDescription'

It is the last one, I hope. Where do I look to find out what I have done wrong?
 
If you have modded your python, look on line 72 of UnitUtil.py Specifically you are calling getDescription on an object that is returning NoneType, and thus using the call getDescription makes no sense to do on it. If you posted the block of code around line 72 of UnitUtil.py I, or someone else could probably comment farther.
 
Well I am assuming you're using RoM as a base, and possibly one of the mod mods for RoM. It's likely that one of these has altered that file. Compare what you have to a clean install of the BUG mod.
 
Unfortunately the UnitUtil.py is identical in both BUG 4.3 and RoM and my version. I am trying to get a new mod working and I always start off with a clean base version, in this case RoM. The error only started to appear after I added the last three units which is probably why I thought that the error was to do with data not python when I posted.
 
Just did a test by getting rid of the last two units (in XML) the python error goes away! I'm not hitting a limit am I? Is there somewhere else that a debug message would be printed so I may be able to tell which of the two units is causing the problem?
 
Well, like I said originally, posting the code around line 72 of UnitUtil might give better insight into the problem. However, keep in mind RoM adds an extreme amount of content; it has like 10x the normal techs and units, and adds in a myriad of python modcomps; it's far too divergent from BtS for me to really have any clue what could be going on. Your best bet is to look at line 72 of UnitUtil and try to figure out why NoneType is being passed into a function where it should not be. Also it wouldn't hurt to ask Afforess for help, he probably has the most experience debugging RoM of anyone else on the forums.
 
That part of UnitUtil is grabbing the descriptions of every generic unit for each unit class. So I bet you have a unit class that has a NONE generic unit type.

Code:
eGenericUnit = classInfo.getDefaultUnitIndex()
...
gc.getUnitInfo(eGenericUnit).getDescription()  # line 72

I can fix BUG to ignore these unit classes, but I think other parts of BTS expect every class to have a generic unit type (the unit every civ gets unless it has a UU for that class).
 
It does, I know for a fact on Vista and Windows 7 that not having a generic unit type will cause a CTD.
 
I can fix BUG to ignore these unit classes, but I think other parts of BTS expect every class to have a generic unit type (the unit every civ gets unless it has a UU for that class).

It might actually be useful for non SDK mods for you to print warning messages about unitclasses without a default unit, and buildingclasses without a default building. The game only complains with Debug DLL's, which a lot of modders don't use.
 
It might actually be useful for non SDK mods for you to print warning messages about unitclasses without a default unit, and buildingclasses without a default building. The game only complains with Debug DLL's, which a lot of modders don't use.

I think this would be a great idea - especially as both the two units I added do have default units for their unitclasses. This means that it may be any of the other half dozen units I added.:(
 
The default unit type should be listed in the unit class, right? That's where it's accessed in Python.
 
Well all the unit classes have a default unit so I am assuming I have done my dyslexia thing somewhere and am now checking that I have not misspelt the unit name. Which means that if you are doing the test for default unit that you probably should check that the default unit exists.
 
If you put in an incorrect unit type you should see an error in Logs/xml.log and it will end up being NO_UNIT just as if there was no default.
 
There are no errors in the xml.log. A whole bunch of
Code:
[177221.140] info type  not found, Current XML file is: modules\DancingHoskuld\Subdue_Animals\Units\SubdueAnimals\Subdue_CIV4UnitInfos.xml
but I am told this is normal for WoC standard XML.
 
Yes, that's normal. So you're still getting the problem but cannot find a bad default unit type?
 
I have tried just adding one of the two units but I still get the error. They are WoC units which I have done some minor changes to for balancing in Rise of Mankind. Both have the default unit specified in the class info. I am including them here so you can see if including them causes you the same problem. At least it may narrow down where the problem is.

Edit: I just found the problem, it had nothing to do with those two units at all. Even though the error only showed up when they were there. It was a dyslexia style problem, I had two underscores in a name rather than one! It showed up when I added some error checking to the "metadata entry" stuff.

Which brings me to another question. Is there some guidelines or a tutorial on how to set up a log file under BUG. It would make my life easier than trying to catch messages flashing up on the screen.
 
Top Bottom