➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 godaygo
收信人 benjamin.peterson, eric.snow, godaygo, larry, ncoghlan, serhiy.storchaka, vstinner
日期 2018-04-26.19:06:50
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1524769610.74.0.682650639539.issue32455@psf.upfronthosting.co.za>
In-reply-to
内容
Sorry if this doesn't fit this issue and needs a separate one.

Since Python switched to 2 byte wordcode, all opcodes which do not imply an argument, technically have it - augmented with 0. So it is convenient to iterate over bytecode like:

op, arg = instruction.

But there is a check in stack_effect that the second argument for this opcodes must be None. 

file::_opcode.c

else if (oparg != Py_None) {
        PyErr_SetString(PyExc_ValueError,
                "stack_effect: opcode does not permit oparg but oparg was specified");
        return -1;
    }


So you need to perform a somewhat _redundant_ check before calling:

arg = arg if op >= opcode.HAVE_ARGUMENT else None.
st = stack_effect(op, arg)

Maybe it's normal to relax this condition - be None or 0 for opcode < opcode.HAVE_ARGUMENT?
历史
日期 用户 动作 参数
2018-04-26 19:06:50godaygo修改recipients: + godaygo, ncoghlan, vstinner, larry, benjamin.peterson, eric.snow, serhiy.storchaka
2018-04-26 19:06:50godaygo修改messageid: <1524769610.74.0.682650639539.issue32455@psf.upfronthosting.co.za>
2018-04-26 19:06:50godaygo链接issue32455 messages
2018-04-26 19:06:50godaygo创建