Skip to content

Commit 5546009

Browse files
committed
Throw correct exceptions in 'fstat' and 'stat'.
1 parent 2eec943 commit 5546009

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
package com.oracle.graal.python.builtins.modules;
2727

2828
import static com.oracle.graal.python.nodes.SpecialMethodNames.__FSPATH__;
29+
import static com.oracle.graal.python.runtime.exception.PythonErrorType.FileNotFoundError;
2930
import static com.oracle.graal.python.runtime.exception.PythonErrorType.NotImplementedError;
3031
import static com.oracle.graal.python.runtime.exception.PythonErrorType.OSError;
3132
import static com.oracle.graal.python.runtime.exception.PythonErrorType.TypeError;
@@ -333,6 +334,11 @@ Object fstatPInt(PInt fd,
333334
return recursive.executeWith(fd.intValue());
334335
}
335336

337+
@Fallback
338+
Object doGeneric(Object o) {
339+
throw raise(TypeError, "an integer is required (got type %p)", o);
340+
}
341+
336342
protected static StatNode createStatNode() {
337343
return StatNode.create();
338344
}
@@ -392,7 +398,7 @@ Object stat(String path, boolean followSymlinks) {
392398
TruffleFile f = getContext().getEnv().getTruffleFile(path);
393399
LinkOption[] linkOptions = followSymlinks ? new LinkOption[0] : new LinkOption[]{LinkOption.NOFOLLOW_LINKS};
394400
if (!f.exists(linkOptions)) {
395-
throw raise(OSError, "No such file or directory: '%s'", path);
401+
throw raise(FileNotFoundError, "No such file or directory: '%s'", path);
396402
}
397403
int mode = 0;
398404
long size = 0;
@@ -969,6 +975,7 @@ class StreamGobbler extends Thread {
969975
}
970976

971977
@Override
978+
@TruffleBoundary
972979
public void run() {
973980
try {
974981
InputStreamReader isr = new InputStreamReader(is);

0 commit comments

Comments
 (0)