Do not use mutable defaults in FieldAttribute, instead allow supplying a callable for defaults of mutable types. Fixes #46824 (#46833)

This commit is contained in:
Matt Martz 2018-10-12 10:43:09 -05:00 committed by GitHub
parent 0dd17b521f
commit a06a5ded61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 57 additions and 37 deletions

View file

@ -49,7 +49,7 @@ class Conditional:
to be run conditionally when a condition is met or skipped.
'''
_when = FieldAttribute(isa='list', default=[], extend=True, prepend=True)
_when = FieldAttribute(isa='list', default=list, extend=True, prepend=True)
def __init__(self, loader=None):
# when used directly, this class needs a loader, but we want to