Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
0.12.0
-
None
-
None
Description
Given this IDL:
struct Basic { 1: required list<string> strings = [] }
the following Python code is generated:
class Basic(object): """ Attributes: - strings """ def __init__(self, strings=[ ]): if identifiers is self.thrift_spec[1][4]: identifiers = [ ] self.identifiers = identifiers <remainder truncated>
If Basic's constructor is called without specifying a value for strings, such as inĀ b = Basic(), then every Basic object created this way will share the same list that's created for the default value. Any attempts to append to the list would yield unexpected results. See https://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html.