Edgewall Software

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#12674 closed defect (fixed)

TypeError: 'unicode' does not have the buffer interface — at Version 4

Reported by: Ryan J Ollos Owned by: Christian Boos
Priority: normal Milestone: 1.3.2
Component: roadmap Version:
Severity: minor Keywords:
Cc: Branch:
Release Notes:

Fixed regression in r15010 that resulted in TypeError when exporting iCal from the roadmap.

API Changes:
Internal Changes:

Description

Found in the logs:

2017-01-26 09:57:35,825 Trac[main] ERROR: Internal Server Error: <RequestWithSession "GET '/roadmap?format=ics'">, referrer None
Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 630, in _dispatch_request
    dispatcher.dispatch(req)
  File "build/bdist.linux-x86_64/egg/trac/web/main.py", line 252, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-x86_64/egg/trac/ticket/roadmap.py", line 511, in process_request
    self._render_ics(req, milestones)
  File "build/bdist.linux-x86_64/egg/trac/ticket/roadmap.py", line 598, in _render_ics
    self.env.project_name + ' - ' + _("Roadmap"))
  File "build/bdist.linux-x86_64/egg/trac/ticket/roadmap.py", line 578, in write_prop
    buf.write(text[:75] + CRLF)
TypeError: 'unicode' does not have the buffer interface 

Change History (4)

comment:1 by Christian Boos, 7 years ago

Looks like in r15010, an io.BytesIO() was used where it should have been a io.StringIO().

This, plus a to_unicode() in write_prop(), as it seems that io.StringIO() is quite picky…

  • trac/ticket/roadmap.py

    diff --git a/trac/ticket/roadmap.py b/trac/ticket/roadmap.py
    index db89d58..e93239c 100644
    a b class RoadmapModule(Component):  
    533533    def _render_ics(self, req, milestones):
    534534        req.send_response(200)
    535535        req.send_header('Content-Type', 'text/calendar;charset=utf-8')
    536         buf = io.BytesIO()
     536        buf = io.StringIO()
    537537
    538538        from trac.ticket import Priority
    539539        priorities = {}
    class RoadmapModule(Component):  
    570570                                                  in params.items()]) + \
    571571                   ':' + escape_value(value)
    572572            firstline = 1
     573            text = to_unicode(text)
    573574            while text:
    574575                if not firstline:
    575576                    text = ' ' + text

comment:2 by Christian Boos, 7 years ago

Milestone: 1.3.2
Owner: set to Christian Boos
Status: newassigned

comment:3 by Christian Boos, 7 years ago

Resolution: fixed
Severity: normalminor
Status: assignedclosed

Applied in r15402.

comment:4 by Ryan J Ollos, 7 years ago

Release Notes: modified (diff)

Added test coverage in r15498.

Last edited 7 years ago by Ryan J Ollos (previous) (diff)
Note: See TracTickets for help on using tickets.