2
0
mirror of https://github.com/openkmip/pykmip synced 2025-12-27 21:53:39 +00:00

Fixing infinite recursion bug with object inheritance

This change removes all references to self.__class__. In object
hierarchies with multiple levels of inheritance, using self.__class__
can cause an infinite loop when resolving references to parent classes.
This commit is contained in:
Peter Hamilton
2015-06-02 11:16:42 -04:00
parent f57273fcc5
commit ab3298c6d1
14 changed files with 219 additions and 205 deletions

View File

@@ -27,12 +27,12 @@ class DestroyRequestPayload(Struct):
def __init__(self,
unique_identifier=None):
super(self.__class__, self).__init__(enums.Tags.REQUEST_PAYLOAD)
super(DestroyRequestPayload, self).__init__(enums.Tags.REQUEST_PAYLOAD)
self.unique_identifier = unique_identifier
self.validate()
def read(self, istream):
super(self.__class__, self).read(istream)
super(DestroyRequestPayload, self).read(istream)
tstream = BytearrayStream(istream.read(self.length))
if self.is_tag_next(Tags.UNIQUE_IDENTIFIER, tstream):
@@ -50,7 +50,7 @@ class DestroyRequestPayload(Struct):
# Write the length and value of the request payload
self.length = tstream.length()
super(self.__class__, self).write(ostream)
super(DestroyRequestPayload, self).write(ostream)
ostream.write(tstream.buffer)
def validate(self):
@@ -65,12 +65,13 @@ class DestroyResponsePayload(Struct):
def __init__(self,
unique_identifier=None):
super(self.__class__, self).__init__(enums.Tags.RESPONSE_PAYLOAD)
super(DestroyResponsePayload, self).__init__(
enums.Tags.RESPONSE_PAYLOAD)
self.unique_identifier = unique_identifier
self.validate()
def read(self, istream):
super(self.__class__, self).read(istream)
super(DestroyResponsePayload, self).read(istream)
tstream = BytearrayStream(istream.read(self.length))
self.unique_identifier = attributes.UniqueIdentifier()
@@ -86,7 +87,7 @@ class DestroyResponsePayload(Struct):
# Write the length and value of the request payload
self.length = tstream.length()
super(self.__class__, self).write(ostream)
super(DestroyResponsePayload, self).write(ostream)
ostream.write(tstream.buffer)
def validate(self):