Hi,

I was trying to wrap a rather verbose library to something more concise. Essentially, I have a module with a bunch of static functions and I wanted to create an object that automatically adds a prefix to the function calls. For example:

my_wrapper.CallFunction(*args)

Would be like:

myapi.F_ApiPrefixCallFunction(*args)

In CPython I could do something like this:

class wrap(myapi):
    def __getattr__(self, method):
        prefix_method = "F_ApiPrefix" + method
        return self.prefix_method

c = wrap()
c.CallFunction()

This returns the right thing.

In IronPython it gives a buffer overflow. I have posted the following code I used to test this out.

>>> class C:
...     def __getattr__(self, var):
...             pre_name = "say_" + str(var)
...             return self.pre_name
...     def hello(self, name):
...             print "Hello %s!" % name
...
>>> c = C()
>>> c.hello('eric')
Hello eric!

Sorry if this has already been posted/reported. I took a quick glance at the codeplex database, but I didn't know if it was the same issue reported for other __getattr__ bugs.

Thanks!

Eric

_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to