From 3410cc153507c8652ebd0920962470807c17466e Mon Sep 17 00:00:00 2001 From: Mark Byrne Date: Mon, 14 Oct 2024 21:16:32 +0200 Subject: [PATCH 1/2] 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``. Co-authored-by: Sergey B Kirpichev --- Lib/_pydecimal.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py index 5b60570c6c592a..8e593d824f5dde 100644 --- a/Lib/_pydecimal.py +++ b/Lib/_pydecimal.py @@ -1796,6 +1796,7 @@ def __round__(self, n=None): Decimal('123.46') >>> round(Decimal('123.456'), -2) Decimal('1E+2') + >>> setcontext(ExtendedContext) >>> round(Decimal('-Infinity'), 37) Decimal('NaN') >>> round(Decimal('sNaN123'), 0) From c9dd073a9a9471726926b0a4154dc3fe4ffb52ab Mon Sep 17 00:00:00 2001 From: Mark Byrne Date: Tue, 15 Oct 2024 09:34:43 +0200 Subject: [PATCH 2/2] Set the local context to ``ExtendedContext`` for two doctests which require the ``InvalidOperation`` trap to be ``False``. --- Lib/_pydecimal.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py index 8e593d824f5dde..81bb04363f9564 100644 --- a/Lib/_pydecimal.py +++ b/Lib/_pydecimal.py @@ -1796,10 +1796,10 @@ def __round__(self, n=None): Decimal('123.46') >>> round(Decimal('123.456'), -2) Decimal('1E+2') - >>> setcontext(ExtendedContext) - >>> round(Decimal('-Infinity'), 37) + >>> with localcontext(ExtendedContext): + ... round(Decimal('-Infinity'), 37) + ... round(Decimal('sNaN123'), 0) Decimal('NaN') - >>> round(Decimal('sNaN123'), 0) Decimal('NaN123') """