Edgewall Software
Modify

Opened 5 months ago

Closed 5 weeks ago

Last modified 4 weeks ago

#13687 closed defect (fixed)

TypeError: %b requires a bytes-like object, or an object that implements __bytes__, not 'int'

Reported by: Dirk Stöcker Owned by: Jun Omae
Priority: normal Milestone: 1.6.1
Component: report system Version: 1.6
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Fixed a TypeError raised while sending sql format of a report.

API Changes:
Internal Changes:

Description

Report 9 of josm.openstreetmap.de fails when called with format=sql as argument:

Internal Server Error: <RequestWithSession "GET '/report/9?format=sql'">, referrer None
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/trac/web/main.py", line 609, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/lib/python3.10/dist-packages/trac/web/main.py", line 301, in dispatch
    raise e
  File "/usr/local/lib/python3.10/dist-packages/trac/web/main.py", line 247, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/lib/python3.10/dist-packages/trac/ticket/report.py", line 188, in process_request
    template, data, content_type = self._render_view(req, id)
  File "/usr/local/lib/python3.10/dist-packages/trac/ticket/report.py", line 382, in _render_view
    self._send_sql(req, id, title, description, sql)
  File "/usr/local/lib/python3.10/dist-packages/trac/ticket/report.py", line 941, in _send_sql
    out.write(b'-- ## %s: %s ## --\n\n' % (id, title.encode('utf-8')))
TypeError: %b requires a bytes-like object, or an object that implements __bytes__, not 'int'

report is

SELECT id AS ticket, summary, component, type, owner, status
  FROM ticket t
  WHERE status <> 'closed' 
  AND (owner=$USER OR reporter=$USER)
  ORDER BY id desc

Fix:

  • report.py

    old new  
    938938        req.perm(self.realm, id).require('REPORT_SQL_VIEW')
    939939
    940940        out = io.BytesIO()
    941         out.write(b'-- ## %s: %s ## --\n\n' % (id, title.encode('utf-8')))
     941        out.write(b'-- ## %s: %s ## --\n\n' % (str(id).encode("utf-8"), title.encode('utf-8')))
    942942        if description:
    943943            lines = description.encode('utf-8').splitlines()
    944             out.write(b'-- %s\n\n' % '\n-- '.join(lines))
     944            out.write(b'-- %s\n\n' % b'\n-- '.join(lines))
    945945        out.write(sql.encode('utf-8'))
    946946        data = out.getvalue()
    947947

Attachments (0)

Change History (4)

comment:1 by Jun Omae, 5 months ago

Milestone: 1.6.1
Version: 1.6

Thanks for the reporting!

comment:2 by Jun Omae, 5 weeks ago

Release Notes: modified (diff)
Resolution: fixed
Status: newclosed

Fixed in [17778] and merged in [17779].

comment:3 by Ryan J Ollos, 5 weeks ago

Let me know if we need to do a software release. I have a week off at the beginning of July. I plan to work on Edgewall infrastructure and pushing out new releases. If we need one before July I can help make that happen.

Last edited 5 weeks ago by Ryan J Ollos (previous) (diff)

in reply to:  3 comment:4 by Jun Omae, 4 weeks ago

Owner: set to Jun Omae

Replying to Ryan J Ollos:

Let me know if we need to do a software release. I have a week off at the beginning of July. I plan to work on Edgewall infrastructure and pushing out new releases. If we need one before July I can help make that happen.

I consider Trac 1.6 has no critical bugs and not needed a new release before beginning of July. I will be fixing tickets in milestone:1.6.1 for a new release on July. Thanks.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.