summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-08-30 18:53:25 (GMT)
committerFred Drake <fdrake@acm.org>2001-08-30 18:53:25 (GMT)
commit14ef244dfe8b79694d4baa48ceda874fe27ec05d (patch)
treee6efd23ed34b577d293e4dff143c782e4d611969 /Python/compile.c
parent4b8c0f6d7d66e2ca8f3a80d1b9ba01afee88f574 (diff)
downloadcpython-14ef244dfe8b79694d4baa48ceda874fe27ec05d.zip
cpython-14ef244dfe8b79694d4baa48ceda874fe27ec05d.tar.gz
cpython-14ef244dfe8b79694d4baa48ceda874fe27ec05d.tar.bz2
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.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 1921220..171fceb 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1891,8 +1891,11 @@ com_factor(struct compiling *c, node *n)
negative in the 0th position.
*/
if ((childtype == PLUS || childtype == MINUS || childtype == TILDE)
+ && NCH(n) == 2
&& TYPE(CHILD(n, 1)) == factor
+ && NCH(CHILD(n, 1)) == 1
&& TYPE(CHILD(CHILD(n, 1), 0)) == power
+ && NCH(CHILD(CHILD(n, 1), 0)) == 1
&& TYPE(CHILD(CHILD(CHILD(n, 1), 0), 0)) == atom
&& TYPE(CHILD(CHILD(CHILD(CHILD(n, 1), 0), 0), 0)) == NUMBER) {
node *constant = CHILD(CHILD(CHILD(n, 1), 0), 0);