|
case Constant_kind: { |
|
/* Ellipsis and immutable sequences are not allowed. |
|
For True, False and None, MatchSingleton() should |
|
be used */ |
|
if (!validate_expr(state, exp, Load)) { |
|
return 0; |
|
} |
|
PyObject *literal = exp->v.Constant.value; |
|
if (PyLong_CheckExact(literal) || PyFloat_CheckExact(literal) || |
|
PyBytes_CheckExact(literal) || PyComplex_CheckExact(literal) || |
|
PyUnicode_CheckExact(literal)) { |
|
return 1; |
|
} |
|
PyErr_SetString(PyExc_ValueError, |
|
"unexpected constant inside of a literal pattern"); |
|
return 0; |
|
} |
|
case Constant_kind: |
|
/* Ellipsis and immutable sequences are not allowed. |
|
For True, False and None, MatchSingleton() should |
|
be used */ |
|
if (!validate_expr(state, exp, Load)) { |
|
return 0; |
|
} |
|
PyObject *literal = exp->v.Constant.value; |
|
if (PyLong_CheckExact(literal) || PyFloat_CheckExact(literal) || |
|
PyBytes_CheckExact(literal) || PyComplex_CheckExact(literal) || |
|
PyUnicode_CheckExact(literal)) { |
|
return 1; |
|
} |
|
PyErr_SetString(PyExc_ValueError, |
|
"unexpected constant inside of a literal pattern"); |
|
return 0; |