bs4.element.Tag causes pickle to go into infinite recursion
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Beautiful Soup |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
% python bs4-fails-
4.2.1
<class 'bs4.element.Tag'>
<a class="skippy" href="#skip">Skip Navigation</a>
cPickle failed with maximum recursion depth exceeded while getting the str of an object
pickle failed with maximum recursion depth exceeded
% PYTHONPATH=
4.3.1
<class 'bs4.element.Tag'>
<a class="skippy" href="#skip">Skip Navigation</a>
cPickle failed with maximum recursion depth exceeded while getting the str of an object
pickle failed with maximum recursion depth exceeded
% cat bs4-fails-
#!/usr/bin/python
#emacs: -*- mode: python-mode; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
#ex: set sts=4 ts=4 sw=4 noet:
"""
COPYRIGHT: Yaroslav Halchenko 2013
LICENSE: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
__author__ = 'Yaroslav Halchenko'
__copyright__ = 'Copyright (c) 2013 Yaroslav Halchenko'
__license__ = 'MIT'
import urllib2
import bs4
from bs4 import BeautifulSoup
print bs4.__version__
page = urllib2.urlopen('http://
soup = BeautifulSoup(page)
a = soup.find(
print type(a)
print a
try:
from cPickle import Pickler
with open('/
except Exception, e:
print "cPickle failed with ", e
try:
from pickle import Pickler
with open('/
except Exception, e:
print "pickle failed with ", e
Changed in beautifulsoup: | |
status: | Fix Committed → Fix Released |
Unfortunately I can't retrieve your example page because the federal government is shut down. Can you provide a minimal set of markup that crashes pickle? There are existing pickle tests (in test_tree. py#TestPersiste nce), but I'm not surprised to find that it doesn't always work.