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
Emphasising in the docs configparser.SafeConfigParser over ConfigParser #50766
Comments
There seems to be no way to add a config item with a value containing a A possible way to escape the formatstrings could be to double the [foo] The value of the bar item should then be "%(string)s". |
The formatstring is a Python % formatting code, and doubling the %% is |
Afacs it is not documented to work. Here is the testcase: #!/usr/bin/python import ConfigParser
import tempfile
file = tempfile.TemporaryFile(mode='rw+b')
file.write("[s]\nf=%%(b)s\n")
file.seek(0)
config = ConfigParser.ConfigParser()
config.readfp(file) print config.get("s", "f") file.close() |
Ah, that's because you aren't using SafeConfigParser (which the docs You are correct that it is not explicitly documented in the ConfigParser To make this all explicit, I've attached a doc patch to make the Georg, Raymond, I added you as nosy to ask for a style/content opinion. |
It would be nice if you could expand the patch to also use only one name In the beginning it is introduced as "reference expansion", but later in Another nice improvement would also be to move the ConfigParser to a |
This issue superseeds bpo-8888 because of the patches attached. Brett, there are two ways we can solve this issue:
I personally would go with 1. and maybe just "hint" about the fact that ConfigParser is not for end users. Formal deprecation seems too big for this since the regular ConfigParser still does have its valid use cases. Please decide on what we're going to do and I'll edit the docs and add the tests here to py3k. |
I disagree. The documentation should promote RawConfigParser, and note Documentation changes should be sufficient; deprecation warnings |
That is another way to go around this. Anyway, ConfigParser is the least predictable of all three for end users and the documentation should be adjusted to emphasize this.
That's another comment that should appear in the documentation.
Isn't is what I was saying above? |
We're in agreement; I was specifically adding weight to *not*
|
This should just be applied. I'll do it shortly unless there is an objection. |
It is (very) unfortunate that configparser.ConfigParser should *not* be used and that configparser.SafeConfigParser is the correct class instead. I would be *in favour* of deprecating ConfigParser and eventually renaming SafeConfigParser back to ConfigParser (leaving SafeConfigParser as an alias). Now that deprecation warnings are silent by default this should be less of an issue. |
You are right, IMO, at least the current doc patch should be applied. Please go ahead, if you want to, I won't have time to get to it for a couple of days. Maybe you could come up with a new title for this issue that reflects the concerns being addressed here... |
Note that the patch doesn't apply cleanly. Łukasz Langa is going to update it. There is still discussion as to whether we should *also* deprecate ConfigParser (well - PendingDeprecation in 3.2, Deprecation in 3.3 and in 3.4 making ConfigParser an alias for SafeConfigParser). |
The 3.2 docs now don't mention ConfigParser prominently anymore (as part of a different patch that added some features). Could be done in other branches as well. |
Yes, so the patch part is already solved. The thing that is still open to discussion is whether we should do something like this:
This is controversial but many developers (myself included) don't see the point in running naked ConfigParser because it's basically SafeConfigParser sans its completeness and predictability. So, please +1 or -1 the deprecation process idea. +1 from me |
+1 for deprecation. Nobody *should* be using ConfigParser anyway, and of those who are 99% either wouldn't notice or would have bugs in their code *fixed* by the rename, so I can't see much of a downside. |
If ConfigParser is not documented first, the name “SafeConfigParser” becomes strange—safe compared to what? These names have an historical motivation and could become clearer if renamed, but I don’t know if python-dev will agree with this deprecation. Renaming a class to an existing name with different behavior can be bad. FTR, in my head RawConfigParser is the config parser, and SafeConfigParser is another thing that I’ll maybe use one day. |
The first sentence is "Derived class of ConfigParser that implements a sane variant of the magical interpolation feature." I think it's enough for an explanation. If this were an encyclopedia, you would be right. But this is more like a Google search results page. Most people will take the first thing that looks like a solution they need.
That is the point.
That would be a shame, essentially it should happen in 3.0 IMO. But it's never too late I think. Think of the children! One day you will read this comment and think: whoa, this was even BEFORE 3.2! Yeah, ancient history.
Yes but this is going to be a problem for 3.4. Maybe then we'll come up with something more natural.
YMMV. FTR, many people I've spoken to treated RawConfigParser as something more low-level and not suitable for consumer use just because of the name AND the presence of a default (=name like the module) ConfigParser class. |
Agree with Michael, +1. |
True.
I wrote that before seeing Michael’s reply. Since Georg is +1 too, I can only say: Great, let’s do it!
Right. I don’t know if people using ConfigParser really want to use the interpolation. If we want to give the same name as the module to the best class for people who don’t read docs, I’d prefer renaming RawConfigParser to ConfigParser and SafeConfigParser to SomethingConfigParser. |
Eric, while I agree that would be nice as well, renaming each and every parser in the module will be more problematic for sure. *** TO ALL: WHAT DO YOU SAY TO A PATH LIKE THIS ***
InterpolatingConfigParser = SafeConfigParser 1.1) In 3.2 we Pending-Deprecate: ConfigParser (message about it being removed in 3.4)
ConfigParser Same messages.
I like that because it opens a new possibility which I would wait with until 3.5: re-introduce ConfigParser but as a completely new subclass that has better but backwards incompatible defaults. For now most of the new functionality I've added is turned off by default because of backwards compatibility reasons and this is unfortunate. |
2010/8/3 Łukasz Langa <report@bugs.python.org>:
I'd rather see the class renamed and SafeConfigParser made the alias in 3.2. Otherwise, +1 for this plan (msg 112589), as there's no silent breakage. |
I'd be happy with aliasing SafeConfigParser to ConfigParser in 3.2. Can we just do this without a deprecation process? |
Making ConfigParser an alias for SafeConfigParser creates a silent -1 So long as the application developer has to change their code to move |
Unfortunately, I have to agree with Fred here. We'll stick to renaming and the deprecation process. |
Sorry - I misunderstood your earlier suggestion Fred. configparser.ConfigParser is the *natural* name for SafeConfigParser. I'm strongly +1 on moving towards that. (I doubt there would *actually* be any real code breakage if we did it earlier though ;-) |
By the way, given that deprecation warnings are silent I am strongly -1 on removing the ConfigParser name altogether. That would cause far more breakage. As ConfigParser should not be used at all, and SafeConfigParser provides its functionality minus bugs, SafeConfigParser (horrible name) should replace it. |
Agree on the proposal of Łukasz, with the caveat mentioned by Fred (rename the class and make the old name an alias, for pickle and all). I’ll let Michael and Fred decide if the name ConfigParser has to go or not, I’m happy enough that the class will be deprecated and removed. |
Getting *rid* of the name ConfigParser would be annoying and cause *gratuitous* code breakage. If we are going to keep the name but get rid of the "unsafe" version then we can only replace it with what is now SafeConfigParser - as it is almost entirely compatible with it. (Modulo the bug fixing "behavioural change".) So the real choices are:
Only the last of these is a positive step forwards... :-) (Strongly -1 on introducing *yet another name* to refer to these classes by.) |
There IS one more option that seems to be better than all of the above:
We can do all this for 3.2 I guess without inflicting any actual damage. It will fix more bugs in running code that break config files. Maybe we shouldn't be so afraid after all and just clean it up. |
It doesn't make sense to make any of these changes to Python 2; this Merging implementations
Changing ConfigParser behavior Changing the behavior of the ConfigParser name requires the deprecation Whether we can assign new semantics to the ConfigParser name in the (This seems to be the real sticking point, unfortunately.) Class names I don't understand Michael's objection to adding new names for the In the case of a merged implementation, a new name for the merged class |
If we merge the functionality in a single class with a new name then I guess that is fine as it will simplify the documentation rather than complexify it (good word hey). We still need to *mention* the old names so that people finding them in old code can find an up to date reference on them. Here's what I don't understand about Fred's difficulty with replacing ConfigParser with the sane implementation. After we deprecate ConfigParser as it is now we have two choices.
I don't see how the first option could *in any way* be preferable to the second. |
Hopefully both RawConfigParser and ConfigParser will be successfully deprecated as part of bpo-10499. The discussion goes on there. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: