deadmenace / shedskin

Automatically exported from code.google.com/p/shedskin
0 stars 0 forks source link

Default arguments for methods of subclasses not initialized. #189

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Compile the attached source with shedskin:

class Alpha:
    def __init(self):
        pass

    def func(self, value=True):
        print("value is:" + str(value))

class Beta(Alpha):
    def __init(self):
        pass

b = Beta()
b.func();

looking at the generated cpp code you can see that default_0 is set
but not used, while default_1 is not set but used.

void __init() {
    const_0 = new str("value is:");

    __name__ = new str("__main__");

    default_0 = True;
    cl_Alpha = new class_("Alpha");
    cl_Beta = new class_("Beta");
    b = (new Beta());
    b->func(default_1);
}

What is the expected output? What do you see instead?

"value is:True".  This is what cpython prints.

Instead I see "value is:False"

What version of the product are you using? On what operating system?

shedskin-mainline, on OSX

Please provide any additional information below.

Original issue reported on code.google.com by paulhaeb...@gmail.com on 3 May 2013 at 12:23

Attachments:

GoogleCodeExporter commented 9 years ago
thanks paul, good catch :D

I added a test for this and fixed the problem in GIT. please let me know when 
you run into more problems!

Original comment by mark.duf...@gmail.com on 4 May 2013 at 5:46

GoogleCodeExporter commented 9 years ago
Super fine! Thanks a lot.

Sent from my iPhone6mini

Original comment by paulhaeb...@gmail.com on 5 May 2013 at 4:37