IronLanguages / IronLanguages/ironpython3
Review PythonOps.TryGetBoundAttr usage
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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