`http.client.HTTPSConnection._tunnel` raises `AttributeError: 'NoneType' object has no attribute 'encode'` when header value is `None`
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- python
- 領域
- backend, networking
調査の方向性
まず http.client.HTTPSConnection._tunnel と Lib/http/client.py にある set_tunnel の処理を読み、報告で特定されているバージョン 3.10.20 の動作と比較してください。Lib/test/test_httplib.py にある既存のトンネルテストを確認し、ヘッダー値が None の場合のテストを追加してください。回帰がテストでカバーされ、この入力で _tunnel() がクラッシュしなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Bug report
Bug Description
Calling http.client.HTTPSConnection._tunnel() raises AttributeError: 'NoneType' object has no attribute 'encode' when _tunnel_headers contains a header key with a None value.
This regression affects third-party libraries (such as Apache Thrift and CodeChecker) that pass header dictionaries containing None values into set_tunnel(..., headers=...) or HTTP connection objects.
In Python 3.10.21, _tunnel() introduced strict encoding of tunnel headers (value.encode("latin-1")) without checking if the header value is None.
Target Python Version
Python 3.10.21 (Regression introduced between 3.10.20 and 3.10.21)
Operating System
Linux / Ubuntu
Code to Reproduce
import http.client
conn = http.client.HTTPSConnection("127.0.0.1", 8080)
# Set tunnel with a header value of None
conn.set_tunnel("example.com", 443, headers={"X-Test-Header": None})
# Call _tunnel() to trigger the issue
conn._tunnel()
Expected Behavior
_tunnel() should gracefully handle or filter out header keys with None values (or handle string conversions) rather than crashing with an AttributeError.
Actual Behavior
Traceback (most recent call last):
File "reproduce.py", line 9, in
conn._tunnel()
File "/usr/lib/python3.10/http/client.py", line 936, in _tunnel
value_bytes = value.encode("latin-1")
AttributeError: 'NoneType' object has no attribute 'encode'
CPython versions tested on:
3.10
Operating systems tested on:
Linux
- 主要言語
- Python
- スター
- 77.6k
- フォーク
- 37.6k
- 平均マージ
- 1日 10時間
- マージ済み PR(30日)
- 573
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/cpython のほかの issue
-
A minor problem with the section "6.10.2. Membership test operations" from the language reference.オープンdocs
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
Docs: socket.htons() and friends raise ValueError for negative input since 3.14対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンdocs
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
python/cpython#159012 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
stdlib topic-profiling type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
stdlib type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
lazy import of `_sysconfig` in `Lib/ctypes/__init__.py` is eager on android and cygwin対応中かも @sillyfellow21 が 5 日前に担当しました。 オープンtests topic-lazy-imports
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
python/cpython#158684 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
MystenLabs/MemWal#1163 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
infertopics leaves new nodes without a topic when untopiced neighbours outnumber topiced ones対応中かも @moneebullah25 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
ClanGenOfficial/clangen#6254 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
FinanceFlash/unvibecode#218 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信