underscore_decorators now automatically convert generators to lists

This commit is contained in:
Dave Halter
2014-01-23 15:21:52 +01:00
parent 6f2c1397b0
commit 162d794081
2 changed files with 9 additions and 4 deletions

View File

@@ -19,11 +19,12 @@ import sys
import json
import hashlib
import gc
import inspect
import shutil
try:
import cPickle as pickle
except ImportError:
import pickle
import shutil
from jedi import settings
from jedi import common
@@ -119,12 +120,15 @@ def underscore_memoization(func):
A now has an attribute ``_x`` written by this decorator.
"""
name = '_' + func.__name__
def wrapper(self):
name = '_' + func.__name__
try:
return getattr(self, name)
except AttributeError:
result = func(self)
if inspect.isgenerator(result):
result = list(result)
setattr(self, name, result)
return result