From d7303fb9d7d9296b3d9401971626b221ec851a93 Mon Sep 17 00:00:00 2001 From: Mark Byrne <31762852+mbyrnepr2@users.noreply.github.com> Date: Thu, 6 Aug 2026 16:49:24 +0200 Subject: [PATCH] gh-109861: Fix a doctest in Lib/_pydecimal.py which was failing when running its doctests directly (GH-125479) Fix a doctest in ``Lib/_pydecimal.py`` which was failing when run directly on the module via the command: ./python.exe -m doctest Lib/_pydecimal.py (cherry picked from commit 5965f08d702aadfc5ae51134c22261cefbc82da5) Co-authored-by: Mark Byrne <31762852+mbyrnepr2@users.noreply.github.com> Co-authored-by: Sergey B Kirpichev --- Lib/_pydecimal.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py index f83524a25604da..4c15889ce5a1c4 100644 --- a/Lib/_pydecimal.py +++ b/Lib/_pydecimal.py @@ -1783,9 +1783,10 @@ def __round__(self, n=None): Decimal('123.46') >>> round(Decimal('123.456'), -2) Decimal('1E+2') - >>> round(Decimal('-Infinity'), 37) + >>> with localcontext(ExtendedContext): + ... round(Decimal('-Infinity'), 37) + ... round(Decimal('sNaN123'), 0) Decimal('NaN') - >>> round(Decimal('sNaN123'), 0) Decimal('NaN123') """