Skip to content

EAN13 calculate_checksum() generates inconsistent values #196

@zspherez

Description

@zspherez

When using the EAN13() constructor with a 12 digit argument to create an EAN13, the check digit generated in the constructor is different than if you were to call calculate_checksum() on the 13 digit value returned by the constructor.

>>> EAN13("842169142322")
<EuropeanArticleNumber13('8421691423220')>

gives that the check digit is 0

>>> ean = EAN13("842169142322")
>>> ean
<EuropeanArticleNumber13('8421691423220')>
>>> ean.calculate_checksum()
4

implying that the check digit is 4

This seems to be due to the fact that when calculate_checksum() is called on a 13 digit EAN via the object itself, the reverse traversal that is used in the method includes the 13th digit when summing and calculating the check digit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions