From 8503d6e1e564cb5ac61bc6e3f16c0b384c76661e Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Tue, 6 Jan 2015 18:30:53 +0400 Subject: gdb/python: exception trying to create empty array The following python command fails: (gdb) python print gdb.lookup_type('char').array(1, 0) Traceback (most recent call last): File "", line 1, in ValueError: Array length must not be negative Error while executing Python code. The above is trying to create an empty array, which is fairly command in Ada. gdb/ChangeLog: * python/py-type.c (typy_array_1): Do not raise negative-length exception if N2 is equal to N1 - 1. gdb/testsuite/ChangeLog: * gdb.python/py-type.exp: Add a couple test about empty array creation, and negative-length array creation. --- gdb/python/py-type.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gdb/python') diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 54fc30f..8e82c99 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -528,7 +528,7 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector) n1 = 0; } - if (n2 < n1) + if (n2 < n1 - 1) { PyErr_SetString (PyExc_ValueError, _("Array length must not be negative")); -- cgit v1.1