Page MenuHomePhabricator

BasePage.get erroneously raises SectionError when the page contains the section
Closed, ResolvedPublicBUG REPORT

Description

Consecutive spaces are not normalized, resulting in erroneous SectionError.

2026-04-09 12:47:17         logging.py,  355 in          exception: ERROR    'Radio stations in India by state' is not a valid section of Wikipedia:Categories for discussion/Log/2026 March 31
Traceback (most recent call last):
  File "/data/project/jjmc89-bot/repos/jjmc89-bot-scripts/enwiki/cfdw.py", line 338, in parse
    self._parse_section(str(section))
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/data/project/jjmc89-bot/repos/jjmc89-bot-scripts/enwiki/cfdw.py", line 375, in _parse_section
    _, action = cfd.get_result_action(
                ~~~~~~~~~~~~~~~~~~~~~^
        instruction["bot_options"]["old_cat"]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/data/project/jjmc89-bot/repos/jjmc89-bot-scripts/enwiki/cfdw.py", line 284, in get_result_action
    text = removeDisabledParts(self.text, tags=EXCEPTIONS, site=self.site)
                               ^^^^^^^^^
  File "/data/project/jjmc89-bot/repos/.venvs/jjmc89-bot-scripts/lib/python3.13/site-packages/pywikibot/page/_basepage.py", line 580, in text
    return self.get(get_redirect=True)
           ~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/data/project/jjmc89-bot/repos/.venvs/jjmc89-bot-scripts/lib/python3.13/site-packages/pywikibot/page/_basepage.py", line 395, in get
    raise SectionError(f'{page_section!r} is not a valid section '
                       f'of {self.title(with_section=False)}')
pywikibot.exceptions.SectionError: 'Radio stations in India by state' is not a valid section of Wikipedia:Categories for discussion/Log/2026 March 31

What should have happened instead?:

SectionError is not raised since the page contains ==== Radio stations in India by state ==== (making Radio stations in India by state a valid section).

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Pywikibot: pywikibot/__init__.py (, -1 (unknown), 2026/04/09, 15:26:34, UNKNOWN)
Release version: 11.1.0
packaging version: 26.0
mwparserfromhell version: 0.7.2
wikitextparser version: n/a
requests version: 2.33.1
  cacerts: /data/project/jjmc89-bot/repos/.venvs/jjmc89-bot-scripts/lib/python3.13/site-packages/certifi/cacert.pem
    certificate test: ok
Python: 3.13.5 (main, Jun 25 2025, 18:55:22) [GCC 14.2.0]
User-Agent: JJMC89_bot_III/version (wikipedia:en; User:JJMC89_bot_III) Pywikibot/11.1.0 (-1 (unknown)) Python/3.13.5.final.0 requests/2.33.1
PYWIKIBOT_DIR: Not set
PYWIKIBOT_DIR_PWB: /data/project/jjmc89-bot/repos/.venvs/jjmc89-bot-scripts/lib/python3.13/site-packages/pywikibot/scripts
PYWIKIBOT_NO_USER_CONFIG: Not set
Config base dir: /data/project/jjmc89-bot/.pywikibot-cfdw
Usernames for family 'wikipedia':
        en: JJMC89 bot III

Details

Related Changes in Gerrit:

Event Timeline

Change #1328725 had a related patch set uploaded (by Mahveotm; author: Mahveotm):

[pywikibot/core@master] page: Do not validate sections in BasePage.get

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

Change #1328725 merged by jenkins-bot:

[pywikibot/core@master] page: Do not validate sections in BasePage.get

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

JJMC89 assigned this task to Mahveotm.
JJMC89 removed a project: Patch-For-Review.