-
Notifications
You must be signed in to change notification settings - Fork 69
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
exit()
in a pythonscript causes Notepad++ to CRASH
#301
Comments
exit()
in a pythonscript causes Notepad++ to exit
I found it mentioned in forum , where workarounds for exiting the script are given (like the good However, IMHO, this bug can still pose a problem for beginners / unsuspecting people, cannot it? N++ appears like crashing in that moment. I'm not a python expert, but can't this problem be solved/prevented by, for example, disabling
|
I wouldn't call this a bug, it does what it is supposed to do, which is to terminate the running program, which in this case is Npp. It may not be what someone expects if they are not familiar with Python, but it is what it is. Maybe there should be a highlighted note in the document explaining this, but I personally wouldn't start implementing code that prevents you from doing something like this. |
This is not a bad idea, but for the individual. Meaning that sure, go ahead and implement it yourself in your startup.py. I've done so for mine. BTW, you don't need the |
Those commands are supposed/meant/defined to terminate Python, not N++... So I don't see why people good at Python would think terminating N++ is expected.
Totally, I can do that.
Well, for all individuals., to be already in their
you're right! |
...Or, just don't use |
Not if you understand that it does not stop a runtime per se, but the process that provides that runtime. PS does not start a separate Python process to run PythonScripts but provides the runtime inside the Npp process, so from my point of view it is expected that an exit terminates Npp. To date, Python has no mechanism for stopping AND starting runtimes/interpreters. It is initialized (started) and runs until it is terminated (end of process). There are plans to add a functionality called subinterpreter, which would then have to provide such a function, but currently ... it does not do that yet. |
wait a second! I don't understand why you (and others) try to cover it up or defend it, instead of acknowledging, so that a solution will be found, in time. |
Yes, I understand your point of view. Given how this plugin is implemented and attached to N++, then, yes, it's expected that exit() will crash N++ too. But I think you can also understand the user's point of view , that exit() should not, not supposed, to kill N++. So at very least, I think developers should adopt the "primitive" solution above about disabling these commands in
I don't fully understand all that, but if you allow me to speculate a little... I'd look at not how Python starts/stops other interpreters, but at how Python itself is started by N++. |
exit()
in a pythonscript causes Notepad++ to exitexit()
in a pythonscript causes Notepad++ to CRASH
well, yes, that should be one of the first lines in the documentation. |
I'm not trying to cover it up or defend it, I was simply stating that the function does what it is supposed to do and therefore it is not a bug. It would be a bug if it didn't do what it was supposed to do.
No, such dependencies are, to my knowledge, not provided for in the window architecture and would have to be programmed manually. It is actually possible the other way around, i.e. you can start a child process which is not terminated when the parent process ends.
I don't see that this is as easy to solve as I said at the moment. |
Thank you.
Good points and questions... I'll go on a limb here: maybe this could also have advantages, as making it harder to have the kind of dangers we discussed in the other issue (#298) where from PythonScript can change variables of importance outside of Scintilla, or even Notepad++ (if I understood correctly) ?
So well said... ! |
I don't think so. Concurrent access to a memory area is always the same challenge, whether it's from a thread or a process. You have to make sure that only one can modify the area at a time. Processes only complicate this further because they bring another layer into play, namely the different address spaces. Now you have to deal with, for example, shared memory. |
Seems issue is caused by exception handling at:
after exit(), quit(), sys.exit() triggers the exception boost::python exception:
Behaviour could be prevented by avoiding to call PyErr_Print() for that exception type in case the input is directly given to the console. If the functions are used by a script there is no such exception. |
Using any of these in a pythonscript:
Causes N++ to
exit abruptlycrash.Notepad++ v8.5.4 (32-bit)
Build time : Jun 17 2023 - 20:40:14
Path : C:\Users\Vic\AppData\npp.8.5.4.portable\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : ON
Cloud Config : OFF
OS Name : Windows 7 Ultimate (32-bit)
OS Build : 7601.24546
Current ANSI codepage : 1252
Plugins :
mimeTools (2.9)
NppConverter (4.5)
NppExec (0.8.4)
NppExport (0.4)
PythonScript (2)
The text was updated successfully, but these errors were encountered: