[Python-Dev] folding cElementTree behind ElementTree in 3.3 (original) (raw)

Ezio Melotti ezio.melotti at gmail.com
Thu Feb 16 18:32:24 CET 2012


On 14/02/2012 9.58, Stefan Behnel wrote:

Nick Coghlan, 14.02.2012 05:44:

On Tue, Feb 14, 2012 at 2:25 PM, Eli Bendersky wrote:

With the deprecation warning being silent, is there much to lose, though? Yes, it creates problems for anyone that deliberately converts all warnings to errors when running their test suites. This forces them to spend time switching over to a Python version dependent import of either cElementTree or ElementTree that could have been spent doing something actually productive instead of mere busywork.

If I'm writing code that imports cElementTree on 3.3+, and I explicitly turn on DeprecationWarnings (that would otherwise be silenced) to check if I'm doing something wrong, I would like Python to tell me "You don't need to import that anymore, just use ElementTree.". If I'm also converting all the warnings to errors, it's probably because I really want my code to do the right thing and spending 1 minute to add/change two line of code to fix this won't probably bother me too much. Regular users won't even notice the warning, unless they stumble upon the note in the doc or enable the warnings (and eventually when the module is removed).

And, of course, even people that don't convert warnings to errors when running tests will have to make the same switch when the module is eventually removed.

When the module is eventually removed and you didn't warn them in advance, the situation is going to turn much worse, because their code will suddenly stop working once they upgrade to the newer version. I don't mind keeping the module and the warning around for a few versions and give enough time for everyone to update their imports, but if eventually the module is removed I don't want all these developers to come and say "why you removed cElementTree without saying anything and broke all my code?".

I'm -1 on emitting a deprecation warning just because cElementTree is being replaced by a bare import. That's an implementation detail, just like cElementTree should have been an implementation detail in the first place. In all currently maintained CPython releases, importing cElementTree is the right thing to do for users.

From 3.3 the right thing will be importing ElementTree, and at some point in the future that will be the only way to do it.

These days, other Python implementations already provide the cElementTree module as a bare alias for ElementTree.py anyway, without emitting any warnings. Why should CPython be the only one that shouts at users for importing it?

I would watch this from the opposite point of view. Why should the other Python implementation have a to keep around a dummy module due to a CPython implementation detail? If we all go through a deprecation process we will eventually be able to get rid of this.

Best Regards, Ezio Melotti

Stefan



More information about the Python-Dev mailing list