@@ -356,7 +356,7 @@ Object setInheritable(int fd, @SuppressWarnings("unused") Object inheritable) {
356356 @ GenerateNodeFactory
357357 @ TypeSystemReference (PythonArithmeticTypes .class )
358358 public abstract static class StatNode extends PythonBinaryBuiltinNode {
359- private final ConditionProfile fileNotFound = ConditionProfile . createBinaryProfile ();
359+ private final BranchProfile fileNotFound = BranchProfile . create ();
360360
361361 private static final int S_IFIFO = 0010000 ;
362362 private static final int S_IFCHR = 0020000 ;
@@ -386,8 +386,12 @@ long fileTimeToSeconds(FileTime t) {
386386 Object stat (String path , boolean followSymlinks ) {
387387 TruffleFile f = getContext ().getEnv ().getTruffleFile (path );
388388 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 );
391395 }
392396 int mode = 0 ;
393397 long size = 0 ;
@@ -475,6 +479,11 @@ Object stat(String path, boolean followSymlinks) {
475479 });
476480 }
477481
482+ private PException fileNoFound (String path ) {
483+ fileNotFound .enter ();
484+ throw raise (FileNotFoundError , "No such file or directory: '%s'" , path );
485+ }
486+
478487 @ TruffleBoundary (allowInlining = true , transferToInterpreterOnException = false )
479488 private static long strToLong (String name ) throws NumberFormatException {
480489 return new Long (name ).longValue ();
0 commit comments