[
https://issues.apache.org/jira/browse/THRIFT-339?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680426#action_12680426
]
Esteve Fernandez commented on THRIFT-339:
-----------------------------------------
Alexander: I don't fully understand your patch. Actually, it breaks the
compiler and default values are not properly handled. For example, given this
structure:
{code}
struct Foo {
1:optional list<i32> l = [1,2,3,4],
}
{code}
the code generated after applying your patch is:
{code}
def __init__(self, l=None):
if l is None:
l = [
1,
2,
3,
4,
]
{code}
which is wrong, which makes it impossible to pass None as l to Foo. Also, it
doesn't set self.l to l, but I guess it was just a slip. With the current
behavior, the generated code is:
{code}
def __init__(self, l=thrift_spec[1][4],):
if l is self.thrift_spec[1][4]:
l = [
1,
2,
3,
4,
]
self.l = l
{code}
> THRIFT-242 is incompatible with arguments with empty key fields
> ---------------------------------------------------------------
>
> Key: THRIFT-339
> URL: https://issues.apache.org/jira/browse/THRIFT-339
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Python)
> Reporter: Jonathan Ellis
> Attachments: thrift-339-2.patch, thrift-339-3.patch,
> thrift-339-4.patch, thrift-339-5.patch, thrift-339-6.patch, thrift-339.patch,
> thrift-python-defaults.patch
>
>
> Esteve's last change to how default values are stored broke stuff. Here is a
> quick example:
> {{
> service Test
> {
> bool get_slice(i32 start = -1),
> }
> }}
> generates
> {{
> class get_slice_args:
> thrift_spec = None
> def __init__(self, start=thrift_spec[-1][4],):
> self.start = start
> }}
> which is obviously invalid.
> I'm not sure how thrift_spec is supposed to be populated here so I'm unsure
> how to fix this.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.