[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-26 Thread STINNER Victor


STINNER Victor  added the comment:

In short, I did my checks on my side, and the merged change now LGTM. Thanks 
Christian for fixing it ;-)

--

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-26 Thread STINNER Victor


STINNER Victor  added the comment:

IMO making the assumption that "char" is signed or not in C code is bad. If 
Python has code like that, it must be signed to explicitly use one of these 
types: unsigned char or uint8_t, signed char or int8_t. Hopefully, Python can 
now use C99  since Python 3.6.

On my x86-64 Fedora 35 (GCC 11.2.1), the "char" type is signed. I built Python 
with -funsigned-char and I ran the test suite: the whole test suite pass! 
Commands:

---
make distclean
./configure --with-pydebug CFLAGS="-O0 -funsigned-char" --with-system-expat 
--with-system-ffi
make
./python -m test -j0 -r
---

Using ./configure CFLAGS, -funsigned-char is also used to build C extensions. 
Example: 

   gcc (...) -O0 -funsigned-char (...) Modules/_elementtree.c (...)


For completeness, I also built Python with -fsigned-char. Again, the full test 
suite passed ;-)

---
make distclean
./configure --with-pydebug CFLAGS="-O0 -fsigned-char" --with-system-expat 
--with-system-ffi
make
./python -m test -r -j0
---

--

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-26 Thread Christian Heimes


Christian Heimes  added the comment:

The fix is in all stable branches. Thanks!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-26 Thread Christian Heimes


Christian Heimes  added the comment:


New changeset 4371fbd4328781496f5f2c6938c4d9a84049b187 by Christian Heimes in 
branch '3.10':
[3.10] bpo-46513: Remove AC_C_CHAR_UNSIGNED / __CHAR_UNSIGNED__ (GH-30851) 
(GH-30914)
https://github.com/python/cpython/commit/4371fbd4328781496f5f2c6938c4d9a84049b187


--

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-26 Thread Christian Heimes


Christian Heimes  added the comment:


New changeset 04772cd6f164c1219c8c74d55626ba114f01aa96 by Christian Heimes in 
branch '3.9':
[3.9] bpo-46513: Remove AC_C_CHAR_UNSIGNED / __CHAR_UNSIGNED__ (GH-30851) 
(GH-30915)
https://github.com/python/cpython/commit/04772cd6f164c1219c8c74d55626ba114f01aa96


--

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-26 Thread Christian Heimes


Change by Christian Heimes :


--
pull_requests: +29094
pull_request: https://github.com/python/cpython/pull/30915

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-26 Thread Christian Heimes


Change by Christian Heimes :


--
pull_requests: +29093
pull_request: https://github.com/python/cpython/pull/30914

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-26 Thread Petr Viktorin


Petr Viktorin  added the comment:

Yeah, that looks like it's for some long-forgotten compiler that didn't 
implement `signed char` at all. 1994 was a fun time, apparently.

--
nosy:  -miss-islington

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-26 Thread miss-islington


miss-islington  added the comment:


New changeset 6e5a193816e1bdf11f5fb78d620995fd6987ccf8 by Christian Heimes in 
branch 'main':
bpo-46513: Remove AC_C_CHAR_UNSIGNED / __CHAR_UNSIGNED__ (GH-30851)
https://github.com/python/cpython/commit/6e5a193816e1bdf11f5fb78d620995fd6987ccf8


--
nosy: +miss-islington

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

My audioop.c change which looks to be wrong (useless):

diff --git a/Modules/audioop.c b/Modules/audioop.c
index 3aeb6f04f13..4c04b17ce7f 100644
--- a/Modules/audioop.c
+++ b/Modules/audioop.c
@@ -1948,6 +1941,13 @@ audioop_exec(PyObject* module)
 {
 audioop_state *state = get_audioop_state(module);
 
+if (!_Py_CTYPE_IS_SIGNED(char)) {
+PyErr_SetString(PyExc_RuntimeError,
+"the audioop module does not support systems "
+"where the char type is unsigned");
+return -1;
+}
+
 state->AudioopError = PyErr_NewException("audioop.error", NULL, NULL);
 if (state->AudioopError == NULL) {
 return -1;

--

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

To test if a C type is signed or not, I wrote this macro:

// Test if a C type is signed.
//
// Usage: assert(_Py_CTYPE_IS_SIGNED(char)); // fail if 'char' type is unsigned
#define _Py_CTYPE_IS_SIGNED(T) (((T)-1) < 0)

I planned to use it to raise an error on "import audioop" if the C "char" type 
is unsigned, but it seems like it's not needed, since the C extensions seems to 
work if char is signed or unsigned (I only read the C code, I didn't run 
test_audioop to actually test it).

--

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

> Modules/audioop.c uses __CHAR_UNSIGNED__, but the absence or presence of the 
> symbol does not affect behavior

This comment is really weird since audioop explicitly uses "signed char" and 
"unsigned char". Maybe to avoid any risk of confusion, the C code should use 
int8_t and uint8_t.

--

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-25 Thread STINNER Victor


STINNER Victor  added the comment:

Fedora downstream issue: https://bugzilla.redhat.com/show_bug.cgi?id=2043555

We should make sure that Python can be built with -fsigned-char *and* with 
-funsigned-char: build Python, but also run its test suite.

--

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-25 Thread Christian Heimes


Christian Heimes  added the comment:

Modules/audioop.c uses __CHAR_UNSIGNED__, but the absence or presence of the 
symbol does not affect behavior:

#if defined(__CHAR_UNSIGNED__)
#if defined(signed)
/* This module currently does not work on systems where only unsigned
   characters are available.  Take it out of Setup.  Sorry. */
#endif
#endif

--

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-25 Thread Christian Heimes


Change by Christian Heimes :


--
keywords: +patch
pull_requests: +29062
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30851

___
Python tracker 

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



[issue46513] AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining __CHAR_UNSIGNED__

2022-01-25 Thread Miro Hrončok

New submission from Miro Hrončok :

As described at 
https://mail.python.org/archives/list/python-...@python.org/thread/MPHZ3TGSHMSF7C4P7JEP2ZCYLRA3ERC5/
 the AC_C_CHAR_UNSIGNED macro from configure.ac confuses GCC 12+ as it exports 
a reserved symbol __CHAR_UNSIGNED__ through pyconfig.h.

My assumption was that AC_C_CHAR_UNSIGNED can be dropped entirely and the PR in 
https://github.com/python/cpython/pull/30851 confirmed that all the buildbots 
are happy with such change. Hence, I open this issue to actually do it.

Thanks

--
components: Build
messages: 411575
nosy: christian.heimes, hroncok, petr.viktorin, vstinner
priority: normal
severity: normal
status: open
title: AC_C_CHAR_UNSIGNED from configure.ac confuses GCC 12+ by defining 
__CHAR_UNSIGNED__
type: compile error
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

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