On Sat, Oct 11, 2008 at 7:34 PM, Armin Rigo <[EMAIL PROTECTED]> wrote: > Hi, > > On Thu, Oct 09, 2008 at 02:19:35AM +0200, Ondrej Certik wrote: >> if hasattr(i, "__iter__"): >> RuntimeError: internal error: <RuntimeError object at 0xb03b60> > > This occurs because our 'str' type has an '__iter__' special method. It > turns out that CPython's does not. I suppose we could remove our > __iter__, but I would rather suggest that sympy's code is fragile there: > as soon as someone realizes that in CPython it is possible to speed up > iteration over strings by creating a stringiterator type, then CPython > will grow a 'str.__iter__' as well, and the same infinite recursion will > occur in sympy... > > A cleaner way to say "is x iterable?" would be to try to call iter(x) > and see if it raises TypeError or not.
Indeed, thanks very much for the tip. We'll fix that, that's definitely something that should be fixed in sympy, I created a new issue for that: http://code.google.com/p/sympy/issues/detail?id=1153 Ondrej _______________________________________________ [email protected] http://codespeak.net/mailman/listinfo/pypy-dev
