Page MenuHomePhabricator

fixing_redirects.py: Exiting due to uncaught exception IndexError: string index out of range
Open, MediumPublicBUG REPORT

Description

Command line:

python pwb.py fixing_redirects -ignoremoves -cat:"مقالات مختارة" -lang:ar

Output:

>>> نادي برشلونة <<<

666 read operations
95 write operations
Execution time: 7959 seconds
Read operation time: 12.0 seconds
Write operation time: 83.8 seconds
Script terminated by exception:

ERROR: string index out of range (IndexError)
Traceback (most recent call last):
  File "C:\Users\Mohammed\Downloads\core\pwb.py", line 39, in <module>
    sys.exit(main())
             ^^^^^^
  File "C:\Users\Mohammed\Downloads\core\pwb.py", line 35, in main
    runpy.run_path(str(path), run_name='__main__')
  File "<frozen runpy>", line 291, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 514, in <module>
    main()
  File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 498, in main
    if not execute():
           ^^^^^^^^^
  File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 485, in execute
    run_python_file(filename, script_args, module)
  File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 147, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File "C:\Users\Mohammed\Downloads\core\scripts\fixing_redirects.py", line 265, in <module>
    main()
  File "C:\Users\Mohammed\Downloads\core\scripts\fixing_redirects.py", line 259, in main
    bot.run()
  File "C:\Users\Mohammed\Downloads\core\pywikibot\bot.py", line 1677, in run
    self.treat(page)
  File "C:\Users\Mohammed\Downloads\core\pywikibot\bot.py", line 1931, in treat
    self.treat_page()
  File "C:\Users\Mohammed\Downloads\core\scripts\fixing_redirects.py", line 206, in treat_page
    newtext = self.replace_links(newtext, page, target)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mohammed\Downloads\core\scripts\fixing_redirects.py", line 131, in replace_links
    if link_text[0].isupper() or link_text[0].isdigit():
       ~~~~~~~~~^^^
IndexError: string index out of range
CRITICAL: Exiting due to uncaught exception IndexError: string index out of range

What happens?

What should have happened instead?:

  • The bot should have been able to process all the articles in the category without crashing.

Software version:

Pywikibot: [https] r-pywikibot-core (320078b, g17918, 2023/06/12, 13:27:04, master)
Release version: 8.2.0.dev2
setuptools version: 67.8.0
mwparserfromhell version: 0.6.4
wikitextparser version: n/a
requests version: 2.31.0
    certificate test: ok
Python: 3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]

Event Timeline

@Meno25: Any idea what is meant with this link: [[اللغة الكتالونية|:]] Should the : really be the link text here? Seems this old patch was wrong for the section title then.

Xqt triaged this task as Medium priority.Jun 17 2023, 9:00 AM

@Meno25: Any idea what is meant with this link: [[اللغة الكتالونية|:]] Should the : really be the link text here? Seems this old patch was wrong for the section title then.

Hi, @Xqt. You are right. This link is wrong and shouldn't be there. I fixed it in this edit. Then I reran the bot and it worked normally on the article.