-
-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Move command-line args out of dev-mode Python invocation #1413
Move command-line args out of dev-mode Python invocation #1413
Conversation
dfbbc23
to
7c1c45a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 minor suggestions listed inline, but otherwise looks good.
On macOS CoreFoundation/NSApplication will do its own independent parsing of argc/argv. This means that whatever we pass to the Python interpreter on start-up will also be visible to NSApplication which will interpret things like `-u` (used to make I/O unbuffered in CPython) as `-u [URL]` (a request to open a document by URL). This is, rather patently, Not Good. To avoid this causing unwanted hilarity, we use environment variables to configure the Python interpreter rather than command-line options.
7c1c45a
to
c3cc4ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# Equivalent of passing "-X dev" | ||
"PYTHONMALLOC": "debug", | ||
"PYTHONASYNCIODEBUG": "1", | ||
"PYTHONFAULTHANDLER": "1", | ||
"PYTHONWARNINGS": "default", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious....was there a reason that PYTHONDEVMODE=1
wasn't used instead?
Setting just PYTHONDEVMODE seems more likely to be forward-compatible with enabling this mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...we didn't realise the setting existed :-)
It's obvious now that I'm looking at the docs; no objection replacing these 4 settings with the single PYTHONDEVMODE=1
For some reason NSApplication/CoreFoundation gets very confused if we pass certain command-line arguments to the outer Python interpreter when running in dev mode.
This patch removes all command-line arguments from the invocation, using environment variables to achieve the equivalent outcomes. The remaining argument, the actual code to start the application, appears to not cause problems.