PROTON-490: fix long/int conversion mixup
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/64a7ce29 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/64a7ce29 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/64a7ce29 Branch: refs/heads/master Commit: 64a7ce2964da2832a8e2248c07aac4a60dc9b7cd Parents: 9e7f16c Author: Ken Giusti <[email protected]> Authored: Wed Apr 29 15:19:05 2015 -0400 Committer: Ken Giusti <[email protected]> Committed: Wed Apr 29 15:19:05 2015 -0400 ---------------------------------------------------------------------- examples/python/test_examples.py | 8 +++----- proton-c/bindings/python/proton/__init__.py | 13 +++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/64a7ce29/examples/python/test_examples.py ---------------------------------------------------------------------- diff --git a/examples/python/test_examples.py b/examples/python/test_examples.py index 6a411d3..7f87616 100644 --- a/examples/python/test_examples.py +++ b/examples/python/test_examples.py @@ -24,10 +24,8 @@ import unittest if sys.version_info[0] == 2: _unicode_prefix = 'u' - _long_suffix = 'L' else: _unicode_prefix = '' - _long_suffix = '' class ExamplesTest(unittest.TestCase): @@ -58,7 +56,7 @@ class ExamplesTest(unittest.TestCase): s.wait() r.wait() actual = [l.strip() for l in r.stdout] - expected = ["{'sequence': %i%s}" % ((i+1), _long_suffix) for i in range(100)] + expected = ["{'sequence': %i}" % (i+1) for i in range(100)] self.assertEqual(actual, expected) def test_client_server(self, client=['client.py'], server=['server.py'], sleep=0): @@ -137,7 +135,7 @@ class ExamplesTest(unittest.TestCase): s.wait() r.wait() actual = [l.strip() for l in r.stdout] - expected = ["{'sequence': %i%s}" % ((i+1), _long_suffix) for i in range(100)] + expected = ["{'sequence': %i}" % (i+1) for i in range(100)] self.assertEqual(actual, expected) def test_direct_send_simple_recv(self): @@ -149,5 +147,5 @@ class ExamplesTest(unittest.TestCase): r.wait() s.wait() actual = [l.strip() for l in r.stdout] - expected = ["{'sequence': %i%s}" % ((i+1), _long_suffix) for i in range(100)] + expected = ["{'sequence': %i}" % (i+1) for i in range(100)] self.assertEqual(actual, expected) http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/64a7ce29/proton-c/bindings/python/proton/__init__.py ---------------------------------------------------------------------- diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py index 864b25e..8b9ffeb 100644 --- a/proton-c/bindings/python/proton/__init__.py +++ b/proton-c/bindings/python/proton/__init__.py @@ -1934,7 +1934,7 @@ class Data: If the current node is a signed int, returns its value, returns 0 otherwise. """ - return pn_data_get_int(self._data) + return int(pn_data_get_int(self._data)) def get_char(self): """ @@ -1955,7 +1955,7 @@ class Data: If the current node is an signed long, returns its value, returns 0 otherwise. """ - return pn_data_get_long(self._data) + return long(pn_data_get_long(self._data)) def get_timestamp(self): """ @@ -2158,7 +2158,7 @@ class Data: unicode: put_string, bytes: put_binary, symbol: put_symbol, - int: put_long, + long: put_long, char: put_char, ulong: put_ulong, timestamp: put_timestamp, @@ -2167,9 +2167,10 @@ class Data: Described: put_py_described, Array: put_py_array } - # for python 2.x: - if long not in put_mappings: - put_mappings[long] = put_long + # for python 3.x, long is merely an alias for int, but for python 2.x + # we need to add an explicit int since it is a different type + if int not in put_mappings: + put_mappings[int] = put_int get_mappings = { NULL: lambda s: None, --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
