← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-translationimportqueue-division into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-translationimportqueue-division into launchpad:master.

Commit message:
Handle / being true division in Python 3 (take 3)

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/399289

`TranslationImportQueueEntry.getElapsedTimeText` can exhibit subtly different behaviour if it uses true division rather than floor division.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-translationimportqueue-division into launchpad:master.
diff --git a/lib/lp/translations/model/translationimportqueue.py b/lib/lp/translations/model/translationimportqueue.py
index 2554ff5..b8830ff 100644
--- a/lib/lp/translations/model/translationimportqueue.py
+++ b/lib/lp/translations/model/translationimportqueue.py
@@ -1,7 +1,12 @@
 # Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
-from __future__ import absolute_import, print_function, unicode_literals
+from __future__ import (
+    absolute_import,
+    division,
+    print_function,
+    unicode_literals,
+    )
 
 __metaclass__ = type
 __all__ = [
@@ -839,8 +844,8 @@ class TranslationImportQueueEntry(StormBase):
         elapsedtime = (
             datetime.datetime.now(UTC) - self.dateimported)
         elapsedtime_text = ''
-        hours = elapsedtime.seconds / 3600
-        minutes = (elapsedtime.seconds % 3600) / 60
+        hours = elapsedtime.seconds // 3600
+        minutes = (elapsedtime.seconds % 3600) // 60
         if elapsedtime.days > 0:
             elapsedtime_text += '%d days ' % elapsedtime.days
         if hours > 0: