diff --git a/pyhamtools/callinfo.py b/pyhamtools/callinfo.py index efa73fa..f20d1a2 100644 --- a/pyhamtools/callinfo.py +++ b/pyhamtools/callinfo.py @@ -214,7 +214,10 @@ class Callinfo(object): pfx = re.sub('/', '', pfx.group(0)) #make sure that the remaining part is actually a callsign (avoid: OZ/JO81) rest = re.search('/[A-Z0-9]+', entire_callsign) - rest = re.sub('/', '', rest.group(0)) + if rest is None: + self._logger.warning("non latin characters in callsign '{0}'".format(entire_callsign)) + raise KeyError + rest = re.sub('/', '', rest.group(0)) if re.match('^[\\d]{0,1}[A-Z]{1,2}\\d([A-Z]{1,4}|\\d{3,3}|\\d{1,3}[A-Z])[A-Z]{0,5}$', rest): return self._iterate_prefix(pfx) diff --git a/test/test_callinfo.py b/test/test_callinfo.py index 5146449..8500188 100644 --- a/test/test_callinfo.py +++ b/test/test_callinfo.py @@ -265,6 +265,15 @@ class Test_callinfo_methods: fix_callinfo._dismantle_callsign("OZ/JO85") + def test_dismantle_callsign_with_cyrillic_characters(self, fix_callinfo): + + with pytest.raises(KeyError): + fix_callinfo._dismantle_callsign("RД3MAS") #cyrillic letter 'Д' in call + with pytest.raises(KeyError): + fix_callinfo._dismantle_callsign("RД3/K9MAS") #cyrillic letter 'Д' in prefix + with pytest.raises(KeyError): + fix_callinfo._dismantle_callsign("R2EA/М") #cyrillic letter 'M' in appendix + def test_dismantle_callsign_with_VK9_special_suffixes(self, fix_callinfo): if fix_callinfo._lookuplib._lookuptype == "clublog":