Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak config loader for PyPy compatibility. #331

Merged
merged 1 commit into from
Apr 3, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion IPython/config/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ def __deepcopy__(self, memo):
return type(self)(copy.deepcopy(self.items()))

def __getitem__(self, key):
# We cannot use directly self._is_section_key, because it triggers
# infinite recursion on top of PyPy. Instead, we manually fish the
# bound method.
is_section_key = self.__class__._is_section_key.__get__(self)

# Because we use this for an exec namespace, we need to delegate
# the lookup of names in __builtin__ to itself. This means
# that you can't have section or attribute names that are
Expand All @@ -126,7 +131,7 @@ def __getitem__(self, key):
return getattr(__builtin__, key)
except AttributeError:
pass
if self._is_section_key(key):
if is_section_key(key):
try:
return dict.__getitem__(self, key)
except KeyError:
Expand Down