Skip to content

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

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

Accept uppercase X as the ISBN-10 check digit#32
vitalivo wants to merge 1 commit into
daveoncode:masterfrom
vitalivo:fix/isbn10-x-check-digit

Conversation

@vitalivo

Copy link
Copy Markdown

This replaces #31, which was accidentally closed and its source fork deleted. The implementation is unchanged; the original discussion and reviews remain linked there.


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