mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #3693: Fix array obscure error message when given a str.
This commit is contained in:
parent
ed7dc14d6a
commit
9730e33535
3 changed files with 43 additions and 18 deletions
|
@ -1027,6 +1027,18 @@ class BaseTest:
|
|||
basesize = support.calcvobjsize('Pn2Pi')
|
||||
support.check_sizeof(self, a, basesize)
|
||||
|
||||
def test_initialize_with_unicode(self):
|
||||
if self.typecode != 'u':
|
||||
with self.assertRaises(TypeError) as cm:
|
||||
a = array.array(self.typecode, 'foo')
|
||||
self.assertIn("cannot use a str", str(cm.exception))
|
||||
with self.assertRaises(TypeError) as cm:
|
||||
a = array.array(self.typecode, array.array('u', 'foo'))
|
||||
self.assertIn("cannot use a unicode array", str(cm.exception))
|
||||
else:
|
||||
a = array.array(self.typecode, "foo")
|
||||
a = array.array(self.typecode, array.array('u', 'foo'))
|
||||
|
||||
|
||||
class StringTest(BaseTest):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue