Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#6021 closed (fixed)

RuntimeError when printing a SafeString

Reported by: Jan Rademaker <j.rademaker@…> Owned by: nobody
Component: Core (Other) Version: dev
Severity: Keywords: print recursion
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

SafeString's __str__ method does not return a string but the SafeString object itself. Simply removing the __str__ method seems to solve the problem (all tests pass).

>>> from django.newforms.util import ErrorList
>>> e = ErrorList([u'foo'])
>>> e
[u'foo']
>>> type(str(e))
<class 'django.utils.safestring.SafeString'>
>>> print e
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: print recursion

Attachments (1)

recursion.diff (468 bytes ) - added by Jan Rademaker <j.rademaker@…> 17 years ago.

Download all attachments as: .zip

Change History (8)

by Jan Rademaker <j.rademaker@…>, 17 years ago

Attachment: recursion.diff added

comment:1 by Thomas Güttler <hv@…>, 17 years ago

Cc: hv@… added
Triage Stage: UnreviewedAccepted

I can reproduce this and the patch solves the problem.

comment:2 by trey@…, 17 years ago

I have verified that all the tests pass as well. Talked to Malcom and this seems to be an appropriate solution.

in reply to:  2 comment:3 by Trey, 17 years ago

Replying to trey@ktrl.com:

I have verified that all the tests pass as well. Talked to Malcom and this seems to be an appropriate solution.

Let me try that while logged in.

comment:4 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [6807]) Fixed #6021 -- Removed some brain damage from SafeString. Not quite sure what I
was smoking there. Thanks, Jan Rademaker.

comment:5 by Karen Tracey <kmtracey@…>, 17 years ago

Could this possibly be what caused the "Exception Value: maximum recursion depth exceeded Exception Location: usr/local/lib64/python2.5/site-packages/django/utils/safestring.py in __add__, line 73" reported in #6071?

comment:6 by Malcolm Tredinnick, 17 years ago

Karen: no. That's more brain damage on my part. Trey also fixed that yesterday and I'll commit it shortly.

comment:7 by Thomas Güttler <hv@…>, 17 years ago

Cc: hv@… removed
Note: See TracTickets for help on using tickets.
Back to Top