summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend@python.org>2023-08-15 14:41:40 (GMT)
committerGitHub <noreply@github.com>2023-08-15 14:41:40 (GMT)
commit607f18c89456cdc9064e27f86a7505e011209757 (patch)
treef713e2df9091e0eb7c041d8b89b0b14fbf9664f0 /Tools
parente90036c9bdf25621c15207a9cabd119fb5366c27 (diff)
downloadcpython-607f18c89456cdc9064e27f86a7505e011209757.zip
cpython-607f18c89456cdc9064e27f86a7505e011209757.tar.gz
cpython-607f18c89456cdc9064e27f86a7505e011209757.tar.bz2
gh-107972: Argument Clinic: Ensure a C basename is provided after 'as' (#107973)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/clinic/clinic.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 11dbfb3..6ff2622 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -4879,9 +4879,11 @@ class DSLParser:
before, equals, existing = line.rpartition('=')
c_basename: str | None
if equals:
- full_name, _, c_basename = before.partition(' as ')
+ full_name, as_, c_basename = before.partition(' as ')
full_name = full_name.strip()
c_basename = c_basename.strip()
+ if as_ and not c_basename:
+ fail("No C basename provided after 'as' keyword")
existing = existing.strip()
if (is_legal_py_identifier(full_name) and
(not c_basename or is_legal_c_identifier(c_basename)) and
@@ -4932,10 +4934,11 @@ class DSLParser:
line, _, returns = line.partition('->')
returns = returns.strip()
- full_name, _, c_basename = line.partition(' as ')
+ full_name, as_, c_basename = line.partition(' as ')
full_name = full_name.strip()
c_basename = c_basename.strip() or None
-
+ if as_ and not c_basename:
+ fail("No C basename provided after 'as' keyword")
if not is_legal_py_identifier(full_name):
fail(f"Illegal function name: {full_name!r}")
if c_basename and not is_legal_c_identifier(c_basename):