New submission from Robert <kxrobe...@gmail.com>:

When PY_SSIZE_T_CLEAN  is not #defined in Py3.10, PyArg_ParseTuple() etc. sets 
a SystemError but the return value says 1 (=SUCCESS)! 
=>  Causes terrific crashes with unfilled variables - instead of a clean Python 
exception.

Background: pywin32 suffers in masses from the drop of int support for the 
s#/y#/et#... formats in PyArg_ParseTuple() etc.  (PY_SSIZE_T_CLEAN is required 
in Py3.10). And only part of the source is already PY_SSIZE_T_CLEAN. Now it is 
very difficult to even run tests and weed out / check, because of freezes 
instead of nice Python exceptions.

=> Instead of preventing such freezes, the PY_SSIZE_T_CLEAN mechanism became 
the opposite: a clever trap, a sword of Damocles :)


The cause is in getargs.c:

=================== getargs.c / convertsimple() ====

#define REQUIRE_PY_SSIZE_T_CLEAN \
    if (!(flags & FLAG_SIZE_T)) { \
        PyErr_SetString(PyExc_SystemError, \
                        "PY_SSIZE_T_CLEAN macro must be defined for '#' 
formats"); \
        return NULL; \
    }
#define RETURN_ERR_OCCURRED return msgbuf

===================


=> The return NULL is further processed as no msg NULL -> no error.  
=> Perhaps it should be a `return converterr(...)` or `return 
sstc_system_error(...)` !?

----------
components: Interpreter Core
messages: 387678
nosy: kxrob
priority: normal
severity: normal
status: open
title: PyArg_ParseTuple() false-returns SUCCESS though SystemError and missing 
data (when PY_SSIZE_T_CLEAN  not #define'd)
type: crash
versions: Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43321>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to