Thanks to visit codestin.com
Credit goes to github.com

Skip to content

decimal.localcontext() ignores None keyword arguments in the C implementation #155051

Description

@serhiy-storchaka

Bug report

localcontext() accepts keyword arguments which set the corresponding attributes of the new context. The C and the pure Python implementations differ if the value is None:

>>> import decimal, _pydecimal
>>> with decimal.localcontext(prec=None) as ctx: ctx.prec
...
28
>>> with _pydecimal.localcontext(prec=None) as ctx: ctx.prec
...
TypeError: prec must be an integer

The C implementation shares the code with the Context constructor, where None means "not specified"; the pure Python implementation simply assigns all keyword arguments. None is not a valid value for any of these attributes, so it should probably be rejected in both.

Linked PRs

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions