summaryrefslogtreecommitdiffstats
path: root/Modules/_zoneinfo.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-12-16 15:26:15 (GMT)
committerGitHub <noreply@github.com>2020-12-16 15:26:15 (GMT)
commitaefb69b23f056c61e82ad228d950f348de090c70 (patch)
treea34be085ccf5725193707099e29b19e287104d15 /Modules/_zoneinfo.c
parent37caeb172b1d51340c1b0db9c4c75f138bda6537 (diff)
downloadcpython-aefb69b23f056c61e82ad228d950f348de090c70.zip
cpython-aefb69b23f056c61e82ad228d950f348de090c70.tar.gz
cpython-aefb69b23f056c61e82ad228d950f348de090c70.tar.bz2
bpo-40686: Fix compiler warnings on _zoneinfo.c (GH-23614)
"uint8_t day" is unsigned and so "day < 0" test is always true. Remove the test to fix the following warnings on Windows: modules\_zoneinfo.c(1224): warning C4068: unknown pragma modules\_zoneinfo.c(1225): warning C4068: unknown pragma modules\_zoneinfo.c(1227): warning C4068: unknown pragma
Diffstat (limited to 'Modules/_zoneinfo.c')
-rw-r--r--Modules/_zoneinfo.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c
index 7888cf8..bb32b14 100644
--- a/Modules/_zoneinfo.c
+++ b/Modules/_zoneinfo.c
@@ -172,7 +172,7 @@ static void
update_strong_cache(const PyTypeObject *const type, PyObject *key,
PyObject *zone);
static PyObject *
-zone_from_strong_cache(const PyTypeObject *const type, PyObject *key);
+zone_from_strong_cache(const PyTypeObject *const type, PyObject *const key);
static PyObject *
zoneinfo_new_instance(PyTypeObject *type, PyObject *key)
@@ -1214,15 +1214,9 @@ calendarrule_new(uint8_t month, uint8_t week, uint8_t day, int8_t hour,
return -1;
}
- // day is an unsigned integer, so day < 0 should always return false, but
- // if day's type changes to a signed integer *without* changing this value,
- // it may create a bug. Considering that the compiler should be able to
- // optimize out the first comparison if day is an unsigned integer anyway,
- // we will leave this comparison in place and disable the compiler warning.
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wtype-limits"
- if (day < 0 || day > 6) {
-#pragma GCC diagnostic pop
+ // If the 'day' parameter type is changed to a signed type,
+ // "day < 0" check must be added.
+ if (/* day < 0 || */ day > 6) {
PyErr_Format(PyExc_ValueError, "Day must be in [0, 6]");
return -1;
}