Skip to content
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

os.startfile documentation should recommend not specifying the operation #94302

Closed
sredna opened this issue Jun 26, 2022 · 0 comments
Closed
Labels
docs Documentation in the Doc dir OS-windows

Comments

@sredna
Copy link

sredna commented Jun 26, 2022

The current documentation claims that open is the same as not specifying an operation, this is not true. open forces the open verb/operation just like any other string forces that operation. open is often the same as unspecified but it might not be.

MSDN describes how the verb is resolved if NULL is passed to ShellExecute:

The default verb is used, if available. If not, the "open" verb is used. If neither verb is available, the system uses the first verb listed in the registry.

The "default verb" is the string that can be set in HKEY_CLASSES_ROOT\%progid%\shell of the file type.

NULL needs to be passed to simulate double-clicking a file in Explorer...

@sredna sredna added the docs Documentation in the Doc dir label Jun 26, 2022
@zooba zooba closed this as completed Jul 29, 2022
Utumno added a commit to wrye-bash/wrye-bash that referenced this issue Nov 1, 2023
As seen in
https://github.com/python/cpython/blob/b14e882428ceda1e5852a1c22772e7f88927bded/Modules/clinic/posixmodule.c.h#L9807C1-L9807C1
the default for show_cmd is 1 which is then passed to ShellExecuteW (sic) in
https://github.com/python/cpython/blob/cf6145453ff3a7bdc0790ac6d95b5b097c489d45/Modules/posixmodule.c#L12772
See also https://docs.python.org/3.11/library/os.html#os.startfile --
cwd is inherited which IIUC means we don't need to pass it
See also python/cpython#94302 for "open"

I removed FindExecutable logic - needs testing and some comments but
I stash it here as actually Applauncher instances are rare - most are
ExeLauncher

exe_args better be just the args as seen
Utumno added a commit to wrye-bash/wrye-bash that referenced this issue Nov 3, 2023
This finally decouples app_buttons from windows specific code. Note
error handling centralized in App_Button sb_click which made more OldCodz
redundant :)

Under #368 for dropping setcw, made possible as its use was centralized.
Still not clear how it's used could use a comment.

shlex:

Was  args = f'"{self.exePath}"' vs ...exePath}" ' <- note space
this seems fishy - I used shlex to do the join instead and used the full
exe_args:

 @@ -1652,3 +1652,4 @@ def launch_app(self, exe_path, exe_args):
         cwd = _Path.getcwd()
-        args = f'"{exe_path}" ' ' '.join([f'{arg}' for arg in self.exeArgs])  #  fixme use shlex?
+        args = shlex.join(exe_args)
+        executable = None
         try:

in32api is only imported in env.windows (and bash.py) - a long term
goal of #258

More shlex.split

I think it's the right thing? see:
https://discord.com/channels/537706885965676554/537710082755133460/1166274759957434388

for a complex cli passed from the ini where posix=false is needed

Reinstate os.startfile in windows:

As seen in
https://github.com/python/cpython/blob/b14e882428ceda1e5852a1c22772e7f88927bded/Modules/clinic/posixmodule.c.h#L9807C1-L9807C1
the default for show_cmd is 1 which is then passed to ShellExecuteW (sic) in
https://github.com/python/cpython/blob/cf6145453ff3a7bdc0790ac6d95b5b097c489d45/Modules/posixmodule.c#L12772
See also https://docs.python.org/3.11/library/os.html#os.startfile --
cwd is inherited which IIUC means we don't need to pass it
See also python/cpython#94302 for "open"

I removed FindExecutable logic - needs testing and some comments but
I stash it here as actually Applauncher instances are rare - most are
ExeLauncher (actually ony SoftimageModTool uses a bat)

See discussion in:

5351c89

exe_args better be just the args without the exe path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir OS-windows
Projects
None yet
Development

No branches or pull requests

3 participants