[New-bugs-announce] [issue40309] “unmatched paren” for space before parenthesis in Py_BuildValue

Gerrit Ansmann report at bugs.python.org
Fri Apr 17 04:54:27 EDT 2020


New submission from Gerrit Ansmann <gansmann at uni-bonn.de>:

According to the C-API documentation¹ for `Py_BuildValue`:

> The characters space, tab, colon and comma are ignored in format strings (but not within format units such as s#). This can be used to make long format strings a tad more readable.

However format strings such as `"(d )"` cause the error:

> Unmatched paren in format

By contrast `"( d)"` and `"(d d)"` cause no problems. I therefore assume that tuples are not considered “format units” in the sense of the above quote and this is a bug. Alternatively, the documentation needs clarification.

I could reproduce this problem with Python 3.7 and 3.8. I did not try other versions.

Appended is a minimal C extension exhibiting the problem. I compile and run with:

gcc -fPIC -I/usr/include/python3.8 -c foo.c -o foo.o
gcc -shared foo.o -o foo.so
python3.8 -c "import foo; foo.bar()"

----

¹ https://docs.python.org/3/c-api/arg.html

----------
components: C API
files: foo.c
messages: 366647
nosy: Wrzlprmft
priority: normal
severity: normal
status: open
title: “unmatched paren” for space before parenthesis in Py_BuildValue
versions: Python 3.7, Python 3.8
Added file: https://bugs.python.org/file49069/foo.c

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40309>
_______________________________________


More information about the New-bugs-announce mailing list