Skip to content

gh-155051: Reject None keyword arguments in decimal.localcontext() - #155054

Merged
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:localcontext-none
Aug 2, 2026
Merged

gh-155051: Reject None keyword arguments in decimal.localcontext()#155054
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:localcontext-none

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

None is not a valid value for any of the context attributes. The C implementation silently ignored it, because it shared the code with the Context constructor, where None means "not specified". The pure Python implementation always rejected it.

None is not a valid value for any of the context attributes.  The C
implementation silently ignored it, because it shared the code with the
Context constructor, where None means "not specified".  The pure Python
implementation always rejected it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Comment on lines +2061 to +2068
prec: object = NULL
rounding: object = NULL
Emin: object = NULL
Emax: object = NULL
capitals: object = NULL
clamp: object = NULL
flags: object = NULL
traps: object = NULL

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in #155047, this is not rendered well by signature().

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already use @text_signature "($module, /, ctx=None, **kwargs)" for this method. And the Python implementation has the same signature.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is no regression. Though, I think in future we could use here explicit arguments with a sentinel.

# Conflicts:
#	Modules/_decimal/_decimal.c
#	Modules/_decimal/clinic/_decimal.c.h
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) August 2, 2026 06:39
@serhiy-storchaka
serhiy-storchaka merged commit 96ebb20 into python:main Aug 2, 2026
53 checks passed
@bedevere-bot

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Windows PGO 3.x (tier-1) has failed when building commit 96ebb20.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1620/builds/4131) and take a look at the build logs.
  4. Check if the failure is related to this commit (96ebb20) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1620/builds/4131

Failed tests:

  • test_venv

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\test_venv.py", line 90, in tearDown
    rmtree(self.env_dir)
    ~~~~~~^^^^^^^^^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\os_helper.py", line 508, in rmtree
    _rmtree(path)
    ~~~~~~~^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\os_helper.py", line 440, in _rmtree
    _waitfor(_rmtree_inner, path, waitall=True)
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\os_helper.py", line 381, in _waitfor
    func(pathname)
    ~~~~^^^^^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\os_helper.py", line 436, in _rmtree_inner
    _waitfor(_rmtree_inner, fullname, waitall=True)
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\os_helper.py", line 381, in _waitfor
    func(pathname)
    ~~~~^^^^^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\os_helper.py", line 439, in _rmtree_inner
    _force_run(fullname, os.unlink, fullname)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\__init__.py", line 224, in _force_run
    return func(*args)
PermissionError: [WinError 5] Access is denied: 'D:\\temp\\test_python_c3hbjmmo\\tmp596rn58_\\Scripts\\python.exe'


Traceback (most recent call last):
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\test_venv.py", line 90, in tearDown
    rmtree(self.env_dir)
    ~~~~~~^^^^^^^^^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\os_helper.py", line 508, in rmtree
    _rmtree(path)
    ~~~~~~~^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\os_helper.py", line 440, in _rmtree
    _waitfor(_rmtree_inner, path, waitall=True)
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\os_helper.py", line 381, in _waitfor
    func(pathname)
    ~~~~^^^^^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\os_helper.py", line 436, in _rmtree_inner
    _waitfor(_rmtree_inner, fullname, waitall=True)
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\os_helper.py", line 381, in _waitfor
    func(pathname)
    ~~~~^^^^^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\os_helper.py", line 439, in _rmtree_inner
    _force_run(fullname, os.unlink, fullname)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\__init__.py", line 224, in _force_run
    return func(*args)
PermissionError: [WinError 5] Access is denied: 'D:\\temp\\test_python_fd8wl30k\\tmpp_f14nel\\Scripts\\python.exe'


Traceback (most recent call last):
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\__init__.py", line 213, in _force_run
    return func(*args)
PermissionError: [WinError 5] Access is denied: 'D:\\temp\\test_python_fd8wl30k\\tmpp_f14nel\\Scripts\\python.exe'


Traceback (most recent call last):
  File "D:\buildarea\3.x.bolen-windows10.pgo\build\Lib\test\support\__init__.py", line 213, in _force_run
    return func(*args)
PermissionError: [WinError 5] Access is denied: 'D:\\temp\\test_python_c3hbjmmo\\tmp596rn58_\\Scripts\\python.exe'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants