forked from rDrama/rDrama
Fix exception when serializing comments JSON.
The JSON API endpoints that return comments, most notably `/comments` returned 500s and created a stack trace with: TypeError: Object of type method is not JSON serializable Further debugging revealed this was because json.encoder was being given a <bound method lazy.<locals>.wrapper of <Comment(id=123)>> to serialize. The introduction of the bug was traced tomaster8ecb4582d0
where it was discovered that the (seemingly inadvertent) removal of the @property decorator on classes/comment.py:parent_fullname was the root cause. In light of the fact that parent_fullname was unrelated to the changes intended in8ecb4582d0
and that no other refactoring around parent_fullname was done, it was restored to being a @property rather than its callers modified to invoke it as a method.
parent
a2a9c2666d
commit
47159f338d
|
@ -235,6 +235,7 @@ class Comment(Base):
|
||||||
|
|
||||||
else: return g.db.get(Comment, self.parent_comment_id)
|
else: return g.db.get(Comment, self.parent_comment_id)
|
||||||
|
|
||||||
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def parent_fullname(self):
|
def parent_fullname(self):
|
||||||
if self.parent_comment_id: return f"t3_{self.parent_comment_id}"
|
if self.parent_comment_id: return f"t3_{self.parent_comment_id}"
|
||||||
|
|
Loading…
Reference in New Issue