-
-
Notifications
You must be signed in to change notification settings - Fork 30k
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
gh-92256: Improve Argument Clinic parser error messages #92268
Conversation
(I'm not sure this needs a NEWS item, but I'm happy to add one.) |
Details: - Behaviour pre this changeWhitespace before end line (disallowed with confusing error message): $ 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]*/ Whitespace after end line (allowed): $ git diff
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 0e903ade5b..958891b995 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]*/
/*
$ !py
python3.11 Tools/clinic/clinic.py -f Modules/_sqlite/cursor.c
$ Garbage after end line (fails badly): $ git diff
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 0e903ade5b..8df423fc80 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]*/ // this won't work
/*[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:
Exception raised during parsing:
Traceback (most recent call last):
File "/Users/erlendaasland/src/cpython.git/Tools/clinic/clinic.py", line 2025, in parse
parser.parse(block)
^^^^^^^^^^^^^^^^^^^
File "/Users/erlendaasland/src/cpython.git/Tools/clinic/clinic.py", line 4176, in parse
self.state(line)
^^^^^^^^^^^^^^^^
File "/Users/erlendaasland/src/cpython.git/Tools/clinic/clinic.py", line 4217, in state_dsl_start
fields = shlex.split(line)
^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shlex.py", line 315, in split
return list(lex)
^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shlex.py", line 300, in __next__
token = self.get_token()
^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shlex.py", line 109, in get_token
raw = self.read_token()
^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shlex.py", line 191, in read_token
raise ValueError("No closing quotation")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: No closing quotation - Behaviour post this changeWhitespace before end line (currently disallowed): $ 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 35:
Whitespace is not allowed before the stop line Whitespace after end line (allowed): $ git diff
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 0e903ade5b..8e4889f162 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 Garbage after end line (disallowed): $ git diff
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index 0e903ade5b..8df423fc80 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]*/ // this won't work
/*[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 35:
Garbage after stop line: '// this won't work' |
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Thanks for the reviews and suggestions, Serhiy and Victor; highly appreciated. |
BTW, I guess we should backport this through 3.9. |
It is an internal tool. No NEWS entry is needed. The change is invisible for users. |
I'll remove the NEWS entry; thanks again. |
Serhiy and Victor have approved this change. I'll land this in a day or two. |
Thanks @erlend-aasland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10, 3.11. |
GH-92614 is a backport of this pull request to the 3.11 branch. |
GH-92615 is a backport of this pull request to the 3.10 branch. |
GH-92616 is a backport of this pull request to the 3.9 branch. |
No description provided.