Open
Description
Bug report
Opening a data uri with urllib.request.urlopen
and read it directly will result in I/O operation on closed file.
.
Errored example:
from urllib.request import urlopen
url = 'data:text/plain,hello world'
print(urlopen(url).file.read())
"""
Output:
Traceback (most recent call last):
File "/home/maple3142/tmp/xa.py", line 4, in <module>
print(urlopen(url).file.read())
ValueError: I/O operation on closed file.
"""
Normal example:
from urllib.request import urlopen
url = 'data:text/plain,hello world'
resp = urlopen(url)
print(resp.file.read())
"""
Output:
b'hello world'
"""
Your environment
- CPython versions tested on: 3.8.11, 3.10.4
- Operating system and architecture: Arch Linux on WSL2 on Windows 10 x64