Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument Clinic generates weird error messages for incorrectly formatted clinic code #92256

Closed
erlend-aasland opened this issue May 3, 2022 · 2 comments
Assignees
Labels
topic-argument-clinic type-bug An unexpected behavior, bug, or error

Comments

@erlend-aasland
Copy link
Contributor

While reviewing a PR, @ambv and I stumbled over some weird AC error messages. After many frustrating minutes, we found that a single before [clinic start generated code] generated error messages other places in the code.

Reproducers

Repro 1, add indent to clinic module and class declaration. The change is in line 35, but clinic.py complains about line 71.

$ git diff
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 0e903ade5b..5c1f2d4d87 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -32,7 +32,7 @@
 /*[clinic input]
 module _sqlite3
 class _sqlite3.Cursor "pysqlite_Cursor *" "clinic_state()->CursorType"
-[clinic start generated code]*/
+ [clinic start generated code]*/
 /*[clinic end generated code: output=da39a3ee5e6b4b0d input=3c5b8115c5cf30f1]*/
 
 /*
$ python3.11 Tools/clinic/clinic.py -f Modules/_sqlite/cursor.c
Error in file "Modules/_sqlite/cursor.c" on line 71:
Illegal function name: [clinic start generated code]*/

Repro 2, add indent to method clinic spec. The change is in line 66, but clinic.py complains about line 733.

$ git diff                                                     
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 0e903ade5b..e936e4c00a 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -63,7 +63,7 @@ _sqlite3.Cursor.__init__ as pysqlite_cursor_init
     connection: object(type='pysqlite_Connection *', subclass_of='clinic_state()->ConnectionType')
     /
 
-[clinic start generated code]*/
+ [clinic start generated code]*/
 
 static int
 pysqlite_cursor_init_impl(pysqlite_Cursor *self,
$ python3.11 Tools/clinic/clinic.py -f Modules/_sqlite/cursor.c
Error in file "Modules/_sqlite/cursor.c" on line 733:
Illegal outdent.
@erlend-aasland erlend-aasland added type-bug An unexpected behavior, bug, or error topic-argument-clinic labels May 3, 2022
@erlend-aasland erlend-aasland self-assigned this May 3, 2022
@erlend-aasland
Copy link
Contributor Author

Either we allow whitespace before the end "tag", or we disallow it. The former makes for the easiest fix. Any preferences before I propose a PR, @ambv, @serhiy-storchaka, @larryhastings?

erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue May 3, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 10, 2022
…GH-92268)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 4bd07d1)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 10, 2022
…GH-92268)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 4bd07d1)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 10, 2022
…GH-92268)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 4bd07d1)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
erlend-aasland added a commit that referenced this issue May 10, 2022
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
miss-islington added a commit that referenced this issue May 10, 2022
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 4bd07d1)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
miss-islington added a commit that referenced this issue May 10, 2022
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 4bd07d1)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
miss-islington added a commit that referenced this issue May 10, 2022
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 4bd07d1)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
hello-adam pushed a commit to hello-adam/cpython that referenced this issue Jun 2, 2022
…GH-92268)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 4bd07d1)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-argument-clinic type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant