diff options
author | Batuhan Taşkaya <47358913+isidentical@users.noreply.github.com> | 2020-03-01 20:07:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-01 20:07:22 (GMT) |
commit | 185903de12de8837bf0dc0008a16e5e56c66a019 (patch) | |
tree | dff76400c68deceedbd15872cc0e1c3e0aa0cc09 | |
parent | 768d739c1cd8c1d41902229581811a9b86bcc76e (diff) | |
download | cpython-185903de12de8837bf0dc0008a16e5e56c66a019.zip cpython-185903de12de8837bf0dc0008a16e5e56c66a019.tar.gz cpython-185903de12de8837bf0dc0008a16e5e56c66a019.tar.bz2 |
bpo-39520: Fix un-parsing of ext slices with no dimensions (GH-18304)
-rw-r--r-- | Lib/test/test_future.py | 5 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2020-02-02-00-12-07.bpo-39520.uicBq6.rst | 2 | ||||
-rw-r--r-- | Python/ast_unparse.c | 1 |
3 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_future.py b/Lib/test/test_future.py index fd468b5..d83c47e 100644 --- a/Lib/test/test_future.py +++ b/Lib/test/test_future.py @@ -256,6 +256,11 @@ class AnnotationsFutureTestCase(unittest.TestCase): 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[a, b:c, d:e:f]") eq("slice[(x for x in a)]") diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-02-02-00-12-07.bpo-39520.uicBq6.rst b/Misc/NEWS.d/next/Core and Builtins/2020-02-02-00-12-07.bpo-39520.uicBq6.rst new file mode 100644 index 0000000..dec6765 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-02-02-00-12-07.bpo-39520.uicBq6.rst @@ -0,0 +1,2 @@ +Fix unparsing of ext slices with no items (``foo[:,]``). Patch by Batuhan +Taskaya. diff --git a/Python/ast_unparse.c b/Python/ast_unparse.c index f376e86..1a7cd23 100644 --- a/Python/ast_unparse.c +++ b/Python/ast_unparse.c @@ -746,6 +746,7 @@ append_ast_ext_slice(_PyUnicodeWriter *writer, slice_ty slice) APPEND_STR_IF(i > 0, ", "); APPEND(slice, (slice_ty)asdl_seq_GET(slice->v.ExtSlice.dims, i)); } + APPEND_STR_IF(dims_count == 1, ","); return 0; } |