summaryrefslogtreecommitdiffstats
path: root/PC
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-09-03 14:28:14 (GMT)
committerGitHub <noreply@github.com>2023-09-03 14:28:14 (GMT)
commit1796c191b43ed0787d83c07be7de8118fb10e8b0 (patch)
treea49fc1fa54d8d6a375516f6e6d1cd6648caf5a78 /PC
parent55846099b155833320bc6d64b03d902028bad439 (diff)
downloadcpython-1796c191b43ed0787d83c07be7de8118fb10e8b0.zip
cpython-1796c191b43ed0787d83c07be7de8118fb10e8b0.tar.gz
cpython-1796c191b43ed0787d83c07be7de8118fb10e8b0.tar.bz2
gh-108494: Argument Clinic: inline parsing code for positional-only parameters in the limited C API (GH-108622)
Diffstat (limited to 'PC')
-rw-r--r--PC/msvcrtmodule.c9
-rw-r--r--PC/winreg.c18
2 files changed, 15 insertions, 12 deletions
diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c
index afc810a..d7c2176 100644
--- a/PC/msvcrtmodule.c
+++ b/PC/msvcrtmodule.c
@@ -38,13 +38,14 @@ class HANDLE_converter(CConverter):
type = 'void *'
format_unit = '"_Py_PARSE_UINTPTR"'
- def parse_arg(self, argname, displayname):
- return """
+ def parse_arg(self, argname, displayname, *, limited_capi):
+ return self.format_code("""
{paramname} = PyLong_AsVoidPtr({argname});
if (!{paramname} && PyErr_Occurred()) {{{{
goto exit;
}}}}
- """.format(argname=argname, paramname=self.parser_name)
+ """,
+ argname=argname)
class HANDLE_return_converter(CReturnConverter):
type = 'void *'
@@ -74,7 +75,7 @@ class wchar_t_return_converter(CReturnConverter):
data.return_conversion.append(
'return_value = PyUnicode_FromOrdinal(_return_value);\n')
[python start generated code]*/
-/*[python end generated code: output=da39a3ee5e6b4b0d input=1e8e9fa3538ec08f]*/
+/*[python end generated code: output=da39a3ee5e6b4b0d input=ff031be44ab3250d]*/
/*[clinic input]
module msvcrt
diff --git a/PC/winreg.c b/PC/winreg.c
index 767127d..77b8021 100644
--- a/PC/winreg.c
+++ b/PC/winreg.c
@@ -222,13 +222,15 @@ class HKEY_converter(CConverter):
converter = 'clinic_HKEY_converter'
broken_limited_capi = True
- def parse_arg(self, argname, displayname):
- return """
- if (!{converter}(_PyModule_GetState(module), {argname}, &{paramname})) {{{{
- goto exit;
- }}}}
- """.format(argname=argname, paramname=self.parser_name,
- converter=self.converter)
+ def parse_arg(self, argname, displayname, *, limited_capi):
+ assert not limited_capi
+ return self.format_code("""
+ if (!{converter}(_PyModule_GetState(module), {argname}, &{paramname})) {{{{
+ goto exit;
+ }}}}
+ """,
+ argname=argname,
+ converter=self.converter)
class HKEY_return_converter(CReturnConverter):
type = 'HKEY'
@@ -250,7 +252,7 @@ class self_return_converter(CReturnConverter):
data.return_conversion.append(
'return_value = (PyObject *)_return_value;\n')
[python start generated code]*/
-/*[python end generated code: output=da39a3ee5e6b4b0d input=f8cb7034338aeaba]*/
+/*[python end generated code: output=da39a3ee5e6b4b0d input=4979f33998ffb6f8]*/
#include "clinic/winreg.c.h"