I think the current implementation of _calculate_checksum in InternationalStandardSerialNumber is wrong. Indeed, the tmp variable sometimes assume the value of "11", while should probably be "0", making the checksum two digits long!
This is a minimum replicating example:
from barcode import ISSN
print(ISSN("6727893").issn) # output = 672789311 when should be 67278930
Simply adding and extra %11 operation at the end of the tmp computation should solve the issue:
def _calculate_checksum(self):
tmp = (
11
- sum(x * int(y) for x, y in enumerate(reversed(self.issn[:7]), start=2))
% 11
) % 11
if tmp == 10:
return "X"
return tmp
For reference:
|
def _calculate_checksum(self): |
I think the current implementation of
_calculate_checksuminInternationalStandardSerialNumberis wrong. Indeed, the tmp variable sometimes assume the value of "11", while should probably be "0", making the checksum two digits long!This is a minimum replicating example:
Simply adding and extra
%11operation at the end of thetmpcomputation should solve the issue:For reference:
python-barcode/barcode/isxn.py
Line 110 in 389dc5f