Skip to content

Python implementation of Decimal can hang in floor division #140036

Description

@serhiy-storchaka

Bug report

# import decimalimport_pydecimalasdecimal_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 checkdecimal.setcontext(_unbounded_dec_context)
x=decimal.Decimal('1')
y=x//1

The C implementation evaluates the last line instantly, but the Python implementation hangs for a long time (infinitely?). The modulus operation has the same behavior.

cc @tim-one

Linked PRs

Metadata

Metadata

Assignees

Labels

3.13bugs and security fixes3.14bugs and security fixes3.15pre-release feature fixes, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions