lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.17-2-g02dec52

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

python-stdnum branch master updated. 1.17-2-g02dec52



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".

The branch, master has been updated
       via  02dec52602ae0709b940b781fc1fcebfde7340b7 (commit)
      from  dcf47300aa522ad4a76c9062e10f7ef4e627e204 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=02dec52602ae0709b940b781fc1fcebfde7340b7

commit 02dec52602ae0709b940b781fc1fcebfde7340b7
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sun Jan 9 17:09:19 2022 +0100

    Fix disabling check digit validation of Mexican CURP
    
    The validation functions supported an optional parameter to disable
    check digit validation in the number that didn't actually affect
    validation and was most likely accidentally copied from the RFC module.
    
    Fixes 50874a9
    Closes https://github.com/arthurdejong/python-stdnum/issues/285

diff --git a/stdnum/mx/curp.py b/stdnum/mx/curp.py
index 0e05b74..e9dadd1 100644
--- a/stdnum/mx/curp.py
+++ b/stdnum/mx/curp.py
@@ -109,7 +109,7 @@ def calc_check_digit(number):
     return str((10 - check % 10) % 10)
 
 
-def validate(number, validate_check_digits=False):
+def validate(number, validate_check_digits=True):
     """Check if the number is a valid CURP."""
     number = compact(number)
     if len(number) != 18:
@@ -122,12 +122,12 @@ def validate(number, validate_check_digits=False):
     get_gender(number)
     if number[11:13] not in _valid_states:
         raise InvalidComponent()
-    if number[-1] != calc_check_digit(number):
+    if validate_check_digits and number[-1] != calc_check_digit(number):
         raise InvalidChecksum()
     return number
 
 
-def is_valid(number, validate_check_digits=False):
+def is_valid(number, validate_check_digits=True):
     """Check if the number provided is a valid CURP."""
     try:
         return bool(validate(number, validate_check_digits))

-----------------------------------------------------------------------

Summary of changes:
 stdnum/mx/curp.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
python-stdnum