Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork320
SetProgramArgs() modifies sys.argv#430
-
Hi! Recently I noticed that sys.argv is modified when extending Python using PythonEngine.pas. I found that this is because SetProgramArgs() inserts an empty string in the call to PySys_SetArgv(). My understanding is that calling PySys_SetArgv() is useful when embedding Python, but when extending Python by using PythonEngine.pas to create a .pyd this seems undesirable. I created this small pargs.py file to reproduce the issue: Initially the output running 'python pargs.py' is: When I also import my own package implemented using PythonEngine.pas like this: running 'python pargs.py' again now results in; Do you think it is a good idea to skip calling the SetProgramArgs procedure when extending Python? If yes, how can we discriminate between extending Python and embedding Python in TPythonEngine.Initialize? Best regards and many thanks for maintaining this excellent PythonEngine, Lennert. |
BetaWas this translation helpful?Give feedback.
All reactions
Sorry for the late reply. I have just seen your response.
As I am writing an extension
Do you mean a python extension module (a pyd file that can be loaded into python)?
If yes, please see how LoadDllInExtensionModule is used in thedemo test module.
Replies: 1 comment 3 replies
-
You are most likely not using LoadDllInExtensionModule to load the python dll in your Delphi created python module. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I am not sure what you mean. As I am writing an extension I don't load the python DLL at all. Or do you mean something else? If needed I can try to make a small extension that does (nearly) nothing but should prove my point that sys.argv is being modified. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Sorry for the late reply. I have just seen your response.
Do you mean a python extension module (a pyd file that can be loaded into python)? If yes, please see how LoadDllInExtensionModule is used in thedemo test module. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thanks, using LoadDllInExtensionModule did the trick! |
BetaWas this translation helpful?Give feedback.