New submission from Vitaly Murashev: [Affects Windows only] Brief description (after analysis in debugger):
Py_InitializeEx fails inside internal call: 1. if (initstdio() < 0) Py_FatalError( "Py_Initialize: can't initialize sys standard streams"); 2. inside initstdio(): if (!is_valid_fd(fd)) { std = Py_None; Py_INCREF(std); } else { // ===> is_valid_fd() passed and we come here std = create_stdio(iomod, fd, 0, "<stdin>", encoding, errors); if (std == NULL) goto error; // ===> this goto leads to fatal error 3. is_valid_fd(int fd) /// => JFI: fd=0 { int dummy_fd; if (fd < 0 || !_PyVerify_fd(fd)) return 0; dummy_fd = dup(fd); /// ==>> dup() WORKS well if (dummy_fd < 0) return 0; close(dummy_fd); return 1; } 4. Let's Look whats going in create_stdio(): Modules\_io\fileio.c static int fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) { ... if (fd >= 0) { if (check_fd(fd)) goto error; /// => fail is here 5. Let's have a look at check_fd(): static int check_fd(int fd) { #if defined(HAVE_FSTAT) /// => yes, it is defined for Windows struct stat buf; if (!_PyVerify_fd(fd) || (fstat(fd, &buf) < 0 && errno == EBADF)) { PyObject *exc; char *msg = strerror(EBADF); exc = PyObject_CallFunction(PyExc_OSError, "(is)", EBADF, msg); PyErr_SetObject(PyExc_OSError, exc); Py_XDECREF(exc); return -1; } #endif return 0; } ---------- components: IO, Interpreter Core, Windows messages: 246199 nosy: paul.moore, steve.dower, tim.golden, vmurashev, zach.ware priority: normal severity: normal status: open title: [VS2013] Py_InitializeEx causes fatal error being from winnt-service type: crash versions: Python 3.4, Python 3.5, Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24561> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com