Hi again,
> @@ -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)
Here's what I pushed now (Nodes.py):
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())
default.free_temps(code)
code.put_giveref(arg.default_entry.cname)
Note that generate_evaluation_code() already cleans up the temps of the RHS
subexpressions, so there is no need to do anything but stealing the reference.
BTW, note that a doctest must be a unicode string. Otherwise, it will not
be executed in Py3.
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev