Skip to content

Commit 5e1d065

Browse files
committed
Merge branch main into refactor
2 parents 86369be + aefaecb commit 5e1d065

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/core/IronPython/Runtime/Operations/ArrayOps.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,24 +214,29 @@ public static string __repr__(CodeContext/*!*/ context, [NotNone] Array/*!*/ sel
214214
ret.Append("Array[");
215215
Type elemType = self.GetType().GetElementType()!;
216216
ret.Append(DynamicHelpers.GetPythonTypeFromType(elemType).Name);
217-
ret.Append("]");
217+
ret.Append(']');
218218
ret.Append("((");
219219
for (int i = 0; i < self.Length; i++) {
220220
if (i > 0) ret.Append(", ");
221221
ret.Append(PythonOps.Repr(context, self.GetValue(i + self.GetLowerBound(0))));
222222
}
223-
ret.Append("))");
223+
ret.Append(')');
224+
if (self.GetLowerBound(0) != 0) {
225+
ret.Append(", base: ");
226+
ret.Append(self.GetLowerBound(0));
227+
}
228+
ret.Append(')');
224229
} else {
225230
// multi dimensional arrays require multiple statements to construct so we just
226231
// give enough info to identify the object and its type.
227-
ret.Append("<");
232+
ret.Append('<');
228233
ret.Append(self.Rank);
229234
ret.Append(" dimensional Array[");
230235
Type elemType = self.GetType().GetElementType()!;
231236
ret.Append(DynamicHelpers.GetPythonTypeFromType(elemType).Name);
232237
ret.Append("] at ");
233238
ret.Append(PythonOps.HexId(self));
234-
ret.Append(">");
239+
ret.Append('>');
235240
}
236241
return ret.ToString();
237242
} finally {

tests/python/test_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def test_nonzero_lowerbound(self):
180180
self.assertEqual(a[2:4], System.Array[int]((2,3)))
181181
self.assertEqual(a[-1], 4)
182182

183-
self.assertEqual(repr(a), 'Array[int]((0, 1, 2, 3, 4))')
183+
self.assertEqual(repr(a), 'Array[int]((0, 1, 2, 3, 4), base: 5)')
184184

185185
a = System.Array.CreateInstance(int, (5,), (15,))
186186
b = System.Array.CreateInstance(int, (5,), (20,))

0 commit comments

Comments
 (0)