[IronPython] __getattr__ overflow

Eric Larson ionrock at gmail.com
Mon Sep 18 18:28:31 CEST 2006


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060918/ae23b925/attachment.html>


More information about the Ironpython-users mailing list