Telephone numbers: Italian landlines lose their leading zero, and shared dialling codes show the wrong country #459
Labels
No labels
accessibility
authentication
breaking change
bug
documentation
enhancement
interface
internationalisation
observability
performance
security
tier
1
tier
2
tier
3
tier/4
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Postulo/postulo#459
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found on 2026-09-29 in a read-only review of postulo at
95348908d, readingcore/phones.pyand runningcombineandcountry_ofagainst numbers from the countries that share a dialling code.Checked again on 2026-10-01 against
mainat0a5cad587: still present.Two mistakes in the country arithmetic.
combineremoves every leading zero from a national number, which is right for most of Europe and wrong for Italy, San Marino and the Vatican, whose zero is part of the international number: an Italian landline is stored as a different number that cannot be dialled. Andcountry_ofbreaks ties between countries sharing a code alphabetically, so the telephone field shows Antigua and Barbuda for every North American number, the Åland Islands for every Finnish one, Kazakhstan for every Russian one and Western Sahara for every Moroccan one.core/phones.py:392(combine,return f"+{row[1]}{digits.lstrip('0')}");core/phones.py:286(_BY_DIALLING = sorted(COUNTRIES, key=lambda row: (-len(row[1]), row[0]))), read bycountry_ofatcore/phones.py:395;core/phone_field.py:84(PhoneWidget.decompress, which sets the chooser and the flag fromcountry_of).IT) records a recruiter's Rome line as06 6982 1234.combine("06 6982 1234", "IT")returns+39669821234; the right number is+390669821234. San Marino fails the same way (0549 882 555becomes+378549882555). The docstring ofcombinesays that where a country has no trunk prefix "nothing happens", but no such exception is coded.+12125551234or+14165551234decompresses toAG,+358401234567toAX,+74951234567toKZ,+212612345678toEH,+590590123456toBLand+5999123456toBQ. The edit form therefore shows that country and its flag beside every US, Canadian, Finnish, Russian, Moroccan, Guadeloupean and Curaçao number. Saving again keeps the same digits, so the second mistake is on screen only, but a Finnish reader meets it on every Finnish number.phones.pysays a number can be fixed; the second puts a wrong, and for Western Sahara a politically loaded, flag beside ordinary numbers.phonenumberslite). Parsing with the chosen region keeps the Italian leading zero, andregion_code_for_numberresolves a shared code by number range; #304's tests name "a country with no trunk prefix" but neither case here, so add them there. Ifcombinesurvives #304 in any form, keep the zero forIT,SMandVA, and give each shared code a main country instead of the alphabetical first (USfor 1,RUfor 7,FIfor 358,MAfor 212,GPfor 590,CWfor 599).Done when
tests/test_phones.pyasserts thatcombine("06 6982 1234", "IT")is+390669821234, and thatcountry_ofanswersUSfor+12125551234,FIfor+358401234567,RUfor+74951234567andMAfor+212612345678; all four fail today.