Author: Konstantin Lopuhin <[email protected]>
Branch: 
Changeset: r58428:be5d72b50028
Date: 2012-07-20 23:21 +0400
http://bitbucket.org/pypy/pypy/changeset/be5d72b50028/

Log:    catch ParseStringError, raise app-level exception

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
@@ -13,6 +13,8 @@
 from pypy.objspace.std.listtype import get_list_index
 from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
 from pypy.objspace.std.stringobject import W_StringObject
+from pypy.objspace.std.strutil import ParseStringError
+from pypy.objspace.std.strutil import string_to_float
 from pypy.objspace.std.tupleobject import W_TupleObject
 from pypy.objspace.std.unicodeobject import W_UnicodeObject
 from pypy.objspace.std import slicetype
@@ -82,7 +84,12 @@
     w_bytearray.data = data
 
 def float__Bytearray(space, w_bytearray):
-    return space.wrap(float(''.join(w_bytearray.data)))
+    try:
+        value = string_to_float(''.join(w_bytearray.data))
+    except ParseStringError, e:
+        raise OperationError(space.w_ValueError, space.wrap(e.msg))
+    else:
+        return space.wrap(value)
 
 def len__Bytearray(space, w_bytearray):
     result = len(w_bytearray.data)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to