Title no support for Py_GetArgcArgv
Priority bug Status testing
Superseder Nosy List kayhayen, nssh
Assigned To Keywords wrong_execution

Created on 2013-03-31.18:10:09 by nssh, last changed by kayhayen.

msg1922 (view) Author: kayhayen Date: 2016-04-22.00:53:59
Part of the latest pre-release, on Windows the API is not present.
msg1901 (view) Author: kayhayen Date: 2016-04-18.07:22:32
I just pushed to factory a solution for this issue on Linux. Needs more work for 
Windows potentially.
msg363 (view) Author: kayhayen Date: 2013-06-12.21:51:51
Ok, deferred indeed.
msg334 (view) Author: nssh Date: 2013-04-04.02:11:06
Check again,
only LD_PRELOAD can fix and that's linux only,
I think Py_GetArgcArgv isn't a standard api because it not list in Python.h.
Just keep the time to do other things,
change status to deferred.
msg324 (view) Author: nssh Date: 2013-04-01.01:55:01
It sound no easy to resolve because orig_argc and orig_argv not public.
but it will use in real code,
this code are copy from a project use multiprocessing and it will change per
process cmdline on linux (use to recognition user, like sshd).
Py_GetArgcArgv also can use in c extesion (just I lazy then use
ctypes.pythonapi) so patch ctypes isn't a good way.
msg323 (view) Author: kayhayen Date: 2013-03-31.21:15:40
I tried to overload the libpython with my own Py_GetArgcArgv, but that won't 
work as well.

I am now contemplating if it's necessary to call Py_Main() instead of 
Py_Initialize(). That would be quite a fight as it does options parsing as 
CPython would to control things, that I would suppose to be already decided, so 
I don't think we can go there.

The variables used for original argv are "static" in CPython. How did you get 
ahold of the code? Is this demonstration code or real code? It seems strange to 
not use sys.argv which is properly set.

The way to support it would be to patch ctypes. Since it is not normally loaded 
at startup (same for inspect), we should devise a way to hook module import, so 
the patching can be delayed.
msg321 (view) Author: nssh Date: 2013-03-31.18:10:09
test code
import ctypes
argv = ctypes.POINTER(ctypes.POINTER(ctypes.c_char))()
argc = ctypes.c_int()
ctypes.pythonapi.Py_GetArgcArgv(ctypes.byref(argc), ctypes.byref(argv))
print argc
for i in xrange(argc.value):
	p = argv[i]
	s = ""
	i = 0
	while 1:
		if p[i] == "\x00":
		s += p[i]
		i += 1
	print s

run result
$ python ../
$ ./bin/nuitka-python ../

in cpython orig_argc and orig_argv are set from Py_Main so maybe other
attributable from py_main has no support too.
Date User Action Args
2016-04-22 00:53:59kayhayensetassignedto: kayhayen ->
messages: + msg1922
2016-04-18 07:22:40kayhayensetassignedto: kayhayen
nosy: + kayhayen
2016-04-18 07:22:32kayhayensetstatus: deferred -> testing
messages: + msg1901
keyword: + wrong_execution
2013-06-12 21:51:51kayhayensetmessages: + msg363
2013-04-04 02:11:06nsshsetstatus: chatting -> deferred
messages: + msg334
2013-04-01 01:55:01nsshsetmessages: + msg324
2013-03-31 21:15:40kayhayensetstatus: unread -> chatting
messages: + msg323
2013-03-31 18:10:09nsshcreate