mirror of
https://github.com/python/cpython.git
synced 2026-05-06 12:49:07 -04:00
GH-131798: Type-propagate string/list/tuple slices (GH-134671)
This commit is contained in:
@@ -1237,6 +1237,20 @@ dummy_func(void) {
|
||||
sym_set_const(callable, list_append);
|
||||
}
|
||||
|
||||
op(_BINARY_SLICE, (container, start, stop -- res)) {
|
||||
// Slicing a string/list/tuple always returns the same type.
|
||||
PyTypeObject *type = sym_get_type(container);
|
||||
if (type == &PyUnicode_Type ||
|
||||
type == &PyList_Type ||
|
||||
type == &PyTuple_Type)
|
||||
{
|
||||
res = sym_new_type(ctx, type);
|
||||
}
|
||||
else {
|
||||
res = sym_new_not_null(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
// END BYTECODES //
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user