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

TypeError: can't pickle _abc_data objects when a class made with pyfields inherits from an ABC #84

Closed
smarie opened this issue Jun 21, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@smarie
Copy link
Owner

smarie commented Jun 21, 2021

This happens when @autoclass or @autofields is used with a default value.

It seems that the _abc_data object from the ABC is mistakenly set as a field.

@smarie smarie added the bug Something isn't working label Jun 21, 2021
@smarie
Copy link
Owner Author

smarie commented Jun 21, 2021

There are two things we can do:

  • add an exclude arg to exclude auto-fields by name
  • add a check with deepcopy(value) at class creation time and raise an error if this does not work.

smarie pushed a commit that referenced this issue Jun 21, 2021
… error when a field definition can not be valid, because the default value can not be (deep-)copied. `@autofields` and `@autoclass` automatically benefit from this check. This will help users detect issues such as #84 earlier.
@smarie smarie closed this as completed in 517b19d Jun 21, 2021
@smarie
Copy link
Owner Author

smarie commented Jun 21, 2021

This only happens in python 3.7+ by the way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant