Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing phone numbers with double leading 1's #277

Closed
etekin-amfam opened this issue Jul 28, 2023 · 3 comments
Closed

Error parsing phone numbers with double leading 1's #277

etekin-amfam opened this issue Jul 28, 2023 · 3 comments
Labels

Comments

@etekin-amfam
Copy link

I am using phonenumberslite 8.13.16, and noticed that when I parse a US code in the format 1(1XX)YYY-YYYY, the national number is parsed incorrectly as XXYYYYYYY instead of 1XXYYYYYYY. This does seem to be present in the Java version as well, see 1(123)4567890 , which is parsed incorrectly, vs 1(223)4567890, which is parsed incorrectly.

import phonenumbers as pn
wrong_no = pn.parse('11234567890', region='US') #wrong
correct_no = pn.parse('12234567890', region='US') #correct

Putting a + sign in front does resolve the issue:

correct_no = pn.parse('+11234567890', region='US') #correct

I have noticed the issue using python 3.9 and 3.10.

@MrMineev
Copy link

MrMineev commented Jul 28, 2023

The phone number "1 (123) 456 7890" is invalid. The phone US phone numbers have this syntax 1(NXX) NXX-XXXX, where N represents any digit from 2 to 9, and X represents any digit from 0 to 9. (https://www.quora.com/What-is-the-American-mobile-phone-number-format) (https://en.wikipedia.org/wiki/North_American_Numbering_Plan)

@etekin-amfam
Copy link
Author

etekin-amfam commented Jul 28, 2023

The phone number "1 (123) 456 7890" is invalid. The phone US phone numbers have this syntax 1(NXX) NXX-XXXX, where N represents any digit from 2 to 9, and X represents any digit from 0 to 9. (https://www.quora.com/What-is-the-American-mobile-phone-number-format) (https://en.wikipedia.org/wiki/North_American_Numbering_Plan)

That is true, but the code does not raise an Exception, just returns an incorrectly parsed number, so it is still an issue as the downstream code has no way of knowing the number was incorrect. Furthermore, if you do enter +11234567890, it does not complain that it is an invalid number.

@daviddrysdale
Copy link
Owner

The Python code is behaving the same as the upstream Java code here, so any requested/suggested changes to behaviour should be reported upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants