pickling fails when soup.builder is None

36 views
Skip to first unread message

Yoav Tzfati

unread,
Jun 29, 2021, 3:03:00 PM6/29/21
to beautifulsoup
Hi, I just opened a bug report, not sure if they're looked at so decided to post it here as well
https://bugs.launchpad.net/beautifulsoup/+bug/1934003

Basically, the following code raises an exception when builder is None - which sometimes happens to me (I think when I'm pickling an unrelated object, I'm not sure)

def __getstate__(self):
    # Frequently a tree builder can't be pickled.
    d = dict(self.__dict__)
    if 'builder' in d and not self.builder.picklable:
        d['builder'] = None
    return d

I think it should be
if d.get('builder') is not None and not self.builder.picklable
Reply all
Reply to author
Forward
0 new messages