ema / pycodicefiscale

Python library for handling Italian fiscal code, officially known as Italy's Codice Fiscale
http://pypi.python.org/pypi/codicefiscale/
GNU Lesser General Public License v2.1
14 stars 12 forks source link

Error with apostrophes #7

Open fermo111 opened 9 years ago

fermo111 commented 9 years ago

There is an error when the last name is 3 characters long and contains an apostrophe. E.g.: FO'

valholl commented 9 years ago

This is the error:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/codicefiscale.py", line 161, in build
    output = __surname_triplet(surname) + __name_triplet(name)
  File "/usr/lib/python2.7/dist-packages/codicefiscale.py", line 94, in __surnam
e_triplet
    return __common_triplet(input_string, consonants, vowels)
  File "/usr/lib/python2.7/dist-packages/codicefiscale.py", line 71, in __common
_triplet
    output += vowels.pop(0)
IndexError: pop from empty list

And also happens when the surname is just one character long.

(I will look into it more in detail in the next few days, and possibly propose a patch.)