From 51835448443e0c6a4f372b7b72c6f971bf00f6b5 2009-03-26 18:51:37 From: Walter Doerwald Date: 2009-03-26 18:51:37 Subject: [PATCH] Fix warnings about ignored GeneratorExit exceptions under Python 2.5+ in ipipe.xrepr(). Enabled unicode string as descriptor in ipipe.upgradexattr(). --- diff --git a/IPython/Extensions/ipipe.py b/IPython/Extensions/ipipe.py index e76e0c3..7f9029a 100644 --- a/IPython/Extensions/ipipe.py +++ b/IPython/Extensions/ipipe.py @@ -114,6 +114,11 @@ except NameError: items.reverse() return items +try: # Python 2.4 compatibility + GeneratorExit +except NameError: + GeneratorExit = SystemExit + try: import pwd except ImportError: @@ -666,7 +671,7 @@ def xrepr(item, mode="default"): try: for x in func(mode): yield x - except (KeyboardInterrupt, SystemExit): + except (KeyboardInterrupt, SystemExit, GeneratorExit): raise except Exception: yield (astyle.style_default, repr(item)) @@ -840,20 +845,20 @@ def upgradexattr(attr): """ Convert an attribute descriptor string to a real descriptor object. - If attr already is a descriptor object return if unmodified. A + If attr already is a descriptor object return it unmodified. A ``SelfDescriptor`` will be returned if ``attr`` is ``None``. ``"foo"`` returns an ``AttributeDescriptor`` for the attribute named ``"foo"``. ``"foo()"`` returns a ``MethodDescriptor`` for the method named ``"foo"``. ``"-foo"`` will return an ``IterAttributeDescriptor`` for the attribute named ``"foo"`` and ``"-foo()"`` will return an ``IterMethodDescriptor`` - for the method named ``"foo"``. Furthermore integer will return the appropriate + for the method named ``"foo"``. Furthermore integers will return the appropriate ``IndexDescriptor`` and callables will return a ``FunctionDescriptor``. """ if attr is None: return selfdescriptor elif isinstance(attr, Descriptor): return attr - elif isinstance(attr, str): + elif isinstance(attr, basestring): if attr.endswith("()"): if attr.startswith("-"): return IterMethodDescriptor(attr[1:-2])