This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

So Spring Python is trying to call getPosition() with some arguments, but no where in the code is getPosition called with any arguments. I'm doing something wrong with SP, or SP doesn't like the way the code I'm trying to wrap around is written. The code is from John Funge's AI4Games (can't post the URL because forum anti-spam won't let me), so you can download it and see. I then tried adding optional arguments to the methods it is getting upset with the length of, and then something else was being cast into the wrong type. Weird, weird stuff

This is driving me pretty nuts now! Would really appreciate help when someone gets a chance

You have uncovered a very interesting problem in Spring Python's AOP module

Thanks for finding this issue! Good news: I replicated your problem and found a temporary workaround without altering Spring Python itself.

I checked out ai4games from subversion (r.428), and then installed PyOpenGL and pygame in order to run these things. I had to make a couple of patches, but I finally got it running. I have the patches included at the bottom of this thread. I also opened SESPRINGPYTHONPY-77 to track this fix.

I then turned on debugging to see what Spring Python was doing, and I started adding more print statements to see what was happening. Sometimes, the very proxy-ish nature of AOP can get in your way when trying to debug that very code.

Anyway, I seemed to discover a pattern where if you are calling an intercepted method, the arguments should not contain intercepting calls themselves. It seems Spring Python's AOP doesn't handle that yet.

The best example is this line from tag.py's setupCharacters:

Code:

c.setPosition(vec.randomVec1(gs.worldDim, c.getPosition(), tmp))

In this case, setPosition will be intercepted, however it blows up. However when I pull the c.getPosition() call out of into a local variable, everything works.

It appeared that in one way or another, the AOP segments arguments from one of these calls was leaking into another. I don't precisely have my finger on it, but if a method that had arguments leaked into a method without arguments, it would break when calling the target method.

P.S. That is a neat little app! I haven't opened it up to see what it is doing, but it looks like it calculates mass, velocity, vectors, etc. to show from random, free-motion system.

Comment

Thanks for finding this issue! Good news: I replicated your problem and found a temporary workaround without altering Spring Python itself.

Greg,
You are a superstar! I'll try out the patches later (it's a little early and I haven't drunk any coffee yet!) but I can't wait to do so.

ai4games is exactly as you say it is; it's supposed to be a good sandbox for trying out certain AI behaviors like steering; decision-making and things like that. The guy who writes it, John Funge, teaches a Game AI class at UC Santa Cruz, and we're looking into how we could make some cleaner code using cross-cutting concerns.

Thanks ever so much Greg, you went way beyond the call of duty. I really, really appreciate it.

Comment

Hey Greg,
Thanks for the patched code. It did help a lot, but unfortunately I still can't use RegexpMethodPointcutAdvisor, as it exhibits the same behavior even on the patched code. This is a bit of a downer, but I can work around it

I really appreciate your usage of Spring Python AOP, mostly because you exposed two key bugs that I was able to code automated tests for and get fixed this morning.

I can't merge these changes to the trunk yet because I'm waiting on the build team to update the CI server. However, I included a patch you can apply to src/springpython/aop/__init__.py that should get things going. NOTE: This patch fixes both the original problem you found, along with the RegexpMethodPointcut problem you just reported.

Comment

Awesome! I'll get to work and let you know how it goes! Thanks so much for working so hard on this, I really appreciate it.

EDIT: Fantastic, it works brilliantly. Thank you so much. It looks like ai4games Rev 428 is actually broken and you seem to have patched it all by yourself! I rolled back and manually patched Rev 427, and it works amazingly. I'll be releasing the code as/when it's finished so you can take a look. Maybe (if I didn't make it too horribly broken) you could use it as a tutorial on your site. It would be great to see more people try the awesome AOP bits of Spring Python. It's far more elegant than any other Python AOP I've tried.