-
-
Notifications
You must be signed in to change notification settings - Fork 133
Open
Description
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 67278930Simply 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 tmpFor reference:
python-barcode/barcode/isxn.py
Line 110 in 389dc5f
| def _calculate_checksum(self): |
Metadata
Metadata
Assignees
Labels
No labels