simplejson-2.0.1 causes unicode-vs-bytestring problems #523

Closed
opened 2008-09-30 21:47:53 +00:00 by warner · 1 comment
warner commented 2008-09-30 21:47:53 +00:00
Owner

A new version of simplejson was released recently, and it appears that the
behavior of simplejson.loads changed. Whereas loads used to always
return unicode strings, now it will return a regular bytestring if the value
will fit into one:

  • simplejson-1.9.2:
>>> simplejson.loads('"a"')
u'a'
  • simplejson-2.0.1:
>>> simplejson.loads('"a"')
'a'

So to be compatible with this newer version, Tahoe needs to carefully coerce
the output of simplejson.loads and convert all the string-or-unicode
objects into unicode objects.

Here is a list of the files that use simplejson.loads:

  • dirnode.py
  • web/directory.py
  • scripts/tahoe_cp.py
  • scripts/tahoe_mv.py
  • scripts/tahoe_ls.py
  • test/check_load.py
  • test/test_web.py
  • test/test_util.py
  • test/test_system.py
A new version of simplejson was released recently, and it appears that the behavior of `simplejson.loads` changed. Whereas loads used to always return unicode strings, now it will return a regular bytestring if the value will fit into one: * simplejson-1.9.2: ``` >>> simplejson.loads('"a"') u'a' ``` * simplejson-2.0.1: ``` >>> simplejson.loads('"a"') 'a' ``` So to be compatible with this newer version, Tahoe needs to carefully coerce the output of `simplejson.loads` and convert all the string-or-unicode objects into unicode objects. Here is a list of the files that use `simplejson.loads`: * dirnode.py * web/directory.py * scripts/tahoe_cp.py * scripts/tahoe_mv.py * scripts/tahoe_ls.py * test/check_load.py * test/test_web.py * test/test_util.py * test/test_system.py
tahoe-lafs added the
code
major
defect
1.2.0
labels 2008-09-30 21:47:53 +00:00
tahoe-lafs added this to the 1.3.0 milestone 2008-09-30 21:47:53 +00:00
warner commented 2008-09-30 22:31:48 +00:00
Author
Owner

Fixed, in changeset:935d1856967cb18e. It looks like simplejson-2.0.0 introduced some speedups, one of which is to optimize decoding of strings that happen to be all-ascii, resulting in this behavior change.

Fixed, in changeset:935d1856967cb18e. It looks like simplejson-2.0.0 introduced some speedups, one of which is to optimize decoding of strings that happen to be all-ascii, resulting in this behavior change.
tahoe-lafs added the
fixed
label 2008-09-30 22:31:48 +00:00
warner closed this issue 2008-09-30 22:31:48 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: tahoe-lafs/trac-2024-07-25#523
No description provided.