You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exception for uninstantiated interpolation (configparser) #85258
The ConfigParser in Lib has a parameter called interpolation, that expects an instance of a subclass of Interpolation. However, when ConfigParser is given an argument of an uninstantiated subclass of Interpolation, the init function of ConfigParser accepts it and continues on. This results in a later receiving an error message along the lines of TypeError: before_set() missing 1 required positional argument: 'value' when functions are later called on the ConfigParser instance. This delay between the feedback and the original mistake has led to a few bugs open on the issue tracker (https://bugs.python.org/issue26831 and https://bugs.python.org/issue26469. Both of which were closed after a quick and simple explanation, which can be easily implemented in the library itself.
I've created a PR for this work and will attach it shortly. Please let me know if there is a better name for the exception other than InterpolationIsNotInstantiatedError. It seems long, but also in line with the other Errors already in configparser.
It's a behavioral change that tightens acceptable objects passed to interpolation=. In the past any object that provided the same interface as Interpolation instances would be accepted. No longer.
I think this is an acceptable compromise but it's definitely outside of the realm of backporting.
Activity
scrummyin commentedon Jun 23, 2020
The ConfigParser in Lib has a parameter called
interpolation, that expects an instance of a subclass of Interpolation. However, when ConfigParser is given an argument of an uninstantiated subclass of Interpolation, the init function of ConfigParser accepts it and continues on. This results in a later receiving an error message along the lines ofTypeError: before_set() missing 1 required positional argument: 'value'when functions are later called on the ConfigParser instance. This delay between the feedback and the original mistake has led to a few bugs open on the issue tracker (https://bugs.python.org/issue26831 and https://bugs.python.org/issue26469. Both of which were closed after a quick and simple explanation, which can be easily implemented in the library itself.I've created a PR for this work and will attach it shortly. Please let me know if there is a better name for the exception other than
InterpolationIsNotInstantiatedError. It seems long, but also in line with the other Errors already in configparser.iritkatriel commentedon Oct 22, 2021
This is not a bugfix so it should probably not be backported.
3 remaining items
ambv commentedon Feb 17, 2022
New changeset fc115c9 by Brian Faherty in branch 'main':
bpo-41086: Add exception for uninstantiated interpolation (configparser) (GH-21062)
fc115c9
ambv commentedon Feb 17, 2022
It's a behavioral change that tightens acceptable objects passed to
interpolation=. In the past any object that provided the same interface asInterpolationinstances would be accepted. No longer.I think this is an acceptable compromise but it's definitely outside of the realm of backporting.
Thanks for your contribution, Brian! ✨ 🍰 ✨