From 3b2a610ea90b72f56339baf976fbe022aa16b06f Mon Sep 17 00:00:00 2001 From: santhreal <64453045+santhreal@users.noreply.github.com> Date: Fri, 17 Jul 2026 21:40:28 -0700 Subject: [PATCH 1/2] fix: stop ISBN-10/ISSN digits from truncating EAN-13 payload Subclass digits overrode EuropeanArticleNumber13.digits, so get_fullcode() returned a truncated barcode while str() still showed the correct ISBN/ISSN. --- barcode/isxn.py | 8 ++++---- tests/test_checksums.py | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/barcode/isxn.py b/barcode/isxn.py index 5fca250..56159cd 100755 --- a/barcode/isxn.py +++ b/barcode/isxn.py @@ -66,11 +66,11 @@ class InternationalStandardBookNumber10(InternationalStandardBookNumber13): name = "ISBN-10" - digits = 9 + isbn_digits = 9 def __init__(self, isbn, writer=None) -> None: isbn = isbn.replace("-", "") - isbn = isbn[: self.digits] + isbn = isbn[: self.isbn_digits] super().__init__("978" + isbn, writer) self.isbn10 = isbn self.isbn10 = f"{isbn}{self._calculate_checksum()}" @@ -99,11 +99,11 @@ class InternationalStandardSerialNumber(EuropeanArticleNumber13): name = "ISSN" - digits = 7 + issn_digits = 7 def __init__(self, issn, writer=None) -> None: issn = issn.replace("-", "") - issn = issn[: self.digits] + issn = issn[: self.issn_digits] self.issn = issn self.issn = f"{issn}{self._calculate_checksum()}" super().__init__(self.make_ean(), writer) diff --git a/tests/test_checksums.py b/tests/test_checksums.py index 9913925..6bf8ebb 100755 --- a/tests/test_checksums.py +++ b/tests/test_checksums.py @@ -36,6 +36,9 @@ def test_ean14_checksum() -> None: def test_isbn10_checksum() -> None: isbn = get_barcode("isbn10", "376926085") assert isbn.isbn10 == "3769260856" # type: ignore[attr-defined] + # ISBN-10 is rendered as EAN-13 with a 978 prefix; digits=9 must not + # poison EuropeanArticleNumber13 slicing. + assert isbn.get_fullcode() == "9783769260854" def test_isbn13_checksum() -> None: @@ -53,6 +56,7 @@ def test_issn_checksum_zero() -> None: # not 11. Regression test for issue #238. issn = get_barcode("issn", "6727893") assert issn.issn == "67278930" # type: ignore[attr-defined] + assert issn.get_fullcode() == "9776727893003" def test_issn_checksum_x() -> None: From f56f1fe2db327c778b379ad51e03aee322c9480a Mon Sep 17 00:00:00 2001 From: santhreal <64453045+santhreal@users.noreply.github.com> Date: Fri, 17 Jul 2026 21:50:13 -0700 Subject: [PATCH 2/2] style: align ISBN-10 fullcode comment with isbn_digits --- tests/test_checksums.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_checksums.py b/tests/test_checksums.py index 6bf8ebb..7d00019 100755 --- a/tests/test_checksums.py +++ b/tests/test_checksums.py @@ -36,8 +36,7 @@ def test_ean14_checksum() -> None: def test_isbn10_checksum() -> None: isbn = get_barcode("isbn10", "376926085") assert isbn.isbn10 == "3769260856" # type: ignore[attr-defined] - # ISBN-10 is rendered as EAN-13 with a 978 prefix; digits=9 must not - # poison EuropeanArticleNumber13 slicing. + # ISBN-10 renders as EAN-13; isbn_digits must not shadow EAN digits. assert isbn.get_fullcode() == "9783769260854"