Arg0s1080 / mrz

Machine Readable Zone generator and checker for official travel documents sizes 1, 2, 3, MRVA and MRVB (Passports, Visas, national id cards and other travel documents)
GNU General Public License v3.0
328 stars 122 forks source link

Undefined variable 's' in Precheck method #26

Closed rutgervandriel closed 3 years ago

rutgervandriel commented 3 years ago

Hello,

I ran into the following bug when calling the precheck method:

raise LengthError(cause=len(s), document=document_description, length=length)
NameError: name 's' is not defined

Having a look at precheck method in string_checkers.py in 0.5.8 I observe the following:


def precheck(document_description: str, string: str, length: int):
    s = string.replace("\n", "")
    if _is_string(_check_upper(string)) and len(s) != length:
        raise LengthError(cause=len(s), document=document_description, length=length)
    if not is_printable(s):
        raise FieldError("%s contains invalid characters" % document_description, s)

Having a look at precheck method in string_checkers.py in 0.6.1 I observe the following:

def precheck(document_description: str, string: str, length: int):
    if check_string(_check_upper(string)) and len(string) != length:
        raise LengthError(cause=len(s), document=document_description, length=length)
    if not is_printable(string, "\n"):
        raise FieldError("%s contains invalid characters" % document_description, s)

Since the removal of s = string.replace("\n", "") there is no defined variable s anymore. Both the LengthError and FieldError reference to this. I believe it should be string instead of s now.

Arg0s1080 commented 3 years ago

Hi!

Its true! Honestly i dont know what happened. Quite few things have been changed. Some error must have occurred during the process. My bad...

Fixed and released v0.6.2

Thank you very much

rutgervandriel commented 3 years ago

No worries, thanks for the fix!