Page MenuHomePhabricator

isbn.py -to13 has fatal error when processing an ISBN13
Closed, ResolvedPublic

Description

I run isbn.py and it shows this error

$ python pwb.py isbn.py -to13 -family:wikipedia -lang:en -page:List_of_Dragonlance_novels -simulate
Retrieving 50 pages from wikipedia:fa.
Traceback (most recent call last):
  File "pwb.py", line 248, in <module>
    if not main():
  File "pwb.py", line 242, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "pwb.py", line 120, in run_python_file
    main_mod.__dict__)
  File "./scripts/isbn.py", line 1659, in <module>
    main()
  File "./scripts/isbn.py", line 1652, in main
    bot.run()
  File "./scripts/isbn.py", line 1521, in run
    self.treat(page)
  File "./scripts/isbn.py", line 1496, in treat
    new_text = self.isbnR.sub(_isbn10toIsbn13, new_text)
  File "./scripts/isbn.py", line 1458, in _isbn10toIsbn13
    i13 = getIsbn(isbn).toISBN13()
AttributeError: 'ISBN13' object has no attribute 'toISBN13'
<type 'exceptions.AttributeError'>
CRITICAL: Closing network session.

Event Timeline

jayvdb renamed this task from isbn.py has fatal erro to isbn.py has fatal error.Jul 3 2016, 11:36 AM
jayvdb renamed this task from isbn.py has fatal error to isbn.py -to13 has fatal error when processing an ISBN13.Jul 3 2016, 11:46 AM
jayvdb triaged this task as Medium priority.
jayvdb raised the priority of this task from Medium to High.Jul 3 2016, 12:10 PM
jayvdb subscribed.

This code was modified by 8a87eaecd95 , but the previous code also had the same bug, with the following stacktrace

Retrieving 1 pages from wikipedia:en.
Traceback (most recent call last):
  File "pwb.py", line 222, in <module>
    run_python_file(filename, argv, argvu, file_package)
  File "pwb.py", line 81, in run_python_file
    main_mod.__dict__)
  File "./scripts/isbn.py", line 1553, in <module>
    main()
  File "./scripts/isbn.py", line 1548, in main
    bot.run()
  File "./scripts/isbn.py", line 1422, in run
    self.treat(page)
  File "./scripts/isbn.py", line 1397, in treat
    newText = self.isbnR.sub(_isbn10toIsbn13, newText)
  File "./scripts/isbn.py", line 1359, in _isbn10toIsbn13
    i13 = i.toISBN13()
AttributeError: ISBN13 instance has no attribute 'toISBN13'

The bug comes from 2007. 4c001a42b https://mediawiki.org/wiki/Special:Code/pywikipedia/4262

Change 312720 had a related patch set uploaded (by Aadith1996):
Added a function toISBN13 in the class ISBN13

https://gerrit.wikimedia.org/r/312720

Change 312724 had a related patch set uploaded (by Aadith1996):
Added a function toISBN13 in the class ISBN13

https://gerrit.wikimedia.org/r/312724

Change 312725 had a related patch set uploaded (by Aadith1996):
Added a function toISBN13 in the class ISBN13

https://gerrit.wikimedia.org/r/312725

Change 312726 had a related patch set uploaded (by Aadith1996):
Added a function toISBN13 in the class ISBN13

https://gerrit.wikimedia.org/r/312726

Change 312720 abandoned by Aadith1996:
Added a function toISBN13 in the class ISBN13

Reason:
SOrry, got confused by gerrit git. The final gerrit can be found at https://gerrit.wikimedia.org/r/#/c/312726/

https://gerrit.wikimedia.org/r/312720

Change 312725 abandoned by Aadith1996:
Added a function toISBN13 in the class ISBN13

Reason:
Sorry, got confused by gerrit git. The final gerrit can be found at https://gerrit.wikimedia.org/r/#/c/312726/

https://gerrit.wikimedia.org/r/312725

Change 312724 abandoned by Aadith1996:
Added a function toISBN13 in the class ISBN13

Reason:
Sorry, got confused by gerrit git. The final gerrit can be found at https://gerrit.wikimedia.org/r/#/c/312726/

https://gerrit.wikimedia.org/r/312724

Sorry for the confusion with gerrit.
The final patchset can be found at https://gerrit.wikimedia.org/r/#/c/312726/

Change 312726 merged by jenkins-bot:
Fix isbn.py -to13 operation when ISBN are already in this format

https://gerrit.wikimedia.org/r/312726

Change 323676 had a related patch set uploaded (by Dalba):
isbn.py: convertIsbn10toIsbn13 should not fail for ISBN13

https://gerrit.wikimedia.org/r/323676

Change 323676 merged by jenkins-bot:
isbn.py: convertIsbn10toIsbn13 should not fail for ISBN13

https://gerrit.wikimedia.org/r/323676