@@ -356,7 +356,7 @@ Object setInheritable(int fd, @SuppressWarnings("unused") Object inheritable) {
356
356
@ GenerateNodeFactory
357
357
@ TypeSystemReference (PythonArithmeticTypes .class )
358
358
public abstract static class StatNode extends PythonBinaryBuiltinNode {
359
- private final ConditionProfile fileNotFound = ConditionProfile . createBinaryProfile ();
359
+ private final BranchProfile fileNotFound = BranchProfile . create ();
360
360
361
361
private static final int S_IFIFO = 0010000 ;
362
362
private static final int S_IFCHR = 0020000 ;
@@ -386,8 +386,12 @@ long fileTimeToSeconds(FileTime t) {
386
386
Object stat (String path , boolean followSymlinks ) {
387
387
TruffleFile f = getContext ().getEnv ().getTruffleFile (path );
388
388
LinkOption [] linkOptions = followSymlinks ? new LinkOption [0 ] : new LinkOption []{LinkOption .NOFOLLOW_LINKS };
389
- if (fileNotFound .profile (!f .exists (linkOptions ))) {
390
- throw raise (FileNotFoundError , "No such file or directory: '%s'" , path );
389
+ try {
390
+ if (!f .exists (linkOptions )) {
391
+ throw fileNoFound (path );
392
+ }
393
+ } catch (SecurityException e ) {
394
+ throw fileNoFound (path );
391
395
}
392
396
int mode = 0 ;
393
397
long size = 0 ;
@@ -475,6 +479,11 @@ Object stat(String path, boolean followSymlinks) {
475
479
});
476
480
}
477
481
482
+ private PException fileNoFound (String path ) {
483
+ fileNotFound .enter ();
484
+ throw raise (FileNotFoundError , "No such file or directory: '%s'" , path );
485
+ }
486
+
478
487
@ TruffleBoundary (allowInlining = true , transferToInterpreterOnException = false )
479
488
private static long strToLong (String name ) throws NumberFormatException {
480
489
return new Long (name ).longValue ();
0 commit comments