NameError: name 'timedelta' is not defined

Bug #2093275 reported by Benjamin Drung
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-sponsoring
Fix Released
Critical
Simon Quigley

Bug Description

Generating the report fails after commit https://git.launchpad.net/ubuntu-sponsoring/commit/?id=a1493abb2b0a95044c36260e18fa7465a60d9bbc:

```
Traceback (most recent call last):
  File "/usr/bin/sponsors-page", line 11, in <module>
    load_entry_point('ubuntu-sponsoring==1.0', 'console_scripts', 'sponsors-page')()
  File "/usr/lib/python3/dist-packages/ubuntu_sponsoring/sponsors_page.py", line 905, in main
    generate_page(
  File "/usr/lib/python3/dist-packages/ubuntu_sponsoring/sponsors_page.py", line 745, in generate_page
    subst["AGEAVERAGE"] = str((sum((x.date_queued for x in items), timedelta()) / len(items)))
NameError: name 'timedelta' is not defined
```

Simon Quigley (tsimonq2)
Changed in ubuntu-sponsoring:
status: New → Fix Released
assignee: nobody → Simon Quigley (tsimonq2)
importance: Undecided → Critical
Revision history for this message
Benjamin Drung (bdrung) wrote :

It fails now with:

```
$ python3 -m ubuntu_sponsoring.sponsors_page -v
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/bdrung/projects/ubuntu-sponsoring/ubuntu_sponsoring/sponsors_page.py", line 929, in <module>
    main()
  File "/home/bdrung/projects/ubuntu-sponsoring/ubuntu_sponsoring/sponsors_page.py", line 906, in main
    generate_page(
  File "/home/bdrung/projects/ubuntu-sponsoring/ubuntu_sponsoring/sponsors_page.py", line 746, in generate_page
    subst["AGEAVERAGE"] = str((sum((x.date_queued for x in items), datetime.timedelta()) / len(items)))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'datetime.datetime'
```

Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :

Should we re-open this?

Revision history for this message
Benjamin Drung (bdrung) wrote :

Commit 7853edd8c6f72229dea35ee59bd0c043e85048f8 fixed the report generation.

Revision history for this message
Alex Murray (alexmurray) wrote :

FWIW I created https://code.launchpad.net/~alexmurray/ubuntu-sponsoring/+git/ubuntu-sponsoring/+merge/479717to try and avoid this in the future if anyone is keen to review it?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.