WhyNotHugo / python-barcode

㊙️ Create standard barcodes with Python. No external dependencies. 100% Organic Python.
http://python-barcode.rtfd.io/
MIT License
558 stars 123 forks source link

Fixed erroneous calculation in calculate_checksum #213

Closed fra87 closed 11 months ago

fra87 commented 1 year ago

The EAN checksum calculation is correct only if the self.ean variable does not have the checksum value already present. This may not be true in some cases (e.g. someone trying to compare an already present checksum with the library-generated one)

WhyNotHugo commented 11 months ago

Apologies, I missed your PR earlier.

I had written a fix for this same issue (https://github.com/WhyNotHugo/python-barcode/pull/215), but yours is a lot simpler, so I've merged your approach but kept the tests from my PR.