From 62c0877479289fda46e4517944644236a3bf5875 Mon Sep 17 00:00:00 2001 From: William Ting Date: Sat, 28 Jun 2014 19:37:32 -0700 Subject: [PATCH] Add xrange() and fix second() for Python3. --- bin/autojump_utils.py | 8 ++++++-- tests/autojump_utils_test.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/autojump_utils.py b/bin/autojump_utils.py index bac2f37..949b4fd 100644 --- a/bin/autojump_utils.py +++ b/bin/autojump_utils.py @@ -172,8 +172,12 @@ def sanitize(directories): def second(xs): it = iter(xs) try: - it.next() - return it.next() + if is_python2(): + it.next() + return it.next() + elif is_python3(): + next(it) + return next(it) except StopIteration: return None diff --git a/tests/autojump_utils_test.py b/tests/autojump_utils_test.py index 811adbf..42dd7f5 100644 --- a/tests/autojump_utils_test.py +++ b/tests/autojump_utils_test.py @@ -24,6 +24,7 @@ from autojump_utils import unico if is_python3(): os.getcwdu = os.getcwd + xrange = range def u(string):