Roundup Tracker - Issues

Message6210

Author joseph_myers
Recipients joseph_myers
Date 2018-08-19.12:11:01
Message-id <1534680662.98.0.56676864532.issue2550976@psf.upfronthosting.co.za>
In-reply-to
When dealing with single strings, in Python 3, if eval of the value from
the CSV file produces a str value s (which in Python 2 is the string
wanted) then s.encode('iso-8859-1').decode('utf-8') is the actual string
wanted in Python 3; for the reverse direction, where repr(s) is
appropriate in Python 2, repr(s.encode('utf-8'))[1:] will give the
representation in Python 3.

However, the CSV files for journals also use repr / eval on dict objects
which contain strings as values.  So to keep those compatible, after
calling eval I suppose you need to do the
s.encode('iso-8859-1').decode('utf-8') for every str value in the
resulting dict, while maybe the code needs to replicate the effects of
repr on a dict itself in order to do the repr(s.encode('utf-8'))[1:] on
every value in the dict.  (Or you could just replace the dict's str
values with s.encode('utf-8') in Python 3 (call
roundup.anypy.strings.s2b unconditionally) before calling repr on the
dict; that would mean the values appeared as b'...' in the CSV file
generated with Python 3, but Python 2 would still be able to read those
values OK.)
History
Date User Action Args
2018-08-19 12:11:02joseph_myerssetmessageid: <1534680662.98.0.56676864532.issue2550976@psf.upfronthosting.co.za>
2018-08-19 12:11:02joseph_myerssetrecipients: + joseph_myers
2018-08-19 12:11:02joseph_myerslinkissue2550976 messages
2018-08-19 12:11:02joseph_myerscreate