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. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You are most likely not using LoadDllInExtensionModule to load the python dll in your Delphi created python module. |
Beta Was this translation helpful? Give feedback.
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 the demo test module.