File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -263,8 +263,12 @@ public abstract static class CwdNode extends PythonBuiltinNode {
263263 @ TruffleBoundary
264264 @ Specialization
265265 String cwd () {
266- // TODO(fa) that should actually be retrieved from native code
267- return System .getProperty ("user.dir" );
266+ if (getContext ().isExecutableAccessAllowed ()) {
267+ // TODO(fa) that should actually be retrieved from native code
268+ return System .getProperty ("user.dir" );
269+ } else {
270+ return "" ;
271+ }
268272 }
269273
270274 }
@@ -275,14 +279,16 @@ public abstract static class ChdirNode extends PythonBuiltinNode {
275279 @ TruffleBoundary
276280 @ Specialization
277281 PNone chdir (String spath ) {
278- // TODO(fa) that should actually be set via native code
279- try {
280- if (Files .exists (Paths .get (spath ))) {
281- System .setProperty ("user.dir" , spath );
282- return PNone .NONE ;
282+ if (getContext ().isExecutableAccessAllowed ()) {
283+ // TODO(fa) that should actually be set via native code
284+ try {
285+ if (Files .exists (Paths .get (spath ))) {
286+ System .setProperty ("user.dir" , spath );
287+ return PNone .NONE ;
288+ }
289+ } catch (InvalidPathException e ) {
290+ // fall through
283291 }
284- } catch (InvalidPathException e ) {
285- // fall through
286292 }
287293 throw raise (PythonErrorType .FileNotFoundError , "No such file or directory: '%s'" , spath );
288294 }
You can’t perform that action at this time.
0 commit comments