Unwanted behaviour of the no_checksum option for EuropeanArticleNumber13 #43

Open
opened 2019-07-01 11:11:35 +02:00 by mzonzon · 3 comments
mzonzon commented 2019-07-01 11:11:35 +02:00 (Migrated from github.com)

If the no_checksum option is passed, A 13 digits code should be accepted as it is.
At the moment, the last digit is replaced by a 0 and it cannot be otherwise:

digits = 12
ean = ean[:self.digits]
# Add a thirteen char if given in parameter,
# otherwise pad with zero
self.ean =  '{0}{1}'.format( ean, ean[self.digits] if len(ean) > self.digits else 0)

len(ean) > self.digits is never going to happen

If the no_checksum option is passed, A 13 digits code should be accepted as it is. At the moment, the last digit is replaced by a 0 and it cannot be otherwise: ```python digits = 12 ean = ean[:self.digits] # Add a thirteen char if given in parameter, # otherwise pad with zero self.ean = '{0}{1}'.format( ean, ean[self.digits] if len(ean) > self.digits else 0) ``` `len(ean) > self.digits` is never going to happen
AlexP11223 commented 2020-12-03 18:25:12 +01:00 (Migrated from github.com)

Bump.
Looks like it is indeed does not work as intended.

>>> barcode.get('ean13')('1234567891234', no_checksum=True)
<EuropeanArticleNumber13('1234567891230')>

instead of 1234567891234.

Bump. Looks like it is indeed does not work as intended. ``` >>> barcode.get('ean13')('1234567891234', no_checksum=True) <EuropeanArticleNumber13('1234567891230')> ``` instead of `1234567891234`.
WhyNotHugo commented 2020-12-03 20:52:31 +01:00 (Migrated from github.com)

Can you confirm if #98 fixes the issue for you?

If so, I'll add some tests and merge it in. Thanks!

Can you confirm if #98 fixes the issue for you? If so, I'll add some tests and merge it in. Thanks!
AlexP11223 commented 2020-12-03 21:35:19 +01:00 (Migrated from github.com)

I am too lazy to figure out how to build/install it :D

But yeah, looks correct.

Maybe adding some validation for the number of digits would be good.

Fix crash

hm, I did not have any crashes. 🤔
Just wrong last digit output like above.

I am too lazy to figure out how to build/install it :D But yeah, looks correct. Maybe adding some validation for the number of digits would be good. > Fix crash hm, I did not have any crashes. :thinking: Just wrong last digit output like above.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
WhyNotHugo/python-barcode#43
No description provided.