This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author hroncok
Recipients hroncok, vstinner
Date 2019-08-23.07:39:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1566545949.45.0.201062291719.issue37926@roundup.psfhosted.org>
In-reply-to
Content
There is a regression between Python 3.7 and 3.8 when using PySys_SetArgvEx(0, NULL, 0).

Consider this example:

#include <Python.h>

int main() {
    Py_Initialize();
    PySys_SetArgvEx(0, NULL, 0);  /* HERE */
    PyRun_SimpleString("from time import time,ctime\n"
                       "print('Today is', ctime(time()))\n");
    Py_FinalizeEx();
    return 0;
}


This works in 3.7 but no longer does in 3.8:

$ gcc $(python3.7-config --cflags --ldflags) example.c 
$ ./a.out 
Today is Fri Aug 23 07:59:52 2019

$ gcc $(python3.8-config --cflags --ldflags --embed) example.c 
$ ./a.out 
Fatal Python error: no mem for sys.argv
SystemError: /builddir/build/BUILD/Python-3.8.0b3/Objects/unicodeobject.c:2089: bad argument to internal function

Current thread 0x00007f12c78b9740 (most recent call first):
Aborted (core dumped)


The documentation https://docs.python.org/3/c-api/init.html#c.PySys_SetArgvEx explicitly mentions passing 0 to PySys_SetArgvEx:

"if argc is 0..."

So I guess this is not something you shouldn't do.
History
Date User Action Args
2019-08-23 07:39:09hroncoksetrecipients: + hroncok, vstinner
2019-08-23 07:39:09hroncoksetmessageid: <1566545949.45.0.201062291719.issue37926@roundup.psfhosted.org>
2019-08-23 07:39:09hroncoklinkissue37926 messages
2019-08-23 07:39:09hroncokcreate