[issue47135] Allow decimal.localcontext to accept keyword arguments to set context attributes

2022-04-01 Thread Sam Ezeh
Change by Sam Ezeh : -- pull_requests: +30313 stage: -> patch review pull_request: https://github.com/python/cpython/pull/32242 ___ Python tracker ___

[issue47135] Allow decimal.localcontext to accept keyword arguments to set context attributes

2022-04-01 Thread Sam Ezeh
Sam Ezeh added the comment: This is what functionality looks like when supplying incorrect attribute names with the patch. Python 3.11.0a6+ (heads/bpo-47135-dirty:d4bb38f82b, Apr 1 2022, 20:01:56) [GCC 11.1.0] on linux Type "help", "copyright", "credits" or "license" for more information.

[issue47135] Allow decimal.localcontext to accept keyword arguments to set context attributes

2022-04-01 Thread Steven D'Aprano
Steven D'Aprano added the comment: I'm not sure what the implementation uses to enforce this, but decimal contexts already seem to reject arbitrary attributes. So a naive implementation that just setattr()'s the keyword arguments will automatically fail: >>> from decimal import getcontext

[issue47135] Allow decimal.localcontext to accept keyword arguments to set context attributes

2022-04-01 Thread Sam Ezeh
Sam Ezeh added the comment: I've uploaded a patch and it seems to work, which I'm very proud of. I'll create some tests, amend documentation and create a news entry. After that, I'll create a pull request on GitHub. -- keywords: +patch Added file:

[issue47135] Allow decimal.localcontext to accept keyword arguments to set context attributes

2022-04-01 Thread Sam Ezeh
Sam Ezeh added the comment: I'm looking into adding this > Seems reasonable to me, but I think a full implementation would want to throw > an error for keyword args that don't already exist as context attributes > (otherwise typos would fail silently) For _pydecimal, I think this would

[issue47135] Allow decimal.localcontext to accept keyword arguments to set context attributes

2022-03-30 Thread Nick Coghlan
Nick Coghlan added the comment: Seems reasonable to me, but I think a full implementation would want to throw an error for keyword args that don't already exist as context attributes (otherwise typos would fail silently) -- ___ Python tracker

[issue47135] Allow decimal.localcontext to accept keyword arguments to set context attributes

2022-03-29 Thread Dong-hee Na
Change by Dong-hee Na : -- nosy: +corona10 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue47135] Allow decimal.localcontext to accept keyword arguments to set context attributes

2022-03-28 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +ncoghlan ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue47135] Allow decimal.localcontext to accept keyword arguments to set context attributes

2022-03-27 Thread Steven D'Aprano
New submission from Steven D'Aprano : Whenever I use decimal and need to change the context temporarily, without fail I try to write with decimal.localcontext(prec=10): ... or similar. Then I get surprised that it fails, and re-write it as with decimal.localcontext() as ctx: