-
-
Notifications
You must be signed in to change notification settings - Fork 245
decimal.getcontext() is not applied within bpython #918
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
Comments
Yikes, that's too bad. Apparently this is a "coroutine-local" thing? So guessing switching from greenlets to threads might not fix, instead it would take moving to async? Maybe we should manually persist this between execution contexts? I want to learn more about coroutine-locals. |
This works in Python 3.6 and is broken in 3.7+. |
Why wouldn't this work if we switch to threads? All the user code that is executed would be in exactly one thread. |
Maybe it will, I meant to say I don't know if it will or not because it's not a thread local, it's something else. |
I'm not sure I can follow. The context is thread-local. |
I don't really understand what a coroutine local is yet, but I think it's now sometimes (usually?) a coroutine-local instead based on the value of |
Still needing help with Python 3.11.3. A workaround that might not apply to everyone is resorting to bpython version 0.24 on top of Python 3.11.3
>>> import decimal
>>> decimal.getcontext().prec = 6
>>> decimal.Decimal(1) / decimal.Decimal(7)
Decimal('0.1428571428571428571428571429')
>>> decimal.DefaultContext.prec = 6
>>> decimal.Decimal(1) / decimal.Decimal(7)
Decimal('0.142857') |
Steps to reproduce:
expected the rounding to be changed.
also fails using
setcontext()
The text was updated successfully, but these errors were encountered: