Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#6021 closed (fixed)

RuntimeError when printing a SafeString

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

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@…> 8 years ago.

Download all attachments as: .zip

Change History (8)

Changed 8 years ago by Jan Rademaker <j.rademaker@…>

comment:1 Changed 8 years ago by Thomas Güttler <hv@…>

  • Cc hv@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

I can reproduce this and the patch solves the problem.

comment:2 follow-up: Changed 8 years ago by trey@…

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

comment:3 in reply to: ↑ 2 Changed 8 years ago by trey

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 Changed 8 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:5 Changed 8 years ago by Karen Tracey <kmtracey@…>

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 Changed 8 years ago by mtredinnick

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

comment:7 Changed 8 years ago by Thomas Güttler <hv@…>

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