Skip to content

Commit 64aa681

Browse files
committed
tabs -> space & misc refactor
1 parent 77d625e commit 64aa681

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

Lib/test/clinic.test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ test_Py_ssize_t_converter(PyObject *module, PyObject *const *args, Py_ssize_t na
17011701
d = ival;
17021702
if (d < 0) {
17031703
PyErr_SetString(PyExc_ValueError,
1704-
"d must be at least 0");
1704+
"d cannot be negative");
17051705
goto exit;
17061706
}
17071707
}
@@ -1743,7 +1743,7 @@ static PyObject *
17431743
test_Py_ssize_t_converter_impl(PyObject *module, Py_ssize_t a, Py_ssize_t b,
17441744
Py_ssize_t c, Py_ssize_t d, Py_ssize_t e,
17451745
Py_ssize_t f, Py_ssize_t g)
1746-
/*[clinic end generated code: output=41297dd17ad0458d input=a25bac8ecf2890aa]*/
1746+
/*[clinic end generated code: output=4ae0a56a1447fba9 input=a25bac8ecf2890aa]*/
17471747

17481748

17491749
/*[clinic input]

Modules/clinic/_testclinic.c.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/modsupport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ _Py_convert_optional_to_non_negative_ssize_t(PyObject *obj, void *result)
4040
return 0;
4141
}
4242
if (obj != Py_None && *((Py_ssize_t *)result) < 0) {
43-
PyErr_SetString(PyExc_ValueError, "argument must be at least 0");
44-
return 0;
43+
PyErr_SetString(PyExc_ValueError, "argument cannot be negative");
44+
return 0;
4545
}
4646
return 1;
4747
}

Tools/clinic/libclinic/converters.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ class Py_ssize_t_converter(CConverter):
420420
type = 'Py_ssize_t'
421421
c_ignored_default = "0"
422422

423-
def converter_init(self, *, accept: TypeSet = {int}, allow_negative: bool = True) -> None:
423+
def converter_init(self, *, accept: TypeSet = {int},
424+
allow_negative: bool = True) -> None:
424425
self.allow_negative = allow_negative
425426
if accept == {int}:
426427
self.format_unit = 'n'
@@ -442,15 +443,16 @@ def use_converter(self) -> None:
442443

443444
def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> str | None:
444445
if self.allow_negative:
445-
non_negative_check = ""
446+
non_negative_check = ''
446447
else:
447448
non_negative_check = self.format_code("""
448449
if ({paramname} < 0) {{{{
449450
PyErr_SetString(PyExc_ValueError,
450-
"{paramname} must be at least 0");
451+
"{paramname} cannot be negative");
451452
goto exit;
452453
}}}}""",
453-
argname=argname)
454+
argname=argname,
455+
)
454456
if self.format_unit == 'n':
455457
if limited_capi:
456458
PyNumber_Index = 'PyNumber_Index'
@@ -473,7 +475,8 @@ def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> st
473475
""",
474476
argname=argname,
475477
PyNumber_Index=PyNumber_Index,
476-
non_negative_check=non_negative_check)
478+
non_negative_check=non_negative_check,
479+
)
477480
if not limited_capi:
478481
return super().parse_arg(argname, displayname, limited_capi=limited_capi)
479482
return self.format_code("""
@@ -492,7 +495,7 @@ def parse_arg(self, argname: str, displayname: str, *, limited_capi: bool) -> st
492495
""",
493496
argname=argname,
494497
bad_argument=self.bad_argument(displayname, 'integer or None', limited_capi=limited_capi),
495-
non_negative_check=non_negative_check
498+
non_negative_check=non_negative_check,
496499
)
497500

498501

0 commit comments

Comments
 (0)