-
-
Notifications
You must be signed in to change notification settings - Fork 625
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 propagating only
and exclude
to nested field instances
#1385
Conversation
…d `exclude` Also, be explicit about which helper methods are private
@@ -878,7 +875,9 @@ def __apply_nested_option(self, option_name, field_names, set_operation): | |||
setattr(self.declared_fields[key], option_name, new_options) | |||
|
|||
def _init_fields(self): | |||
"""Update fields based on schema options.""" | |||
"""Update self.fields, self.load_fields, and self.dump_fields based on schema options. | |||
This method is private API. |
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.
This was always private even though we don't actually use __
, so I don't consider this a breaking change.
This generalizes slightly better to accommodate #1382
Copy schema to avoid unwanted sharing of `only` and `exclude` across instances
Merging this because I don't want this bug and the bug in #1160 in the wild for too long. |
@@ -468,8 +468,17 @@ def schema(self): | |||
# Inherit context from parent. | |||
context = getattr(self.parent, "context", {}) | |||
if isinstance(self.nested, SchemaABC): | |||
self._schema = self.nested | |||
self._schema = copy.deepcopy(self.nested) |
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.
I have nested schema instance which context contains non-pickling object. In my case it is Crypto.Cipher.AES
object which i tried to deepcopy in console and got an error. Should I start an issue?
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.
Does it fix it if you use copy.copy
instead?
self._schema = copy.deepcopy(self.nested) | |
self._schema = copy.copy(self.nested) |
Now that I think of it, I'm not sure we even need to deepcopy here. Let me know if the above fixes your issue.
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.
@sloria yep, copy works just fine! waiting for release, thanks!
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.
Thanks for checking. The fix is released in 3.1.1.
Fix #1384