Skip to content

Commit 68ecdf3

Browse files
committed
Fix C23 warning
Fix the compiler warning: {'file': 'Objects/floatobject.c', 'line': '174', 'column': '5', 'message': 'label followed by a declaration is a C23 extension', 'option': '-Wc23-extensions'}
1 parent 32674ae commit 68ecdf3

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

Objects/floatobject.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,23 @@ float_from_string_inner(const char *s, Py_ssize_t len, void *data)
171171
}
172172

173173
error:
174-
PyObject *obj = (PyObject*)data;
175-
if (obj == NULL) {
176-
obj = PyBytes_FromStringAndSize(orig_s, len);
174+
// Label followed by a declaration is a C23 extension, so use a sub-scope
175+
{
176+
PyObject *obj = (PyObject*)data;
177177
if (obj == NULL) {
178-
return NULL;
178+
obj = PyBytes_FromStringAndSize(orig_s, len);
179+
if (obj == NULL) {
180+
return NULL;
181+
}
179182
}
183+
else {
184+
Py_INCREF(obj);
185+
}
186+
PyErr_Format(PyExc_ValueError,
187+
"could not convert string to float: "
188+
"%R", obj);
189+
Py_DECREF(obj);
180190
}
181-
else {
182-
Py_INCREF(obj);
183-
}
184-
PyErr_Format(PyExc_ValueError,
185-
"could not convert string to float: "
186-
"%R", obj);
187-
Py_DECREF(obj);
188191
return NULL;
189192
}
190193

0 commit comments

Comments
 (0)