Page MenuHomePhabricator

newitem.py: AttributeError: 'function' object has no attribute 'startswith'
Closed, ResolvedPublic

Description

sat@ubuntu-sat2:~/wikipedia/jobs/wikidata/wd_mangler$ python ~/pywikibot/core/pwb.py newitem -file:kat_trin2
Page age is set to 21 days so only pages created
before 2019-02-10T10:49:19Z will be considered.
Last edit is set to 7 days so only pages last edited
before 2019-02-24T10:49:19Z will be considered.
Traceback (most recent call last):
  File "/home/sat/pywikibot/core/pwb.py", line 232, in <module>
    if not main():
  File "/home/sat/pywikibot/core/pwb.py", line 225, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "/home/sat/pywikibot/core/pwb.py", line 94, in run_python_file
    main_mod.__dict__)
  File "/home/sat/pywikibot/core/scripts/newitem.py", line 175, in <module>
    main()
  File "/home/sat/pywikibot/core/scripts/newitem.py", line 159, in main
    user = pywikibot.User(bot.site, bot.site.username)
  File "/home/sat/pywikibot/core/pywikibot/tools/__init__.py", line 1738, in wrapper
    return obj(*__args, **__kw)
  File "/home/sat/pywikibot/core/pywikibot/page.py", line 3183, in __init__
    if title.startswith('#'):
AttributeError: 'function' object has no attribute 'startswith'
CRITICAL: Exiting due to uncaught exception <type 'exceptions.AttributeError'>

How to fix:

sat@ubuntu-sat2:~/pywikibot/core$ git diff scripts/newitem.py
diff --git a/scripts/newitem.py b/scripts/newitem.py
index a2f35959..9744f0f4 100755
--- a/scripts/newitem.py
+++ b/scripts/newitem.py
@@ -156,7 +156,7 @@ def main(*args):
         return False
 
     bot = NewItemRobot(generator, **options)
-    user = pywikibot.User(bot.site, bot.site.username)
+    user = pywikibot.User(bot.site, bot.site.username())
     if bot.getOption('touch') == 'newly' \
             and 'autoconfirmed' not in user.groups():
         pywikibot.warning(fill(

(tip from "valhallasw`cloud" on irc)

Event Timeline

Steenth created this task.Mar 3 2019, 2:50 PM
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptMar 3 2019, 2:50 PM
valhallasw updated the task description. (Show Details)Mar 3 2019, 3:07 PM
Restricted Application added a project: User-Zoranzoki21. · View Herald TranscriptMar 3 2019, 3:42 PM

Change 494041 had a related patch set uploaded (by Zoranzoki21; owner: Zoranzoki21):
[pywikibot/core@master] Fixed AttributeError at newitem.py script

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

Zoranzoki21 renamed this task from bug in newitem.py to newitem.py: AttributeError: 'function' object has no attribute 'startswith'.Mar 3 2019, 3:47 PM
Xqt triaged this task as Normal priority.Mar 3 2019, 4:04 PM
Xqt closed this task as Resolved.
Zoranzoki21 reopened this task as Open.Mar 3 2019, 4:08 PM
Zoranzoki21 added a subscriber: Xqt.

@Xqt Patch wasn't merged.. Please +2 it again.

Change 494041 merged by jenkins-bot:
[pywikibot/core@master] Fixed AttributeError at newitem.py script

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

Xqt closed this task as Resolved.Mar 3 2019, 11:17 PM