Page MenuHomePhabricator

PWB listpages: -linter and -ns arguments have an ordering dependency
Open, LowPublic

Description

This does not work:

python pwb.py listpages -linter:misnested-tag -ns:Wikisource

But this does:

python pwb.py listpages -ns:Wikisource -linter:misnested-tag

The error from the former is :

Traceback (most recent call last):
  File "/opt/pywikibot/pwb.py", line 363, in <module>
    if not main():
  File "/opt/pywikibot/pwb.py", line 355, in main
    run_python_file(filename,
  File "/opt/pywikibot/pwb.py", line 74, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File "./scripts/listpages.py", line 284, in <module>
    main()
  File "./scripts/listpages.py", line 216, in main
    gen_factory.handleArg(arg)
  File "/opt/pywikibot/pywikibot/pagegenerators.py", line 1207, in handleArg
    handler_result = handler(value)
  File "/opt/pywikibot/pywikibot/pagegenerators.py", line 900, in _handle_namespaces
    assert not isinstance(self._namespaces, frozenset)
AssertionError
CRITICAL: Exiting due to uncaught exception <class 'AssertionError'>

Other filters like -ql seems to work fine after the -linter parameter.

Version:

Pywikibot: [https] r-pywikibot-core.git (1a11f78, g14378, 2021/03/08, 18:42:14, master)
Release version: 6.0.0.dev0

Event Timeline

This is the same problem as T119940. See also the documentation (-help) string:

-namespaces         Filter the page generator to only yield pages in the
-namespace          specified namespaces. Separate multiple namespace
-ns                 numbers or names with commas.
                    ...
                    If used with -newpages/-random/-randomredirect/linter
                    generators, -namespace/ns must be provided before
                    -newpages/-random/-randomredirect/linter.

Change 670163 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [doc] Raise a RuntimeError if -namespace is provided to late

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

Xqt triaged this task as Low priority.

@Xqt well now I feel silly. The new error handling makes it much clearer for dummies. Thanks!

@Xqt well now I feel silly. The new error handling makes it much clearer for dummies. Thanks!

I haven't recognized that behaviour but maybe we can give up this restriction. I made some tests and it looks good. Therefore I keep this Task open.

Change 670163 merged by jenkins-bot:
[pywikibot/core@master] [doc] Raise a RuntimeError if -namespace is provided too late

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

Xqt removed Xqt as the assignee of this task.Mar 10 2021, 6:31 AM