`LogRecord` should normalize falsy `exc_info` values
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start in Lib/logging/init.py at the logging call path cited in the issue, where exc_info is normalized before makeRecord. Check the relevant logging tests and add coverage for falsy exc_info values such as False and None. Done when falsy values reach LogRecord as None and the tests pass.
Written by the indexing model from the issue text.
Description
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:
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
- Dominant language
- Python
- Stars
- 77.6k
- Forks
- 37.6k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 573
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python/cpython
-
stdlib type-bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
python/cpython#159044 · 4 comments ·
Maintainers usually reply within 1 day
-
A minor problem with the section "6.10.2. Membership test operations" from the language reference.Opendocs
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Docs: socket.htons() and friends raise ValueError for negative input since 3.14Possibly taken A pull request linked to this issue is open or already merged. Opendocs
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
python/cpython#159012 · 1 comment ·
Maintainers usually reply within 1 day
-
stdlib topic-profiling type-bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
lazy import of `_sysconfig` in `Lib/ctypes/__init__.py` is eager on android and cygwinPossibly taken @sillyfellow21 claimed this 5 days ago. Opentests topic-lazy-imports
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
python/cpython#158684 · 4 comments ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
MystenLabs/MemWal#1163 · 2 comments ·
Maintainers usually reply within 1 day
-
infertopics leaves new nodes without a topic when untopiced neighbours outnumber topiced onesPossibly taken @moneebullah25 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ClanGenOfficial/clangen#6254 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
FinanceFlash/unvibecode#218 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day