diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2012-12-19 21:20:29 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2012-12-19 21:20:29 -0500 |
commit | 90170a258e53eb7fbe964ddc2dcf7d85718cd0bb (patch) | |
tree | f9c8866abb2a3072e6f15e3e68182d841bf44b89 /coverage/backward.py | |
parent | 0d302a85d92378b74e953c43df30ba094811c908 (diff) | |
download | python-coveragepy-90170a258e53eb7fbe964ddc2dcf7d85718cd0bb.tar.gz |
Retro-fit onto 2.3 and 2.4 again.
Diffstat (limited to 'coverage/backward.py')
-rw-r--r-- | coverage/backward.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/coverage/backward.py b/coverage/backward.py index 6347501..2c015af 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -24,6 +24,22 @@ except NameError: lst.sort() return lst +# rpartition is new in 2.5 +try: + "".rpartition +except AttributeError: + def rpartition(s, sep): + """Implement s.rpartition(sep) for old Pythons.""" + i = s.rfind(sep) + if i == -1: + return ('', '', s) + else: + return (s[:i], sep, s[i+len(sep):]) +else: + def rpartition(s, sep): + """A common interface for new Pythons.""" + return s.rpartition(sep) + # Pythons 2 and 3 differ on where to get StringIO try: from cStringIO import StringIO |