summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS4
-rw-r--r--Modules/clinic/binascii.c.h4
-rw-r--r--Modules/posixmodule.c12
-rwxr-xr-xTools/clinic/clinic.py6
4 files changed, 17 insertions, 9 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index dea39bf..43b458b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -882,6 +882,10 @@ Tests
Tools/Demos
-----------
+- Issue #22120: For functions using an unsigned integer return converter,
+ Argument Clinic now generates a cast to that type for the comparison
+ to -1 in the generated code. (This supresses a compilation warning.)
+
- Issue #18974: Tools/scripts/diff.py now uses argparse instead of optparse.
- Issue #21906: Make Tools/scripts/md5sum.py work in Python 3.
diff --git a/Modules/clinic/binascii.c.h b/Modules/clinic/binascii.c.h
index 5247180..6147be9 100644
--- a/Modules/clinic/binascii.c.h
+++ b/Modules/clinic/binascii.c.h
@@ -320,7 +320,7 @@ binascii_crc32(PyModuleDef *module, PyObject *args)
&data, &crc))
goto exit;
_return_value = binascii_crc32_impl(module, &data, crc);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == (unsigned int)-1) && PyErr_Occurred())
goto exit;
return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
@@ -475,4 +475,4 @@ exit:
return return_value;
}
-/*[clinic end generated code: output=68e2bcc6956b6213 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=53cd6b379c745220 input=a9049054013a1b77]*/
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index d953b5c..533d7b4 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -12465,7 +12465,7 @@ os_major(PyModuleDef *module, PyObject *args)
&device))
goto exit;
_return_value = os_major_impl(module, device);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == (unsigned int)-1) && PyErr_Occurred())
goto exit;
return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
@@ -12475,7 +12475,7 @@ exit:
static unsigned int
os_major_impl(PyModuleDef *module, int device)
-/*[clinic end generated code: output=f60d3cc3d5d20325 input=ea48820b7e10d310]*/
+/*[clinic end generated code: output=52e6743300dcf4ad input=ea48820b7e10d310]*/
{
return major(device);
}
@@ -12514,7 +12514,7 @@ os_minor(PyModuleDef *module, PyObject *args)
&device))
goto exit;
_return_value = os_minor_impl(module, device);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == (unsigned int)-1) && PyErr_Occurred())
goto exit;
return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
@@ -12524,7 +12524,7 @@ exit:
static unsigned int
os_minor_impl(PyModuleDef *module, int device)
-/*[clinic end generated code: output=71eca1d5149c2a07 input=089733ebbf9754e8]*/
+/*[clinic end generated code: output=aebe4bd7f455b755 input=089733ebbf9754e8]*/
{
return minor(device);
}
@@ -12565,7 +12565,7 @@ os_makedev(PyModuleDef *module, PyObject *args)
&major, &minor))
goto exit;
_return_value = os_makedev_impl(module, major, minor);
- if ((_return_value == -1) && PyErr_Occurred())
+ if ((_return_value == (unsigned int)-1) && PyErr_Occurred())
goto exit;
return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
@@ -12575,7 +12575,7 @@ exit:
static unsigned int
os_makedev_impl(PyModuleDef *module, int major, int minor)
-/*[clinic end generated code: output=e04dc5723a98cd3b input=f55bf7cffb028a08]*/
+/*[clinic end generated code: output=5cb79d9c9eac58b0 input=f55bf7cffb028a08]*/
{
return makedev(major, minor);
}
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index d15318e..962abdf 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -2865,10 +2865,11 @@ class long_return_converter(CReturnConverter):
type = 'long'
conversion_fn = 'PyLong_FromLong'
cast = ''
+ unsigned_cast = ''
def render(self, function, data):
self.declare(data)
- self.err_occurred_if("_return_value == -1", data)
+ self.err_occurred_if("_return_value == {}-1".format(self.unsigned_cast), data)
data.return_conversion.append(
''.join(('return_value = ', self.conversion_fn, '(', self.cast, '_return_value);\n')))
@@ -2889,10 +2890,12 @@ class init_return_converter(long_return_converter):
class unsigned_long_return_converter(long_return_converter):
type = 'unsigned long'
conversion_fn = 'PyLong_FromUnsignedLong'
+ unsigned_cast = '(unsigned long)'
class unsigned_int_return_converter(unsigned_long_return_converter):
type = 'unsigned int'
cast = '(unsigned long)'
+ unsigned_cast = '(unsigned int)'
class Py_ssize_t_return_converter(long_return_converter):
type = 'Py_ssize_t'
@@ -2901,6 +2904,7 @@ class Py_ssize_t_return_converter(long_return_converter):
class size_t_return_converter(long_return_converter):
type = 'size_t'
conversion_fn = 'PyLong_FromSize_t'
+ unsigned_cast = '(size_t)'
class double_return_converter(CReturnConverter):