New GitHub issue #94644 from vstinner:<br>

<hr>

<pre>
At commit e925241d95d8095adf67f492042f97254ff82ec1, test_curses leaks references:

```
$ ./python -m test test_curses -m test_output_string_embedded_null_chars -u all  -R 3:3
(...)
test_curses leaked [4, 4, 4] references, sum=12
```

I reproduce the issue on Fedora.

Example of failing buildbot: https://buildbot.python.org/all/#/builders/16/builds/244

Before this change, Python doesn't leak references.

Before: make:

```
building '_curses' extension
gcc -fPIC -g -Og -Wall -O0 -std=c11 -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -D_DEFAULT_SOURCE -I./Include -I. -I/usr/local/include -I/home/vstinner/python/main/Include -I/home/vstinner/python/main -c /home/vstinner/python/main/Modules/_cursesmodule.c -o build/temp.linux-x86_64-3.12-pydebug/home/vstinner/python/main/Modules/_cursesmodule.o
Dans le fichier inclus depuis ./Include/Python.h:12,
                 depuis /home/vstinner/python/main/Modules/readline.c:8:
./pyconfig.h:1762: attention: « _XOPEN_SOURCE » redéfini
 1762 | #define _XOPEN_SOURCE 700
      | 
<ligne-de-commande>: note: ceci est l'emplacement d’une précédente définition
gcc -shared build/temp.linux-x86_64-3.12-pydebug/home/vstinner/python/main/Modules/_csv.o -L/usr/local/lib -o build/lib.linux-x86_64-3.12-pydebug/_csv.cpython-312d-x86_64-linux-gnu.so
gcc -shared build/temp.linux-x86_64-3.12-pydebug/home/vstinner/python/main/Modules/_xxsubinterpretersmodule.o -L/usr/local/lib -o build/lib.linux-x86_64-3.12-pydebug/_xxsubinterpreters.cpython-312d-x86_64-linux-gnu.so
gcc -shared build/temp.linux-x86_64-3.12-pydebug/home/vstinner/python/main/Modules/_testinternalcapi.o -L/usr/local/lib -o build/lib.linux-x86_64-3.12-pydebug/_testinternalcapi.cpython-312d-x86_64-linux-gnu.so
building '_curses_panel' extension
gcc -fPIC -g -Og -Wall -O0 -std=c11 -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -I./Include -I. -I/usr/local/include -I/home/vstinner/python/main/Include -I/home/vstinner/python/main -c /home/vstinner/python/main/Modules/_curses_panel.c -o build/temp.linux-x86_64-3.12-pydebug/home/vstinner/python/main/Modules/_curses_panel.o
```

After: make:

```
``

The commit removes ``-DHAVE_NCURSESW=1 -I/usr/include/ncursesw`` options and adds `` -D_DEFAULT_SOURCE`` option to the (gcc) build command line of the _curses extension.

cc @tiran @erlend-aasland 
</pre>

<hr>

<a href="https://github.com/python/cpython/issues/94644">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>