|
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 |
@@ -3607,10 +3608,11 @@ infer_type(expr_ty e) |
3607 | 3608 | return &PyGen_Type; |
3608 | 3609 | case Lambda_kind: |
3609 | 3610 | return &PyFunction_Type; |
3610 | | - case JoinedStr_kind: |
3611 | 3611 | case TemplateStr_kind: |
3612 | | - case FormattedValue_kind: |
3613 | 3612 | case Interpolation_kind: |
| 3613 | + return &_PyTemplate_Type; |
| 3614 | + case JoinedStr_kind: |
| 3615 | + case FormattedValue_kind: |
3614 | 3616 | return &PyUnicode_Type; |
3615 | 3617 | case Constant_kind: |
3616 | 3618 | return Py_TYPE(e->v.Constant.value); |
@@ -3664,6 +3666,8 @@ check_subscripter(compiler *c, expr_ty e) |
3664 | 3666 | case Set_kind: |
3665 | 3667 | case SetComp_kind: |
3666 | 3668 | case GeneratorExp_kind: |
| 3669 | + case TemplateStr_kind: |
| 3670 | + case Interpolation_kind: |
3667 | 3671 | case Lambda_kind: { |
3668 | 3672 | location loc = LOC(e); |
3669 | 3673 | return _PyCompile_Warn(c, loc, "'%.200s' object is not subscriptable; " |
@@ -3698,9 +3702,7 @@ check_index(compiler *c, expr_ty e, expr_ty s) |
3698 | 3702 | case List_kind: |
3699 | 3703 | case ListComp_kind: |
3700 | 3704 | case JoinedStr_kind: |
3701 | | - case TemplateStr_kind: |
3702 | | - case FormattedValue_kind: |
3703 | | - case Interpolation_kind: { |
| 3705 | + case FormattedValue_kind: { |
3704 | 3706 | location loc = LOC(e); |
3705 | 3707 | return _PyCompile_Warn(c, loc, "%.200s indices must be integers " |
3706 | 3708 | "or slices, not %.200s; " |
|
0 commit comments