Issue 2551019
Created on 2019-02-06 18:46 by tekberg, last changed 2020-02-08 00:34 by cmeerw.
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
|
|
Date |
User |
Action |
Args |
2020-02-08 00:34:11 | cmeerw | set | nosy:
+ cmeerw messages:
+ msg6871 |
2019-02-10 14:12:47 | joseph_myers | set | status: new -> fixed resolution: fixed messages:
+ msg6336 |
2019-02-06 20:48:31 | tekberg | set | files:
+ wsgi_handler.py-bs2b.hgdiff messages:
+ msg6327 |
2019-02-06 20:16:07 | joseph_myers | set | nosy:
+ joseph_myers messages:
+ msg6326 |
2019-02-06 18:46:17 | tekberg | create | |
|