Page MenuHomePhabricator

cosmetic_changes.py: uncaught exception <class 'stdnum.exceptions.InvalidLength'>The number has an invalid length
Closed, DuplicatePublic

Description

Command line:

python pwb.py cosmetic_changes -site:wikibooks:ar -page:"الوسط البيئي (الجزء 1)"

Output:

Retrieving 1 pages from wikibooks:ar.

>>> الوسط البيئي (الجزء 1) <<<

0 pages read
0 pages written
0 pages skipped
Execution time: 0 seconds
Script terminated by exception:

ERROR: InvalidLength: The number has an invalid length.
Traceback (most recent call last):
  File "C:\Users\Mohammed\Downloads\core\pwb.py", line 365, in <module>
    if not main():
  File "C:\Users\Mohammed\Downloads\core\pwb.py", line 357, in main
    run_python_file(filename,
  File "C:\Users\Mohammed\Downloads\core\pwb.py", line 73, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File ".\scripts\cosmetic_changes.py", line 140, in <module>
    main()
  File ".\scripts\cosmetic_changes.py", line 134, in main
    bot.run()
  File "C:\Users\Mohammed\Downloads\core\pywikibot\bot.py", line 1507, in run
    self.treat(page)
  File "C:\Users\Mohammed\Downloads\core\pywikibot\bot.py", line 1757, in treat
    self.treat_page()
  File ".\scripts\cosmetic_changes.py", line 78, in treat_page
    changed_text = cc_toolkit.change(self.current_page.get())
  File "C:\Users\Mohammed\Downloads\core\pywikibot\cosmetic_changes.py", line 325, in change
    new_text = self._change(text)
  File "C:\Users\Mohammed\Downloads\core\pywikibot\cosmetic_changes.py", line 319, in _change
    text = self.safe_execute(method, text)
  File "C:\Users\Mohammed\Downloads\core\pywikibot\cosmetic_changes.py", line 306, in safe_execute
    result = method(text)
  File "C:\Users\Mohammed\Downloads\core\pywikibot\cosmetic_changes.py", line 1097, in fix_ISBN
    return _reformat_ISBNs(text, strict=self.ignore != CANCEL_MATCH)
  File "C:\Users\Mohammed\Downloads\core\pywikibot\cosmetic_changes.py", line 205, in _reformat_ISBNs
    return textlib.reformat_ISBNs(
  File "C:\Users\Mohammed\Downloads\core\pywikibot\textlib.py", line 1965, in reformat_ISBNs
    text = isbnR.sub(match_func, text)
  File "C:\Users\Mohammed\Downloads\core\pywikibot\cosmetic_changes.py", line 206, in <lambda>
    text, lambda match: _format_isbn_match(match, strict=strict))
  File "C:\Users\Mohammed\Downloads\core\pywikibot\cosmetic_changes.py", line 190, in _format_isbn_match
    stdnum_isbn.validate(isbn)
  File "C:\Users\Mohammed\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\stdnum\isbn.py", line 105, in validate
    raise InvalidLength()
stdnum.exceptions.InvalidLength: The number has an invalid length.
CRITICAL: Exiting due to uncaught exception <class 'stdnum.exceptions.InvalidLength'>

Output of version.py:

Pywikibot: [https] r-pywikibot-core (c97951b, g14953, 2021/05/27, 16:56:53, master)
Release version: 6.2.0.dev0
requests version: 2.25.1
    certificate test: ok
Python: 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]

Event Timeline

Xqt triaged this task as High priority.

@Meno25: Use -ignore:match option or one of the other ignoring parameters:

-ignore:          Ignores if an error occurred and either skips the page or
                  only that method. It can be set to 'page' or 'method'.

@Meno25: Use -ignore:match option or one of the other ignoring parameters:

-ignore:          Ignores if an error occurred and either skips the page or
                  only that method. It can be set to 'page' or 'method'.

Thank you very much for your comment. Much appreciated.