Possible hasattr issue in 1.9x64

I recently installed Panda 1.9 (64bit version) and ran an old project I hadn’t touched in a while.

It’s a game that allows the user to click to move a character. When I clicked the terrain to move my character, my app crashed with
“SystemError: error return without exception set”

caused by this line of code: if hasattr(target, “model”)
Full method that is crashing is below:

def turnTo(self, target):
		if hasattr(target, "model"):
			self.model.lookAt(target.model)
		else:
			self.model.lookAt(target)

My app allows you to click either the “terrain” (which is just a large flat .egg file) or another model (the “foes” you fight) . If you click the terrain, the “target” attribute is set to a variable of type ‘panda3d.core.LPoint3f’ (a 3d coord). If you click a foe, the “target” attribute is set to the actual enemy character (a custom class I created).

This was all working without issues in 1.8.1.

I changed the code to this and it worked fine.

def turnTo(self, target):
		try:
			self.model.lookAt(target.model)
		except:
			self.model.lookAt(target)

To check, I then uninstalled 1.9x64 and re-installed 1.8.1. Sure enough, the original hasattr version of the code worked fine, which tells me something has changed in 1.9.

I do have a solution using try/except, but just curious why this is happening in 1.9x64?

Yes, I get it too:

>>> from panda3d.core import *
>>> hasattr(LPoint3(), 'model')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: error return without exception set

Thanks for reporting. I’ll take a look into it.

Thanks for the quick reply.