Skip to content
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

[config] protect is_serializable against circular references #12196

Merged
merged 6 commits into from
Mar 25, 2024

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Mar 24, 2024

I'm not entirely sure of the coverage since it's very hard to check things or generate examples of "broken" configurations that would be meaningful.

Note that it is not possible to test equality of objects with circular references using == (thus, we cannot test equality of objects with circular references after pickle+unpickle since the references are not the same).

It does not fix #11752 because the recursion error occurs in the __instancecheck__ and I was not given anything to reproduce (so I cannot say for sure that it was directly related to that or if the recursion error happened at that call site). However, we do have an issue with circular objects (if any).

@picnixz
Copy link
Member Author

picnixz commented Mar 24, 2024

Forgot to add a CHANGES entry but I'll do it next week (I'm leaving for today).

@picnixz
Copy link
Member Author

picnixz commented Mar 24, 2024

I may also add a simple test for is_serializable without circular references, just to check that I did not mess up a possible condition.

sphinx/config.py Outdated Show resolved Hide resolved
Copy link
Member

@chrisjsewell chrisjsewell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @picnixz, at a quick high-level look I think this looks all good

@picnixz
Copy link
Member Author

picnixz commented Mar 25, 2024

I'm not entirely confident that the recursive guard based on the id is really sufficient but I cannot come up with a counter-example. Intuitively, we are not modifying the objects being tested during the check so even if they are mutable containers, since we are only checking their type, it should not be an issue. However, if the collections happens to be mutated (without changing its length) for whatever reason, then there might be an issue.

Now, I will not make it entirely foolproof because, as the name indicates, I don't want to protect against fools too much.

@picnixz picnixz merged commit f26d492 into sphinx-doc:master Mar 25, 2024
22 checks passed
@picnixz picnixz deleted the fix/11752-circular-references branch March 25, 2024 10:19
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 26, 2024
@AA-Turner AA-Turner added this to the 7.3.0 milestone Jul 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] sphinx.config.is_serializable is not safe against circular references
4 participants