From f74821f63e2ad9efd0e35339cbe2c7292eb607b8 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 2277578df5412b7..e944c9fb21ca7ff 100644 --- a/Lib/_pydecimal.py +++ b/Lib/_pydecimal.py @@ -1821,9 +1821,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') """