Skip to content
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

bpo-47135: Accept attributes as keyword arguments in decimal.localcontext #32242

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

Copy link
Contributor

@dignissimus dignissimus commented Apr 1, 2022

This allows attributes to be set like this

with decimal.localcontext(prec=10):
    ...

instead of like this

with decimal.localcontext() as ctx:
    ctx.prec = 10
    ...

https://bugs.python.org/issue47135

Lib/_pydecimal.py Outdated Show resolved Hide resolved
Lib/test/test_decimal.py Show resolved Hide resolved
Doc/library/decimal.rst Show resolved Hide resolved
Modules/_decimal/_decimal.c Outdated Show resolved Hide resolved
@dignissimus
Copy link
Contributor Author

@dignissimus dignissimus commented Apr 4, 2022

Thank you for the review, I'll be able to make the changes later today

Raises :exc:`TypeError` if *kwargs* supplies an attribute that :class:`Context` doesn't
support.

.. versionchanged:: 3.11
Raises either :exc:`TypeError` or :exc:`ValueError` if *kwargs* supplies an invalid value for an attribute.
Copy link
Member

@JelleZijlstra JelleZijlstra Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should only be one note. The note should say that keyword arguments are now supported, because that's the important part. The exceptions should stay in the main text.

Lib/_pydecimal.py Outdated Show resolved Hide resolved
Lib/_pydecimal.py Outdated Show resolved Hide resolved
dignissimus and others added 4 commits Apr 4, 2022
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants