diff options
| author | Terry Wilson <twilson@redhat.com> | 2016-06-08 08:55:13 -0500 |
|---|---|---|
| committer | Ben Pfaff <blp@ovn.org> | 2016-06-08 11:35:03 -0700 |
| commit | 2c362f17d6f81b7602ac94abb7980fa1e6eb9cee (patch) | |
| tree | cc76001f80762bab3018974549ece58f82e451b2 /python/ovs | |
| parent | 2f22698ff1c88f8eb911711b0f98757f0660ef95 (diff) | |
| download | openvswitch-2c362f17d6f81b7602ac94abb7980fa1e6eb9cee.tar.gz | |
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: Terry Wilson <twilson@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'python/ovs')
| -rw-r--r-- | python/ovs/json.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/python/ovs/json.py b/python/ovs/json.py index 42e697dc0..ff986eab9 100644 --- a/python/ovs/json.py +++ b/python/ovs/json.py @@ -280,7 +280,7 @@ class Parser(object): significand *= 10 pow10 -= 1 while pow10 < 0 and significand % 10 == 0: - significand /= 10 + significand //= 10 pow10 += 1 if (pow10 == 0 and ((not sign and significand < 2 ** 63) or |
