[issue1757057] IDLE + BeautifulSoup = Error

Tal Einat report at bugs.python.org
Sun Mar 29 17:59:22 CEST 2009


Tal Einat <taleinat at users.sourceforge.net> added the comment:

To recreate use BeautifulSoup 3.0.4 and run the following:

>>> from BeautifulSoup import BeautifulSoup
>>> soup = BeautifulSoup("<html>aa</html")
>>> x = soup.find('html').contents[0]
>>> x
u'aa'
>>> print x

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    print x
RuntimeError: maximum recursion depth exceeded


This is caused by a bug in BeautifulSoup which was fixed in version
3.0.5. The bug manifests when trying to pickle an instance of the
NavigableString class.

In the above scenario, IDLE has the subprocess pickle the object and
send it to the parent process. Since the problem is with the pickling,
turning the object into a string in the subprocess (instead of sending
it as-is to the parent process) avoids generating the error:

>>> print str(x)
aa
>>> print repr(x)
u'aa'


To verify that pickle is the culprit:
>>> import pickle
>>> pickle.dumps(x)
(very long traceback...)
RuntimeError: maximum recursion depth exceeded


Like I said in my first post, IMO IDLE should check for any exception
(not just pickle.PicklingError) when trying to pickle an object for
sending to the parent process. If pickle doesn't work, for whatever
reason, IDLE can still try to work around it with str() and/or repr().

(I tried this with Python 2.5 but I've tested this in the past with 2.6
as well. I haven't tried it with 3.0 or 2.7 yet.)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1757057>
_______________________________________


More information about the Python-bugs-list mailing list