Edgewall Software

Opened 3 months ago

Closed 3 months ago

#13575 closed defect (fixed)

Blank page in CGI mode

Reported by: ebourg@… Owned by: Jun Omae
Priority: normal Milestone: 1.6
Component: web frontend Version: 1.5.4
Severity: major Keywords: cgi
Cc: Branch:
Release Notes:

Write data as binary to stdout in CGI frontend.

API Changes:
Internal Changes:


I've upgraded a Trac instance deployed on Apache in CGI mode. The database upgrade went well, testing in standalone mode looked ok, but with Apache I just got a blank page, no HTTP error, no stacktrace, and nothing in the Apache error.log in debug mode.

I tracked down the issue to cgi_frontend.py where an exception occurs (but isn't propagated for some reason) when calling sys.stdout.write(data):

write() argument must be str, not bytes

Converting the bytes to string fixed the issue:


Attachments (0)

Change History (4)

comment:1 by anonymous, 3 months ago

Actually it fixed only the rendering of the HTML pages, it broke the images.

comment:2 by anonymous, 3 months ago

This seems to work better:


comment:3 by Jun Omae, 3 months ago

Keywords: cgi added
Milestone: 1.6
Owner: set to Jun Omae
Status: newassigned

Thanks for the report. Reproduced it by the following:

$ TRAC_ENV=/var/trac/1.5-sqlite \
> SERVER_PORT=3000 \
> PATH_INFO=/chrome/common/trac.ico \
> /venv/trac/1.5.4/bin/python -m trac.web.cgi_frontend
Status: 200 Ok
Content-Type: image/x-icon
Content-Length: 3638
Last-Modified: Mon, 20 Feb 2023 02:34:22 GMT
Set-Cookie: trac_session=da00d9c1ae3bde3ef228a048; expires=Wed, 07 Jun 2023 10:09:00 GMT; HttpOnly; Path=/

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/venv/trac/1.5.4/lib/python3.9/site-packages/trac/web/cgi_frontend.py", line 71, in run
  File "/venv/trac/1.5.4/lib/python3.9/site-packages/trac/web/wsgi.py", line 125, in run
  File "/venv/trac/1.5.4/lib/python3.9/site-packages/trac/web/cgi_frontend.py", line 49, in _write
TypeError: write() argument must be str, not bytes

comment:4 by Jun Omae, 3 months ago

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

Fixed in [17686].

Modify Ticket

Change Properties
Set your email in Preferences
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.