-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Overriding Field.__deepcopy__ for RegexField #2617
Conversation
Compiled regex pattern cannot be deepcopied. The overridden __deepcopy__ mimics the behavior as the parent method, but checks for `regex` instead of `validators`
args = self._args[:1] + copy.deepcopy(self._args[1:]) | ||
kwargs = dict(self._kwargs) | ||
|
||
# deepcopy doesn't work on compiled regex pattern |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if it'd instead be simpler to handle all this logic alongside the similar 'validators' special casing in Field.__deepcopy__
?
Hi there, Wondering if there's been a decision made on this? I'm running into the same deepcopy issue with RegexFields. Having
doesn't seem to avoid them being in
and it's
|
Bumping up the priority to ensure this gets reviewed sometime over the coming weeks. |
To add on, this happens only when I'm using a compiled regex object as the Using a pattern string works fine eg.
|
Noted. Thanks! |
Problem:
Serializers
are deepcopying a declaredRegexField
[source], but it'll error out with the message.TypeError: cannot deepcopy this pattern object
.