-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Run Python File In Terminal doesn't escape special chars in pathnames #4165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for letting us know about this, @lockejan. There are two separate issues at play here:
(In the future you'll be best served by opening separate issues.) For the first one that seems like something we could address (e.g. quote the entire filename when passing to the shell). I expect we haven't done so because having such characters in your file/directory names is pretty uncommon. Regardless, we'll look into it. |
As to the second issue (CWD for running scripts), that's mostly a function of how Python executes scripts. It does not modify the current working directory to match that of the script. Python does, however, put the script's directory at the front of The typical approach for data files in Python is to resolve the absolute path relative to the script: import os.path
DATADIR = os.path.dirname(os.path.abspath(__file__))
DATAFILE = os.path.join(DATADIR, 'fighter.csv')
... You are welcome to submit a feature request to have "Run Python File In Terminal" change to the script's directory before running (perhaps as a setting-enabled option). However, it's unlikely that we'd do something like that. |
I've marked this as a bug since I'd expect us to be quoting filenames in the terminal. |
This isn't an issue under Windows, so marking as a macOS/Linux issue. |
Closing as dup of #20360. |
Environment data
Expected behaviour
Running a script via Terminal would execute no matter where inside the project directory the script is stored
Actual behaviour
filepathes can't be resolved due to lack of escaping special characters:
example for special characters in pathname:


Steps to reproduce:
Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)Output from
Console
under theDeveloper Tools
panel (toggle Developer Tools on underHelp
; turn on source maps to make any tracebacks be useful by runningEnable source map support for extension debugging
)Old Second Part of Issue
Expected behaviour
linked path resources would be resolved relatively to the directory of the executed script
Actual behaviour
example for non resolvable pathes inside scripts:


line 3 of the script:

Steps to reproduce:
The text was updated successfully, but these errors were encountered: