]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-41086: Add exception for uninstantiated interpolation (configparser) (GH-21062)
authorBrian Faherty <anothergenericuser@gmail.com>
Thu, 17 Feb 2022 12:17:43 +0000 (07:17 -0500)
committerGitHub <noreply@github.com>
Thu, 17 Feb 2022 12:17:43 +0000 (13:17 +0100)
commitfc115c9bde52a58b4fb9be2b80c3d6be8a4d2454
tree0bff1ede5007a36651d434918f8b93d47e9a4c9e
parent5bc4327e2c55c33342a6850c4741e2b63ff96aec
bpo-41086: Add exception for uninstantiated interpolation (configparser) (GH-21062)

* Add exception for uninstantiated interpolation (configparser)

The current feedback when users try to pass an uninstantiated
interpolation into a ConfigParser is an error message that does not help
users solve the problem. This current error of `TypeError: before_set()
missing 1 required positional argument: 'value'` does not display until
the parser is used, which usually results in the assumption that
instantiation of the parser was done correctly. The new exception of
InterpolationTypeError, will be raised on the line where the
ConfigParser is instantiated. This will result in users see the line
that has the error in their backtrace for faster debugging.

There have been a number of bugs created in the issue tracker, which
could have been addressed by:
https://bugs.python.org/issue26831 and https://bugs.python.org/issue26469

* 📜🤖 Added by blurb_it.

* Replace custom Error with TypeError

Per feedback from @iritkatriel, the custom InterpolationTypeError has
been dropped in favour of a TypeError with a custom message, and the
unittests have been expanded.

* More verbose message

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Lib/configparser.py
Lib/test/test_configparser.py
Misc/NEWS.d/next/Library/2020-06-23-01-50-24.bpo-41086.YnOvpS.rst [new file with mode: 0644]