Skip to content

Commit 03eedd0

Browse files
committed
[GR-21398] Rethrow AttributeError as UnknownIdentifierException in invokeMember
PullRequest: graalpython/828
2 parents be28696 + af1a294 commit 03eedd0

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PythonAbstractObject.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -453,15 +453,23 @@ public Object invokeMember(String member, Object[] arguments,
453453
@Exclusive @Cached CallNode callGetattributeNode,
454454
@Exclusive @Cached PExecuteNode executeNode,
455455
@Exclusive @Cached("createBinaryProfile()") ConditionProfile profileGetattribute,
456-
@Exclusive @Cached("createBinaryProfile()") ConditionProfile profileMember) throws UnknownIdentifierException, UnsupportedMessageException {
457-
Object attrGetattribute = lookupGetattributeNode.execute(this, __GETATTRIBUTE__);
458-
if (profileGetattribute.profile(attrGetattribute != PNone.NO_VALUE)) {
459-
Object memberObj = callGetattributeNode.execute(null, attrGetattribute, this, member);
460-
if (profileMember.profile(memberObj != PNone.NO_VALUE)) {
461-
return executeNode.execute(memberObj, arguments);
456+
@Exclusive @Cached("createBinaryProfile()") ConditionProfile profileMember,
457+
@Exclusive @Cached IsBuiltinClassProfile attributeErrorProfile) throws UnknownIdentifierException, UnsupportedMessageException {
458+
Object memberObj;
459+
try {
460+
Object attrGetattribute = lookupGetattributeNode.execute(this, __GETATTRIBUTE__);
461+
if (profileGetattribute.profile(attrGetattribute == PNone.NO_VALUE)) {
462+
throw UnknownIdentifierException.create(member);
463+
}
464+
memberObj = callGetattributeNode.execute(null, attrGetattribute, this, member);
465+
if (profileMember.profile(memberObj == PNone.NO_VALUE)) {
466+
throw UnknownIdentifierException.create(member);
462467
}
468+
} catch (PException e) {
469+
e.expect(AttributeError, attributeErrorProfile);
470+
throw UnknownIdentifierException.create(member);
463471
}
464-
throw UnknownIdentifierException.create(member);
472+
return executeNode.execute(memberObj, arguments);
465473
}
466474

467475
@ExportMessage

0 commit comments

Comments
 (0)