]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-132732: JIT: Only allow compact ints in pure evaluation (GH-136040)
authorKen Jin <kenjin@python.org>
Fri, 27 Jun 2025 16:18:44 +0000 (00:18 +0800)
committerGitHub <noreply@github.com>
Fri, 27 Jun 2025 16:18:44 +0000 (00:18 +0800)
Python/optimizer_symbols.c

index e4dbca8362f4ce54668ef34d4e12217426278ffb..bd3ec615d08592e4a0717e229e5e924cf87d7ba8 100644 (file)
@@ -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);