attributeerror 'nonetype'

keldath

LivE LonG AnD PrOsPeR
Joined
Dec 20, 2005
Messages
7,578
Location
israel
hey guys,

another quastion,

i get a python error - attributeerror 'nonetype' object has no attribute 'getdescription'

and it refers me to :

Code:
	def _handleDefaultEvent(self, eventType, argsList):
		if self.EventHandlerMap.has_key(eventType):
			for eventHandler in self.EventHandlerMap[eventType]:
				try:
					eventHandler(argsList)
				except:
					BugUtil.trace("Error in %s event handler %s", eventType, eventHandler)
and this:
Code:
				if (self.CityConscriptCounter[i] != 0
				and iCurrentConstrictCounter < self.CityConscriptCounter[i]
				and iCurrentConstrictCounter % iCity.flatConscriptAngerLength() == 0):
					message = BugUtil.getText("TXT_KEY_AUTOLOG_DRAFT_ANGER_DECREASED", (iCity.getName(), ))
					Logger.writeLog(message, vColor="DarkRed")


can anyone point me to the problem?
 
i get a python error - attributeerror 'nonetype' object has no attribute 'getdescription'
I don't know the code in question nor am I that familiar with python. However it looks to me like you encountered a way too common bug type, which is easily introduced by modders. On startup, each type in XML is given a number based on the index and during gameplay you can look up the type to get the index and hence look up the XML data belonging to that index.

Your problem is that you try to look up the none-type, which is -1. As indexes in the vector (array) can't be negative, it complains that you try to read non-existing data.

The bug isn't where you get the error message. It is at the place where it decides to use the none-type and then call a function with it, which will not accept none-type arguments. Finding the source of the non-type can be tricky.

You may consider ignoring all calls using the none-type. However be aware that while it removes the error in question, you could end up concealing a bug and the code will not work as intended.
 
The only index in the code you posted is "i". Perhaps it is not being set to what you think it should be.

Another possibility is that iCity is not pointing to a real city. Sometimes when python is called the city parameter is invalid which is why it is suggested that you test it first. You test it is not None.

Something like:-
Code:
def onXXXXX( argsList):
	pCity = argsList[0]
	if pCity == None:
		return
 
Actually, when the error occurs, it will tell you which line is problematic. So just look at that line.
That line should have getDescription which is not in what you posted.
 
getDescription is usually used with a info item, like tech info or unit info.
It is definitely not in what you pasted.
 
Back
Top Bottom