Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 14ef244

Browse files
committed
When re-writing a factor containing a unary negation of a literal, only
affect nodes without another operator. This was causing negated exponentiations to drop the exponentiation. This closes SF bug #456756.
1 parent 4b8c0f6 commit 14ef244

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Python/compile.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,8 +1891,11 @@ com_factor(struct compiling *c, node *n)
18911891
negative in the 0th position.
18921892
*/
18931893
if ((childtype == PLUS || childtype == MINUS || childtype == TILDE)
1894+
&& NCH(n) == 2
18941895
&& TYPE(CHILD(n, 1)) == factor
1896+
&& NCH(CHILD(n, 1)) == 1
18951897
&& TYPE(CHILD(CHILD(n, 1), 0)) == power
1898+
&& NCH(CHILD(CHILD(n, 1), 0)) == 1
18961899
&& TYPE(CHILD(CHILD(CHILD(n, 1), 0), 0)) == atom
18971900
&& TYPE(CHILD(CHILD(CHILD(CHILD(n, 1), 0), 0), 0)) == NUMBER) {
18981901
node *constant = CHILD(CHILD(CHILD(n, 1), 0), 0);

0 commit comments

Comments
 (0)