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

Avoid confusing Python by returning generic objects for magic attributes. #2403

Merged
merged 1 commit into from
Feb 10, 2021

Conversation

matthewwardrop
Copy link
Contributor

@matthewwardrop matthewwardrop commented Feb 10, 2021

As reported in #2402 , we recently came up against an issue whereby Altair charts could not be deep-copied. The issue is that in three locations a __getattr__ method is implemented in such a way that it returns a object for any named attribute. This is usually helpful, but it sometimes confuses Python when it coincides with a Python "magic" method/attribute (which are always of form __<name>__; and in this case in particular, __deepcopy__ is looked up but then doesn't behave in the way copy.deepcopy expects.

This patch causes Altair to avoid returning generic objects as attributes for Python magic names, fixing this (and other similar) issue(s).

closes #2402

@matthewwardrop
Copy link
Contributor Author

@jakevdp fyi :).

@jakevdp
Copy link
Collaborator

jakevdp commented Feb 10, 2021

Thanks, this looks great!

@jakevdp jakevdp merged commit 64b3480 into vega:master Feb 10, 2021
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

Successfully merging this pull request may close these issues.

DatumType and Selection instances are not deep copyable.
2 participants