From 70ac0e736ba2a00a5b5befc3e55bf79f49b673ba Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 3 Jul 2009 22:32:08 -0400 Subject: Move the backward-compatibility definitions to a common file. There seems to be no pretty way to do this. --- coverage/backward.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 coverage/backward.py (limited to 'coverage/backward.py') diff --git a/coverage/backward.py b/coverage/backward.py new file mode 100644 index 0000000..506649d --- /dev/null +++ b/coverage/backward.py @@ -0,0 +1,24 @@ +"""Add things to old Pythons so I can pretend they are newer.""" + +# pylint: disable-msg=W0622 +# (Redefining built-in blah) +# The whole point of this file is to redefine built-ins, so shut up about it. + + +# Python 2.3 doesn't have `set` +try: + set = set # new in 2.4 +except NameError: + # (Redefining built-in 'set') + from sets import Set as set + + +# Python 2.3 doesn't have `sorted`. +try: + sorted = sorted +except NameError: + def sorted(iterable): + """A 2.3-compatible implementation of `sorted`.""" + lst = list(iterable) + lst.sort() + return lst -- cgit v1.2.1