| | 157 | |
| | 158 | == Serializing bytes with JSON == |
| | 159 | |
| | 160 | In Python 2 you can serialize bytes with `json`. In Python 3 you can't. Real Soon Now there will be utility module `allmydata.util.jsonbytes` that allows encoding bytes on Python 3, to minimize changes. |
| | 161 | |
| | 162 | == Dictionaries with bytes/unicode keys == |
| | 163 | |
| | 164 | In Python 2 a key can be bytes or unicode, and it will replace the other one. So the key `b"foo"` is the same as `u"foo"` from dict's perspective. In Python 3 they are different keys. |
| | 165 | |
| | 166 | This can lead to bugs when porting, where you end up with two keys instead of one as some strings become Unicode strings. |
| | 167 | |
| | 168 | The interim solution will likely be dicts that enforce key type to be only bytes or only Unicode (https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3476#ticket). |