diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-07-03 22:32:08 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-07-03 22:32:08 -0400 |
commit | 9e37d56c3a485991f2af2b362581c3af7e2065ce (patch) | |
tree | 408236c64ec8d747c6328bb043cc7d583ba7cc6f /coverage/backward.py | |
parent | fee9f33351329a3d9fa449e380e9e77973c3102e (diff) | |
download | python-coveragepy-git-9e37d56c3a485991f2af2b362581c3af7e2065ce.tar.gz |
Move the backward-compatibility definitions to a common file. There seems to be no pretty way to do this.
Diffstat (limited to 'coverage/backward.py')
-rw-r--r-- | coverage/backward.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/coverage/backward.py b/coverage/backward.py new file mode 100644 index 00000000..506649d2 --- /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 |