Skip to content

Commit 8db8f14

Browse files
committed
More constructor error checking
1 parent f5a0952 commit 8db8f14

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_array.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@
337337
*graalpython.lib-python.3.test.test_array.LongTest.test_tofromlist
338338
*graalpython.lib-python.3.test.test_array.LongTest.test_type_error
339339
*graalpython.lib-python.3.test.test_array.LongTest.test_weakref
340+
*graalpython.lib-python.3.test.test_array.MiscTest.test_bad_constructor
340341
*graalpython.lib-python.3.test.test_array.MiscTest.test_empty
341342
*graalpython.lib-python.3.test.test_array.ShortTest.test_add
342343
*graalpython.lib-python.3.test.test_array.ShortTest.test_assignment

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ PArray arrayIteratorInitializer(VirtualFrame frame, Object cls, String typeCode,
207207
}
208208

209209
private BufferFormat getFormatChecked(String typeCode) {
210+
if (typeCode.length() != 1) {
211+
throw raise(TypeError, "array() argument 1 must be a unicode character, not str");
212+
}
210213
BufferFormat format = BufferFormat.forArray(typeCode);
211214
if (format == null) {
212215
throw raise(ValueError, "bad typecode (must be b, B, u, h, H, i, I, l, L, q, Q, f or d)");

0 commit comments

Comments
 (0)