gh-76007: Deprecate __version__ attribute in decimal (#140302)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
Stan Ulbrych 2025-10-26 11:01:04 +00:00 committed by GitHub
parent 33b2ca80bb
commit 00026d19c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 74 additions and 7 deletions

View file

@ -47,13 +47,16 @@
'HAVE_THREADS',
# C version: compile time choice that enables the coroutine local context
'HAVE_CONTEXTVAR'
'HAVE_CONTEXTVAR',
# Highest version of the spec this module complies with
'SPEC_VERSION',
]
__xname__ = __name__ # sys.modules lookup (--without-threads)
__name__ = 'decimal' # For pickling
__version__ = '1.70' # Highest version of the spec this complies with
# See http://speleotrove.com/decimal/
SPEC_VERSION = '1.70' # Highest version of the spec this complies with
# See https://speleotrove.com/decimal/decarith.html
__libmpdec_version__ = "2.4.2" # compatible libmpdec version
import math as _math
@ -6399,3 +6402,11 @@ def _format_number(is_negative, intpart, fracpart, exp, spec):
# _PyHASH_10INV is the inverse of 10 modulo the prime _PyHASH_MODULUS
_PyHASH_10INV = pow(10, _PyHASH_MODULUS - 2, _PyHASH_MODULUS)
del sys
def __getattr__(name):
if name == "__version__":
from warnings import _deprecated
_deprecated("__version__", remove=(3, 20))
return SPEC_VERSION
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")