[ovs-git] [openvswitch/ovs] f914f9: Ensure significand remains an integer in Python3 j...

GitHub noreply at github.com
Tue Jun 7 15:34:43 UTC 2016


  Branch: refs/heads/master
  Home:   https://github.com/openvswitch/ovs
  Commit: f914f978dd74dbf715fb13d4576a414ed92402e8
      https://github.com/openvswitch/ovs/commit/f914f978dd74dbf715fb13d4576a414ed92402e8
  Author: Terry Wilson <twilson at redhat.com>
  Date:   2016-06-07 (Tue, 07 Jun 2016)

  Changed paths:
    M python/ovs/json.py

  Log Message:
  -----------
  Ensure significand remains an integer in Python3 json parser

The / operation in Python 2 is "floor division" for int/long types
while in Python 3 is "true division". This means that the
significand can become a float with the existing code in Python 3.
This, in turn, can result in a parse of something like [1.10e1]
returning 11 in Python 2 and 11.0 in Python 3. Switching to the
// operator resolves this difference.

The JSON tests do not catch this difference because the built-in
serializer prints floats with the %.15g format which will convert
floats with no fractional part to an integer representation.

Signed-off-by: Ben Pfaff <blp at ovn.org>




More information about the git mailing list