Hi Lisandro,

could you explain why this is needed? My fix would have been to add a
GIVEREF, as the default argument is being made global. I also liked the
code a lot better the old way. Is there a case where the original code
didn't work?

Stefan


@@ -1231,15 +1233,14 @@
             if default:
                 if not default.is_literal:
                     default.generate_evaluation_code(code)
-                    default.make_owned_reference(code)
-                    code.putln(
-                        "%s = %s;" % (
-                            arg.default_entry.cname,
-                            default.result_as(arg.default_entry.type)))
-                    if default.is_temp and default.type.is_pyobject:
-                        code.putln(
-                            "%s = 0;" %
-                                default.result())
+                    assign_code = "%s = %s;" % (
+                        arg.default_entry.cname,
+                        default.result_as(arg.default_entry.type))
+                    if default.type.is_pyobject:
+                        assign_code += " Py_INCREF(%s);" % \
+                            arg.type.as_pyobject(arg.default_entry.cname)
+                    code.putln(assign_code)
+                    default.generate_disposal_code(code)
                     default.free_temps(code)
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to