jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/323676 )
Change subject: isbn.py: convertIsbn10toIsbn13 should not fail for ISBN13 ......................................................................
isbn.py: convertIsbn10toIsbn13 should not fail for ISBN13
ISBN13 objects don't have a toISBN13 method, do not try to call that method on ISBN13 objects.
The patch was originally introduced in a8008a210585759ac46f962eb2d6bd1ebad0460c by Aadith1996, but reverted to fix minor issues.
Bug: T138911 Change-Id: I47118f6aa18cb659d1f9f96cdab93615e24af07b --- M scripts/isbn.py M tests/isbn_tests.py 2 files changed, 10 insertions(+), 1 deletion(-)
Approvals: jenkins-bot: Verified Whym: Looks good to me, approved
diff --git a/scripts/isbn.py b/scripts/isbn.py index f1e1a4b..cfd1fbb 100755 --- a/scripts/isbn.py +++ b/scripts/isbn.py @@ -1466,7 +1466,11 @@ except InvalidIsbnException: # don't change return isbn - i13 = getIsbn(isbn).toISBN13() + i1x = getIsbn(isbn) + if not isinstance(i1x, ISBN13): + i13 = i1x.toISBN13() + else: + i13 = i1x return i13.code
diff --git a/tests/isbn_tests.py b/tests/isbn_tests.py index 701c50d..da97687 100644 --- a/tests/isbn_tests.py +++ b/tests/isbn_tests.py @@ -138,6 +138,11 @@ 'ISBN 978-0-9752298-0-4') self.assertEqual(convertIsbn10toIsbn13('ISBN 0-9752298-0-1'), 'ISBN 0-9752298-0-1') # Invalid ISBN - no changes + # Should not fail for ISBN13 + self.assertEqual( + convertIsbn10toIsbn13('ISBN 978-0-7869-3669-4'), + 'ISBN 978-0-7869-3669-4' + )
# Errors isbn = ISBN10('9492098059')
pywikibot-commits@lists.wikimedia.org