2009-06-18 22:18:28 -04:00
|
|
|
|
PEP: 387
|
|
|
|
|
Title: Backwards Compatibility Policy
|
|
|
|
|
Version: $Revision$
|
|
|
|
|
Last-Modified: $Date$
|
|
|
|
|
Author: Benjamin Peterson <benjamin@python.org>
|
2019-04-17 19:47:45 -04:00
|
|
|
|
BDFL-Delegate: Brett Cannon (on behalf of the steering council)
|
2020-06-15 19:45:49 -04:00
|
|
|
|
Discussions-To: https://discuss.python.org/t/pep-387-backwards-compatibilty-policy/
|
2020-07-20 14:47:55 -04:00
|
|
|
|
Status: Active
|
2009-06-18 22:18:28 -04:00
|
|
|
|
Type: Process
|
|
|
|
|
Content-Type: text/x-rst
|
|
|
|
|
Created: 18-Jun-2009
|
2020-06-15 19:45:49 -04:00
|
|
|
|
Post-History: 19-Jun-2009, 12-Jun-2020
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Abstract
|
|
|
|
|
========
|
|
|
|
|
|
|
|
|
|
This PEP outlines Python's backwards compatibility policy.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rationale
|
|
|
|
|
=========
|
|
|
|
|
|
2020-05-27 22:45:05 -04:00
|
|
|
|
As one of the most used programming languages today [#tiobe]_, the
|
|
|
|
|
Python core language and its standard library play a critical role in
|
|
|
|
|
millions of applications and libraries. This is fantastic. However, it
|
|
|
|
|
means the development team must be very careful not to break this
|
|
|
|
|
existing 3rd party code with new releases.
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
2020-06-16 15:47:42 -04:00
|
|
|
|
This PEP takes the perspective that "backwards incompatibility" means
|
|
|
|
|
preexisting code ceases to comparatively function after a change. It is
|
|
|
|
|
acknowledged that this is not a concrete definition, but the expectation
|
|
|
|
|
is people in general understand what is meant by
|
|
|
|
|
"backwards incompatibility", and if they are unsure they may ask the
|
|
|
|
|
Python development team and/or steering council for guidance.
|
|
|
|
|
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
|
|
|
|
Backwards Compatibility Rules
|
|
|
|
|
=============================
|
|
|
|
|
|
2009-06-19 16:55:54 -04:00
|
|
|
|
This policy applies to all public APIs. These include:
|
|
|
|
|
|
|
|
|
|
- Syntax and behavior of these constructs as defined by the reference
|
2020-06-15 19:45:49 -04:00
|
|
|
|
manual.
|
2009-06-19 16:55:54 -04:00
|
|
|
|
|
2020-06-15 19:45:49 -04:00
|
|
|
|
- The C-API.
|
2009-06-19 16:55:54 -04:00
|
|
|
|
|
|
|
|
|
- Function, class, module, attribute, and method names and types.
|
|
|
|
|
|
2009-06-19 17:03:44 -04:00
|
|
|
|
- Given a set of arguments, the return value, side effects, and raised
|
|
|
|
|
exceptions of a function. This does not preclude changes from
|
|
|
|
|
reasonable bug fixes.
|
|
|
|
|
|
2009-06-19 16:55:54 -04:00
|
|
|
|
- The position and expected types of arguments and returned values.
|
|
|
|
|
|
|
|
|
|
- Behavior of classes with regards to subclasses: the conditions under
|
|
|
|
|
which overridden methods are called.
|
|
|
|
|
|
2020-06-15 19:45:49 -04:00
|
|
|
|
- Documented exceptions and the semantics which lead to their raising.
|
|
|
|
|
|
|
|
|
|
- Exceptions commonly raised in EAFP scenarios.
|
|
|
|
|
|
2016-07-11 11:14:08 -04:00
|
|
|
|
Others are explicitly not part of the public API. They can change or
|
2009-06-19 16:55:54 -04:00
|
|
|
|
be removed at any time in any way. These include:
|
|
|
|
|
|
2020-06-15 19:45:49 -04:00
|
|
|
|
- Function, class, module, attribute, method, and C-API names and
|
|
|
|
|
types that are prefixed by "_" (except special names).
|
|
|
|
|
|
|
|
|
|
- Anything documented publicly as being private.
|
|
|
|
|
|
|
|
|
|
- Imported modules (unless explicitly documented as part of the public
|
|
|
|
|
API; e.g. importing the ``bacon`` module in the ``spam`` does not
|
2020-06-20 03:44:31 -04:00
|
|
|
|
automatically mean ``spam.bacon`` is part of the public API unless
|
2020-06-15 19:45:49 -04:00
|
|
|
|
it is documented as such).
|
2009-06-19 16:55:54 -04:00
|
|
|
|
|
|
|
|
|
- Inheritance patterns of internal classes.
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
2020-06-15 19:45:49 -04:00
|
|
|
|
- Test suites. (Anything in the ``Lib/test`` directory or test
|
2009-08-28 12:30:08 -04:00
|
|
|
|
subdirectories of packages.)
|
|
|
|
|
|
2020-07-20 13:10:55 -04:00
|
|
|
|
- Backward compatibility rules do not apply to any module or API that is
|
2022-01-21 06:03:51 -05:00
|
|
|
|
explicitly documented as **Provisional** per :pep:`411`.
|
2020-07-20 13:10:55 -04:00
|
|
|
|
|
2020-06-15 19:45:49 -04:00
|
|
|
|
|
|
|
|
|
Basic policy for backwards compatibility
|
|
|
|
|
----------------------------------------
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
2020-05-27 22:45:05 -04:00
|
|
|
|
* In general, incompatibilities should have a large benefit to
|
|
|
|
|
breakage ratio, and the incompatibility should be easy to resolve in
|
|
|
|
|
affected code. For example, adding an stdlib module with the same
|
2020-06-15 19:45:49 -04:00
|
|
|
|
name as a third party package is generally not acceptable. Adding
|
|
|
|
|
a method or attribute that conflicts with 3rd party code through
|
|
|
|
|
inheritance, however, is likely reasonable.
|
2020-05-27 22:45:05 -04:00
|
|
|
|
|
2009-06-19 09:55:12 -04:00
|
|
|
|
* Unless it is going through the deprecation process below, the
|
2020-06-15 19:45:49 -04:00
|
|
|
|
behavior of an API *must* not change in an incompatible fashion
|
|
|
|
|
between any two consecutive releases. Python's yearly release
|
|
|
|
|
process (:pep:`602`) means that the deprecation period must last at
|
|
|
|
|
least two years.
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
2009-06-19 09:55:12 -04:00
|
|
|
|
* Similarly a feature cannot be removed without notice between any two
|
|
|
|
|
consecutive releases.
|
|
|
|
|
|
2022-04-04 19:39:11 -04:00
|
|
|
|
* For changes that are unable to raise a deprecation warning, consult
|
|
|
|
|
with the steering council.
|
|
|
|
|
|
2020-05-27 22:45:05 -04:00
|
|
|
|
* The steering council may grant exceptions to this policy. In
|
|
|
|
|
particular, they may shorten the required deprecation period for a
|
|
|
|
|
feature. Exceptions are only granted for extreme situations such as
|
|
|
|
|
dangerously broken or insecure features or features no one could
|
|
|
|
|
reasonably be depending on (e.g., support for completely obsolete
|
|
|
|
|
platforms).
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Making Incompatible Changes
|
|
|
|
|
===========================
|
|
|
|
|
|
2020-06-15 19:45:49 -04:00
|
|
|
|
Making an incompatible change is a gradual process performed over
|
|
|
|
|
several releases:
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
2020-05-27 22:45:05 -04:00
|
|
|
|
1. Discuss the change. Depending on the degree of incompatibility,
|
|
|
|
|
this could be on the bug tracker, python-dev, python-list, or the
|
|
|
|
|
appropriate SIG. A PEP or similar document may be written.
|
|
|
|
|
Hopefully users of the affected API will pipe up to comment.
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
2020-06-24 19:42:48 -04:00
|
|
|
|
2. Add a warning. If behavior is changing, the API may gain a new
|
|
|
|
|
function or method to perform the new behavior; old usage should
|
|
|
|
|
raise the warning. If an API is being removed, simply warn
|
|
|
|
|
whenever it is entered. ``DeprecationWarning`` is the usual
|
2020-05-27 22:45:05 -04:00
|
|
|
|
warning category to use, but ``PendingDeprecationWarning`` may be
|
2020-07-20 13:10:55 -04:00
|
|
|
|
used in special cases where the old and new versions of the API will
|
2020-06-24 19:42:48 -04:00
|
|
|
|
coexist for many releases [#warnings]_. Compiler warnings are also
|
|
|
|
|
acceptable. The warning message should include the release the
|
|
|
|
|
incompatibility is expected to become the default and a link to an
|
|
|
|
|
issue that users can post feedback to.
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
2021-04-16 18:21:47 -04:00
|
|
|
|
3. Wait for the warning to appear in at least two minor Python
|
|
|
|
|
versions of the same major version, or one minor version in an older
|
|
|
|
|
major version (e.g. for a warning in Python 3.10, you either wait
|
|
|
|
|
until at least Python 3.12 or Python 4.0 to make the change).
|
|
|
|
|
It's fine to wait more than two releases.
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
2020-05-27 22:45:05 -04:00
|
|
|
|
4. See if there's any feedback. Users not involved in the original
|
|
|
|
|
discussions may comment now after seeing the warning. Perhaps
|
|
|
|
|
reconsider.
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
2020-05-27 22:45:05 -04:00
|
|
|
|
5. The behavior change or feature removal may now be made default or
|
2020-06-15 19:45:49 -04:00
|
|
|
|
permanent having reached the declared version. Remove the old
|
|
|
|
|
version and warning.
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
2022-04-04 19:39:11 -04:00
|
|
|
|
6. If a warning cannot be provided to users, consult with the steering
|
|
|
|
|
council.
|
|
|
|
|
|
2009-06-18 22:18:28 -04:00
|
|
|
|
|
|
|
|
|
References
|
|
|
|
|
==========
|
|
|
|
|
|
|
|
|
|
.. [#tiobe] TIOBE Programming Community Index
|
|
|
|
|
|
|
|
|
|
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
|
|
|
|
|
|
|
|
|
|
.. [#warnings] The warnings module
|
|
|
|
|
|
|
|
|
|
http://docs.python.org/library/warnings.html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright
|
|
|
|
|
=========
|
|
|
|
|
|
|
|
|
|
This document has been placed in the public domain.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
..
|
|
|
|
|
Local Variables:
|
|
|
|
|
mode: indented-text
|
|
|
|
|
indent-tabs-mode: nil
|
|
|
|
|
sentence-end-double-space: t
|
|
|
|
|
fill-column: 70
|
|
|
|
|
coding: utf-8
|
|
|
|
|
End:
|