Skip to content

Commit 1c2009c

Browse files
committed
Use Argument Clinic correctly
1 parent 684a31a commit 1c2009c

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

Modules/clinic/posixmodule.c.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3111,18 +3111,22 @@ class Py_off_t_return_converter(long_return_converter):
31113111
type = 'Py_off_t'
31123112
conversion_fn = 'PyLong_FromPy_off_t'
31133113
3114-
class path_confname_converter(CConverter):
3114+
class confname_converter(CConverter):
31153115
type="int"
3116-
converter="conv_path_confname"
3116+
converter="conv_confname"
31173117
3118-
class confstr_confname_converter(path_confname_converter):
3119-
converter='conv_confstr_confname'
3118+
def converter_init(self, *, table):
3119+
self.table = table
31203120
3121-
class sysconf_confname_converter(path_confname_converter):
3122-
converter="conv_sysconf_confname"
3121+
def parse_arg(self, argname, displayname, *, limited_capi):
3122+
return self.format_code("""
3123+
if (!{converter}(module, {argname}, &{paramname}, "{table}")) {{{{
3124+
goto exit;
3125+
}}}}
3126+
""", argname=argname, converter=self.converter, table=self.table)
31233127
31243128
[python start generated code]*/
3125-
/*[python end generated code: output=da39a3ee5e6b4b0d input=1860d32584c2a539]*/
3129+
/*[python end generated code: output=da39a3ee5e6b4b0d input=8189d5ae78244626]*/
31263130

31273131
/*[clinic input]
31283132
@@ -13660,7 +13664,7 @@ static struct constdef posix_constants_pathconf[] = {
1366013664
os.fpathconf -> long
1366113665
1366213666
fd: fildes
13663-
name: path_confname
13667+
name: confname(table="pathconf_names")
1366413668
/
1366513669
1366613670
Return the configuration limit name for the file descriptor fd.
@@ -13670,7 +13674,7 @@ If there is no limit, return -1.
1367013674

1367113675
static long
1367213676
os_fpathconf_impl(PyObject *module, int fd, int name)
13673-
/*[clinic end generated code: output=d5b7042425fc3e21 input=5b8d2471cfaae186]*/
13677+
/*[clinic end generated code: output=d5b7042425fc3e21 input=023d44589c9ed6aa]*/
1367413678
{
1367513679
long limit;
1367613680

@@ -13688,7 +13692,7 @@ os_fpathconf_impl(PyObject *module, int fd, int name)
1368813692
/*[clinic input]
1368913693
os.pathconf -> long
1369013694
path: path_t(allow_fd='PATH_HAVE_FPATHCONF')
13691-
name: path_confname
13695+
name: confname(table="pathconf_names")
1369213696
1369313697
Return the configuration limit name for the file or directory path.
1369413698
@@ -13699,7 +13703,7 @@ On some platforms, path may also be specified as an open file descriptor.
1369913703

1370013704
static long
1370113705
os_pathconf_impl(PyObject *module, path_t *path, int name)
13702-
/*[clinic end generated code: output=5bedee35b293a089 input=bc3e2a985af27e5e]*/
13706+
/*[clinic end generated code: output=5bedee35b293a089 input=6f6072f57b10c787]*/
1370313707
{
1370413708
long limit;
1370513709

@@ -13880,15 +13884,15 @@ static struct constdef posix_constants_confstr[] = {
1388013884
/*[clinic input]
1388113885
os.confstr
1388213886
13883-
name: confstr_confname
13887+
name: confname(table="confstr_names")
1388413888
/
1388513889
1388613890
Return a string-valued system configuration variable.
1388713891
[clinic start generated code]*/
1388813892

1388913893
static PyObject *
1389013894
os_confstr_impl(PyObject *module, int name)
13891-
/*[clinic end generated code: output=bfb0b1b1e49b9383 input=18fb4d0567242e65]*/
13895+
/*[clinic end generated code: output=bfb0b1b1e49b9383 input=4c6ffca2837ec959]*/
1389213896
{
1389313897
PyObject *result = NULL;
1389413898
char buffer[255];
@@ -14428,15 +14432,15 @@ static struct constdef posix_constants_sysconf[] = {
1442814432

1442914433
/*[clinic input]
1443014434
os.sysconf -> long
14431-
name: sysconf_confname
14435+
name: confname(table="sysconf_names")
1443214436
/
1443314437
1443414438
Return an integer-valued system configuration variable.
1443514439
[clinic start generated code]*/
1443614440

1443714441
static long
1443814442
os_sysconf_impl(PyObject *module, int name)
14439-
/*[clinic end generated code: output=3662f945fc0cc756 input=279e3430a33f29e4]*/
14443+
/*[clinic end generated code: output=3662f945fc0cc756 input=930b8f23b5d15086]*/
1444014444
{
1444114445
long value;
1444214446

0 commit comments

Comments
 (0)