0002507: [Place-Dialog] "Unhandled exception" when pasting some invalid string

Fixing the bug, no features or improvements


svn: r11415
This commit is contained in:
Benny Malengier
2008-12-04 15:05:48 +00:00
parent ad25d37cd9
commit 299796096c

View File

@@ -178,9 +178,10 @@ def conv_lat_lon(latitude, longitude, format="D.D4"):
#allow some special unicode symbols #allow some special unicode symbols
val = val.replace( u'\u2033',r'"') val = val.replace( u'\u2033',r'"')
val = val.replace( u'\u2032',r"'") val = val.replace( u'\u2032',r"'")
#ignore spaces #ignore spaces, a regex with \s* would be better here...
val = val.replace(r'\s*', r'') val = val.replace(r' ', r'')
# get the degrees, must be present val = val.replace(r'\t', r'')
# get the degrees, must be present to parse as old degree notation
if val.find(r'_') != -1: if val.find(r'_') != -1:
l = val.split('_') l = val.split('_')
if len(l) != 2: if len(l) != 2:
@@ -236,6 +237,7 @@ def conv_lat_lon(latitude, longitude, format="D.D4"):
sign = '-' sign = '-'
else: else:
error = True error = True
# degs should have a value now # degs should have a value now
if degs == None: if degs == None:
error = True error = True
@@ -492,6 +494,8 @@ if __name__ == '__main__':
test_formats_fail(lat,lon) test_formats_fail(lat,lon)
lat, lon = ' 50°59.60"N', ' 2°53\'E' lat, lon = ' 50°59.60"N', ' 2°53\'E'
test_formats_success(lat,lon) test_formats_success(lat,lon)
lat, lon = ' 11° 11\' 11" N, 11° 11\' 11" O', ' '
test_formats_fail(lat,lon)
# very small negative # very small negative
lat, lon = '-0.00006', '-0.00006' lat, lon = '-0.00006', '-0.00006'
test_formats_success(lat,lon) test_formats_success(lat,lon)