Commits

Philip Jenvey  committed 32fdb45

slightly rework the bytearray to float fix mostly for the sake of py3k

  • Participants
  • Parent commits 86ab7f9

Comments (0)

Files changed (2)

File pypy/objspace/std/bytearrayobject.py

     data = makebytearraydata_w(space, w_source)
     w_bytearray.data = data
 
-def float__Bytearray(space, w_bytearray):
-    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)
     return wrapint(space, result)

File pypy/objspace/std/floattype.py

         if space.is_w(w_floattype, space.w_float):
             return w_obj
         value = space.float_w(w_obj)
-    elif space.isinstance_w(w_value, space.w_str):
-        strvalue = space.str_w(w_value)
+    elif (space.isinstance_w(w_value, space.w_str) or
+          space.isinstance_w(w_value, space.w_bytearray)):
+        strvalue = space.bufferstr_w(w_value)
         try:
             value = string_to_float(strvalue)
         except ParseStringError, e: