lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.2-1-gfb0efe0

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

python-stdnum branch master updated. 1.2-1-gfb0efe0



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  fb0efe0e35d4dc3e3fdff87fdf5150ed3368f58d (commit)
      from  13618173f72ed2c014869ad9a4366b26f1d1e5d3 (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 -----------------------------------------------------------------
http://arthurdejong.org/git/python-stdnum/commit/?id=fb0efe0e35d4dc3e3fdff87fdf5150ed3368f58d

commit fb0efe0e35d4dc3e3fdff87fdf5150ed3368f58d
Author: Ronald Paloschi <ronald.paloschi@gmail.com>
Date:   Thu Oct 15 22:03:13 2015 -0300

    Fix for when ISO 6346 checksum is 10
    
    Bug fix for when the checksum is 10, it was compared to 0 and failed.
    New doctest exposing the bug that passes after the fix is applied.
    
    See: https://github.com/arthurdejong/python-stdnum/pull/30

diff --git a/stdnum/iso6346.py b/stdnum/iso6346.py
index 7958bff..5b936fc 100644
--- a/stdnum/iso6346.py
+++ b/stdnum/iso6346.py
@@ -59,7 +59,7 @@ def calc_check_digit(number):
     alphabet = '0123456789A BCDEFGHIJK LMNOPQRSTU VWXYZ'
     return str(sum(
         alphabet.index(n) * pow(2, i)
-        for i, n in enumerate(number)) % 11)
+        for i, n in enumerate(number)) % 11 % 10)
 
 
 def validate(number):
diff --git a/tests/test_iso6346.doctest b/tests/test_iso6346.doctest
index 32b67ea..a6b2f49 100644
--- a/tests/test_iso6346.doctest
+++ b/tests/test_iso6346.doctest
@@ -39,6 +39,8 @@ True
 'TCNU7200794'
 >>> iso6346.validate('tolu4734787')
 'TOLU4734787'
+>>> iso6346.validate('GYOU4047990')
+'GYOU4047990'
 
 
 Test with invalid numbers:

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

Summary of changes:
 stdnum/iso6346.py          |    2 +-
 tests/test_iso6346.doctest |    2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
python-stdnum
-- 
To unsubscribe send an email to
python-stdnum-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/python-stdnum-commits/