urllib.request.urlopen(data_uri).file are closed automatically when the response is not hold by a variable
オープン
まだ誰も着手していません。
stdlib
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- PR マージ指標
- PR 指標を取得中
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず urllib.request.urlopen の2つの例を再現し、その後、そのエントリポイントの背後にある data-URI の処理を調査します。直接チェーンした .file.read() の呼び出しが閉じたファイルのエラーなしで動作し、既存の保存されたレスポンスの例が引き続き正しく動作することを確認し、この動作の回帰テストを追加できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- networking
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 42/100