Roundup Tracker - Issues

Message6087

Author joseph_myers
Recipients ber, joseph_myers, rouilj
Date 2018-06-17.12:47:58
Message-id <1529239681.02.0.56676864532.issue2550960@psf.upfronthosting.co.za>
In-reply-to
Now added patch 40, which addresses Python 3 differences in comparisons
(a standard Python 3 conversion issue, not covered by automated tools as
the results of an automated conversion would generally be very
unidiomatic).  Testing the same as for previous patches (Roundup
testsuite under Python 2, only the parts not skipped with the modules I
have installed).

Python 3 no longer has the cmp function, or cmp= arguments to sorting
functions / methods (key= must be used instead), and requires rich
comparison methods such as __lt__ to be defined instead of using
__cmp__.  All of the comparison mechanisms supported in Python 3 are
also supported in Python 2.

This patch makes the corresponding changes in Roundup to use key
functions and rich comparison methods.  In the case of the
JournalPassword and Permission classes, only __eq__ and __ne__ are
defined as I don't see ordered comparisons as useful there (and for
Permission, the old __cmp__ function didn't try to provide a valid
ordering).  In the case of the Date class, I kept the __cmp__ method and
implemented the others in terms of it, to avoid excess repetitiveness in
duplicating implementation code for all six rich comparison methods.

In roundup/admin.py, help_commands_html used operator.attrgetter to
produce the second argument of sorted() - which would be reasonable for
a key function, but the second argument is the cmp function in Python 2,
not a key function (and the key function must be a named argument not a
positional argument in Python 3).  That function appears to be
completely unused, so I expect that code never worked.  This patch adds
the missing key= to that sorted() call, but it would also be reasonable
to remove the unused function completely instead.
History
Date User Action Args
2018-06-17 12:48:01joseph_myerssetmessageid: <1529239681.02.0.56676864532.issue2550960@psf.upfronthosting.co.za>
2018-06-17 12:48:01joseph_myerssetrecipients: + joseph_myers, ber, rouilj
2018-06-17 12:48:00joseph_myerslinkissue2550960 messages
2018-06-17 12:48:00joseph_myerscreate