Opened 7 years ago

Closed 6 years ago

#12369 closed (fixed)

cStringIO portability

Reported by: rubic Owned by: niall
Component: Documentation Version: 1.1
Severity: Keywords: cStringIO portability
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


In reference to:

cStringIO is a great way to speed up complex reportlab pdfs. For portability in environments that don't have cStringIO, I would encourage django coders to use this idiom:

    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO

Attachments (1)

outputting-pdf.diff (692 bytes) - added by niall 6 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 7 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 6 years ago by niall

  • Has patch set
  • Owner changed from nobody to niall
  • Status changed from new to assigned

Added a simple patch that changes the code sample to use the try, except block and a simple explanation of why it's necessary after the code sample.

comment:3 Changed 6 years ago by Alex

I'd simplify the explanation to just a parenthetical note that "cStringIO is not avilable in all enviroments, StringIO may be used in it's place in such circumstances".

Changed 6 years ago by niall

comment:4 Changed 6 years ago by niall

Updated the patch, now just has a comment above the import with a one line description explaining what's happening.

comment:5 Changed 6 years ago by timo

  • Triage Stage changed from Accepted to Ready for checkin

comment:6 Changed 6 years ago by gabrielhurley

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

(In [14076]) Fixed #12369 -- Improved example to account for environments where cStringIO is not available. Thanks to rubic for the report and niall for the patch.

Note: See TracTickets for help on using tickets.
Back to Top