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
Unexpected "maximum recursion depth exceeded" in IDLE shell with objects that cannot be pickled #45221
Comments
This bug manifests only when running with a subprocess. Trying to display an instance of BeautifulSoup's NavigableString class, this is the result: RuntimeError: maximum recursion depth exceeded See http://mail.python.org/pipermail/idle-dev/2007-July/002600.html for details (including how to recreate the error). Diagnosis: The problem arises when trying to pickle such instances - pickle enters an endless loop and reaches the max recursion limit (eventually). This happens regardless of the protocol used. IDLE is probably trying to pickle them because their class, NavigableString, inherits from unicode, so isinstance(<NavigableString instance>, basestring) return True. Possibly related to SF bug bpo-1581183: "pickle protocol 2 failure on int subclass" Fix: IDLE should check for any exception when trying to pickle, not just pickle.PicklingError, to avoid such errors. If pickle doesn't work, for whatever reason, IDLE can still work around it with str() and repr(). I'll post a bug report for Pickle as well. |
I can't seem to reproduce this here. I've tried both python 2.4.5 and Any chance you can retry it ? And if you do reproduce it then include |
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 In the above scenario, IDLE has the subprocess pickle the object and >>> 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 (I tried this with Python 2.5 but I've tested this in the past with 2.6 |
Do you have some specific suggestion on how to do so ? As I'm seeing |
Sending a code object back to the parent process and having it deal with In general, I can't think of any reason for IDLE to pickle "user I'll have to unwind the spaghetti in rpc.py, run.py and PyShell.py a bit |
Can we close this given "This is caused by a bug in BeautifulSoup which was fixed in version 3.0.5." from msg84412? |
While BeautifulSoup may have been fixed, the issue here still points to an underlying problem in IDLE being vulnerable to pickling errors. The given test case still fails in 2.7 (I didn't try to construct a test for Python 3). |
I think that bpo-13532 fixes this issue, as only strings are now pickled from the subprocess to the IDLE front-end for writing to stdout and stderr. This should address the pickling vulnerability. I downloaded BeautifulSoup 3.0.4 and did not see this problem when using IDLE 2.7.1, and then against the latest dev version from the repo. I am closing this issue as being out of date. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: