From cf8104fc6f89f930c9ed73aa5fcb26d719c34c8c Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 8 Jul 2009 09:24:20 -0400 Subject: Various Py3k fixes: remove gratuitous print, don't test the print statement, deal with __cmp__ ugliness, etc. --- coverage/codeunit.py | 22 ++++++++++++++++++++-- coverage/execfile.py | 4 ++-- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'coverage') diff --git a/coverage/codeunit.py b/coverage/codeunit.py index 87782cd..7f4ed96 100644 --- a/coverage/codeunit.py +++ b/coverage/codeunit.py @@ -83,8 +83,26 @@ class CodeUnit: def __repr__(self): return "" % (self.name, self.filename) - def __cmp__(self, other): - return cmp(self.name, other.name) + # Annoying comparison operators. Py3k wants __lt__ etc, and Py2k needs all + # of them defined. + + def __lt__(self, other): + return self.name < other.name + + def __le__(self, other): + return self.name <= other.name + + def __eq__(self, other): + return self.name == other.name + + def __ne__(self, other): + return self.name != other.name + + def __gt__(self, other): + return self.name > other.name + + def __ge__(self, other): + return self.name >= other.name def flat_rootname(self): """A base for a flat filename to correspond to this code unit. diff --git a/coverage/execfile.py b/coverage/execfile.py index 09947bc..a345c76 100644 --- a/coverage/execfile.py +++ b/coverage/execfile.py @@ -6,8 +6,8 @@ try: # In Py 2.x, the builtins were in __builtin__ BUILTINS = sys.modules['__builtin__'] except KeyError: - # In Py 3.x, they're in builtin - BUILTINS = sys.modules['builtin'] + # In Py 3.x, they're in builtins + BUILTINS = sys.modules['builtins'] def run_python_file(filename, args): -- cgit v1.2.1