Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-76007: Deprecate __version__ attribute in decimal#140302
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
10 commits Select commit Hold shift + click to select a range
8c30b2c Commit
StanFromIreland d583f55 Commit
StanFromIreland 61a43b9 Commit
StanFromIreland 0a2a9fb Correct version number
StanFromIreland 9b43d7f Apply suggestions from code review
StanFromIreland 82ef916 Convert to macro
StanFromIreland 16b7bc8 Add comment
StanFromIreland 56a75e0 Relocate constant in doc
StanFromIreland dbebb28 Merge branch 'main' into decimal-version
hugovk ba3295b Apply suggestions from code review
StanFromIreland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions 2 Misc/NEWS.d/next/Library/2025-10-18-15-20-25.gh-issue-76007.SNUzRq.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| :mod:`decimal`: Deprecate ``__version__`` and replace with | ||
| :data:`decimal.SPEC_VERSION`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -58,6 +58,9 @@ | ||
| #include "clinic/_decimal.c.h" | ||
| #define MPD_SPEC_VERSION "1.70" // Highest version of the spec this complies with | ||
| // See https://speleotrove.com/decimal/decarith.html | ||
| /*[clinic input] | ||
| module _decimal | ||
| class _decimal.Decimal "PyObject *" "&dec_spec" | ||
| @@ -7566,12 +7569,35 @@ static PyType_Spec context_spec ={ | ||
| }; | ||
| static PyObject * | ||
| decimal_getattr(PyObject *self, PyObject *args) | ||
| { | ||
| PyObject *name; | ||
| if (!PyArg_UnpackTuple(args, "__getattr__", 1, 1, &name)){ | ||
| return NULL; | ||
| } | ||
| if (PyUnicode_Check(name) && PyUnicode_EqualToUTF8(name, "__version__")){ | ||
| if (PyErr_WarnEx(PyExc_DeprecationWarning, | ||
| "'__version__' is deprecated and slated for removal in Python 3.20", | ||
| 1) < 0){ | ||
| return NULL; | ||
| } | ||
| return PyUnicode_FromString(MPD_SPEC_VERSION); | ||
| } | ||
| PyErr_Format(PyExc_AttributeError, "module 'decimal' has no attribute %R", name); | ||
| return NULL; | ||
| } | ||
| static PyMethodDef _decimal_methods [] = | ||
| { | ||
| _DECIMAL_GETCONTEXT_METHODDEF | ||
| _DECIMAL_SETCONTEXT_METHODDEF | ||
| _DECIMAL_LOCALCONTEXT_METHODDEF | ||
| _DECIMAL_IEEECONTEXT_METHODDEF | ||
| {"__getattr__", decimal_getattr, METH_VARARGS, "Module __getattr__"}, | ||
skirpichev marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| {NULL, NULL, 1, NULL } | ||
| }; | ||
| @@ -7891,7 +7917,7 @@ _decimal_exec(PyObject *m) | ||
| } | ||
| /* Add specification version number */ | ||
| CHECK_INT(PyModule_AddStringConstant(m, "__version__", "1.70")); | ||
| CHECK_INT(PyModule_AddStringConstant(m, "SPEC_VERSION", MPD_SPEC_VERSION)); | ||
| CHECK_INT(PyModule_AddStringConstant(m, "__libmpdec_version__", mpd_version())); | ||
| return 0; | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.