Skip to content

Commit 3df2b8c

Browse files
committed
OsErrorBuiltins / ImportErrorBuiltins: fix __str__ and __reduce__ builtins
1 parent 708cc18 commit 3df2b8c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/ImportErrorBuiltins.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,8 @@ Object str(VirtualFrame frame, PBaseException self,
195195
@Cached BaseExceptionAttrNode attrNode,
196196
@Cached BaseExceptionBuiltins.StrNode exStrNode,
197197
@Cached PyUnicodeCheckExactNode unicodeCheckExactNode) {
198-
assert self.getExceptionAttributes() != null;
199198
final Object msg = attrNode.get(self, IDX_MSG, IMPORT_ERROR_ATTR_FACTORY);
200-
if (msg != null && unicodeCheckExactNode.execute(msg)) {
199+
if (msg != PNone.NONE && unicodeCheckExactNode.execute(msg)) {
201200
return msg;
202201
} else {
203202
return exStrNode.execute(frame, self);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/OsErrorBuiltins.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,12 @@ Object reduce(VirtualFrame frame, PBaseException self,
447447
PTuple args = self.getArgs();
448448
final Object filename = attrNode.get(self, IDX_FILENAME, OS_ERROR_ATTR_FACTORY);
449449
final Object filename2 = attrNode.get(self, IDX_FILENAME2, OS_ERROR_ATTR_FACTORY);
450-
if (lenNode.execute(args.getSequenceStorage()) == 2 && filename != null) {
451-
Object[] argData = new Object[filename2 != null ? 5 : 3];
450+
if (lenNode.execute(args.getSequenceStorage()) == 2 && filename != PNone.NONE) {
451+
Object[] argData = new Object[filename2 != PNone.NONE ? 5 : 3];
452452
argData[0] = getItemNode.execute(frame, args.getSequenceStorage(), 0);
453453
argData[1] = getItemNode.execute(frame, args.getSequenceStorage(), 1);
454454
argData[2] = filename;
455-
if (filename2 != null) {
455+
if (filename2 != PNone.NONE) {
456456
// This tuple is essentially used as OSError(*args). So, to recreate filename2,
457457
// we need to pass in winerror as well
458458
argData[3] = PNone.NONE;

0 commit comments

Comments
 (0)