New GitHub issue #123284 from picnixz:<br>
<hr>
<pre>
### Bug description:
The `_decimal` module was recently fixed in #123243. I also found that `_pylong` leaks references due to the creation of a global context to use as a local context:
```py
_unbounded_dec_context = decimal.getcontext().copy()
_unbounded_dec_context.prec = decimal.MAX_PREC
_unbounded_dec_context.Emax = decimal.MAX_EMAX
_unbounded_dec_context.Emin = decimal.MIN_EMIN
_unbounded_dec_context.traps[decimal.Inexact] = 1 # sanity check
```
This context is used as `with decimal.localcontext(_unbounded_dec_context)`. On the other hand `decimal.getcontext().copy()` returns a *copy* of the decimal context for the current thread (or set it to `decimal.DefaultContext` if none exists). Instead of setting it like that, I suggest that we construct a `decimal.Context()` object directly in `_pylong` instead of possibly polluting the `decimal` module (whether it's the C or the python implementation).
### CPython versions tested on:
CPython main branch
### Operating systems tested on:
Linux
</pre>
<hr>
<a href="https://github.com/python/cpython/issues/123284">View on GitHub</a>
<p>Labels: type-bug, stdlib</p>
<p>Assignee: picnixz</p>