Page MenuHomePhabricator

fixing_redirects.py: Exiting due to uncaught exception SectionError: not a valid section of
Closed, ResolvedPublicBUG REPORT

Description

Command line:

python pwb.py fixing_redirects -ignoremoves -page:"قالب:سكان كندا الاصليين" -lang:arz

Output:

Retrieving 1 pages from wikipedia:arz.


>>> قالب:سكان كندا الاصليين <<<

1 read operation
Execution time: 1 seconds
Read operation time: 1.0 seconds
Script terminated by exception:

ERROR: '.E2.80.8Emin homma el n.C4.81s betu.CA.95 .22Lakota.22.E2.80.8E' is not a valid section of مقالات باللاتينى (SectionError)
Traceback (most recent call last):
  File "C:\Users\Mohammed\Downloads\core\pwb.py", line 40, in <module>
    sys.exit(main())
             ^^^^^^
  File "C:\Users\Mohammed\Downloads\core\pwb.py", line 36, in main
    runpy.run_path(str(path), run_name='__main__')
  File "<frozen runpy>", line 286, 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 521, in <module>
    main()
  File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 505, in main
    if not execute():
           ^^^^^^^^^
  File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 492, in execute
    run_python_file(filename, script_args, module)
  File "C:\Users\Mohammed\Downloads\core\pywikibot\scripts\wrapper.py", line 149, 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 261, in main
    bot.run()
  File "C:\Users\Mohammed\Downloads\core\pywikibot\bot.py", line 1581, in run
    self.treat(page)
  File "C:\Users\Mohammed\Downloads\core\pywikibot\bot.py", line 1834, in treat
    self.treat_page()
  File "C:\Users\Mohammed\Downloads\core\scripts\fixing_redirects.py", line 206, in treat_page
    page, target = future.result()
                   ^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1264.0_x64__qbz5n2kfra8p0\Lib\concurrent\futures\_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1264.0_x64__qbz5n2kfra8p0\Lib\concurrent\futures\_base.py", line 401, in __get_result
    raise self._exception
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1264.0_x64__qbz5n2kfra8p0\Lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mohammed\Downloads\core\scripts\fixing_redirects.py", line 181, in get_target
    if section and not does_text_contain_section(target.text,
                                                 ^^^^^^^^^^^
  File "C:\Users\Mohammed\Downloads\core\pywikibot\page\_basepage.py", line 578, in text
    return self.get(get_redirect=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mohammed\Downloads\core\pywikibot\page\_basepage.py", line 408, in get
    raise SectionError(f'{page_section!r} is not a valid section '
pywikibot.exceptions.SectionError: '.E2.80.8Emin homma el n.C4.81s betu.CA.95 .22Lakota.22.E2.80.8E' is not a valid section of مقالات باللاتينى
CRITICAL: Exiting due to uncaught exception SectionError: '.E2.80.8Emin homma el n.C4.81s betu.CA.95 .22Lakota.22.E2.80.8E' is not a valid section of مقالات باللاتينى

Request:

  • Please fix this SectionError and make the bot ignore this uncaught exception and skip the page in such cases. Thank you.

Software version:

Pywikibot: [https] r-pywikibot-core (4187a2e, g18937, 2024/07/16, 17:16:38, master)
Release version: 9.3.0.dev1
packaging version: 24.1
mwparserfromhell version: 0.6.6
wikitextparser version: 0.56.0
requests version: 2.32.3
    certificate test: ok
Python: 3.12.4 (tags/v3.12.4:8e8a4ba, Jun  6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)]

Event Timeline

Xqt triaged this task as Medium priority.Jul 18 2024, 6:39 AM
Xqt subscribed.

Looks like the section part has to be decoded/unquoted first.

Xqt changed the task status from Open to In Progress.Jul 19 2024, 12:55 PM
Xqt claimed this task.

Change #1055439 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [IMPR] Ignore SectionError in fixing_redirects.py script

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

Change #1055439 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] Ignore SectionError in fixing_redirects.py script

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