Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configparser.ConfigParser: 2 newlines at end of file (EOF) #89512

Closed
PedanticHacker mannequin opened this issue Oct 3, 2021 · 3 comments
Closed

configparser.ConfigParser: 2 newlines at end of file (EOF) #89512

PedanticHacker mannequin opened this issue Oct 3, 2021 · 3 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@PedanticHacker
Copy link
Mannequin

PedanticHacker mannequin commented Oct 3, 2021

BPO 45349
Nosy @ericvsmith, @vadmium, @PedanticHacker
Superseder
  • bpo-32917: ConfigParser writes a superfluous final blank line
  • 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']

    @PedanticHacker
    Copy link
    Mannequin Author

    PedanticHacker mannequin commented 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?

    @PedanticHacker PedanticHacker mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Oct 3, 2021
    @ericvsmith
    Copy link
    Member

    Please provide code that we can run that shows the problem.

    @vadmium
    Copy link
    Member

    vadmium commented 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.

    @vadmium vadmium closed this as completed Oct 3, 2021
    @vadmium vadmium closed this as completed Oct 3, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants