<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, 2 May 2018 at 02:12 Victor Stinner <<a href="mailto:vstinner@redhat.com">vstinner@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
As a follow-up to the "[Python-Dev] (Looking for) A Retrospective on<br>
the Move to Python 3" thread, I will like to clarify how a feature<br>
should be removed from Python.<br>
<br>
We have multiple tools:<br>
<br>
* Emit a PendingDeprecationWarning warning at runtime for *slow*<br>
deprecation (remove a feature in at least 3 cycles)<br>
* Emit a DeprecationWarning warning at runtime for fast deprecation<br>
(remove a feature in 2 cycles)<br>
* Document that a feature is deprecated in the module documentation<br>
* "What's New in Python X.Y?" documents: especially Deprecated,<br>
Removed and Porting to Python X.Y sections.<br>
* Communicate on python-dev, Twitter, Python Insider blog, etc.<br>
* Collaborate with major Python projects to help them to migrate the alternative<br>
<br>
IMHO a feature should not be removed if there is no alternative, or if<br>
the alternative is too new.<br>
<br>
The usual process is:<br>
<br>
* Document the deprecation and emit DeprecationWarning in version N<br>
* Document the removal and remove the feature in version N+1<br>
<br>
Slow deprecation:<br>
<br>
* Document the deprecation and emit PendingDeprecationWarning in version N<br>
* Emit a DeprecationWarning in version N+1<br>
* Document the removal and remove the feature in version N+2<br>
<br>
The hidden ghost is the old rule:<br>
<br>
   "keep old APIs around to make porting from Python 2 easier"<br>
<br>
Is this rule still applicable?<br></blockquote><div><br></div><div>Python 2 is still supported, so I assume so.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Does it mean that the Python 3 release following Python 2 end-of-life<br>
(2020) will be our next feared "Python 4"? Are we going to remove all<br>
deprecated features at once, to maximize incompatibilities and make<br>
users unhappy?<br></blockquote><div><br></div><div>I don't see why removing features that already raise a DeprecationWarning would require bumping the major version number. Personally, I assumed either Python 3.9 or 3.10 would be the version where we were okay clearing out the stuff that had been raising DeprecationWarning for years.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Should we always document in which version a feature will be removed?<br></blockquote><div><br></div><div>We should at least open an issue to track when the removal is scheduled. But if we know ahead of time then I so no reason not to document it.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Some features are deprecated since many versions, and the deprecated<br>
features are still there. In most cases, it's because of the Python 2<br>
rule.<br>
<br>
Sometimes, we forget to remove features which has been scheduled for<br>
removal in a specific version.<br></blockquote><div><br></div><div>Right, which is why we should open an issue immediately. I had a "remove pyvenv" issue open and assigned to myself for years while I waited for Python 3.8 development to open. Staring at that issue for so long made sure I didn't forget. ;)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Maybe we should create a tool to list features scheduled for removal,<br>
and open a discussion to check each removal?<br></blockquote><div><br></div><div>I don't know if a tool is necessary. We could have a meta issue or text file somewhere to track what's to be removed in a certain version.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Ten years ago, I wanted to remove most modules and many functions from<br>
the standard library. Now my experience showed me that *each* removal<br>
is very painful, hurt more projects than expected, and takes longer<br>
than 3 years to be fully effective (no longer used in most common 3rd<br>
party modules).<br>
<br>
The usual issue is to write a single code base working on all Python<br>
versions. For example, the new alternative is only available on recent<br>
Python versions, which requires to have at least two code paths to<br>
support all versions. Sometimes, there are 3 code paths...<br>
<br>
For a recent example, see "remove platform.linux_distribution()":<br>
<a href="https://bugs.python.org/issue28167" rel="noreferrer" target="_blank">https://bugs.python.org/issue28167</a><br>
<br>
Removing a feature from the C API is more complex, since there is no<br>
portable way to emit a deprecation warning at compilation. There is<br>
Py_DEPRECATED() which seems to only be available on GCC (3.1 and<br>
newer).<br>
<br>
Maybe we should stop to remove features, except if there is really a<br>
good reason to do that?<br></blockquote><div><br></div><div>I thought that already was the policy. ;) I think the real question is what is people's definition of a "good reason". For instance, I'm all for removing unsupported code so we don't have to maintain it, even if it's just from code modernization and such (i.e. pruning down the stdlib). But I also know others disagree with me and are fine just having modules sit there as long as the issue rate is low enough to not notice. It's just one of those things we don't have an official policy on (yet?).<br><br></div><div>-Brett<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Victor<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/brett%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/brett%40python.org</a><br>
</blockquote></div></div>