8000 bpo-42282: Fold constants inside named expressions by ncoghlan · Pull Request #23190 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-42282: Fold constants inside named expressions #23190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Minor code tweak (need to trigger new CI run anyway)
  • Loading branch information
ncoghlan committed Nov 7, 2020
commit a4741aa27eb7f81016553d2be12630ee92db5ace
7 changes: 3 additions & 4 deletions Python/ast_opt.c
90EB
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
static int
make_const(expr_ty node, PyObject *val, PyArena *arena)
{
// Even if no new value was calculated, make_const may still
// need to clear an error (e.g. for division by zero)
if (val == NULL) {
if (PyErr_ExceptionMatches(PyExc_KeyboardInterrupt)) {
return 0;
Expand Down Expand Up @@ -274,14 +276,11 @@ fold_binop(expr_ty node, PyArena *arena, _PyASTOptimizeState *state)
break;
// No builtin constants implement the following operators
case MatMult:
break;
return 1;
// No default case, so the compiler will emit a warning if new binary
// operators are added without being handled here
}

// Even if no new value was calculated, make_const may still
// need to clear an error (e.g. for division by zero)

return make_const(node, newval, arena);
}

Expand Down
0