From 99f1c805efd9a1925b272ca5fa2557eeb36d7512 Mon Sep 17 00:00:00 2001 From: David Halter Date: Wed, 19 Dec 2012 23:47:54 +0100 Subject: [PATCH] reversed builtin for pypy (is not a class), fixes #85 --- jedi/builtin.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jedi/builtin.py b/jedi/builtin.py index 8fd208d2..0162a692 100644 --- a/jedi/builtin.py +++ b/jedi/builtin.py @@ -330,7 +330,17 @@ def _generate_code(scope, mixin_funcs={}, depth=0): # the parser only supports basic functions with a newline after # the double dots # find doc_str place - pos = re.search(r'\):\s*\n', mixin).end() + try: + pos = re.search(r'\):\s*\n', mixin).end() + except TypeError: + # pypy uses a different reversed builtin + if name == 'reversed': + mixin = 'def reversed(sequence):\n' \ + ' for i in self.__sequence: yield i' + pos = 24 + else: + debug.warning('mixin trouble in pypy: %s', name) + raise if pos is None: raise Exception("Builtin function not parsed correctly") code += mixin[:pos] + doc_str + mixin[pos:]