Skip to content

PicklingError: parser phases not pickleable #269

@jdufresne

Description

@jdufresne

Pickling an HTMLParser object fails.

The following test demonstrates the behavior I was expecting:

def test_pickle_parser():
    parser = HTMLParser()
    encoded = pickle.dumps(parser)
    decoded = pickle.loads(encoded)
    ...

This is failing because the *Phase classes are not defined at the top-level, but instead are defined inside the factory function getPhases(). (This pattern exists in the treebuilders directory as well.)

Unless there is a reason to never reuse a parser, I think the object should be pickleable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions