summaryrefslogtreecommitdiff
path: root/kafka/protocol/struct.py
diff options
context:
space:
mode:
authorDana Powers <dana.powers@gmail.com>2017-03-09 15:12:27 -0800
committerGitHub <noreply@github.com>2017-03-09 15:12:27 -0800
commit899f11730db5f209c03cfad20111ec131ee4c70b (patch)
tree98eeab3440354330564e1660358a730614a05404 /kafka/protocol/struct.py
parentbb709f4c141dacee07248eb111fa48c3992cf2f9 (diff)
downloadkafka-python-899f11730db5f209c03cfad20111ec131ee4c70b.tar.gz
Fix kwarg handing in kafka.protocol.struct.Struct (#1025)
Diffstat (limited to 'kafka/protocol/struct.py')
-rw-r--r--kafka/protocol/struct.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/kafka/protocol/struct.py b/kafka/protocol/struct.py
index 4c1afcb..3288172 100644
--- a/kafka/protocol/struct.py
+++ b/kafka/protocol/struct.py
@@ -18,7 +18,12 @@ class Struct(AbstractType):
elif len(args) > 0:
raise ValueError('Args must be empty or mirror schema')
else:
- self.__dict__.update(kwargs)
+ for name in self.SCHEMA.names:
+ self.__dict__[name] = kwargs.pop(name, None)
+ if kwargs:
+ raise ValueError('Keyword(s) not in schema %s: %s'
+ % (list(self.SCHEMA.names),
+ ', '.join(kwargs.keys())))
# overloading encode() to support both class and instance
# Without WeakMethod() this creates circular ref, which