You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have found out certain peculiarity of interpreter in case it is embedded.
There is no way to reference to the real parameters argv, argc of main process from embedded python's C extensions.
When python is not embedded, it is task of function Py_Main, which sets the value of variables orig_argv, orig_argc.
These variables keep references to the original values of argv, argc and give opportunity to manage them from the python C extensions if necessary.
I understand that the function Py_GetArgcArgv is rarely used, and this is true, but still believe that ability to manipulate these variables should be exist in any form of python from its C extension modules.
I tried different modules of C-extensions with such functional in embedded environment, but they all causes Segmentation Fault. The problem is not only in their implementation quality without any additional inspections, but also the function Py_GetArgcArgv doesn't additionally reported that its returned, and just ruturn null pointer in self argv parameter when used in embedded environment.
The following quote all the code that refers to this functionality in Python 2.7-3.3 at the moment:
/* For Py_GetArgcArgv(); set by main() */staticchar**orig_argv;
staticintorig_argc;
..........................................................................................
/* Main program */
Thats why I would like to suggest something similar to such function and use it in Py_Main and probably make it available from Python C API.
And also extend Py_GetArgcArgv with more detailed null pointer handling if variables orig_argv, orig_argc had not been initialized.
changed the title [-]Real Argc Argv in embedded interpreter[/-][+]Real argc and argv in embedded interpreter[/+]on Aug 8, 2012
BreamoreBoy commented on Jul 11, 2014
BreamoreBoymannequin
Mannequin
More actions
Without a patch this issue will go nowhere. I'm assuming that this limitation must have been overcome by other projects using embedded Python. Has anybody got any ideas as to how, I certainly haven't?
Activity
nordaux commentedon Aug 7, 2012
I have found out certain peculiarity of interpreter in case it is embedded.
There is no way to reference to the real parameters argv, argc of main process from embedded python's C extensions.
When python is not embedded, it is task of function Py_Main, which sets the value of variables orig_argv, orig_argc.
These variables keep references to the original values of argv, argc and give opportunity to manage them from the python C extensions if necessary.
I understand that the function Py_GetArgcArgv is rarely used, and this is true, but still believe that ability to manipulate these variables should be exist in any form of python from its C extension modules.
I tried different modules of C-extensions with such functional in embedded environment, but they all causes Segmentation Fault. The problem is not only in their implementation quality without any additional inspections, but also the function Py_GetArgcArgv doesn't additionally reported that its returned, and just ruturn null pointer in self argv parameter when used in embedded environment.
The following quote all the code that refers to this functionality in Python 2.7-3.3 at the moment:
..........................................................................................
/* Main program */
Thats why I would like to suggest something similar to such function and use it in Py_Main and probably make it available from Python C API.
And also extend Py_GetArgcArgv with more detailed null pointer handling if variables orig_argv, orig_argc had not been initialized.
Would like to see other suggestions.
Thanks.
[-]Real Argc Argv in embeded interpreter[/-][+]Real Argc Argv in embedded interpreter[/+][-]Real Argc Argv in embedded interpreter[/-][+]Real argc and argv in embedded interpreter[/+]BreamoreBoy commentedon Jul 11, 2014
Without a patch this issue will go nowhere. I'm assuming that this limitation must have been overcome by other projects using embedded Python. Has anybody got any ideas as to how, I certainly haven't?
vstinner commentedon Sep 26, 2019
I only saw one request (this issue) for this feature, in 2012. So it doesn't sound really important. I close the issue.
encukou commentedon Jun 8, 2020
FWIW, another project that needs Py_GetArgcArgv is "setproctitle": https://bugzilla.redhat.com/show_bug.cgi?id=1792059
See also: cherrypy/cherrypy#1506
dvarrazzo commentedon Jun 8, 2020
Py_GetArgcArgv gone broke setproctitle indeed.
dvarrazzo/py-setproctitle#76
Is there a way to get the same feature in 3.9 or should setproctitle become no-op from 3.9 on and Python loses this feature?
Thank you.
vstinner commentedon Jun 8, 2020
I mark this issue as a duplicate of bpo-23427.
vstinner commentedon Jun 8, 2020
See also bpo-40910: "Py_GetArgcArgv() is no longer exported by the C API".