Page MenuHomePhabricator

clean_sandbox.py: uncaught exception: TypeError: unsupported operand type(s) for -: 'NoneType' and 'datetime.timedelta'
Closed, ResolvedPublicBUG REPORT

Description

Commandline:

python3 pwb.py clean_sandbox -lang:ar -family:wikibooks

Output:

WARNING: /mnt/nfs/labstore-secondary-tools-home/meno25/core/pywikibot/tools/__init__.py:1449: UserWarning: Site wikipedia:be-tarask instantiated using different code "be-x-old"
  return obj(*__args, **__kw)

Preparing to process sandbox page [[ويكي الكتب:ساحة اللعب]]
Traceback (most recent call last):
  File "pwb.py", line 363, in <module>
    if not main():
  File "pwb.py", line 358, in main
    file_package)
  File "pwb.py", line 75, in run_python_file
    main_mod.__dict__)
  File "./scripts/clean_sandbox.py", line 301, in <module>
    main()
  File "./scripts/clean_sandbox.py", line 297, in main
    bot.run()
  File "./scripts/clean_sandbox.py", line 228, in run
    delta = self.opt.delay_td - edit_delta
TypeError: unsupported operand type(s) for -: 'NoneType' and 'datetime.timedelta'
CRITICAL: Exiting due to uncaught exception <class 'TypeError'>

Note:

  • The specific line in the error:
delta = self.opt.delay_td - edit_delta

was recently changed in rPWBCe3c9d3c507d2212c9e0dcacf64a05dccb890cb1d (related to T264721: Rewrite scripts using new option handler)

so, it is probably the cause of this error.

Event Timeline

Meno25 created this task.Nov 11 2020, 8:46 AM
Restricted Application added subscribers: pywikibot-bugs-list, alaa, Aklapper. · View Herald TranscriptNov 11 2020, 8:46 AM
Meno25 updated the task description. (Show Details)Nov 11 2020, 8:48 AM
Xqt claimed this task.Nov 11 2020, 9:52 AM
Xqt triaged this task as Medium priority.
Xqt changed the subtype of this task from "Task" to "Bug Report".

Change 640670 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [bugfix] fix TypeError in clean_sandbox.py

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

Change 640670 merged by jenkins-bot:
[pywikibot/core@master] [bugfix] fix TypeError in clean_sandbox.py

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

Meno25 closed this task as Resolved.Nov 11 2020, 11:15 AM
Mpaa added a subscriber: Mpaa.Nov 11 2020, 4:09 PM

@Xqt shouldn't self.available_options['delay_td'] be accessible also via self.opt.delay_td also after setting a new value?

Xqt added a comment.Nov 25 2020, 5:41 AM

@Xqt shouldn't self.available_options['delay_td'] be accessible also via self.opt.delay_td also after setting a new value?

No because available_options holds default settings for set_options method. Changing it after options are set via OptionHandler initialiser does not change the opt options itself.