Skip to content

Conversation

nilnullzip
Copy link

The method pymongo.cursor.Cursor.__deepcopy() was apparently created avoid copying regex'es in a deep copy. It works to copy dicts but does nothing for the list case. I found this behavior to be the cause of (obscure) "cannot deepcopy this pattern object" crashes when using Flask-admin with mongoengine. The failure was the result of query criteria containing a list that contained regex'es. In that list case __deepcopy() just calls copy.deepcopy() which fails on the regex'es.

The submitted patch enables __deepcopy to copy lists in addition to dicts. My goal in writing the patch was to implement the list case while minimizing logic changes to the original code as I did not want to unintentionally introduce any new problems. So the code may appear a bit clumsy. But it is perfectly functional and solves the failing case.

I hope this helps. Thanks for all the good work! -Juan

@ghost ghost assigned rozza May 8, 2013
rozza added a commit to rozza/mongo-python-driver that referenced this pull request May 8, 2013
@rozza
Copy link
Member

rozza commented May 8, 2013

@nilnullzip thanks for the ticket - this has been fixed in 3f5cb6f which is in master.

@rozza rozza closed this May 8, 2013
ajdavis pushed a commit to ajdavis/mongo-python-driver that referenced this pull request Feb 13, 2014
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