diff --git a/Src/IronPython/Runtime/Operations/ArrayOps.cs b/Src/IronPython/Runtime/Operations/ArrayOps.cs index f80cd9734..0134db996 100644 --- a/Src/IronPython/Runtime/Operations/ArrayOps.cs +++ b/Src/IronPython/Runtime/Operations/ArrayOps.cs @@ -214,24 +214,29 @@ public static string __repr__(CodeContext/*!*/ context, [NotNone] Array/*!*/ sel ret.Append("Array["); Type elemType = self.GetType().GetElementType()!; ret.Append(DynamicHelpers.GetPythonTypeFromType(elemType).Name); - ret.Append("]"); + ret.Append(']'); ret.Append("(("); for (int i = 0; i < self.Length; i++) { if (i > 0) ret.Append(", "); ret.Append(PythonOps.Repr(context, self.GetValue(i + self.GetLowerBound(0)))); } - ret.Append("))"); + ret.Append(')'); + if (self.GetLowerBound(0) != 0) { + ret.Append(", base: "); + ret.Append(self.GetLowerBound(0)); + } + ret.Append(')'); } else { // multi dimensional arrays require multiple statements to construct so we just // give enough info to identify the object and its type. - ret.Append("<"); + ret.Append('<'); ret.Append(self.Rank); ret.Append(" dimensional Array["); Type elemType = self.GetType().GetElementType()!; ret.Append(DynamicHelpers.GetPythonTypeFromType(elemType).Name); ret.Append("] at "); ret.Append(PythonOps.HexId(self)); - ret.Append(">"); + ret.Append('>'); } return ret.ToString(); } finally { diff --git a/Tests/test_array.py b/Tests/test_array.py index de04efac0..d02a0f16f 100644 --- a/Tests/test_array.py +++ b/Tests/test_array.py @@ -180,7 +180,7 @@ def test_nonzero_lowerbound(self): self.assertEqual(a[2:4], System.Array[int]((2,3))) self.assertEqual(a[-1], 4) - self.assertEqual(repr(a), 'Array[int]((0, 1, 2, 3, 4))') + self.assertEqual(repr(a), 'Array[int]((0, 1, 2, 3, 4), base: 5)') a = System.Array.CreateInstance(int, (5,), (15,)) b = System.Array.CreateInstance(int, (5,), (20,))