Skip to content

Accept uppercase X as the ISBN-10 check digit - #31

Closed
vitalivo wants to merge 1 commit into
daveoncode:masterfrom
vitalivo:fix/isbn10-x-check-digit
Closed

vitalivo wants to merge 1 commit into
daveoncode:masterfrom
vitalivo:fix/isbn10-x-check-digit

Conversation

@vitalivo

Copy link
Copy Markdown

is_isbn_10('080442957X') and is_isbn('080442957X') currently return False because the checksum loop tries to convert the final X with int().

Treat an uppercase X in the tenth position as 10, as specified in the Library of Congress ISBN structure documentation. Other positions and lowercase x remain invalid, and the ISBN-13 calculation is unchanged.

Tests cover two valid X-ending ISBNs, hyphen normalization, disabled normalization, an incorrect checksum, and misplaced/repeated X characters. Four assertions fail before the fix; all 409 tests pass with python -m unittest discover on Python 3.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant