Exception in the `startup.py` tries to open a random command line file
- 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 Please paste your Notepad++ Debug Info data here.
@andry81 The user manual states: The only intended and supported use for this option is for the Notepad Replacement syntax.. Thus, don't do what you're doing with -z.
You could try -pluginMessage="text for plugin(s)" instead...
@andry81 Please paste your Notepad++ Debug Info data here.
Notepad++ v8.8 (64-bit)
Build time : Apr 24 2025 - 02:59:05
Scintilla/Lexilla included : 5.5.6/5.4.4
Boost Regex included : 1_85
Path : C:\Programs\Utility\notepad-plus-plus.org\Notepad++\notepad++.exe
Command Line : -nosession -multiInst
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : OFF
Placeholders : OFF
Scintilla Rendering Mode : SC_TECHNOLOGY_DEFAULT (0)
Multi-instance Mode : monoInst
File Status Auto-Detection : cdEnabledOld (for all opened files/tabs)
Dark Mode : ON
OS Name : Windows 8.1 Single Language (64-bit)
OS Build : 9600.20778
Current ANSI codepage : 1251
Plugins :
HTMLTag (1.5.2)
mimeTools (3.1)
MultiReplace (4.2.2.25)
NppConverter (4.6)
NppExport (0.4)
NppTextFX (1.4.1)
PythonScript (3.0.20)
XMLTools (3.1.1.13)
@andry81 The user manual states:
The only intended and supported use for this option is for the Notepad Replacement syntax.. Thus, don't do what you're doing with-z.
It works as expected. Don't see a problem here.
The problem is with a not catched exception, which alters the behavior.
It works as expected.
Ok, but not sure how far anyone here will attempt to carry support along, for an unsupported usage.
The problem is with a not catched exception,
Well, are you trying to catch it in the Python? Really, you don't show much of anything in your writeup of this issue.
Really, you don't show much of anything in your writeup of this issue.
startup.py:
print(notepad.getCommandLine())
raise Exception('123')
Run:
cd c:\test
notepad++.exe -nosession -multiInst -z "" -z test
Result:
Create new file
"c:\test\-z test" doesn't exist. Create it?
Yes No