Skip to content

Commit

Permalink
Fixd repr_attr in case __repr__ is called before __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
bartvm committed Nov 18, 2014
1 parent 5867538 commit 8d1559f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions blocks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,18 @@ def repr_attrs(instance, *attrs):
<blocks.utils.A object at 0x7fb2b4741a10: value=a_value>
"""
repr_template = ("<{0.__class__.__module__}.{0.__class__.__name__} "
"object at {1:#x}")
orig_repr_template = ("<{0.__class__.__module__}.{0.__class__.__name__} "
"object at {1:#x}")
if attrs:
repr_template += ": " + ", ".join(["{0}={{0.{0}}}".format(attr)
for attr in attrs])
repr_template = (orig_repr_template + ": " +
", ".join(["{0}={{0.{0}}}".format(attr)
for attr in attrs]))
repr_template += '>'
return repr_template.format(instance, id(instance))
orig_repr_template += '>'
try:
return repr_template.format(instance, id(instance))
except:
return orig_repr_template.format(instance, id(instance))


def update_instance(self, kwargs, ignore=True):
Expand Down

0 comments on commit 8d1559f

Please sign in to comment.