[issue47135] Allow decimal.localcontext to accept keyword arguments to set context attributes
Steven D'Aprano
report at bugs.python.org
Fri Apr 1 15:35:28 EDT 2022
Steven D'Aprano <steve at pearwood.info> 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
>>> ctx = getcontext()
>>> setattr(ctx, 'precision', 10)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'decimal.Context' object has no attribute 'precision'
But you are absolutely correct that however we enforce it, we should
avoid allowing typos to silently fail.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47135>
_______________________________________
More information about the Python-bugs-list
mailing list