File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -519,16 +519,21 @@ def _run_solc(
519
519
520
520
additional_kwargs : Dict = {"cwd" : working_dir } if working_dir else {}
521
521
if not compiler_version .version in [f"0.4.{ x } " for x in range (0 , 11 )]:
522
- # Add . as default allowed path
522
+ # Add --allow-paths argument, if it isn't already specified
523
+ # We allow the CWD as well as the directory that contains the file
523
524
if "--allow-paths" not in cmd :
524
525
file_dir_start = os .path .normpath (os .path .dirname (filename ))
526
+ # Paths in the --allow-paths arg can't contain commas, since this is the delimeter
527
+ # Try using absolute path; if it contains a comma, try using relative path instead
525
528
file_dir = os .path .abspath (file_dir_start )
526
529
if "," in file_dir :
527
530
try :
528
531
file_dir = os .path .relpath (file_dir_start )
529
532
except ValueError :
533
+ # relpath can fail if, for example, we're on Windows and the directory is on a different drive than CWD
530
534
pass
531
535
536
+ # Even the relative path might have a comma in it, so we want to make sure first
532
537
if "," not in file_dir :
533
538
cmd += ["--allow-paths" , ".," + file_dir ]
534
539
else :
You can’t perform that action at this time.
0 commit comments