From c419af9e277bea7dd78f4defefc752fe93b0b8ec Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Sat, 28 Jun 2025 00:18:44 +0800 Subject: gh-132732: JIT: Only allow compact ints in pure evaluation (GH-136040) --- Python/optimizer_symbols.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Python/optimizer_symbols.c') diff --git a/Python/optimizer_symbols.c b/Python/optimizer_symbols.c index e4dbca8362f..bd3ec615d08 100644 --- a/Python/optimizer_symbols.c +++ b/Python/optimizer_symbols.c @@ -206,9 +206,11 @@ _Py_uop_sym_is_safe_const(JitOptContext *ctx, JitOptRef sym) if (const_val == NULL) { return false; } + if (_PyLong_CheckExactAndCompact(const_val)) { + return true; + } PyTypeObject *typ = Py_TYPE(const_val); - return (typ == &PyLong_Type) || - (typ == &PyUnicode_Type) || + return (typ == &PyUnicode_Type) || (typ == &PyFloat_Type) || (typ == &PyTuple_Type) || (typ == &PyBool_Type); -- cgit v1.2.3