bpo-39520: Fix un-parsing of ext slices with no dimensions (GH-18304)
This commit is contained in:
parent
768d739c1c
commit
185903de12
|
@ -256,6 +256,11 @@ class AnnotationsFutureTestCase(unittest.TestCase):
|
||||||
eq("slice[:-1]")
|
eq("slice[:-1]")
|
||||||
eq("slice[1:]")
|
eq("slice[1:]")
|
||||||
eq("slice[::-1]")
|
eq("slice[::-1]")
|
||||||
|
eq("slice[:,]")
|
||||||
|
eq("slice[1:2,]")
|
||||||
|
eq("slice[1:2:3,]")
|
||||||
|
eq("slice[1:2, 1]")
|
||||||
|
eq("slice[1:2, 2, 3]")
|
||||||
eq("slice[()]")
|
eq("slice[()]")
|
||||||
eq("slice[a, b:c, d:e:f]")
|
eq("slice[a, b:c, d:e:f]")
|
||||||
eq("slice[(x for x in a)]")
|
eq("slice[(x for x in a)]")
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix unparsing of ext slices with no items (``foo[:,]``). Patch by Batuhan
|
||||||
|
Taskaya.
|
|
@ -746,6 +746,7 @@ append_ast_ext_slice(_PyUnicodeWriter *writer, slice_ty slice)
|
||||||
APPEND_STR_IF(i > 0, ", ");
|
APPEND_STR_IF(i > 0, ", ");
|
||||||
APPEND(slice, (slice_ty)asdl_seq_GET(slice->v.ExtSlice.dims, i));
|
APPEND(slice, (slice_ty)asdl_seq_GET(slice->v.ExtSlice.dims, i));
|
||||||
}
|
}
|
||||||
|
APPEND_STR_IF(dims_count == 1, ",");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue