oddly placed error

on the second line of a function I defined, I am getting this error:

Python script error from controller “cont#CONTR#2”:
Traceback (most recent call last):
File “wheel”, line 54, in <module>
File “screenPosition.py”, line 2, in screenPos
SystemError: Blender Game Engine data has been freed, cannot use this python variable

the line in question looks like

x,y=cam.getScreenPosition(ob)

just in case it helps the line in the script that calls it looks like

spos=screenPos(o,2)

, where screenPos is the function I defined and o is the object the script is running on.

I’m wondering if this is because tey’ve begun to implement the removal of global variables on scene changes, but if so it’s inconsistent as I change scenes before with no error.

If anyone knows what is wrong and/or can help, I would be very grateful.

you tried to switch the position of the object?
x,y=cam.getScreenPosition(ob.position)

I’m starting to think it’s because getScreenPosition is now on the camera, and as the main camera is in a suspended scene while the script is running in a temporary overlay scene, it’s having trouble choosing the correct camera (or something).