Skip to content

Commit 984c41e

Browse files
committed
[GR-23263] Make test_subclassinit pass
PullRequest: graalpython/1174
2 parents 48a2109 + bca0a17 commit 984c41e

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_subclassinit.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
*graalpython.lib-python.3.test.test_subclassinit.Test.test_init_subclass_skipped
99
*graalpython.lib-python.3.test.test_subclassinit.Test.test_init_subclass_wrong
1010
*graalpython.lib-python.3.test.test_subclassinit.Test.test_set_name
11+
*graalpython.lib-python.3.test.test_subclassinit.Test.test_set_name_error
1112
*graalpython.lib-python.3.test.test_subclassinit.Test.test_set_name_init_subclass
1213
*graalpython.lib-python.3.test.test_subclassinit.Test.test_set_name_lookup
1314
*graalpython.lib-python.3.test.test_subclassinit.Test.test_set_name_metaclass
1415
*graalpython.lib-python.3.test.test_subclassinit.Test.test_set_name_modifying_dict
16+
*graalpython.lib-python.3.test.test_subclassinit.Test.test_set_name_wrong
1517
*graalpython.lib-python.3.test.test_subclassinit.Test.test_type

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import static com.oracle.graal.python.nodes.BuiltinNames.TYPE;
6161
import static com.oracle.graal.python.nodes.BuiltinNames.ZIP;
6262
import static com.oracle.graal.python.nodes.ErrorMessages.ARG_MUST_NOT_BE_ZERO;
63+
import static com.oracle.graal.python.nodes.ErrorMessages.ERROR_CALLING_SET_NAME;
6364
import static com.oracle.graal.python.nodes.PGuards.isInteger;
6465
import static com.oracle.graal.python.nodes.PGuards.isNoValue;
6566
import static com.oracle.graal.python.nodes.SpecialAttributeNames.__BASICSIZE__;
@@ -2318,7 +2319,11 @@ Object typeNew(VirtualFrame frame, Object cls, Object wName, PTuple bases, PDict
23182319
for (DictEntry entry : nslib.entries(namespace.getDictStorage())) {
23192320
Object setName = getSetNameNode.execute(entry.value);
23202321
if (setName != PNone.NO_VALUE) {
2321-
callSetNameNode.execute(frame, setName, entry.value, newType, entry.key);
2322+
try {
2323+
callSetNameNode.execute(frame, setName, entry.value, newType, entry.key);
2324+
} catch (PException e) {
2325+
throw raise(RuntimeError, e.getEscapedException(), ERROR_CALLING_SET_NAME, entry.value, entry.key, newType);
2326+
}
23222327
}
23232328
}
23242329

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public abstract class ErrorMessages {
195195
public static final String ERROR57_SOCKET_CANNOT_BE_CONNECTED = "[Errno 57] Socket is not connected";
196196
public static final String ERROR_5_WHILE_DECOMPRESSING = "Error -5 while decompressing data: incomplete or truncated stream";
197197
public static final String ERROR_WRITING_FORKEXEC = "there was an error writing the fork_exec error to the error pipe";
198+
public static final String ERROR_CALLING_SET_NAME = "Error calling __set_name__ on '%p' instance '%s' in '%N'";
198199
public static final String ESTAR_FORMAT_SPECIFIERS_NOT_ALLOWED = "'e*' format specifiers are not supported";
199200
public static final String EXCEPTION_CAUSE_MUST_BE_NONE_OR_DERIVE_FROM_BASE_EX = "exception cause must be None or derive from BaseException";
200201
public static final String EXCEPTION_CAUSES_MUST_DERIVE_FROM_BASE_EX = "exception causes must derive from BaseException";

0 commit comments

Comments
 (0)