[issue42889] Incorrect behavior of Python parser after ast node of test program being modified

2021-01-12 Thread Guido van Rossum
Guido van Rossum added the comment: Yeah, there's supposed to be a checker. -- nosy: +lys.nikolaou, serhiy.storchaka ___ Python tracker ___

[issue42889] Incorrect behavior of Python parser after ast node of test program being modified

2021-01-12 Thread Xinmeng Xia
Xinmeng Xia added the comment: Nice suggestion! I change the argument and I can' find segfault program in transforming ast.Name. But I do find a segfault program in transforming ast.BinOp! Seeing the following example, this program will cause a segmentation fault on Python 3.10. No error

[issue42889] Incorrect behavior of Python parser after ast node of test program being modified

2021-01-11 Thread Guido van Rossum
Guido van Rossum added the comment: Hm, if your argument is just that you can make invalid identifiers this way, I still don't see why that's a big deal. You can do `x.__dict__["1"] = 1` and now you've given x an attribute that's not a valid identifier. You could also call the code object

[issue42889] Incorrect behavior of Python parser after ast node of test program being modified

2021-01-11 Thread Xinmeng Xia
Xinmeng Xia added the comment: Sorry, my description is a little confusing. My points lie on function 'compile' and 'exec'. Yes, I agree. AST can be modified and don't correspond to valid programs. But I don't think this invaild program can be compiled and exec without any check. It's

[issue42889] Incorrect behavior of Python parser after ast node of test program being modified

2021-01-11 Thread Guido van Rossum
Guido van Rossum added the comment: I don't think this is a bug, unless you can show an example where the bytecode compiler or the interpreter actually crashes. Basically you can change AST nodes in lots of ways that don't correspond to valid programs, and as long as you can't make CPython

[issue42889] Incorrect behavior of Python parser after ast node of test program being modified

2021-01-10 Thread Xinmeng Xia
New submission from Xinmeng Xia : The following program will lead to a incorrect behavior of Python parser. We change all variable to integer( forcely transformed to string) via ast.NodeTransformer. Then we compile the new code and execute it. It's surprising that code like "1=2; print(1)"