Skip to content

Commit

Permalink
A small compatibility fix
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhalter committed Aug 10, 2019
1 parent ab80646 commit a7accf4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions jedi/evaluate/context/iterable.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
1. Array modfications work only in the current module.
2. Jedi only checks Array additions; ``list.pop``, etc are ignored.
"""
import sys

from jedi import debug
from jedi import settings
from jedi._compatibility import force_unicode, is_py3
Expand All @@ -36,7 +38,7 @@
from jedi.evaluate.filters import ParserTreeFilter, LazyAttributeOverwrite, \
publish_method
from jedi.evaluate.base_context import ContextSet, Context, NO_CONTEXTS, \
TreeContext, ContextualizedNode, iterate_contexts, HelperContextMixin
TreeContext, ContextualizedNode, iterate_contexts, HelperContextMixin, _sentinel
from jedi.parser_utils import get_sync_comp_fors


Expand All @@ -50,7 +52,14 @@ def py__stop_iteration_returns(self):
# doing this in the end as well.
# This mostly speeds up patterns like `sys.version_info >= (3, 0)` in
# typeshed.
get_safe_value = Context.get_safe_value
if sys.version_info[0] == 2:
# Python 2...........
def get_safe_value(self, default=_sentinel):
if default is _sentinel:
raise ValueError("There exists no safe value for context %s" % self)
return default
else:
get_safe_value = Context.get_safe_value


class GeneratorBase(LazyAttributeOverwrite, IterableMixin):
Expand Down

0 comments on commit a7accf4

Please sign in to comment.