Skip to content

Commit

Permalink
fix: made a shallow copy of __dict__ when iterating over class attrib…
Browse files Browse the repository at this point in the history
…utes to avoid RuntimeError
  • Loading branch information
viniarck committed May 23, 2023
1 parent c7de458 commit 13192c3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyof/foundation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def get_class_attributes(cls):
"""
#: see this method docstring for a important notice about the use of
#: cls.__dict__
for name, value in cls.__dict__.items():
for name, value in cls.__dict__.copy().items():
# gets only our (pyof) attributes. this ignores methods, dunder
# methods and attributes, and common python type attributes.
if GenericStruct._is_pyof_attribute(value):
Expand All @@ -605,7 +605,7 @@ def _get_instance_attributes(self):
generator: tuples with attribute name and value.
"""
for name, value in self.__dict__.items():
for name, value in self.__dict__.copy().items():
if name in map((lambda x: x[0]), self.get_class_attributes()):
yield (name, value)

Expand Down

0 comments on commit 13192c3

Please sign in to comment.