@@ -57,7 +57,7 @@ def __init__(self,
5757 country_code = None ,
5858 national_number = None ,
5959 extension = None ,
60- italian_leading_zero = False ,
60+ italian_leading_zero = None ,
6161 number_of_leading_zeros = None ,
6262 raw_input = None ,
6363 country_code_source = None ,
@@ -119,8 +119,18 @@ def __init__(self,
119119 #
120120 # Clients who use the parsing functionality of the i18n phone number
121121 # libraries will have these fields set if necessary automatically.
122- self .italian_leading_zero = bool (italian_leading_zero )
123- self .number_of_leading_zeros = number_of_leading_zeros # None or int
122+ #
123+ # None if not set, of type bool otherwise:
124+ if italian_leading_zero is None :
125+ self .italian_leading_zero = None
126+ else :
127+ self .italian_leading_zero = bool (italian_leading_zero )
128+
129+ # None if not set, of type int otherwise.
130+ if number_of_leading_zeros is None :
131+ self .number_of_leading_zeros = None
132+ else :
133+ self .number_of_leading_zeros = int (number_of_leading_zeros )
124134
125135 # The next few fields are non-essential fields for a phone number.
126136 # They retain extra information about the form the phone number was
@@ -156,7 +166,7 @@ def clear(self):
156166 self .country_code = None
157167 self .national_number = None
158168 self .extension = None
159- self .italian_leading_zero = False
169+ self .italian_leading_zero = None
160170 self .number_of_leading_zeros = None
161171 self .raw_input = None
162172 self .country_code_source = None
@@ -187,7 +197,7 @@ def __eq__(self, other):
187197 return (self .country_code == other .country_code and
188198 self .national_number == other .national_number and
189199 self .extension == other .extension and
190- self .italian_leading_zero == other .italian_leading_zero and
200+ bool ( self .italian_leading_zero ) == bool ( other .italian_leading_zero ) and
191201 self .number_of_leading_zeros == other .number_of_leading_zeros and
192202 self .raw_input == other .raw_input and
193203 self .country_code_source == other .country_code_source and
@@ -231,7 +241,7 @@ def __hash__(self):
231241 return hash ((self .country_code ,
232242 self .national_number ,
233243 self .extension ,
234- self .italian_leading_zero ,
244+ bool ( self .italian_leading_zero ) ,
235245 self .number_of_leading_zeros ,
236246 self .raw_input ,
237247 self .country_code_source ,
0 commit comments