Author hroncok
Recipients hroncok, vstinner
Date 2019-08-23.07:39:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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() {
    PySys_SetArgvEx(0, NULL, 0);  /* HERE */
    PyRun_SimpleString("from time import time,ctime\n"
                       "print('Today is', ctime(time()))\n");
    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 explicitly mentions passing 0 to PySys_SetArgvEx:

"if argc is 0..."

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