Permalink
Browse files

Tweak config loader for PyPy compatibility.

closes gh-327
  • Loading branch information...
1 parent 7d1bdfa commit 7eb58d30ffc34053c2b6aff906d7efcbcf39b724 Antonio Cuni committed with takluyver Apr 2, 2011
Showing with 6 additions and 1 deletion.
  1. +6 −1 IPython/config/loader.py
@@ -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
@@ -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:

0 comments on commit 7eb58d3

Please sign in to comment.