Roundup Tracker - Issues

Issue 2551019

classification
roundup.cgi.actions.ExportCSVAction broken for python3
Type: Severity: normal
Components: Web interface, Infrastructure Versions: devel
process
Status: fixed fixed
:
: : cmeerw, joseph_myers, tekberg
Priority: :

Created on 2019-02-06 18:46 by tekberg, last changed 2020-02-08 00:34 by cmeerw.

Files
File name Uploaded Description Edit Remove
wsgi_handler.py.hgdiff tekberg, 2019-02-06 18:46 hg diff file for wsgi_handler.py
wsgi_handler.py-bs2b.hgdiff tekberg, 2019-02-06 20:48 Updated diff using bs2b function.
Messages
msg6325 Author: [hidden] (tekberg) Date: 2019-02-06 18:46
Problem: exporting to a CSV file fails when using python3

Repeat by:
Install roundup using python3.
  * Bring up a tracker,
  * click 'home' unless already there,
  * click 'Download as CSV'

Error description:
  TypeError: byte string value expected, value of type str found

Location of failure:
  write method of the Writer class in roundup/cgi/wsgi_handler.py

Cause of error:
  Python3 expects the argument to the write method to be a byte string
(e.g. b'somestring') where python 2.7 expects a string.

Solution:
Change the write method to convert the string using the encode function
for utf-8. In python 2.7 this encode function returns a string which is
== to the argument. In python 3 it returns a byte string. The attached
hg diff file contains the details.
msg6326 Author: [hidden] (joseph_myers) Date: 2019-02-06 20:16
Existing practice in the Roundup code for such cases (converting something 
that in Python 3 might be a str or bytes object to bytes) is to use bs2b 
(from roundup.anypy.strings).
msg6327 Author: [hidden] (tekberg) Date: 2019-02-06 20:48
Thanks for the review Joseph. I attached the updated diff.

Of course I tested it to make sure it still works.
msg6336 Author: [hidden] (joseph_myers) Date: 2019-02-10 14:12
Thanks, I've committed this patch.
msg6871 Author: [hidden] (cmeerw) Date: 2020-02-08 00:34
fixed it in the CSV action now (as the issue wasn't limited to the WSGI 
interface), commit f74d078cfd9a
History
Date User Action Args
2020-02-08 00:34:11cmeerwsetnosy: + cmeerw
messages: + msg6871
2019-02-10 14:12:47joseph_myerssetstatus: new -> fixed
resolution: fixed
messages: + msg6336
2019-02-06 20:48:31tekbergsetfiles: + wsgi_handler.py-bs2b.hgdiff
messages: + msg6327
2019-02-06 20:16:07joseph_myerssetnosy: + joseph_myers
messages: + msg6326
2019-02-06 18:46:17tekbergcreate