[pypy-svn] pypy bytearray: (lac, mfoord) constructing a bytearray of size -1 now fails with a ValueError

mfoord commits-noreply at bitbucket.org
Thu Jan 20 18:51:46 CET 2011


Author: Michael Foord <michael at voidspace.org.uk>
Branch: bytearray
Changeset: r41061:09eb2be3761a
Date: 2011-01-20 18:51 +0100
http://bitbucket.org/pypy/pypy/changeset/09eb2be3761a/

Log:	(lac, mfoord) constructing a bytearray of size -1 now fails with a
	ValueError

diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -75,6 +75,9 @@
         if not e.match(space, space.w_TypeError):
             raise
     else:
+        if count < 0:
+            raise OperationError(space.w_ValueError,
+                                 space.wrap("bytearray negative count"))
         w_bytearray.data[:] = ['\0'] * count
         return
 


More information about the Pypy-commit mailing list