8000 Complex edges break pickling (due to unpicklable FrozenDict) · Issue #481 · pydot/pydot · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Complex edges break pickling (due to unpicklable FrozenDict) #481

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

Open
ferdnyc opened this issue May 16, 2025 · 2 comments
Open

Complex edges break pickling (due to unpicklable FrozenDict) #481

ferdnyc opened this issue May 16, 2025 · 2 comments

Comments

@ferdnyc
Copy link
Member
ferdnyc commented May 16, 2025

Let me preface this by saying that I could not possibly care less about this issue — I'm always amazed that anyone still uses pickle at all, anymore. Using it to serialize Pydot data seems especially silly, because it makes far more sense to just serialize as a dot file and re-parse it on load, if someone really needs to store their graphs.

But, it's something I discovered in experimenting, so I wanted to at least document it. I don't have any plans to fix it, heck I'm not even sure if it is fixable.

Because complex edges are partly made up of FrozenDict objects, graphs that include them are no longer picklable. Writing out the data will work fine, but when attempting to load it back in Python will throw out a Traceback originating in:

AttributeError: A frozendict cannot be modified.

(Including the incorrect casing; I forgot to update the message when I renamed the class to FrozenDict.)

AFAICT it's always been this way... I loaded up Pydot v1.4.2 and attempted to pickle a frozendict from that version of the code, and got the same exact traceback.

The only difference is, now that we support complex edges, there will be FrozenDicts in the graph data. There never were, before, because they're only used for subgraphs on edge endpoints.

This issue only affects graphs that use complex edges, for the same reason. So, as far as I care, that's fine: Complex edges are incompatible with pickle, so users can choose one or the other (or neither). ¯\_(ツ)_/¯

@lkk7
Copy link
Member
lkk7 commented May 16, 2025

I foresee a possibility of user-friendly pickling errors when a complex edge is detected in the graph, implemented in the __getstate__ method. That's probably a feature that nobody will ever use.

@ferdnyc
Copy link
Member Author
ferdnyc commented May 16, 2025

PRs welcome! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0