From da065f84a54ee72510f7c8bec80257b31d458320 Mon Sep 17 00:00:00 2001 From: Prince Roshan Date: Sat, 5 Aug 2023 23:36:41 +0530 Subject: [PATCH] Resolve comments --- Doc/library/configparser.rst | 12 +++++------- .../2023-08-05-08-41-58.gh-issue-107625.cVSHCT.rst | 5 ++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index 424252a7998d7a..00385e38b8fe55 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -956,6 +956,11 @@ ConfigParser Objects converter gets its own corresponding :meth:`get*()` method on the parser object and section proxies. + Raise a :exc:`ParsingError` instead of an :exc:`AttributeError` for + :meth:`read` and :meth:`read_file` if the configuration contains + a key without a corresponding value in scenarios where configuration + contains extra space or newline within a section. + .. versionchanged:: 3.1 The default *dict_type* is :class:`collections.OrderedDict`. @@ -1030,13 +1035,6 @@ ConfigParser Objects directory), and all existing configuration files in the iterable will be read. - Raise :exc:`ParsingError` instead of :exc:`AttributeError` - when the configuration contains a key without a corresponding value. - This change is intended to handle scenarios where a key lacks a value - in a configuration which contains extra space or newline within a section. - Please note that it's not recommended to have extra spaces - or blank lines within sections of the configuration. - If none of the named files exist, the :class:`ConfigParser` instance will contain an empty dataset. An application which requires initial values to be loaded from a file should load the required file or diff --git a/Misc/NEWS.d/next/Library/2023-08-05-08-41-58.gh-issue-107625.cVSHCT.rst b/Misc/NEWS.d/next/Library/2023-08-05-08-41-58.gh-issue-107625.cVSHCT.rst index b38069408f9d51..00f919da1e7675 100644 --- a/Misc/NEWS.d/next/Library/2023-08-05-08-41-58.gh-issue-107625.cVSHCT.rst +++ b/Misc/NEWS.d/next/Library/2023-08-05-08-41-58.gh-issue-107625.cVSHCT.rst @@ -1 +1,4 @@ -Raise an :exc:`ParsingError` instead of an :exc:`AttributeError` when the configuration contains a key without a corresponding value in a scenario where extra space or a new line is present within the section. +Emit :exc:`ParsingError` from :meth:`read` and :meth:`read_file` +of :class:`ConfigParser` if configuration contains a key +without a corresponding value in a scenario where extra space +or a new line is present within the section.