[issue46605] Py_XDECREF() module on fail in Py_mod_exec

2022-02-01 Thread ov2k


New submission from ov2k :

In some of the xx modules, a Py_mod_exec function steals a reference to the 
module argument when an error occurs (Py_XDECREF(m) after goto fail).  It's a 
bit pernicious given the modules' stated intent to be used as a template, 
although I'm not sure how often this has actually happened.  At the very least, 
I haven't noticed this outside the xx modules.

For Python <= 3.9, this affects xx_exec() in xxmodule.c and xx_modexec() in 
xxlimited.c.  For Python >= 3.10, this affects xx_exec() in xxmodule.c and 
xx_modexec() in xxlimited_35.c.

--
components: Extension Modules
messages: 412315
nosy: ov2k
priority: normal
severity: normal
status: open
title: Py_XDECREF() module on fail in Py_mod_exec
type: behavior
versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue46605>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46664] PY_SSIZE_T_MAX is not an integer constant expression

2022-02-06 Thread ov2k


New submission from ov2k :

PY_SSIZE_T_MAX is currently defined in Include/pyport.h as: 

#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))

This is not an integer constant expression, which means it can't be used in 
preprocessor conditionals.  For example: 

#if PY_SSIZE_T_MAX > UINT32_MAX

will fail to compile.  This was touched upon and ignored a long time ago: 

https://mail.python.org/archives/list/python-...@python.org/thread/27X7LINL4UO7DAJE6J3IFQEZGUKAO4VL/

I think the best fix is to move the definition of PY_SSIZE_T_MAX (and 
PY_SSIZE_T_MIN) next to the definition of Py_ssize_t, and use the proper 
corresponding limit macro.  If Py_ssize_t is a typedef for ssize_t, then 
PY_SSIZE_T_MAX should be SSIZE_MAX.  If Py_ssize_t is a typedef for 
Py_intptr_t, then PY_SSIZE_T_MAX should be INTPTR_MAX.  There's a minor 
complication because Py_ssize_t can be defined in PC/pyconfig.h.  I'm not so 
familiar with the various Windows compilers, so I'm not sure what's best to do 
here.  I think __int64 has a corresponding _I64_MAX macro, and int obviously 
has INT_MAX.

--
components: C API
messages: 412670
nosy: ov2k
priority: normal
severity: normal
status: open
title: PY_SSIZE_T_MAX is not an integer constant expression
type: compile error
versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue46664>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46664] PY_SSIZE_T_MAX is not an integer constant expression

2022-02-06 Thread ov2k


Change by ov2k :


--
type: compile error -> enhancement

___
Python tracker 
<https://bugs.python.org/issue46664>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com