[issue27703] Replace two Py_XDECREFs with Py_DECREFs in do_raise

Xiang Zhang report at bugs.python.org
Sun Aug 7 23:05:07 EDT 2016


Xiang Zhang added the comment:

Thanks for your reply Raymond. You always provide thoughtful feedbacks, though it makes me somewhat more nervous. ;) (I am nervous about making noise here and waste others' time.)

> Have you checked all the possibly code paths to be sure?

Yes. I did check all the code paths. I don't want to be a noise maker so I did check it carefully.

>  "Seems to be unnecessary" is insufficient reason for undoing Guido's code that has stood since 1997.

I use the word "seems" because even if I think my opinion is right, I am only 99% sure. Just as you said, the code is legacy and changing it has to be careful. I can miss something and be wrong. But now I think I am right.

> Looking at the snarl of possible code paths, I not finding it obvious why some of the paths require Py_XDECREF and others don't.

When we reach the two Py_XDECREFs, can type and value be NULL?

> then the patch needs to include assertions at key checkpoints (i.e. after a given assignment to "type" or "value" can we reliably assert the value is non-null) and/or comments showing what the reasoning is

Sorry, I didn't realize that. This is definitely good practice I know. But this is not documented and not a must then so I didn't do that. But I'll remember this in later patches.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27703>
_______________________________________


More information about the Python-bugs-list mailing list