summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Plotnick <shrike@netaxs.com>2012-03-23 10:19:09 -0400
committerJulien Danjou <julien@danjou.info>2012-03-23 15:28:28 +0100
commit3dd06e863bb3bd6abc38e630c55d30f2e642439b (patch)
tree5f04ebc0c1229bdab58548c4dc969037cc09518a
parent831826a3ef3967bafd1cb72ed780c9d2257b63af (diff)
Fix length field handling, again.
This revises commit c5ff7fbf5a53cc20984a20d5461be2fc1f1eac39, which did fix the build, but generated invalid code for (at least) QueryTextExtents. Signed-off-by: Julien Danjou <julien@danjou.info>
-rwxr-xr-xsrc/py_client.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/py_client.py b/src/py_client.py
index d132f43..358df49 100755
--- a/src/py_client.py
+++ b/src/py_client.py
@@ -259,16 +259,12 @@ def _py_get_length_field(expr):
For fields that follow a variable-length field, use the accessor.
Otherwise, just reference the structure field directly.
'''
- if expr.lenfield_name != None:
- # This would be nicer if Request had an is_request attribute...
- try:
- has_opcode = hasattr(expr.parent.parents, "opcode")
- except AttributeError:
- has_opcode = False
- if has_opcode:
- return expr.lenfield_name
- else:
- return 'self.%s' % expr.lenfield_name
+ if expr.lenfield_name is not None:
+ for grandparent in expr.parent.parents:
+ # This would be nicer if Request had an is_request attribute...
+ if hasattr(grandparent, "opcode"):
+ return expr.lenfield_name
+ return 'self.%s' % expr.lenfield_name
else:
return str(expr.nmemb)