gh-132732: JIT: Only allow compact ints in pure evaluation (GH-136040)

This commit is contained in:
Ken Jin 2025-06-28 00:18:44 +08:00 committed by GitHub
parent 0e5d096130
commit c419af9e27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View 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);