1
0
forked from VimPlug/jedi

reversed builtin for pypy (is not a class), fixes #85

This commit is contained in:
David Halter
2012-12-19 23:47:54 +01:00
parent ce0aadc9a5
commit 99f1c805ef

View File

@@ -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:]