This is an archive of the discontinued LLVM Phabricator instance.

[LNT] Python 3 support: get rid of calls to cmp builtin
ClosedPublic

Authored by thopre on Sep 20 2019, 1:39 AM.

Details

Summary

Get rid of calls to cmp builtins since it was removed in Python 3:

  • for the tests, the assignment to sortTestMethodsUsing is removed altogether since the default is the built-in ordering for strings;
  • for the call in the TestsuiteDB.Order class, we define the rich comparison methods that have replaced cmp;
  • for the stats module, we use equality expressions since only the equality value is needed.

Note that one of the uses of cmp in the stats module is dead but removal
of the dead code is kept for future work to keep a separation of concern
between commits.

Diff Detail

Repository
rL LLVM

Event Timeline

thopre created this revision.Sep 20 2019, 1:39 AM
lnt/server/db/testsuitedb.py
284 ↗(On Diff #220979)

Not sure what you think of this drive-by:

next(
    itertools.dropwhile(
        lambda x: x[0] == x[1],
        map(
            lambda item:
            (convert_revision(self.get_field(item), cache=Order.order_name_cache),
             convert_revision(b.get_field(item), cache=Order.order_name_cache)),
            self.fields)), (0, 0))
tests/server/ui/test_api_modify.py
229 ↗(On Diff #220979)

This does get called, but the default behavior is fine.

thopre updated this revision to Diff 221546.Sep 24 2019, 8:33 AM
thopre marked 3 inline comments as done.
  • Use Hubert's improve _compare_prepare implementation and rename it accordingly
thopre added inline comments.Sep 24 2019, 8:58 AM
lnt/server/db/testsuitedb.py
284 ↗(On Diff #220979)

Went for intermediate steps as I find it more readable, YMMV.

tests/server/ui/test_api_modify.py
229 ↗(On Diff #220979)

What calls this lambda?

hubert.reinterpretcast marked an inline comment as done.

LGTM with suggestion for a minor drive-by typo correction.

lnt/server/db/testsuitedb.py
284 ↗(On Diff #221546)

Minor drive-by: s/verse/versus/;

tests/server/ui/test_api_modify.py
229 ↗(On Diff #220979)

Something called through the call to unittest.main below.

This revision is now accepted and ready to land.Sep 24 2019, 8:49 PM
thopre updated this revision to Diff 221697.Sep 25 2019, 3:01 AM
thopre marked 2 inline comments as done.

Fix misses uses of cmp builtin

thopre requested review of this revision.Sep 25 2019, 3:01 AM
thopre edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Sep 27 2019, 7:20 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 28 2019, 12:12 AM