|
29 | 29 | #include "pycore_symtable.h" // PySTEntryObject |
30 | 30 | #include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString |
31 | 31 | #include "pycore_ceval.h" // SPECIAL___ENTER__ |
| 32 | +#include "pycore_template.h" // _PyTemplate_Type |
32 | 33 |
|
33 | 34 | #define NEED_OPCODE_METADATA |
34 | 35 | #include "pycore_opcode_metadata.h" // _PyOpcode_opcode_metadata, _PyOpcode_num_popped/pushed |
@@ -3617,10 +3618,11 @@ infer_type(expr_ty e) |
3617 | 3618 | return &PyGen_Type; |
3618 | 3619 | case Lambda_kind: |
3619 | 3620 | return &PyFunction_Type; |
3620 | | - case JoinedStr_kind: |
3621 | 3621 | case TemplateStr_kind: |
3622 | | - case FormattedValue_kind: |
3623 | 3622 | case Interpolation_kind: |
| 3623 | + return &_PyTemplate_Type; |
| 3624 | + case JoinedStr_kind: |
| 3625 | + case FormattedValue_kind: |
3624 | 3626 | return &PyUnicode_Type; |
3625 | 3627 | case Constant_kind: |
3626 | 3628 | return Py_TYPE(e->v.Constant.value); |
@@ -3674,6 +3676,8 @@ check_subscripter(compiler *c, expr_ty e) |
3674 | 3676 | case Set_kind: |
3675 | 3677 | case SetComp_kind: |
3676 | 3678 | case GeneratorExp_kind: |
| 3679 | + case TemplateStr_kind: |
| 3680 | + case Interpolation_kind: |
3677 | 3681 | case Lambda_kind: { |
3678 | 3682 | location loc = LOC(e); |
3679 | 3683 | return _PyCompile_Warn(c, loc, "'%.200s' object is not subscriptable; " |
@@ -3708,9 +3712,7 @@ check_index(compiler *c, expr_ty e, expr_ty s) |
3708 | 3712 | case List_kind: |
3709 | 3713 | case ListComp_kind: |
3710 | 3714 | case JoinedStr_kind: |
3711 | | - case TemplateStr_kind: |
3712 | | - case FormattedValue_kind: |
3713 | | - case Interpolation_kind: { |
| 3715 | + case FormattedValue_kind: { |
3714 | 3716 | location loc = LOC(e); |
3715 | 3717 | return _PyCompile_Warn(c, loc, "%.200s indices must be integers " |
3716 | 3718 | "or slices, not %.200s; " |
|
0 commit comments