Skip to content

Commit af8fb4b

Browse files
committed
Add reason for unhittable code
1 parent 25cc742 commit af8fb4b

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

python/phonenumbers/geocoder.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ def area_description_for_number(numobj, lang, script=None, region=None):
9393
number's area, or an empty string if no description is available."""
9494
e164_num = format_number(numobj, PhoneNumberFormat.E164)
9595
if not e164_num.startswith('+'): # pragma no cover
96+
# Can only hit this arm if there's an internal error in the rest of
97+
# the library
9698
raise Exception("Expect E164 number to start with +")
9799
for prefix_len in xrange(GEOCODE_LONGEST_PREFIX, 0, -1):
98100
prefix = e164_num[1:(1 + prefix_len)]

python/phonenumbers/phonenumberutil.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2307,9 +2307,10 @@ def parse(number, region=None, keep_raw_input=False,
23072307
numobj.preferred_domestic_carrier_code = carrier_code
23082308
len_national_number = len(normalized_national_number)
23092309
if len_national_number < _MIN_LENGTH_FOR_NSN: # pragma no cover
2310+
# Check of _is_viable_phone_number() at the top of this function makes
2311+
# this effectively unhittable.
23102312
raise NumberParseException(NumberParseException.TOO_SHORT_NSN,
23112313
"The string supplied is too short to be a phone number.")
2312-
23132314
if len_national_number > _MAX_LENGTH_FOR_NSN:
23142315
raise NumberParseException(NumberParseException.TOO_LONG,
23152316
"The string supplied is too long to be a phone number.")

0 commit comments

Comments
 (0)