Skip to content

Commit

Permalink
pythongh-110964: clinic: pass clinic argument to bad_argument()
Browse files Browse the repository at this point in the history
Don't rely on the global 'clinic' argument: pass explicitly a
'clinic' argument.
  • Loading branch information
vstinner committed Oct 18, 2023
1 parent cb1bf89 commit 26db3ea
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 88 deletions.
4 changes: 2 additions & 2 deletions Modules/_multiprocessing/multiprocessing.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class HANDLE_converter(CConverter):
type = "HANDLE"
format_unit = '"F_HANDLE"'
def parse_arg(self, argname, displayname, *, limited_capi):
def parse_arg(self, argname, displayname, *, clinic, limited_capi):
return self.format_code("""
{paramname} = PyLong_AsVoidPtr({argname});
if (!{paramname} && PyErr_Occurred()) {{{{
Expand All @@ -24,7 +24,7 @@ class HANDLE_converter(CConverter):
argname=argname)
[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=3cf0318efc6a8772]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=256fe1883e186bbe]*/

/*[clinic input]
module _multiprocessing
Expand Down
4 changes: 2 additions & 2 deletions Modules/_posixsubprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class pid_t_converter(CConverter):
type = 'pid_t'
format_unit = '" _Py_PARSE_PID "'
def parse_arg(self, argname, displayname, *, limited_capi):
def parse_arg(self, argname, displayname, *, clinic, limited_capi):
return self.format_code("""
{paramname} = PyLong_AsPid({argname});
if ({paramname} == -1 && PyErr_Occurred()) {{{{
Expand All @@ -96,7 +96,7 @@ class pid_t_converter(CConverter):
""",
argname=argname)
[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=c94349aa1aad151d]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=b582c628f43ebe2a]*/

#include "clinic/_posixsubprocess.c.h"

Expand Down
4 changes: 2 additions & 2 deletions Modules/_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class cache_struct_converter(CConverter):
c_default = "NULL"
broken_limited_capi = True
def parse_arg(self, argname, displayname, *, limited_capi):
def parse_arg(self, argname, displayname, *, clinic, limited_capi):
assert not limited_capi
return self.format_code("""
if (!{converter}(module, {argname}, &{paramname})) {{{{
Expand All @@ -122,7 +122,7 @@ class cache_struct_converter(CConverter):
def cleanup(self):
return "Py_XDECREF(%s);\n" % self.name
[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=c33b27d6b06006c6]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=06483ea83abe39fb]*/

static int cache_struct_converter(PyObject *, PyObject *, PyStructObject **);

Expand Down
6 changes: 3 additions & 3 deletions Modules/overlapped.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
class pointer_converter(CConverter):
format_unit = '"F_POINTER"'
def parse_arg(self, argname, displayname, *, limited_capi):
def parse_arg(self, argname, displayname, *, clinic, limited_capi):
return self.format_code("""
{paramname} = PyLong_AsVoidPtr({argname});
if (!{paramname} && PyErr_Occurred()) {{{{
Expand All @@ -56,7 +56,7 @@ class HANDLE_converter(pointer_converter):
class ULONG_PTR_converter(pointer_converter):
type = 'ULONG_PTR'
def parse_arg(self, argname, displayname, *, limited_capi):
def parse_arg(self, argname, displayname, *, clinic, limited_capi):
return self.format_code("""
{paramname} = (uintptr_t)PyLong_AsVoidPtr({argname});
if (!{paramname} && PyErr_Occurred()) {{{{
Expand All @@ -71,7 +71,7 @@ class DWORD_converter(unsigned_long_converter):
class BOOL_converter(int_converter):
type = 'BOOL'
[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=436f4440630a304c]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=422287c842b7eba8]*/

/*[clinic input]
module _overlapped
Expand Down
4 changes: 2 additions & 2 deletions Modules/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class pid_t_converter(CConverter):
type = 'pid_t'
format_unit = '" _Py_PARSE_PID "'
def parse_arg(self, argname, displayname, *, limited_capi):
def parse_arg(self, argname, displayname, *, clinic, limited_capi):
return self.format_code("""
{paramname} = PyLong_AsPid({argname});
if ({paramname} == -1 && PyErr_Occurred()) {{{{
Expand All @@ -35,7 +35,7 @@ class pid_t_converter(CConverter):
""",
argname=argname)
[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=c94349aa1aad151d]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=b582c628f43ebe2a]*/

#include "clinic/resource.c.h"

Expand Down
4 changes: 2 additions & 2 deletions PC/_testconsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class HANDLE_converter(CConverter):
type = 'void *'
format_unit = '"_Py_PARSE_UINTPTR"'
def parse_arg(self, argname, displayname, *, limited_capi):
def parse_arg(self, argname, displayname, *, clinic, limited_capi):
return self.format_code("""
{paramname} = PyLong_AsVoidPtr({argname});
if (!{paramname} && PyErr_Occurred()) {{{{
Expand All @@ -49,7 +49,7 @@ class HANDLE_converter(CConverter):
""",
argname=argname)
[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=380aa5c91076742b]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=6519570cd567ce54]*/
/*[python end generated code:]*/

/*[clinic input]
Expand Down
4 changes: 2 additions & 2 deletions PC/msvcrtmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class HANDLE_converter(CConverter):
type = 'void *'
format_unit = '"_Py_PARSE_UINTPTR"'
def parse_arg(self, argname, displayname, *, limited_capi):
def parse_arg(self, argname, displayname, *, clinic, limited_capi):
return self.format_code("""
{paramname} = PyLong_AsVoidPtr({argname});
if (!{paramname} && PyErr_Occurred()) {{{{
Expand Down Expand Up @@ -75,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=ff031be44ab3250d]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=6cfb201e0745c7f7]*/

/*[clinic input]
module msvcrt
Expand Down
4 changes: 2 additions & 2 deletions PC/winreg.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class HKEY_converter(CConverter):
converter = 'clinic_HKEY_converter'
broken_limited_capi = True
def parse_arg(self, argname, displayname, *, limited_capi):
def parse_arg(self, argname, displayname, *, clinic, limited_capi):
assert not limited_capi
return self.format_code("""
if (!{converter}(_PyModule_GetState(module), {argname}, &{paramname})) {{{{
Expand Down Expand Up @@ -252,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=4979f33998ffb6f8]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=5d9a391867dbe35a]*/

#include "clinic/winreg.c.h"

Expand Down
Loading

0 comments on commit 26db3ea

Please sign in to comment.