Skip to content

Commit bf96d06

Browse files
committed
fixed issue of a label at the end of a compound statment; revert to using PyNumber_AsSsize_t; fixed indentation
1 parent 4e1e3e6 commit bf96d06

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Objects/bytesobject.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,15 +2826,13 @@ _PyBytes_FromSequence(PyObject *x)
28262826
Py_DECREF(bytes);
28272827
/* Py_None as a fallback sentinel to the slow path */
28282828
bytes = Py_None;
2829-
goto done;
2829+
goto done;
28302830
}
2831-
int overflow;
2832-
long value = PyLong_AsLongAndOverflow(items[i], &overflow);
2831+
Py_ssize_t value = PyNumber_AsSsize_t(items[i], NULL);
28332832
if (value == -1 && PyErr_Occurred()) {
28342833
goto error;
28352834
}
28362835
if (value < 0 || value >= 256) {
2837-
/* this includes an overflow in converting to C long */
28382836
PyErr_SetString(PyExc_ValueError,
28392837
"bytes must be in range(0, 256)");
28402838
goto error;
@@ -2846,6 +2844,10 @@ _PyBytes_FromSequence(PyObject *x)
28462844
Py_DECREF(bytes);
28472845
bytes = NULL;
28482846
done:
2847+
/* some C parsers require a label not to be at the end of a compound
2848+
statement, which the ending macro of a critical section introduces, so
2849+
we need an empty statement here to satisfy that syntax rule */
2850+
;
28492851
/* both success and failure need to end the critical section */
28502852
Py_END_CRITICAL_SECTION_SEQUENCE_FAST();
28512853
return bytes;

0 commit comments

Comments
 (0)