`configparser.getboolean()` raises `AttributeError` for a value-less option
Open
Nobody has claimed this yet.
stdlib
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug description
When ConfigParser uses allow_no_value=True, calling getboolean() on a value-less option raises AttributeError instead of the documented ValueError.
Documentation:
https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.getboolean
Reproducer
import configparser
config = configparser.ConfigParser(allow_no_value=True)
config.read_string("""
[section]
enabled
""")
assert config.get("section", "enabled") is None
config.getboolean("section", "enabled")
Current result:
AttributeError: 'NoneType' object has no attribute 'lower'
Expected result:
ValueError: Not a boolean: None
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-155437
Contributor 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.
Research direction
Start at the ConfigParser.getboolean() entry point and reproduce the value-less option case from the issue. Check the existing configparser tests for boolean conversion and add coverage showing the documented ValueError for None; the work is done when this case no longer raises AttributeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100