aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pypy/module/array/interp_array.py2
-rw-r--r--pypy/module/array/test/test_array.py3
2 files changed, 5 insertions, 0 deletions
diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
index 9aec652bfb..6048c3f669 100644
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -236,6 +236,8 @@ class W_ArrayBase(W_Root):
raise OperationError(self.space.w_ValueError, self.space.wrap(msg))
oldlen = self.len
new = len(s) / self.itemsize
+ if not new:
+ return
self.setlen(oldlen + new)
cbuf = self._charbuf_start()
copy_string_to_raw(llstr(s), rffi.ptradd(cbuf, oldlen * self.itemsize), 0, len(s))
diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py
index d9c5b3991f..358f08cc55 100644
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -171,6 +171,9 @@ class BaseArrayTests:
a = self.array('c')
a.fromstring('Hi!')
assert a[0] == 'H' and a[1] == 'i' and a[2] == '!' and len(a) == 3
+ a = self.array('c')
+ a.fromstring('')
+ assert not len(a)
for t in 'bBhHiIlLfd':
a = self.array(t)