PythonScript icon indicating copy to clipboard operation
PythonScript copied to clipboard

Exception in the `startup.py` tries to open a random command line file

Open andry81 opened this issue 8 months ago • 6 comments

  • PythonScript: 3.0.20.0

I have an extension to the Notepad++. In the extension I have using the startup.py to parse an extra command line looking like this:

notepad++.exe -nosession -multiInst -z --custom_parameter_1 -z "<path-to-custom-file-list>" -z --custom_parameter_2 -z custom_parameter_3

The startup.py has a code:

...
with open(path_to_custom_file_list, 'rb') as file_list:
  ...
...

Which throws the exception:

FileNotFoundError: [Errno 2] No such file or directory: "<path-to-custom-file-list>"

This is ok, as long the file does not exist.

But, then Notepad++ tries to create a new file with the dialog box:


Create new file

"-z --custom_parameter_2 -z custom_parameter_3" doesn't exist. Create it?

Yes No

This is not expected. The Notepad++ should not proceed to open anything. Just open an empty tab instance would be enough.

I suspect the Notepad++ tries to detect the rest of the command line after a random file parameter as a path to a file.

Suggestion: May be command line cleanup in the default exception handler would be enough.

andry81 avatar May 10 '25 13:05 andry81