Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`LogRecord` should normalize falsy `exc_info` values

オープン 初心者向け
#158,839 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

Lib/logging/init.pyで、issueで挙げられているloggingの呼び出し経路を確認してください。ここではexc_infoがmakeRecordの前に正規化されます。関連するloggingのテストを確認し、FalseやNoneなどのfalsyなexc_info値をカバーするテストを追加してください。falsyな値がNoneとしてLogRecordに渡され、テストが成功すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

stdlib type-bug
Bug report

Pointed out by @tjkuson in python/typeshed#16466

According to the documentation, the exc_info argument to the log() group of function can be any falsy value to indicate that no exception information is provided. It's common to use either None or False here.

When a truthy value is provided, it is normalized to an exception info tuple before passing it to LogRecord. A falsy value is passed on unchanged:

https://github.com/python/cpython/blob/9112daed900c3314fa522043fc64ddbb2ecd4ca5/Lib/logging/__init__.py#L1678-L1682

This contradicts LogRecords documentation, which says that only None is accepted and that the exc_info field can be a tuple or None. The mypy primer run in python/typeshed#16466 shows that a few projects make this assumption. For example, sphinx:

        if record.exc_info is not None:
            raise SphinxWarning(message) from record.exc_info[1]

Solution: Normalize falsy values to None before passing them to makeRecord.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs
  • gh-158840
主要言語
Python
スター
77.6k
フォーク
37.6k
平均マージ
1日 16時間
マージ済み PR(30日)
612

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python/cpython のほかの issue

python/cpython の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。