IronLanguages / IronLanguages/ironpython3

Keyword-only argument issues

Open
#1,019 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
2.8k
Forks
316
Avg merge
1d 9h
Merged PRs (30d)
1

Description

Some issues I noticed while working on https://github.com/IronLanguages/ironpython3/issues/1015. The following examples need to be run in fresh ipy instances to exhibit the broken behavior.

  1. Bad error message for missing keyword arguments:
def test(*, a): return a

test() # throws TypeError: test() takes no arguments (0 given)
  1. When the call binds to a failure when a value in __kwdefaults__ is missing it still throws even if the value becomes available later on:
def test(*, a=1): return a

test.__kwdefaults__ = None
test() # throws TypeError as expected
test.__kwdefaults__ = {"a": 1}
assert test() == 1 # still throws the same TypeError as above
  1. Not finding a value in __kwdefaults__ should throw a TypeError instead of returning None:
def test(*, a=1): return a

assert test() == 1
test.__kwdefaults__ = None
test() # should throw but returns None instead
  1. PythonFunction.CalculatedCachedCompat takes into account the number of arguments in __kwdefaults__. I don't think this makes sense since __kwdefaults__ can be changed any time and there's no way to know.

  2. More stuff I'm forgetting about...

Related PR: https://github.com/IronLanguages/ironpython3/pull/1018

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the four keyword-only argument examples in fresh ipy instances, then inspect PythonFunction.CalculatedCachedCompat and the behavior around kwdefaults. Done means the reported calls produce the correct TypeError behavior and changes to kwdefaults are reflected consistently; use the related PR as context.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, python
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.