Skip to content

Argument Clinic's [python input] blocks do not support /* in literal strings #128153

@picnixz

Description

@picnixz

Bug report

Bug description:

The following is not a valid Python input clinic but should be:

/*[python input]
print("/* this is a comment *\/")
[python start generated code]*/

Note that the inner C comment should be *\/ because otherwise IDEs will consider the block comment to be closed resulting in syntax errors (for the C file). Another example is just:

/*[python input]
x = "/*"
[python start generated code]*/

Both result in the following error (I've just added the AC directive in the first file I had opened):

$ python3 ./Tools/clinic/clinic.py --force --make --exclude Lib/test/clinic.test.c --srcdir .
Error in file 'Modules/sha1module.c' on line 270:
Nested block comment!
make: *** [Makefile:1055: clinic] Error 1

For now the workaround is to break /* into multiple strings: x = "/" + "*" for instance.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions