Closed
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
| BPO | 45349 |
|---|---|
| Nosy | @ericvsmith, @vadmium, @PedanticHacker |
| Superseder |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = <Date 2021-10-03.01:50:44.954>
created_at = <Date 2021-10-03.01:02:54.160>
labels = ['type-bug', '3.8', '3.9', '3.10', '3.11', '3.7', 'library']
title = 'configparser.ConfigParser: 2 newlines at end of file (EOF)'
updated_at = <Date 2021-10-03.01:50:44.949>
user = 'https://github.com/PedanticHacker'bugs.python.org fields:
activity = <Date 2021-10-03.01:50:44.949>
actor = 'martin.panter'
assignee = 'none'
closed = True
closed_date = <Date 2021-10-03.01:50:44.954>
closer = 'martin.panter'
components = ['Library (Lib)']
creation = <Date 2021-10-03.01:02:54.160>
creator = 'PythonEnthusiast'
dependencies = []
files = []
hgrepos = []
issue_num = 45349
keywords = []
message_count = 3.0
messages = ['403069', '403071', '403072']
nosy_count = 3.0
nosy_names = ['eric.smith', 'martin.panter', 'PythonEnthusiast']
pr_nums = []
priority = 'normal'
resolution = 'duplicate'
stage = 'resolved'
status = 'closed'
superseder = '32917'
type = 'behavior'
url = 'https://bugs.python.org/issue45349'
versions = ['Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']Metadata
Metadata
Assignees
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
PedanticHacker commentedon Oct 3, 2021
In every Python version that I've tested, writing a config.ini file (utilizing configparser.ConfigParser), the result is such that the config.ini file has 2 newlines at the end of the file.
The problem is that source code editors like Sublime Text, or IDEs like PyCharm, already insert a newline at the end of a file, but then configparser.ConfigParser
(or maybe the Python's write() function?) insert its own as well.
Is it possible to fix this behavior?
ericvsmith commentedon Oct 3, 2021
Please provide code that we can run that shows the problem.
vadmium commentedon Oct 3, 2021
Looks like the same as bpo-32917. I presume there are two newlines at the end of the file because there are two newlines following every config section.
IMO this is a minor cosmetic annoyance, just like writing a key with an empty value gets you a trailing space after the equals sign at the end of the line. Not worth changing as a bug fix, and not worth a special option, but maybe okay to change if the code is simple and it doesn't harm compatibility.