https://github.com/python/cpython/commit/eba2a21ea6928df515e400b9e5d61ebd23ec512b
commit: eba2a21ea6928df515e400b9e5d61ebd23ec512b
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-11-08T20:37:57+01:00
summary:
gh-161625: Fix compiler warnings in 32-bit mode (#161631)
Fix warnigs:
* Include/internal/pycore_global_objects_fini.h:45:51: warning:
comparison of integer expressions of different signedness:
'digit' {aka 'unsigned int'} and 'long int' [-Wsign-compare]
* Modules/_testlimitedcapi/heaptype_relative.c:71:28: warning: cast
from pointer to integer of different size [-Wpointer-to-int-cast]
* Objects/moduleobject.c:412:38: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
* Objects/moduleobject.c:474:44: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
* Python/getopt.c:163:49: warning: format '%lc' expects argument of
type 'wint_t', but argument 3 has type 'wchar_t' {aka 'long int'}
[-Wformat=]
* Python/getopt.c:177:55: warning: format '%lc' expects argument of
type 'wint_t', but argument 3 has type 'wchar_t' {aka 'long int'}
[-Wformat=]
In getopt.c, pass wint_t instead of wchar_t to printf("%lc").
files:
M Include/internal/pycore_global_objects_fini.h
M Modules/_testlimitedcapi/heaptype_relative.c
M Objects/moduleobject.c
M Python/getopt.c
diff --git a/Include/internal/pycore_global_objects_fini.h
b/Include/internal/pycore_global_objects_fini.h
index ee3a593db37b69e..41bc2c5d8fb1405 100644
--- a/Include/internal/pycore_global_objects_fini.h
+++ b/Include/internal/pycore_global_objects_fini.h
@@ -42,7 +42,7 @@ _PyStaticObject_CheckLongSingleton(PyObject *obj, long value,
int is_bool)
lv_tag |= IMMORTALITY_BIT_MASK;
}
_PyObject_ASSERT(obj, long_value->lv_tag == lv_tag);
- _PyObject_ASSERT(obj, long_value->ob_digit[0] == Py_ABS(value));
+ _PyObject_ASSERT(obj, long_value->ob_digit[0] == (digit)Py_ABS(value));
}
diff --git a/Modules/_testlimitedcapi/heaptype_relative.c
b/Modules/_testlimitedcapi/heaptype_relative.c
index a5e15026f028ca7..f21ca9250ed2666 100644
--- a/Modules/_testlimitedcapi/heaptype_relative.c
+++ b/Modules/_testlimitedcapi/heaptype_relative.c
@@ -68,7 +68,7 @@ make_sized_heaptypes(PyObject *module, PyObject *args)
}
result = Py_BuildValue("OOOKnn", base, sub, instance,
- (unsigned long long)data_ptr,
+ (unsigned long long)(uintptr_t)data_ptr,
(Py_ssize_t)(data_ptr - (char*)instance),
data_size);
finally:
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 7c842f3ed8b1965..568711149a8aeb6 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -409,7 +409,7 @@ module_from_slots_and_spec(
createfunc_t create = NULL;
PyObject *nameobj;
PyObject *m = NULL;
- uint64_t multiple_interpreters =
(uint64_t)Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED;
+ uint64_t multiple_interpreters =
(uint64_t)(uintptr_t)Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED;
bool requires_gil = true;
const char *name;
int ret;
@@ -471,7 +471,7 @@ module_from_slots_and_spec(
case Py_mod_gil:
{
uint64_t val = it.current.sl_uint64;
- requires_gil = (val != (uint64_t)Py_MOD_GIL_NOT_USED);
+ requires_gil = (val !=
(uint64_t)(uintptr_t)Py_MOD_GIL_NOT_USED);
}
break;
case Py_mod_abi:
diff --git a/Python/getopt.c b/Python/getopt.c
index f6a3ef960a4021b..c64d6e65c2740ad 100644
--- a/Python/getopt.c
+++ b/Python/getopt.c
@@ -160,7 +160,7 @@ _PyOS_GetOpt(struct _PyOS_GetOpt *getopt)
wchar_t *ptr = wcschr(SHORT_OPTS, option);
if (ptr == NULL) {
if (error) {
- fprintf(stderr, "Invalid option '-%lc'\n", option);
+ fprintf(stderr, "Invalid option '-%lc'\n", (wint_t)option);
}
return '_';
}
@@ -174,7 +174,7 @@ _PyOS_GetOpt(struct _PyOS_GetOpt *getopt)
if (getopt->index >= argc) {
if (error) {
fprintf(stderr,
- "Argument expected for the -%lc option\n", option);
+ "Argument expected for the -%lc option\n",
(wint_t)option);
}
return '_';
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]