pycdc
pycdc copied to clipboard
Python 3.5: new opcodes for "with" statement unsupported (WITH_CLEANUP_START and _FINISH)
In Python 3.5 the opcode for WITH_CLEANUP is replaced by the pair of opcodes WITH_CLEANUP_START and WITH_CLEANUP_FINISH. This is to support async "with". These opcodes are not handled by pycdc, so the "with" statement compiled to bytecode with python 3.5 cannot be decompiled.
A quick and dirty solution is to add the following after the Pyc::WITH_CLEANUP
block in ASTree.cpp
. As the comment below says, this does not support async "with". In the case of not using async "with", the two opcodes will follow eachother immediately, and so should do the same as the old WITH_CLEANUP.
case Pyc::WITH_CLEANUP_START:
{
// This is just a copy of the WITH_CLEANUP block
// Stack top should be a None. Ignore it.
PycRef<ASTNode> none = stack.top();
stack.pop();
if (none != Node_NULL) {
fprintf(stderr, "Something TERRIBLE happened!\n");
break;
}
if (curblock->blktype() == ASTBlock::BLK_WITH
&& curblock->end() == curpos) {
PycRef<ASTBlock> with = curblock;
blocks.pop();
curblock = blocks.top();
curblock->append(with.cast<ASTNode>());
}
else {
fprintf(stderr, "Something TERRIBLE happened! No matching with block found for WITH_CLEANUP at %d\n", curpos);
}
}
break;
case Pyc::WITH_CLEANUP_FINISH:
{
// Do nothing. (This does not support async with.)
}
break;
Also: pycdc
just saved my day after an early morning git facepalm. Thank you all so much for this wonderful tool.
@asmunder @zrax this work, but i get more problems with BUILD_CONST_KEY_MAP
geting this too
# WARNING: Decompyle incomplete
#172
this issue can be closed also after this merge #460 @zrax