Skip to content

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

Open
serhiy-storchaka wants to merge 2 commits into
python:mainfrom
serhiy-storchaka:localcontext-none
Open

gh-155051: Reject None keyword arguments in decimal.localcontext()#155054
serhiy-storchaka wants to merge 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants