diff roundup/roundupdb.py @ 5395:23b8e6067f7c

Python 3 preparation: update calls to dict methods. Tool-assisted patch. Changes of iterkeys / itervalues / iteritems to keys / values / items are fully automated, but may make things less efficient in Python 2. Automated tools want to add list() around many calls to keys / values / items, but I thought most such list() additions were unnecessary because it seemed the result of keys / values / items was just iterated over while the set of dict keys remained unchanged, rather than used in a way requiring an actual list, or used while the set of keys in the dict could change. It's quite possible I missed some cases where list() was really needed, or left in some unnecessary list() calls. In cases where list() was only needed because the resulting list was then sorted in-place, I changed the code to use calls to sorted().
author Joseph Myers <jsm@polyomino.org.uk>
date Tue, 24 Jul 2018 23:04:42 +0000
parents 0942fe89e82e
children 56c9bcdea47f
line wrap: on
line diff
--- a/roundup/roundupdb.py	Tue Jul 24 23:03:35 2018 +0000
+++ b/roundup/roundupdb.py	Tue Jul 24 23:04:42 2018 +0000
@@ -710,8 +710,7 @@
 
         # list the values
         m = []
-        prop_items = props.items()
-        prop_items.sort()
+        prop_items = sorted(props.items())
         for propname, prop in prop_items:
             # Omit quiet properties from history/changelog
             if prop.quiet:
@@ -784,8 +783,7 @@
 
         # list the changes
         m = []
-        changed_items = changed.items()
-        changed_items.sort()
+        changed_items = sorted(changed.items())
         for propname, oldvalue in changed_items:
             prop = props[propname]
             # Omit quiet properties from history/changelog

Roundup Issue Tracker: http://roundup-tracker.org/