stefanfoulis/django-phonenumber-field — pull request #49 by cormier (2014-10-17 22:17:07+00:00)
Title: Let python-phonenumbers compare PhoneNumber instances

in `phonenumber.py`, the overridden `__eq__` converts the number to e_164 before the comparison:
```python
def __eq__(self, other):
if type(other) == PhoneNumber:
return self.as_e164 == other.as_e164
else:
return super(PhoneNumber, self).__eq__(other)
```
It seems that the e_164 conversion does not include the extension, and it causes a comparison of two PhoneNumbers to be erroneous when only the extension is divergent. For example:
```python
> other
PhoneNumber(country_code=1, national_number=8005551234, extension='2', italian_leading_zero=None, number_of_leading_zeros=None, country_code_source=20, preferred_domestic_carrier_code='')
> self
PhoneNumber(country_code=1, national_number=8005551234, extension=None, italian_leading_zero=None, number_of_leading_zeros=None, country_code_source=20, preferred_domestic_carrier_code='')
> other == self
True
```
In my opinion, `django-phonenumber-field` should not be involved in the comparison, and should delegate all operations that involve phone number logic to `python-phonenumbers`.