Negative float values are not serialized correctly

Bug #298864 reported by nside
2
Affects Status Importance Assigned to Milestone
Twotp
Fix Released
Medium
Thomas Herve

Bug Description

Erlang code:
-module(store).
-export([test/1]).
test(SomeFloat) ->
 io:fwrite("the float: ~p~n", [SomeFloat]).

python code (variant of):
from twisted.internet import reactor
from twotp import OneShotPortMapperFactory, readCookie, buildNodeName

def gotConnection(inst): #this will work
    return inst.factory.callRemote(inst, "store", "test", (40.0,)
        ).addCallback(gotResult)

def gotConnection(inst): #this will not work
    return inst.factory.callRemote(inst, "store", "test", (-40.0,)
        ).addCallback(gotResult)

def gotResult(resp):
    print "Got response", resp
    reactor.stop()

def eb(error):
    print "Got error", error
    reactor.stop()

cookie = readCookie()
nodeName = buildNodeName('nodename')
epmd = OneShotPortMapperFactory(nodeName, cookie)
epmd.connectToNode("foo").addCallback(gotConnection).addErrback(eb)
reactor.run()

erlang error:
=ERROR REPORT==== 16-Nov-2008::17:36:51 ===
Got invalid data on distribution channel, offending packet is: <<112,131,104,4,97,6,103,100,0,19,108,111,97,100,101,114,64,110,115,105,100,101,45,117,98,117,110,116,117,0,0,0,0,0,0,0,0,0,100,0,0,100,0,3,114,101,120,131,104,2,103,100,0,19,108,111,97,100,101,114,64,110,115,105,100,101,45,117,98,117,110,116,117,0,0,0,0,0,0,0,0,0,104,5,100,0,4,99,97,108,108,100,0,5,115,116,111,114,101,100,0,4,116,101,115,116,108,0,0,0,1,104,1,99,45,52,46,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,101,43,48,49,0,0,0,0,0,106,100,0,4,117,115,101,114>>

nside (denis-2ni)
description: updated
Revision history for this message
nside (denis-2ni) wrote :

I fixed the bug using py_interface float serialization code. Change packer.py to this:
    def pack_float(self, term):
        """
        Pack a float.
        """
        floatStr = "%.20e" % term
        nullPadStr = "\0" * (31 - len(floatStr))
        return self.packChar(self.MAGIC_FLOAT) + floatStr + nullPadStr

Revision history for this message
Thomas Herve (therve) wrote :

Thanks a lot for the report! This is fixed in r25 of trunk.

Changed in twotp:
assignee: nobody → therve
importance: Undecided → Medium
status: New → Fix Committed
Thomas Herve (therve)
Changed in twotp:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.