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

Fix BaseDocument._from_son() deepcopy failed with compiled regex #2438

Closed
wants to merge 6 commits into from

Conversation

StoneMoe
Copy link

@StoneMoe StoneMoe commented Dec 4, 2020

Fix for issue #2429

@StoneMoe StoneMoe marked this pull request as ready for review December 4, 2020 16:27
mongoengine/fields.py Outdated Show resolved Hide resolved
mongoengine/fields.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@bagerard bagerard left a comment

Choose a reason for hiding this comment

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

Hi @StoneMoe , thanks for your contribution. It looks great, I only have a minor few comments. Please check the comments and let me know if there are additional questions.

@StoneMoe
Copy link
Author

StoneMoe commented Dec 7, 2020

Hi, thanks for the reviewing, I added more tests and changed approach for this fix based on that.

but there are some question might need more discussion:

  1. deepcopy() won't copy class-level attributes added by __new__, which is instance._fields in this case. which resulting in the test you request to add won't pass in the first place, is this expected or another bug for mongoengine?
  2. deepcopy() works for _fields attribute of the instance returned by _from_son(), but not work for the objects returned from queryset

@bagerard
Copy link
Collaborator

sorry I lost track of this. I tested the initial issues on latest master and it's not failing anymore so I guess something got merged since this PR got created. I'm including the test cases in #2865 to avoid regression but I'm closing this one as I prefer to avoid too much hacks on deepcopy internals unless absolutly necessary

@bagerard bagerard closed this Oct 19, 2024
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.

2 participants