[New-bugs-announce] [issue32358] json.dump: fp must be a text file object

TaoQingyun report at bugs.python.org
Mon Dec 18 01:24:46 EST 2017


New submission from TaoQingyun <845767657 at qq.com>:

```
>>> import json        
>>> f = open('/tmp/t.json', 'wb')              
>>> json.dump(123, f)  
Traceback (most recent call last):             
  File "<stdin>", line 1, in <module>          
  File "/usr/lib/python3.6/json/__init__.py", line 180, in dump                               
    fp.write(chunk)    
TypeError: a bytes-like object is required, not 'str'
```

This may not a bug. But it should mention at docs https://docs.python.org/3/library/json.html#json.dump

----------
components: Library (Lib)
messages: 308517
nosy: qingyunha
priority: normal
severity: normal
status: open
title: json.dump: fp must be a text file object
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32358>
_______________________________________


More information about the New-bugs-announce mailing list