Message315164
Hey I'm new here, so please let me know what incorrect things I am doing!
I _think_ `json.dumps(o, ensure_ascii=False)` is doing the wrong thing when `o` has both unicode and str keys/values. For instance:
```
import json
o = {u"greeting": "hi", "currency": "€"}
json.dumps(o, ensure_ascii=False, encoding="utf8")
json.dumps(o, ensure_ascii=False)
```
The first `dumps` will work while the second will fail. the reason is:
https://github.com/python/cpython/blob/2.7/Lib/json/encoder.py#L198
This will decode any str if the encoding is not 'utf-8'. In the mixed case (unicode and str) this will blow. I workaround is to use any of the aliases for 'utf-8' like 'utf8' or 'u8'.
I would be crazy happy to provide a PR if this is really an issue.
Let me know if extra clarification is needed.
Nicolás |
|
Date |
User |
Action |
Args |
2018-04-10 09:21:14 | nhatcher | set | recipients:
+ nhatcher, vstinner, ezio.melotti |
2018-04-10 09:21:14 | nhatcher | set | messageid: <1523352074.24.0.682650639539.issue33255@psf.upfronthosting.co.za> |
2018-04-10 09:21:14 | nhatcher | link | issue33255 messages |
2018-04-10 09:21:13 | nhatcher | create | |
|