File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed
Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -2898,16 +2898,13 @@ _PyBytes_FromSequence_lock_held(PyObject *x)
28982898
28992899 PyObject * const * items = PySequence_Fast_ITEMS (x );
29002900 for (Py_ssize_t i = 0 ; i < size ; i ++ ) {
2901- if (!PyLong_Check (items [i ])) {
2901+ Py_ssize_t value = PyLong_AsSsize_t (items [i ]);
2902+ if (value == -1 && PyErr_Occurred ()) {
29022903 PyBytesWriter_Discard (writer );
2904+ PyErr_Clear ();
29032905 /* Py_None as a fallback sentinel to the slow path */
29042906 Py_RETURN_NONE ;
29052907 }
2906- Py_ssize_t value = PyNumber_AsSsize_t (items [i ], NULL );
2907- if (value == -1 && PyErr_Occurred ()) {
2908- PyBytesWriter_Discard (writer );
2909- return NULL ;
2910- }
29112908
29122909 if (value < 0 || value >= 256 ) {
29132910 PyErr_SetString (PyExc_ValueError ,
You can’t perform that action at this time.
0 commit comments