Skip to content

Commit

Permalink
Merge branch 'pr/tested/1-newtypes_dunder-overloads' into master-rhin…
Browse files Browse the repository at this point in the history
…o-8.x
  • Loading branch information
eirannejad committed Nov 14, 2024
2 parents 70d67ea + 7515426 commit e6aefd3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/runtime/Types/ReflectedClrType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,15 @@ static bool TryGetBuiltinAttr(BorrowedReference ob, BorrowedReference key, out N
return false;
}

if (keyStr == nameof(PyIdentifier.__init__))
switch (keyStr)
{
result = Runtime.PyObject_GenericGetAttr(ob, key);
return true;
case nameof(PyIdentifier.__init__):
result = Runtime.PyObject_GenericGetAttr(ob, key);
return true;

case nameof(PyIdentifier.__dict__):
result = Runtime.PyObject_GenericGetDict(ob);
return true;
}

return false;
Expand Down
8 changes: 8 additions & 0 deletions tests/test_method_getattribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
IBASE = System.Collections.IEnumerable


def test_instance_get_dict():
class T:
pass

t = T()
assert isinstance(t.__dict__, dict)


def test_method_getattribute():
class S1(BASE):
def __getattribute__(self, name):
Expand Down

0 comments on commit e6aefd3

Please sign in to comment.