lists.arthurdejong.org
RSS feed

Re: stdnum.se.personnummer is_valid is crashing under a given input

[Date Prev][Date Next] [Thread Prev][Thread Next]

Re: stdnum.se.personnummer is_valid is crashing under a given input



Hi,

It seems that your number is wrong. You are using 19670- as birdth date but is this is only 5 digits while it should be 6.

Am I right?


El 12/2/20 a les 10:38, Avishay Balderman ha escrit:

Hi

Thanks for the great library – it really helps us 😊

 

I have code that calls the is_valid method of  stdnum.se.personnummer.

The input I am sending is “breaking” the birthday calculation and I believe should be fixed.

The code below reproduces the issue

 

from stdnum.se.personnummer import is_valid

is_valid('19670-19-9535')

 

The output is:

 

Traceback (most recent call last):

  File "C:/dev/projects/waf-ai-repo/reproduce_stdnum_issue.py", line 3, in <module>

    is_valid('19670-19-9535')

  File "C:\dev\tools\python371\lib\site-packages\stdnum\se\personnummer.py", line 118, in is_valid

    return bool(validate(number))

  File "C:\dev\tools\python371\lib\site-packages\stdnum\se\personnummer.py", line 110, in validate

    get_birth_date(number)

  File "C:\dev\tools\python371\lib\site-packages\stdnum\se\personnummer.py", line 73, in get_birth_date

    month = int(number[4:6])

ValueError: invalid literal for int() with base 10: '0-'

 

 

Thanks

 

Avishay

 

 

Sent from Mail for Windows 10

 


-- 
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk