8000 gh-118201: Simplify conv_confname by mhsmith · Pull Request #126089 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-118201: Simplify conv_confname #126089

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

Merged
merged 6 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use Argument Clinic correctly
  • Loading branch information
mhsmith committed Oct 28, 2024
commit 1c2009c6796d8199336e5f0ceaaa77dcafbe4314
2 changes: 1 addition & 1 deletion Modules/clinic/posixmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 19 additions & 15 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3111,18 +3111,22 @@ class Py_off_t_return_converter(long_return_converter):
type = 'Py_off_t'
conversion_fn = 'PyLong_FromPy_off_t'

class path_confname_converter(CConverter):
class confname_converter(CConverter):
type="int"
converter="conv_path_confname"
converter="conv_confname"

class confstr_confname_converter(path_confname_converter):
converter='conv_confstr_confname'
def converter_init(self, *, table):
self.table = table

class sysconf_confname_converter(path_confname_converter):
converter="conv_sysconf_confname"
def parse_arg(self, argname, displayname, *, limited_capi):
return self.format_code("""
if (!{converter}(module, {argname}, &{paramname}, "{table}")) {{{{
goto exit;
}}}}
""", argname=argname, converter=self.converter, table=self.table)

[python start generated code]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=1860d32584c2a539]*/
/*[python end generated code: output=da39a3ee5e6b4b0d input=8189d5ae78244626]*/

/*[clinic input]

Expand Down Expand Up @@ -13660,7 +13664,7 @@ static struct constdef posix_constants_pathconf[] = {
os.fpathconf -> long

fd: fildes
name: path_confname
name: confname(table="pathconf_names")
/

Return the configuration limit name for the file descriptor fd.
Expand All @@ -13670,7 +13674,7 @@ If there is no limit, return -1.

static long
os_fpathconf_impl(PyObject *module, int fd, int name)
/*[clinic end generated code: output=d5b7042425fc3e21 input=5b8d2471cfaae186]*/
/*[clinic end generated code: output=d5b7042425fc3e21 input=023d44589c9ed6aa]*/
{
long limit;

Expand All @@ -13688,7 +13692,7 @@ os_fpathconf_impl(PyObject *module, int fd, int name)
/*[clinic input]
os.pathconf -> long
path: path_t(allow_fd='PATH_HAVE_FPATHCONF')
name: path_confname
name: confname(table="pathconf_names")

Return the configuration limit name for the file or directory path.

Expand All @@ -13699,7 +13703,7 @@ On some platforms, path may also be specified as an open file descriptor.

static long
os_pathconf_impl(PyObject *module, path_t *path, int name)
/*[clinic end generated code: output=5bedee35b293a089 input=bc3e2a985af27e5e]*/
/*[clinic end generated code: output=5bedee35b293a089 input=6f6072f57b10c787]*/
{
long limit;

Expand Down Expand Up @@ -13880,15 +13884,15 @@ static struct constdef posix_constants_confstr[] = {
/*[clinic input]
os.confstr

name: confstr_confname
name: confname(table="confstr_names")
/

Return a string-valued system configuration variable.
[clinic start generated code]*/

static PyObject *
os_confstr_impl(PyObject *module, int name)
/*[clinic end generated code: output=bfb0b1b1e49b9383 input=18fb4d0567242e65]*/
/*[clinic end generated code: output=bfb0b1b1e49b9383 input=4c6ffca2837ec959]*/
{
PyObj 860F ect *result = NULL;
char buffer[255];
Expand Down Expand Up @@ -14428,15 +14432,15 @@ static struct constdef posix_constants_sysconf[] = {

/*[clinic input]
os.sysconf -> long
name: sysconf_confname
name: confname(table="sysconf_names")
/

Return an integer-valued system configuration variable.
[clinic start generated code]*/

static long
os_sysconf_impl(PyObject *module, int name)
/*[clinic end generated code: output=3662f945fc0cc756 input=279e3430a33f29e4]*/
/*[clinic end generated code: output=3662f945fc0cc756 input=930b8f23b5d15086]*/
{
long value;

Expand Down
Loading
0