Page MenuHomePhabricator

listpages -cat throws exception
Closed, ResolvedPublic

Description

After working around T128991, I can reproduce an error that I see also on travis en.wp builds https://travis-ci.org/wikimedia/pywikibot-core/jobs/113989337

FAIL: test_pagegen_i18n_input (tests.i18n_tests.InputTestCase)
Test i18n.input via .
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/wikimedia/pywikibot-core/tests/i18n_tests.py", line 380, in test_pagegen_i18n_input
    self.assertIn('Please enter the category name:', result['stderr'])
AssertionError: u'Please enter the category name:' not found in u'No handlers could be found for logger "pywiki"\nTraceback (most recent call last):\n  File "/home/travis/build/wikimedia/pywikibot-core/pwb.py", line 256, in <module>\n    if not main():\n  File "/home/travis/build/wikimedia/pywikibot-core/pwb.py", line 250, in main\n    run_python_file(filename, [filename] + args, argvu, file_package)\n  File "/home/travis/build/wikimedia/pywikibot-core/pwb.py", line 121, in run_python_file\n    main_mod.__dict__)\n  File "./scripts/listpages.py", line 277, in <module>\n    main()\n  File "./scripts/listpages.py", line 214, in main\n    genFactory.handleArg(arg)\n  File "/home/travis/build/wikimedia/pywikibot-core/pywikibot/pagegenerators.py", line 674, in handleArg\n    gen = self.getCategoryGen(value, recurse=recurse, gen_func=gen_func)\n  File "/home/travis/build/wikimedia/pywikibot-core/pywikibot/pagegenerators.py", line 524, in getCategoryGen\n    cat, startfrom = self.getCategory(category)\n  File "/home/travis/build/wikimedia/pywikibot-core/pywikibot/pagegenerators.py", line 486, in getCategory\n    if category.startswith(\'-\'):  # old arg parameter\nAttributeError: \'NoneType\' object has no attribute \'startswith\'\nCRITICAL: Closing network session.\n'

Restructuring that, the error is

No handlers could be found for logger "pywiki"
Traceback (most recent call last):
  File "/home/travis/build/wikimedia/pywikibot-core/pwb.py", line 256, in <module>
    if not main():
  File "/home/travis/build/wikimedia/pywikibot-core/pwb.py", line 250, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "/home/travis/build/wikimedia/pywikibot-core/pwb.py", line 121, in run_python_file
    main_mod.__dict__)
  File "./scripts/listpages.py", line 277, in <module>
    main()
  File "./scripts/listpages.py", line 214, in main
    genFactory.handleArg(arg)
  File "/home/travis/build/wikimedia/pywikibot-core/pywikibot/pagegenerators.py", line 674, in handleArg
    gen = self.getCategoryGen(value, recurse=recurse, gen_func=gen_func)
  File "/home/travis/build/wikimedia/pywikibot-core/pywikibot/pagegenerators.py", line 524, in getCategoryGen
    cat, startfrom = self.getCategory(category)
  File "/home/travis/build/wikimedia/pywikibot-core/pywikibot/pagegenerators.py", line 486, in getCategory
    if category.startswith('-'):  # old arg parameter
AttributeError: 'NoneType' object has no attribute 'startswith'
CRITICAL: Closing network session.

Event Timeline

Easily reproduced with $ python pwb.py listpages -cat

git bisect identifies the problem as 343b875

Change 275272 had a related patch set uploaded (by John Vandenberg):
Fix -cat pagegenerator

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

Change 275272 merged by jenkins-bot:
Fix -cat pagegenerator

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

jayvdb claimed this task.

Change 269855 had a related patch set uploaded (by Xqt):
[bugfix] category parameter for getCategory may be None

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

Change 269855 abandoned by Xqt:
[bugfix] category parameter for getCategory may be None

Reason:
Already done in Ifca4c65737e1f67f145

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