From dce7a6d7f734d85a4b625a530655112c5e62cb26 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Thu, 15 May 2014 19:02:36 +0100 Subject: [PATCH] Fix bug in latitude/longitude conversion Fixed unit test for python3. int('+ 1') works in python2 but not python3. Also corrected a unit test. --- gramps/gen/utils/place.py | 9 ++++++--- gramps/gen/utils/test/place_test.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gramps/gen/utils/place.py b/gramps/gen/utils/place.py index 2ca30bef5..956f3f56f 100644 --- a/gramps/gen/utils/place.py +++ b/gramps/gen/utils/place.py @@ -116,9 +116,12 @@ def __convert_using_colon_repr(stringValue): # if no characters before ':' nothing useful is input! if len(l[0]) == 0: return None - if l[0][0] == '-': - sign = '-' - l[0]=l[0][1:] + if l[0][0] in ['+', '-']: + sign = l[0][0] + l[0]=l[0][1:].strip() + # regard a second sign as an error + if l[0][0] in ['+', '-']: + return None else: sign = '+' try: diff --git a/gramps/gen/utils/test/place_test.py b/gramps/gen/utils/test/place_test.py index 80fa0fe5b..dbaa6163a 100644 --- a/gramps/gen/utils/test/place_test.py +++ b/gramps/gen/utils/test/place_test.py @@ -202,7 +202,7 @@ class PlaceTest(unittest.TestCase): self._test_formats_fail(lat, lon) lat, lon = '-50:10:1', '-+2:1:2' - self._test_formats_success(lat, lon) + self._test_formats_fail(lat, lon) def test_missing_minute(self): lat, lon = '-50::1', '-2:1:2'