IronLanguages / IronLanguages/ironpython3

Review PythonOps.TryGetBoundAttr usage

Open
#790 0 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

In a lot of cases, PythonOps.TryGetBoundAttr is used when it should not be. While the usages may have been correct for IronPython 2, it is probably no longer the case.

As an example, math.trunc calls:

if (PythonOps.TryGetBoundAttr(value, "__trunc__", out object func))
    return PythonOps.CallWithContext(context, func);

it should probably be:

if (PythonTypeOps.TryInvokeUnaryOperator(context, value, "__trunc__", out object res))
    return res;

The difference being that TryGetBoundAttr will resolve on the instance, but in this case __trunc__ should resolve on the type.

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

Search the repository for all uses of PythonOps.TryGetBoundAttr, starting with the math.trunc example in the issue. Review whether each special method should resolve on the type instead of the instance, and consider the work complete when inappropriate usages have been identified and corrected consistently.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.